UNPKG

51 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5var globals = require('../../utilities/globals');
6var React = require('rehackt');
7var context = require('../context');
8var tslib = require('tslib');
9var utilities = require('../../utilities');
10var equal = require('@wry/equality');
11var errors = require('../../errors');
12var core = require('../../core');
13var parser = require('../parser');
14var internal = require('../internal');
15var cache = require('../../cache');
16
17function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
18
19function _interopNamespace(e) {
20 if (e && e.__esModule) return e;
21 var n = Object.create(null);
22 if (e) {
23 for (var k in e) {
24 n[k] = e[k];
25 }
26 }
27 n["default"] = e;
28 return Object.freeze(n);
29}
30
31var React__namespace = /*#__PURE__*/_interopNamespace(React);
32var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
33
34function useApolloClient(override) {
35 var context$1 = React__namespace.useContext(context.getApolloContext());
36 var client = override || context$1.client;
37 globals.invariant(!!client, 50);
38 return client;
39}
40
41var didWarnUncachedGetSnapshot = false;
42var uSESKey = "useSyncExternalStore";
43var realHook$1 = React__namespace[uSESKey];
44var useSyncExternalStore = realHook$1 ||
45 (function (subscribe, getSnapshot, getServerSnapshot) {
46 var value = getSnapshot();
47 if (
48 globalThis.__DEV__ !== false &&
49 !didWarnUncachedGetSnapshot &&
50 value !== getSnapshot()) {
51 didWarnUncachedGetSnapshot = true;
52 globalThis.__DEV__ !== false && globals.invariant.error(60);
53 }
54 var _a = React__namespace.useState({
55 inst: { value: value, getSnapshot: getSnapshot },
56 }), inst = _a[0].inst, forceUpdate = _a[1];
57 if (utilities.canUseLayoutEffect) {
58 React__namespace.useLayoutEffect(function () {
59 Object.assign(inst, { value: value, getSnapshot: getSnapshot });
60 if (checkIfSnapshotChanged(inst)) {
61 forceUpdate({ inst: inst });
62 }
63 }, [subscribe, value, getSnapshot]);
64 }
65 else {
66 Object.assign(inst, { value: value, getSnapshot: getSnapshot });
67 }
68 React__namespace.useEffect(function () {
69 if (checkIfSnapshotChanged(inst)) {
70 forceUpdate({ inst: inst });
71 }
72 return subscribe(function handleStoreChange() {
73 if (checkIfSnapshotChanged(inst)) {
74 forceUpdate({ inst: inst });
75 }
76 });
77 }, [subscribe]);
78 return value;
79 });
80function checkIfSnapshotChanged(_a) {
81 var value = _a.value, getSnapshot = _a.getSnapshot;
82 try {
83 return value !== getSnapshot();
84 }
85 catch (_b) {
86 return true;
87 }
88}
89
90function useDeepMemo(memoFn, deps) {
91 var ref = React__namespace.useRef();
92 if (!ref.current || !equal.equal(ref.current.deps, deps)) {
93 ref.current = { value: memoFn(), deps: deps };
94 }
95 return ref.current.value;
96}
97
98var useIsomorphicLayoutEffect = utilities.canUseDOM ? React__namespace.useLayoutEffect : React__namespace.useEffect;
99
100var Ctx;
101function noop$1() { }
102function useRenderGuard() {
103 if (!Ctx) {
104 Ctx = React__namespace.createContext(null);
105 }
106 return React__namespace.useCallback(
107 function () {
108 var orig = console.error;
109 try {
110 console.error = noop$1;
111 React__namespace["useContext" ](Ctx);
112 return true;
113 }
114 catch (e) {
115 return false;
116 }
117 finally {
118 console.error = orig;
119 }
120 }, []);
121}
122
123var INIT = {};
124function useLazyRef(getInitialValue) {
125 var ref = React__namespace.useRef(INIT);
126 if (ref.current === INIT) {
127 ref.current = getInitialValue();
128 }
129 return ref;
130}
131
132var useKey = "use";
133var realHook = React__namespace[useKey];
134var __use = realHook ||
135 function __use(promise) {
136 var statefulPromise = utilities.wrapPromiseWithState(promise);
137 switch (statefulPromise.status) {
138 case "pending":
139 throw statefulPromise;
140 case "rejected":
141 throw statefulPromise.reason;
142 case "fulfilled":
143 return statefulPromise.value;
144 }
145 };
146
147var wrapperSymbol = Symbol.for("apollo.hook.wrappers");
148function wrapHook(hookName, useHook, clientOrObsQuery) {
149 var queryManager = clientOrObsQuery["queryManager"];
150 var wrappers = queryManager && queryManager[wrapperSymbol];
151 var wrapper = wrappers && wrappers[hookName];
152 return wrapper ? wrapper(useHook) : useHook;
153}
154
155var hasOwnProperty = Object.prototype.hasOwnProperty;
156function noop() { }
157var lastWatchOptions = Symbol();
158function useQuery(query, options) {
159 if (options === void 0) { options = Object.create(null); }
160 return wrapHook("useQuery", _useQuery, useApolloClient(options && options.client))(query, options);
161}
162function _useQuery(query, options) {
163 var _a = useQueryInternals(query, options), result = _a.result, obsQueryFields = _a.obsQueryFields;
164 return React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign({}, result), obsQueryFields)); }, [result, obsQueryFields]);
165}
166function useInternalState(client, query, options, renderPromises, makeWatchQueryOptions) {
167 function createInternalState(previous) {
168 var _a;
169 parser.verifyDocumentType(query, parser.DocumentType.Query);
170 var internalState = {
171 client: client,
172 query: query,
173 observable:
174 (renderPromises &&
175 renderPromises.getSSRObservable(makeWatchQueryOptions())) ||
176 client.watchQuery(getObsQueryOptions(void 0, client, options, makeWatchQueryOptions())),
177 resultData: {
178 previousData: (_a = previous === null || previous === void 0 ? void 0 : previous.resultData.current) === null || _a === void 0 ? void 0 : _a.data,
179 },
180 };
181 return internalState;
182 }
183 var _a = React__namespace.useState(createInternalState), internalState = _a[0], updateInternalState = _a[1];
184 function onQueryExecuted(watchQueryOptions) {
185 var _a;
186 var _b;
187 Object.assign(internalState.observable, (_a = {},
188 _a[lastWatchOptions] = watchQueryOptions,
189 _a));
190 var resultData = internalState.resultData;
191 updateInternalState(tslib.__assign(tslib.__assign({}, internalState), {
192 query: watchQueryOptions.query, resultData: Object.assign(resultData, {
193 previousData: ((_b = resultData.current) === null || _b === void 0 ? void 0 : _b.data) || resultData.previousData,
194 current: undefined,
195 }) }));
196 }
197 if (client !== internalState.client || query !== internalState.query) {
198 var newInternalState = createInternalState(internalState);
199 updateInternalState(newInternalState);
200 return [newInternalState, onQueryExecuted];
201 }
202 return [internalState, onQueryExecuted];
203}
204function useQueryInternals(query, options) {
205 var client = useApolloClient(options.client);
206 var renderPromises = React__namespace.useContext(context.getApolloContext()).renderPromises;
207 var isSyncSSR = !!renderPromises;
208 var disableNetworkFetches = client.disableNetworkFetches;
209 var ssrAllowed = options.ssr !== false && !options.skip;
210 var partialRefetch = options.partialRefetch;
211 var makeWatchQueryOptions = createMakeWatchQueryOptions(client, query, options, isSyncSSR);
212 var _a = useInternalState(client, query, options, renderPromises, makeWatchQueryOptions), _b = _a[0], observable = _b.observable, resultData = _b.resultData, onQueryExecuted = _a[1];
213 var watchQueryOptions = makeWatchQueryOptions(observable);
214 useResubscribeIfNecessary(resultData,
215 observable,
216 client, options, watchQueryOptions);
217 var obsQueryFields = React__namespace.useMemo(function () { return bindObservableMethods(observable); }, [observable]);
218 useRegisterSSRObservable(observable, renderPromises, ssrAllowed);
219 var result = useObservableSubscriptionResult(resultData, observable, client, options, watchQueryOptions, disableNetworkFetches, partialRefetch, isSyncSSR, {
220 onCompleted: options.onCompleted || noop,
221 onError: options.onError || noop,
222 });
223 return {
224 result: result,
225 obsQueryFields: obsQueryFields,
226 observable: observable,
227 resultData: resultData,
228 client: client,
229 onQueryExecuted: onQueryExecuted,
230 };
231}
232function useObservableSubscriptionResult(resultData, observable, client, options, watchQueryOptions, disableNetworkFetches, partialRefetch, isSyncSSR, callbacks) {
233 var callbackRef = React__namespace.useRef(callbacks);
234 React__namespace.useEffect(function () {
235 callbackRef.current = callbacks;
236 });
237 var resultOverride = ((isSyncSSR || disableNetworkFetches) &&
238 options.ssr === false &&
239 !options.skip) ?
240 ssrDisabledResult
241 : options.skip || watchQueryOptions.fetchPolicy === "standby" ?
242 skipStandbyResult
243 : void 0;
244 var previousData = resultData.previousData;
245 var currentResultOverride = React__namespace.useMemo(function () {
246 return resultOverride &&
247 toQueryResult(resultOverride, previousData, observable, client);
248 }, [client, observable, resultOverride, previousData]);
249 return useSyncExternalStore(React__namespace.useCallback(function (handleStoreChange) {
250 if (isSyncSSR) {
251 return function () { };
252 }
253 var onNext = function () {
254 var previousResult = resultData.current;
255 var result = observable.getCurrentResult();
256 if (previousResult &&
257 previousResult.loading === result.loading &&
258 previousResult.networkStatus === result.networkStatus &&
259 equal.equal(previousResult.data, result.data)) {
260 return;
261 }
262 setResult(result, resultData, observable, client, partialRefetch, handleStoreChange, callbackRef.current);
263 };
264 var onError = function (error) {
265 subscription.current.unsubscribe();
266 subscription.current = observable.resubscribeAfterError(onNext, onError);
267 if (!hasOwnProperty.call(error, "graphQLErrors")) {
268 throw error;
269 }
270 var previousResult = resultData.current;
271 if (!previousResult ||
272 (previousResult && previousResult.loading) ||
273 !equal.equal(error, previousResult.error)) {
274 setResult({
275 data: (previousResult && previousResult.data),
276 error: error,
277 loading: false,
278 networkStatus: core.NetworkStatus.error,
279 }, resultData, observable, client, partialRefetch, handleStoreChange, callbackRef.current);
280 }
281 };
282 var subscription = { current: observable.subscribe(onNext, onError) };
283 return function () {
284 setTimeout(function () { return subscription.current.unsubscribe(); });
285 };
286 }, [
287 disableNetworkFetches,
288 isSyncSSR,
289 observable,
290 resultData,
291 partialRefetch,
292 client,
293 ]), function () {
294 return currentResultOverride ||
295 getCurrentResult(resultData, observable, callbackRef.current, partialRefetch, client);
296 }, function () {
297 return currentResultOverride ||
298 getCurrentResult(resultData, observable, callbackRef.current, partialRefetch, client);
299 });
300}
301function useRegisterSSRObservable(observable, renderPromises, ssrAllowed) {
302 if (renderPromises && ssrAllowed) {
303 renderPromises.registerSSRObservable(observable);
304 if (observable.getCurrentResult().loading) {
305 renderPromises.addObservableQueryPromise(observable);
306 }
307 }
308}
309function useResubscribeIfNecessary(
310resultData,
311observable, client, options, watchQueryOptions) {
312 var _a;
313 if (observable[lastWatchOptions] &&
314 !equal.equal(observable[lastWatchOptions], watchQueryOptions)) {
315 observable.reobserve(getObsQueryOptions(observable, client, options, watchQueryOptions));
316 resultData.previousData =
317 ((_a = resultData.current) === null || _a === void 0 ? void 0 : _a.data) || resultData.previousData;
318 resultData.current = void 0;
319 }
320 observable[lastWatchOptions] = watchQueryOptions;
321}
322function createMakeWatchQueryOptions(client, query, _a, isSyncSSR) {
323 if (_a === void 0) { _a = {}; }
324 var skip = _a.skip; _a.ssr; _a.onCompleted; _a.onError; var defaultOptions = _a.defaultOptions,
325 otherOptions = tslib.__rest(_a, ["skip", "ssr", "onCompleted", "onError", "defaultOptions"]);
326 return function (observable) {
327 var watchQueryOptions = Object.assign(otherOptions, { query: query });
328 if (isSyncSSR &&
329 (watchQueryOptions.fetchPolicy === "network-only" ||
330 watchQueryOptions.fetchPolicy === "cache-and-network")) {
331 watchQueryOptions.fetchPolicy = "cache-first";
332 }
333 if (!watchQueryOptions.variables) {
334 watchQueryOptions.variables = {};
335 }
336 if (skip) {
337 watchQueryOptions.initialFetchPolicy =
338 watchQueryOptions.initialFetchPolicy ||
339 watchQueryOptions.fetchPolicy ||
340 getDefaultFetchPolicy(defaultOptions, client.defaultOptions);
341 watchQueryOptions.fetchPolicy = "standby";
342 }
343 else if (!watchQueryOptions.fetchPolicy) {
344 watchQueryOptions.fetchPolicy =
345 (observable === null || observable === void 0 ? void 0 : observable.options.initialFetchPolicy) ||
346 getDefaultFetchPolicy(defaultOptions, client.defaultOptions);
347 }
348 return watchQueryOptions;
349 };
350}
351function getObsQueryOptions(observable, client, queryHookOptions, watchQueryOptions) {
352 var toMerge = [];
353 var globalDefaults = client.defaultOptions.watchQuery;
354 if (globalDefaults)
355 toMerge.push(globalDefaults);
356 if (queryHookOptions.defaultOptions) {
357 toMerge.push(queryHookOptions.defaultOptions);
358 }
359 toMerge.push(utilities.compact(observable && observable.options, watchQueryOptions));
360 return toMerge.reduce(utilities.mergeOptions);
361}
362function setResult(nextResult, resultData, observable, client, partialRefetch, forceUpdate, callbacks) {
363 var previousResult = resultData.current;
364 if (previousResult && previousResult.data) {
365 resultData.previousData = previousResult.data;
366 }
367 if (!nextResult.error && utilities.isNonEmptyArray(nextResult.errors)) {
368 nextResult.error = new errors.ApolloError({ graphQLErrors: nextResult.errors });
369 }
370 resultData.current = toQueryResult(unsafeHandlePartialRefetch(nextResult, observable, partialRefetch), resultData.previousData, observable, client);
371 forceUpdate();
372 handleErrorOrCompleted(nextResult, previousResult === null || previousResult === void 0 ? void 0 : previousResult.networkStatus, callbacks);
373}
374function handleErrorOrCompleted(result, previousNetworkStatus, callbacks) {
375 if (!result.loading) {
376 var error_1 = toApolloError$1(result);
377 Promise.resolve()
378 .then(function () {
379 if (error_1) {
380 callbacks.onError(error_1);
381 }
382 else if (result.data &&
383 previousNetworkStatus !== result.networkStatus &&
384 result.networkStatus === core.NetworkStatus.ready) {
385 callbacks.onCompleted(result.data);
386 }
387 })
388 .catch(function (error) {
389 globalThis.__DEV__ !== false && globals.invariant.warn(error);
390 });
391 }
392}
393function getCurrentResult(resultData, observable, callbacks, partialRefetch, client) {
394 if (!resultData.current) {
395 setResult(observable.getCurrentResult(), resultData, observable, client, partialRefetch, function () { }, callbacks);
396 }
397 return resultData.current;
398}
399function getDefaultFetchPolicy(queryHookDefaultOptions, clientDefaultOptions) {
400 var _a;
401 return ((queryHookDefaultOptions === null || queryHookDefaultOptions === void 0 ? void 0 : queryHookDefaultOptions.fetchPolicy) ||
402 ((_a = clientDefaultOptions === null || clientDefaultOptions === void 0 ? void 0 : clientDefaultOptions.watchQuery) === null || _a === void 0 ? void 0 : _a.fetchPolicy) ||
403 "cache-first");
404}
405function toApolloError$1(result) {
406 return utilities.isNonEmptyArray(result.errors) ?
407 new errors.ApolloError({ graphQLErrors: result.errors })
408 : result.error;
409}
410function toQueryResult(result, previousData, observable, client) {
411 var data = result.data; result.partial; var resultWithoutPartial = tslib.__rest(result, ["data", "partial"]);
412 var queryResult = tslib.__assign(tslib.__assign({ data: data }, resultWithoutPartial), { client: client, observable: observable, variables: observable.variables, called: result !== ssrDisabledResult && result !== skipStandbyResult, previousData: previousData });
413 return queryResult;
414}
415function unsafeHandlePartialRefetch(result, observable, partialRefetch) {
416 if (result.partial &&
417 partialRefetch &&
418 !result.loading &&
419 (!result.data || Object.keys(result.data).length === 0) &&
420 observable.options.fetchPolicy !== "cache-only") {
421 observable.refetch();
422 return tslib.__assign(tslib.__assign({}, result), { loading: true, networkStatus: core.NetworkStatus.refetch });
423 }
424 return result;
425}
426var ssrDisabledResult = utilities.maybeDeepFreeze({
427 loading: true,
428 data: void 0,
429 error: void 0,
430 networkStatus: core.NetworkStatus.loading,
431});
432var skipStandbyResult = utilities.maybeDeepFreeze({
433 loading: false,
434 data: void 0,
435 error: void 0,
436 networkStatus: core.NetworkStatus.ready,
437});
438function bindObservableMethods(observable) {
439 return {
440 refetch: observable.refetch.bind(observable),
441 reobserve: observable.reobserve.bind(observable),
442 fetchMore: observable.fetchMore.bind(observable),
443 updateQuery: observable.updateQuery.bind(observable),
444 startPolling: observable.startPolling.bind(observable),
445 stopPolling: observable.stopPolling.bind(observable),
446 subscribeToMore: observable.subscribeToMore.bind(observable),
447 };
448}
449
450var EAGER_METHODS = [
451 "refetch",
452 "reobserve",
453 "fetchMore",
454 "updateQuery",
455 "startPolling",
456 "stopPolling",
457 "subscribeToMore",
458];
459function useLazyQuery(query, options) {
460 var _a;
461 var execOptionsRef = React__namespace.useRef();
462 var optionsRef = React__namespace.useRef();
463 var queryRef = React__namespace.useRef();
464 var merged = utilities.mergeOptions(options, execOptionsRef.current || {});
465 var document = (_a = merged === null || merged === void 0 ? void 0 : merged.query) !== null && _a !== void 0 ? _a : query;
466 optionsRef.current = options;
467 queryRef.current = document;
468 var queryHookOptions = tslib.__assign(tslib.__assign({}, merged), { skip: !execOptionsRef.current });
469 var _b = useQueryInternals(document, queryHookOptions), obsQueryFields = _b.obsQueryFields, useQueryResult = _b.result, client = _b.client, resultData = _b.resultData, observable = _b.observable, onQueryExecuted = _b.onQueryExecuted;
470 var initialFetchPolicy = observable.options.initialFetchPolicy ||
471 getDefaultFetchPolicy(queryHookOptions.defaultOptions, client.defaultOptions);
472 var forceUpdateState = React__namespace.useReducer(function (tick) { return tick + 1; }, 0)[1];
473 var eagerMethods = React__namespace.useMemo(function () {
474 var eagerMethods = {};
475 var _loop_1 = function (key) {
476 var method = obsQueryFields[key];
477 eagerMethods[key] = function () {
478 if (!execOptionsRef.current) {
479 execOptionsRef.current = Object.create(null);
480 forceUpdateState();
481 }
482 return method.apply(this, arguments);
483 };
484 };
485 for (var _i = 0, EAGER_METHODS_1 = EAGER_METHODS; _i < EAGER_METHODS_1.length; _i++) {
486 var key = EAGER_METHODS_1[_i];
487 _loop_1(key);
488 }
489 return eagerMethods;
490 }, [forceUpdateState, obsQueryFields]);
491 var called = !!execOptionsRef.current;
492 var result = React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign(tslib.__assign({}, useQueryResult), eagerMethods), { called: called })); }, [useQueryResult, eagerMethods, called]);
493 var execute = React__namespace.useCallback(function (executeOptions) {
494 execOptionsRef.current =
495 executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
496 fetchPolicy: initialFetchPolicy,
497 };
498 var options = utilities.mergeOptions(optionsRef.current, tslib.__assign({ query: queryRef.current }, execOptionsRef.current));
499 var promise = executeQuery(resultData, observable, client, document, tslib.__assign(tslib.__assign({}, options), { skip: false }), onQueryExecuted).then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
500 promise.catch(function () { });
501 return promise;
502 }, [
503 client,
504 document,
505 eagerMethods,
506 initialFetchPolicy,
507 observable,
508 resultData,
509 onQueryExecuted,
510 ]);
511 var executeRef = React__namespace.useRef(execute);
512 useIsomorphicLayoutEffect(function () {
513 executeRef.current = execute;
514 });
515 var stableExecute = React__namespace.useCallback(function () {
516 var args = [];
517 for (var _i = 0; _i < arguments.length; _i++) {
518 args[_i] = arguments[_i];
519 }
520 return executeRef.current.apply(executeRef, args);
521 }, []);
522 return [stableExecute, result];
523}
524function executeQuery(resultData, observable, client, currentQuery, options, onQueryExecuted) {
525 var query = options.query || currentQuery;
526 var watchQueryOptions = createMakeWatchQueryOptions(client, query, options, false)(observable);
527 var concast = observable.reobserveAsConcast(getObsQueryOptions(observable, client, options, watchQueryOptions));
528 onQueryExecuted(watchQueryOptions);
529 return new Promise(function (resolve) {
530 var result;
531 concast.subscribe({
532 next: function (value) {
533 result = value;
534 },
535 error: function () {
536 resolve(toQueryResult(observable.getCurrentResult(), resultData.previousData, observable, client));
537 },
538 complete: function () {
539 resolve(toQueryResult(result, resultData.previousData, observable, client));
540 },
541 });
542 });
543}
544
545function useMutation(mutation, options) {
546 var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
547 parser.verifyDocumentType(mutation, parser.DocumentType.Mutation);
548 var _a = React__namespace.useState({
549 called: false,
550 loading: false,
551 client: client,
552 }), result = _a[0], setResult = _a[1];
553 var ref = React__namespace.useRef({
554 result: result,
555 mutationId: 0,
556 isMounted: true,
557 client: client,
558 mutation: mutation,
559 options: options,
560 });
561 useIsomorphicLayoutEffect(function () {
562 Object.assign(ref.current, { client: client, options: options, mutation: mutation });
563 });
564 var execute = React__namespace.useCallback(function (executeOptions) {
565 if (executeOptions === void 0) { executeOptions = {}; }
566 var _a = ref.current, options = _a.options, mutation = _a.mutation;
567 var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
568 var client = executeOptions.client || ref.current.client;
569 if (!ref.current.result.loading &&
570 !baseOptions.ignoreResults &&
571 ref.current.isMounted) {
572 setResult((ref.current.result = {
573 loading: true,
574 error: void 0,
575 data: void 0,
576 called: true,
577 client: client,
578 }));
579 }
580 var mutationId = ++ref.current.mutationId;
581 var clientOptions = utilities.mergeOptions(baseOptions, executeOptions);
582 return client
583 .mutate(clientOptions)
584 .then(function (response) {
585 var _a, _b;
586 var data = response.data, errors$1 = response.errors;
587 var error = errors$1 && errors$1.length > 0 ?
588 new errors.ApolloError({ graphQLErrors: errors$1 })
589 : void 0;
590 var onError = executeOptions.onError || ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError);
591 if (error && onError) {
592 onError(error, clientOptions);
593 }
594 if (mutationId === ref.current.mutationId &&
595 !clientOptions.ignoreResults) {
596 var result_1 = {
597 called: true,
598 loading: false,
599 data: data,
600 error: error,
601 client: client,
602 };
603 if (ref.current.isMounted && !equal.equal(ref.current.result, result_1)) {
604 setResult((ref.current.result = result_1));
605 }
606 }
607 var onCompleted = executeOptions.onCompleted || ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onCompleted);
608 if (!error) {
609 onCompleted === null || onCompleted === void 0 ? void 0 : onCompleted(response.data, clientOptions);
610 }
611 return response;
612 })
613 .catch(function (error) {
614 var _a;
615 if (mutationId === ref.current.mutationId && ref.current.isMounted) {
616 var result_2 = {
617 loading: false,
618 error: error,
619 data: void 0,
620 called: true,
621 client: client,
622 };
623 if (!equal.equal(ref.current.result, result_2)) {
624 setResult((ref.current.result = result_2));
625 }
626 }
627 var onError = executeOptions.onError || ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError);
628 if (onError) {
629 onError(error, clientOptions);
630 return { data: void 0, errors: error };
631 }
632 throw error;
633 });
634 }, []);
635 var reset = React__namespace.useCallback(function () {
636 if (ref.current.isMounted) {
637 var result_3 = {
638 called: false,
639 loading: false,
640 client: ref.current.client,
641 };
642 Object.assign(ref.current, { mutationId: 0, result: result_3 });
643 setResult(result_3);
644 }
645 }, []);
646 React__namespace.useEffect(function () {
647 var current = ref.current;
648 current.isMounted = true;
649 return function () {
650 current.isMounted = false;
651 };
652 }, []);
653 return [execute, tslib.__assign({ reset: reset }, result)];
654}
655
656function useSubscription(subscription, options) {
657 if (options === void 0) { options = Object.create(null); }
658 var hasIssuedDeprecationWarningRef = React__namespace.useRef(false);
659 var client = useApolloClient(options.client);
660 parser.verifyDocumentType(subscription, parser.DocumentType.Subscription);
661 if (!hasIssuedDeprecationWarningRef.current) {
662 hasIssuedDeprecationWarningRef.current = true;
663 if (options.onSubscriptionData) {
664 globalThis.__DEV__ !== false && globals.invariant.warn(options.onData ? 53 : 54);
665 }
666 if (options.onSubscriptionComplete) {
667 globalThis.__DEV__ !== false && globals.invariant.warn(options.onComplete ? 55 : 56);
668 }
669 }
670 var skip = options.skip, fetchPolicy = options.fetchPolicy, errorPolicy = options.errorPolicy, shouldResubscribe = options.shouldResubscribe, context = options.context, extensions = options.extensions, ignoreResults = options.ignoreResults;
671 var variables = useDeepMemo(function () { return options.variables; }, [options.variables]);
672 var recreate = function () {
673 return createSubscription(client, subscription, variables, fetchPolicy, errorPolicy, context, extensions);
674 };
675 var _a = React__namespace.useState(options.skip ? null : recreate), observable = _a[0], setObservable = _a[1];
676 var recreateRef = React__namespace.useRef(recreate);
677 useIsomorphicLayoutEffect(function () {
678 recreateRef.current = recreate;
679 });
680 if (skip) {
681 if (observable) {
682 setObservable((observable = null));
683 }
684 }
685 else if (!observable ||
686 ((client !== observable.__.client ||
687 subscription !== observable.__.query ||
688 fetchPolicy !== observable.__.fetchPolicy ||
689 errorPolicy !== observable.__.errorPolicy ||
690 !equal.equal(variables, observable.__.variables)) &&
691 (typeof shouldResubscribe === "function" ?
692 !!shouldResubscribe(options)
693 : shouldResubscribe) !== false)) {
694 setObservable((observable = recreate()));
695 }
696 var optionsRef = React__namespace.useRef(options);
697 React__namespace.useEffect(function () {
698 optionsRef.current = options;
699 });
700 var fallbackLoading = !skip && !ignoreResults;
701 var fallbackResult = React__namespace.useMemo(function () { return ({
702 loading: fallbackLoading,
703 error: void 0,
704 data: void 0,
705 variables: variables,
706 }); }, [fallbackLoading, variables]);
707 var ignoreResultsRef = React__namespace.useRef(ignoreResults);
708 useIsomorphicLayoutEffect(function () {
709 ignoreResultsRef.current = ignoreResults;
710 });
711 var ret = useSyncExternalStore(React__namespace.useCallback(function (update) {
712 if (!observable) {
713 return function () { };
714 }
715 var subscriptionStopped = false;
716 var variables = observable.__.variables;
717 var client = observable.__.client;
718 var subscription = observable.subscribe({
719 next: function (fetchResult) {
720 var _a, _b;
721 if (subscriptionStopped) {
722 return;
723 }
724 var result = {
725 loading: false,
726 data: fetchResult.data,
727 error: toApolloError$1(fetchResult),
728 variables: variables,
729 };
730 observable.__.setResult(result);
731 if (!ignoreResultsRef.current)
732 update();
733 if (result.error) {
734 (_b = (_a = optionsRef.current).onError) === null || _b === void 0 ? void 0 : _b.call(_a, result.error);
735 }
736 else if (optionsRef.current.onData) {
737 optionsRef.current.onData({
738 client: client,
739 data: result,
740 });
741 }
742 else if (optionsRef.current.onSubscriptionData) {
743 optionsRef.current.onSubscriptionData({
744 client: client,
745 subscriptionData: result,
746 });
747 }
748 },
749 error: function (error) {
750 var _a, _b;
751 error =
752 error instanceof core.ApolloError ? error : (new core.ApolloError({ protocolErrors: [error] }));
753 if (!subscriptionStopped) {
754 observable.__.setResult({
755 loading: false,
756 data: void 0,
757 error: error,
758 variables: variables,
759 });
760 if (!ignoreResultsRef.current)
761 update();
762 (_b = (_a = optionsRef.current).onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
763 }
764 },
765 complete: function () {
766 if (!subscriptionStopped) {
767 if (optionsRef.current.onComplete) {
768 optionsRef.current.onComplete();
769 }
770 else if (optionsRef.current.onSubscriptionComplete) {
771 optionsRef.current.onSubscriptionComplete();
772 }
773 }
774 },
775 });
776 return function () {
777 subscriptionStopped = true;
778 setTimeout(function () {
779 subscription.unsubscribe();
780 });
781 };
782 }, [observable]), function () {
783 return observable && !skip && !ignoreResults ?
784 observable.__.result
785 : fallbackResult;
786 }, function () { return fallbackResult; });
787 return React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign({}, ret), { restart: function () {
788 globals.invariant(!optionsRef.current.skip, 57);
789 setObservable(recreateRef.current());
790 } })); }, [ret]);
791}
792function createSubscription(client, query, variables, fetchPolicy, errorPolicy, context, extensions) {
793 var options = {
794 query: query,
795 variables: variables,
796 fetchPolicy: fetchPolicy,
797 errorPolicy: errorPolicy,
798 context: context,
799 extensions: extensions,
800 };
801 var __ = tslib.__assign(tslib.__assign({}, options), { client: client, result: {
802 loading: true,
803 data: void 0,
804 error: void 0,
805 variables: variables,
806 }, setResult: function (result) {
807 __.result = result;
808 } });
809 var observable = null;
810 return Object.assign(new core.Observable(function (observer) {
811 if (!observable) {
812 observable = client.subscribe(options);
813 }
814 var sub = observable.subscribe(observer);
815 return function () { return sub.unsubscribe(); };
816 }), {
817 __: __,
818 });
819}
820
821function useReactiveVar(rv) {
822 return useSyncExternalStore(React__namespace.useCallback(function (update) {
823 return rv.onNextChange(function onNext() {
824 update();
825 rv.onNextChange(onNext);
826 });
827 }, [rv]), rv, rv);
828}
829
830function useFragment(options) {
831 return wrapHook("useFragment", _useFragment, useApolloClient(options.client))(options);
832}
833function _useFragment(options) {
834 var cache = useApolloClient(options.client).cache;
835 var diffOptions = useDeepMemo(function () {
836 var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
837 return tslib.__assign(tslib.__assign({}, rest), { returnPartialData: true, id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
838 }, [options]);
839 var resultRef = useLazyRef(function () {
840 return diffToResult(cache.diff(diffOptions));
841 });
842 var stableOptions = useDeepMemo(function () { return options; }, [options]);
843 React__namespace.useMemo(function () {
844 resultRef.current = diffToResult(cache.diff(diffOptions));
845 }, [diffOptions, cache]);
846 var getSnapshot = React__namespace.useCallback(function () { return resultRef.current; }, []);
847 return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
848 var lastTimeout = 0;
849 var subscription = cache.watchFragment(stableOptions).subscribe({
850 next: function (result) {
851 if (equal__default(result, resultRef.current))
852 return;
853 resultRef.current = result;
854 clearTimeout(lastTimeout);
855 lastTimeout = setTimeout(forceUpdate);
856 },
857 });
858 return function () {
859 subscription.unsubscribe();
860 clearTimeout(lastTimeout);
861 };
862 }, [cache, stableOptions]), getSnapshot, getSnapshot);
863}
864function diffToResult(diff) {
865 var result = {
866 data: diff.result,
867 complete: !!diff.complete,
868 };
869 if (diff.missing) {
870 result.missing = utilities.mergeDeepArray(diff.missing.map(function (error) { return error.missing; }));
871 }
872 return result;
873}
874
875var skipToken = Symbol.for("apollo.skipToken");
876
877function useSuspenseQuery(query, options) {
878 if (options === void 0) { options = Object.create(null); }
879 return wrapHook("useSuspenseQuery", _useSuspenseQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
880}
881function _useSuspenseQuery(query, options) {
882 var client = useApolloClient(options.client);
883 var suspenseCache = internal.getSuspenseCache(client);
884 var watchQueryOptions = useWatchQueryOptions({
885 client: client,
886 query: query,
887 options: options,
888 });
889 var fetchPolicy = watchQueryOptions.fetchPolicy, variables = watchQueryOptions.variables;
890 var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
891 var cacheKey = tslib.__spreadArray([
892 query,
893 cache.canonicalStringify(variables)
894 ], [].concat(queryKey), true);
895 var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
896 return client.watchQuery(watchQueryOptions);
897 });
898 var _b = React__namespace.useState([queryRef.key, queryRef.promise]), current = _b[0], setPromise = _b[1];
899 if (current[0] !== queryRef.key) {
900 current[0] = queryRef.key;
901 current[1] = queryRef.promise;
902 }
903 var promise = current[1];
904 if (queryRef.didChangeOptions(watchQueryOptions)) {
905 current[1] = promise = queryRef.applyOptions(watchQueryOptions);
906 }
907 React__namespace.useEffect(function () {
908 var dispose = queryRef.retain();
909 var removeListener = queryRef.listen(function (promise) {
910 setPromise([queryRef.key, promise]);
911 });
912 return function () {
913 removeListener();
914 dispose();
915 };
916 }, [queryRef]);
917 var skipResult = React__namespace.useMemo(function () {
918 var error = toApolloError(queryRef.result);
919 return {
920 loading: false,
921 data: queryRef.result.data,
922 networkStatus: error ? core.NetworkStatus.error : core.NetworkStatus.ready,
923 error: error,
924 };
925 }, [queryRef.result]);
926 var result = fetchPolicy === "standby" ? skipResult : __use(promise);
927 var fetchMore = React__namespace.useCallback(function (options) {
928 var promise = queryRef.fetchMore(options);
929 setPromise([queryRef.key, queryRef.promise]);
930 return promise;
931 }, [queryRef]);
932 var refetch = React__namespace.useCallback(function (variables) {
933 var promise = queryRef.refetch(variables);
934 setPromise([queryRef.key, queryRef.promise]);
935 return promise;
936 }, [queryRef]);
937 var subscribeToMore = queryRef.observable.subscribeToMore;
938 return React__namespace.useMemo(function () {
939 return {
940 client: client,
941 data: result.data,
942 error: toApolloError(result),
943 networkStatus: result.networkStatus,
944 fetchMore: fetchMore,
945 refetch: refetch,
946 subscribeToMore: subscribeToMore,
947 };
948 }, [client, fetchMore, refetch, result, subscribeToMore]);
949}
950function validateOptions(options) {
951 var query = options.query, fetchPolicy = options.fetchPolicy, returnPartialData = options.returnPartialData;
952 parser.verifyDocumentType(query, parser.DocumentType.Query);
953 validateFetchPolicy(fetchPolicy);
954 validatePartialDataReturn(fetchPolicy, returnPartialData);
955}
956function validateFetchPolicy(fetchPolicy) {
957 if (fetchPolicy === void 0) { fetchPolicy = "cache-first"; }
958 var supportedFetchPolicies = [
959 "cache-first",
960 "network-only",
961 "no-cache",
962 "cache-and-network",
963 ];
964 globals.invariant(supportedFetchPolicies.includes(fetchPolicy), 58, fetchPolicy);
965}
966function validatePartialDataReturn(fetchPolicy, returnPartialData) {
967 if (fetchPolicy === "no-cache" && returnPartialData) {
968 globalThis.__DEV__ !== false && globals.invariant.warn(59);
969 }
970}
971function toApolloError(result) {
972 return utilities.isNonEmptyArray(result.errors) ?
973 new core.ApolloError({ graphQLErrors: result.errors })
974 : result.error;
975}
976function useWatchQueryOptions(_a) {
977 var client = _a.client, query = _a.query, options = _a.options;
978 return useDeepMemo(function () {
979 var _a;
980 if (options === skipToken) {
981 return { query: query, fetchPolicy: "standby" };
982 }
983 var fetchPolicy = options.fetchPolicy ||
984 ((_a = client.defaultOptions.watchQuery) === null || _a === void 0 ? void 0 : _a.fetchPolicy) ||
985 "cache-first";
986 var watchQueryOptions = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: fetchPolicy, query: query, notifyOnNetworkStatusChange: false, nextFetchPolicy: void 0 });
987 if (globalThis.__DEV__ !== false) {
988 validateOptions(watchQueryOptions);
989 }
990 if (options.skip) {
991 watchQueryOptions.fetchPolicy = "standby";
992 }
993 return watchQueryOptions;
994 }, [client, options, query]);
995}
996
997function useBackgroundQuery(query, options) {
998 if (options === void 0) { options = Object.create(null); }
999 return wrapHook("useBackgroundQuery", _useBackgroundQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
1000}
1001function _useBackgroundQuery(query, options) {
1002 var client = useApolloClient(options.client);
1003 var suspenseCache = internal.getSuspenseCache(client);
1004 var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
1005 var fetchPolicy = watchQueryOptions.fetchPolicy, variables = watchQueryOptions.variables;
1006 var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
1007 var didFetchResult = React__namespace.useRef(fetchPolicy !== "standby");
1008 didFetchResult.current || (didFetchResult.current = fetchPolicy !== "standby");
1009 var cacheKey = tslib.__spreadArray([
1010 query,
1011 cache.canonicalStringify(variables)
1012 ], [].concat(queryKey), true);
1013 var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
1014 return client.watchQuery(watchQueryOptions);
1015 });
1016 var _b = React__namespace.useState(internal.wrapQueryRef(queryRef)), wrappedQueryRef = _b[0], setWrappedQueryRef = _b[1];
1017 if (internal.unwrapQueryRef(wrappedQueryRef) !== queryRef) {
1018 setWrappedQueryRef(internal.wrapQueryRef(queryRef));
1019 }
1020 if (queryRef.didChangeOptions(watchQueryOptions)) {
1021 var promise = queryRef.applyOptions(watchQueryOptions);
1022 internal.updateWrappedQueryRef(wrappedQueryRef, promise);
1023 }
1024 React__namespace.useEffect(function () {
1025 var id = setTimeout(function () {
1026 if (queryRef.disposed) {
1027 suspenseCache.add(cacheKey, queryRef);
1028 }
1029 });
1030 return function () { return clearTimeout(id); };
1031 });
1032 var fetchMore = React__namespace.useCallback(function (options) {
1033 var promise = queryRef.fetchMore(options);
1034 setWrappedQueryRef(internal.wrapQueryRef(queryRef));
1035 return promise;
1036 }, [queryRef]);
1037 var refetch = React__namespace.useCallback(function (variables) {
1038 var promise = queryRef.refetch(variables);
1039 setWrappedQueryRef(internal.wrapQueryRef(queryRef));
1040 return promise;
1041 }, [queryRef]);
1042 React__namespace.useEffect(function () { return queryRef.softRetain(); }, [queryRef]);
1043 return [
1044 didFetchResult.current ? wrappedQueryRef : void 0,
1045 {
1046 fetchMore: fetchMore,
1047 refetch: refetch,
1048 subscribeToMore: queryRef.observable.subscribeToMore,
1049 },
1050 ];
1051}
1052
1053function useLoadableQuery(query, options) {
1054 if (options === void 0) { options = Object.create(null); }
1055 var client = useApolloClient(options.client);
1056 var suspenseCache = internal.getSuspenseCache(client);
1057 var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
1058 var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
1059 var _b = React__namespace.useState(null), queryRef = _b[0], setQueryRef = _b[1];
1060 internal.assertWrappedQueryRef(queryRef);
1061 var internalQueryRef = queryRef && internal.unwrapQueryRef(queryRef);
1062 if (queryRef && (internalQueryRef === null || internalQueryRef === void 0 ? void 0 : internalQueryRef.didChangeOptions(watchQueryOptions))) {
1063 var promise = internalQueryRef.applyOptions(watchQueryOptions);
1064 internal.updateWrappedQueryRef(queryRef, promise);
1065 }
1066 var calledDuringRender = useRenderGuard();
1067 var fetchMore = React__namespace.useCallback(function (options) {
1068 if (!internalQueryRef) {
1069 throw new Error("The query has not been loaded. Please load the query.");
1070 }
1071 var promise = internalQueryRef.fetchMore(options);
1072 setQueryRef(internal.wrapQueryRef(internalQueryRef));
1073 return promise;
1074 }, [internalQueryRef]);
1075 var refetch = React__namespace.useCallback(function (options) {
1076 if (!internalQueryRef) {
1077 throw new Error("The query has not been loaded. Please load the query.");
1078 }
1079 var promise = internalQueryRef.refetch(options);
1080 setQueryRef(internal.wrapQueryRef(internalQueryRef));
1081 return promise;
1082 }, [internalQueryRef]);
1083 var loadQuery = React__namespace.useCallback(function () {
1084 var args = [];
1085 for (var _i = 0; _i < arguments.length; _i++) {
1086 args[_i] = arguments[_i];
1087 }
1088 globals.invariant(!calledDuringRender(), 51);
1089 var variables = args[0];
1090 var cacheKey = tslib.__spreadArray([
1091 query,
1092 cache.canonicalStringify(variables)
1093 ], [].concat(queryKey), true);
1094 var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
1095 return client.watchQuery(tslib.__assign(tslib.__assign({}, watchQueryOptions), { variables: variables }));
1096 });
1097 setQueryRef(internal.wrapQueryRef(queryRef));
1098 }, [
1099 query,
1100 queryKey,
1101 suspenseCache,
1102 watchQueryOptions,
1103 calledDuringRender,
1104 client,
1105 ]);
1106 var subscribeToMore = React__namespace.useCallback(function (options) {
1107 globals.invariant(internalQueryRef, 52);
1108 return internalQueryRef.observable.subscribeToMore(options);
1109 }, [internalQueryRef]);
1110 var reset = React__namespace.useCallback(function () {
1111 setQueryRef(null);
1112 }, []);
1113 return [loadQuery, queryRef, { fetchMore: fetchMore, refetch: refetch, reset: reset, subscribeToMore: subscribeToMore }];
1114}
1115
1116function useQueryRefHandlers(queryRef) {
1117 var unwrapped = internal.unwrapQueryRef(queryRef);
1118 return wrapHook("useQueryRefHandlers", _useQueryRefHandlers, unwrapped ?
1119 unwrapped["observable"]
1120 : useApolloClient())(queryRef);
1121}
1122function _useQueryRefHandlers(queryRef) {
1123 internal.assertWrappedQueryRef(queryRef);
1124 var _a = React__namespace.useState(queryRef), previousQueryRef = _a[0], setPreviousQueryRef = _a[1];
1125 var _b = React__namespace.useState(queryRef), wrappedQueryRef = _b[0], setWrappedQueryRef = _b[1];
1126 var internalQueryRef = internal.unwrapQueryRef(queryRef);
1127 if (previousQueryRef !== queryRef) {
1128 setPreviousQueryRef(queryRef);
1129 setWrappedQueryRef(queryRef);
1130 }
1131 else {
1132 internal.updateWrappedQueryRef(queryRef, internal.getWrappedPromise(wrappedQueryRef));
1133 }
1134 var refetch = React__namespace.useCallback(function (variables) {
1135 var promise = internalQueryRef.refetch(variables);
1136 setWrappedQueryRef(internal.wrapQueryRef(internalQueryRef));
1137 return promise;
1138 }, [internalQueryRef]);
1139 var fetchMore = React__namespace.useCallback(function (options) {
1140 var promise = internalQueryRef.fetchMore(options);
1141 setWrappedQueryRef(internal.wrapQueryRef(internalQueryRef));
1142 return promise;
1143 }, [internalQueryRef]);
1144 return {
1145 refetch: refetch,
1146 fetchMore: fetchMore,
1147 subscribeToMore: internalQueryRef.observable.subscribeToMore,
1148 };
1149}
1150
1151function useReadQuery(queryRef) {
1152 var unwrapped = internal.unwrapQueryRef(queryRef);
1153 return wrapHook("useReadQuery", _useReadQuery, unwrapped ?
1154 unwrapped["observable"]
1155 : useApolloClient())(queryRef);
1156}
1157function _useReadQuery(queryRef) {
1158 internal.assertWrappedQueryRef(queryRef);
1159 var internalQueryRef = React__namespace.useMemo(function () { return internal.unwrapQueryRef(queryRef); }, [queryRef]);
1160 var getPromise = React__namespace.useCallback(function () { return internal.getWrappedPromise(queryRef); }, [queryRef]);
1161 if (internalQueryRef.disposed) {
1162 internalQueryRef.reinitialize();
1163 internal.updateWrappedQueryRef(queryRef, internalQueryRef.promise);
1164 }
1165 React__namespace.useEffect(function () { return internalQueryRef.retain(); }, [internalQueryRef]);
1166 var promise = useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
1167 return internalQueryRef.listen(function (promise) {
1168 internal.updateWrappedQueryRef(queryRef, promise);
1169 forceUpdate();
1170 });
1171 }, [internalQueryRef, queryRef]), getPromise, getPromise);
1172 var result = __use(promise);
1173 return React__namespace.useMemo(function () {
1174 return {
1175 data: result.data,
1176 networkStatus: result.networkStatus,
1177 error: toApolloError(result),
1178 };
1179 }, [result]);
1180}
1181
1182exports.skipToken = skipToken;
1183exports.useApolloClient = useApolloClient;
1184exports.useBackgroundQuery = useBackgroundQuery;
1185exports.useFragment = useFragment;
1186exports.useLazyQuery = useLazyQuery;
1187exports.useLoadableQuery = useLoadableQuery;
1188exports.useMutation = useMutation;
1189exports.useQuery = useQuery;
1190exports.useQueryRefHandlers = useQueryRefHandlers;
1191exports.useReactiveVar = useReactiveVar;
1192exports.useReadQuery = useReadQuery;
1193exports.useSubscription = useSubscription;
1194exports.useSuspenseQuery = useSuspenseQuery;
1195//# sourceMappingURL=hooks.cjs.map