@faasjs/react 1.7.2 → 2.0.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/README.md CHANGED
@@ -27,17 +27,6 @@ const client = FaasReactClient({
27
27
 
28
28
  2. Use [faas](#faas), [useFaas](#usefaas) or [FaasDataWrapper](#faasdatawrapper).
29
29
 
30
- ## Usage with [@preact/signal-react](https://github.com/preactjs/signals/blob/main/packages/react/README.md)
31
-
32
- 1. `npm i --save-dev @preact/signals-react-transform`
33
- 2. Add `@preact/signals-react-transform` to babel config:
34
- ```json
35
- {
36
- "plugins": [["module:@preact/signals-react-transform"]]
37
- }
38
- ```
39
- 3. Add `import '@preact/signals-react/auto'` to your test files.
40
-
41
30
  ## Classes
42
31
 
43
32
  - [ErrorBoundary](classes/ErrorBoundary.md)
@@ -60,7 +49,6 @@ const client = FaasReactClient({
60
49
  - [FaasReactClientOptions](type-aliases/FaasReactClientOptions.md)
61
50
  - [Options](type-aliases/Options.md)
62
51
  - [ResponseHeaders](type-aliases/ResponseHeaders.md)
63
- - [SignalOptions](type-aliases/SignalOptions.md)
64
52
  - [useFaasOptions](type-aliases/useFaasOptions.md)
65
53
 
66
54
  ## Functions
@@ -69,7 +57,5 @@ const client = FaasReactClient({
69
57
  - [FaasReactClient](functions/FaasReactClient.md)
70
58
  - [faas](functions/faas.md)
71
59
  - [getClient](functions/getClient.md)
72
- - [signal](functions/signal.md)
73
60
  - [useConstant](functions/useConstant.md)
74
61
  - [useFaas](functions/useFaas.md)
75
- - [useSignalState](functions/useSignalState.md)
package/dist/index.d.mts CHANGED
@@ -3,10 +3,7 @@ export { FaasAction, FaasData, FaasParams } from '@faasjs/types';
3
3
  import { Options, ResponseError, Response as Response$1 } from '@faasjs/browser';
4
4
  export { Options, Response, ResponseError, ResponseHeaders } from '@faasjs/browser';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
- import { ReactNode, ReactElement, Component, SetStateAction } from 'react';
7
- import * as _preact_signals_core from '@preact/signals-core';
8
- export { batch, computed, effect, signal as originSignal } from '@preact/signals-react';
9
- export { useSignal as originUseSignal, useComputed, useSignalEffect, useSignals } from '@preact/signals-react/runtime';
6
+ import { ReactNode, ReactElement, Component } from 'react';
10
7
 
11
8
  /**
12
9
  * Returns a constant value that is created by the given function.
@@ -40,7 +37,7 @@ type FaasDataInjection<Data = any> = {
40
37
  data: Data
41
38
  error: any
42
39
  promise: Promise<Response<Data>>
43
- reload(params?: Record<string, any>): void
40
+ reload(params?: Record<string, any>): Promise<Response<Data>>
44
41
  setData: React.Dispatch<React.SetStateAction<Data>>
45
42
  setLoading: React.Dispatch<React.SetStateAction<boolean>>
46
43
  setPromise: React.Dispatch<React.SetStateAction<Promise<Response<Data>>>>
@@ -181,44 +178,4 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
181
178
  render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element;
182
179
  }
183
180
 
184
- type SignalOptions = {
185
- debugName?: string;
186
- };
187
- /**
188
- * Create a [signal](https://preactjs.com/guide/v10/signals) with options
189
- *
190
- * @param initialValue
191
- * @param options
192
- * @param options.debugName - debug name for signal, will print signal value to console.debug
193
- *
194
- * @example
195
- * ```ts
196
- * import { signal } from '@faasjs/react'
197
- *
198
- * const count = signal(0, { debugName: 'count' })
199
- *
200
- * count.value = 1
201
- * ```
202
- */
203
- declare function signal<T = any>(initialValue: any, options?: SignalOptions): _preact_signals_core.Signal<T>;
204
- /**
205
- * Create a [signal](https://preactjs.com/guide/v10/signals) like useState.
206
- *
207
- * ```tsx
208
- * import { useSignalState, useSignalEffect } from '@faasjs/react'
209
- *
210
- * function App () {
211
- * const [count, setCount] = useSignalState(0, { debugName: 'count' })
212
- *
213
- * useSignalEffect(() => console.log('count', count))
214
- *
215
- * return <div>
216
- * <button onClick={() => setCount(count + 1)}>+</button>
217
- * <span>{count}</span>
218
- * </div>
219
- * }
220
- * ```
221
- */
222
- declare function useSignalState<T = any>(initialValue: T, options?: SignalOptions): readonly [T, (changes: SetStateAction<T>) => void];
223
-
224
- export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, type SignalOptions, faas, getClient, signal, useConstant, useFaas, type useFaasOptions, useSignalState };
181
+ export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, faas, getClient, useConstant, useFaas, type useFaasOptions };
package/dist/index.d.ts CHANGED
@@ -3,10 +3,7 @@ export { FaasAction, FaasData, FaasParams } from '@faasjs/types';
3
3
  import { Options, ResponseError, Response as Response$1 } from '@faasjs/browser';
4
4
  export { Options, Response, ResponseError, ResponseHeaders } from '@faasjs/browser';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
- import { ReactNode, ReactElement, Component, SetStateAction } from 'react';
7
- import * as _preact_signals_core from '@preact/signals-core';
8
- export { batch, computed, effect, signal as originSignal } from '@preact/signals-react';
9
- export { useSignal as originUseSignal, useComputed, useSignalEffect, useSignals } from '@preact/signals-react/runtime';
6
+ import { ReactNode, ReactElement, Component } from 'react';
10
7
 
11
8
  /**
12
9
  * Returns a constant value that is created by the given function.
@@ -40,7 +37,7 @@ type FaasDataInjection<Data = any> = {
40
37
  data: Data
41
38
  error: any
42
39
  promise: Promise<Response<Data>>
43
- reload(params?: Record<string, any>): void
40
+ reload(params?: Record<string, any>): Promise<Response<Data>>
44
41
  setData: React.Dispatch<React.SetStateAction<Data>>
45
42
  setLoading: React.Dispatch<React.SetStateAction<boolean>>
46
43
  setPromise: React.Dispatch<React.SetStateAction<Promise<Response<Data>>>>
@@ -181,44 +178,4 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
181
178
  render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element;
182
179
  }
183
180
 
184
- type SignalOptions = {
185
- debugName?: string;
186
- };
187
- /**
188
- * Create a [signal](https://preactjs.com/guide/v10/signals) with options
189
- *
190
- * @param initialValue
191
- * @param options
192
- * @param options.debugName - debug name for signal, will print signal value to console.debug
193
- *
194
- * @example
195
- * ```ts
196
- * import { signal } from '@faasjs/react'
197
- *
198
- * const count = signal(0, { debugName: 'count' })
199
- *
200
- * count.value = 1
201
- * ```
202
- */
203
- declare function signal<T = any>(initialValue: any, options?: SignalOptions): _preact_signals_core.Signal<T>;
204
- /**
205
- * Create a [signal](https://preactjs.com/guide/v10/signals) like useState.
206
- *
207
- * ```tsx
208
- * import { useSignalState, useSignalEffect } from '@faasjs/react'
209
- *
210
- * function App () {
211
- * const [count, setCount] = useSignalState(0, { debugName: 'count' })
212
- *
213
- * useSignalEffect(() => console.log('count', count))
214
- *
215
- * return <div>
216
- * <button onClick={() => setCount(count + 1)}>+</button>
217
- * <span>{count}</span>
218
- * </div>
219
- * }
220
- * ```
221
- */
222
- declare function useSignalState<T = any>(initialValue: T, options?: SignalOptions): readonly [T, (changes: SetStateAction<T>) => void];
223
-
224
- export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, type SignalOptions, faas, getClient, signal, useConstant, useFaas, type useFaasOptions, useSignalState };
181
+ export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, faas, getClient, useConstant, useFaas, type useFaasOptions };
package/dist/index.js CHANGED
@@ -3,8 +3,6 @@
3
3
  var react = require('react');
4
4
  var browser = require('@faasjs/browser');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
- var signalsReact = require('@preact/signals-react');
7
- var runtime = require('@preact/signals-react/runtime');
8
6
 
9
7
  // src/constant.ts
10
8
  function useConstant(fn) {
@@ -110,6 +108,7 @@ function FaasReactClient({
110
108
  if (params2)
111
109
  setParams(params2);
112
110
  setReloadTimes((prev) => prev + 1);
111
+ return promise;
113
112
  },
114
113
  [params]
115
114
  );
@@ -241,63 +240,11 @@ var ErrorBoundary = class extends react.Component {
241
240
  }
242
241
  };
243
242
  ErrorBoundary.whyDidYouRender = true;
244
- function signal(initialValue, options = {}) {
245
- const state = signalsReact.signal(initialValue);
246
- if (options.debugName)
247
- signalsReact.effect(() => console.debug(options.debugName, state.value));
248
- return state;
249
- }
250
- function useSignalState(initialValue, options = {}) {
251
- const state = runtime.useSignal(initialValue);
252
- if (options.debugName) {
253
- runtime.useSignalEffect(() => console.log(options.debugName, state.value));
254
- }
255
- return [
256
- state.value,
257
- (changes) => {
258
- state.value = typeof changes === "function" ? changes(state.value) : changes;
259
- }
260
- ];
261
- }
262
243
 
263
- Object.defineProperty(exports, "batch", {
264
- enumerable: true,
265
- get: function () { return signalsReact.batch; }
266
- });
267
- Object.defineProperty(exports, "computed", {
268
- enumerable: true,
269
- get: function () { return signalsReact.computed; }
270
- });
271
- Object.defineProperty(exports, "effect", {
272
- enumerable: true,
273
- get: function () { return signalsReact.effect; }
274
- });
275
- Object.defineProperty(exports, "originSignal", {
276
- enumerable: true,
277
- get: function () { return signalsReact.signal; }
278
- });
279
- Object.defineProperty(exports, "originUseSignal", {
280
- enumerable: true,
281
- get: function () { return runtime.useSignal; }
282
- });
283
- Object.defineProperty(exports, "useComputed", {
284
- enumerable: true,
285
- get: function () { return runtime.useComputed; }
286
- });
287
- Object.defineProperty(exports, "useSignalEffect", {
288
- enumerable: true,
289
- get: function () { return runtime.useSignalEffect; }
290
- });
291
- Object.defineProperty(exports, "useSignals", {
292
- enumerable: true,
293
- get: function () { return runtime.useSignals; }
294
- });
295
244
  exports.ErrorBoundary = ErrorBoundary;
296
245
  exports.FaasDataWrapper = FaasDataWrapper;
297
246
  exports.FaasReactClient = FaasReactClient;
298
247
  exports.faas = faas;
299
248
  exports.getClient = getClient;
300
- exports.signal = signal;
301
249
  exports.useConstant = useConstant;
302
250
  exports.useFaas = useFaas;
303
- exports.useSignalState = useSignalState;
package/dist/index.mjs CHANGED
@@ -1,10 +1,6 @@
1
1
  import { useRef, useState, useEffect, Component, cloneElement, useCallback, useMemo } from 'react';
2
2
  import { FaasBrowserClient } from '@faasjs/browser';
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
- import { signal as signal$1, effect } from '@preact/signals-react';
5
- export { batch, computed, effect, signal as originSignal } from '@preact/signals-react';
6
- import { useSignal, useSignalEffect } from '@preact/signals-react/runtime';
7
- export { useSignal as originUseSignal, useComputed, useSignalEffect, useSignals } from '@preact/signals-react/runtime';
8
4
 
9
5
  // src/constant.ts
10
6
  function useConstant(fn) {
@@ -110,6 +106,7 @@ function FaasReactClient({
110
106
  if (params2)
111
107
  setParams(params2);
112
108
  setReloadTimes((prev) => prev + 1);
109
+ return promise;
113
110
  },
114
111
  [params]
115
112
  );
@@ -241,23 +238,5 @@ var ErrorBoundary = class extends Component {
241
238
  }
242
239
  };
243
240
  ErrorBoundary.whyDidYouRender = true;
244
- function signal(initialValue, options = {}) {
245
- const state = signal$1(initialValue);
246
- if (options.debugName)
247
- effect(() => console.debug(options.debugName, state.value));
248
- return state;
249
- }
250
- function useSignalState(initialValue, options = {}) {
251
- const state = useSignal(initialValue);
252
- if (options.debugName) {
253
- useSignalEffect(() => console.log(options.debugName, state.value));
254
- }
255
- return [
256
- state.value,
257
- (changes) => {
258
- state.value = typeof changes === "function" ? changes(state.value) : changes;
259
- }
260
- ];
261
- }
262
241
 
263
- export { ErrorBoundary, FaasDataWrapper, FaasReactClient, faas, getClient, signal, useConstant, useFaas, useSignalState };
242
+ export { ErrorBoundary, FaasDataWrapper, FaasReactClient, faas, getClient, useConstant, useFaas };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/react",
3
- "version": "1.7.2",
3
+ "version": "2.0.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -22,17 +22,14 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@faasjs/browser": "1.7.2"
25
+ "@faasjs/browser": "2.0.0"
26
26
  },
27
27
  "peerDependencies": {
28
- "react": "*",
29
- "@preact/signals-react": "*"
28
+ "react": "*"
30
29
  },
31
30
  "devDependencies": {
32
31
  "@types/react": "*",
33
- "react": "*",
34
- "@preact/signals-react": "*",
35
- "@types/use-sync-external-store": "*"
32
+ "react": "*"
36
33
  },
37
34
  "engines": {
38
35
  "npm": ">=9.0.0",