@hyper-fetch/core 9.3.0 → 9.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.
- package/__tests__/features/adapter/adapter.request-options.spec.ts +116 -0
- package/__tests__/features/client/client.base.spec.ts +14 -0
- package/__tests__/features/managers/app/app.manager.base.spec.ts +173 -1
- package/dist/adapter/adapter.d.ts +17 -12
- package/dist/adapter/adapter.d.ts.map +1 -1
- package/dist/adapter/adapter.types.d.ts +5 -3
- package/dist/adapter/adapter.types.d.ts.map +1 -1
- package/dist/client/client.d.ts +2 -2
- package/dist/client/client.d.ts.map +1 -1
- package/dist/http-adapter/http-adapter.fetch.d.ts +1 -1
- package/dist/http-adapter/http-adapter.fetch.d.ts.map +1 -1
- package/dist/index.mjs +69 -15
- package/dist/index.mjs.map +1 -1
- package/dist/managers/app/app.manager.constants.d.ts.map +1 -1
- package/dist/managers/app/app.manager.d.ts +9 -0
- package/dist/managers/app/app.manager.d.ts.map +1 -1
- package/dist/managers/app/app.manager.types.d.ts +8 -2
- package/dist/managers/app/app.manager.types.d.ts.map +1 -1
- package/dist/managers/app/app.manager.utils.d.ts +5 -0
- package/dist/managers/app/app.manager.utils.d.ts.map +1 -1
- package/dist/types/adapter.types.d.ts +13 -11
- package/dist/types/adapter.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/adapter/adapter.ts +33 -13
- package/src/adapter/adapter.types.ts +7 -3
- package/src/client/client.ts +3 -1
- package/src/managers/app/app.manager.constants.ts +18 -7
- package/src/managers/app/app.manager.ts +44 -10
- package/src/managers/app/app.manager.types.ts +8 -2
- package/src/managers/app/app.manager.utils.ts +13 -0
- package/src/types/adapter.types.ts +18 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.manager.constants.d.ts","sourceRoot":"","sources":["../../../src/managers/app/app.manager.constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI1C,oBAAY,SAAS;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,eAAO,MAAM,wBAAwB,EAAE,YAAY,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"app.manager.constants.d.ts","sourceRoot":"","sources":["../../../src/managers/app/app.manager.constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI1C,oBAAY,SAAS;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,eAAO,MAAM,wBAAwB,EAAE,YAAY,CAAC,qBAAqB,CAuBxE,CAAC"}
|
|
@@ -25,8 +25,17 @@ export declare class AppManager {
|
|
|
25
25
|
isBrowser: boolean;
|
|
26
26
|
isOnline: boolean;
|
|
27
27
|
isFocused: boolean;
|
|
28
|
+
private unmountCallbacks;
|
|
28
29
|
constructor(options?: AppManagerOptionsType | undefined);
|
|
30
|
+
/**
|
|
31
|
+
* Subscribes to the environment focus and network changes. Calling it again replaces the previous subscriptions,
|
|
32
|
+
* so the listeners are never registered twice.
|
|
33
|
+
*/
|
|
29
34
|
initialize: () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Removes the environment listeners registered by `initialize()`. Listeners added with `events` are kept.
|
|
37
|
+
*/
|
|
38
|
+
unmount: () => void;
|
|
30
39
|
private setInitialFocus;
|
|
31
40
|
private setInitialOnline;
|
|
32
41
|
setFocused: (isFocused: boolean) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.manager.d.ts","sourceRoot":"","sources":["../../../src/managers/app/app.manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC;;;;;;;;GAQG;AACH,qBAAa,UAAU;
|
|
1
|
+
{"version":3,"file":"app.manager.d.ts","sourceRoot":"","sources":["../../../src/managers/app/app.manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC;;;;;;;;GAQG;AACH,qBAAa,UAAU;IAUF,OAAO,CAAC,EAAE,qBAAqB;IATlD,OAAO,eAAsB;IAC7B,MAAM;;;;;;;;;MAAqC;IAE3C,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IAEnB,OAAO,CAAC,gBAAgB,CAAsB;gBAE3B,OAAO,CAAC,EAAE,qBAAqB,YAAA;IAalD;;;OAGG;IACH,UAAU,aAWR;IAEF;;OAEG;IACH,OAAO,aAIL;IAEF,OAAO,CAAC,eAAe,CAcrB;IAEF,OAAO,CAAC,gBAAgB,CActB;IAEF,UAAU,GAAI,WAAW,OAAO,UAQ9B;IAEF,SAAS,GAAI,UAAU,OAAO,UAQ5B;CACH"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
export type AppManagerOptionsType = {
|
|
2
2
|
initiallyFocused?: boolean | (() => boolean | Promise<boolean>);
|
|
3
3
|
initiallyOnline?: boolean | (() => boolean | Promise<boolean>);
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Subscribes to the environment focus changes. Return a cleanup function to let `unmount()` remove the listeners.
|
|
6
|
+
*/
|
|
7
|
+
focusEvent?: (setFocused: (isFocused: boolean) => void) => void | VoidFunction;
|
|
8
|
+
/**
|
|
9
|
+
* Subscribes to the environment network changes. Return a cleanup function to let `unmount()` remove the listeners.
|
|
10
|
+
*/
|
|
11
|
+
onlineEvent?: (setOnline: (isOnline: boolean) => void) => void | VoidFunction;
|
|
6
12
|
};
|
|
7
13
|
//# sourceMappingURL=app.manager.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.manager.types.d.ts","sourceRoot":"","sources":["../../../src/managers/app/app.manager.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,gBAAgB,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAChE,eAAe,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"app.manager.types.d.ts","sourceRoot":"","sources":["../../../src/managers/app/app.manager.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,gBAAgB,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAChE,eAAe,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,GAAG,YAAY,CAAC;IAC/E;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,GAAG,YAAY,CAAC;CAC/E,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export declare const hasWindow: () => boolean;
|
|
2
2
|
export declare const hasDocument: () => boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Reads the current network state from the browser. Falls back to `true` when it is unknown - e.g. in Node.js or
|
|
5
|
+
* React Native, where `navigator.onLine` is not available.
|
|
6
|
+
*/
|
|
7
|
+
export declare const isNavigatorOnline: () => boolean;
|
|
3
8
|
export declare const onWindowEvent: <K extends keyof WindowEventMap>(key: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined) => VoidFunction;
|
|
4
9
|
export declare const onDocumentEvent: <K extends keyof DocumentEventMap>(key: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined) => VoidFunction;
|
|
5
10
|
//# sourceMappingURL=app.manager.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.manager.utils.d.ts","sourceRoot":"","sources":["../../../src/managers/app/app.manager.utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,eAOrB,CAAC;AAEF,eAAO,MAAM,WAAW,eAOvB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,cAAc,EAC1D,KAAK,CAAC,EACN,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,GAAG,EACtD,UAAU,OAAO,GAAG,uBAAuB,GAAG,SAAS,KACtD,YAQF,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,gBAAgB,EAC9D,KAAK,CAAC,EACN,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,GAAG,EAC1D,UAAU,OAAO,GAAG,uBAAuB,GAAG,SAAS,KACtD,YAQF,CAAC"}
|
|
1
|
+
{"version":3,"file":"app.manager.utils.d.ts","sourceRoot":"","sources":["../../../src/managers/app/app.manager.utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,eAOrB,CAAC;AAEF,eAAO,MAAM,WAAW,eAOvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,eAO7B,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,cAAc,EAC1D,KAAK,CAAC,EACN,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,GAAG,EACtD,UAAU,OAAO,GAAG,uBAAuB,GAAG,SAAS,KACtD,YAQF,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,gBAAgB,EAC9D,KAAK,CAAC,EACN,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,GAAG,EAC1D,UAAU,OAAO,GAAG,uBAAuB,GAAG,SAAS,KACtD,YAQF,CAAC"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Adapter, AdapterInstance } from '../adapter';
|
|
2
|
-
export type ExtractAdapterOptionsType<T> = T extends Adapter<infer O, any, any, any, any, any, any, any, any, any, any> ? O : never;
|
|
3
|
-
export type ExtractAdapterMethodType<T> = T extends Adapter<any, infer M, any, any, any, any, any, any, any, any, any> ? M : never;
|
|
4
|
-
export type ExtractAdapterStatusType<T> = T extends Adapter<any, any, infer S, any, any, any, any, any, any, any, any> ? S : never;
|
|
5
|
-
export type ExtractAdapterExtraType<T> = T extends Adapter<any, any, any, infer A, any, any, any, any, any, any, any> ? A : never;
|
|
6
|
-
export type ExtractAdapterQueryParamsType<T> = T extends Adapter<any, any, any, any, infer Q, any, any, any, any, any, any> ? Q : never;
|
|
7
|
-
export type ExtractAdapterDefaultQueryParamsType<T> = T extends Adapter<any, any, any, any, any, infer Q, any, any, any, any, any> ? Q : never;
|
|
8
|
-
export type ExtractAdapterEndpointType<T> = T extends Adapter<any, any, any, any, any, any, infer E, any, any, any, any> ? E : never;
|
|
9
|
-
export type ExtractAdapterEndpointMapperType<T> = T extends Adapter<any, any, any, any, any, any, any, infer EM, any, any, any> ? EM : never;
|
|
10
|
-
export type ExtractAdapterQueryParamsMapperType<T> = T extends Adapter<any, any, any, any, any, any, any, any, infer QPM, any, any> ? QPM : never;
|
|
11
|
-
export type ExtractAdapterHeaderMapperType<T> = T extends Adapter<any, any, any, any, any, any, any, any, any, infer HM, any> ? HM : never;
|
|
12
|
-
export type ExtractAdapterPayloadMapperType<T> = T extends Adapter<any, any, any, any, any, any, any, any, any, any, infer PM> ? PM : never;
|
|
2
|
+
export type ExtractAdapterOptionsType<T> = T extends Adapter<infer O, any, any, any, any, any, any, any, any, any, any, any> ? O : never;
|
|
3
|
+
export type ExtractAdapterMethodType<T> = T extends Adapter<any, infer M, any, any, any, any, any, any, any, any, any, any> ? M : never;
|
|
4
|
+
export type ExtractAdapterStatusType<T> = T extends Adapter<any, any, infer S, any, any, any, any, any, any, any, any, any> ? S : never;
|
|
5
|
+
export type ExtractAdapterExtraType<T> = T extends Adapter<any, any, any, infer A, any, any, any, any, any, any, any, any> ? A : never;
|
|
6
|
+
export type ExtractAdapterQueryParamsType<T> = T extends Adapter<any, any, any, any, infer Q, any, any, any, any, any, any, any> ? Q : never;
|
|
7
|
+
export type ExtractAdapterDefaultQueryParamsType<T> = T extends Adapter<any, any, any, any, any, infer Q, any, any, any, any, any, any> ? Q : never;
|
|
8
|
+
export type ExtractAdapterEndpointType<T> = T extends Adapter<any, any, any, any, any, any, infer E, any, any, any, any, any> ? E : never;
|
|
9
|
+
export type ExtractAdapterEndpointMapperType<T> = T extends Adapter<any, any, any, any, any, any, any, infer EM, any, any, any, any> ? EM : never;
|
|
10
|
+
export type ExtractAdapterQueryParamsMapperType<T> = T extends Adapter<any, any, any, any, any, any, any, any, infer QPM, any, any, any> ? QPM : never;
|
|
11
|
+
export type ExtractAdapterHeaderMapperType<T> = T extends Adapter<any, any, any, any, any, any, any, any, any, infer HM, any, any> ? HM : never;
|
|
12
|
+
export type ExtractAdapterPayloadMapperType<T> = T extends Adapter<any, any, any, any, any, any, any, any, any, any, infer PM, any> ? PM : never;
|
|
13
|
+
/** `any` (e.g. `AdapterInstance`) resolves to `{}`, otherwise it would erase the type of the whole `createRequest` params */
|
|
14
|
+
export type ExtractAdapterRequestOptionsType<T> = T extends Adapter<any, any, any, any, any, any, any, any, any, any, any, infer RO> ? 0 extends 1 & RO ? {} : RO : never;
|
|
13
15
|
export type ExtractUnionAdapter<AdapterType extends AdapterInstance, Values extends {
|
|
14
16
|
method?: any;
|
|
15
17
|
options?: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.types.d.ts","sourceRoot":"","sources":["../../src/types/adapter.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,MAAM,yBAAyB,CAAC,CAAC,IACrC,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.types.d.ts","sourceRoot":"","sources":["../../src/types/adapter.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,MAAM,yBAAyB,CAAC,CAAC,IACrC,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChG,MAAM,MAAM,wBAAwB,CAAC,CAAC,IACpC,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EA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
|
|
4
4
|
"description": "Cache, Queue and Persist your requests no matter if you are online or offline!",
|
|
5
5
|
"author": "Maciej Pyrc <maciekpyrc@gmail.com>, Kacper Skawina <kacper.skawina@gmail.com>",
|
|
6
6
|
"homepage": "https://hyperfetch.bettertyped.com/",
|
package/src/adapter/adapter.ts
CHANGED
|
@@ -39,6 +39,7 @@ export class Adapter<
|
|
|
39
39
|
QueryParamsMapperType extends QueryParamsMapper<QueryParams> | DefaultMapperType = DefaultMapperType,
|
|
40
40
|
HeaderMapperType extends HeaderMappingType | DefaultMapperType = DefaultMapperType,
|
|
41
41
|
PayloadMapperType extends AdapterPayloadMappingType | DefaultMapperType = DefaultMapperType,
|
|
42
|
+
RequestOptions extends Record<string, any> = {},
|
|
42
43
|
> {
|
|
43
44
|
/** Fetching function */
|
|
44
45
|
public unstable_fetcher: AdapterFetcherType<
|
|
@@ -53,7 +54,8 @@ export class Adapter<
|
|
|
53
54
|
EndpointMapperType,
|
|
54
55
|
QueryParamsMapperType,
|
|
55
56
|
HeaderMapperType,
|
|
56
|
-
PayloadMapperType
|
|
57
|
+
PayloadMapperType,
|
|
58
|
+
RequestOptions
|
|
57
59
|
>
|
|
58
60
|
>;
|
|
59
61
|
|
|
@@ -80,6 +82,12 @@ export class Adapter<
|
|
|
80
82
|
public unstable_payloadMapperConfig: Parameters<PayloadMapperType>[1];
|
|
81
83
|
public unstable_endpointMapperConfig: Parameters<EndpointMapperType>[1];
|
|
82
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Type-only carrier of the additional `createRequest` fields declared by this adapter.
|
|
87
|
+
* It has no runtime value - adapters read those fields from `request.requestOptions`.
|
|
88
|
+
*/
|
|
89
|
+
public unstable_requestOptionsType?: RequestOptions = undefined;
|
|
90
|
+
|
|
83
91
|
constructor(
|
|
84
92
|
public options: {
|
|
85
93
|
name: string;
|
|
@@ -147,7 +155,8 @@ export class Adapter<
|
|
|
147
155
|
EndpointMapperType,
|
|
148
156
|
QueryParamsMapperType,
|
|
149
157
|
HeaderMapperType,
|
|
150
|
-
PayloadMapperType
|
|
158
|
+
PayloadMapperType,
|
|
159
|
+
RequestOptions
|
|
151
160
|
>
|
|
152
161
|
>;
|
|
153
162
|
}
|
|
@@ -161,7 +170,9 @@ export class Adapter<
|
|
|
161
170
|
* Get formatted endpoint name of the request.
|
|
162
171
|
* Helpful in displaying long endpoints like in case of graphql schemas etc.
|
|
163
172
|
*/
|
|
164
|
-
public unstable_devtoolsEndpointGetter: (endpoint: string) => string = (
|
|
173
|
+
public unstable_devtoolsEndpointGetter: (endpoint: string, requestOptions?: Record<string, any>) => string = (
|
|
174
|
+
endpoint,
|
|
175
|
+
) => endpoint;
|
|
165
176
|
|
|
166
177
|
/**
|
|
167
178
|
* ********************
|
|
@@ -182,7 +193,7 @@ export class Adapter<
|
|
|
182
193
|
};
|
|
183
194
|
|
|
184
195
|
/** Set a function that formats the endpoint string for display in devtools. */
|
|
185
|
-
setDevtoolsEndpointGetter = (callback: (endpoint: string) => string) => {
|
|
196
|
+
setDevtoolsEndpointGetter = (callback: (endpoint: string, requestOptions?: Record<string, any>) => string) => {
|
|
186
197
|
this.unstable_devtoolsEndpointGetter = callback;
|
|
187
198
|
return this;
|
|
188
199
|
};
|
|
@@ -217,7 +228,8 @@ export class Adapter<
|
|
|
217
228
|
EndpointMapperType,
|
|
218
229
|
QueryParamsMapperType,
|
|
219
230
|
HeaderMapperType,
|
|
220
|
-
PayloadMapperType
|
|
231
|
+
PayloadMapperType,
|
|
232
|
+
RequestOptions
|
|
221
233
|
>
|
|
222
234
|
>;
|
|
223
235
|
}
|
|
@@ -251,7 +263,8 @@ export class Adapter<
|
|
|
251
263
|
EndpointMapperType,
|
|
252
264
|
QueryParamsMapperType,
|
|
253
265
|
NewMapper,
|
|
254
|
-
PayloadMapperType
|
|
266
|
+
PayloadMapperType,
|
|
267
|
+
RequestOptions
|
|
255
268
|
>;
|
|
256
269
|
};
|
|
257
270
|
|
|
@@ -275,7 +288,8 @@ export class Adapter<
|
|
|
275
288
|
EndpointMapperType,
|
|
276
289
|
QueryParamsMapperType,
|
|
277
290
|
HeaderMapperType,
|
|
278
|
-
NewMapper
|
|
291
|
+
NewMapper,
|
|
292
|
+
RequestOptions
|
|
279
293
|
>;
|
|
280
294
|
};
|
|
281
295
|
|
|
@@ -299,7 +313,8 @@ export class Adapter<
|
|
|
299
313
|
NewEndpointMapper,
|
|
300
314
|
QueryParamsMapperType,
|
|
301
315
|
HeaderMapperType,
|
|
302
|
-
PayloadMapperType
|
|
316
|
+
PayloadMapperType,
|
|
317
|
+
RequestOptions
|
|
303
318
|
>;
|
|
304
319
|
};
|
|
305
320
|
|
|
@@ -325,7 +340,8 @@ export class Adapter<
|
|
|
325
340
|
EndpointMapperType,
|
|
326
341
|
NewQueryParamsMapper,
|
|
327
342
|
HeaderMapperType,
|
|
328
|
-
PayloadMapperType
|
|
343
|
+
PayloadMapperType,
|
|
344
|
+
RequestOptions
|
|
329
345
|
>;
|
|
330
346
|
};
|
|
331
347
|
|
|
@@ -381,7 +397,8 @@ export class Adapter<
|
|
|
381
397
|
EndpointMapperType,
|
|
382
398
|
QueryParamsMapperType,
|
|
383
399
|
HeaderMapperType,
|
|
384
|
-
PayloadMapperType
|
|
400
|
+
PayloadMapperType,
|
|
401
|
+
RequestOptions
|
|
385
402
|
>
|
|
386
403
|
>,
|
|
387
404
|
) {
|
|
@@ -408,7 +425,8 @@ export class Adapter<
|
|
|
408
425
|
EndpointMapperType,
|
|
409
426
|
QueryParamsMapperType,
|
|
410
427
|
HeaderMapperType,
|
|
411
|
-
PayloadMapperType
|
|
428
|
+
PayloadMapperType,
|
|
429
|
+
RequestOptions
|
|
412
430
|
>
|
|
413
431
|
>;
|
|
414
432
|
}
|
|
@@ -445,7 +463,8 @@ export class Adapter<
|
|
|
445
463
|
EndpointMapperType,
|
|
446
464
|
QueryParamsMapperType,
|
|
447
465
|
HeaderMapperType,
|
|
448
|
-
PayloadMapperType
|
|
466
|
+
PayloadMapperType,
|
|
467
|
+
RequestOptions
|
|
449
468
|
>
|
|
450
469
|
>({
|
|
451
470
|
request,
|
|
@@ -470,7 +489,8 @@ export class Adapter<
|
|
|
470
489
|
EndpointMapperType,
|
|
471
490
|
QueryParamsMapperType,
|
|
472
491
|
HeaderMapperType,
|
|
473
|
-
PayloadMapperType
|
|
492
|
+
PayloadMapperType,
|
|
493
|
+
RequestOptions
|
|
474
494
|
>
|
|
475
495
|
>(bindings);
|
|
476
496
|
}
|
|
@@ -21,7 +21,7 @@ import type { getAdapterBindings } from "./adapter.bindings";
|
|
|
21
21
|
* Base Adapter
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
export type AdapterInstance = Adapter<any, any, any, any, any, any, any, any, any, any, any>;
|
|
24
|
+
export type AdapterInstance = Adapter<any, any, any, any, any, any, any, any, any, any, any, any>;
|
|
25
25
|
|
|
26
26
|
export type AdapterGenericType<
|
|
27
27
|
AdapterOptions,
|
|
@@ -35,6 +35,7 @@ export type AdapterGenericType<
|
|
|
35
35
|
QueryParamsMapperType extends QueryParamsMapper<QueryParams> | DefaultMapperType = DefaultMapperType,
|
|
36
36
|
HeaderMapperType extends HeaderMappingType | DefaultMapperType = DefaultMapperType,
|
|
37
37
|
PayloadMapperType extends AdapterPayloadMappingType | DefaultMapperType = DefaultMapperType,
|
|
38
|
+
RequestOptions extends Record<string, any> = {},
|
|
38
39
|
> = {
|
|
39
40
|
adapterOptions: AdapterOptions;
|
|
40
41
|
methodType: MethodType;
|
|
@@ -47,10 +48,12 @@ export type AdapterGenericType<
|
|
|
47
48
|
queryParamsMapperType?: QueryParamsMapperType;
|
|
48
49
|
headerMapperType?: HeaderMapperType;
|
|
49
50
|
payloadMapperType?: PayloadMapperType;
|
|
51
|
+
/** Additional fields accepted by `createRequest` on clients using this adapter */
|
|
52
|
+
requestOptions?: RequestOptions;
|
|
50
53
|
};
|
|
51
54
|
|
|
52
55
|
export type DeclareAdapterType<
|
|
53
|
-
Properties extends AdapterGenericType<any, any, any, any, any, any, any, any, any, any>,
|
|
56
|
+
Properties extends AdapterGenericType<any, any, any, any, any, any, any, any, any, any, any, any>,
|
|
54
57
|
> = Adapter<
|
|
55
58
|
TypeWithDefaults<Properties, "adapterOptions", any>,
|
|
56
59
|
TypeWithDefaults<Properties, "methodType", any>,
|
|
@@ -62,7 +65,8 @@ export type DeclareAdapterType<
|
|
|
62
65
|
TypeWithDefaults<Properties, "endpointMapperType", DefaultMapperType>,
|
|
63
66
|
TypeWithDefaults<Properties, "queryParamsMapperType", DefaultMapperType>,
|
|
64
67
|
TypeWithDefaults<Properties, "headerMapperType", DefaultMapperType>,
|
|
65
|
-
NonNullable<TypeWithDefaults<Properties, "payloadMapperType", DefaultMapperType
|
|
68
|
+
NonNullable<TypeWithDefaults<Properties, "payloadMapperType", DefaultMapperType>>,
|
|
69
|
+
TypeWithDefaults<Properties, "requestOptions", {}>
|
|
66
70
|
>;
|
|
67
71
|
|
|
68
72
|
export type AdapterFetcherType<Adapter extends AdapterInstance> = (
|
package/src/client/client.ts
CHANGED
|
@@ -28,6 +28,7 @@ import type {
|
|
|
28
28
|
HydrateDataType,
|
|
29
29
|
HydrationOptions,
|
|
30
30
|
ExtractAdapterDefaultQueryParamsType,
|
|
31
|
+
ExtractAdapterRequestOptionsType,
|
|
31
32
|
} from "types";
|
|
32
33
|
import { getUniqueRequestId } from "utils";
|
|
33
34
|
|
|
@@ -418,6 +419,7 @@ export class Client<
|
|
|
418
419
|
this.fetchDispatcher.emitter.removeAllListeners();
|
|
419
420
|
this.submitDispatcher.emitter.removeAllListeners();
|
|
420
421
|
this.cache.emitter.removeAllListeners();
|
|
422
|
+
this.appManager.unmount();
|
|
421
423
|
|
|
422
424
|
this.cache = cache?.() || new Cache();
|
|
423
425
|
this.appManager = appManager?.() || new AppManager();
|
|
@@ -505,7 +507,7 @@ export class Client<
|
|
|
505
507
|
AdapterOptions extends ExtractAdapterOptionsType<Adapter>,
|
|
506
508
|
MethodType extends ExtractAdapterMethodType<Adapter>,
|
|
507
509
|
>(
|
|
508
|
-
params: RequestOptionsType<EndpointType, AdapterOptions, MethodType>,
|
|
510
|
+
params: RequestOptionsType<EndpointType, AdapterOptions, MethodType> & ExtractAdapterRequestOptionsType<Adapter>,
|
|
509
511
|
) => {
|
|
510
512
|
type Endpoint = TypeWithDefaults<RequestProperties, "endpoint", EndpointType>;
|
|
511
513
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AppManagerOptionsType } from "managers";
|
|
2
2
|
import type { RequiredKeys } from "types";
|
|
3
3
|
|
|
4
|
-
import { onWindowEvent, onDocumentEvent } from "./app.manager.utils";
|
|
4
|
+
import { onWindowEvent, onDocumentEvent, isNavigatorOnline } from "./app.manager.utils";
|
|
5
5
|
|
|
6
6
|
export enum AppEvents {
|
|
7
7
|
FOCUS = "focus",
|
|
@@ -12,14 +12,25 @@ export enum AppEvents {
|
|
|
12
12
|
|
|
13
13
|
export const appManagerInitialOptions: RequiredKeys<AppManagerOptionsType> = {
|
|
14
14
|
initiallyFocused: true,
|
|
15
|
-
initiallyOnline:
|
|
15
|
+
initiallyOnline: isNavigatorOnline,
|
|
16
16
|
focusEvent: (setFocused) => {
|
|
17
|
-
onDocumentEvent("visibilitychange", () => setFocused(true));
|
|
18
|
-
onWindowEvent("focus", () => setFocused(true));
|
|
19
|
-
onWindowEvent("blur", () => setFocused(false));
|
|
17
|
+
const unmountVisibility = onDocumentEvent("visibilitychange", () => setFocused(true));
|
|
18
|
+
const unmountFocus = onWindowEvent("focus", () => setFocused(true));
|
|
19
|
+
const unmountBlur = onWindowEvent("blur", () => setFocused(false));
|
|
20
|
+
|
|
21
|
+
return () => {
|
|
22
|
+
unmountVisibility();
|
|
23
|
+
unmountFocus();
|
|
24
|
+
unmountBlur();
|
|
25
|
+
};
|
|
20
26
|
},
|
|
21
27
|
onlineEvent: (setOnline) => {
|
|
22
|
-
onWindowEvent("online", () => setOnline(true));
|
|
23
|
-
onWindowEvent("offline", () => setOnline(false));
|
|
28
|
+
const unmountOnline = onWindowEvent("online", () => setOnline(true));
|
|
29
|
+
const unmountOffline = onWindowEvent("offline", () => setOnline(false));
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
unmountOnline();
|
|
33
|
+
unmountOffline();
|
|
34
|
+
};
|
|
24
35
|
},
|
|
25
36
|
};
|
|
@@ -19,6 +19,8 @@ export class AppManager {
|
|
|
19
19
|
isOnline: boolean;
|
|
20
20
|
isFocused: boolean;
|
|
21
21
|
|
|
22
|
+
private unmountCallbacks: VoidFunction[] = [];
|
|
23
|
+
|
|
22
24
|
constructor(public options?: AppManagerOptionsType) {
|
|
23
25
|
this.emitter?.setMaxListeners(1000);
|
|
24
26
|
const {
|
|
@@ -32,29 +34,61 @@ export class AppManager {
|
|
|
32
34
|
this.isBrowser = hasDocument();
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Subscribes to the environment focus and network changes. Calling it again replaces the previous subscriptions,
|
|
39
|
+
* so the listeners are never registered twice.
|
|
40
|
+
*/
|
|
35
41
|
initialize = () => {
|
|
36
42
|
const { focusEvent = appManagerInitialOptions.focusEvent, onlineEvent = appManagerInitialOptions.onlineEvent } =
|
|
37
43
|
this.options || appManagerInitialOptions;
|
|
38
44
|
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
this.unmount();
|
|
46
|
+
|
|
47
|
+
[focusEvent(this.setFocused), onlineEvent(this.setOnline)].forEach((unmount) => {
|
|
48
|
+
if (typeof unmount === "function") {
|
|
49
|
+
this.unmountCallbacks.push(unmount);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Removes the environment listeners registered by `initialize()`. Listeners added with `events` are kept.
|
|
56
|
+
*/
|
|
57
|
+
unmount = () => {
|
|
58
|
+
const callbacks = this.unmountCallbacks;
|
|
59
|
+
this.unmountCallbacks = [];
|
|
60
|
+
callbacks.forEach((unmount) => unmount());
|
|
41
61
|
};
|
|
42
62
|
|
|
43
63
|
private setInitialFocus = async (initValue: Exclude<AppManagerOptionsType["initiallyFocused"], undefined>) => {
|
|
44
|
-
if (typeof initValue
|
|
45
|
-
this.isFocused = false;
|
|
46
|
-
this.isFocused = await initValue();
|
|
47
|
-
} else {
|
|
64
|
+
if (typeof initValue !== "function") {
|
|
48
65
|
this.isFocused = initValue;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Synchronous getters apply right away, so there is no moment with a wrong value
|
|
70
|
+
const value = initValue();
|
|
71
|
+
if (typeof value === "boolean") {
|
|
72
|
+
this.isFocused = value;
|
|
73
|
+
} else {
|
|
74
|
+
this.isFocused = false;
|
|
75
|
+
this.isFocused = await value;
|
|
49
76
|
}
|
|
50
77
|
};
|
|
51
78
|
|
|
52
79
|
private setInitialOnline = async (initValue: Exclude<AppManagerOptionsType["initiallyOnline"], undefined>) => {
|
|
53
|
-
if (typeof initValue
|
|
54
|
-
this.isOnline = false;
|
|
55
|
-
this.isOnline = await initValue();
|
|
56
|
-
} else {
|
|
80
|
+
if (typeof initValue !== "function") {
|
|
57
81
|
this.isOnline = initValue;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Synchronous getters apply right away, so there is no moment with a wrong value
|
|
86
|
+
const value = initValue();
|
|
87
|
+
if (typeof value === "boolean") {
|
|
88
|
+
this.isOnline = value;
|
|
89
|
+
} else {
|
|
90
|
+
this.isOnline = false;
|
|
91
|
+
this.isOnline = await value;
|
|
58
92
|
}
|
|
59
93
|
};
|
|
60
94
|
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export type AppManagerOptionsType = {
|
|
2
2
|
initiallyFocused?: boolean | (() => boolean | Promise<boolean>);
|
|
3
3
|
initiallyOnline?: boolean | (() => boolean | Promise<boolean>);
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Subscribes to the environment focus changes. Return a cleanup function to let `unmount()` remove the listeners.
|
|
6
|
+
*/
|
|
7
|
+
focusEvent?: (setFocused: (isFocused: boolean) => void) => void | VoidFunction;
|
|
8
|
+
/**
|
|
9
|
+
* Subscribes to the environment network changes. Return a cleanup function to let `unmount()` remove the listeners.
|
|
10
|
+
*/
|
|
11
|
+
onlineEvent?: (setOnline: (isOnline: boolean) => void) => void | VoidFunction;
|
|
6
12
|
};
|
|
@@ -16,6 +16,19 @@ export const hasDocument = () => {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Reads the current network state from the browser. Falls back to `true` when it is unknown - e.g. in Node.js or
|
|
21
|
+
* React Native, where `navigator.onLine` is not available.
|
|
22
|
+
*/
|
|
23
|
+
export const isNavigatorOnline = () => {
|
|
24
|
+
try {
|
|
25
|
+
return typeof navigator.onLine === "boolean" ? navigator.onLine : true;
|
|
26
|
+
} catch {
|
|
27
|
+
/* istanbul ignore next */
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
19
32
|
export const onWindowEvent = <K extends keyof WindowEventMap>(
|
|
20
33
|
key: K,
|
|
21
34
|
listener: (this: Window, ev: WindowEventMap[K]) => any,
|
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
import type { Adapter, AdapterInstance } from "adapter";
|
|
2
2
|
|
|
3
3
|
export type ExtractAdapterOptionsType<T> =
|
|
4
|
-
T extends Adapter<infer O, any, any, any, any, any, any, any, any, any, any> ? O : never;
|
|
4
|
+
T extends Adapter<infer O, any, any, any, any, any, any, any, any, any, any, any> ? O : never;
|
|
5
5
|
export type ExtractAdapterMethodType<T> =
|
|
6
|
-
T extends Adapter<any, infer M, any, any, any, any, any, any, any, any, any> ? M : never;
|
|
6
|
+
T extends Adapter<any, infer M, any, any, any, any, any, any, any, any, any, any> ? M : never;
|
|
7
7
|
export type ExtractAdapterStatusType<T> =
|
|
8
|
-
T extends Adapter<any, any, infer S, any, any, any, any, any, any, any, any> ? S : never;
|
|
8
|
+
T extends Adapter<any, any, infer S, any, any, any, any, any, any, any, any, any> ? S : never;
|
|
9
9
|
export type ExtractAdapterExtraType<T> =
|
|
10
|
-
T extends Adapter<any, any, any, infer A, any, any, any, any, any, any, any> ? A : never;
|
|
10
|
+
T extends Adapter<any, any, any, infer A, any, any, any, any, any, any, any, any> ? A : never;
|
|
11
11
|
export type ExtractAdapterQueryParamsType<T> =
|
|
12
|
-
T extends Adapter<any, any, any, any, infer Q, any, any, any, any, any, any> ? Q : never;
|
|
12
|
+
T extends Adapter<any, any, any, any, infer Q, any, any, any, any, any, any, any> ? Q : never;
|
|
13
13
|
export type ExtractAdapterDefaultQueryParamsType<T> =
|
|
14
|
-
T extends Adapter<any, any, any, any, any, infer Q, any, any, any, any, any> ? Q : never;
|
|
14
|
+
T extends Adapter<any, any, any, any, any, infer Q, any, any, any, any, any, any> ? Q : never;
|
|
15
15
|
export type ExtractAdapterEndpointType<T> =
|
|
16
|
-
T extends Adapter<any, any, any, any, any, any, infer E, any, any, any, any> ? E : never;
|
|
16
|
+
T extends Adapter<any, any, any, any, any, any, infer E, any, any, any, any, any> ? E : never;
|
|
17
17
|
export type ExtractAdapterEndpointMapperType<T> =
|
|
18
|
-
T extends Adapter<any, any, any, any, any, any, any, infer EM, any, any, any> ? EM : never;
|
|
18
|
+
T extends Adapter<any, any, any, any, any, any, any, infer EM, any, any, any, any> ? EM : never;
|
|
19
19
|
export type ExtractAdapterQueryParamsMapperType<T> =
|
|
20
|
-
T extends Adapter<any, any, any, any, any, any, any, any, infer QPM, any, any> ? QPM : never;
|
|
20
|
+
T extends Adapter<any, any, any, any, any, any, any, any, infer QPM, any, any, any> ? QPM : never;
|
|
21
21
|
export type ExtractAdapterHeaderMapperType<T> =
|
|
22
|
-
T extends Adapter<any, any, any, any, any, any, any, any, any, infer HM, any> ? HM : never;
|
|
22
|
+
T extends Adapter<any, any, any, any, any, any, any, any, any, infer HM, any, any> ? HM : never;
|
|
23
23
|
export type ExtractAdapterPayloadMapperType<T> =
|
|
24
|
-
T extends Adapter<any, any, any, any, any, any, any, any, any, any, infer PM> ? PM : never;
|
|
24
|
+
T extends Adapter<any, any, any, any, any, any, any, any, any, any, infer PM, any> ? PM : never;
|
|
25
|
+
/** `any` (e.g. `AdapterInstance`) resolves to `{}`, otherwise it would erase the type of the whole `createRequest` params */
|
|
26
|
+
export type ExtractAdapterRequestOptionsType<T> =
|
|
27
|
+
T extends Adapter<any, any, any, any, any, any, any, any, any, any, any, infer RO>
|
|
28
|
+
? 0 extends 1 & RO
|
|
29
|
+
? {}
|
|
30
|
+
: RO
|
|
31
|
+
: never;
|
|
25
32
|
|
|
26
33
|
// Special type only for selecting appropriate AdapterType union version (check FirebaseAdapterType).
|
|
27
34
|
export type ExtractUnionAdapter<
|