http-react
Advanced tools
Comparing version 3.2.7 to 3.2.8
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /// <reference types="react" /> |
@@ -32,3 +32,3 @@ 'use client'; | ||
// This will render the fallback in the server | ||
return (ssr ? fallback : (0, jsx_runtime_1.jsx)(react_1.Suspense, __assign({ fallback: fallback }, { children: children }))); | ||
return (ssr ? fallback : (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: fallback, children: children })); | ||
} | ||
@@ -66,4 +66,4 @@ exports.SSRSuspense = SSRSuspense; | ||
var mergedConfig = __assign(__assign(__assign({}, previousConfig), props), { headers: __assign(__assign({}, previousConfig.headers), props.headers), children: undefined }); | ||
return ((0, jsx_runtime_1.jsx)(internal_1.FetchContext.Provider, __assign({ value: mergedConfig }, { children: children }))); | ||
return ((0, jsx_runtime_1.jsx)(internal_1.FetchContext.Provider, { value: mergedConfig, children: children })); | ||
} | ||
exports.FetchConfig = FetchConfig; |
export { FetchConfig, SSRSuspense } from '../index'; |
@@ -0,0 +0,0 @@ 'use client'; |
export { useFetch } from './use-fetch'; | ||
export { useIsomorphicLayoutEffect } from '../utils'; | ||
export { useFetchLoading as useLoading, useFetchConfig as useConfig, useFetchData as useData, useFetchCode as useCode, useFetchError as useError, useFetchMutate as useMutate, useFetchId as useFetchId, useFetchBlob as useBlob, useFetchText as useText, useFetchResponseTime as useResponseTime, useManualFetch, useRequestEnd, useRequestStart, useGET, useDELETE, useHEAD, useOPTIONS, usePOST, usePUT, usePATCH, usePURGE, useLINK, useUNLINK, useResolve, useGql, useImperative, useFetchSuspense, useExpiration, useHasData, useLoadingFirst, useOnline, useReFetch, useRevalidating, useSuccess, useDebounceFetch, useServerAction } from './others'; |
@@ -0,0 +0,0 @@ 'use client'; |
@@ -0,0 +0,0 @@ 'use client'; |
@@ -1,2 +0,2 @@ | ||
import { CustomResponse, FetchConfigType, FetchConfigTypeNoUrl, HTTP_METHODS, ImperativeFetch, TimeSpan } from '../types'; | ||
import { CustomResponse, FetchConfigType, FetchConfigTypeNoUrl, ImperativeFetch } from '../types'; | ||
/** | ||
@@ -20,49 +20,6 @@ * Fetch hook | ||
reFetch: () => Promise<void>; | ||
mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; | ||
mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: (data: FetchDataType, fetcher: ImperativeFetch) => void) => FetchDataType; | ||
fetcher: ImperativeFetch; | ||
abort: () => void; | ||
config: Omit<RequestInit, "body" | "headers"> & { | ||
headers?: any; | ||
fetcher?(url: string, config: FetchConfigType<FetchDataType, BodyType>): Promise<{ | ||
json?: any; | ||
data?: any; | ||
status?: number | undefined; | ||
blob?: any; | ||
text?: any; | ||
}>; | ||
body?: any; | ||
id?: any; | ||
url?: string | undefined; | ||
default?: FetchDataType | undefined; | ||
refresh?: TimeSpan | undefined; | ||
auto?: boolean | undefined; | ||
memory?: boolean | undefined; | ||
onResolve?: ((data: FetchDataType, res?: Response | undefined) => void) | undefined; | ||
cacheProvider?: import("../types").CacheStoreType | undefined; | ||
onMutate?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined; | ||
onError?: ((error: Error, req?: Response | undefined) => void) | undefined; | ||
onAbort?: (() => void) | undefined; | ||
cancelOnChange?: boolean | undefined; | ||
resolver?: ((d: CustomResponse<FetchDataType>) => any) | undefined; | ||
attempts?: number | undefined; | ||
attemptInterval?: TimeSpan | undefined; | ||
revalidateOnFocus?: boolean | undefined; | ||
revalidateOnMount?: boolean | undefined; | ||
onOffline?: (() => void) | undefined; | ||
onOnline?: ((e: { | ||
cancel: () => void; | ||
}) => void) | undefined; | ||
retryOnReconnect?: boolean | undefined; | ||
suspense?: boolean | undefined; | ||
baseUrl?: string | undefined; | ||
method?: HTTP_METHODS | undefined; | ||
query?: any; | ||
params?: any; | ||
formatBody?: boolean | ((b: BodyType) => any) | undefined; | ||
debounce?: TimeSpan | undefined; | ||
onFetchStart?: ((req: Request, config: FetchConfigType<any, any>, ctx: import("../types").FetchContextType) => void) | undefined; | ||
onFetchEnd?: ((res: Response, config: FetchConfigType<any, any>, ctx: import("../types").FetchContextType) => void) | undefined; | ||
cacheIfError?: boolean | undefined; | ||
maxCacheAge?: TimeSpan | undefined; | ||
} & { | ||
config: FetchConfigType<FetchDataType, BodyType> & { | ||
baseUrl: string; | ||
@@ -69,0 +26,0 @@ url: string; |
@@ -77,3 +77,3 @@ 'use client'; | ||
? __assign({ url: init.url, method: init.method, init: init }, options) : init; | ||
var _o = optionsConfig.onOnline, onOnline = _o === void 0 ? ctx.onOnline : _o, _p = optionsConfig.onOffline, onOffline = _p === void 0 ? ctx.onOffline : _p, onMutate = optionsConfig.onMutate, _q = optionsConfig.revalidateOnMount, revalidateOnMount = _q === void 0 ? ctx.revalidateOnMount : _q, _r = optionsConfig.url, url = _r === void 0 ? '' : _r, _s = optionsConfig.query, query = _s === void 0 ? {} : _s, _t = optionsConfig.params, params = _t === void 0 ? {} : _t, _u = optionsConfig.baseUrl, baseUrl = _u === void 0 ? undefined : _u, _v = optionsConfig.method, method = _v === void 0 ? isRequest ? init.method : constants_1.METHODS.GET : _v, _w = optionsConfig.headers, headers = _w === void 0 ? {} : _w, _x = optionsConfig.body, body = _x === void 0 ? undefined : _x, _y = optionsConfig.formatBody, formatBody = _y === void 0 ? function (e) { return JSON.stringify(e); } : _y, _z = optionsConfig.resolver, resolver = _z === void 0 ? (0, shared_1.isFunction)(ctx.resolver) ? ctx.resolver : constants_1.DEFAULT_RESOLVER : _z, onError = optionsConfig.onError, _0 = optionsConfig.auto, auto = _0 === void 0 ? (0, shared_1.isDefined)(ctx.auto) ? ctx.auto : true : _0, _1 = optionsConfig.memory, memory = _1 === void 0 ? (0, shared_1.isDefined)(ctx.memory) ? ctx.memory : true : _1, onResolve = optionsConfig.onResolve, onAbort = optionsConfig.onAbort, _2 = optionsConfig.refresh, refresh = _2 === void 0 ? (0, shared_1.isDefined)(ctx.refresh) ? ctx.refresh : 0 : _2, _3 = optionsConfig.attempts, attempts = _3 === void 0 ? ctx.attempts : _3, _4 = optionsConfig.attemptInterval, attemptInterval = _4 === void 0 ? ctx.attemptInterval : _4, _5 = optionsConfig.revalidateOnFocus, revalidateOnFocus = _5 === void 0 ? ctx.revalidateOnFocus : _5, $suspense = optionsConfig.suspense, _6 = optionsConfig.onFetchStart, onFetchStart = _6 === void 0 ? ctx.onFetchStart : _6, _7 = optionsConfig.onFetchEnd, onFetchEnd = _7 === void 0 ? ctx.onFetchEnd : _7, _8 = optionsConfig.cacheIfError, cacheIfError = _8 === void 0 ? ctx.cacheIfError : _8, _9 = optionsConfig.maxCacheAge, maxCacheAge = _9 === void 0 ? ctx.maxCacheAge : _9, _10 = optionsConfig.fetcher, fetcher = _10 === void 0 ? ctx.fetcher : _10; | ||
var _o = optionsConfig.onOnline, onOnline = _o === void 0 ? ctx.onOnline : _o, _p = optionsConfig.onOffline, onOffline = _p === void 0 ? ctx.onOffline : _p, onMutate = optionsConfig.onMutate, _q = optionsConfig.revalidateOnMount, revalidateOnMount = _q === void 0 ? ctx.revalidateOnMount : _q, _r = optionsConfig.url, url = _r === void 0 ? '' : _r, _s = optionsConfig.query, query = _s === void 0 ? {} : _s, _t = optionsConfig.params, params = _t === void 0 ? {} : _t, _u = optionsConfig.baseUrl, baseUrl = _u === void 0 ? undefined : _u, _v = optionsConfig.method, method = _v === void 0 ? isRequest ? init.method : constants_1.METHODS.GET : _v, _w = optionsConfig.headers, headers = _w === void 0 ? {} : _w, _x = optionsConfig.body, body = _x === void 0 ? undefined : _x, _y = optionsConfig.formatBody, formatBody = _y === void 0 ? function (e) { return JSON.stringify(e); } : _y, _z = optionsConfig.resolver, resolver = _z === void 0 ? (0, shared_1.isFunction)(ctx.resolver) ? ctx.resolver : constants_1.DEFAULT_RESOLVER : _z, onError = optionsConfig.onError, _0 = optionsConfig.auto, auto = _0 === void 0 ? (0, shared_1.isDefined)(ctx.auto) ? ctx.auto : true : _0, _1 = optionsConfig.memory, memory = _1 === void 0 ? (0, shared_1.isDefined)(ctx.memory) ? ctx.memory : true : _1, onResolve = optionsConfig.onResolve, onAbort = optionsConfig.onAbort, _2 = optionsConfig.refresh, refresh = _2 === void 0 ? (0, shared_1.isDefined)(ctx.refresh) ? ctx.refresh : 0 : _2, _3 = optionsConfig.attempts, attempts = _3 === void 0 ? ctx.attempts : _3, _4 = optionsConfig.attemptInterval, attemptInterval = _4 === void 0 ? ctx.attemptInterval : _4, _5 = optionsConfig.revalidateOnFocus, revalidateOnFocus = _5 === void 0 ? ctx.revalidateOnFocus : _5, $suspense = optionsConfig.suspense, _6 = optionsConfig.onFetchStart, onFetchStart = _6 === void 0 ? ctx.onFetchStart : _6, _7 = optionsConfig.onFetchEnd, onFetchEnd = _7 === void 0 ? ctx.onFetchEnd : _7, _8 = optionsConfig.cacheIfError, cacheIfError = _8 === void 0 ? ctx.cacheIfError : _8, _9 = optionsConfig.maxCacheAge, maxCacheAge = _9 === void 0 ? ctx.maxCacheAge : _9, _10 = optionsConfig.fetcher, fetcher = _10 === void 0 ? ctx.fetcher : _10, _11 = optionsConfig.middleware, middleware = _11 === void 0 ? ctx.middleware : _11; | ||
var $fetch = (0, shared_1.isFunction)(fetcher) ? fetcher : fetch; | ||
@@ -89,6 +89,6 @@ var config = { | ||
}; | ||
var _11 = ctx.cacheProvider, $cacheProvider = _11 === void 0 ? internal_1.defaultCache : _11; | ||
var _12 = ctx.cacheProvider, $cacheProvider = _12 === void 0 ? internal_1.defaultCache : _12; | ||
var logStart = (0, shared_1.isFunction)(onFetchStart); | ||
var logEnd = (0, shared_1.isFunction)(onFetchEnd); | ||
var _12 = optionsConfig.cacheProvider, cacheProvider = _12 === void 0 ? $cacheProvider : _12; | ||
var _13 = optionsConfig.cacheProvider, cacheProvider = _13 === void 0 ? $cacheProvider : _13; | ||
var requestCallId = (0, react_1.useMemo)(function () { return "".concat(Math.random()).split('.')[1]; }, []); | ||
@@ -116,3 +116,3 @@ var willResolve = (0, shared_1.isDefined)(onResolve); | ||
var defaultId = [method, url].join(' '); | ||
var _13 = optionsConfig.id, id = _13 === void 0 ? defaultId : _13; | ||
var _14 = optionsConfig.id, id = _14 === void 0 ? defaultId : _14; | ||
var idString = (0, shared_1.serialize)(id); | ||
@@ -203,3 +203,3 @@ var urlWithParams = (0, react_1.useMemo)(function () { return (0, shared_1.setURLParams)(rawUrl, reqParams); }, [(0, shared_1.serialize)(reqParams), config.baseUrl, ctx.baseUrl, url]); | ||
var initialDataValue = (_c = (_b = internal_1.valuesMemory.get(resolvedKey)) !== null && _b !== void 0 ? _b : requestCache) !== null && _c !== void 0 ? _c : def; | ||
var _14 = (0, react_1.useState)({ | ||
var _15 = (0, react_1.useState)({ | ||
data: initialDataValue, | ||
@@ -215,3 +215,3 @@ online: true, | ||
completedAttempts: 0 | ||
}), fetchState = _14[0], setFetchState = _14[1]; | ||
}), fetchState = _15[0], setFetchState = _15[1]; | ||
var thisDeps = (0, react_1.useRef)({ | ||
@@ -313,9 +313,9 @@ data: false, | ||
var isGqlRequest = (0, shared_1.isDefined)(optionsConfig['__gql']); | ||
var fetchData = (0, react_1.useCallback)(function fetchData(c) { | ||
var _a; | ||
if (c === void 0) { c = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var rawUrl, urlWithParams, realUrl, newAbortController_1, $$data_1, rpc_1, reqConfig, _headers, k, newRequestConfig, r, json, resolvedDate, code, _data_1, _b, dataExpirationTime, __data_1, err_1, errorString; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
var fetchData = (0, react_1.useCallback)(function fetchData() { | ||
return __awaiter(this, arguments, void 0, function (c) { | ||
var rawUrl, urlWithParams, realUrl, newAbortController_1, $$data_1, rpc_1, reqConfig, _headers, k, newRequestConfig, r, json, resolvedDate, code, incoming, _a, _data_1, _b, dataExpirationTime, __data_1, err_1, errorString; | ||
var _c; | ||
if (c === void 0) { c = {}; } | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
@@ -332,3 +332,3 @@ rawUrl = ((0, shared_1.hasBaseUrl)(url) | ||
(urlWithParams.includes('?') ? ((c === null || c === void 0 ? void 0 : c.query) !== '' ? "&" : '') : ''); | ||
if (!(internal_1.previousConfig.get(resolvedKey) !== (0, shared_1.serialize)(optionsConfig))) return [3 /*break*/, 8]; | ||
if (!(internal_1.previousConfig.get(resolvedKey) !== (0, shared_1.serialize)(optionsConfig))) return [3 /*break*/, 11]; | ||
internal_1.previousProps.set(resolvedKey, optionsConfig); | ||
@@ -344,3 +344,3 @@ (0, shared_1.queue)(function () { | ||
}); | ||
if (!!(0, internal_1.isPending)(resolvedKey)) return [3 /*break*/, 8]; | ||
if (!!(0, internal_1.isPending)(resolvedKey)) return [3 /*break*/, 11]; | ||
internal_1.runningRequests.set(resolvedKey, auto); | ||
@@ -362,5 +362,5 @@ internal_1.hasErrors.set(resolvedDataKey, false); | ||
rpc_1 = {}; | ||
_c.label = 1; | ||
_d.label = 1; | ||
case 1: | ||
_c.trys.push([1, 6, 7, 8]); | ||
_d.trys.push([1, 9, 10, 11]); | ||
reqConfig = {}; | ||
@@ -397,3 +397,3 @@ _headers = isRequest ? (0, shared_1.getRequestHeaders)(init) : {}; | ||
case 2: | ||
json = _c.sent(); | ||
json = _d.sent(); | ||
resolvedDate = Date.now(); | ||
@@ -407,10 +407,20 @@ cacheProvider.set('expiration' + resolvedDataKey, resolvedDate + maxAge); | ||
rpc_1 = __assign(__assign({}, rpc_1), { response: json, error: false, code: code }); | ||
if (!((_a = json === null || json === void 0 ? void 0 : json['data']) !== null && _a !== void 0)) return [3 /*break*/, 3]; | ||
_b = _a; | ||
if (!((_c = json === null || json === void 0 ? void 0 : json['data']) !== null && _c !== void 0)) return [3 /*break*/, 3]; | ||
_a = _c; | ||
return [3 /*break*/, 5]; | ||
case 3: return [4 /*yield*/, resolver(json)]; | ||
case 4: | ||
_b = (_c.sent()); | ||
_c.label = 5; | ||
_a = (_d.sent()); | ||
_d.label = 5; | ||
case 5: | ||
incoming = _a; | ||
if (!(0, shared_1.isFunction)(middleware)) return [3 /*break*/, 7]; | ||
return [4 /*yield*/, middleware(incoming, thisCache)]; | ||
case 6: | ||
_b = _d.sent(); | ||
return [3 /*break*/, 8]; | ||
case 7: | ||
_b = incoming; | ||
_d.label = 8; | ||
case 8: | ||
_data_1 = _b; | ||
@@ -510,5 +520,5 @@ if (code >= 200 && code < 400) { | ||
} | ||
return [3 /*break*/, 8]; | ||
case 6: | ||
err_1 = _c.sent(); | ||
return [3 /*break*/, 11]; | ||
case 9: | ||
err_1 = _d.sent(); | ||
errorString = err_1 === null || err_1 === void 0 ? void 0 : err_1.toString(); | ||
@@ -557,4 +567,4 @@ // Only set error if no abort | ||
} | ||
return [3 /*break*/, 8]; | ||
case 7: | ||
return [3 /*break*/, 11]; | ||
case 10: | ||
internal_1.runningRequests.set(resolvedKey, false); | ||
@@ -570,3 +580,3 @@ internal_1.suspenseInitialized.set(resolvedKey, true); | ||
return [2 /*return*/, $$data_1]; | ||
case 8: return [2 /*return*/]; | ||
case 11: return [2 /*return*/]; | ||
} | ||
@@ -1042,3 +1052,3 @@ }); | ||
} | ||
var _15 = [ | ||
var _16 = [ | ||
(0, shared_1.notNull)(cacheProvider.get('requestStart' + resolvedDataKey)) | ||
@@ -1050,3 +1060,3 @@ ? new Date(cacheProvider.get('requestStart' + resolvedDataKey)) | ||
: null | ||
], $requestStart = _15[0], $requestEnd = _15[1]; | ||
], $requestStart = _16[0], $requestEnd = _16[1]; | ||
var expirationDate = error | ||
@@ -1053,0 +1063,0 @@ ? (0, shared_1.notNull)($requestEnd) |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -14,2 +14,3 @@ declare const DEFAULTS: {}; | ||
declare const DEFAULT_RESOLVER: (e: any) => any; | ||
declare const DEFAULT_MIDDLEWARE: (incoming: any, previous: any) => any; | ||
declare const METHODS: { | ||
@@ -37,2 +38,2 @@ GET: string; | ||
}; | ||
export { DEFAULTS, QUERY, PARAMS, ON_OFFLINE, ON_ONLINE, ONLINE, ATTEMPTS, ATTEMPT_INTERVAL, REVALIDATE_ON_FOCUS, RETRY_ON_RECONNECT, REVALIDATE_ON_MOUNT, DEFAULT_GRAPHQL_PATH, DEFAULT_RESOLVER, METHODS, UNITS_MILISECONDS_EQUIVALENTS }; | ||
export { DEFAULTS, QUERY, PARAMS, ON_OFFLINE, ON_ONLINE, ONLINE, ATTEMPTS, ATTEMPT_INTERVAL, REVALIDATE_ON_FOCUS, RETRY_ON_RECONNECT, REVALIDATE_ON_MOUNT, DEFAULT_GRAPHQL_PATH, DEFAULT_RESOLVER, METHODS, UNITS_MILISECONDS_EQUIVALENTS, DEFAULT_MIDDLEWARE }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.UNITS_MILISECONDS_EQUIVALENTS = exports.METHODS = exports.DEFAULT_RESOLVER = exports.DEFAULT_GRAPHQL_PATH = exports.REVALIDATE_ON_MOUNT = exports.RETRY_ON_RECONNECT = exports.REVALIDATE_ON_FOCUS = exports.ATTEMPT_INTERVAL = exports.ATTEMPTS = exports.ONLINE = exports.ON_ONLINE = exports.ON_OFFLINE = exports.PARAMS = exports.QUERY = exports.DEFAULTS = void 0; | ||
exports.DEFAULT_MIDDLEWARE = exports.UNITS_MILISECONDS_EQUIVALENTS = exports.METHODS = exports.DEFAULT_RESOLVER = exports.DEFAULT_GRAPHQL_PATH = exports.REVALIDATE_ON_MOUNT = exports.RETRY_ON_RECONNECT = exports.REVALIDATE_ON_FOCUS = exports.ATTEMPT_INTERVAL = exports.ATTEMPTS = exports.ONLINE = exports.ON_ONLINE = exports.ON_OFFLINE = exports.PARAMS = exports.QUERY = exports.DEFAULTS = void 0; | ||
var DEFAULTS = {}; | ||
@@ -30,2 +30,4 @@ exports.DEFAULTS = DEFAULTS; | ||
exports.DEFAULT_RESOLVER = DEFAULT_RESOLVER; | ||
var DEFAULT_MIDDLEWARE = function (incoming, previous) { return incoming; }; | ||
exports.DEFAULT_MIDDLEWARE = DEFAULT_MIDDLEWARE; | ||
var METHODS = { | ||
@@ -32,0 +34,0 @@ GET: 'GET', |
@@ -0,0 +0,0 @@ /// <reference types="react" /> |
@@ -115,3 +115,4 @@ 'use client'; | ||
revalidateOnMount: constants_1.REVALIDATE_ON_MOUNT, | ||
cacheIfError: true | ||
cacheIfError: true, | ||
middleware: constants_1.DEFAULT_MIDDLEWARE | ||
}; | ||
@@ -118,0 +119,0 @@ exports.FetchContext = (0, react_1.createContext)(defaultContextVaue); |
@@ -30,2 +30,3 @@ export type HTTP_METHODS = 'GET' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'POST' | 'PUT' | 'PATCH' | 'PURGE' | 'LINK' | 'UNLINK'; | ||
resolver?: (r: Response) => any; | ||
middleware?(incomindgData: any, previousData: any): any; | ||
children?: any; | ||
@@ -125,2 +126,8 @@ auto?: boolean; | ||
headers?: any; | ||
/** | ||
* The middleware function should return the data that will be commited to the state. It can be used for pagination, logging, etc. | ||
* | ||
* It assumes `previousData`, `incomingData` and the returned data have the same type for consistency. | ||
*/ | ||
middleware?(incomindgData: FetchDataType, previousData: FetchDataType): FetchDataType; | ||
fetcher?(url: string, config: FetchConfigType<FetchDataType, BodyType>): Promise<{ | ||
@@ -127,0 +134,0 @@ json?: any; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -58,3 +58,3 @@ import { useEffect } from 'react'; | ||
}; | ||
} ? { [e in keyof R]: R[e]; }[P]["value"] : any, any>, "url"> & { | ||
} ? { [e in keyof R]: R[e]; }[P]["value"] : any>, "url"> & { | ||
default?: ({ [e in keyof R]: R[e]; }[P] extends { | ||
@@ -96,2 +96,3 @@ value: unknown; | ||
headers?: any; | ||
middleware?(incomindgData: any, previousData: any): any; | ||
fetcher?(url: string, config: import("../types").FetchConfigType<any, any>): Promise<{ | ||
@@ -98,0 +99,0 @@ json?: any; |
@@ -0,0 +0,0 @@ 'use client'; |
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
export declare function getRequestHeaders(req: Request): { | ||
[k: string]: any; | ||
[k: string]: string; | ||
}; | ||
@@ -9,0 +9,0 @@ export declare function isDefined(target: any): boolean; |
@@ -156,9 +156,17 @@ "use strict"; | ||
return params[paramName] | ||
.map(function (p) { return "".concat(paramName, "=").concat(encodeURIComponent(p)); }) | ||
.map(function (p) { | ||
return typeof p === 'undefined' | ||
? '' | ||
: "".concat(paramName, "=").concat(encodeURIComponent(p)); | ||
}) | ||
.filter(Boolean) | ||
.join('&'); | ||
} | ||
else { | ||
if (typeof params[paramName] === 'undefined') | ||
return ''; | ||
return "".concat(paramName, "=").concat(encodeURIComponent(params[paramName])); | ||
} | ||
}) | ||
.filter(Boolean) | ||
.join('&'); | ||
@@ -184,6 +192,6 @@ return (url + | ||
function createRequestFn(method, baseUrl, $headers) { | ||
return function (url, init) { | ||
if (init === void 0) { init = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return function (url_1) { | ||
return __awaiter(this, arguments, void 0, function (url, init) { | ||
var def, _a, params, headers, _b, query, body, _c, $method, formatBody, _d, resolver, _e, onResolve, _f, onError, rawUrl, reqQueryString, reqConfig, r, requestUrl, req, data, err_1; | ||
if (init === void 0) { init = {}; } | ||
return __generator(this, function (_g) { | ||
@@ -190,0 +198,0 @@ switch (_g.label) { |
{ | ||
"name": "http-react", | ||
"version": "3.2.7", | ||
"version": "3.2.8", | ||
"description": "React hooks for data fetching", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"test": "tsc && webpack --mode production && jest", | ||
"test": "tsc && jest", | ||
"compile": "tsc" | ||
@@ -39,18 +39,19 @@ }, | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.16.11", | ||
"@babel/preset-react": "^7.16.7", | ||
"@testing-library/react": "^13.1.1", | ||
"@testing-library/react-hooks": "^7.0.2", | ||
"@types/jest": "^27.4.0", | ||
"@types/react": "^18.0.9", | ||
"babel-jest": "^27.4.6", | ||
"jest": "^27.4.7", | ||
"react": ">=16.13.1", | ||
"react-dom": ">=16.13.1", | ||
"react-test-renderer": "^17.0.2", | ||
"ts-jest": "^27.1.3", | ||
"ts-loader": "^9.4.2", | ||
"typescript": "^4.5.5", | ||
"webpack": "^5.75.0", | ||
"webpack-cli": "^5.0.1" | ||
"@babel/preset-env": "^7.24.4", | ||
"@babel/preset-react": "^7.24.1", | ||
"@testing-library/react": "^15.0.2", | ||
"@testing-library/react-hooks": "3.4.1", | ||
"@types/jest": "^29.5.12", | ||
"@types/react": "^18.2.79", | ||
"babel-jest": "^29.7.0", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-test-renderer": "^18.2.0", | ||
"ts-jest": "^29.1.2", | ||
"ts-loader": "^9.5.1", | ||
"typescript": "^5.4.5", | ||
"webpack": "^5.91.0", | ||
"webpack-cli": "^5.1.4" | ||
}, | ||
@@ -57,0 +58,0 @@ "peerDependencies": { |
Sorry, the diff of this file is too big to display
222820
17
4892