@lowdefy/block-utils 4.5.2 → 4.7.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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import React, { Component } from 'react';
16
+ import { BlockError, LowdefyInternalError } from '@lowdefy/errors';
16
17
  import ErrorPage from './ErrorPage.js';
17
18
  let ErrorBoundary = class ErrorBoundary extends Component {
18
19
  static getDerivedStateFromError(error) {
@@ -21,6 +22,34 @@ let ErrorBoundary = class ErrorBoundary extends Component {
21
22
  error
22
23
  };
23
24
  }
25
+ componentDidCatch(error) {
26
+ const { blockId, blockType, configKey, onError } = this.props;
27
+ // Preserve known error types
28
+ if (error.isLowdefyError) {
29
+ if (onError) {
30
+ onError(error);
31
+ }
32
+ return;
33
+ }
34
+ // Wrap unknown errors based on context
35
+ let wrappedError;
36
+ if (blockId) {
37
+ wrappedError = new BlockError(error.message, {
38
+ cause: error,
39
+ typeName: blockType,
40
+ location: blockId,
41
+ configKey,
42
+ received: this.props.properties
43
+ });
44
+ } else {
45
+ wrappedError = new LowdefyInternalError(error.message, {
46
+ cause: error
47
+ });
48
+ }
49
+ if (onError) {
50
+ onError(wrappedError);
51
+ }
52
+ }
24
53
  render() {
25
54
  const { children, description, fallback, fullPage, message, name } = this.props;
26
55
  const { hasError, error } = this.state;
package/dist/ErrorPage.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,48 +13,53 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import React from 'react';
16
+ const fontFamily = "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif";
16
17
  const ErrorPage = ({ code, description, message, name })=>/*#__PURE__*/ React.createElement("div", {
17
18
  style: {
18
- height: '100%',
19
- fontFamily: 'system-ui',
19
+ height: '100vh',
20
+ fontFamily,
20
21
  margin: 0,
21
22
  display: 'flex',
23
+ flexDirection: 'column',
24
+ alignItems: 'center',
22
25
  justifyContent: 'center',
23
- alignItems: 'center'
26
+ textAlign: 'center',
27
+ padding: '0 24px'
24
28
  }
25
29
  }, /*#__PURE__*/ React.createElement("div", {
26
30
  style: {
27
- flex: '0 1 auto',
28
31
  fontSize: '4.3em',
29
32
  fontWeight: '100',
30
- paddingRight: 30
33
+ marginBottom: 16
31
34
  }
32
35
  }, code ?? 500), /*#__PURE__*/ React.createElement("div", {
33
- style: {
34
- flex: '0 1 auto',
35
- paddingLeft: 30,
36
- maxWidth: 400,
37
- borderLeft: '1px solid #aeaeae'
38
- }
39
- }, /*#__PURE__*/ React.createElement("div", {
40
36
  style: {
41
37
  fontSize: '1.3em',
42
38
  fontWeight: '300',
43
- paddingBottom: 10
39
+ marginBottom: 8
44
40
  }
45
41
  }, name ?? 'Error'), /*#__PURE__*/ React.createElement("div", {
46
42
  style: {
47
- fontSize: '0.9em'
43
+ fontSize: '0.9em',
44
+ color: '#595959',
45
+ maxWidth: 400
48
46
  }
49
- }, message ?? 'An error has occurred.'), /*#__PURE__*/ React.createElement("div", {
47
+ }, message ?? 'An error has occurred.'), description && /*#__PURE__*/ React.createElement("div", {
50
48
  style: {
51
- fontSize: '0.9em'
49
+ fontSize: '0.9em',
50
+ color: '#595959',
51
+ maxWidth: 400,
52
+ marginTop: 4
52
53
  }
53
54
  }, description), /*#__PURE__*/ React.createElement("div", {
54
55
  style: {
55
- paddingTop: 20
56
+ marginTop: 24
56
57
  }
57
58
  }, /*#__PURE__*/ React.createElement("a", {
58
- href: "/"
59
- }, "Return to home page"))));
59
+ href: "/",
60
+ style: {
61
+ color: '#1890ff',
62
+ textDecoration: 'none'
63
+ }
64
+ }, "Return to home page")));
60
65
  export default ErrorPage;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,9 +14,10 @@
14
14
  limitations under the License.
15
15
  */ import blockDefaultProps from './blockDefaultProps.js';
16
16
  import blockSchema from './blockSchema.js';
17
- import HtmlComponent from './HtmlComponent.js';
18
17
  import ErrorBoundary from './ErrorBoundary.js';
18
+ import ErrorPage from './ErrorPage.js';
19
+ import HtmlComponent from './HtmlComponent.js';
19
20
  import makeCssClass from './makeCssClass.js';
20
21
  import mediaToCssObject from './mediaToCssObject.js';
21
22
  import renderHtml from './renderHtml.js';
22
- export { blockDefaultProps, blockSchema, ErrorBoundary, HtmlComponent, makeCssClass, mediaToCssObject, renderHtml };
23
+ export { blockDefaultProps, blockSchema, ErrorBoundary, ErrorPage, HtmlComponent, makeCssClass, mediaToCssObject, renderHtml };
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-undef */ /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/block-utils",
3
- "version": "4.5.2",
3
+ "version": "4.7.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy Block Utils",
6
6
  "homepage": "https://lowdefy.com",
@@ -35,7 +35,8 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@emotion/css": "11.11.2",
38
- "@lowdefy/helpers": "4.5.2",
38
+ "@lowdefy/errors": "4.7.0",
39
+ "@lowdefy/helpers": "4.7.0",
39
40
  "dompurify": "3.2.4",
40
41
  "react": "18.2.0",
41
42
  "react-dom": "18.2.0"