@contentful/experiences-visual-editor-react 1.14.0 → 1.14.1-dev-20240911T0616-ea0d046.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -83,13 +83,15 @@ var PostMessageMethods$2;
83
83
  })(PostMessageMethods$2 || (PostMessageMethods$2 = {}));
84
84
  const SUPPORTED_IMAGE_FORMATS = ['jpg', 'png', 'webp', 'gif', 'avif'];
85
85
 
86
- const structureComponents = new Set([
86
+ const structureComponentIds = new Set([
87
87
  CONTENTFUL_COMPONENTS$1.section.id,
88
88
  CONTENTFUL_COMPONENTS$1.columns.id,
89
89
  CONTENTFUL_COMPONENTS$1.container.id,
90
90
  CONTENTFUL_COMPONENTS$1.singleColumn.id,
91
91
  ]);
92
- const isContentfulStructureComponent = (componentId) => structureComponents.has(componentId ?? '');
92
+ const allContentfulComponentIds = new Set(Object.values(CONTENTFUL_COMPONENTS$1).map((component) => component.id));
93
+ const isContentfulStructureComponent = (componentId) => structureComponentIds.has(componentId ?? '');
94
+ const isContentfulComponent = (componentId) => allContentfulComponentIds.has(componentId ?? '');
93
95
  const isComponentAllowedOnRoot = (componentId) => isContentfulStructureComponent(componentId) || componentId === CONTENTFUL_COMPONENTS$1.divider.id;
94
96
  const isStructureWithRelativeHeight = (componentId, height) => {
95
97
  return isContentfulStructureComponent(componentId) && !height?.toString().endsWith('px');
@@ -4039,9 +4041,25 @@ class ImportedComponentError extends Error {
4039
4041
  this.name = 'ImportedComponentError';
4040
4042
  }
4041
4043
  }
4044
+ class ExperienceSDKError extends Error {
4045
+ constructor(message) {
4046
+ super(message);
4047
+ this.name = 'ExperienceSDKError';
4048
+ }
4049
+ }
4042
4050
  class ImportedComponentErrorBoundary extends React.Component {
4043
4051
  componentDidCatch(error, _errorInfo) {
4044
- const err = new ImportedComponentError(error.message);
4052
+ if (error.name === 'ImportedComponentError' || error.name === 'ExperienceSDKError') {
4053
+ // This error was already handled by a nested error boundary and should be passed upwards
4054
+ // We have to do this as we wrap every component on every layer with this error boundary and
4055
+ // thus an error deep in the tree bubbles through many layers of error boundaries.
4056
+ throw error;
4057
+ }
4058
+ // Differentiate between custom and SDK-provided components for error tracking
4059
+ const ErrorClass = isContentfulComponent(this.props.componentId)
4060
+ ? ExperienceSDKError
4061
+ : ImportedComponentError;
4062
+ const err = new ErrorClass(error.message);
4045
4063
  err.stack = error.stack;
4046
4064
  throw err;
4047
4065
  }
@@ -4106,7 +4124,7 @@ const useComponent = ({ node: rawNode, resolveDesignValue, renderDropzone, userI
4106
4124
  const isAssembly = node.type === 'assembly';
4107
4125
  const modifiedProps = isStructureComponent || isAssembly ? componentProps : customComponentProps;
4108
4126
  const requiresDragWrapper = !isStructureComponent && componentRegistration.options?.wrapComponent === false;
4109
- const element = React.createElement(ImportedComponentErrorBoundary, null, React.createElement(componentRegistration.component, {
4127
+ const element = React.createElement(ImportedComponentErrorBoundary, { componentId: node.data.blockId }, React.createElement(componentRegistration.component, {
4110
4128
  ...modifiedProps,
4111
4129
  dragProps,
4112
4130
  }));