Comparing version 3.2.2-canary-20241030084036.8a8ba96a67f2b79a53e49800389c7c57a8640208 to 3.2.2-canary-20241030171637.226cdf31797ac07d5472d9d6e17c7138ef87e932
@@ -50,3 +50,3 @@ 'use strict'; | ||
/** Look up table for normalized objects. */ | ||
__privateAdd(this, _normalizedObjects, /* @__PURE__ */ new Map()); | ||
__privateAdd(this, _normalizedObjects, new frailMap.FrailMap()); | ||
/** Temporary strong references for the WeakRefs in FrailMap. */ | ||
@@ -53,0 +53,0 @@ __privateAdd(this, _dataRefs, /* @__PURE__ */ new Set()); |
@@ -0,1 +1,2 @@ | ||
import type { FrailMap } from 'frail-map'; | ||
import type { CacheNode, CacheObject } from '.'; | ||
@@ -8,3 +9,3 @@ export type NormalizedObjectShell<TData extends CacheObject = CacheObject> = TData & { | ||
export type NormalizatioOptions<TData extends CacheObject = CacheObject> = CacheNormalizationHandler & { | ||
store: Map<string, NormalizedObjectShell<TData>>; | ||
store: FrailMap<string, NormalizedObjectShell<TData>>; | ||
}; | ||
@@ -11,0 +12,0 @@ /** |
@@ -11,3 +11,3 @@ import type { ExecutionResult } from 'graphql'; | ||
* | ||
* If the cache to omitted, a global cache will be used instead. | ||
* If the `cache` argument is omitted, a global cache will be used instead. | ||
*/ | ||
@@ -14,0 +14,0 @@ export declare const dedupePromise: <TData = Record<string, unknown>, TExtensions = Record<string, unknown>>(cache: Cache | undefined, hash: string, fetchOrSubscribe: () => Promise<ExecutionResult<TData, TExtensions> | void>) => Promise<ExecutionResult<TData, TExtensions>>; |
@@ -148,2 +148,4 @@ import type { BaseGeneratedSchema, FetchOptions } from '.'; | ||
* promise. | ||
* | ||
* @deprecated Use the `unsubscribe` method returned from `subscribe()` instead. | ||
*/ | ||
@@ -150,0 +152,0 @@ onSubscribe?: (unsubscribe: Unsubscribe) => void; |
@@ -45,2 +45,3 @@ 'use strict'; | ||
const correlatedCaches = new multidict.MultiDict(); | ||
const subscriber$1 = subscriber.isWsClient(fetchOptions.subscriber) ? subscriber.createSubscriber(fetchOptions.subscriber) : fetchOptions.subscriber; | ||
const createResolver = ({ | ||
@@ -178,3 +179,2 @@ cachePolicy = defaultCachePolicy, | ||
}; | ||
const subscriber$1 = subscriber.isWsClient(fetchOptions.subscriber) ? subscriber.createSubscriber(fetchOptions.subscriber) : fetchOptions.subscriber; | ||
const subscribe = ({ | ||
@@ -235,4 +235,3 @@ onComplete, | ||
[{ data, error, extensions: extensions2 }], | ||
cachePolicy !== "no-store" && context$1.cache !== resolverCache ? [context$1.cache, resolverCache] : [context$1.cache], | ||
{ skipNotify: !context$1.notifyCacheUpdate } | ||
cachePolicy !== "no-store" && context$1.cache !== resolverCache ? [context$1.cache, resolverCache] : [context$1.cache] | ||
); | ||
@@ -258,3 +257,3 @@ if (!lastSelectionsUpdated) { | ||
operationName, | ||
onSubscribe: () => onSubscribe == null ? void 0 : onSubscribe(unsubscribe2), | ||
onSubscribe: () => queueMicrotask(() => onSubscribe == null ? void 0 : onSubscribe(unsubscribe2)), | ||
onComplete: () => resolve2() | ||
@@ -261,0 +260,0 @@ } |
@@ -156,7 +156,11 @@ 'use strict'; | ||
next, | ||
error(err) { | ||
if (Array.isArray(err)) { | ||
error(index.GQtyError.fromGraphQLErrors(err)); | ||
} else if (!isCloseEvent(err)) { | ||
error(index.GQtyError.create(err)); | ||
error(e) { | ||
if (Array.isArray(e)) { | ||
error(index.GQtyError.fromGraphQLErrors(e)); | ||
} else if (!isCloseEvent(e)) { | ||
if (e instanceof Error) { | ||
error(index.GQtyError.create(e)); | ||
} else { | ||
console.error("Unknown subscription error:", e); | ||
} | ||
} | ||
@@ -163,0 +167,0 @@ this.complete(); |
@@ -5,2 +5,3 @@ import type { Client as SseClient } from 'graphql-sse'; | ||
export type GQtyWsClient = WsClient & { | ||
isOnline?: boolean; | ||
/** | ||
@@ -16,2 +17,2 @@ * Subscription listeners to be called when the client is online, or called | ||
*/ | ||
export declare const createSubscriber: (client: WsClient) => GQtyWsClient; | ||
export declare const createSubscriber: (input: WsClient) => GQtyWsClient; |
@@ -6,24 +6,26 @@ 'use strict'; | ||
const isWsClient = (client) => client !== void 0 && typeof client.on === "function"; | ||
const createSubscriber = (client) => { | ||
const listeners = /* @__PURE__ */ new Set(); | ||
const newClient = client; | ||
let isOnline = false; | ||
newClient.on("connected", () => { | ||
if (!isOnline) { | ||
isOnline = true; | ||
const createSubscriber = (input) => { | ||
const client = input; | ||
if (client.onSubscribe !== void 0) { | ||
return client; | ||
} | ||
const listeners = []; | ||
client.on("connected", () => { | ||
if (!client.isOnline) { | ||
client.isOnline = true; | ||
listeners.forEach((fn) => fn()); | ||
listeners.clear(); | ||
listeners.length = 0; | ||
} | ||
}); | ||
newClient.on("closed", () => { | ||
isOnline = false; | ||
client.on("closed", () => { | ||
client.isOnline = false; | ||
}); | ||
newClient.onSubscribe = (fn) => { | ||
if (isOnline) { | ||
client.onSubscribe = (fn) => { | ||
if (client.isOnline) { | ||
fn(); | ||
} else { | ||
listeners.add(fn); | ||
listeners.push(fn); | ||
} | ||
}; | ||
return newClient; | ||
return client; | ||
}; | ||
@@ -30,0 +32,0 @@ |
{ | ||
"name": "gqty", | ||
"version": "3.2.2-canary-20241030084036.8a8ba96a67f2b79a53e49800389c7c57a8640208", | ||
"version": "3.2.2-canary-20241030171637.226cdf31797ac07d5472d9d6e17c7138ef87e932", | ||
"description": "The No-GraphQL Client for TypeScript", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -49,3 +49,3 @@ 'use strict'; | ||
const input = s.input; | ||
if (input) { | ||
if (input && Object.keys(input.values).length > 0) { | ||
if (!inputDedupe.has(input)) { | ||
@@ -52,0 +52,0 @@ const queryInputs = Object.entries(input.values).map(([key2, value]) => { |
@@ -51,2 +51,5 @@ 'use strict'; | ||
return this; | ||
}, | ||
async [Symbol.asyncDispose]() { | ||
await this.return(); | ||
} | ||
@@ -53,0 +56,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
295426
8305