@tanstack/query-core 5.90.20 → 5.91.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/_tsup-dts-rollup.d.cts +2229 -0
- package/build/legacy/_tsup-dts-rollup.d.ts +2229 -0
- package/build/legacy/environmentManager.cjs +48 -0
- package/build/legacy/environmentManager.cjs.map +1 -0
- package/build/legacy/environmentManager.d.cts +2 -0
- package/build/legacy/environmentManager.d.ts +2 -0
- package/build/legacy/environmentManager.js +25 -0
- package/build/legacy/environmentManager.js.map +1 -0
- package/build/legacy/focusManager.cjs +1 -2
- package/build/legacy/focusManager.cjs.map +1 -1
- package/build/legacy/focusManager.d.cts +2 -17
- package/build/legacy/focusManager.d.ts +2 -17
- package/build/legacy/focusManager.js +1 -2
- package/build/legacy/focusManager.js.map +1 -1
- package/build/legacy/hydration.d.cts +7 -3
- package/build/legacy/hydration.d.ts +7 -3
- package/build/legacy/index.cjs +3 -0
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/index.d.cts +142 -10
- package/build/legacy/index.d.ts +142 -10
- package/build/legacy/index.js +2 -0
- package/build/legacy/index.js.map +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +3 -15
- package/build/legacy/infiniteQueryBehavior.d.ts +3 -15
- package/build/legacy/infiniteQueryObserver.d.cts +1 -20
- package/build/legacy/infiniteQueryObserver.d.ts +1 -20
- package/build/legacy/mutation.d.cts +4 -3
- package/build/legacy/mutation.d.ts +4 -3
- package/build/legacy/mutationCache.d.cts +2 -3
- package/build/legacy/mutationCache.d.ts +2 -3
- package/build/legacy/mutationObserver.d.cts +1 -3
- package/build/legacy/mutationObserver.d.ts +1 -3
- package/build/legacy/notifyManager.d.cts +3 -46
- package/build/legacy/notifyManager.d.ts +3 -46
- package/build/legacy/onlineManager.cjs +1 -2
- package/build/legacy/onlineManager.cjs.map +1 -1
- package/build/legacy/onlineManager.d.cts +2 -16
- package/build/legacy/onlineManager.d.ts +2 -16
- package/build/legacy/onlineManager.js +1 -2
- package/build/legacy/onlineManager.js.map +1 -1
- package/build/legacy/queriesObserver.d.cts +2 -27
- package/build/legacy/queriesObserver.d.ts +2 -27
- package/build/legacy/query.cjs +13 -4
- package/build/legacy/query.cjs.map +1 -1
- package/build/legacy/query.d.cts +10 -3
- package/build/legacy/query.d.ts +10 -3
- package/build/legacy/query.js +13 -4
- package/build/legacy/query.js.map +1 -1
- package/build/legacy/queryCache.d.cts +3 -3
- package/build/legacy/queryCache.d.ts +3 -3
- package/build/legacy/queryClient.d.cts +1 -3
- package/build/legacy/queryClient.d.ts +1 -3
- package/build/legacy/queryObserver.cjs +4 -3
- package/build/legacy/queryObserver.cjs.map +1 -1
- package/build/legacy/queryObserver.d.cts +1 -3
- package/build/legacy/queryObserver.d.ts +1 -3
- package/build/legacy/queryObserver.js +4 -4
- package/build/legacy/queryObserver.js.map +1 -1
- package/build/legacy/removable.cjs +2 -1
- package/build/legacy/removable.cjs.map +1 -1
- package/build/legacy/removable.d.cts +1 -11
- package/build/legacy/removable.d.ts +1 -11
- package/build/legacy/removable.js +3 -2
- package/build/legacy/removable.js.map +1 -1
- package/build/legacy/retryer.cjs +2 -1
- package/build/legacy/retryer.cjs.map +1 -1
- package/build/legacy/retryer.d.cts +7 -3
- package/build/legacy/retryer.d.ts +7 -3
- package/build/legacy/retryer.js +3 -2
- package/build/legacy/retryer.js.map +1 -1
- package/build/legacy/streamedQuery.cjs +2 -4
- package/build/legacy/streamedQuery.cjs.map +1 -1
- package/build/legacy/streamedQuery.d.cts +1 -34
- package/build/legacy/streamedQuery.d.ts +1 -34
- package/build/legacy/streamedQuery.js +2 -4
- package/build/legacy/streamedQuery.js.map +1 -1
- package/build/legacy/subscribable.d.cts +1 -10
- package/build/legacy/subscribable.d.ts +1 -10
- package/build/legacy/thenable.cjs.map +1 -1
- package/build/legacy/thenable.d.cts +6 -47
- package/build/legacy/thenable.d.ts +6 -47
- package/build/legacy/thenable.js.map +1 -1
- package/build/legacy/timeoutManager.d.cts +7 -58
- package/build/legacy/timeoutManager.d.ts +7 -58
- package/build/legacy/types.d.cts +95 -3
- package/build/legacy/types.d.ts +95 -3
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +30 -3
- package/build/legacy/utils.d.ts +30 -3
- package/build/legacy/utils.js.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.cts +2229 -0
- package/build/modern/_tsup-dts-rollup.d.ts +2229 -0
- package/build/modern/environmentManager.cjs +48 -0
- package/build/modern/environmentManager.cjs.map +1 -0
- package/build/modern/environmentManager.d.cts +2 -0
- package/build/modern/environmentManager.d.ts +2 -0
- package/build/modern/environmentManager.js +23 -0
- package/build/modern/environmentManager.js.map +1 -0
- package/build/modern/focusManager.cjs +1 -2
- package/build/modern/focusManager.cjs.map +1 -1
- package/build/modern/focusManager.d.cts +2 -17
- package/build/modern/focusManager.d.ts +2 -17
- package/build/modern/focusManager.js +1 -2
- package/build/modern/focusManager.js.map +1 -1
- package/build/modern/hydration.d.cts +7 -3
- package/build/modern/hydration.d.ts +7 -3
- package/build/modern/index.cjs +3 -0
- package/build/modern/index.cjs.map +1 -1
- package/build/modern/index.d.cts +142 -10
- package/build/modern/index.d.ts +142 -10
- package/build/modern/index.js +2 -0
- package/build/modern/index.js.map +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +3 -15
- package/build/modern/infiniteQueryBehavior.d.ts +3 -15
- package/build/modern/infiniteQueryObserver.d.cts +1 -20
- package/build/modern/infiniteQueryObserver.d.ts +1 -20
- package/build/modern/mutation.d.cts +4 -3
- package/build/modern/mutation.d.ts +4 -3
- package/build/modern/mutationCache.d.cts +2 -3
- package/build/modern/mutationCache.d.ts +2 -3
- package/build/modern/mutationObserver.d.cts +1 -3
- package/build/modern/mutationObserver.d.ts +1 -3
- package/build/modern/notifyManager.d.cts +3 -46
- package/build/modern/notifyManager.d.ts +3 -46
- package/build/modern/onlineManager.cjs +1 -2
- package/build/modern/onlineManager.cjs.map +1 -1
- package/build/modern/onlineManager.d.cts +2 -16
- package/build/modern/onlineManager.d.ts +2 -16
- package/build/modern/onlineManager.js +1 -2
- package/build/modern/onlineManager.js.map +1 -1
- package/build/modern/queriesObserver.d.cts +2 -27
- package/build/modern/queriesObserver.d.ts +2 -27
- package/build/modern/query.cjs +12 -3
- package/build/modern/query.cjs.map +1 -1
- package/build/modern/query.d.cts +10 -3
- package/build/modern/query.d.ts +10 -3
- package/build/modern/query.js +12 -3
- package/build/modern/query.js.map +1 -1
- package/build/modern/queryCache.d.cts +3 -3
- package/build/modern/queryCache.d.ts +3 -3
- package/build/modern/queryClient.d.cts +1 -3
- package/build/modern/queryClient.d.ts +1 -3
- package/build/modern/queryObserver.cjs +4 -3
- package/build/modern/queryObserver.cjs.map +1 -1
- package/build/modern/queryObserver.d.cts +1 -3
- package/build/modern/queryObserver.d.ts +1 -3
- package/build/modern/queryObserver.js +4 -4
- package/build/modern/queryObserver.js.map +1 -1
- package/build/modern/removable.cjs +2 -1
- package/build/modern/removable.cjs.map +1 -1
- package/build/modern/removable.d.cts +1 -11
- package/build/modern/removable.d.ts +1 -11
- package/build/modern/removable.js +3 -2
- package/build/modern/removable.js.map +1 -1
- package/build/modern/retryer.cjs +2 -1
- package/build/modern/retryer.cjs.map +1 -1
- package/build/modern/retryer.d.cts +7 -3
- package/build/modern/retryer.d.ts +7 -3
- package/build/modern/retryer.js +3 -2
- package/build/modern/retryer.js.map +1 -1
- package/build/modern/streamedQuery.cjs +2 -4
- package/build/modern/streamedQuery.cjs.map +1 -1
- package/build/modern/streamedQuery.d.cts +1 -34
- package/build/modern/streamedQuery.d.ts +1 -34
- package/build/modern/streamedQuery.js +2 -4
- package/build/modern/streamedQuery.js.map +1 -1
- package/build/modern/subscribable.d.cts +1 -10
- package/build/modern/subscribable.d.ts +1 -10
- package/build/modern/thenable.cjs.map +1 -1
- package/build/modern/thenable.d.cts +6 -47
- package/build/modern/thenable.d.ts +6 -47
- package/build/modern/thenable.js.map +1 -1
- package/build/modern/timeoutManager.d.cts +7 -58
- package/build/modern/timeoutManager.d.ts +7 -58
- package/build/modern/types.d.cts +95 -3
- package/build/modern/types.d.ts +95 -3
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +30 -3
- package/build/modern/utils.d.ts +30 -3
- package/build/modern/utils.js.map +1 -1
- package/package.json +4 -5
- package/src/environmentManager.ts +25 -0
- package/src/focusManager.ts +1 -2
- package/src/index.ts +1 -0
- package/src/onlineManager.ts +1 -2
- package/src/query.ts +17 -6
- package/src/queryObserver.ts +8 -4
- package/src/removable.ts +3 -2
- package/src/retryer.ts +3 -2
- package/src/streamedQuery.ts +2 -4
- package/src/thenable.ts +1 -1
- package/src/utils.ts +3 -0
- package/build/legacy/hydration-BlEVG2Lp.d.ts +0 -1384
- package/build/legacy/hydration-uphG6M-i.d.cts +0 -1384
- package/build/modern/hydration-BlEVG2Lp.d.ts +0 -1384
- package/build/modern/hydration-uphG6M-i.d.cts +0 -1384
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/thenable.ts"],"sourcesContent":["/**\n * Thenable types which matches React's types for promises\n *\n * React seemingly uses `.status`, `.value` and `.reason` properties on a promises to optimistically unwrap data from promises\n *\n * @see https://github.com/facebook/react/blob/main/packages/shared/ReactTypes.js#L112-L138\n * @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227\n */\n\nimport { noop } from './utils'\n\ninterface Fulfilled<T> {\n status: 'fulfilled'\n value: T\n}\ninterface Rejected {\n status: 'rejected'\n reason: unknown\n}\ninterface Pending<T> {\n status: 'pending'\n\n /**\n * Resolve the promise with a value.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n resolve: (value: T) => void\n /**\n * Reject the promise with a reason.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n reject: (reason: unknown) => void\n}\n\nexport type FulfilledThenable<T> = Promise<T> & Fulfilled<T>\nexport type RejectedThenable<T> = Promise<T> & Rejected\nexport type PendingThenable<T> = Promise<T> & Pending<T>\n\nexport type Thenable<T> =\n | FulfilledThenable<T>\n | RejectedThenable<T>\n | PendingThenable<T>\n\nexport function pendingThenable<T>(): PendingThenable<T> {\n let resolve: Pending<T>['resolve']\n let reject: Pending<T>['reject']\n // this could use `Promise.withResolvers()` in the future\n const thenable = new Promise((_resolve, _reject) => {\n resolve = _resolve\n reject = _reject\n }) as PendingThenable<T>\n\n thenable.status = 'pending'\n thenable.catch(() => {\n // prevent unhandled rejection errors\n })\n\n function finalize(data: Fulfilled<T> | Rejected) {\n Object.assign(thenable, data)\n\n // clear pending props
|
|
1
|
+
{"version":3,"sources":["../../src/thenable.ts"],"sourcesContent":["/**\n * Thenable types which matches React's types for promises\n *\n * React seemingly uses `.status`, `.value` and `.reason` properties on a promises to optimistically unwrap data from promises\n *\n * @see https://github.com/facebook/react/blob/main/packages/shared/ReactTypes.js#L112-L138\n * @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227\n */\n\nimport { noop } from './utils'\n\ninterface Fulfilled<T> {\n status: 'fulfilled'\n value: T\n}\ninterface Rejected {\n status: 'rejected'\n reason: unknown\n}\ninterface Pending<T> {\n status: 'pending'\n\n /**\n * Resolve the promise with a value.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n resolve: (value: T) => void\n /**\n * Reject the promise with a reason.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n reject: (reason: unknown) => void\n}\n\nexport type FulfilledThenable<T> = Promise<T> & Fulfilled<T>\nexport type RejectedThenable<T> = Promise<T> & Rejected\nexport type PendingThenable<T> = Promise<T> & Pending<T>\n\nexport type Thenable<T> =\n | FulfilledThenable<T>\n | RejectedThenable<T>\n | PendingThenable<T>\n\nexport function pendingThenable<T>(): PendingThenable<T> {\n let resolve: Pending<T>['resolve']\n let reject: Pending<T>['reject']\n // this could use `Promise.withResolvers()` in the future\n const thenable = new Promise((_resolve, _reject) => {\n resolve = _resolve\n reject = _reject\n }) as PendingThenable<T>\n\n thenable.status = 'pending'\n thenable.catch(() => {\n // prevent unhandled rejection errors\n })\n\n function finalize(data: Fulfilled<T> | Rejected) {\n Object.assign(thenable, data)\n\n // clear pending props to avoid calling them twice\n delete (thenable as Partial<PendingThenable<T>>).resolve\n delete (thenable as Partial<PendingThenable<T>>).reject\n }\n\n thenable.resolve = (value) => {\n finalize({\n status: 'fulfilled',\n value,\n })\n\n resolve(value)\n }\n thenable.reject = (reason) => {\n finalize({\n status: 'rejected',\n reason,\n })\n\n reject(reason)\n }\n\n return thenable\n}\n\n/**\n * This function takes a Promise-like input and detects whether the data\n * is synchronously available or not.\n *\n * It does not inspect .status, .value or .reason properties of the promise,\n * as those are not always available, and the .status of React's promises\n * should not be considered part of the public API.\n */\nexport function tryResolveSync(promise: Promise<unknown> | Thenable<unknown>) {\n let data: unknown\n\n promise\n .then((result) => {\n data = result\n return result\n }, noop)\n // .catch can be unavailable on certain kinds of thenable's\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n ?.catch(noop)\n\n if (data !== undefined) {\n return { data }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,mBAAqB;AAkCd,SAAS,kBAAyC;AACvD,MAAI;AACJ,MAAI;AAEJ,QAAM,WAAW,IAAI,QAAQ,CAAC,UAAU,YAAY;AAClD,cAAU;AACV,aAAS;AAAA,EACX,CAAC;AAED,WAAS,SAAS;AAClB,WAAS,MAAM,MAAM;AAAA,EAErB,CAAC;AAED,WAAS,SAAS,MAA+B;AAC/C,WAAO,OAAO,UAAU,IAAI;AAG5B,WAAQ,SAAyC;AACjD,WAAQ,SAAyC;AAAA,EACnD;AAEA,WAAS,UAAU,CAAC,UAAU;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,YAAQ,KAAK;AAAA,EACf;AACA,WAAS,SAAS,CAAC,WAAW;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AAAA,EACf;AAEA,SAAO;AACT;AAUO,SAAS,eAAe,SAA+C;AAC5E,MAAI;AAEJ,UACG,KAAK,CAAC,WAAW;AAChB,WAAO;AACP,WAAO;AAAA,EACT,GAAG,iBAAI,GAGL,MAAM,iBAAI;AAEd,MAAI,SAAS,QAAW;AACtB,WAAO,EAAE,KAAK;AAAA,EAChB;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,47 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227
|
|
8
|
-
*/
|
|
9
|
-
interface Fulfilled<T> {
|
|
10
|
-
status: 'fulfilled';
|
|
11
|
-
value: T;
|
|
12
|
-
}
|
|
13
|
-
interface Rejected {
|
|
14
|
-
status: 'rejected';
|
|
15
|
-
reason: unknown;
|
|
16
|
-
}
|
|
17
|
-
interface Pending<T> {
|
|
18
|
-
status: 'pending';
|
|
19
|
-
/**
|
|
20
|
-
* Resolve the promise with a value.
|
|
21
|
-
* Will remove the `resolve` and `reject` properties from the promise.
|
|
22
|
-
*/
|
|
23
|
-
resolve: (value: T) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Reject the promise with a reason.
|
|
26
|
-
* Will remove the `resolve` and `reject` properties from the promise.
|
|
27
|
-
*/
|
|
28
|
-
reject: (reason: unknown) => void;
|
|
29
|
-
}
|
|
30
|
-
type FulfilledThenable<T> = Promise<T> & Fulfilled<T>;
|
|
31
|
-
type RejectedThenable<T> = Promise<T> & Rejected;
|
|
32
|
-
type PendingThenable<T> = Promise<T> & Pending<T>;
|
|
33
|
-
type Thenable<T> = FulfilledThenable<T> | RejectedThenable<T> | PendingThenable<T>;
|
|
34
|
-
declare function pendingThenable<T>(): PendingThenable<T>;
|
|
35
|
-
/**
|
|
36
|
-
* This function takes a Promise-like input and detects whether the data
|
|
37
|
-
* is synchronously available or not.
|
|
38
|
-
*
|
|
39
|
-
* It does not inspect .status, .value or .reason properties of the promise,
|
|
40
|
-
* as those are not always available, and the .status of React's promises
|
|
41
|
-
* should not be considered part of the public API.
|
|
42
|
-
*/
|
|
43
|
-
declare function tryResolveSync(promise: Promise<unknown> | Thenable<unknown>): {
|
|
44
|
-
data: {} | null;
|
|
45
|
-
} | undefined;
|
|
46
|
-
|
|
47
|
-
export { type FulfilledThenable, type PendingThenable, type RejectedThenable, type Thenable, pendingThenable, tryResolveSync };
|
|
1
|
+
export { pendingThenable } from './_tsup-dts-rollup.cjs';
|
|
2
|
+
export { tryResolveSync } from './_tsup-dts-rollup.cjs';
|
|
3
|
+
export { FulfilledThenable } from './_tsup-dts-rollup.cjs';
|
|
4
|
+
export { RejectedThenable } from './_tsup-dts-rollup.cjs';
|
|
5
|
+
export { PendingThenable } from './_tsup-dts-rollup.cjs';
|
|
6
|
+
export { Thenable } from './_tsup-dts-rollup.cjs';
|
|
@@ -1,47 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227
|
|
8
|
-
*/
|
|
9
|
-
interface Fulfilled<T> {
|
|
10
|
-
status: 'fulfilled';
|
|
11
|
-
value: T;
|
|
12
|
-
}
|
|
13
|
-
interface Rejected {
|
|
14
|
-
status: 'rejected';
|
|
15
|
-
reason: unknown;
|
|
16
|
-
}
|
|
17
|
-
interface Pending<T> {
|
|
18
|
-
status: 'pending';
|
|
19
|
-
/**
|
|
20
|
-
* Resolve the promise with a value.
|
|
21
|
-
* Will remove the `resolve` and `reject` properties from the promise.
|
|
22
|
-
*/
|
|
23
|
-
resolve: (value: T) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Reject the promise with a reason.
|
|
26
|
-
* Will remove the `resolve` and `reject` properties from the promise.
|
|
27
|
-
*/
|
|
28
|
-
reject: (reason: unknown) => void;
|
|
29
|
-
}
|
|
30
|
-
type FulfilledThenable<T> = Promise<T> & Fulfilled<T>;
|
|
31
|
-
type RejectedThenable<T> = Promise<T> & Rejected;
|
|
32
|
-
type PendingThenable<T> = Promise<T> & Pending<T>;
|
|
33
|
-
type Thenable<T> = FulfilledThenable<T> | RejectedThenable<T> | PendingThenable<T>;
|
|
34
|
-
declare function pendingThenable<T>(): PendingThenable<T>;
|
|
35
|
-
/**
|
|
36
|
-
* This function takes a Promise-like input and detects whether the data
|
|
37
|
-
* is synchronously available or not.
|
|
38
|
-
*
|
|
39
|
-
* It does not inspect .status, .value or .reason properties of the promise,
|
|
40
|
-
* as those are not always available, and the .status of React's promises
|
|
41
|
-
* should not be considered part of the public API.
|
|
42
|
-
*/
|
|
43
|
-
declare function tryResolveSync(promise: Promise<unknown> | Thenable<unknown>): {
|
|
44
|
-
data: {} | null;
|
|
45
|
-
} | undefined;
|
|
46
|
-
|
|
47
|
-
export { type FulfilledThenable, type PendingThenable, type RejectedThenable, type Thenable, pendingThenable, tryResolveSync };
|
|
1
|
+
export { pendingThenable } from './_tsup-dts-rollup.js';
|
|
2
|
+
export { tryResolveSync } from './_tsup-dts-rollup.js';
|
|
3
|
+
export { FulfilledThenable } from './_tsup-dts-rollup.js';
|
|
4
|
+
export { RejectedThenable } from './_tsup-dts-rollup.js';
|
|
5
|
+
export { PendingThenable } from './_tsup-dts-rollup.js';
|
|
6
|
+
export { Thenable } from './_tsup-dts-rollup.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/thenable.ts"],"sourcesContent":["/**\n * Thenable types which matches React's types for promises\n *\n * React seemingly uses `.status`, `.value` and `.reason` properties on a promises to optimistically unwrap data from promises\n *\n * @see https://github.com/facebook/react/blob/main/packages/shared/ReactTypes.js#L112-L138\n * @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227\n */\n\nimport { noop } from './utils'\n\ninterface Fulfilled<T> {\n status: 'fulfilled'\n value: T\n}\ninterface Rejected {\n status: 'rejected'\n reason: unknown\n}\ninterface Pending<T> {\n status: 'pending'\n\n /**\n * Resolve the promise with a value.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n resolve: (value: T) => void\n /**\n * Reject the promise with a reason.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n reject: (reason: unknown) => void\n}\n\nexport type FulfilledThenable<T> = Promise<T> & Fulfilled<T>\nexport type RejectedThenable<T> = Promise<T> & Rejected\nexport type PendingThenable<T> = Promise<T> & Pending<T>\n\nexport type Thenable<T> =\n | FulfilledThenable<T>\n | RejectedThenable<T>\n | PendingThenable<T>\n\nexport function pendingThenable<T>(): PendingThenable<T> {\n let resolve: Pending<T>['resolve']\n let reject: Pending<T>['reject']\n // this could use `Promise.withResolvers()` in the future\n const thenable = new Promise((_resolve, _reject) => {\n resolve = _resolve\n reject = _reject\n }) as PendingThenable<T>\n\n thenable.status = 'pending'\n thenable.catch(() => {\n // prevent unhandled rejection errors\n })\n\n function finalize(data: Fulfilled<T> | Rejected) {\n Object.assign(thenable, data)\n\n // clear pending props
|
|
1
|
+
{"version":3,"sources":["../../src/thenable.ts"],"sourcesContent":["/**\n * Thenable types which matches React's types for promises\n *\n * React seemingly uses `.status`, `.value` and `.reason` properties on a promises to optimistically unwrap data from promises\n *\n * @see https://github.com/facebook/react/blob/main/packages/shared/ReactTypes.js#L112-L138\n * @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227\n */\n\nimport { noop } from './utils'\n\ninterface Fulfilled<T> {\n status: 'fulfilled'\n value: T\n}\ninterface Rejected {\n status: 'rejected'\n reason: unknown\n}\ninterface Pending<T> {\n status: 'pending'\n\n /**\n * Resolve the promise with a value.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n resolve: (value: T) => void\n /**\n * Reject the promise with a reason.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n reject: (reason: unknown) => void\n}\n\nexport type FulfilledThenable<T> = Promise<T> & Fulfilled<T>\nexport type RejectedThenable<T> = Promise<T> & Rejected\nexport type PendingThenable<T> = Promise<T> & Pending<T>\n\nexport type Thenable<T> =\n | FulfilledThenable<T>\n | RejectedThenable<T>\n | PendingThenable<T>\n\nexport function pendingThenable<T>(): PendingThenable<T> {\n let resolve: Pending<T>['resolve']\n let reject: Pending<T>['reject']\n // this could use `Promise.withResolvers()` in the future\n const thenable = new Promise((_resolve, _reject) => {\n resolve = _resolve\n reject = _reject\n }) as PendingThenable<T>\n\n thenable.status = 'pending'\n thenable.catch(() => {\n // prevent unhandled rejection errors\n })\n\n function finalize(data: Fulfilled<T> | Rejected) {\n Object.assign(thenable, data)\n\n // clear pending props to avoid calling them twice\n delete (thenable as Partial<PendingThenable<T>>).resolve\n delete (thenable as Partial<PendingThenable<T>>).reject\n }\n\n thenable.resolve = (value) => {\n finalize({\n status: 'fulfilled',\n value,\n })\n\n resolve(value)\n }\n thenable.reject = (reason) => {\n finalize({\n status: 'rejected',\n reason,\n })\n\n reject(reason)\n }\n\n return thenable\n}\n\n/**\n * This function takes a Promise-like input and detects whether the data\n * is synchronously available or not.\n *\n * It does not inspect .status, .value or .reason properties of the promise,\n * as those are not always available, and the .status of React's promises\n * should not be considered part of the public API.\n */\nexport function tryResolveSync(promise: Promise<unknown> | Thenable<unknown>) {\n let data: unknown\n\n promise\n .then((result) => {\n data = result\n return result\n }, noop)\n // .catch can be unavailable on certain kinds of thenable's\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n ?.catch(noop)\n\n if (data !== undefined) {\n return { data }\n }\n\n return undefined\n}\n"],"mappings":";AASA,SAAS,YAAY;AAkCd,SAAS,kBAAyC;AACvD,MAAI;AACJ,MAAI;AAEJ,QAAM,WAAW,IAAI,QAAQ,CAAC,UAAU,YAAY;AAClD,cAAU;AACV,aAAS;AAAA,EACX,CAAC;AAED,WAAS,SAAS;AAClB,WAAS,MAAM,MAAM;AAAA,EAErB,CAAC;AAED,WAAS,SAAS,MAA+B;AAC/C,WAAO,OAAO,UAAU,IAAI;AAG5B,WAAQ,SAAyC;AACjD,WAAQ,SAAyC;AAAA,EACnD;AAEA,WAAS,UAAU,CAAC,UAAU;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,YAAQ,KAAK;AAAA,EACf;AACA,WAAS,SAAS,CAAC,WAAW;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AAAA,EACf;AAEA,SAAO;AACT;AAUO,SAAS,eAAe,SAA+C;AAC5E,MAAI;AAEJ,UACG,KAAK,CAAC,WAAW;AAChB,WAAO;AACP,WAAO;AAAA,EACT,GAAG,IAAI,GAGL,MAAM,IAAI;AAEd,MAAI,SAAS,QAAW;AACtB,WAAO,EAAE,KAAK;AAAA,EAChB;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,58 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
type TimeoutCallback = (_: void) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Wrapping `setTimeout` is awkward from a typing perspective because platform
|
|
12
|
-
* typings may extend the return type of `setTimeout`. For example, NodeJS
|
|
13
|
-
* typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be
|
|
14
|
-
* able to return such a type.
|
|
15
|
-
*/
|
|
16
|
-
type ManagedTimerId = number | {
|
|
17
|
-
[Symbol.toPrimitive]: () => number;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Backend for timer functions.
|
|
21
|
-
*/
|
|
22
|
-
type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> = {
|
|
23
|
-
readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId;
|
|
24
|
-
readonly clearTimeout: (timeoutId: TTimerId | undefined) => void;
|
|
25
|
-
readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId;
|
|
26
|
-
readonly clearInterval: (intervalId: TTimerId | undefined) => void;
|
|
27
|
-
};
|
|
28
|
-
declare const defaultTimeoutProvider: TimeoutProvider<ReturnType<typeof setTimeout>>;
|
|
29
|
-
/**
|
|
30
|
-
* Allows customization of how timeouts are created.
|
|
31
|
-
*
|
|
32
|
-
* @tanstack/query-core makes liberal use of timeouts to implement `staleTime`
|
|
33
|
-
* and `gcTime`. The default TimeoutManager provider uses the platform's global
|
|
34
|
-
* `setTimeout` implementation, which is known to have scalability issues with
|
|
35
|
-
* thousands of timeouts on the event loop.
|
|
36
|
-
*
|
|
37
|
-
* If you hit this limitation, consider providing a custom TimeoutProvider that
|
|
38
|
-
* coalesces timeouts.
|
|
39
|
-
*/
|
|
40
|
-
declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
|
|
41
|
-
#private;
|
|
42
|
-
setTimeoutProvider<TTimerId extends ManagedTimerId>(provider: TimeoutProvider<TTimerId>): void;
|
|
43
|
-
setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId;
|
|
44
|
-
clearTimeout(timeoutId: ManagedTimerId | undefined): void;
|
|
45
|
-
setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId;
|
|
46
|
-
clearInterval(intervalId: ManagedTimerId | undefined): void;
|
|
47
|
-
}
|
|
48
|
-
declare const timeoutManager: TimeoutManager;
|
|
49
|
-
/**
|
|
50
|
-
* In many cases code wants to delay to the next event loop tick; this is not
|
|
51
|
-
* mediated by {@link timeoutManager}.
|
|
52
|
-
*
|
|
53
|
-
* This function is provided to make auditing the `tanstack/query-core` for
|
|
54
|
-
* incorrect use of system `setTimeout` easier.
|
|
55
|
-
*/
|
|
56
|
-
declare function systemSetTimeoutZero(callback: TimeoutCallback): void;
|
|
57
|
-
|
|
58
|
-
export { type ManagedTimerId, type TimeoutCallback, TimeoutManager, type TimeoutProvider, defaultTimeoutProvider, systemSetTimeoutZero, timeoutManager };
|
|
1
|
+
export { systemSetTimeoutZero } from './_tsup-dts-rollup.cjs';
|
|
2
|
+
export { TimeoutCallback_alias_1 as TimeoutCallback } from './_tsup-dts-rollup.cjs';
|
|
3
|
+
export { ManagedTimerId_alias_1 as ManagedTimerId } from './_tsup-dts-rollup.cjs';
|
|
4
|
+
export { TimeoutProvider_alias_1 as TimeoutProvider } from './_tsup-dts-rollup.cjs';
|
|
5
|
+
export { defaultTimeoutProvider } from './_tsup-dts-rollup.cjs';
|
|
6
|
+
export { TimeoutManager } from './_tsup-dts-rollup.cjs';
|
|
7
|
+
export { timeoutManager_alias_1 as timeoutManager } from './_tsup-dts-rollup.cjs';
|
|
@@ -1,58 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
type TimeoutCallback = (_: void) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Wrapping `setTimeout` is awkward from a typing perspective because platform
|
|
12
|
-
* typings may extend the return type of `setTimeout`. For example, NodeJS
|
|
13
|
-
* typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be
|
|
14
|
-
* able to return such a type.
|
|
15
|
-
*/
|
|
16
|
-
type ManagedTimerId = number | {
|
|
17
|
-
[Symbol.toPrimitive]: () => number;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Backend for timer functions.
|
|
21
|
-
*/
|
|
22
|
-
type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> = {
|
|
23
|
-
readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId;
|
|
24
|
-
readonly clearTimeout: (timeoutId: TTimerId | undefined) => void;
|
|
25
|
-
readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId;
|
|
26
|
-
readonly clearInterval: (intervalId: TTimerId | undefined) => void;
|
|
27
|
-
};
|
|
28
|
-
declare const defaultTimeoutProvider: TimeoutProvider<ReturnType<typeof setTimeout>>;
|
|
29
|
-
/**
|
|
30
|
-
* Allows customization of how timeouts are created.
|
|
31
|
-
*
|
|
32
|
-
* @tanstack/query-core makes liberal use of timeouts to implement `staleTime`
|
|
33
|
-
* and `gcTime`. The default TimeoutManager provider uses the platform's global
|
|
34
|
-
* `setTimeout` implementation, which is known to have scalability issues with
|
|
35
|
-
* thousands of timeouts on the event loop.
|
|
36
|
-
*
|
|
37
|
-
* If you hit this limitation, consider providing a custom TimeoutProvider that
|
|
38
|
-
* coalesces timeouts.
|
|
39
|
-
*/
|
|
40
|
-
declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
|
|
41
|
-
#private;
|
|
42
|
-
setTimeoutProvider<TTimerId extends ManagedTimerId>(provider: TimeoutProvider<TTimerId>): void;
|
|
43
|
-
setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId;
|
|
44
|
-
clearTimeout(timeoutId: ManagedTimerId | undefined): void;
|
|
45
|
-
setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId;
|
|
46
|
-
clearInterval(intervalId: ManagedTimerId | undefined): void;
|
|
47
|
-
}
|
|
48
|
-
declare const timeoutManager: TimeoutManager;
|
|
49
|
-
/**
|
|
50
|
-
* In many cases code wants to delay to the next event loop tick; this is not
|
|
51
|
-
* mediated by {@link timeoutManager}.
|
|
52
|
-
*
|
|
53
|
-
* This function is provided to make auditing the `tanstack/query-core` for
|
|
54
|
-
* incorrect use of system `setTimeout` easier.
|
|
55
|
-
*/
|
|
56
|
-
declare function systemSetTimeoutZero(callback: TimeoutCallback): void;
|
|
57
|
-
|
|
58
|
-
export { type ManagedTimerId, type TimeoutCallback, TimeoutManager, type TimeoutProvider, defaultTimeoutProvider, systemSetTimeoutZero, timeoutManager };
|
|
1
|
+
export { systemSetTimeoutZero } from './_tsup-dts-rollup.js';
|
|
2
|
+
export { TimeoutCallback_alias_1 as TimeoutCallback } from './_tsup-dts-rollup.js';
|
|
3
|
+
export { ManagedTimerId_alias_1 as ManagedTimerId } from './_tsup-dts-rollup.js';
|
|
4
|
+
export { TimeoutProvider_alias_1 as TimeoutProvider } from './_tsup-dts-rollup.js';
|
|
5
|
+
export { defaultTimeoutProvider } from './_tsup-dts-rollup.js';
|
|
6
|
+
export { TimeoutManager } from './_tsup-dts-rollup.js';
|
|
7
|
+
export { timeoutManager_alias_1 as timeoutManager } from './_tsup-dts-rollup.js';
|
package/build/modern/types.d.cts
CHANGED
|
@@ -1,3 +1,95 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export { NonUndefinedGuard_alias_1 as NonUndefinedGuard } from './_tsup-dts-rollup.cjs';
|
|
2
|
+
export { DistributiveOmit_alias_1 as DistributiveOmit } from './_tsup-dts-rollup.cjs';
|
|
3
|
+
export { OmitKeyof_alias_1 as OmitKeyof } from './_tsup-dts-rollup.cjs';
|
|
4
|
+
export { Override_alias_1 as Override } from './_tsup-dts-rollup.cjs';
|
|
5
|
+
export { NoInfer_alias_1 as NoInfer } from './_tsup-dts-rollup.cjs';
|
|
6
|
+
export { Register_alias_1 as Register } from './_tsup-dts-rollup.cjs';
|
|
7
|
+
export { DefaultError_alias_1 as DefaultError } from './_tsup-dts-rollup.cjs';
|
|
8
|
+
export { QueryKey_alias_1 as QueryKey } from './_tsup-dts-rollup.cjs';
|
|
9
|
+
export { dataTagSymbol_alias_1 as dataTagSymbol } from './_tsup-dts-rollup.cjs';
|
|
10
|
+
export { dataTagErrorSymbol_alias_1 as dataTagErrorSymbol } from './_tsup-dts-rollup.cjs';
|
|
11
|
+
export { unsetMarker_alias_1 as unsetMarker } from './_tsup-dts-rollup.cjs';
|
|
12
|
+
export { UnsetMarker_alias_1 as UnsetMarker } from './_tsup-dts-rollup.cjs';
|
|
13
|
+
export { AnyDataTag_alias_1 as AnyDataTag } from './_tsup-dts-rollup.cjs';
|
|
14
|
+
export { DataTag_alias_1 as DataTag } from './_tsup-dts-rollup.cjs';
|
|
15
|
+
export { InferDataFromTag_alias_1 as InferDataFromTag } from './_tsup-dts-rollup.cjs';
|
|
16
|
+
export { InferErrorFromTag_alias_1 as InferErrorFromTag } from './_tsup-dts-rollup.cjs';
|
|
17
|
+
export { QueryFunction_alias_1 as QueryFunction } from './_tsup-dts-rollup.cjs';
|
|
18
|
+
export { StaleTime_alias_1 as StaleTime } from './_tsup-dts-rollup.cjs';
|
|
19
|
+
export { StaleTimeFunction_alias_1 as StaleTimeFunction } from './_tsup-dts-rollup.cjs';
|
|
20
|
+
export { Enabled_alias_1 as Enabled } from './_tsup-dts-rollup.cjs';
|
|
21
|
+
export { QueryPersister_alias_1 as QueryPersister } from './_tsup-dts-rollup.cjs';
|
|
22
|
+
export { QueryFunctionContext_alias_1 as QueryFunctionContext } from './_tsup-dts-rollup.cjs';
|
|
23
|
+
export { InitialDataFunction_alias_1 as InitialDataFunction } from './_tsup-dts-rollup.cjs';
|
|
24
|
+
export { PlaceholderDataFunction_alias_1 as PlaceholderDataFunction } from './_tsup-dts-rollup.cjs';
|
|
25
|
+
export { QueriesPlaceholderDataFunction_alias_1 as QueriesPlaceholderDataFunction } from './_tsup-dts-rollup.cjs';
|
|
26
|
+
export { QueryKeyHashFunction_alias_1 as QueryKeyHashFunction } from './_tsup-dts-rollup.cjs';
|
|
27
|
+
export { GetPreviousPageParamFunction_alias_1 as GetPreviousPageParamFunction } from './_tsup-dts-rollup.cjs';
|
|
28
|
+
export { GetNextPageParamFunction_alias_1 as GetNextPageParamFunction } from './_tsup-dts-rollup.cjs';
|
|
29
|
+
export { InfiniteData_alias_1 as InfiniteData } from './_tsup-dts-rollup.cjs';
|
|
30
|
+
export { QueryMeta_alias_1 as QueryMeta } from './_tsup-dts-rollup.cjs';
|
|
31
|
+
export { NetworkMode_alias_1 as NetworkMode } from './_tsup-dts-rollup.cjs';
|
|
32
|
+
export { NotifyOnChangeProps_alias_1 as NotifyOnChangeProps } from './_tsup-dts-rollup.cjs';
|
|
33
|
+
export { QueryOptions_alias_1 as QueryOptions } from './_tsup-dts-rollup.cjs';
|
|
34
|
+
export { InitialPageParam_alias_1 as InitialPageParam } from './_tsup-dts-rollup.cjs';
|
|
35
|
+
export { InfiniteQueryPageParamsOptions_alias_1 as InfiniteQueryPageParamsOptions } from './_tsup-dts-rollup.cjs';
|
|
36
|
+
export { ThrowOnError_alias_1 as ThrowOnError } from './_tsup-dts-rollup.cjs';
|
|
37
|
+
export { QueryObserverOptions_alias_1 as QueryObserverOptions } from './_tsup-dts-rollup.cjs';
|
|
38
|
+
export { WithRequired_alias_1 as WithRequired } from './_tsup-dts-rollup.cjs';
|
|
39
|
+
export { DefaultedQueryObserverOptions_alias_1 as DefaultedQueryObserverOptions } from './_tsup-dts-rollup.cjs';
|
|
40
|
+
export { InfiniteQueryObserverOptions_alias_1 as InfiniteQueryObserverOptions } from './_tsup-dts-rollup.cjs';
|
|
41
|
+
export { DefaultedInfiniteQueryObserverOptions_alias_1 as DefaultedInfiniteQueryObserverOptions } from './_tsup-dts-rollup.cjs';
|
|
42
|
+
export { FetchQueryOptions_alias_1 as FetchQueryOptions } from './_tsup-dts-rollup.cjs';
|
|
43
|
+
export { EnsureQueryDataOptions_alias_1 as EnsureQueryDataOptions } from './_tsup-dts-rollup.cjs';
|
|
44
|
+
export { EnsureInfiniteQueryDataOptions_alias_1 as EnsureInfiniteQueryDataOptions } from './_tsup-dts-rollup.cjs';
|
|
45
|
+
export { FetchInfiniteQueryOptions_alias_1 as FetchInfiniteQueryOptions } from './_tsup-dts-rollup.cjs';
|
|
46
|
+
export { ResultOptions_alias_1 as ResultOptions } from './_tsup-dts-rollup.cjs';
|
|
47
|
+
export { RefetchOptions_alias_1 as RefetchOptions } from './_tsup-dts-rollup.cjs';
|
|
48
|
+
export { InvalidateQueryFilters_alias_1 as InvalidateQueryFilters } from './_tsup-dts-rollup.cjs';
|
|
49
|
+
export { RefetchQueryFilters_alias_1 as RefetchQueryFilters } from './_tsup-dts-rollup.cjs';
|
|
50
|
+
export { InvalidateOptions_alias_1 as InvalidateOptions } from './_tsup-dts-rollup.cjs';
|
|
51
|
+
export { ResetOptions_alias_1 as ResetOptions } from './_tsup-dts-rollup.cjs';
|
|
52
|
+
export { FetchNextPageOptions_alias_1 as FetchNextPageOptions } from './_tsup-dts-rollup.cjs';
|
|
53
|
+
export { FetchPreviousPageOptions_alias_1 as FetchPreviousPageOptions } from './_tsup-dts-rollup.cjs';
|
|
54
|
+
export { QueryStatus_alias_1 as QueryStatus } from './_tsup-dts-rollup.cjs';
|
|
55
|
+
export { FetchStatus_alias_1 as FetchStatus } from './_tsup-dts-rollup.cjs';
|
|
56
|
+
export { QueryObserverBaseResult_alias_1 as QueryObserverBaseResult } from './_tsup-dts-rollup.cjs';
|
|
57
|
+
export { QueryObserverPendingResult_alias_1 as QueryObserverPendingResult } from './_tsup-dts-rollup.cjs';
|
|
58
|
+
export { QueryObserverLoadingResult_alias_1 as QueryObserverLoadingResult } from './_tsup-dts-rollup.cjs';
|
|
59
|
+
export { QueryObserverLoadingErrorResult_alias_1 as QueryObserverLoadingErrorResult } from './_tsup-dts-rollup.cjs';
|
|
60
|
+
export { QueryObserverRefetchErrorResult_alias_1 as QueryObserverRefetchErrorResult } from './_tsup-dts-rollup.cjs';
|
|
61
|
+
export { QueryObserverSuccessResult_alias_1 as QueryObserverSuccessResult } from './_tsup-dts-rollup.cjs';
|
|
62
|
+
export { QueryObserverPlaceholderResult_alias_1 as QueryObserverPlaceholderResult } from './_tsup-dts-rollup.cjs';
|
|
63
|
+
export { DefinedQueryObserverResult_alias_1 as DefinedQueryObserverResult } from './_tsup-dts-rollup.cjs';
|
|
64
|
+
export { QueryObserverResult_alias_1 as QueryObserverResult } from './_tsup-dts-rollup.cjs';
|
|
65
|
+
export { InfiniteQueryObserverBaseResult_alias_1 as InfiniteQueryObserverBaseResult } from './_tsup-dts-rollup.cjs';
|
|
66
|
+
export { InfiniteQueryObserverPendingResult_alias_1 as InfiniteQueryObserverPendingResult } from './_tsup-dts-rollup.cjs';
|
|
67
|
+
export { InfiniteQueryObserverLoadingResult_alias_1 as InfiniteQueryObserverLoadingResult } from './_tsup-dts-rollup.cjs';
|
|
68
|
+
export { InfiniteQueryObserverLoadingErrorResult_alias_1 as InfiniteQueryObserverLoadingErrorResult } from './_tsup-dts-rollup.cjs';
|
|
69
|
+
export { InfiniteQueryObserverRefetchErrorResult_alias_1 as InfiniteQueryObserverRefetchErrorResult } from './_tsup-dts-rollup.cjs';
|
|
70
|
+
export { InfiniteQueryObserverSuccessResult_alias_1 as InfiniteQueryObserverSuccessResult } from './_tsup-dts-rollup.cjs';
|
|
71
|
+
export { InfiniteQueryObserverPlaceholderResult_alias_1 as InfiniteQueryObserverPlaceholderResult } from './_tsup-dts-rollup.cjs';
|
|
72
|
+
export { DefinedInfiniteQueryObserverResult_alias_1 as DefinedInfiniteQueryObserverResult } from './_tsup-dts-rollup.cjs';
|
|
73
|
+
export { InfiniteQueryObserverResult_alias_1 as InfiniteQueryObserverResult } from './_tsup-dts-rollup.cjs';
|
|
74
|
+
export { MutationKey_alias_1 as MutationKey } from './_tsup-dts-rollup.cjs';
|
|
75
|
+
export { MutationStatus_alias_1 as MutationStatus } from './_tsup-dts-rollup.cjs';
|
|
76
|
+
export { MutationScope_alias_1 as MutationScope } from './_tsup-dts-rollup.cjs';
|
|
77
|
+
export { MutationMeta_alias_1 as MutationMeta } from './_tsup-dts-rollup.cjs';
|
|
78
|
+
export { MutationFunctionContext_alias_1 as MutationFunctionContext } from './_tsup-dts-rollup.cjs';
|
|
79
|
+
export { MutationFunction_alias_1 as MutationFunction } from './_tsup-dts-rollup.cjs';
|
|
80
|
+
export { MutationOptions_alias_1 as MutationOptions } from './_tsup-dts-rollup.cjs';
|
|
81
|
+
export { MutationObserverOptions_alias_1 as MutationObserverOptions } from './_tsup-dts-rollup.cjs';
|
|
82
|
+
export { MutateOptions_alias_1 as MutateOptions } from './_tsup-dts-rollup.cjs';
|
|
83
|
+
export { MutateFunction_alias_1 as MutateFunction } from './_tsup-dts-rollup.cjs';
|
|
84
|
+
export { MutationObserverBaseResult_alias_1 as MutationObserverBaseResult } from './_tsup-dts-rollup.cjs';
|
|
85
|
+
export { MutationObserverIdleResult_alias_1 as MutationObserverIdleResult } from './_tsup-dts-rollup.cjs';
|
|
86
|
+
export { MutationObserverLoadingResult_alias_1 as MutationObserverLoadingResult } from './_tsup-dts-rollup.cjs';
|
|
87
|
+
export { MutationObserverErrorResult_alias_1 as MutationObserverErrorResult } from './_tsup-dts-rollup.cjs';
|
|
88
|
+
export { MutationObserverSuccessResult_alias_1 as MutationObserverSuccessResult } from './_tsup-dts-rollup.cjs';
|
|
89
|
+
export { MutationObserverResult_alias_1 as MutationObserverResult } from './_tsup-dts-rollup.cjs';
|
|
90
|
+
export { QueryClientConfig_alias_1 as QueryClientConfig } from './_tsup-dts-rollup.cjs';
|
|
91
|
+
export { DefaultOptions_alias_1 as DefaultOptions } from './_tsup-dts-rollup.cjs';
|
|
92
|
+
export { CancelOptions_alias_1 as CancelOptions } from './_tsup-dts-rollup.cjs';
|
|
93
|
+
export { SetDataOptions_alias_1 as SetDataOptions } from './_tsup-dts-rollup.cjs';
|
|
94
|
+
export { NotifyEventType_alias_1 as NotifyEventType } from './_tsup-dts-rollup.cjs';
|
|
95
|
+
export { NotifyEvent_alias_1 as NotifyEvent } from './_tsup-dts-rollup.cjs';
|
package/build/modern/types.d.ts
CHANGED
|
@@ -1,3 +1,95 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export { NonUndefinedGuard_alias_1 as NonUndefinedGuard } from './_tsup-dts-rollup.js';
|
|
2
|
+
export { DistributiveOmit_alias_1 as DistributiveOmit } from './_tsup-dts-rollup.js';
|
|
3
|
+
export { OmitKeyof_alias_1 as OmitKeyof } from './_tsup-dts-rollup.js';
|
|
4
|
+
export { Override_alias_1 as Override } from './_tsup-dts-rollup.js';
|
|
5
|
+
export { NoInfer_alias_1 as NoInfer } from './_tsup-dts-rollup.js';
|
|
6
|
+
export { Register_alias_1 as Register } from './_tsup-dts-rollup.js';
|
|
7
|
+
export { DefaultError_alias_1 as DefaultError } from './_tsup-dts-rollup.js';
|
|
8
|
+
export { QueryKey_alias_1 as QueryKey } from './_tsup-dts-rollup.js';
|
|
9
|
+
export { dataTagSymbol_alias_1 as dataTagSymbol } from './_tsup-dts-rollup.js';
|
|
10
|
+
export { dataTagErrorSymbol_alias_1 as dataTagErrorSymbol } from './_tsup-dts-rollup.js';
|
|
11
|
+
export { unsetMarker_alias_1 as unsetMarker } from './_tsup-dts-rollup.js';
|
|
12
|
+
export { UnsetMarker_alias_1 as UnsetMarker } from './_tsup-dts-rollup.js';
|
|
13
|
+
export { AnyDataTag_alias_1 as AnyDataTag } from './_tsup-dts-rollup.js';
|
|
14
|
+
export { DataTag_alias_1 as DataTag } from './_tsup-dts-rollup.js';
|
|
15
|
+
export { InferDataFromTag_alias_1 as InferDataFromTag } from './_tsup-dts-rollup.js';
|
|
16
|
+
export { InferErrorFromTag_alias_1 as InferErrorFromTag } from './_tsup-dts-rollup.js';
|
|
17
|
+
export { QueryFunction_alias_1 as QueryFunction } from './_tsup-dts-rollup.js';
|
|
18
|
+
export { StaleTime_alias_1 as StaleTime } from './_tsup-dts-rollup.js';
|
|
19
|
+
export { StaleTimeFunction_alias_1 as StaleTimeFunction } from './_tsup-dts-rollup.js';
|
|
20
|
+
export { Enabled_alias_1 as Enabled } from './_tsup-dts-rollup.js';
|
|
21
|
+
export { QueryPersister_alias_1 as QueryPersister } from './_tsup-dts-rollup.js';
|
|
22
|
+
export { QueryFunctionContext_alias_1 as QueryFunctionContext } from './_tsup-dts-rollup.js';
|
|
23
|
+
export { InitialDataFunction_alias_1 as InitialDataFunction } from './_tsup-dts-rollup.js';
|
|
24
|
+
export { PlaceholderDataFunction_alias_1 as PlaceholderDataFunction } from './_tsup-dts-rollup.js';
|
|
25
|
+
export { QueriesPlaceholderDataFunction_alias_1 as QueriesPlaceholderDataFunction } from './_tsup-dts-rollup.js';
|
|
26
|
+
export { QueryKeyHashFunction_alias_1 as QueryKeyHashFunction } from './_tsup-dts-rollup.js';
|
|
27
|
+
export { GetPreviousPageParamFunction_alias_1 as GetPreviousPageParamFunction } from './_tsup-dts-rollup.js';
|
|
28
|
+
export { GetNextPageParamFunction_alias_1 as GetNextPageParamFunction } from './_tsup-dts-rollup.js';
|
|
29
|
+
export { InfiniteData_alias_1 as InfiniteData } from './_tsup-dts-rollup.js';
|
|
30
|
+
export { QueryMeta_alias_1 as QueryMeta } from './_tsup-dts-rollup.js';
|
|
31
|
+
export { NetworkMode_alias_1 as NetworkMode } from './_tsup-dts-rollup.js';
|
|
32
|
+
export { NotifyOnChangeProps_alias_1 as NotifyOnChangeProps } from './_tsup-dts-rollup.js';
|
|
33
|
+
export { QueryOptions_alias_1 as QueryOptions } from './_tsup-dts-rollup.js';
|
|
34
|
+
export { InitialPageParam_alias_1 as InitialPageParam } from './_tsup-dts-rollup.js';
|
|
35
|
+
export { InfiniteQueryPageParamsOptions_alias_1 as InfiniteQueryPageParamsOptions } from './_tsup-dts-rollup.js';
|
|
36
|
+
export { ThrowOnError_alias_1 as ThrowOnError } from './_tsup-dts-rollup.js';
|
|
37
|
+
export { QueryObserverOptions_alias_1 as QueryObserverOptions } from './_tsup-dts-rollup.js';
|
|
38
|
+
export { WithRequired_alias_1 as WithRequired } from './_tsup-dts-rollup.js';
|
|
39
|
+
export { DefaultedQueryObserverOptions_alias_1 as DefaultedQueryObserverOptions } from './_tsup-dts-rollup.js';
|
|
40
|
+
export { InfiniteQueryObserverOptions_alias_1 as InfiniteQueryObserverOptions } from './_tsup-dts-rollup.js';
|
|
41
|
+
export { DefaultedInfiniteQueryObserverOptions_alias_1 as DefaultedInfiniteQueryObserverOptions } from './_tsup-dts-rollup.js';
|
|
42
|
+
export { FetchQueryOptions_alias_1 as FetchQueryOptions } from './_tsup-dts-rollup.js';
|
|
43
|
+
export { EnsureQueryDataOptions_alias_1 as EnsureQueryDataOptions } from './_tsup-dts-rollup.js';
|
|
44
|
+
export { EnsureInfiniteQueryDataOptions_alias_1 as EnsureInfiniteQueryDataOptions } from './_tsup-dts-rollup.js';
|
|
45
|
+
export { FetchInfiniteQueryOptions_alias_1 as FetchInfiniteQueryOptions } from './_tsup-dts-rollup.js';
|
|
46
|
+
export { ResultOptions_alias_1 as ResultOptions } from './_tsup-dts-rollup.js';
|
|
47
|
+
export { RefetchOptions_alias_1 as RefetchOptions } from './_tsup-dts-rollup.js';
|
|
48
|
+
export { InvalidateQueryFilters_alias_1 as InvalidateQueryFilters } from './_tsup-dts-rollup.js';
|
|
49
|
+
export { RefetchQueryFilters_alias_1 as RefetchQueryFilters } from './_tsup-dts-rollup.js';
|
|
50
|
+
export { InvalidateOptions_alias_1 as InvalidateOptions } from './_tsup-dts-rollup.js';
|
|
51
|
+
export { ResetOptions_alias_1 as ResetOptions } from './_tsup-dts-rollup.js';
|
|
52
|
+
export { FetchNextPageOptions_alias_1 as FetchNextPageOptions } from './_tsup-dts-rollup.js';
|
|
53
|
+
export { FetchPreviousPageOptions_alias_1 as FetchPreviousPageOptions } from './_tsup-dts-rollup.js';
|
|
54
|
+
export { QueryStatus_alias_1 as QueryStatus } from './_tsup-dts-rollup.js';
|
|
55
|
+
export { FetchStatus_alias_1 as FetchStatus } from './_tsup-dts-rollup.js';
|
|
56
|
+
export { QueryObserverBaseResult_alias_1 as QueryObserverBaseResult } from './_tsup-dts-rollup.js';
|
|
57
|
+
export { QueryObserverPendingResult_alias_1 as QueryObserverPendingResult } from './_tsup-dts-rollup.js';
|
|
58
|
+
export { QueryObserverLoadingResult_alias_1 as QueryObserverLoadingResult } from './_tsup-dts-rollup.js';
|
|
59
|
+
export { QueryObserverLoadingErrorResult_alias_1 as QueryObserverLoadingErrorResult } from './_tsup-dts-rollup.js';
|
|
60
|
+
export { QueryObserverRefetchErrorResult_alias_1 as QueryObserverRefetchErrorResult } from './_tsup-dts-rollup.js';
|
|
61
|
+
export { QueryObserverSuccessResult_alias_1 as QueryObserverSuccessResult } from './_tsup-dts-rollup.js';
|
|
62
|
+
export { QueryObserverPlaceholderResult_alias_1 as QueryObserverPlaceholderResult } from './_tsup-dts-rollup.js';
|
|
63
|
+
export { DefinedQueryObserverResult_alias_1 as DefinedQueryObserverResult } from './_tsup-dts-rollup.js';
|
|
64
|
+
export { QueryObserverResult_alias_1 as QueryObserverResult } from './_tsup-dts-rollup.js';
|
|
65
|
+
export { InfiniteQueryObserverBaseResult_alias_1 as InfiniteQueryObserverBaseResult } from './_tsup-dts-rollup.js';
|
|
66
|
+
export { InfiniteQueryObserverPendingResult_alias_1 as InfiniteQueryObserverPendingResult } from './_tsup-dts-rollup.js';
|
|
67
|
+
export { InfiniteQueryObserverLoadingResult_alias_1 as InfiniteQueryObserverLoadingResult } from './_tsup-dts-rollup.js';
|
|
68
|
+
export { InfiniteQueryObserverLoadingErrorResult_alias_1 as InfiniteQueryObserverLoadingErrorResult } from './_tsup-dts-rollup.js';
|
|
69
|
+
export { InfiniteQueryObserverRefetchErrorResult_alias_1 as InfiniteQueryObserverRefetchErrorResult } from './_tsup-dts-rollup.js';
|
|
70
|
+
export { InfiniteQueryObserverSuccessResult_alias_1 as InfiniteQueryObserverSuccessResult } from './_tsup-dts-rollup.js';
|
|
71
|
+
export { InfiniteQueryObserverPlaceholderResult_alias_1 as InfiniteQueryObserverPlaceholderResult } from './_tsup-dts-rollup.js';
|
|
72
|
+
export { DefinedInfiniteQueryObserverResult_alias_1 as DefinedInfiniteQueryObserverResult } from './_tsup-dts-rollup.js';
|
|
73
|
+
export { InfiniteQueryObserverResult_alias_1 as InfiniteQueryObserverResult } from './_tsup-dts-rollup.js';
|
|
74
|
+
export { MutationKey_alias_1 as MutationKey } from './_tsup-dts-rollup.js';
|
|
75
|
+
export { MutationStatus_alias_1 as MutationStatus } from './_tsup-dts-rollup.js';
|
|
76
|
+
export { MutationScope_alias_1 as MutationScope } from './_tsup-dts-rollup.js';
|
|
77
|
+
export { MutationMeta_alias_1 as MutationMeta } from './_tsup-dts-rollup.js';
|
|
78
|
+
export { MutationFunctionContext_alias_1 as MutationFunctionContext } from './_tsup-dts-rollup.js';
|
|
79
|
+
export { MutationFunction_alias_1 as MutationFunction } from './_tsup-dts-rollup.js';
|
|
80
|
+
export { MutationOptions_alias_1 as MutationOptions } from './_tsup-dts-rollup.js';
|
|
81
|
+
export { MutationObserverOptions_alias_1 as MutationObserverOptions } from './_tsup-dts-rollup.js';
|
|
82
|
+
export { MutateOptions_alias_1 as MutateOptions } from './_tsup-dts-rollup.js';
|
|
83
|
+
export { MutateFunction_alias_1 as MutateFunction } from './_tsup-dts-rollup.js';
|
|
84
|
+
export { MutationObserverBaseResult_alias_1 as MutationObserverBaseResult } from './_tsup-dts-rollup.js';
|
|
85
|
+
export { MutationObserverIdleResult_alias_1 as MutationObserverIdleResult } from './_tsup-dts-rollup.js';
|
|
86
|
+
export { MutationObserverLoadingResult_alias_1 as MutationObserverLoadingResult } from './_tsup-dts-rollup.js';
|
|
87
|
+
export { MutationObserverErrorResult_alias_1 as MutationObserverErrorResult } from './_tsup-dts-rollup.js';
|
|
88
|
+
export { MutationObserverSuccessResult_alias_1 as MutationObserverSuccessResult } from './_tsup-dts-rollup.js';
|
|
89
|
+
export { MutationObserverResult_alias_1 as MutationObserverResult } from './_tsup-dts-rollup.js';
|
|
90
|
+
export { QueryClientConfig_alias_1 as QueryClientConfig } from './_tsup-dts-rollup.js';
|
|
91
|
+
export { DefaultOptions_alias_1 as DefaultOptions } from './_tsup-dts-rollup.js';
|
|
92
|
+
export { CancelOptions_alias_1 as CancelOptions } from './_tsup-dts-rollup.js';
|
|
93
|
+
export { SetDataOptions_alias_1 as SetDataOptions } from './_tsup-dts-rollup.js';
|
|
94
|
+
export { NotifyEventType_alias_1 as NotifyEventType } from './_tsup-dts-rollup.js';
|
|
95
|
+
export { NotifyEvent_alias_1 as NotifyEvent } from './_tsup-dts-rollup.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import { timeoutManager } from './timeoutManager'\nimport type {\n DefaultError,\n Enabled,\n FetchStatus,\n MutationKey,\n MutationStatus,\n QueryFunction,\n QueryKey,\n QueryOptions,\n StaleTime,\n StaleTimeFunction,\n} from './types'\nimport type { Mutation } from './mutation'\nimport type { FetchOptions, Query } from './query'\n\n// TYPES\n\ntype DropLast<T extends ReadonlyArray<unknown>> = T extends readonly [\n ...infer R,\n unknown,\n]\n ? readonly [...R]\n : never\n\ntype TuplePrefixes<T extends ReadonlyArray<unknown>> = T extends readonly []\n ? readonly []\n : TuplePrefixes<DropLast<T>> | T\n\nexport interface QueryFilters<TQueryKey extends QueryKey = QueryKey> {\n /**\n * Filter to active queries, inactive queries or all queries\n */\n type?: QueryTypeFilter\n /**\n * Match query key exactly\n */\n exact?: boolean\n /**\n * Include queries matching this predicate function\n */\n predicate?: (query: Query) => boolean\n /**\n * Include queries matching this query key\n */\n queryKey?: TQueryKey | TuplePrefixes<TQueryKey>\n /**\n * Include or exclude stale queries\n */\n stale?: boolean\n /**\n * Include queries matching their fetchStatus\n */\n fetchStatus?: FetchStatus\n}\n\nexport interface MutationFilters<\n TData = unknown,\n TError = DefaultError,\n TVariables = unknown,\n TOnMutateResult = unknown,\n> {\n /**\n * Match mutation key exactly\n */\n exact?: boolean\n /**\n * Include mutations matching this predicate function\n */\n predicate?: (\n mutation: Mutation<TData, TError, TVariables, TOnMutateResult>,\n ) => boolean\n /**\n * Include mutations matching this mutation key\n */\n mutationKey?: TuplePrefixes<MutationKey>\n /**\n * Filter by mutation status\n */\n status?: MutationStatus\n}\n\nexport type Updater<TInput, TOutput> = TOutput | ((input: TInput) => TOutput)\n\nexport type QueryTypeFilter = 'all' | 'active' | 'inactive'\n\n// UTILS\n\nexport const isServer = typeof window === 'undefined' || 'Deno' in globalThis\n\nexport function noop(): void\nexport function noop(): undefined\nexport function noop() {}\n\nexport function functionalUpdate<TInput, TOutput>(\n updater: Updater<TInput, TOutput>,\n input: TInput,\n): TOutput {\n return typeof updater === 'function'\n ? (updater as (_: TInput) => TOutput)(input)\n : updater\n}\n\nexport function isValidTimeout(value: unknown): value is number {\n return typeof value === 'number' && value >= 0 && value !== Infinity\n}\n\nexport function timeUntilStale(updatedAt: number, staleTime?: number): number {\n return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0)\n}\n\nexport function resolveStaleTime<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n staleTime:\n | undefined\n | StaleTimeFunction<TQueryFnData, TError, TData, TQueryKey>,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n): StaleTime | undefined {\n return typeof staleTime === 'function' ? staleTime(query) : staleTime\n}\n\nexport function resolveEnabled<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n enabled: undefined | Enabled<TQueryFnData, TError, TData, TQueryKey>,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n): boolean | undefined {\n return typeof enabled === 'function' ? enabled(query) : enabled\n}\n\nexport function matchQuery(\n filters: QueryFilters,\n query: Query<any, any, any, any>,\n): boolean {\n const {\n type = 'all',\n exact,\n fetchStatus,\n predicate,\n queryKey,\n stale,\n } = filters\n\n if (queryKey) {\n if (exact) {\n if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {\n return false\n }\n } else if (!partialMatchKey(query.queryKey, queryKey)) {\n return false\n }\n }\n\n if (type !== 'all') {\n const isActive = query.isActive()\n if (type === 'active' && !isActive) {\n return false\n }\n if (type === 'inactive' && isActive) {\n return false\n }\n }\n\n if (typeof stale === 'boolean' && query.isStale() !== stale) {\n return false\n }\n\n if (fetchStatus && fetchStatus !== query.state.fetchStatus) {\n return false\n }\n\n if (predicate && !predicate(query)) {\n return false\n }\n\n return true\n}\n\nexport function matchMutation(\n filters: MutationFilters,\n mutation: Mutation<any, any>,\n): boolean {\n const { exact, status, predicate, mutationKey } = filters\n if (mutationKey) {\n if (!mutation.options.mutationKey) {\n return false\n }\n if (exact) {\n if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {\n return false\n }\n } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {\n return false\n }\n }\n\n if (status && mutation.state.status !== status) {\n return false\n }\n\n if (predicate && !predicate(mutation)) {\n return false\n }\n\n return true\n}\n\nexport function hashQueryKeyByOptions<TQueryKey extends QueryKey = QueryKey>(\n queryKey: TQueryKey,\n options?: Pick<QueryOptions<any, any, any, any>, 'queryKeyHashFn'>,\n): string {\n const hashFn = options?.queryKeyHashFn || hashKey\n return hashFn(queryKey)\n}\n\n/**\n * Default query & mutation keys hash function.\n * Hashes the value into a stable hash.\n */\nexport function hashKey(queryKey: QueryKey | MutationKey): string {\n return JSON.stringify(queryKey, (_, val) =>\n isPlainObject(val)\n ? Object.keys(val)\n .sort()\n .reduce((result, key) => {\n result[key] = val[key]\n return result\n }, {} as any)\n : val,\n )\n}\n\n/**\n * Checks if key `b` partially matches with key `a`.\n */\nexport function partialMatchKey(a: QueryKey, b: QueryKey): boolean\nexport function partialMatchKey(a: any, b: any): boolean {\n if (a === b) {\n return true\n }\n\n if (typeof a !== typeof b) {\n return false\n }\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]))\n }\n\n return false\n}\n\nconst hasOwn = Object.prototype.hasOwnProperty\n\n/**\n * This function returns `a` if `b` is deeply equal.\n * If not, it will replace any deeply equal children of `b` with those of `a`.\n * This can be used for structural sharing between JSON values for example.\n */\nexport function replaceEqualDeep<T>(a: unknown, b: T, depth?: number): T\nexport function replaceEqualDeep(a: any, b: any, depth = 0): any {\n if (a === b) {\n return a\n }\n\n if (depth > 500) return b\n\n const array = isPlainArray(a) && isPlainArray(b)\n\n if (!array && !(isPlainObject(a) && isPlainObject(b))) return b\n\n const aItems = array ? a : Object.keys(a)\n const aSize = aItems.length\n const bItems = array ? b : Object.keys(b)\n const bSize = bItems.length\n const copy: any = array ? new Array(bSize) : {}\n\n let equalItems = 0\n\n for (let i = 0; i < bSize; i++) {\n const key: any = array ? i : bItems[i]\n const aItem = a[key]\n const bItem = b[key]\n\n if (aItem === bItem) {\n copy[key] = aItem\n if (array ? i < aSize : hasOwn.call(a, key)) equalItems++\n continue\n }\n\n if (\n aItem === null ||\n bItem === null ||\n typeof aItem !== 'object' ||\n typeof bItem !== 'object'\n ) {\n copy[key] = bItem\n continue\n }\n\n const v = replaceEqualDeep(aItem, bItem, depth + 1)\n copy[key] = v\n if (v === aItem) equalItems++\n }\n\n return aSize === bSize && equalItems === aSize ? a : copy\n}\n\n/**\n * Shallow compare objects.\n */\nexport function shallowEqualObjects<T extends Record<string, any>>(\n a: T,\n b: T | undefined,\n): boolean {\n if (!b || Object.keys(a).length !== Object.keys(b).length) {\n return false\n }\n\n for (const key in a) {\n if (a[key] !== b[key]) {\n return false\n }\n }\n\n return true\n}\n\nexport function isPlainArray(value: unknown): value is Array<unknown> {\n return Array.isArray(value) && value.length === Object.keys(value).length\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\nexport function isPlainObject(o: any): o is Record<PropertyKey, unknown> {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has no constructor\n const ctor = o.constructor\n if (ctor === undefined) {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!prot.hasOwnProperty('isPrototypeOf')) {\n return false\n }\n\n // Handles Objects created by Object.create(<arbitrary prototype>)\n if (Object.getPrototypeOf(o) !== Object.prototype) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\nexport function sleep(timeout: number): Promise<void> {\n return new Promise((resolve) => {\n timeoutManager.setTimeout(resolve, timeout)\n })\n}\n\nexport function replaceData<\n TData,\n TOptions extends QueryOptions<any, any, any, any>,\n>(prevData: TData | undefined, data: TData, options: TOptions): TData {\n if (typeof options.structuralSharing === 'function') {\n return options.structuralSharing(prevData, data) as TData\n } else if (options.structuralSharing !== false) {\n if (process.env.NODE_ENV !== 'production') {\n try {\n return replaceEqualDeep(prevData, data)\n } catch (error) {\n console.error(\n `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`,\n )\n\n // Prevent the replaceEqualDeep from being called again down below.\n throw error\n }\n }\n // Structurally share data between prev and new data if needed\n return replaceEqualDeep(prevData, data)\n }\n return data\n}\n\nexport function keepPreviousData<T>(\n previousData: T | undefined,\n): T | undefined {\n return previousData\n}\n\nexport function addToEnd<T>(items: Array<T>, item: T, max = 0): Array<T> {\n const newItems = [...items, item]\n return max && newItems.length > max ? newItems.slice(1) : newItems\n}\n\nexport function addToStart<T>(items: Array<T>, item: T, max = 0): Array<T> {\n const newItems = [item, ...items]\n return max && newItems.length > max ? newItems.slice(0, -1) : newItems\n}\n\nexport const skipToken = Symbol()\nexport type SkipToken = typeof skipToken\n\nexport function ensureQueryFn<\n TQueryFnData = unknown,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: {\n queryFn?: QueryFunction<TQueryFnData, TQueryKey> | SkipToken\n queryHash?: string\n },\n fetchOptions?: FetchOptions<TQueryFnData>,\n): QueryFunction<TQueryFnData, TQueryKey> {\n if (process.env.NODE_ENV !== 'production') {\n if (options.queryFn === skipToken) {\n console.error(\n `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`,\n )\n }\n }\n\n // if we attempt to retry a fetch that was triggered from an initialPromise\n // when we don't have a queryFn yet, we can't retry, so we just return the already rejected initialPromise\n // if an observer has already mounted, we will be able to retry with that queryFn\n if (!options.queryFn && fetchOptions?.initialPromise) {\n return () => fetchOptions.initialPromise!\n }\n\n if (!options.queryFn || options.queryFn === skipToken) {\n return () =>\n Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`))\n }\n\n return options.queryFn\n}\n\nexport function shouldThrowError<T extends (...args: Array<any>) => boolean>(\n throwOnError: boolean | T | undefined,\n params: Parameters<T>,\n): boolean {\n // Allow throwOnError function to override throwing behavior on a per-error basis\n if (typeof throwOnError === 'function') {\n return throwOnError(...params)\n }\n\n return !!throwOnError\n}\n\nexport function addConsumeAwareSignal<T>(\n object: T,\n getSignal: () => AbortSignal,\n onCancelled: VoidFunction,\n): T & { signal: AbortSignal } {\n let consumed = false\n let signal: AbortSignal | undefined\n\n Object.defineProperty(object, 'signal', {\n enumerable: true,\n get: () => {\n signal ??= getSignal()\n if (consumed) {\n return signal\n }\n\n consumed = true\n if (signal.aborted) {\n onCancelled()\n } else {\n signal.addEventListener('abort', onCancelled, { once: true })\n }\n\n return signal\n },\n })\n\n return object as T & { signal: AbortSignal }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA+B;AAwFxB,IAAM,WAAW,OAAO,WAAW,eAAe,UAAU;AAI5D,SAAS,OAAO;AAAC;AAEjB,SAAS,iBACd,SACA,OACS;AACT,SAAO,OAAO,YAAY,aACrB,QAAmC,KAAK,IACzC;AACN;AAEO,SAAS,eAAe,OAAiC;AAC9D,SAAO,OAAO,UAAU,YAAY,SAAS,KAAK,UAAU;AAC9D;AAEO,SAAS,eAAe,WAAmB,WA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SAAS,MAAM,SAAS,MAAM,GAAG,EAAE,IAAI;AAChE;AAEO,IAAM,YAAY,uBAAO;AAGzB,SAAS,cAId,SAIA,cACwC;AACxC,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,QAAQ,YAAY,WAAW;AACjC,cAAQ;AAAA,QACN,yGAAyG,QAAQ,SAAS;AAAA,MAC5H;AAAA,IACF;AAAA,EACF;AAKA,MAAI,CAAC,QAAQ,WAAW,cAAc,gBAAgB;AACpD,WAAO,MAAM,aAAa;AAAA,EAC5B;AAEA,MAAI,CAAC,QAAQ,WAAW,QAAQ,YAAY,WAAW;AACrD,WAAO,MACL,QAAQ,OAAO,IAAI,MAAM,qBAAqB,QAAQ,SAAS,GAAG,CAAC;AAAA,EACvE;AAEA,SAAO,QAAQ;AACjB;AAEO,SAAS,iBACd,cACA,QACS;AAET,MAAI,OAAO,iBAAiB,YAAY;AACtC,WAAO,aAAa,GAAG,MAAM;AAAA,EAC/B;AAEA,SAAO,CAAC,CAAC;AACX;AAEO,SAAS,sBACd,QACA,WACA,aAC6B;AAC7B,MAAI,WAAW;AACf,MAAI;AAEJ,SAAO,eAAe,QAAQ,UAAU;AAAA,IACtC,YAAY;AAAA,IACZ,KAAK,MAAM;AACT,iBAAW,UAAU;AACrB,UAAI,UAAU;AACZ,eAAO;AAAA,MACT;AAEA,iBAAW;AACX,UAAI,OAAO,SAAS;AAClB,oBAAY;AAAA,MACd,OAAO;AACL,eAAO,iBAAiB,SAAS,aAAa,EAAE,MAAM,KAAK,CAAC;AAAA,MAC9D;AAEA,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import { timeoutManager } from './timeoutManager'\nimport type {\n DefaultError,\n Enabled,\n FetchStatus,\n MutationKey,\n MutationStatus,\n QueryFunction,\n QueryKey,\n QueryOptions,\n StaleTime,\n StaleTimeFunction,\n} from './types'\nimport type { Mutation } from './mutation'\nimport type { FetchOptions, Query } from './query'\n\n// TYPES\n\ntype DropLast<T extends ReadonlyArray<unknown>> = T extends readonly [\n ...infer R,\n unknown,\n]\n ? readonly [...R]\n : never\n\ntype TuplePrefixes<T extends ReadonlyArray<unknown>> = T extends readonly []\n ? readonly []\n : TuplePrefixes<DropLast<T>> | T\n\nexport interface QueryFilters<TQueryKey extends QueryKey = QueryKey> {\n /**\n * Filter to active queries, inactive queries or all queries\n */\n type?: QueryTypeFilter\n /**\n * Match query key exactly\n */\n exact?: boolean\n /**\n * Include queries matching this predicate function\n */\n predicate?: (query: Query) => boolean\n /**\n * Include queries matching this query key\n */\n queryKey?: TQueryKey | TuplePrefixes<TQueryKey>\n /**\n * Include or exclude stale queries\n */\n stale?: boolean\n /**\n * Include queries matching their fetchStatus\n */\n fetchStatus?: FetchStatus\n}\n\nexport interface MutationFilters<\n TData = unknown,\n TError = DefaultError,\n TVariables = unknown,\n TOnMutateResult = unknown,\n> {\n /**\n * Match mutation key exactly\n */\n exact?: boolean\n /**\n * Include mutations matching this predicate function\n */\n predicate?: (\n mutation: Mutation<TData, TError, TVariables, TOnMutateResult>,\n ) => boolean\n /**\n * Include mutations matching this mutation key\n */\n mutationKey?: TuplePrefixes<MutationKey>\n /**\n * Filter by mutation status\n */\n status?: MutationStatus\n}\n\nexport type Updater<TInput, TOutput> = TOutput | ((input: TInput) => TOutput)\n\nexport type QueryTypeFilter = 'all' | 'active' | 'inactive'\n\n// UTILS\n\n/** @deprecated\n * use `environmentManager.isServer()` instead.\n */\nexport const isServer = typeof window === 'undefined' || 'Deno' in globalThis\n\nexport function noop(): void\nexport function noop(): undefined\nexport function noop() {}\n\nexport function functionalUpdate<TInput, TOutput>(\n updater: Updater<TInput, TOutput>,\n input: TInput,\n): TOutput {\n return typeof updater === 'function'\n ? (updater as (_: TInput) => TOutput)(input)\n : updater\n}\n\nexport function isValidTimeout(value: unknown): value is number {\n return typeof value === 'number' && value >= 0 && value !== Infinity\n}\n\nexport function timeUntilStale(updatedAt: number, staleTime?: number): number {\n return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0)\n}\n\nexport function resolveStaleTime<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n staleTime:\n | undefined\n | StaleTimeFunction<TQueryFnData, TError, TData, TQueryKey>,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n): StaleTime | undefined {\n return typeof staleTime === 'function' ? staleTime(query) : staleTime\n}\n\nexport function resolveEnabled<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n enabled: undefined | Enabled<TQueryFnData, TError, TData, TQueryKey>,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n): boolean | undefined {\n return typeof enabled === 'function' ? enabled(query) : enabled\n}\n\nexport function matchQuery(\n filters: QueryFilters,\n query: Query<any, any, any, any>,\n): boolean {\n const {\n type = 'all',\n exact,\n fetchStatus,\n predicate,\n queryKey,\n stale,\n } = filters\n\n if (queryKey) {\n if (exact) {\n if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {\n return false\n }\n } else if (!partialMatchKey(query.queryKey, queryKey)) {\n return false\n }\n }\n\n if (type !== 'all') {\n const isActive = query.isActive()\n if (type === 'active' && !isActive) {\n return false\n }\n if (type === 'inactive' && isActive) {\n return false\n }\n }\n\n if (typeof stale === 'boolean' && query.isStale() !== stale) {\n return false\n }\n\n if (fetchStatus && fetchStatus !== query.state.fetchStatus) {\n return false\n }\n\n if (predicate && !predicate(query)) {\n return false\n }\n\n return true\n}\n\nexport function matchMutation(\n filters: MutationFilters,\n mutation: Mutation<any, any>,\n): boolean {\n const { exact, status, predicate, mutationKey } = filters\n if (mutationKey) {\n if (!mutation.options.mutationKey) {\n return false\n }\n if (exact) {\n if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {\n return false\n }\n } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {\n return false\n }\n }\n\n if (status && mutation.state.status !== status) {\n return false\n }\n\n if (predicate && !predicate(mutation)) {\n return false\n }\n\n return true\n}\n\nexport function hashQueryKeyByOptions<TQueryKey extends QueryKey = QueryKey>(\n queryKey: TQueryKey,\n options?: Pick<QueryOptions<any, any, any, any>, 'queryKeyHashFn'>,\n): string {\n const hashFn = options?.queryKeyHashFn || hashKey\n return hashFn(queryKey)\n}\n\n/**\n * Default query & mutation keys hash function.\n * Hashes the value into a stable hash.\n */\nexport function hashKey(queryKey: QueryKey | MutationKey): string {\n return JSON.stringify(queryKey, (_, val) =>\n isPlainObject(val)\n ? Object.keys(val)\n .sort()\n .reduce((result, key) => {\n result[key] = val[key]\n return result\n }, {} as any)\n : val,\n )\n}\n\n/**\n * Checks if key `b` partially matches with key `a`.\n */\nexport function partialMatchKey(a: QueryKey, b: QueryKey): boolean\nexport function partialMatchKey(a: any, b: any): boolean {\n if (a === b) {\n return true\n }\n\n if (typeof a !== typeof b) {\n return false\n }\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]))\n }\n\n return false\n}\n\nconst hasOwn = Object.prototype.hasOwnProperty\n\n/**\n * This function returns `a` if `b` is deeply equal.\n * If not, it will replace any deeply equal children of `b` with those of `a`.\n * This can be used for structural sharing between JSON values for example.\n */\nexport function replaceEqualDeep<T>(a: unknown, b: T, depth?: number): T\nexport function replaceEqualDeep(a: any, b: any, depth = 0): any {\n if (a === b) {\n return a\n }\n\n if (depth > 500) return b\n\n const array = isPlainArray(a) && isPlainArray(b)\n\n if (!array && !(isPlainObject(a) && isPlainObject(b))) return b\n\n const aItems = array ? a : Object.keys(a)\n const aSize = aItems.length\n const bItems = array ? b : Object.keys(b)\n const bSize = bItems.length\n const copy: any = array ? new Array(bSize) : {}\n\n let equalItems = 0\n\n for (let i = 0; i < bSize; i++) {\n const key: any = array ? i : bItems[i]\n const aItem = a[key]\n const bItem = b[key]\n\n if (aItem === bItem) {\n copy[key] = aItem\n if (array ? i < aSize : hasOwn.call(a, key)) equalItems++\n continue\n }\n\n if (\n aItem === null ||\n bItem === null ||\n typeof aItem !== 'object' ||\n typeof bItem !== 'object'\n ) {\n copy[key] = bItem\n continue\n }\n\n const v = replaceEqualDeep(aItem, bItem, depth + 1)\n copy[key] = v\n if (v === aItem) equalItems++\n }\n\n return aSize === bSize && equalItems === aSize ? a : copy\n}\n\n/**\n * Shallow compare objects.\n */\nexport function shallowEqualObjects<T extends Record<string, any>>(\n a: T,\n b: T | undefined,\n): boolean {\n if (!b || Object.keys(a).length !== Object.keys(b).length) {\n return false\n }\n\n for (const key in a) {\n if (a[key] !== b[key]) {\n return false\n }\n }\n\n return true\n}\n\nexport function isPlainArray(value: unknown): value is Array<unknown> {\n return Array.isArray(value) && value.length === Object.keys(value).length\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\nexport function isPlainObject(o: any): o is Record<PropertyKey, unknown> {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has no constructor\n const ctor = o.constructor\n if (ctor === undefined) {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!prot.hasOwnProperty('isPrototypeOf')) {\n return false\n }\n\n // Handles Objects created by Object.create(<arbitrary prototype>)\n if (Object.getPrototypeOf(o) !== Object.prototype) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\nexport function sleep(timeout: number): Promise<void> {\n return new Promise((resolve) => {\n timeoutManager.setTimeout(resolve, timeout)\n })\n}\n\nexport function replaceData<\n TData,\n TOptions extends QueryOptions<any, any, any, any>,\n>(prevData: TData | undefined, data: TData, options: TOptions): TData {\n if (typeof options.structuralSharing === 'function') {\n return options.structuralSharing(prevData, data) as TData\n } else if (options.structuralSharing !== false) {\n if (process.env.NODE_ENV !== 'production') {\n try {\n return replaceEqualDeep(prevData, data)\n } catch (error) {\n console.error(\n `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`,\n )\n\n // Prevent the replaceEqualDeep from being called again down below.\n throw error\n }\n }\n // Structurally share data between prev and new data if needed\n return replaceEqualDeep(prevData, data)\n }\n return data\n}\n\nexport function keepPreviousData<T>(\n previousData: T | undefined,\n): T | undefined {\n return previousData\n}\n\nexport function addToEnd<T>(items: Array<T>, item: T, max = 0): Array<T> {\n const newItems = [...items, item]\n return max && newItems.length > max ? newItems.slice(1) : newItems\n}\n\nexport function addToStart<T>(items: Array<T>, item: T, max = 0): Array<T> {\n const newItems = [item, ...items]\n return max && newItems.length > max ? newItems.slice(0, -1) : newItems\n}\n\nexport const skipToken = Symbol()\nexport type SkipToken = typeof skipToken\n\nexport function ensureQueryFn<\n TQueryFnData = unknown,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: {\n queryFn?: QueryFunction<TQueryFnData, TQueryKey> | SkipToken\n queryHash?: string\n },\n fetchOptions?: FetchOptions<TQueryFnData>,\n): QueryFunction<TQueryFnData, TQueryKey> {\n if (process.env.NODE_ENV !== 'production') {\n if (options.queryFn === skipToken) {\n console.error(\n `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`,\n )\n }\n }\n\n // if we attempt to retry a fetch that was triggered from an initialPromise\n // when we don't have a queryFn yet, we can't retry, so we just return the already rejected initialPromise\n // if an observer has already mounted, we will be able to retry with that queryFn\n if (!options.queryFn && fetchOptions?.initialPromise) {\n return () => fetchOptions.initialPromise!\n }\n\n if (!options.queryFn || options.queryFn === skipToken) {\n return () =>\n Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`))\n }\n\n return options.queryFn\n}\n\nexport function shouldThrowError<T extends (...args: Array<any>) => boolean>(\n throwOnError: boolean | T | undefined,\n params: Parameters<T>,\n): boolean {\n // Allow throwOnError function to override throwing behavior on a per-error basis\n if (typeof throwOnError === 'function') {\n return throwOnError(...params)\n }\n\n return !!throwOnError\n}\n\nexport function addConsumeAwareSignal<T>(\n object: T,\n getSignal: () => AbortSignal,\n onCancelled: VoidFunction,\n): T & { signal: AbortSignal } {\n let consumed = false\n let signal: AbortSignal | undefined\n\n Object.defineProperty(object, 'signal', {\n enumerable: true,\n get: () => {\n signal ??= getSignal()\n if (consumed) {\n return signal\n }\n\n consumed = true\n if (signal.aborted) {\n onCancelled()\n } else {\n signal.addEventListener('abort', onCancelled, { once: true })\n }\n\n return signal\n },\n })\n\n return object as T & { signal: AbortSignal }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA+B;AA2FxB,IAAM,WAAW,OAAO,WAAW,eAAe,UAAU;AAI5D,SAAS,OAAO;AAAC;AAEjB,SAAS,iBACd,SACA,OACS;AACT,SAAO,OAAO,YAAY,aACrB,QAAmC,KAAK,IACzC;AACN;AAEO,SAAS,eAAe,OAAiC;AAC9D,SAAO,OAAO,UAAU,YAAY,SAAS,KAAK,UAAU;AAC9D;AAEO,SAAS,eAAe,WAAmB,WAA4B;AAC5E,SAAO,KAAK,IAAI,aAAa,aAAa,KAAK,KAAK,IAAI,GAAG,CAAC;AAC9D;AAEO,SAAS,iBAMd,WAGA,OACuB;AACvB,SAAO,OAAO,cAAc,aAAa,UAAU,KAAK,IAAI;AAC9D;AAEO,SAAS,eAMd,SACA,OACqB;AACrB,SAAO,OAAO,YAAY,aAAa,QAAQ,KAAK,IAAI;AAC1D;AAEO,SAAS,WACd,SACA,OACS;AACT,QAAM;AAAA,IACJ,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AA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