@hyper-fetch/react 3.1.0 → 3.2.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.
Files changed (61) hide show
  1. package/.eslintrc.json +1 -2
  2. package/README.md +15 -15
  3. package/dist/index.cjs.js +1 -1
  4. package/dist/index.cjs.js.map +3 -3
  5. package/dist/index.d.ts +674 -11
  6. package/dist/index.esm.js +1 -1
  7. package/dist/index.esm.js.map +3 -3
  8. package/package.json +2 -2
  9. package/src/hooks/use-event-messages/use-event-messages.hooks.ts +2 -2
  10. package/src/hooks/use-fetch/use-fetch.hooks.ts +5 -5
  11. package/src/index.ts +1 -0
  12. package/dist/config-provider/config-provider.d.ts +0 -13
  13. package/dist/config-provider/config-provider.types.d.ts +0 -23
  14. package/dist/config-provider/index.d.ts +0 -2
  15. package/dist/helpers/index.d.ts +0 -3
  16. package/dist/helpers/use-request-events/index.d.ts +0 -2
  17. package/dist/helpers/use-request-events/use-request-events.hooks.d.ts +0 -8
  18. package/dist/helpers/use-request-events/use-request-events.types.d.ts +0 -80
  19. package/dist/helpers/use-socket-state/index.d.ts +0 -3
  20. package/dist/helpers/use-socket-state/use-socket-state.constants.d.ts +0 -2
  21. package/dist/helpers/use-socket-state/use-socket-state.hooks.d.ts +0 -16
  22. package/dist/helpers/use-socket-state/use-socket-state.types.d.ts +0 -9
  23. package/dist/helpers/use-tracked-state/index.d.ts +0 -4
  24. package/dist/helpers/use-tracked-state/use-tracked-state.constants.d.ts +0 -2
  25. package/dist/helpers/use-tracked-state/use-tracked-state.hooks.d.ts +0 -10
  26. package/dist/helpers/use-tracked-state/use-tracked-state.types.d.ts +0 -72
  27. package/dist/helpers/use-tracked-state/use-tracked-state.utils.d.ts +0 -7
  28. package/dist/hooks/use-app-manager/index.d.ts +0 -2
  29. package/dist/hooks/use-app-manager/use-app-manager.hooks.d.ts +0 -2
  30. package/dist/hooks/use-app-manager/use-app-manager.types.d.ts +0 -18
  31. package/dist/hooks/use-cache/index.d.ts +0 -3
  32. package/dist/hooks/use-cache/use-cache.constants.d.ts +0 -5
  33. package/dist/hooks/use-cache/use-cache.hooks.d.ts +0 -2
  34. package/dist/hooks/use-cache/use-cache.types.d.ts +0 -35
  35. package/dist/hooks/use-emitter/index.d.ts +0 -2
  36. package/dist/hooks/use-emitter/use-emitter.hooks.d.ts +0 -19
  37. package/dist/hooks/use-emitter/use-emitter.types.d.ts +0 -3
  38. package/dist/hooks/use-event-messages/index.d.ts +0 -2
  39. package/dist/hooks/use-event-messages/use-event-messages.hooks.d.ts +0 -24
  40. package/dist/hooks/use-event-messages/use-event-messages.types.d.ts +0 -4
  41. package/dist/hooks/use-fetch/index.d.ts +0 -4
  42. package/dist/hooks/use-fetch/use-fetch.constants.d.ts +0 -7
  43. package/dist/hooks/use-fetch/use-fetch.hooks.d.ts +0 -8
  44. package/dist/hooks/use-fetch/use-fetch.types.d.ts +0 -89
  45. package/dist/hooks/use-fetch/use-fetch.utils.d.ts +0 -1
  46. package/dist/hooks/use-listener/index.d.ts +0 -2
  47. package/dist/hooks/use-listener/use-listener.hooks.d.ts +0 -20
  48. package/dist/hooks/use-listener/use-listener.types.d.ts +0 -3
  49. package/dist/hooks/use-queue/index.d.ts +0 -3
  50. package/dist/hooks/use-queue/use-queue.constants.d.ts +0 -3
  51. package/dist/hooks/use-queue/use-queue.hooks.d.ts +0 -8
  52. package/dist/hooks/use-queue/use-queue.types.d.ts +0 -48
  53. package/dist/hooks/use-submit/index.d.ts +0 -3
  54. package/dist/hooks/use-submit/use-submit.constants.d.ts +0 -7
  55. package/dist/hooks/use-submit/use-submit.hooks.d.ts +0 -8
  56. package/dist/hooks/use-submit/use-submit.types.d.ts +0 -105
  57. package/dist/types/index.d.ts +0 -1
  58. package/dist/types/invalidation.types.d.ts +0 -2
  59. package/dist/utils/bounce.utils.d.ts +0 -7
  60. package/dist/utils/deep-equal.utils.d.ts +0 -13
  61. package/dist/utils/index.d.ts +0 -2
@@ -1,3 +0,0 @@
1
- export type UseListenerOptionsType = {
2
- dependencyTracking?: boolean;
3
- };
@@ -1,3 +0,0 @@
1
- export * from "./use-queue.hooks";
2
- export * from "./use-queue.types";
3
- export * from "./use-queue.constants";
@@ -1,3 +0,0 @@
1
- import { RequiredKeys } from "@hyper-fetch/core";
2
- import { UseQueueOptionsType } from "hooks/use-queue";
3
- export declare const useQueueDefaultOptions: RequiredKeys<UseQueueOptionsType>;
@@ -1,8 +0,0 @@
1
- import { UseQueueOptionsType, UseQueueReturnType } from "hooks/use-queue";
2
- /**
3
- * This hook allows to control dispatchers request queues
4
- * @param request
5
- * @param options
6
- * @returns
7
- */
8
- export declare const useQueue: <Request_1 extends Request<any, any, any, any, any, any, any, any, any, any, any>>(request: Request_1, options?: UseQueueOptionsType) => UseQueueReturnType<Request_1>;
@@ -1,48 +0,0 @@
1
- import { ProgressType, RequestInstance, DispatcherStorageValueType } from "@hyper-fetch/core";
2
- export type UseQueueOptionsType = {
3
- queueType?: "auto" | "fetch" | "submit";
4
- };
5
- export type QueueRequest<Request extends RequestInstance> = DispatcherStorageValueType<Request> & {
6
- /**
7
- * Uploading progress for given request
8
- */
9
- uploading?: ProgressType;
10
- /**
11
- * Downloading progress for given request
12
- */
13
- downloading?: ProgressType;
14
- /**
15
- * Callback which allow to start previously stopped request.
16
- */
17
- startRequest: () => void;
18
- /**
19
- * Callback which allow to stop request and cancel it if it's ongoing.
20
- */
21
- stopRequest: () => void;
22
- /**
23
- * Removes request from the queue
24
- */
25
- deleteRequest: () => void;
26
- };
27
- export type UseQueueReturnType<T extends RequestInstance> = {
28
- /**
29
- * Queue status for provided request
30
- */
31
- stopped: boolean;
32
- /**
33
- * List of requests for provided request
34
- */
35
- requests: QueueRequest<T>[];
36
- /**
37
- * Callback which allow to stop queue, it will cancel ongoing requests.
38
- */
39
- stop: () => void;
40
- /**
41
- * Callback which allow to pause queue. It will allow ongoing requests to be finished, but will stop next from being send.
42
- */
43
- pause: () => void;
44
- /**
45
- * Callback which allow to start queue.
46
- */
47
- start: () => void;
48
- };
@@ -1,3 +0,0 @@
1
- export * from "./use-submit.hooks";
2
- export * from "./use-submit.types";
3
- export * from "./use-submit.constants";
@@ -1,7 +0,0 @@
1
- import { RequestInstance, RequiredKeys } from "@hyper-fetch/core";
2
- import { UseSubmitOptionsType } from "./use-submit.types";
3
- type DefaultOptionsType = RequiredKeys<Omit<UseSubmitOptionsType<RequestInstance>, "initialData">> & {
4
- initialData: null;
5
- };
6
- export declare const useSubmitDefaultOptions: DefaultOptionsType;
7
- export {};
@@ -1,8 +0,0 @@
1
- import { UseSubmitOptionsType, UseSubmitReturnType } from "hooks/use-submit";
2
- /**
3
- * This hooks aims to mutate data on the server.
4
- * @param request
5
- * @param options
6
- * @returns
7
- */
8
- export declare const useSubmit: <RequestType extends Request<any, any, any, any, any, any, any, any, any, any, any>>(request: RequestType, options?: UseSubmitOptionsType<RequestType>) => UseSubmitReturnType<RequestType>;
@@ -1,105 +0,0 @@
1
- import { CacheValueType, ExtractErrorType, ExtractResponseType, RequestInstance, RequestSendType } from "@hyper-fetch/core";
2
- import { isEqual } from "utils";
3
- import { OnErrorCallbackType, OnFinishedCallbackType, OnProgressCallbackType, OnStartCallbackType, OnSuccessCallbackType, UseTrackedStateType, UseTrackedStateActions } from "helpers";
4
- import { InvalidationKeyType } from "types";
5
- export type UseSubmitOptionsType<T extends RequestInstance> = {
6
- /**
7
- * Disable fetching
8
- */
9
- disabled?: boolean;
10
- /**
11
- * If cache is empty we can use placeholder data.
12
- */
13
- initialData?: CacheValueType<ExtractResponseType<T>, ExtractErrorType<T>>["data"] | null;
14
- /**
15
- * Enable/disable debouncing for often changing keys or refreshing, to limit requests to server.
16
- */
17
- bounce?: boolean;
18
- /**
19
- * Possibility to choose between debounce and throttle approaches
20
- */
21
- bounceType?: "debounce" | "throttle";
22
- /**
23
- * How long it should bounce requests.
24
- */
25
- bounceTime?: number;
26
- /**
27
- * ONLY in throttle mode - options for handling last bounce event
28
- */
29
- bounceTimeout?: number;
30
- /**
31
- * If `true` it will rerender only when values used by our component gets changed. Otherwise it will rerender on any change.
32
- */
33
- dependencyTracking?: boolean;
34
- /**
35
- * Deep comparison function for hook to check for equality in incoming data, to limit rerenders.
36
- */
37
- deepCompare?: boolean | typeof isEqual;
38
- };
39
- export type UseSubmitReturnType<RequestType extends RequestInstance> = Omit<UseTrackedStateType<RequestType>, "loading"> & UseTrackedStateActions<RequestType> & {
40
- /**
41
- * Callback which allows to cancel ongoing requests from given queueKey.
42
- */
43
- abort: () => void;
44
- /**
45
- * Helper hook listening on success response.
46
- */
47
- onSubmitSuccess: (callback: OnSuccessCallbackType<RequestType>) => void;
48
- /**
49
- * Helper hook listening on error response.
50
- */
51
- onSubmitError: (callback: OnErrorCallbackType<RequestType>) => void;
52
- /**
53
- * Helper hook listening on any response.
54
- */
55
- onSubmitFinished: (callback: OnFinishedCallbackType<RequestType>) => void;
56
- /**
57
- * Helper hook listening on request start.
58
- */
59
- onSubmitRequestStart: (callback: OnStartCallbackType<RequestType>) => void;
60
- /**
61
- * Helper hook listening on response start(before we receive all data from server).
62
- */
63
- onSubmitResponseStart: (callback: OnStartCallbackType<RequestType>) => void;
64
- /**
65
- * Helper hook listening on download progress ETA. We can later match given requests by their id's or request instance which holds all data which is being transferred.
66
- */
67
- onSubmitDownloadProgress: (callback: OnProgressCallbackType) => void;
68
- /**
69
- * Helper hook listening on upload progress ETA. We can later match given requests by their id's or request instance which holds all data which is being transferred.
70
- */
71
- onSubmitUploadProgress: (callback: OnProgressCallbackType) => void;
72
- /**
73
- * Helper hook listening on aborting of requests. Abort events are not triggering onError callbacks.
74
- */
75
- onSubmitAbort: (callback: OnErrorCallbackType<RequestType>) => void;
76
- /**
77
- * Helper hook listening on request going into offline awaiting for network connection to be restored. It will not trigger onError when 'offline' mode is set on request.
78
- */
79
- onSubmitOfflineError: (callback: OnErrorCallbackType<RequestType>) => void;
80
- /**
81
- * Method responsible for triggering requests. It return Promise which will be resolved with the request.
82
- */
83
- submit: RequestSendType<RequestType>;
84
- /**
85
- * Request loading state
86
- */
87
- submitting: boolean;
88
- /**
89
- * Data related to current state of the bounce usage
90
- */
91
- bounce: {
92
- /**
93
- * Active state of the bounce method
94
- */
95
- active: boolean;
96
- /**
97
- * Method to stop the active bounce method execution
98
- */
99
- reset: () => void;
100
- };
101
- /**
102
- * Revalidate current request resource or pass custom key to trigger it by invalidationKey(Regex / cacheKey).
103
- */
104
- revalidate: (invalidateKey: InvalidationKeyType | InvalidationKeyType[]) => void;
105
- };
@@ -1 +0,0 @@
1
- export * from "./invalidation.types";
@@ -1,2 +0,0 @@
1
- import { RequestInstance } from "@hyper-fetch/core";
2
- export type InvalidationKeyType = string | RequestInstance | RegExp;
@@ -1,7 +0,0 @@
1
- export declare const getBounceData: (bounceData: {
2
- reset: () => void;
3
- active: boolean;
4
- }) => {
5
- reset: () => void;
6
- active: boolean;
7
- };
@@ -1,13 +0,0 @@
1
- /**
2
- * Check if value is empty
3
- * @param value any object or primitive
4
- * @returns true when value is empty
5
- */
6
- export declare const isEmpty: (value: unknown) => boolean;
7
- /**
8
- * Allow to deep compare any passed values
9
- * @param firstValue unknown
10
- * @param secondValue unknown
11
- * @returns true when elements are equal
12
- */
13
- export declare const isEqual: (firstValue: unknown, secondValue: unknown) => boolean;
@@ -1,2 +0,0 @@
1
- export * from "./deep-equal.utils";
2
- export * from "./bounce.utils";