@faasjs/react 0.0.4-beta.11 → 0.0.4-beta.12

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
@@ -35,6 +35,7 @@ React plugin for FaasJS.
35
35
  - [FaasReactClientInstance](#faasreactclientinstance)
36
36
  - [Options](#options)
37
37
  - [ResponseHeaders](#responseheaders)
38
+ - [SignalOptions](#signaloptions)
38
39
  - [useFaasOptions](#usefaasoptions)
39
40
 
40
41
  ### Functions
@@ -43,6 +44,7 @@ React plugin for FaasJS.
43
44
  - [FaasReactClient](#faasreactclient)
44
45
  - [faas](#faas)
45
46
  - [getClient](#getclient)
47
+ - [signal](#signal)
46
48
  - [useFaas](#usefaas)
47
49
 
48
50
  ## Type Aliases
@@ -183,6 +185,18 @@ ___
183
185
 
184
186
  ___
185
187
 
188
+ ### SignalOptions
189
+
190
+ Ƭ **SignalOptions**: `Object`
191
+
192
+ #### Type declaration
193
+
194
+ | Name | Type |
195
+ | :------ | :------ |
196
+ | `debugName?` | `string` |
197
+
198
+ ___
199
+
186
200
  ### useFaasOptions
187
201
 
188
202
  Ƭ **useFaasOptions**\<`PathOrData`\>: `Object`
@@ -322,6 +336,31 @@ getClient('another-domain')
322
336
 
323
337
  ___
324
338
 
339
+ ### signal
340
+
341
+ ▸ **signal**\<`T`\>(`initialValue`, `options?`): `Signal`\<`T`\>
342
+
343
+ Create a [signal](https://preactjs.com/guide/v10/signals) with options
344
+
345
+ #### Type parameters
346
+
347
+ | Name | Type |
348
+ | :------ | :------ |
349
+ | `T` | `any` |
350
+
351
+ #### Parameters
352
+
353
+ | Name | Type |
354
+ | :------ | :------ |
355
+ | `initialValue` | `any` |
356
+ | `options` | [`SignalOptions`](#signaloptions) |
357
+
358
+ #### Returns
359
+
360
+ `Signal`\<`T`\>
361
+
362
+ ___
363
+
325
364
  ### useFaas
326
365
 
327
366
  ▸ **useFaas**\<`PathOrData`\>(`action`, `defaultParams`, `options?`): [`FaasDataInjection`](#faasdatainjection)\<[`FaasData`](#faasdata)\<`PathOrData`\>\>
package/dist/index.d.mts CHANGED
@@ -4,6 +4,8 @@ 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
6
  import { ReactNode, ReactElement, Component } from 'react';
7
+ import * as _preact_signals_core from '@preact/signals-core';
8
+ export { batch, computed, effect, signal as originSignal, useComputed, useSignal, useSignalEffect } from '@preact/signals-react';
7
9
 
8
10
  type FaasReactClientInstance = {
9
11
  id: string
@@ -161,4 +163,25 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
161
163
  render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<ReactNode>;
162
164
  }
163
165
 
164
- export { ErrorBoundary, ErrorBoundaryProps, ErrorChildrenProps, FaasDataInjection, FaasDataWrapper, FaasDataWrapperProps, FaasReactClient, FaasReactClientInstance, faas, getClient, useFaas, useFaasOptions };
166
+ type SignalOptions = {
167
+ debugName?: string;
168
+ };
169
+ /**
170
+ * Create a [signal](https://preactjs.com/guide/v10/signals) with options
171
+ *
172
+ * @param initialValue
173
+ * @param options
174
+ * @param options.debugName - debug name for signal, will print signal value to console.debug
175
+ *
176
+ * @example
177
+ * ```ts
178
+ * import { signal } from '@faasjs/react'
179
+ *
180
+ * const count = signal(0, { debugName: 'count' })
181
+ *
182
+ * count.value = 1
183
+ * ```
184
+ */
185
+ declare function signal<T = any>(initialValue: any, options?: SignalOptions): _preact_signals_core.Signal<T>;
186
+
187
+ export { ErrorBoundary, ErrorBoundaryProps, ErrorChildrenProps, FaasDataInjection, FaasDataWrapper, FaasDataWrapperProps, FaasReactClient, FaasReactClientInstance, SignalOptions, faas, getClient, signal, useFaas, useFaasOptions };
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@ 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
6
  import { ReactNode, ReactElement, Component } from 'react';
7
+ import * as _preact_signals_core from '@preact/signals-core';
8
+ export { batch, computed, effect, signal as originSignal, useComputed, useSignal, useSignalEffect } from '@preact/signals-react';
7
9
 
8
10
  type FaasReactClientInstance = {
9
11
  id: string
@@ -161,4 +163,25 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
161
163
  render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<ReactNode>;
162
164
  }
163
165
 
164
- export { ErrorBoundary, ErrorBoundaryProps, ErrorChildrenProps, FaasDataInjection, FaasDataWrapper, FaasDataWrapperProps, FaasReactClient, FaasReactClientInstance, faas, getClient, useFaas, useFaasOptions };
166
+ type SignalOptions = {
167
+ debugName?: string;
168
+ };
169
+ /**
170
+ * Create a [signal](https://preactjs.com/guide/v10/signals) with options
171
+ *
172
+ * @param initialValue
173
+ * @param options
174
+ * @param options.debugName - debug name for signal, will print signal value to console.debug
175
+ *
176
+ * @example
177
+ * ```ts
178
+ * import { signal } from '@faasjs/react'
179
+ *
180
+ * const count = signal(0, { debugName: 'count' })
181
+ *
182
+ * count.value = 1
183
+ * ```
184
+ */
185
+ declare function signal<T = any>(initialValue: any, options?: SignalOptions): _preact_signals_core.Signal<T>;
186
+
187
+ export { ErrorBoundary, ErrorBoundaryProps, ErrorChildrenProps, FaasDataInjection, FaasDataWrapper, FaasDataWrapperProps, FaasReactClient, FaasReactClientInstance, SignalOptions, faas, getClient, signal, useFaas, useFaasOptions };
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@
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');
6
7
 
7
8
  // src/client.tsx
8
9
  var clients = {};
@@ -224,10 +225,45 @@ var ErrorBoundary = class extends react.Component {
224
225
  return this.props.children;
225
226
  }
226
227
  };
228
+ function signal(initialValue, options = {}) {
229
+ const state = signalsReact.signal(initialValue);
230
+ if (options.debugName)
231
+ signalsReact.effect(() => console.debug(options.debugName, state.value));
232
+ return state;
233
+ }
227
234
 
235
+ Object.defineProperty(exports, 'batch', {
236
+ enumerable: true,
237
+ get: function () { return signalsReact.batch; }
238
+ });
239
+ Object.defineProperty(exports, 'computed', {
240
+ enumerable: true,
241
+ get: function () { return signalsReact.computed; }
242
+ });
243
+ Object.defineProperty(exports, 'effect', {
244
+ enumerable: true,
245
+ get: function () { return signalsReact.effect; }
246
+ });
247
+ Object.defineProperty(exports, 'originSignal', {
248
+ enumerable: true,
249
+ get: function () { return signalsReact.signal; }
250
+ });
251
+ Object.defineProperty(exports, 'useComputed', {
252
+ enumerable: true,
253
+ get: function () { return signalsReact.useComputed; }
254
+ });
255
+ Object.defineProperty(exports, 'useSignal', {
256
+ enumerable: true,
257
+ get: function () { return signalsReact.useSignal; }
258
+ });
259
+ Object.defineProperty(exports, 'useSignalEffect', {
260
+ enumerable: true,
261
+ get: function () { return signalsReact.useSignalEffect; }
262
+ });
228
263
  exports.ErrorBoundary = ErrorBoundary;
229
264
  exports.FaasDataWrapper = FaasDataWrapper;
230
265
  exports.FaasReactClient = FaasReactClient;
231
266
  exports.faas = faas;
232
267
  exports.getClient = getClient;
268
+ exports.signal = signal;
233
269
  exports.useFaas = useFaas;
package/dist/index.mjs CHANGED
@@ -1,6 +1,8 @@
1
1
  import { useState, useEffect, cloneElement, Component } 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, useComputed, useSignal, useSignalEffect } from '@preact/signals-react';
4
6
 
5
7
  // src/client.tsx
6
8
  var clients = {};
@@ -222,5 +224,11 @@ var ErrorBoundary = class extends Component {
222
224
  return this.props.children;
223
225
  }
224
226
  };
227
+ function signal(initialValue, options = {}) {
228
+ const state = signal$1(initialValue);
229
+ if (options.debugName)
230
+ effect(() => console.debug(options.debugName, state.value));
231
+ return state;
232
+ }
225
233
 
226
- export { ErrorBoundary, FaasDataWrapper, FaasReactClient, faas, getClient, useFaas };
234
+ export { ErrorBoundary, FaasDataWrapper, FaasReactClient, faas, getClient, signal, useFaas };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/react",
3
- "version": "0.0.4-beta.11",
3
+ "version": "0.0.4-beta.12",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -22,14 +22,17 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@faasjs/browser": "0.0.4-beta.11"
25
+ "@faasjs/browser": "0.0.4-beta.12"
26
26
  },
27
27
  "peerDependencies": {
28
- "react": "*"
28
+ "react": "*",
29
+ "@preact/signals-react": "*"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@types/react": "*",
32
- "react": "*"
33
+ "react": "*",
34
+ "@preact/signals-react": "*",
35
+ "@types/use-sync-external-store": "*"
33
36
  },
34
37
  "engines": {
35
38
  "npm": ">=9.0.0",