@contentful/experiences-core 3.7.0-dev-20250918T1641-6da833a.0 → 3.7.0-dev-20250919T0754-9f36582.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,8 +53,8 @@ declare class EntityStore extends EntityStoreBase {
53
53
  get breakpoints(): {
54
54
  id: string;
55
55
  query: "*" | `>${number}px` | `<${number}px`;
56
- previewSize: string;
57
56
  displayName: string;
57
+ previewSize?: string | undefined;
58
58
  displayIcon?: "desktop" | "tablet" | "mobile" | undefined;
59
59
  }[];
60
60
  get dataSource(): Record<string, {
package/dist/index.cjs CHANGED
@@ -1000,7 +1000,7 @@ const BreakpointSchema = zod.z
1000
1000
  id: propertyKeySchema,
1001
1001
  // Can be replace with z.templateLiteral when upgrading to zod v4
1002
1002
  query: zod.z.string().refine((s) => BREAKPOINT_QUERY_REGEX.test(s)),
1003
- previewSize: zod.z.string(),
1003
+ previewSize: zod.z.string().optional(),
1004
1004
  displayName: zod.z.string(),
1005
1005
  displayIcon: zod.z.enum(['desktop', 'tablet', 'mobile']).optional(),
1006
1006
  })
@@ -1037,6 +1037,19 @@ const ComponentVariableSchema = zod.z.object({
1037
1037
  });
1038
1038
  const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
1039
1039
  children: zod.z.lazy(() => ComponentTreeNodeSchema.array()),
1040
+ }).superRefine(({ id, prebindingId, parameters }, ctx) => {
1041
+ if (prebindingId && !parameters) {
1042
+ ctx.addIssue({
1043
+ code: zod.z.ZodIssueCode.custom,
1044
+ message: `Found "prebindingId" but no "parameters" for node with id: "${id}"`,
1045
+ });
1046
+ }
1047
+ if (parameters && !prebindingId) {
1048
+ ctx.addIssue({
1049
+ code: zod.z.ZodIssueCode.custom,
1050
+ message: `Found "parameters" but no "prebindingId" for node with id: "${id}"`,
1051
+ });
1052
+ }
1040
1053
  });
1041
1054
  const ComponentTreeSchema = zod.z
1042
1055
  .object({
@@ -1521,29 +1534,54 @@ const validateBreakpointsDefinition = (breakpoints) => {
1521
1534
  return { success: true };
1522
1535
  };
1523
1536
 
1524
- exports.breakpointsRegistry = [];
1537
+ const breakpointsRegistry = [];
1525
1538
  /**
1526
- * Register custom breakpoints
1527
- * @param breakpoints - [{[key:string]: string}]
1528
- * @returns void
1539
+ * Define custom breakpoints that should be used for all your experiences.
1540
+ * A breakpoint consists of:
1541
+ * - id: a unique identifier for this breakpoint
1542
+ * - query: a media query string that defines when this breakpoint is active
1543
+ * - previewSize: an optional fixed preview size to be used in the Studio editor when selecting this breakpoint
1544
+ * - displayName: the name to be displayed in the Studio editor for this breakpoint
1545
+ * - displayIcon: an optional icon to be displayed in the Studio editor for this breakpoint
1546
+ *
1547
+ * The first breakpoint must use a wildcard query (`*`) to match all sizes.
1548
+ *
1549
+ * Every subsequent breakpoint inherits the designs of the previous ones by default.
1550
+ *
1551
+ * The order of breakpoints must be either:
1552
+ * - desktop first: from largest to smallest, using `<` operators
1553
+ * - mobile first: from smallest to largest, using `>` operators
1554
+ *
1555
+ * @note changing breakpoints after you have created experiences may break those experiences
1556
+ * @example
1557
+ * defineBreakpoints([{
1558
+ * id: 'desktop',
1559
+ * query: '*',
1560
+ * displayName: 'Desktop',
1561
+ * displayIcon: 'desktop',
1562
+ * }, {
1563
+ * id: 'tablet',
1564
+ * query: '<992px',
1565
+ * displayName: 'Tablet',
1566
+ * displayIcon: 'tablet',
1567
+ * }, {
1568
+ * id: 'mobile',
1569
+ * query: '<576px',
1570
+ * displayName: 'Mobile',
1571
+ * displayIcon: 'mobile',
1572
+ * }]);
1529
1573
  */
1530
1574
  const defineBreakpoints = (breakpoints) => {
1531
- Object.assign(exports.breakpointsRegistry, breakpoints);
1575
+ Object.assign(breakpointsRegistry, breakpoints);
1532
1576
  };
1533
1577
  const runBreakpointsValidation = () => {
1534
- if (!exports.breakpointsRegistry.length)
1578
+ if (!breakpointsRegistry.length)
1535
1579
  return;
1536
- const validation = validateBreakpointsDefinition(exports.breakpointsRegistry);
1580
+ const validation = validateBreakpointsDefinition(breakpointsRegistry);
1537
1581
  if (!validation.success) {
1538
1582
  throw new Error(`Invalid breakpoints definition. Failed with errors: \n${JSON.stringify(validation.errors, null, 2)}`);
1539
1583
  }
1540
1584
  };
1541
- // Used in the tests to get a breakpoint registration
1542
- const getBreakpointRegistration = (id) => exports.breakpointsRegistry.find((breakpoint) => breakpoint.id === id);
1543
- // Used in the tests to reset the registry
1544
- const resetBreakpointsRegistry = () => {
1545
- exports.breakpointsRegistry = [];
1546
- };
1547
1585
 
1548
1586
  const sdkOptionsRegistry = {};
1549
1587
  /**
@@ -5262,6 +5300,7 @@ exports.EntityStoreBase = EntityStoreBase;
5262
5300
  exports.MEDIA_QUERY_REGEXP = MEDIA_QUERY_REGEXP;
5263
5301
  exports.addLocale = addLocale;
5264
5302
  exports.addMinHeightForEmptyStructures = addMinHeightForEmptyStructures;
5303
+ exports.breakpointsRegistry = breakpointsRegistry;
5265
5304
  exports.buildCfStyles = buildCfStyles;
5266
5305
  exports.buildStyleTag = buildStyleTag;
5267
5306
  exports.buildTemplate = buildTemplate;
@@ -5303,7 +5342,6 @@ exports.gatherDeepReferencesFromTree = gatherDeepReferencesFromTree;
5303
5342
  exports.generateDefaultDataSourceForPrebindingDefinition = generateDefaultDataSourceForPrebindingDefinition;
5304
5343
  exports.generateRandomId = generateRandomId;
5305
5344
  exports.getActiveBreakpointIndex = getActiveBreakpointIndex;
5306
- exports.getBreakpointRegistration = getBreakpointRegistration;
5307
5345
  exports.getDataFromTree = getDataFromTree;
5308
5346
  exports.getDesignTokenRegistration = getDesignTokenRegistration;
5309
5347
  exports.getElementCoordinates = getElementCoordinates;
@@ -5346,7 +5384,6 @@ exports.parseCSSValue = parseCSSValue;
5346
5384
  exports.parseDataSourcePathIntoFieldset = parseDataSourcePathIntoFieldset;
5347
5385
  exports.parseDataSourcePathWithL1DeepBindings = parseDataSourcePathWithL1DeepBindings;
5348
5386
  exports.referencesOf = referencesOf;
5349
- exports.resetBreakpointsRegistry = resetBreakpointsRegistry;
5350
5387
  exports.resetDesignTokenRegistry = resetDesignTokenRegistry;
5351
5388
  exports.resolveBackgroundImageBinding = resolveBackgroundImageBinding;
5352
5389
  exports.resolveHyperlinkPattern = resolveHyperlinkPattern;