the-forest/client/node_modules/.cache/babel-loader/10280ef3663d05dd75922eeddbd389e6089edde50dfe255a2581953fe38891f0.json

1 line
9.6 KiB
JSON
Raw Normal View History

2024-09-17 20:35:18 -04:00
{"ast":null,"code":"\"use client\";\n\n// src/useBaseQuery.ts\nimport * as React from \"react\";\nimport { notifyManager } from \"@tanstack/query-core\";\nimport { useQueryErrorResetBoundary } from \"./QueryErrorResetBoundary.js\";\nimport { useQueryClient } from \"./QueryClientProvider.js\";\nimport { useIsRestoring } from \"./isRestoring.js\";\nimport { ensurePreventErrorBoundaryRetry, getHasError, useClearResetErrorBoundary } from \"./errorBoundaryUtils.js\";\nimport { ensureSuspenseTimers, fetchOptimistic, shouldSuspend } from \"./suspense.js\";\nfunction useBaseQuery(options, Observer, queryClient) {\n if (process.env.NODE_ENV !== \"production\") {\n if (typeof options !== \"object\" || Array.isArray(options)) {\n throw new Error('Bad argument type. Starting with v5, only the \"Object\" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');\n }\n }\n const client = useQueryClient(queryClient);\n const isRestoring = useIsRestoring();\n const errorResetBoundary = useQueryErrorResetBoundary();\n const defaultedOptions = client.defaultQueryOptions(options);\n client.getDefaultOptions().queries?._experimental_beforeQuery?.(defaultedOptions);\n defaultedOptions._optimisticResults = isRestoring ? \"isRestoring\" : \"optimistic\";\n ensureSuspenseTimers(defaultedOptions);\n ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);\n useClearResetErrorBoundary(errorResetBoundary);\n const [observer] = React.useState(() => new Observer(client, defaultedOptions));\n const result = observer.getOptimisticResult(defaultedOptions);\n React.useSyncExternalStore(React.useCallback(onStoreChange => {\n const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange));\n observer.updateResult();\n return unsubscribe;\n }, [observer, isRestoring]), () => observer.getCurrentResult(), () => observer.getCurrentResult());\n React.useEffect(() => {\n observer.setOptions(defaultedOptions, {\n listeners: false\n });\n }, [defaultedOptions, observer]);\n if (shouldSuspend(defaultedOptions, result)) {\n throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);\n }\n if (getHasError({\n result,\n errorResetBoundary,\n throwOnError: defaultedOptions.throwOnError,\n query: client.getQueryCache().get(defaultedOptions.queryHash)\n })) {\n throw result.error;\n }\n ;\n client.getDefaultOptions().queries?._experimental_afterQuery?.(defaultedOptions, result);\n return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;\n}\nexport { useBaseQuery };","map":{"version":3,"names":["React","notifyManager","useQueryErrorResetBoundary","useQueryClient","useIsRestoring","ensurePreventErrorBoundaryRetry","getHasError","useClearResetErrorBoundary","ensureSuspenseTimers","fetchOptimistic","shouldSuspend","useBaseQuery","options","Observer","queryClient","process","env","NODE_ENV","Array","isArray","Error","client","isRestoring","errorResetBoundary","defaultedOptions","defaultQueryOptions","getDefaultOptions","queries","_experimental_beforeQuery","_optimisticResults","observer","useState","result","getOptimisticResult","useSyncExternalStore","useCallback","onStoreChange","unsubscribe","subscribe","batchCalls","updateResult","getCurrentResult","useEffect","setOptions","listeners","throwOnError","query","getQueryCache","get","queryHash","error","_experimental_afterQuery","notifyOnChangeProps","trackResult"],"sources":["/Users/shoofle/Projects/the-forest/client/node_modules/@tanstack/react-query/src/useBaseQuery.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport { notifyManager } from '@tanstack/query-core'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport { useQueryClient } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport {\n ensure