Comparing version 3.0.0-alpha-524ea531.0 to 3.0.0-alpha-577a9298.0
@@ -285,3 +285,14 @@ 'use strict'; | ||
} | ||
return cache.get(`${type}.${field}`, cacheOptions); | ||
const { data } = cache.get(`${type}.${field}`, cacheOptions); | ||
return { | ||
data, | ||
get expiresAt() { | ||
var _a, _b; | ||
return (_b = (_a = cache.get(`${type}.${field}`, cacheOptions)) == null ? void 0 : _a.expiresAt) != null ? _b : -Infinity; | ||
}, | ||
get swrBefore() { | ||
var _a, _b; | ||
return (_b = (_a = cache.get(`${type}.${field}`, cacheOptions)) == null ? void 0 : _a.swrBefore) != null ? _b : -Infinity; | ||
} | ||
}; | ||
}; | ||
@@ -288,0 +299,0 @@ const getIdentityFields = ({ |
@@ -36,2 +36,7 @@ import { type GeneratedSchemaObject } from '../Schema'; | ||
swrBefore?: number; | ||
/** | ||
* Remove internal data reference, allowing WeakRefs to be garbase collected. | ||
* | ||
* For StrongRefs, calling this function has no effect. | ||
*/ | ||
unref?: () => void; | ||
@@ -38,0 +43,0 @@ }; |
@@ -64,4 +64,4 @@ 'use strict'; | ||
__privateAdd(this, _normalizedObjects, /* @__PURE__ */ new Map()); | ||
/** Temporary strong references in parallel with the WeakRef in FrailMap. */ | ||
__privateAdd(this, _dataRefs, /* @__PURE__ */ new Map()); | ||
/** Temporary strong references for the WeakRefs in FrailMap. */ | ||
__privateAdd(this, _dataRefs, /* @__PURE__ */ new Set()); | ||
/** Subscription paths and it's listener function. */ | ||
@@ -225,3 +225,3 @@ __privateAdd(this, _subscriptions, /* @__PURE__ */ new Map()); | ||
set(values, { skipNotify = false } = {}) { | ||
var _a, _b; | ||
var _a; | ||
const age = this.maxAge; | ||
@@ -238,9 +238,8 @@ const swr = this.staleWhileRevalidate; | ||
for (const [field, data] of Object.entries(cacheObjects)) { | ||
const __ref = Symbol(); | ||
const cacheKey = `${type}.${field}`; | ||
let unrefTimer; | ||
const unref = () => { | ||
clearTimeout(unrefTimer); | ||
__privateGet(this, _dataRefs).delete(__ref); | ||
__privateGet(this, _dataRefs).delete(dataContainer); | ||
}; | ||
const cacheKey = `${type}.${field}`; | ||
const dataContainer = ( | ||
@@ -264,3 +263,9 @@ // Mutation and subscription results should be returned right away for | ||
); | ||
(_b = (_a = __privateGet(this, _data).get(cacheKey)) == null ? void 0 : _a.unref) == null ? void 0 : _b.call(_a); | ||
const existing = __privateGet(this, _data).get(cacheKey); | ||
if (existing) { | ||
(_a = existing.unref) == null ? void 0 : _a.call(existing); | ||
Object.assign(existing, dataContainer); | ||
} else { | ||
__privateGet(this, _data).set(cacheKey, dataContainer, { strong: !isFinite(age) }); | ||
} | ||
if (isFinite(age + swr)) { | ||
@@ -271,5 +276,4 @@ unrefTimer = setTimeout(unref, age + swr); | ||
} | ||
__privateGet(this, _dataRefs).set(__ref, dataContainer); | ||
__privateGet(this, _dataRefs).add(dataContainer); | ||
} | ||
__privateGet(this, _data).set(cacheKey, dataContainer, { strong: !isFinite(age) }); | ||
} | ||
@@ -276,0 +280,0 @@ } |
{ | ||
"name": "gqty", | ||
"version": "3.0.0-alpha-524ea531.0", | ||
"version": "3.0.0-alpha-577a9298.0", | ||
"description": "gqty client without queries", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
276605
7958