@axelor/aos-mobile-error 8.3.8 → 8.4.1

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,10 +1,14 @@
1
1
  import React from 'react';
2
+ export declare class MaintenanceError extends Error {
3
+ constructor(message?: string);
4
+ }
2
5
  interface ErrorBoundaryProps {
3
6
  children: React.ReactNode;
4
- errorScreen: ({ errorMessage, onReloadPress, }: {
7
+ ErrorScreen: React.ComponentType<{
5
8
  errorMessage: string;
6
- onReloadPress: () => any;
7
- }) => React.ReactNode;
9
+ handleReload: () => void;
10
+ isMaintenance?: boolean;
11
+ }>;
8
12
  putMethod: (fetchOptions: {
9
13
  additionalURL: string;
10
14
  data: any;
@@ -16,6 +20,7 @@ interface ErrorBoundaryState {
16
20
  hasError: boolean;
17
21
  tracing: boolean;
18
22
  errorMessage: string;
23
+ maintenance: boolean;
19
24
  }
20
25
  declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
21
26
  constructor(props: any);
@@ -24,6 +29,7 @@ declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBou
24
29
  };
25
30
  componentDidCatch(error: any, errorInfo: any): void;
26
31
  reloadApp(): void;
27
- render(): React.ReactNode;
32
+ resetState(): void;
33
+ render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element;
28
34
  }
29
35
  export default ErrorBoundary;
@@ -18,6 +18,12 @@
18
18
  import React from 'react';
19
19
  const TECHNICAL_ABNORMALITY = 0;
20
20
  const CONFIGURATION_PROBLEM = 4;
21
+ export class MaintenanceError extends Error {
22
+ constructor(message = 'The server is under maintenance.') {
23
+ super(message);
24
+ this.name = 'MaintenanceError';
25
+ }
26
+ }
21
27
  class ErrorBoundary extends React.Component {
22
28
  constructor(props) {
23
29
  super(props);
@@ -25,6 +31,7 @@ class ErrorBoundary extends React.Component {
25
31
  hasError: false,
26
32
  tracing: false,
27
33
  errorMessage: '',
34
+ maintenance: false,
28
35
  };
29
36
  }
30
37
  static getDerivedStateFromError() {
@@ -32,6 +39,15 @@ class ErrorBoundary extends React.Component {
32
39
  }
33
40
  componentDidCatch(error, errorInfo) {
34
41
  const { putMethod, userIdfetcher, additionalURL } = this.props;
42
+ if (error instanceof MaintenanceError) {
43
+ this.setState(state => ({
44
+ ...state,
45
+ hasError: true,
46
+ maintenance: true,
47
+ errorMessage: error.message,
48
+ }));
49
+ return;
50
+ }
35
51
  userIdfetcher().then(userId => {
36
52
  this.setState(state => ({
37
53
  ...state,
@@ -56,15 +72,16 @@ class ErrorBoundary extends React.Component {
56
72
  reloadApp() {
57
73
  window.location.reload();
58
74
  }
75
+ resetState() {
76
+ this.setState({ hasError: false });
77
+ }
59
78
  render() {
60
- const { errorScreen } = this.props;
61
- if (this.state.hasError) {
62
- return errorScreen({
63
- errorMessage: this.state.errorMessage,
64
- onReloadPress: () => this.setState({ hasError: false }),
65
- });
79
+ const { children, ErrorScreen } = this.props;
80
+ const { hasError, errorMessage, maintenance } = this.state;
81
+ if (hasError) {
82
+ return (<ErrorScreen errorMessage={errorMessage} handleReload={() => this.resetState()} isMaintenance={maintenance}/>);
66
83
  }
67
- return this.props.children;
84
+ return children;
68
85
  }
69
86
  }
70
87
  export default ErrorBoundary;
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../src/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAsBhC,MAAM,aAAc,SAAQ,KAAK,CAAC,SAGjC;IACC,YAAY,KAAK;QACf,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACX,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,KAAK;YACd,YAAY,EAAE,EAAE;SACjB,CAAC;IACJ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W,EAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QAEzD,IAAI,QAAQ,EAAE;YACZ,OAAO,CACL,CAAC,WAAW,CACV,YAAY,CAAC,CAAC,YAAY,CAAC,CAC3B,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CACtC,aAAa,CAAC,CAAC,WAAW,CAAC,EAC3B,CACH,CAAC;SACH;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAED,eAAe,aAAa,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { default as ErrorBoundary } from './ErrorBoundary';
1
+ export { default as ErrorBoundary, MaintenanceError } from './ErrorBoundary';
package/lib/index.js CHANGED
@@ -15,5 +15,5 @@
15
15
  * You should have received a copy of the GNU Affero General Public License
16
16
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
- export { default as ErrorBoundary } from './ErrorBoundary';
18
+ export { default as ErrorBoundary, MaintenanceError } from './ErrorBoundary';
19
19
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axelor/aos-mobile-error",
3
- "version": "8.3.8",
3
+ "version": "8.4.1",
4
4
  "author": "Axelor",
5
5
  "license": "AGPL-3.0-only",
6
6
  "publishConfig": {
@@ -24,18 +24,18 @@
24
24
  "license:add": "npx add-copyright-header --generate --dir 'src'"
25
25
  },
26
26
  "peerDependencies": {
27
- "react": "18.2.0"
27
+ "react": "18.3.1"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@babel/runtime": "^7.20.0",
31
- "@react-native/eslint-config": "0.73.2",
32
- "@types/react": "^18.2.6",
31
+ "@react-native/eslint-config": "0.75.5",
32
+ "@types/react": "^18.3.20",
33
33
  "cpx2": "^4.2.0",
34
34
  "eslint": "8.57.0",
35
35
  "prettier": "^3.3.3",
36
- "react": "18.2.0"
36
+ "react": "18.3.1"
37
37
  },
38
38
  "resolutions": {
39
- "@types/react": "^18.2.6"
39
+ "@types/react": "^18.3.20"
40
40
  }
41
41
  }