@apollo/client
Advanced tools
Comparing version 0.0.0-pr-11638-20240304221457 to 0.0.0-pr-11647-20240307055025
@@ -15,2 +15,3 @@ import { __assign } from "tslib"; | ||
import { getApolloClientMemoryInternals } from "../utilities/caching/getMemoryInternals.js"; | ||
import { getDevtoolsConnector } from "../devtools/index.js"; | ||
export { mergeOptions }; | ||
@@ -128,7 +129,6 @@ /** | ||
if (typeof window === "object") { | ||
var windowWithDevTools = window; | ||
var devtoolsSymbol = Symbol.for("apollo.devtools"); | ||
(windowWithDevTools[devtoolsSymbol] = | ||
windowWithDevTools[devtoolsSymbol] || []).push(this); | ||
windowWithDevTools.__APOLLO_CLIENT__ = this; | ||
var connector = getDevtoolsConnector(); | ||
var windowWithClient = window; | ||
connector.push(this); | ||
windowWithClient.__APOLLO_CLIENT__ = this; | ||
} | ||
@@ -135,0 +135,0 @@ /** |
@@ -431,3 +431,3 @@ 'use strict'; | ||
var version = "0.0.0-pr-11638-20240304221457"; | ||
var version = "0.0.0-pr-11647-20240307055025"; | ||
@@ -434,0 +434,0 @@ function maybe(thunk) { |
{ | ||
"name": "@apollo/client", | ||
"version": "0.0.0-pr-11638-20240304221457", | ||
"version": "0.0.0-pr-11647-20240307055025", | ||
"description": "A fully-featured caching GraphQL client.", | ||
@@ -62,3 +62,3 @@ "private": false, | ||
"prop-types": "^15.7.2", | ||
"rehackt": "0.0.5", | ||
"rehackt": "0.0.6", | ||
"response-iterator": "^0.2.6", | ||
@@ -75,3 +75,3 @@ "symbol-observable": "^4.0.0", | ||
"@changesets/cli": "2.27.1", | ||
"@graphql-tools/schema": "10.0.2", | ||
"@graphql-tools/schema": "10.0.3", | ||
"@microsoft/api-extractor": "7.40.2", | ||
@@ -92,5 +92,5 @@ "@rollup/plugin-node-resolve": "11.2.1", | ||
"@types/lodash": "4.14.202", | ||
"@types/node": "20.11.19", | ||
"@types/node": "20.11.24", | ||
"@types/node-fetch": "2.6.11", | ||
"@types/react": "18.2.56", | ||
"@types/react": "18.2.61", | ||
"@types/react-dom": "18.2.19", | ||
@@ -128,4 +128,4 @@ "@types/relay-runtime": "14.1.23", | ||
"react-dom-17": "npm:react-dom@^17", | ||
"react-error-boundary": "4.0.12", | ||
"recast": "0.23.4", | ||
"react-error-boundary": "4.0.13", | ||
"recast": "0.23.5", | ||
"resolve": "1.22.8", | ||
@@ -132,0 +132,0 @@ "rimraf": "5.0.5", |
@@ -87,5 +87,60 @@ 'use strict'; | ||
function useDeepMemo(memoFn, deps) { | ||
var ref = React__namespace.useRef(); | ||
if (!ref.current || !equality.equal(ref.current.deps, deps)) { | ||
ref.current = { value: memoFn(), deps: deps }; | ||
} | ||
return ref.current.value; | ||
} | ||
function getRenderDispatcher() { | ||
var _a, _b; | ||
return (_b = (_a = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current; | ||
} | ||
var RenderDispatcher = null; | ||
function useRenderGuard() { | ||
RenderDispatcher = getRenderDispatcher(); | ||
return React__namespace.useCallback(function () { | ||
return (RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher()); | ||
}, []); | ||
} | ||
var INIT = {}; | ||
function useLazyRef(getInitialValue) { | ||
var ref = React__namespace.useRef(INIT); | ||
if (ref.current === INIT) { | ||
ref.current = getInitialValue(); | ||
} | ||
return ref; | ||
} | ||
var useKey = "use"; | ||
var realHook = React__namespace[useKey]; | ||
var __use = realHook || | ||
function __use(promise) { | ||
var statefulPromise = utilities.wrapPromiseWithState(promise); | ||
switch (statefulPromise.status) { | ||
case "pending": | ||
throw statefulPromise; | ||
case "rejected": | ||
throw statefulPromise.reason; | ||
case "fulfilled": | ||
return statefulPromise.value; | ||
} | ||
}; | ||
var wrapperSymbol = Symbol.for("apollo.hook.wrappers"); | ||
function wrapHook(hookName, useHook, clientOrObsQuery) { | ||
var queryManager = clientOrObsQuery["queryManager"]; | ||
var wrappers = queryManager && queryManager[wrapperSymbol]; | ||
var wrapper = wrappers && wrappers[hookName]; | ||
return wrapper ? wrapper(useHook) : useHook; | ||
} | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function useQuery(query, options) { | ||
if (options === void 0) { options = Object.create(null); } | ||
return wrapHook("useQuery", _useQuery, useApolloClient(options && options.client))(query, options); | ||
} | ||
function _useQuery(query, options) { | ||
return useInternalState(useApolloClient(options.client), query).useQuery(options); | ||
@@ -695,47 +750,6 @@ } | ||
function useDeepMemo(memoFn, deps) { | ||
var ref = React__namespace.useRef(); | ||
if (!ref.current || !equality.equal(ref.current.deps, deps)) { | ||
ref.current = { value: memoFn(), deps: deps }; | ||
} | ||
return ref.current.value; | ||
function useFragment(options) { | ||
return wrapHook("useFragment", _useFragment, useApolloClient(options.client))(options); | ||
} | ||
function getRenderDispatcher() { | ||
var _a, _b; | ||
return (_b = (_a = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current; | ||
} | ||
var RenderDispatcher = null; | ||
function useRenderGuard() { | ||
RenderDispatcher = getRenderDispatcher(); | ||
return React__namespace.useCallback(function () { | ||
return (RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher()); | ||
}, []); | ||
} | ||
var INIT = {}; | ||
function useLazyRef(getInitialValue) { | ||
var ref = React__namespace.useRef(INIT); | ||
if (ref.current === INIT) { | ||
ref.current = getInitialValue(); | ||
} | ||
return ref; | ||
} | ||
var useKey = "use"; | ||
var realHook = React__namespace[useKey]; | ||
var __use = realHook || | ||
function __use(promise) { | ||
var statefulPromise = utilities.wrapPromiseWithState(promise); | ||
switch (statefulPromise.status) { | ||
case "pending": | ||
throw statefulPromise; | ||
case "rejected": | ||
throw statefulPromise.reason; | ||
case "fulfilled": | ||
return statefulPromise.value; | ||
} | ||
}; | ||
function useFragment(options) { | ||
function _useFragment(options) { | ||
var cache = useApolloClient(options.client).cache; | ||
@@ -780,2 +794,5 @@ var diffOptions = useDeepMemo(function () { | ||
if (options === void 0) { options = Object.create(null); } | ||
return wrapHook("useSuspenseQuery", _useSuspenseQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options); | ||
} | ||
function _useSuspenseQuery(query, options) { | ||
var client = useApolloClient(options.client); | ||
@@ -898,2 +915,5 @@ var suspenseCache = internal.getSuspenseCache(client); | ||
if (options === void 0) { options = Object.create(null); } | ||
return wrapHook("useBackgroundQuery", _useBackgroundQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options); | ||
} | ||
function _useBackgroundQuery(query, options) { | ||
var client = useApolloClient(options.client); | ||
@@ -1013,2 +1033,5 @@ var suspenseCache = internal.getSuspenseCache(client); | ||
function useReadQuery(queryRef) { | ||
return wrapHook("useReadQuery", _useReadQuery, internal.unwrapQueryRef(queryRef)["observable"])(queryRef); | ||
} | ||
function _useReadQuery(queryRef) { | ||
var internalQueryRef = React__namespace.useMemo(function () { return internal.unwrapQueryRef(queryRef); }, [queryRef]); | ||
@@ -1015,0 +1038,0 @@ var getPromise = React__namespace.useCallback(function () { return internal.getWrappedPromise(queryRef); }, [queryRef]); |
@@ -6,2 +6,3 @@ export { useDeepMemo } from "./useDeepMemo.js"; | ||
export { __use } from "./__use.js"; | ||
export { wrapHook } from "./wrapHook.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,2 +7,3 @@ // These hooks are used internally and are not exported publicly by the library | ||
export { __use } from "./__use.js"; | ||
export { wrapHook } from "./wrapHook.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -5,2 +5,3 @@ import { __spreadArray } from "tslib"; | ||
import { getSuspenseCache, unwrapQueryRef, updateWrappedQueryRef, wrapQueryRef, } from "../internal/index.js"; | ||
import { wrapHook } from "./internal/index.js"; | ||
import { useWatchQueryOptions } from "./useSuspenseQuery.js"; | ||
@@ -10,2 +11,5 @@ import { canonicalStringify } from "../../cache/index.js"; | ||
if (options === void 0) { options = Object.create(null); } | ||
return wrapHook("useBackgroundQuery", _useBackgroundQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options); | ||
} | ||
function _useBackgroundQuery(query, options) { | ||
var client = useApolloClient(options.client); | ||
@@ -12,0 +16,0 @@ var suspenseCache = getSuspenseCache(client); |
@@ -7,4 +7,7 @@ import { __assign, __rest } from "tslib"; | ||
import { useSyncExternalStore } from "./useSyncExternalStore.js"; | ||
import { useDeepMemo, useLazyRef } from "./internal/index.js"; | ||
import { useDeepMemo, useLazyRef, wrapHook } from "./internal/index.js"; | ||
export function useFragment(options) { | ||
return wrapHook("useFragment", _useFragment, useApolloClient(options.client))(options); | ||
} | ||
function _useFragment(options) { | ||
var cache = useApolloClient(options.client).cache; | ||
@@ -11,0 +14,0 @@ var diffOptions = useDeepMemo(function () { |
@@ -13,2 +13,3 @@ import { __assign, __rest } from "tslib"; | ||
import { canUseWeakMap, compact, isNonEmptyArray, maybeDeepFreeze, } from "../../utilities/index.js"; | ||
import { wrapHook } from "./internal/index.js"; | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
@@ -51,2 +52,5 @@ /** | ||
if (options === void 0) { options = Object.create(null); } | ||
return wrapHook("useQuery", _useQuery, useApolloClient(options && options.client))(query, options); | ||
} | ||
function _useQuery(query, options) { | ||
return useInternalState(useApolloClient(options.client), query).useQuery(options); | ||
@@ -53,0 +57,0 @@ } |
import * as React from "rehackt"; | ||
import { getWrappedPromise, unwrapQueryRef, updateWrappedQueryRef, } from "../internal/index.js"; | ||
import { __use } from "./internal/index.js"; | ||
import { __use, wrapHook } from "./internal/index.js"; | ||
import { toApolloError } from "./useSuspenseQuery.js"; | ||
import { useSyncExternalStore } from "./useSyncExternalStore.js"; | ||
export function useReadQuery(queryRef) { | ||
return wrapHook("useReadQuery", _useReadQuery, unwrapQueryRef(queryRef)["observable"])(queryRef); | ||
} | ||
function _useReadQuery(queryRef) { | ||
var internalQueryRef = React.useMemo(function () { return unwrapQueryRef(queryRef); }, [queryRef]); | ||
@@ -8,0 +11,0 @@ var getPromise = React.useCallback(function () { return getWrappedPromise(queryRef); }, [queryRef]); |
@@ -8,3 +8,3 @@ import { __assign, __spreadArray } from "tslib"; | ||
import { DocumentType, verifyDocumentType } from "../parser/index.js"; | ||
import { __use, useDeepMemo } from "./internal/index.js"; | ||
import { __use, useDeepMemo, wrapHook } from "./internal/index.js"; | ||
import { getSuspenseCache } from "../internal/index.js"; | ||
@@ -15,2 +15,5 @@ import { canonicalStringify } from "../../cache/index.js"; | ||
if (options === void 0) { options = Object.create(null); } | ||
return wrapHook("useSuspenseQuery", _useSuspenseQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options); | ||
} | ||
function _useSuspenseQuery(query, options) { | ||
var client = useApolloClient(options.client); | ||
@@ -17,0 +20,0 @@ var suspenseCache = getSuspenseCache(client); |
@@ -246,3 +246,3 @@ import { __assign } from "tslib"; | ||
// itself. By wrapping in `setTimeout`, this should provide a short | ||
// delay to allow the `QueryInfo.notify` handler to run before this the | ||
// delay to allow the `QueryInfo.notify` handler to run before this | ||
// promise is checked. | ||
@@ -249,0 +249,0 @@ // See https://github.com/apollographql/apollo-client/issues/11315 for |
@@ -6,2 +6,3 @@ export { getSuspenseCache } from "./cache/getSuspenseCache.js"; | ||
export type { SuspenseCacheOptions } from "./cache/SuspenseCache.js"; | ||
export type { HookWrappers } from "../hooks/internal/wrapHook.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,3 +7,3 @@ 'use strict'; | ||
var version = "0.0.0-pr-11638-20240304221457"; | ||
var version = "0.0.0-pr-11647-20240307055025"; | ||
@@ -10,0 +10,0 @@ function maybe(thunk) { |
@@ -1,2 +0,2 @@ | ||
export var version = "0.0.0-pr-11638-20240304221457"; | ||
export var version = "0.0.0-pr-11647-20240307055025"; | ||
//# sourceMappingURL=version.js.map |
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 too big to display
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 too big to display
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
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
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
6678307
822
58112
+ Addedrehackt@0.0.6(transitive)
- Removedrehackt@0.0.5(transitive)
Updatedrehackt@0.0.6