@faasjs/react 0.0.3-beta.90 → 0.0.3-beta.92

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.d.mts CHANGED
@@ -2,6 +2,30 @@ import { Response, Options, ResponseError } from '@faasjs/browser';
2
2
  export { FaasBrowserClient, Options, Response, ResponseError, ResponseHeaders } from '@faasjs/browser';
3
3
  import { FaasAction, FaasData, FaasParams } from '@faasjs/types';
4
4
  export { FaasAction, FaasData, FaasParams } from '@faasjs/types';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ import { ReactNode, ReactElement, Component } from 'react';
7
+
8
+ interface ErrorBoundaryProps {
9
+ children?: ReactNode;
10
+ onError: (error: Error | null, info: any) => void;
11
+ errorChildren?: ReactElement<ErrorChildrenProps>;
12
+ }
13
+ type ErrorChildrenProps = {
14
+ error?: Error;
15
+ info?: any;
16
+ errorMessage?: string;
17
+ errorDescription?: string;
18
+ };
19
+ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
20
+ error?: Error;
21
+ info?: {
22
+ componentStack?: string;
23
+ };
24
+ }> {
25
+ constructor(props: ErrorBoundaryProps);
26
+ componentDidCatch(error: Error | null, info: any): void;
27
+ render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element;
28
+ }
5
29
 
6
30
  /**
7
31
  * Injects FaasData props.
@@ -119,4 +143,4 @@ declare function useFaas<PathOrData extends FaasAction>(action: string | PathOrD
119
143
  */
120
144
  declare function FaasDataWrapper<PathOrData extends FaasAction>(props: FaasDataWrapperProps<PathOrData>): JSX.Element;
121
145
 
122
- export { FaasDataInjection, FaasDataWrapper, FaasDataWrapperProps, FaasReactClient, FaasReactClientInstance, faas, getClient, useFaas };
146
+ export { ErrorBoundary, ErrorBoundaryProps, ErrorChildrenProps, FaasDataInjection, FaasDataWrapper, FaasDataWrapperProps, FaasReactClient, FaasReactClientInstance, faas, getClient, useFaas };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,30 @@ import { Response, Options, ResponseError } from '@faasjs/browser';
2
2
  export { FaasBrowserClient, Options, Response, ResponseError, ResponseHeaders } from '@faasjs/browser';
3
3
  import { FaasAction, FaasData, FaasParams } from '@faasjs/types';
4
4
  export { FaasAction, FaasData, FaasParams } from '@faasjs/types';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ import { ReactNode, ReactElement, Component } from 'react';
7
+
8
+ interface ErrorBoundaryProps {
9
+ children?: ReactNode;
10
+ onError: (error: Error | null, info: any) => void;
11
+ errorChildren?: ReactElement<ErrorChildrenProps>;
12
+ }
13
+ type ErrorChildrenProps = {
14
+ error?: Error;
15
+ info?: any;
16
+ errorMessage?: string;
17
+ errorDescription?: string;
18
+ };
19
+ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
20
+ error?: Error;
21
+ info?: {
22
+ componentStack?: string;
23
+ };
24
+ }> {
25
+ constructor(props: ErrorBoundaryProps);
26
+ componentDidCatch(error: Error | null, info: any): void;
27
+ render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element;
28
+ }
5
29
 
6
30
  /**
7
31
  * Injects FaasData props.
@@ -119,4 +143,4 @@ declare function useFaas<PathOrData extends FaasAction>(action: string | PathOrD
119
143
  */
120
144
  declare function FaasDataWrapper<PathOrData extends FaasAction>(props: FaasDataWrapperProps<PathOrData>): JSX.Element;
121
145
 
122
- export { FaasDataInjection, FaasDataWrapper, FaasDataWrapperProps, FaasReactClient, FaasReactClientInstance, faas, getClient, useFaas };
146
+ export { ErrorBoundary, ErrorBoundaryProps, ErrorChildrenProps, FaasDataInjection, FaasDataWrapper, FaasDataWrapperProps, FaasReactClient, FaasReactClientInstance, faas, getClient, useFaas };
package/dist/index.js CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  var browser = require('@faasjs/browser');
4
4
  var react = require('react');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ // src/index.tsx
8
+ var ErrorBoundary = class extends react.Component {
9
+ constructor(props) {
10
+ super(props);
11
+ this.state = {
12
+ error: void 0,
13
+ info: { componentStack: "" }
14
+ };
15
+ }
16
+ componentDidCatch(error, info) {
17
+ this.setState({
18
+ error,
19
+ info
20
+ });
21
+ }
22
+ render() {
23
+ var _a;
24
+ const errorMessage = (this.state.error || "").toString();
25
+ const errorDescription = ((_a = this.state.info) == null ? void 0 : _a.componentStack) ? this.state.info.componentStack : null;
26
+ if (this.state.error) {
27
+ if (this.props.onError)
28
+ this.props.onError(this.state.error, this.state.info);
29
+ if (this.props.errorChildren)
30
+ return react.cloneElement(this.props.errorChildren, {
31
+ error: this.state.error,
32
+ info: this.state.info,
33
+ errorMessage,
34
+ errorDescription
35
+ });
36
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
37
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: errorMessage }),
38
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { children: errorDescription })
39
+ ] });
40
+ }
41
+ return this.props.children;
42
+ }
43
+ };
5
44
 
6
45
  // src/index.tsx
7
46
  var clients = {};
@@ -159,6 +198,7 @@ Object.defineProperty(exports, 'FaasBrowserClient', {
159
198
  enumerable: true,
160
199
  get: function () { return browser.FaasBrowserClient; }
161
200
  });
201
+ exports.ErrorBoundary = ErrorBoundary;
162
202
  exports.FaasDataWrapper = FaasDataWrapper;
163
203
  exports.FaasReactClient = FaasReactClient;
164
204
  exports.faas = faas;
package/dist/index.mjs CHANGED
@@ -1,6 +1,45 @@
1
1
  import { FaasBrowserClient } from '@faasjs/browser';
2
2
  export { FaasBrowserClient } from '@faasjs/browser';
3
- import { useState, useEffect, createElement, cloneElement } from 'react';
3
+ import { Component, cloneElement, useState, useEffect, createElement } from 'react';
4
+ import { jsxs, jsx } from 'react/jsx-runtime';
5
+
6
+ // src/index.tsx
7
+ var ErrorBoundary = class extends Component {
8
+ constructor(props) {
9
+ super(props);
10
+ this.state = {
11
+ error: void 0,
12
+ info: { componentStack: "" }
13
+ };
14
+ }
15
+ componentDidCatch(error, info) {
16
+ this.setState({
17
+ error,
18
+ info
19
+ });
20
+ }
21
+ render() {
22
+ var _a;
23
+ const errorMessage = (this.state.error || "").toString();
24
+ const errorDescription = ((_a = this.state.info) == null ? void 0 : _a.componentStack) ? this.state.info.componentStack : null;
25
+ if (this.state.error) {
26
+ if (this.props.onError)
27
+ this.props.onError(this.state.error, this.state.info);
28
+ if (this.props.errorChildren)
29
+ return cloneElement(this.props.errorChildren, {
30
+ error: this.state.error,
31
+ info: this.state.info,
32
+ errorMessage,
33
+ errorDescription
34
+ });
35
+ return /* @__PURE__ */ jsxs("div", { children: [
36
+ /* @__PURE__ */ jsx("p", { children: errorMessage }),
37
+ /* @__PURE__ */ jsx("pre", { children: errorDescription })
38
+ ] });
39
+ }
40
+ return this.props.children;
41
+ }
42
+ };
4
43
 
5
44
  // src/index.tsx
6
45
  var clients = {};
@@ -154,4 +193,4 @@ function FaasDataWrapper(props) {
154
193
  return createElement(client.FaasDataWrapper, props);
155
194
  }
156
195
 
157
- export { FaasDataWrapper, FaasReactClient, faas, getClient, useFaas };
196
+ export { ErrorBoundary, FaasDataWrapper, FaasReactClient, faas, getClient, useFaas };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/react",
3
- "version": "0.0.3-beta.90",
3
+ "version": "0.0.3-beta.92",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@faasjs/browser": "^0.0.3-beta.90"
25
+ "@faasjs/browser": "^0.0.3-beta.92"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": "*"