http-react
Advanced tools
Comparing version 3.5.0 to 3.5.1
@@ -72,5 +72,6 @@ 'use client'; | ||
function FetchConfig(props) { | ||
var children = props.children, _a = props.defaults, defaults = _a === void 0 ? {} : _a, _b = props.value, value = _b === void 0 ? {} : _b, _c = props.suspense, suspense = _c === void 0 ? [] : _c; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j; | ||
var children = props.children, _k = props.defaults, defaults = _k === void 0 ? {} : _k, _l = props.value, value = _l === void 0 ? {} : _l, _m = props.suspense, suspense = _m === void 0 ? [] : _m, clientOnly = props.clientOnly; | ||
var previousConfig = (0, internal_1.useHRFContext)(); | ||
var _d = previousConfig.cacheProvider, cacheProvider = _d === void 0 ? internal_1.defaultCache : _d; | ||
var _o = previousConfig.cacheProvider, cacheProvider = _o === void 0 ? internal_1.defaultCache : _o; | ||
function getAsyncFallbackValues() { | ||
@@ -195,3 +196,38 @@ return __awaiter(this, void 0, void 0, function () { | ||
} | ||
getAsyncFallbackValues(); | ||
if (clientOnly) { | ||
for (var valueKey in value) { | ||
var resolvedKey = (0, shared_1.serialize)({ | ||
idString: (0, shared_1.serialize)(valueKey) | ||
}); | ||
if (!(0, shared_1.isDefined)(internal_1.valuesMemory.get(resolvedKey))) { | ||
internal_1.valuesMemory.set(resolvedKey, (_b = (_a = value[valueKey]) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : value[valueKey]); | ||
} | ||
if (!(0, shared_1.isDefined)(internal_1.fetcherDefaults.get(resolvedKey))) { | ||
internal_1.fetcherDefaults.set(resolvedKey, (_d = (_c = value[valueKey]) === null || _c === void 0 ? void 0 : _c.data) !== null && _d !== void 0 ? _d : value[valueKey]); | ||
} | ||
if (!(0, shared_1.isDefined)(cacheProvider.get(resolvedKey))) { | ||
cacheProvider.set(resolvedKey, (_f = (_e = value[valueKey]) === null || _e === void 0 ? void 0 : _e.data) !== null && _f !== void 0 ? _f : value[valueKey]); | ||
} | ||
} | ||
for (var defaultKey in defaults) { | ||
var _p = defaults[defaultKey].id, id = _p === void 0 ? defaultKey : _p; | ||
var resolvedKey = (0, shared_1.serialize)({ | ||
idString: (0, shared_1.serialize)(id) | ||
}); | ||
if ((0, shared_1.isDefined)(id)) { | ||
if (!(0, shared_1.isDefined)(internal_1.valuesMemory.get(resolvedKey))) { | ||
internal_1.valuesMemory.set(resolvedKey, (_g = defaults[defaultKey]) === null || _g === void 0 ? void 0 : _g.value); | ||
} | ||
if (!(0, shared_1.isDefined)(internal_1.fetcherDefaults.get(resolvedKey))) { | ||
internal_1.fetcherDefaults.set(resolvedKey, (_h = defaults[defaultKey]) === null || _h === void 0 ? void 0 : _h.value); | ||
} | ||
} | ||
if (!(0, shared_1.isDefined)(cacheProvider.get(resolvedKey))) { | ||
cacheProvider.set(resolvedKey, (_j = defaults[defaultKey]) === null || _j === void 0 ? void 0 : _j.value); | ||
} | ||
} | ||
} | ||
else { | ||
getAsyncFallbackValues(); | ||
} | ||
for (var _i = 0, suspense_1 = suspense; _i < suspense_1.length; _i++) { | ||
@@ -198,0 +234,0 @@ var suspenseKey = suspense_1[_i]; |
export type HTTP_METHODS = 'GET' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'POST' | 'PUT' | 'PATCH' | 'PURGE' | 'LINK' | 'UNLINK'; | ||
export type FetchContextType = { | ||
clientOnly?: boolean; | ||
fetcher?(url: string, config: FetchConfigType): Promise<{ | ||
@@ -4,0 +5,0 @@ json?: any; |
@@ -122,5 +122,3 @@ import { useEffect } from 'react'; | ||
memory?: boolean | undefined; | ||
onSubmit?: "reset" | ((form: HTMLFormElement, data: FormData) => void) | undefined; /** | ||
* The caching mechanism | ||
*/ | ||
onSubmit?: "reset" | ((form: HTMLFormElement, data: FormData) => void) | undefined; | ||
onResolve?: ((data: any, res?: Response | undefined) => void) | undefined; | ||
@@ -127,0 +125,0 @@ cacheProvider?: CacheStoreType | undefined; |
{ | ||
"name": "http-react", | ||
"version": "3.5.0", | ||
"version": "3.5.1", | ||
"description": "React hooks for data fetching", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
269987
5872