@uniformdev/canvas 16.2.1-alpha.142 → 16.2.1-alpha.320
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2C4YYM6A.mjs +5 -0
- package/dist/cli/cli.d.ts +2 -5
- package/dist/cli/cli.js +59 -59
- package/dist/cli/cli.mjs +59 -59
- package/dist/{createEventBus-97218204.d.ts → createEventBus-97db7eb7.d.ts} +45 -6
- package/dist/{createEventBus-3af5b249.d.ts → createEventBus-da6bed9e.d.ts} +126 -4
- package/dist/index.d.ts +55 -3
- package/dist/index.esm.js +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +1 -1
- package/package.json +8 -8
- package/dist/chunk-N2C6WISR.mjs +0 -5
@@ -215,7 +215,7 @@ interface external$1 {
|
|
215
215
|
/** @description Friendly name of the component definition */
|
216
216
|
name: string;
|
217
217
|
/**
|
218
|
-
* @description Icon name for the component definition (e.g. 'screen')
|
218
|
+
* @description Icon name or URL for the component definition (e.g. 'screen' or 'https://s3/my-component.jpg')
|
219
219
|
* @default screen
|
220
220
|
*/
|
221
221
|
icon?: string;
|
@@ -258,7 +258,10 @@ interface external$1 {
|
|
258
258
|
type: string;
|
259
259
|
binding?: external$1["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["ComponentParameterBinding"];
|
260
260
|
};
|
261
|
-
/**
|
261
|
+
/**
|
262
|
+
* @deprecated
|
263
|
+
* @description Defines a binding from a resource data value to a component parameter value. Do not use.
|
264
|
+
*/
|
262
265
|
ComponentParameterBinding: {
|
263
266
|
/**
|
264
267
|
* @description A JSON Pointer expression that defines the binding directly to the parameter value, or
|
@@ -419,7 +422,7 @@ interface components$1 {
|
|
419
422
|
/** @description Friendly name of the component definition */
|
420
423
|
name: string;
|
421
424
|
/**
|
422
|
-
* @description Icon name for the component definition (e.g. 'screen')
|
425
|
+
* @description Icon name or URL for the component definition (e.g. 'screen' or 'https://s3/my-component.jpg')
|
423
426
|
* @default screen
|
424
427
|
*/
|
425
428
|
icon?: string;
|
@@ -460,6 +463,32 @@ interface components$1 {
|
|
460
463
|
value: unknown;
|
461
464
|
/** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
|
462
465
|
type: string;
|
466
|
+
binding?: components$1["schemas"]["ComponentParameterBinding"];
|
467
|
+
};
|
468
|
+
/**
|
469
|
+
* @deprecated
|
470
|
+
* @description Defines a binding from a resource data value to a component parameter value. Do not use.
|
471
|
+
*/
|
472
|
+
ComponentParameterBinding: {
|
473
|
+
/**
|
474
|
+
* @description A JSON Pointer expression that defines the binding directly to the parameter value, or
|
475
|
+
* a map of JSON Pointers in the target parameter to JSON Pointers in the source resource data.
|
476
|
+
* Used to bind to object-type values.
|
477
|
+
* e.g. { "/prop1/thing": "/res1/things/value" } would set the target parameter's `value` to
|
478
|
+
* {
|
479
|
+
* prop1: {
|
480
|
+
* thing: "value of /res1/things/value resource"
|
481
|
+
* }
|
482
|
+
* }
|
483
|
+
*/
|
484
|
+
pointer: string | {
|
485
|
+
[key: string]: string;
|
486
|
+
};
|
487
|
+
/**
|
488
|
+
* @description The syntax of the binding (currently always 'jptr')
|
489
|
+
* @enum {string}
|
490
|
+
*/
|
491
|
+
syntax: "jptr";
|
463
492
|
};
|
464
493
|
/** @description Defines the shape of a component instance served by the composition API. */
|
465
494
|
ComponentInstance: {
|
@@ -824,7 +853,7 @@ interface external {
|
|
824
853
|
/** @description Friendly name of the component definition */
|
825
854
|
name: string;
|
826
855
|
/**
|
827
|
-
* @description Icon name for the component definition (e.g. 'screen')
|
856
|
+
* @description Icon name or URL for the component definition (e.g. 'screen' or 'https://s3/my-component.jpg')
|
828
857
|
* @default screen
|
829
858
|
*/
|
830
859
|
icon?: string;
|
@@ -867,7 +896,10 @@ interface external {
|
|
867
896
|
type: string;
|
868
897
|
binding?: external["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["ComponentParameterBinding"];
|
869
898
|
};
|
870
|
-
/**
|
899
|
+
/**
|
900
|
+
* @deprecated
|
901
|
+
* @description Defines a binding from a resource data value to a component parameter value. Do not use.
|
902
|
+
*/
|
871
903
|
ComponentParameterBinding: {
|
872
904
|
/**
|
873
905
|
* @description A JSON Pointer expression that defines the binding directly to the parameter value, or
|
@@ -967,6 +999,8 @@ declare type ComponentParameter<TValue = unknown> = Omit<SharedComponents['Compo
|
|
967
999
|
/** The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
|
968
1000
|
value: TValue;
|
969
1001
|
};
|
1002
|
+
/** Defines a binding from a resource data value to a component parameter value. */
|
1003
|
+
declare type ComponentParameterBinding = SharedComponents['ComponentParameterBinding'];
|
970
1004
|
/** Defines the shape of a component instance served by the composition API. */
|
971
1005
|
declare type ComponentInstance = SharedComponents['ComponentInstance'] & {
|
972
1006
|
/** Data for the component instance, provided by a component enhancer. Never set in unenhanced data. */
|
@@ -974,6 +1008,11 @@ declare type ComponentInstance = SharedComponents['ComponentInstance'] & {
|
|
974
1008
|
};
|
975
1009
|
/** Defines the shape of the root component in a composition */
|
976
1010
|
declare type RootComponentInstance = SharedComponents['RootComponentInstance'];
|
1011
|
+
/** Defines single structure to keep all canvas models (used in CLI commands and Starter content generations) */
|
1012
|
+
declare type CanvasDefinitions = {
|
1013
|
+
components?: Array<ComponentDefinition>;
|
1014
|
+
compositions?: Array<CompositionGetResponse>;
|
1015
|
+
};
|
977
1016
|
|
978
1017
|
/**
|
979
1018
|
* Pusher-js is large (80k) and not tree shakable so it is always bundled if directly referenced,
|
@@ -1000,4 +1039,4 @@ declare global {
|
|
1000
1039
|
*/
|
1001
1040
|
declare function createEventBus(): Promise<PreviewEventBus | undefined>;
|
1002
1041
|
|
1003
|
-
export {
|
1042
|
+
export { CanvasDefinitions as A, ChannelSubscription as B, ComponentInstance as C, createEventBus as D, PreviewEventBus as P, RootComponentInstance as R, ComponentParameter as a, CompositionGetParameters as b, CompositionPutParameters as c, CompositionDeleteParameters as d, ComponentDefinitionGetParameters as e, ComponentDefinitionPutParameters as f, ComponentDefinitionDeleteParameters as g, ComponentDefinitionGetResponse as h, ComponentDefinitionAPIResponse as i, ComponentDefinitionAPIPutRequest as j, ComponentDefinitionAPIDeleteRequest as k, ComponentDefinitionListAPIOptions as l, ComponentDefinitionParameter as m, ComponentDefinitionVariant as n, ComponentDefinitionSlugSettings as o, ComponentDefinitionSlot as p, ComponentDefinitionPermission as q, ComponentDefinition as r, CreatingComponentDefinition as s, CompositionGetResponse as t, CompositionGetListResponse as u, CompositionAPIResponse as v, CompositionAPIDeleteRequest as w, CompositionListAPIResponse as x, CompositionAPIOptions as y, ComponentParameterBinding as z };
|
@@ -215,7 +215,7 @@ interface external$1 {
|
|
215
215
|
/** @description Friendly name of the component definition */
|
216
216
|
name: string;
|
217
217
|
/**
|
218
|
-
* @description Icon name for the component definition (e.g. 'screen')
|
218
|
+
* @description Icon name or URL for the component definition (e.g. 'screen' or 'https://s3/my-component.jpg')
|
219
219
|
* @default screen
|
220
220
|
*/
|
221
221
|
icon?: string;
|
@@ -256,6 +256,40 @@ interface external$1 {
|
|
256
256
|
value: unknown;
|
257
257
|
/** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
|
258
258
|
type: string;
|
259
|
+
binding?: external$1["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["ComponentParameterBinding"];
|
260
|
+
};
|
261
|
+
/**
|
262
|
+
* @deprecated
|
263
|
+
* @description Defines a binding from a resource data value to a component parameter value. Do not use.
|
264
|
+
*/
|
265
|
+
ComponentParameterBinding: {
|
266
|
+
/**
|
267
|
+
* @description A JSON Pointer expression that defines the binding directly to the parameter value, or
|
268
|
+
* a map of JSON Pointers in the target parameter to JSON Pointers in the source resource data.
|
269
|
+
* Used to bind to object-type values.
|
270
|
+
* e.g. { "/prop1/thing": "/res1/things/value" } would set the target parameter's `value` to
|
271
|
+
* {
|
272
|
+
* prop1: {
|
273
|
+
* thing: "value of /res1/things/value resource"
|
274
|
+
* }
|
275
|
+
* }
|
276
|
+
*/
|
277
|
+
pointer: string | {
|
278
|
+
[key: string]: string;
|
279
|
+
};
|
280
|
+
/**
|
281
|
+
* @description The syntax of the binding (currently always 'jptr')
|
282
|
+
* @enum {string}
|
283
|
+
*/
|
284
|
+
syntax: "jptr";
|
285
|
+
/**
|
286
|
+
* @description Whether the binding should cause an error if it cannot be resolved.
|
287
|
+
* If true, and the binding cannot be resolved, an error will be returned by the binding process.
|
288
|
+
* If false, and the binding cannot be resolved, the parameter will be removed from the bound composition.
|
289
|
+
*
|
290
|
+
* @default false
|
291
|
+
*/
|
292
|
+
required?: boolean;
|
259
293
|
};
|
260
294
|
/** @description Defines the shape of a component instance served by the composition API. */
|
261
295
|
ComponentInstance: {
|
@@ -396,7 +430,7 @@ interface components$1 {
|
|
396
430
|
/** @description Friendly name of the component definition */
|
397
431
|
name: string;
|
398
432
|
/**
|
399
|
-
* @description Icon name for the component definition (e.g. 'screen')
|
433
|
+
* @description Icon name or URL for the component definition (e.g. 'screen' or 'https://s3/my-component.jpg')
|
400
434
|
* @default screen
|
401
435
|
*/
|
402
436
|
icon?: string;
|
@@ -437,6 +471,32 @@ interface components$1 {
|
|
437
471
|
value: unknown;
|
438
472
|
/** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
|
439
473
|
type: string;
|
474
|
+
binding?: components$1["schemas"]["ComponentParameterBinding"];
|
475
|
+
};
|
476
|
+
/**
|
477
|
+
* @deprecated
|
478
|
+
* @description Defines a binding from a resource data value to a component parameter value. Do not use.
|
479
|
+
*/
|
480
|
+
ComponentParameterBinding: {
|
481
|
+
/**
|
482
|
+
* @description A JSON Pointer expression that defines the binding directly to the parameter value, or
|
483
|
+
* a map of JSON Pointers in the target parameter to JSON Pointers in the source resource data.
|
484
|
+
* Used to bind to object-type values.
|
485
|
+
* e.g. { "/prop1/thing": "/res1/things/value" } would set the target parameter's `value` to
|
486
|
+
* {
|
487
|
+
* prop1: {
|
488
|
+
* thing: "value of /res1/things/value resource"
|
489
|
+
* }
|
490
|
+
* }
|
491
|
+
*/
|
492
|
+
pointer: string | {
|
493
|
+
[key: string]: string;
|
494
|
+
};
|
495
|
+
/**
|
496
|
+
* @description The syntax of the binding (currently always 'jptr')
|
497
|
+
* @enum {string}
|
498
|
+
*/
|
499
|
+
syntax: "jptr";
|
440
500
|
};
|
441
501
|
/** @description Defines the shape of a component instance served by the composition API. */
|
442
502
|
ComponentInstance: {
|
@@ -606,6 +666,7 @@ interface paths {
|
|
606
666
|
* @default false
|
607
667
|
*/
|
608
668
|
pattern?: boolean;
|
669
|
+
resources?: components["schemas"]["CompositionResourceDefinitions"];
|
609
670
|
/** @description Ignored if present */
|
610
671
|
created?: string;
|
611
672
|
/** @description Ignored if present */
|
@@ -668,11 +729,31 @@ interface components {
|
|
668
729
|
modified: string;
|
669
730
|
/** @description Whether this composition is a pattern (can be referenced by other compositions, not treated as a composition) */
|
670
731
|
pattern: boolean;
|
732
|
+
resources?: components["schemas"]["CompositionResourceDefinitions"];
|
671
733
|
composition: external["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["RootComponentInstance"];
|
672
734
|
};
|
673
735
|
CompositionListResponse: {
|
674
736
|
compositions: components["schemas"]["CompositionApiResponse"][];
|
675
737
|
};
|
738
|
+
/**
|
739
|
+
* @deprecated
|
740
|
+
* @description Resource definitions attached to this composition. The property name is the key of the resource in the resource document.
|
741
|
+
*/
|
742
|
+
CompositionResourceDefinitions: {
|
743
|
+
[key: string]: components["schemas"]["CompositionResourceDefinition"];
|
744
|
+
};
|
745
|
+
/**
|
746
|
+
* @deprecated
|
747
|
+
* @description Resource definition attached to this composition
|
748
|
+
*/
|
749
|
+
CompositionResourceDefinition: {
|
750
|
+
/** @description Integration that provides this resource */
|
751
|
+
type: string;
|
752
|
+
/** @description Type-specific data to configure resource */
|
753
|
+
data: {
|
754
|
+
[key: string]: unknown;
|
755
|
+
};
|
756
|
+
};
|
676
757
|
};
|
677
758
|
}
|
678
759
|
interface external {
|
@@ -801,7 +882,7 @@ interface external {
|
|
801
882
|
/** @description Friendly name of the component definition */
|
802
883
|
name: string;
|
803
884
|
/**
|
804
|
-
* @description Icon name for the component definition (e.g. 'screen')
|
885
|
+
* @description Icon name or URL for the component definition (e.g. 'screen' or 'https://s3/my-component.jpg')
|
805
886
|
* @default screen
|
806
887
|
*/
|
807
888
|
icon?: string;
|
@@ -842,6 +923,40 @@ interface external {
|
|
842
923
|
value: unknown;
|
843
924
|
/** @description The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
|
844
925
|
type: string;
|
926
|
+
binding?: external["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["ComponentParameterBinding"];
|
927
|
+
};
|
928
|
+
/**
|
929
|
+
* @deprecated
|
930
|
+
* @description Defines a binding from a resource data value to a component parameter value. Do not use.
|
931
|
+
*/
|
932
|
+
ComponentParameterBinding: {
|
933
|
+
/**
|
934
|
+
* @description A JSON Pointer expression that defines the binding directly to the parameter value, or
|
935
|
+
* a map of JSON Pointers in the target parameter to JSON Pointers in the source resource data.
|
936
|
+
* Used to bind to object-type values.
|
937
|
+
* e.g. { "/prop1/thing": "/res1/things/value" } would set the target parameter's `value` to
|
938
|
+
* {
|
939
|
+
* prop1: {
|
940
|
+
* thing: "value of /res1/things/value resource"
|
941
|
+
* }
|
942
|
+
* }
|
943
|
+
*/
|
944
|
+
pointer: string | {
|
945
|
+
[key: string]: string;
|
946
|
+
};
|
947
|
+
/**
|
948
|
+
* @description The syntax of the binding (currently always 'jptr')
|
949
|
+
* @enum {string}
|
950
|
+
*/
|
951
|
+
syntax: "jptr";
|
952
|
+
/**
|
953
|
+
* @description Whether the binding should cause an error if it cannot be resolved.
|
954
|
+
* If true, and the binding cannot be resolved, an error will be returned by the binding process.
|
955
|
+
* If false, and the binding cannot be resolved, the parameter will be removed from the bound composition.
|
956
|
+
*
|
957
|
+
* @default false
|
958
|
+
*/
|
959
|
+
required?: boolean;
|
845
960
|
};
|
846
961
|
/** @description Defines the shape of a component instance served by the composition API. */
|
847
962
|
ComponentInstance: {
|
@@ -921,6 +1036,8 @@ declare type ComponentParameter<TValue = unknown> = Omit<SharedComponents['Compo
|
|
921
1036
|
/** The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
|
922
1037
|
value: TValue;
|
923
1038
|
};
|
1039
|
+
/** Defines a binding from a resource data value to a component parameter value. */
|
1040
|
+
declare type ComponentParameterBinding = SharedComponents['ComponentParameterBinding'];
|
924
1041
|
/** Defines the shape of a component instance served by the composition API. */
|
925
1042
|
declare type ComponentInstance = SharedComponents['ComponentInstance'] & {
|
926
1043
|
/** Data for the component instance, provided by a component enhancer. Never set in unenhanced data. */
|
@@ -928,6 +1045,11 @@ declare type ComponentInstance = SharedComponents['ComponentInstance'] & {
|
|
928
1045
|
};
|
929
1046
|
/** Defines the shape of the root component in a composition */
|
930
1047
|
declare type RootComponentInstance = SharedComponents['RootComponentInstance'];
|
1048
|
+
/** Defines single structure to keep all canvas models (used in CLI commands and Starter content generations) */
|
1049
|
+
declare type CanvasDefinitions = {
|
1050
|
+
components?: Array<ComponentDefinition>;
|
1051
|
+
compositions?: Array<CompositionGetResponse>;
|
1052
|
+
};
|
931
1053
|
|
932
1054
|
/**
|
933
1055
|
* Pusher-js is large (80k) and not tree shakable so it is always bundled if directly referenced,
|
@@ -954,4 +1076,4 @@ declare global {
|
|
954
1076
|
*/
|
955
1077
|
declare function createEventBus(): Promise<PreviewEventBus | undefined>;
|
956
1078
|
|
957
|
-
export {
|
1079
|
+
export { CanvasDefinitions as A, ChannelSubscription as B, ComponentInstance as C, createEventBus as D, PreviewEventBus as P, RootComponentInstance as R, ComponentParameter as a, CompositionGetParameters as b, CompositionPutParameters as c, CompositionDeleteParameters as d, ComponentDefinitionGetParameters as e, ComponentDefinitionPutParameters as f, ComponentDefinitionDeleteParameters as g, ComponentDefinitionGetResponse as h, ComponentDefinitionAPIResponse as i, ComponentDefinitionAPIPutRequest as j, ComponentDefinitionAPIDeleteRequest as k, ComponentDefinitionListAPIOptions as l, ComponentDefinitionParameter as m, ComponentDefinitionVariant as n, ComponentDefinitionSlugSettings as o, ComponentDefinitionSlot as p, ComponentDefinitionPermission as q, ComponentDefinition as r, CreatingComponentDefinition as s, CompositionGetResponse as t, CompositionGetListResponse as u, CompositionAPIResponse as v, CompositionAPIDeleteRequest as w, CompositionListAPIResponse as x, CompositionAPIOptions as y, ComponentParameterBinding as z };
|
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, P as PreviewEventBus } from './createEventBus-
|
2
|
-
export {
|
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, P as PreviewEventBus } from './createEventBus-97db7eb7.js';
|
2
|
+
export { A as CanvasDefinitions, B as ChannelSubscription, r as ComponentDefinition, k as ComponentDefinitionAPIDeleteRequest, j as ComponentDefinitionAPIPutRequest, i as ComponentDefinitionAPIResponse, g as ComponentDefinitionDeleteParameters, e as ComponentDefinitionGetParameters, h as ComponentDefinitionGetResponse, l as ComponentDefinitionListAPIOptions, m as ComponentDefinitionParameter, q as ComponentDefinitionPermission, f as ComponentDefinitionPutParameters, p as ComponentDefinitionSlot, o as ComponentDefinitionSlugSettings, n as ComponentDefinitionVariant, C as ComponentInstance, a as ComponentParameter, z as ComponentParameterBinding, w as CompositionAPIDeleteRequest, y as CompositionAPIOptions, v as CompositionAPIResponse, d as CompositionDeleteParameters, u as CompositionGetListResponse, b as CompositionGetParameters, t as CompositionGetResponse, x as CompositionListAPIResponse, c as CompositionPutParameters, s as CreatingComponentDefinition, P as PreviewEventBus, R as RootComponentInstance, D as createEventBus } from './createEventBus-97db7eb7.js';
|
3
3
|
import { Options } from 'p-throttle';
|
4
4
|
import { Options as Options$1 } from 'p-retry';
|
5
5
|
import { PersonalizedVariant, TestVariant } from '@uniformdev/context';
|
@@ -89,9 +89,14 @@ declare type ComponentLocationReference = {
|
|
89
89
|
parentSlotIndex?: number;
|
90
90
|
};
|
91
91
|
declare type WalkComponentTreeActions = {
|
92
|
+
/** Replaces the component being visited with a new object */
|
92
93
|
replaceComponent: (replacementComponent: ComponentInstance) => void;
|
94
|
+
/** Removes the component being visited from the composition */
|
93
95
|
removeComponent: () => void;
|
96
|
+
/** Inserts a new component immediately after the current component in its parent slot */
|
94
97
|
insertAfter: (components: ComponentInstance | ComponentInstance[]) => void;
|
98
|
+
/** Aborts visitation of components that are in child slots of the current component */
|
99
|
+
stopProcessingDescendants: () => void;
|
95
100
|
};
|
96
101
|
/** Walks a composition's component tree, visiting each component instance depth-first, in order. */
|
97
102
|
declare function walkComponentTree(component: ComponentInstance, visitor: (component: ComponentInstance, ancestorsAndSelf: Array<ComponentLocationReference>, actions: WalkComponentTreeActions) => void): void;
|
@@ -263,6 +268,8 @@ declare type CanvasClientOptions = {
|
|
263
268
|
* Default: retry 3x on failures with exponential backoff, up to 10 requests per second.
|
264
269
|
* Use createLimitPolicy() to help creating a policy. */
|
265
270
|
limitPolicy?: LimitPolicy;
|
271
|
+
/** Specify whether caching is disabled. */
|
272
|
+
bypassCache?: boolean;
|
266
273
|
};
|
267
274
|
declare class CanvasClientError extends Error {
|
268
275
|
errorMessage: string;
|
@@ -290,6 +297,12 @@ declare class CanvasClient {
|
|
290
297
|
[key: string]: {
|
291
298
|
value: unknown;
|
292
299
|
type: string;
|
300
|
+
binding?: {
|
301
|
+
pointer: string | {
|
302
|
+
[key: string]: string;
|
303
|
+
};
|
304
|
+
syntax: "jptr";
|
305
|
+
} | undefined;
|
293
306
|
};
|
294
307
|
} | undefined;
|
295
308
|
variant?: string | undefined;
|
@@ -300,6 +313,12 @@ declare class CanvasClient {
|
|
300
313
|
[key: string]: {
|
301
314
|
value: unknown;
|
302
315
|
type: string;
|
316
|
+
binding?: {
|
317
|
+
pointer: string | {
|
318
|
+
[key: string]: string;
|
319
|
+
};
|
320
|
+
syntax: "jptr";
|
321
|
+
} | undefined;
|
303
322
|
};
|
304
323
|
} | undefined;
|
305
324
|
variant?: string | undefined;
|
@@ -329,6 +348,12 @@ declare class CanvasClient {
|
|
329
348
|
[key: string]: {
|
330
349
|
value: unknown;
|
331
350
|
type: string;
|
351
|
+
binding?: {
|
352
|
+
pointer: string | {
|
353
|
+
[key: string]: string;
|
354
|
+
};
|
355
|
+
syntax: "jptr";
|
356
|
+
} | undefined;
|
332
357
|
};
|
333
358
|
} | undefined;
|
334
359
|
variant?: string | undefined;
|
@@ -339,6 +364,12 @@ declare class CanvasClient {
|
|
339
364
|
[key: string]: {
|
340
365
|
value: unknown;
|
341
366
|
type: string;
|
367
|
+
binding?: {
|
368
|
+
pointer: string | {
|
369
|
+
[key: string]: string;
|
370
|
+
};
|
371
|
+
syntax: "jptr";
|
372
|
+
} | undefined;
|
342
373
|
};
|
343
374
|
} | undefined;
|
344
375
|
variant?: string | undefined;
|
@@ -367,6 +398,12 @@ declare class CanvasClient {
|
|
367
398
|
[key: string]: {
|
368
399
|
value: unknown;
|
369
400
|
type: string;
|
401
|
+
binding?: {
|
402
|
+
pointer: string | {
|
403
|
+
[key: string]: string;
|
404
|
+
};
|
405
|
+
syntax: "jptr";
|
406
|
+
} | undefined;
|
370
407
|
};
|
371
408
|
} | undefined;
|
372
409
|
variant?: string | undefined;
|
@@ -377,6 +414,12 @@ declare class CanvasClient {
|
|
377
414
|
[key: string]: {
|
378
415
|
value: unknown;
|
379
416
|
type: string;
|
417
|
+
binding?: {
|
418
|
+
pointer: string | {
|
419
|
+
[key: string]: string;
|
420
|
+
};
|
421
|
+
syntax: "jptr";
|
422
|
+
} | undefined;
|
380
423
|
};
|
381
424
|
} | undefined;
|
382
425
|
variant?: string | undefined;
|
@@ -437,6 +480,12 @@ declare class CanvasClient {
|
|
437
480
|
[key: string]: {
|
438
481
|
value: unknown;
|
439
482
|
type: string;
|
483
|
+
binding?: {
|
484
|
+
pointer: string | {
|
485
|
+
[key: string]: string;
|
486
|
+
};
|
487
|
+
syntax: "jptr";
|
488
|
+
} | undefined;
|
440
489
|
};
|
441
490
|
} | undefined;
|
442
491
|
variant?: string | undefined;
|
@@ -462,6 +511,9 @@ declare class CanvasClient {
|
|
462
511
|
private createUrl;
|
463
512
|
private static getRequestId;
|
464
513
|
}
|
514
|
+
declare class UncachedCanvasClient extends CanvasClient {
|
515
|
+
constructor(options: Omit<CanvasClientOptions, 'bypassCache'>);
|
516
|
+
}
|
465
517
|
|
466
518
|
/** Public ID of Canvas personalization component type */
|
467
519
|
declare const CANVAS_PERSONALIZE_TYPE = "$personalization";
|
@@ -532,4 +584,4 @@ declare function localize({ composition, locale, }: {
|
|
532
584
|
}) => string | undefined);
|
533
585
|
}): void;
|
534
586
|
|
535
|
-
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, ChildEnhancerBuilder, ComponentEnhancer, ComponentEnhancerFunction, ComponentEnhancerOptions, ComponentLocationReference, ComponentParameterEnhancer, ComponentParameterEnhancerFunction, ComponentParameterEnhancerOptions, EnhancerBuilder, EnhancerContext, EnhancerError, EventNames, LimitPolicy, SubscribeToCompositionOptions, UniqueBatchEntries, UnsubscribeCallback, compose, createBatchEnhancer, createLimitPolicy, enhance, extractLocales, getChannelName, getComponentPath, isSystemComponentDefinition, localize, mapSlotToPersonalizedVariations, mapSlotToTestVariations, nullLimitPolicy, subscribeToComposition, walkComponentTree };
|
587
|
+
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, ChildEnhancerBuilder, ComponentEnhancer, ComponentEnhancerFunction, ComponentEnhancerOptions, ComponentLocationReference, ComponentParameterEnhancer, ComponentParameterEnhancerFunction, ComponentParameterEnhancerOptions, EnhancerBuilder, EnhancerContext, EnhancerError, EventNames, LimitPolicy, SubscribeToCompositionOptions, UncachedCanvasClient, UniqueBatchEntries, UnsubscribeCallback, WalkComponentTreeActions, compose, createBatchEnhancer, createLimitPolicy, enhance, extractLocales, getChannelName, getComponentPath, isSystemComponentDefinition, localize, mapSlotToPersonalizedVariations, mapSlotToTestVariations, nullLimitPolicy, subscribeToComposition, walkComponentTree };
|
package/dist/index.esm.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{A as
|
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,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-2C4YYM6A.mjs";export{f as BatchEntry,w as CANVAS_DRAFT_STATE,A as CANVAS_ENRICHMENT_TAG_PARAM,r as CANVAS_INTENT_TAG_PARAM,s as CANVAS_LOCALE_TAG_PARAM,v as CANVAS_LOCALIZATION_SLOT,q as CANVAS_LOCALIZATION_TYPE,y as CANVAS_PERSONALIZATION_PARAM,t as CANVAS_PERSONALIZE_SLOT,o as CANVAS_PERSONALIZE_TYPE,x as CANVAS_PUBLISHED_STATE,u as CANVAS_TEST_SLOT,p as CANVAS_TEST_TYPE,z as CANVAS_TEST_VARIANT_PARAM,m as CanvasClient,l as CanvasClientError,d as ChildEnhancerBuilder,e as EnhancerBuilder,n as UncachedCanvasClient,c as UniqueBatchEntries,k as compose,g as createBatchEnhancer,E as createEventBus,h as createLimitPolicy,j as enhance,H as extractLocales,F as getChannelName,b as getComponentPath,B as isSystemComponentDefinition,I as localize,C as mapSlotToPersonalizedVariations,D as mapSlotToTestVariations,i as nullLimitPolicy,G as subscribeToComposition,a as walkComponentTree};
|
package/dist/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
"use strict";var B=Object.create;var C=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var G=(r,e)=>{for(var t in e)C(r,t,{get:e[t],enumerable:!0})},L=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of U(e))!D.call(r,o)&&o!==t&&C(r,o,{get:()=>e[o],enumerable:!(n=M(e,o))||n.enumerable});return r};var N=(r,e,t)=>(t=r!=null?B(F(r)):{},L(e||!r||!r.__esModule?C(t,"default",{value:r,enumerable:!0}):t,r)),z=r=>L(C({},"__esModule",{value:!0}),r);var me={};G(me,{BatchEntry:()=>E,CANVAS_DRAFT_STATE:()=>_e,CANVAS_ENRICHMENT_TAG_PARAM:()=>ne,CANVAS_INTENT_TAG_PARAM:()=>X,CANVAS_LOCALE_TAG_PARAM:()=>x,CANVAS_LOCALIZATION_SLOT:()=>w,CANVAS_LOCALIZATION_TYPE:()=>I,CANVAS_PERSONALIZATION_PARAM:()=>_,CANVAS_PERSONALIZE_SLOT:()=>ee,CANVAS_PERSONALIZE_TYPE:()=>Q,CANVAS_PUBLISHED_STATE:()=>Re,CANVAS_TEST_SLOT:()=>te,CANVAS_TEST_TYPE:()=>q,CANVAS_TEST_VARIANT_PARAM:()=>R,CanvasClient:()=>y,CanvasClientError:()=>u,ChildEnhancerBuilder:()=>f,EnhancerBuilder:()=>T,UniqueBatchEntries:()=>g,compose:()=>J,createBatchEnhancer:()=>H,createEventBus:()=>se,createLimitPolicy:()=>v,enhance:()=>K,extractLocales:()=>k,getChannelName:()=>b,getComponentPath:()=>P,isSystemComponentDefinition:()=>oe,localize:()=>pe,mapSlotToPersonalizedVariations:()=>re,mapSlotToTestVariations:()=>ae,nullLimitPolicy:()=>l,subscribeToComposition:()=>ce,walkComponentTree:()=>d});module.exports=z(me);function d(r,e){let t=[{ancestorsAndSelf:[{component:r,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let n=t.pop();if(!n)continue;let o=n.ancestorsAndSelf[0];e(o.component,n.ancestorsAndSelf,{replaceComponent:i=>{Object.assign(o.component,i),["parameters","variant","slots","data","_pattern","_patternError"].forEach(s=>{i[s]||delete o.component[s]})},removeComponent:()=>{let{parentSlot:i,parentSlotIndex:c}=n.ancestorsAndSelf[0],s=n.ancestorsAndSelf[1];if(i&&typeof c!="undefined")s.component.slots[i].splice(c,1);else throw new Error("Unable to delete composition.")},insertAfter:i=>{let c=Array.isArray(i)?i:[i],{parentSlot:s,parentSlotIndex:p}=n.ancestorsAndSelf[0],m=n.ancestorsAndSelf[1];if(s&&typeof p!="undefined")m.component.slots[s].splice(p+1,0,...c);else throw new Error("Unable to insert after a component not in a slot.")}});let a=o.component.slots;if(a){let i=Object.keys(a);for(let c=i.length-1;c>=0;c--){let s=i[c],p=a[s];for(let m=p.length-1;m>=0;m--)t.push({ancestorsAndSelf:[{component:p[m],parentSlot:s,parentSlotIndex:m},...n.ancestorsAndSelf]})}}}while(t.length>0)}function P(r){let e=[];for(let t=r.length-1;t>=0;t--){let{parentSlot:n,parentSlotIndex:o}=r[t];n&&o!==void 0&&e.push(`${n}[${o}]`)}return`.${e.join(".")}`}var g=class{constructor(e,t){this.groups=e.reduce((n,o)=>{var i;let a=t(o.args);return n[a]=(i=n[a])!=null?i:[],n[a].push(o),n},{})}resolveKey(e,t){this.groups[e].forEach(n=>n.resolve(t))}resolveRemaining(e){Object.keys(this.groups).forEach(t=>{this.groups[t].forEach(n=>{n.isCompleted||n.resolve(e)})})}};var f=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(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(t)})),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,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 n;return(n=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===t.type||!o.type&&!o.name))==null?void 0:n.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},T=class{constructor(){this._componentIndex={};this._rootBuilder=new f}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(o=>{this._componentIndex[o]=this._componentIndex[o]||new f,t(this._componentIndex[o])}),this}resolveParameterEnhancer(e,t,n){let o=this._componentIndex[e.type];if(o){let a=o.resolveParameterEnhancer(t,n);if(a)return a}return this._rootBuilder.resolveParameterEnhancer(t,n)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers(),n=this._componentIndex[e.type];if(n){t=new Map(t);for(let[o,a]of n.resolveComponentEnhancers())t.set(o,a)}return t}};var E=class{constructor(e,t,n){this._resolve=e;this._reject=t;this.args=n;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 H({handleBatch:r,shouldQueue:e,limitPolicy:t}){let n=[];return{enhanceOne:async i=>{if(!e||e(i))return new Promise((c,s)=>{n.push(new E(c,s,i))})},completeAll:async()=>{if(n.length>0){try{await r(n)}catch(c){n.forEach(s=>s.reject(c))}if(n.some(c=>!c.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let i=n.length;return n=[],i},limitPolicy:t}}var j=N(require("p-throttle")),V=N(require("p-retry"));function v({throttle:r={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let t=r?(0,j.default)(r):null;return function(o){let a=async()=>await o();if(t&&(a=t(a)),e){let i=a;a=()=>(0,V.default)(i,e)}return a()}}var l=async r=>await r();async function K({composition:r,enhancers:e,context:t,onErrors:n=o=>{throw new Error(o.map(a=>`${a.message}
|
2
|
-
${typeof
|
1
|
+
"use strict";var Y=Object.create;var A=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var w=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ne=(r,e)=>{for(var t in e)A(r,t,{get:e[t],enumerable:!0})},U=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of X(e))!te.call(r,o)&&o!==t&&A(r,o,{get:()=>e[o],enumerable:!(n=Q(e,o))||n.enumerable});return r};var re=(r,e,t)=>(t=r!=null?Y(ee(r)):{},U(e||!r||!r.__esModule?A(t,"default",{value:r,enumerable:!0}):t,r)),oe=r=>U(A({},"__esModule",{value:!0}),r);var F=w((Ve,j)=>{function u(r,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(r)),this._timeouts=r,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))}j.exports=u;u.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};u.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};u.prototype.retry=function(r){if(this._timeout&&clearTimeout(this._timeout),!r)return!1;var e=new Date().getTime();if(r&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(r),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(r);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 n=this;return this._timer=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},t),this._options.unref&&this._timer.unref(),!0};u.prototype.attempt=function(r,e){this._fn=r,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)};u.prototype.try=function(r){console.log("Using RetryOperation.try() is deprecated"),this.attempt(r)};u.prototype.start=function(r){console.log("Using RetryOperation.start() is deprecated"),this.attempt(r)};u.prototype.start=u.prototype.try;u.prototype.errors=function(){return this._errors};u.prototype.attempts=function(){return this._attempts};u.prototype.mainError=function(){if(this._errors.length===0)return null;for(var r={},e=null,t=0,n=0;n<this._errors.length;n++){var o=this._errors[n],i=o.message,s=(r[i]||0)+1;r[i]=s,s>=t&&(e=o,t=s)}return e}});var G=w(d=>{var se=F();d.operation=function(r){var e=d.timeouts(r);return new se(e,{forever:r&&(r.forever||r.retries===1/0),unref:r&&r.unref,maxRetryTime:r&&r.maxRetryTime})};d.timeouts=function(r){if(r instanceof Array)return[].concat(r);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in r)e[t]=r[t];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],o=0;o<e.retries;o++)n.push(this.createTimeout(o,e));return r&&r.forever&&!n.length&&n.push(this.createTimeout(o,e)),n.sort(function(i,s){return i-s}),n};d.createTimeout=function(r,e){var t=e.randomize?Math.random()+1:1,n=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,r));return n=Math.min(n,e.maxTimeout),n};d.wrap=function(r,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var n in r)typeof r[n]=="function"&&t.push(n)}for(var o=0;o<t.length;o++){var i=t[o],s=r[i];r[i]=function(c){var m=d.operation(e),p=Array.prototype.slice.call(arguments,1),l=p.pop();p.push(function(h){m.retry(h)||(h&&(arguments[0]=m.mainError()),l.apply(this,arguments))}),m.attempt(function(){c.apply(r,p)})}.bind(r,s),r[i].options=e}}});var H=w((Be,z)=>{z.exports=G()});var Re={};ne(Re,{BatchEntry:()=>v,CANVAS_DRAFT_STATE:()=>Xe,CANVAS_ENRICHMENT_TAG_PARAM:()=>ge,CANVAS_INTENT_TAG_PARAM:()=>Ce,CANVAS_LOCALE_TAG_PARAM:()=>M,CANVAS_LOCALIZATION_SLOT:()=>V,CANVAS_LOCALIZATION_TYPE:()=>k,CANVAS_PERSONALIZATION_PARAM:()=>$,CANVAS_PERSONALIZE_SLOT:()=>Ee,CANVAS_PERSONALIZE_TYPE:()=>de,CANVAS_PUBLISHED_STATE:()=>et,CANVAS_TEST_SLOT:()=>Te,CANVAS_TEST_TYPE:()=>ye,CANVAS_TEST_VARIANT_PARAM:()=>B,CanvasClient:()=>E,CanvasClientError:()=>C,ChildEnhancerBuilder:()=>P,EnhancerBuilder:()=>b,UncachedCanvasClient:()=>L,UniqueBatchEntries:()=>x,compose:()=>he,createBatchEnhancer:()=>ie,createEventBus:()=>we,createLimitPolicy:()=>N,enhance:()=>me,extractLocales:()=>J,getChannelName:()=>D,getComponentPath:()=>_,isSystemComponentDefinition:()=>Pe,localize:()=>be,mapSlotToPersonalizedVariations:()=>Ae,mapSlotToTestVariations:()=>_e,nullLimitPolicy:()=>f,subscribeToComposition:()=>xe,walkComponentTree:()=>g});module.exports=oe(Re);function g(r,e){let t=[{ancestorsAndSelf:[{component:r,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let n=t.pop();if(!n)continue;let o=n.ancestorsAndSelf[0],i=!0;e(o.component,n.ancestorsAndSelf,{replaceComponent:a=>{Object.assign(o.component,a),["parameters","variant","slots","data","_pattern","_patternError"].forEach(m=>{a[m]||delete o.component[m]})},removeComponent:()=>{let{parentSlot:a,parentSlotIndex:c}=n.ancestorsAndSelf[0],m=n.ancestorsAndSelf[1];if(a&&typeof c!="undefined")m.component.slots[a].splice(c,1);else throw new Error("Unable to delete composition.")},insertAfter:a=>{let c=Array.isArray(a)?a:[a],{parentSlot:m,parentSlotIndex:p}=n.ancestorsAndSelf[0],l=n.ancestorsAndSelf[1];if(m&&typeof p!="undefined")l.component.slots[m].splice(p+1,0,...c);else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){i=!1}});let s=o.component.slots;if(i&&s){let a=Object.keys(s);for(let c=a.length-1;c>=0;c--){let m=a[c],p=s[m];for(let l=p.length-1;l>=0;l--)t.push({ancestorsAndSelf:[{component:p[l],parentSlot:m,parentSlotIndex:l},...n.ancestorsAndSelf]})}}}while(t.length>0)}function _(r){let e=[];for(let t=r.length-1;t>=0;t--){let{parentSlot:n,parentSlotIndex:o}=r[t];n&&o!==void 0&&e.push(`${n}[${o}]`)}return`.${e.join(".")}`}var x=class{constructor(e,t){this.groups=e.reduce((n,o)=>{var s;let i=t(o.args);return n[i]=(s=n[i])!=null?s:[],n[i].push(o),n},{})}resolveKey(e,t){this.groups[e].forEach(n=>n.resolve(t))}resolveRemaining(e){Object.keys(this.groups).forEach(t=>{this.groups[t].forEach(n=>{n.isCompleted||n.resolve(e)})})}};var P=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(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(t)})),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,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 n;return(n=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===t.type||!o.type&&!o.name))==null?void 0:n.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},b=class{constructor(){this._componentIndex={};this._rootBuilder=new P}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(o=>{this._componentIndex[o]=this._componentIndex[o]||new P,t(this._componentIndex[o])}),this}resolveParameterEnhancer(e,t,n){let o=this._componentIndex[e.type];if(o){let i=o.resolveParameterEnhancer(t,n);if(i)return i}return this._rootBuilder.resolveParameterEnhancer(t,n)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers(),n=this._componentIndex[e.type];if(n){t=new Map(t);for(let[o,i]of n.resolveComponentEnhancers())t.set(o,i)}return t}};var v=class{constructor(e,t,n){this._resolve=e;this._reject=t;this.args=n;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 ie({handleBatch:r,shouldQueue:e,limitPolicy:t}){let n=[];return{enhanceOne:async s=>{if(!e||e(s))return new Promise((a,c)=>{n.push(new v(a,c,s))})},completeAll:async()=>{if(n.length>0){try{await r(n)}catch(a){n.forEach(c=>c.reject(a))}if(n.some(a=>!a.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let s=n.length;return n=[],s},limitPolicy:t}}var R=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function I({limit:r,interval:e,strict:t}){if(!Number.isFinite(r))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 n=new Map,o=0,i=0;function s(){let p=Date.now();return p-o>e?(i=1,o=p,0):(i<r?i++:(o+=e,i=1),o-p)}let a=[];function c(){let p=Date.now();if(a.length<r)return a.push(p),0;let l=a.shift()+e;return p>=l?(a.push(p),0):(a.push(l),l-p)}let m=t?c:s;return p=>{let l=function(...h){if(!l.isEnabled)return(async()=>p.apply(this,h))();let y;return new Promise((T,W)=>{y=setTimeout(()=>{T(p.apply(this,h)),n.delete(y)},m()),n.set(y,W)})};return l.abort=()=>{for(let h of n.keys())clearTimeout(h),n.get(h)(new R);n.clear(),a.splice(0,a.length)},l.isEnabled=!0,l}}var Z=re(H(),1),ae=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),S=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},ce=(r,e,t)=>{let n=t.retries-(e-1);return r.attemptNumber=e,r.retriesLeft=n,r},pe=r=>ae.has(r),K=r=>globalThis.DOMException===void 0?new Error(r):new DOMException(r);async function O(r,e){return new Promise((t,n)=>{e={onFailedAttempt(){},retries:10,...e};let o=Z.default.operation(e);o.attempt(async i=>{try{t(await r(i))}catch(s){if(!(s instanceof Error)){n(new TypeError(`Non-error was thrown: "${s}". You should only throw errors.`));return}if(s instanceof S)o.stop(),n(s.originalError);else if(s instanceof TypeError&&!pe(s.message))o.stop(),n(s);else{ce(s,i,e);try{await e.onFailedAttempt(s)}catch(a){n(a);return}o.retry(s)||n(o.mainError())}}}),e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",()=>{o.stop();let i=e.signal.reason===void 0?K("The operation was aborted."):e.signal.reason;n(i instanceof Error?i:K(i))},{once:!0})})}function N({throttle:r={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let t=r?I(r):null;return function(o){let i=async()=>await o();if(t&&(i=t(i)),e){let s=i;i=()=>O(s,e)}return i()}}var f=async r=>await r();async function me({composition:r,enhancers:e,context:t,onErrors:n=o=>{throw new Error(o.map(i=>`${i.message}
|
2
|
+
${typeof i.error=="object"&&"stack"in i.error?i.error.stack:i.error}`).join(`
|
3
3
|
|
4
|
-
`))}}){let o=[],
|
5
|
-
${
|
4
|
+
`))}}){let o=[],i=new Set,s=new Set;g(r,(c,m)=>{var l;Object.entries((l=c.parameters)!=null?l:{}).forEach(([h,y])=>{let T=e.resolveParameterEnhancer(c,h,y);T&&(s.add(T),o.push(ue(c,m,h,y,T,t)))});let p=e.resolveComponentEnhancers(c);o.push(le(c,m,p,t)),i.add(p)}),o.push(...Array.from(i).flatMap(c=>Array.from(c).map(async([,m])=>{var p;try{m.completeAll&&await((p=m.limitPolicy)!=null?p:f)(()=>m.completeAll())}catch(l){return{error:l,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),o.push(...Array.from(s).map(async c=>{var m;try{c.completeAll&&await((m=c.limitPolicy)!=null?m:f)(()=>c.completeAll())}catch(p){return{error:p,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let a=(await Promise.all(o)).flatMap(c=>Array.isArray(c)?c:[c]).filter(c=>c);a.length&&n(a)}async function le(r,e,t,n){return t.size&&(r.data={}),await Promise.all(Array.from(t).map(async([o,i])=>{var s;try{let c=await(i.completeAll?f:(s=i.limitPolicy)!=null?s:f)(async()=>i.enhanceOne({component:r,context:n}));c!=null&&(r.data[o]=c)}catch(a){let c=`Component ${_(e)} (type: ${r.type}): data.${o} enhancer threw exception. Data key will not be present.`;return delete r.data[o],{message:c,error:a}}}))}async function ue(r,e,t,n,o,i){var s;try{let c=await(o.completeAll?f:(s=o.limitPolicy)!=null?s:f)(async()=>o.enhanceOne({parameter:n,parameterName:t,component:r,context:i}));c===null?delete r.parameters[t]:typeof c=="undefined"?r.parameters[t]={...n,value:n.value}:r.parameters[t]={...n,value:c}}catch(a){let c=`Component ${_(e)} (type: ${r.type}): enhancing parameter ${t} (type: ${n.type}) threw exception. Parameter will be removed.`;return delete r.parameters[t],{message:c,error:a}}}var he=(r,...e)=>({enhanceOne:n=>{let o="enhanceOne"in r?r.enhanceOne(n):r(n);for(let i of e){let s=fe(o)?o:Promise.resolve(o),a="enhanceOne"in i?i.enhanceOne:i;o=s.then(c=>a({...n,parameter:{type:n.parameter.type,value:c}}))}return o},completeAll:async()=>{var n,o;for(let i of e)if("completeAll"in i)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(o="completeAll"in r?(n=r.completeAll)==null?void 0:n.call(r):0)!=null?o:0}});function fe(r){return!!r&&(typeof r=="object"||typeof r=="function")&&typeof r.then=="function"}var C=class extends Error{constructor(t,n,o,i,s,a){super(`${t}
|
5
|
+
${i}${s?" "+s:""} (${n} ${o}${a?` Request ID: ${a}`:""})`);this.errorMessage=t;this.fetchMethod=n;this.fetchUri=o;this.statusCode=i;this.statusText=s;this.requestId=a;Object.setPrototypeOf(this,C.prototype)}},E=class{constructor(e){var n,o,i,s,a,c;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=e.fetch;if(!t)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")t=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")t=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...e,fetch:t,apiHost:(n=e.apiHost)!=null?n:"https://uniform.app",apiKey:(o=e.apiKey)!=null?o:null,projectId:(i=e.projectId)!=null?i:null,bearerToken:(s=e.bearerToken)!=null?s:null,limitPolicy:(a=e.limitPolicy)!=null?a:N({}),bypassCache:(c=e.bypassCache)!=null?c:!1}}async getCompositionList(e){let{projectId:t}=this.options,n=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(n)}async getCompositionBySlug(e){let{projectId:t}=this.options,n=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(n)}async getCompositionById(e){let{projectId:t}=this.options,n=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(n)}async updateComposition(e){let t=this.createUrl("/api/v1/canvas");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(e){let t=this.createUrl("/api/v1/canvas"),{projectId:n}=this.options;await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:n}),expectNoContent:!0})}async getComponentDefinitions(e){let{projectId:t}=this.options,n=this.createUrl("/api/v1/canvas-definitions",{...e,projectId:t});return await this.apiClient(n)}async updateComponentDefinition(e){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(e){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(e,t){return this.options.limitPolicy(async()=>{var i;let n=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},o=await this.options.fetch(e.toString(),{...t,headers:{"x-bypass-cache":this.options.bypassCache.toString(),...t==null?void 0:t.headers,...n}});if(!o.ok){let s="";try{let a=await o.text();try{let c=JSON.parse(a);c.errorMessage?s=Array.isArray(c.errorMessage)?c.errorMessage.join(", "):c.errorMessage:s=a}catch(c){s=a}}catch(a){s="General error"}throw new C(s,(i=t==null?void 0:t.method)!=null?i:"GET",e.toString(),o.status,o.statusText,E.getRequestId(o))}return t!=null&&t.expectNoContent?null:await o.json()})}createUrl(e,t){let n=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([o,i])=>{var s;typeof i!==void 0&&i!==null&&n.searchParams.append(o,(s=i==null?void 0:i.toString())!=null?s:"")}),n}static getRequestId(e){let t=e.headers.get("apigw-requestid");if(t)return t}},L=class extends E{constructor(e){super({...e,bypassCache:!0})}};var de="$personalization",ye="$test",k="$localization",Ce="intentTag",M="locale",Ee="pz",Te="test",V="localized",Xe=0,et=64,$="$pzCrit",B="$tstVrnt",ge="$enr";var Pe=r=>r.startsWith("$");function Ae(r){return r?r.map((e,t)=>{var i,s;let n=(s=(i=e.parameters)==null?void 0:i[$])==null?void 0:s.value,o=(n==null?void 0:n.name)||`pz-${t}-${e.type}`;return{...e,id:o,pz:n}}):[]}function _e(r){return r?r.map((e,t)=>{var i,s,a;let n=(s=(i=e.parameters)==null?void 0:i[B])==null?void 0:s.value,o=(a=n==null?void 0:n.id)!=null?a:"testId"in e?e.testId:`ab-${t}-${e.type}`;return{...e,id:o}}):[]}var q="https://js.pusher.com/7.0.3/pusher.min.js";async function ve(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((r,e)=>{let t=setTimeout(()=>{window.Pusher&&r(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${q}"><\/script> manually.`)},5e3),n=document.createElement("script");n.src=q,n.addEventListener("load",()=>{clearTimeout(t),r(window.Pusher)}),document.head.appendChild(n)})}async function we(){let r=await ve();if(!r)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let t=new r("7b5f5abd160fea549ffe",{cluster:"mt1"});t.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:n=>{let o=t.subscribe(n);return{unsubscribe:()=>t.unsubscribe(n),addEventHandler:(i,s)=>(o.bind(i,s),()=>o.unbind(i,s))}}}}return e}function D(r,e,t){return`${r}.${e}@${t}`}function xe({projectId:r,compositionId:e,compositionState:t=0,eventBus:{subscribe:n},callback:o,event:i="updated"}){let s=D(r,e,t),a=n(s),c=a.addEventHandler(i,o);return()=>{c(),a.unsubscribe()}}function J({component:r}){var n;let e={},t=(n=r.slots)==null?void 0:n[V];return t==null||t.forEach(o=>{var s;let i=(s=o.parameters)==null?void 0:s[M];(i==null?void 0:i.value)&&typeof i.value=="string"&&(e[i.value]=e[i.value]||[],e[i.value].push(o))}),e}function be({composition:r,locale:e}){g(r,(t,n,o)=>{if(t.type===k){let i=J({component:t}),s=typeof e=="string"?e:e({component:t,locales:i}),a;if(s&&(a=i[s]),a!=null&&a.length){let[c,...m]=a;o.replaceComponent(c),m.length&&o.insertAfter(m)}else o.removeComponent()}})}0&&(module.exports={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,EnhancerBuilder,UncachedCanvasClient,UniqueBatchEntries,compose,createBatchEnhancer,createEventBus,createLimitPolicy,enhance,extractLocales,getChannelName,getComponentPath,isSystemComponentDefinition,localize,mapSlotToPersonalizedVariations,mapSlotToTestVariations,nullLimitPolicy,subscribeToComposition,walkComponentTree});
|
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{A as
|
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,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-2C4YYM6A.mjs";export{f as BatchEntry,w as CANVAS_DRAFT_STATE,A as CANVAS_ENRICHMENT_TAG_PARAM,r as CANVAS_INTENT_TAG_PARAM,s as CANVAS_LOCALE_TAG_PARAM,v as CANVAS_LOCALIZATION_SLOT,q as CANVAS_LOCALIZATION_TYPE,y as CANVAS_PERSONALIZATION_PARAM,t as CANVAS_PERSONALIZE_SLOT,o as CANVAS_PERSONALIZE_TYPE,x as CANVAS_PUBLISHED_STATE,u as CANVAS_TEST_SLOT,p as CANVAS_TEST_TYPE,z as CANVAS_TEST_VARIANT_PARAM,m as CanvasClient,l as CanvasClientError,d as ChildEnhancerBuilder,e as EnhancerBuilder,n as UncachedCanvasClient,c as UniqueBatchEntries,k as compose,g as createBatchEnhancer,E as createEventBus,h as createLimitPolicy,j as enhance,H as extractLocales,F as getChannelName,b as getComponentPath,B as isSystemComponentDefinition,I as localize,C as mapSlotToPersonalizedVariations,D as mapSlotToTestVariations,i as nullLimitPolicy,G as subscribeToComposition,a as walkComponentTree};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/canvas",
|
3
|
-
"version": "16.2.1-alpha.
|
3
|
+
"version": "16.2.1-alpha.320+8dcf5fc30",
|
4
4
|
"description": "Common functionality and types for Uniform Canvas",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -49,15 +49,15 @@
|
|
49
49
|
"devDependencies": {
|
50
50
|
"@types/retry": "0.12.1",
|
51
51
|
"@types/yargs": "17.0.10",
|
52
|
-
"@uniformdev/cli": "^16.2.1-alpha.
|
53
|
-
"
|
52
|
+
"@uniformdev/cli": "^16.2.1-alpha.320+8dcf5fc30",
|
53
|
+
"p-limit": "4.0.0",
|
54
|
+
"p-retry": "5.1.1",
|
55
|
+
"p-throttle": "5.0.0",
|
56
|
+
"pusher-js": "7.2.0",
|
54
57
|
"yargs": "17.5.1"
|
55
58
|
},
|
56
59
|
"dependencies": {
|
57
|
-
"@uniformdev/context": "^16.2.1-alpha.
|
58
|
-
"p-limit": "^3.1.0",
|
59
|
-
"p-retry": "^4.6.2",
|
60
|
-
"p-throttle": "^4.1.1"
|
60
|
+
"@uniformdev/context": "^16.2.1-alpha.320+8dcf5fc30"
|
61
61
|
},
|
62
62
|
"files": [
|
63
63
|
"/dist"
|
@@ -65,5 +65,5 @@
|
|
65
65
|
"publishConfig": {
|
66
66
|
"access": "public"
|
67
67
|
},
|
68
|
-
"gitHead": "
|
68
|
+
"gitHead": "8dcf5fc30e73cb76d24e091562e4b55f5d388688"
|
69
69
|
}
|