@tanstack/query-core 4.1.3 → 4.3.0-beta.0
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/{types/packages/query-core/src → lib}/focusManager.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/hydration.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/index.d.ts +2 -2
- package/build/lib/index.js +3115 -0
- package/build/lib/index.js.map +1 -0
- package/build/{esm/index.js → lib/index.mjs} +3 -1
- package/build/lib/index.mjs.map +1 -0
- package/build/{types/packages/query-core/src → lib}/infiniteQueryBehavior.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/infiniteQueryObserver.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/logger.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/logger.native.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/mutation.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/mutationCache.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/mutationObserver.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/notifyManager.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/onlineManager.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/queriesObserver.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/query.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/queryCache.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/queryClient.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/queryObserver.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/removable.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/retryer.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/subscribable.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/types.d.ts +2 -1
- package/build/{types/packages/query-core/src → lib}/utils.d.ts +0 -0
- package/build/umd/index.development.js +2 -0
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +16 -8
- package/src/index.ts +2 -2
- package/src/tests/queryClient.test.tsx +33 -0
- package/src/types.ts +4 -1
- package/src/utils.ts +2 -0
- package/build/cjs/focusManager.js +0 -101
- package/build/cjs/focusManager.js.map +0 -1
- package/build/cjs/hydration.js +0 -112
- package/build/cjs/hydration.js.map +0 -1
- package/build/cjs/index.js +0 -51
- package/build/cjs/index.js.map +0 -1
- package/build/cjs/infiniteQueryBehavior.js +0 -160
- package/build/cjs/infiniteQueryBehavior.js.map +0 -1
- package/build/cjs/infiniteQueryObserver.js +0 -92
- package/build/cjs/infiniteQueryObserver.js.map +0 -1
- package/build/cjs/logger.js +0 -18
- package/build/cjs/logger.js.map +0 -1
- package/build/cjs/mutation.js +0 -258
- package/build/cjs/mutation.js.map +0 -1
- package/build/cjs/mutationCache.js +0 -99
- package/build/cjs/mutationCache.js.map +0 -1
- package/build/cjs/mutationObserver.js +0 -140
- package/build/cjs/mutationObserver.js.map +0 -1
- package/build/cjs/notifyManager.js +0 -114
- package/build/cjs/notifyManager.js.map +0 -1
- package/build/cjs/onlineManager.js +0 -100
- package/build/cjs/onlineManager.js.map +0 -1
- package/build/cjs/queriesObserver.js +0 -170
- package/build/cjs/queriesObserver.js.map +0 -1
- package/build/cjs/query.js +0 -474
- package/build/cjs/query.js.map +0 -1
- package/build/cjs/queryCache.js +0 -140
- package/build/cjs/queryCache.js.map +0 -1
- package/build/cjs/queryClient.js +0 -353
- package/build/cjs/queryClient.js.map +0 -1
- package/build/cjs/queryObserver.js +0 -529
- package/build/cjs/queryObserver.js.map +0 -1
- package/build/cjs/removable.js +0 -47
- package/build/cjs/removable.js.map +0 -1
- package/build/cjs/retryer.js +0 -177
- package/build/cjs/retryer.js.map +0 -1
- package/build/cjs/subscribable.js +0 -43
- package/build/cjs/subscribable.js.map +0 -1
- package/build/cjs/utils.js +0 -356
- package/build/cjs/utils.js.map +0 -1
- package/build/esm/index.js.map +0 -1
- package/build/stats-html.html +0 -2689
- package/build/stats.json +0 -811
- package/build/types/packages/query-core/src/tests/focusManager.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/hydration.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/infiniteQueryBehavior.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/infiniteQueryObserver.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/mutationCache.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/mutationObserver.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/mutations.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/notifyManager.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/onlineManager.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/queriesObserver.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/query.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/queryCache.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/queryClient.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/queryObserver.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/utils.test.d.ts +0 -1
- package/build/types/tests/utils.d.ts +0 -24
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* query-core
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var mutation = require('./mutation.js');
|
|
16
|
-
var notifyManager = require('./notifyManager.js');
|
|
17
|
-
var subscribable = require('./subscribable.js');
|
|
18
|
-
var utils = require('./utils.js');
|
|
19
|
-
|
|
20
|
-
// CLASS
|
|
21
|
-
class MutationObserver extends subscribable.Subscribable {
|
|
22
|
-
constructor(client, options) {
|
|
23
|
-
super();
|
|
24
|
-
this.client = client;
|
|
25
|
-
this.setOptions(options);
|
|
26
|
-
this.bindMethods();
|
|
27
|
-
this.updateResult();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
bindMethods() {
|
|
31
|
-
this.mutate = this.mutate.bind(this);
|
|
32
|
-
this.reset = this.reset.bind(this);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
setOptions(options) {
|
|
36
|
-
const prevOptions = this.options;
|
|
37
|
-
this.options = this.client.defaultMutationOptions(options);
|
|
38
|
-
|
|
39
|
-
if (!utils.shallowEqualObjects(prevOptions, this.options)) {
|
|
40
|
-
this.client.getMutationCache().notify({
|
|
41
|
-
type: 'observerOptionsUpdated',
|
|
42
|
-
mutation: this.currentMutation,
|
|
43
|
-
observer: this
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
onUnsubscribe() {
|
|
49
|
-
if (!this.listeners.length) {
|
|
50
|
-
var _this$currentMutation;
|
|
51
|
-
|
|
52
|
-
(_this$currentMutation = this.currentMutation) == null ? void 0 : _this$currentMutation.removeObserver(this);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
onMutationUpdate(action) {
|
|
57
|
-
this.updateResult(); // Determine which callbacks to trigger
|
|
58
|
-
|
|
59
|
-
const notifyOptions = {
|
|
60
|
-
listeners: true
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
if (action.type === 'success') {
|
|
64
|
-
notifyOptions.onSuccess = true;
|
|
65
|
-
} else if (action.type === 'error') {
|
|
66
|
-
notifyOptions.onError = true;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
this.notify(notifyOptions);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
getCurrentResult() {
|
|
73
|
-
return this.currentResult;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
reset() {
|
|
77
|
-
this.currentMutation = undefined;
|
|
78
|
-
this.updateResult();
|
|
79
|
-
this.notify({
|
|
80
|
-
listeners: true
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
mutate(variables, options) {
|
|
85
|
-
this.mutateOptions = options;
|
|
86
|
-
|
|
87
|
-
if (this.currentMutation) {
|
|
88
|
-
this.currentMutation.removeObserver(this);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
this.currentMutation = this.client.getMutationCache().build(this.client, { ...this.options,
|
|
92
|
-
variables: typeof variables !== 'undefined' ? variables : this.options.variables
|
|
93
|
-
});
|
|
94
|
-
this.currentMutation.addObserver(this);
|
|
95
|
-
return this.currentMutation.execute();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
updateResult() {
|
|
99
|
-
const state = this.currentMutation ? this.currentMutation.state : mutation.getDefaultState();
|
|
100
|
-
const result = { ...state,
|
|
101
|
-
isLoading: state.status === 'loading',
|
|
102
|
-
isSuccess: state.status === 'success',
|
|
103
|
-
isError: state.status === 'error',
|
|
104
|
-
isIdle: state.status === 'idle',
|
|
105
|
-
mutate: this.mutate,
|
|
106
|
-
reset: this.reset
|
|
107
|
-
};
|
|
108
|
-
this.currentResult = result;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
notify(options) {
|
|
112
|
-
notifyManager.notifyManager.batch(() => {
|
|
113
|
-
// First trigger the mutate callbacks
|
|
114
|
-
if (this.mutateOptions) {
|
|
115
|
-
if (options.onSuccess) {
|
|
116
|
-
var _this$mutateOptions$o, _this$mutateOptions, _this$mutateOptions$o2, _this$mutateOptions2;
|
|
117
|
-
|
|
118
|
-
(_this$mutateOptions$o = (_this$mutateOptions = this.mutateOptions).onSuccess) == null ? void 0 : _this$mutateOptions$o.call(_this$mutateOptions, this.currentResult.data, this.currentResult.variables, this.currentResult.context);
|
|
119
|
-
(_this$mutateOptions$o2 = (_this$mutateOptions2 = this.mutateOptions).onSettled) == null ? void 0 : _this$mutateOptions$o2.call(_this$mutateOptions2, this.currentResult.data, null, this.currentResult.variables, this.currentResult.context);
|
|
120
|
-
} else if (options.onError) {
|
|
121
|
-
var _this$mutateOptions$o3, _this$mutateOptions3, _this$mutateOptions$o4, _this$mutateOptions4;
|
|
122
|
-
|
|
123
|
-
(_this$mutateOptions$o3 = (_this$mutateOptions3 = this.mutateOptions).onError) == null ? void 0 : _this$mutateOptions$o3.call(_this$mutateOptions3, this.currentResult.error, this.currentResult.variables, this.currentResult.context);
|
|
124
|
-
(_this$mutateOptions$o4 = (_this$mutateOptions4 = this.mutateOptions).onSettled) == null ? void 0 : _this$mutateOptions$o4.call(_this$mutateOptions4, undefined, this.currentResult.error, this.currentResult.variables, this.currentResult.context);
|
|
125
|
-
}
|
|
126
|
-
} // Then trigger the listeners
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (options.listeners) {
|
|
130
|
-
this.listeners.forEach(listener => {
|
|
131
|
-
listener(this.currentResult);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
exports.MutationObserver = MutationObserver;
|
|
140
|
-
//# sourceMappingURL=mutationObserver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutationObserver.js","sources":["../../src/mutationObserver.ts"],"sourcesContent":["import { Action, getDefaultState, Mutation } from './mutation'\nimport { notifyManager } from './notifyManager'\nimport type { QueryClient } from './queryClient'\nimport { Subscribable } from './subscribable'\nimport type {\n MutateOptions,\n MutationObserverBaseResult,\n MutationObserverResult,\n MutationObserverOptions,\n} from './types'\nimport { shallowEqualObjects } from './utils'\n\n// TYPES\n\ntype MutationObserverListener<TData, TError, TVariables, TContext> = (\n result: MutationObserverResult<TData, TError, TVariables, TContext>,\n) => void\n\ninterface NotifyOptions {\n listeners?: boolean\n onError?: boolean\n onSuccess?: boolean\n}\n\n// CLASS\n\nexport class MutationObserver<\n TData = unknown,\n TError = unknown,\n TVariables = void,\n TContext = unknown,\n> extends Subscribable<\n MutationObserverListener<TData, TError, TVariables, TContext>\n> {\n options!: MutationObserverOptions<TData, TError, TVariables, TContext>\n\n private client: QueryClient\n private currentResult!: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n private currentMutation?: Mutation<TData, TError, TVariables, TContext>\n private mutateOptions?: MutateOptions<TData, TError, TVariables, TContext>\n\n constructor(\n client: QueryClient,\n options: MutationObserverOptions<TData, TError, TVariables, TContext>,\n ) {\n super()\n\n this.client = client\n this.setOptions(options)\n this.bindMethods()\n this.updateResult()\n }\n\n protected bindMethods(): void {\n this.mutate = this.mutate.bind(this)\n this.reset = this.reset.bind(this)\n }\n\n setOptions(\n options?: MutationObserverOptions<TData, TError, TVariables, TContext>,\n ) {\n const prevOptions = this.options\n this.options = this.client.defaultMutationOptions(options)\n if (!shallowEqualObjects(prevOptions, this.options)) {\n this.client.getMutationCache().notify({\n type: 'observerOptionsUpdated',\n mutation: this.currentMutation,\n observer: this,\n })\n }\n }\n\n protected onUnsubscribe(): void {\n if (!this.listeners.length) {\n this.currentMutation?.removeObserver(this)\n }\n }\n\n onMutationUpdate(action: Action<TData, TError, TVariables, TContext>): void {\n this.updateResult()\n\n // Determine which callbacks to trigger\n const notifyOptions: NotifyOptions = {\n listeners: true,\n }\n\n if (action.type === 'success') {\n notifyOptions.onSuccess = true\n } else if (action.type === 'error') {\n notifyOptions.onError = true\n }\n\n this.notify(notifyOptions)\n }\n\n getCurrentResult(): MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n > {\n return this.currentResult\n }\n\n reset(): void {\n this.currentMutation = undefined\n this.updateResult()\n this.notify({ listeners: true })\n }\n\n mutate(\n variables?: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TContext>,\n ): Promise<TData> {\n this.mutateOptions = options\n\n if (this.currentMutation) {\n this.currentMutation.removeObserver(this)\n }\n\n this.currentMutation = this.client.getMutationCache().build(this.client, {\n ...this.options,\n variables:\n typeof variables !== 'undefined' ? variables : this.options.variables,\n })\n\n this.currentMutation.addObserver(this)\n\n return this.currentMutation.execute()\n }\n\n private updateResult(): void {\n const state = this.currentMutation\n ? this.currentMutation.state\n : getDefaultState<TData, TError, TVariables, TContext>()\n\n const result: MutationObserverBaseResult<\n TData,\n TError,\n TVariables,\n TContext\n > = {\n ...state,\n isLoading: state.status === 'loading',\n isSuccess: state.status === 'success',\n isError: state.status === 'error',\n isIdle: state.status === 'idle',\n mutate: this.mutate,\n reset: this.reset,\n }\n\n this.currentResult = result as MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n }\n\n private notify(options: NotifyOptions) {\n notifyManager.batch(() => {\n // First trigger the mutate callbacks\n if (this.mutateOptions) {\n if (options.onSuccess) {\n this.mutateOptions.onSuccess?.(\n this.currentResult.data!,\n this.currentResult.variables!,\n this.currentResult.context!,\n )\n this.mutateOptions.onSettled?.(\n this.currentResult.data!,\n null,\n this.currentResult.variables!,\n this.currentResult.context,\n )\n } else if (options.onError) {\n this.mutateOptions.onError?.(\n this.currentResult.error!,\n this.currentResult.variables!,\n this.currentResult.context,\n )\n this.mutateOptions.onSettled?.(\n undefined,\n this.currentResult.error,\n this.currentResult.variables!,\n this.currentResult.context,\n )\n }\n }\n\n // Then trigger the listeners\n if (options.listeners) {\n this.listeners.forEach((listener) => {\n listener(this.currentResult)\n })\n }\n })\n }\n}\n"],"names":["MutationObserver","Subscribable","constructor","client","options","setOptions","bindMethods","updateResult","mutate","bind","reset","prevOptions","defaultMutationOptions","shallowEqualObjects","getMutationCache","notify","type","mutation","currentMutation","observer","onUnsubscribe","listeners","length","removeObserver","onMutationUpdate","action","notifyOptions","onSuccess","onError","getCurrentResult","currentResult","undefined","variables","mutateOptions","build","addObserver","execute","state","getDefaultState","result","isLoading","status","isSuccess","isError","isIdle","notifyManager","batch","data","context","onSettled","error","forEach","listener"],"mappings":";;;;;;;;;;;;;;;;;;;AAwBA;AAEO,MAAMA,gBAAN,S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D,GAAA;;AAzKD;;;;"}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* query-core
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var utils = require('./utils.js');
|
|
16
|
-
|
|
17
|
-
function createNotifyManager() {
|
|
18
|
-
let queue = [];
|
|
19
|
-
let transactions = 0;
|
|
20
|
-
|
|
21
|
-
let notifyFn = callback => {
|
|
22
|
-
callback();
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
let batchNotifyFn = callback => {
|
|
26
|
-
callback();
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const batch = callback => {
|
|
30
|
-
let result;
|
|
31
|
-
transactions++;
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
result = callback();
|
|
35
|
-
} finally {
|
|
36
|
-
transactions--;
|
|
37
|
-
|
|
38
|
-
if (!transactions) {
|
|
39
|
-
flush();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return result;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const schedule = callback => {
|
|
47
|
-
if (transactions) {
|
|
48
|
-
queue.push(callback);
|
|
49
|
-
} else {
|
|
50
|
-
utils.scheduleMicrotask(() => {
|
|
51
|
-
notifyFn(callback);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* All calls to the wrapped function will be batched.
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const batchCalls = callback => {
|
|
61
|
-
return (...args) => {
|
|
62
|
-
schedule(() => {
|
|
63
|
-
callback(...args);
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const flush = () => {
|
|
69
|
-
const originalQueue = queue;
|
|
70
|
-
queue = [];
|
|
71
|
-
|
|
72
|
-
if (originalQueue.length) {
|
|
73
|
-
utils.scheduleMicrotask(() => {
|
|
74
|
-
batchNotifyFn(() => {
|
|
75
|
-
originalQueue.forEach(callback => {
|
|
76
|
-
notifyFn(callback);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Use this method to set a custom notify function.
|
|
84
|
-
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const setNotifyFunction = fn => {
|
|
89
|
-
notifyFn = fn;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
93
|
-
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const setBatchNotifyFunction = fn => {
|
|
98
|
-
batchNotifyFn = fn;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
return {
|
|
102
|
-
batch,
|
|
103
|
-
batchCalls,
|
|
104
|
-
schedule,
|
|
105
|
-
setNotifyFunction,
|
|
106
|
-
setBatchNotifyFunction
|
|
107
|
-
};
|
|
108
|
-
} // SINGLETON
|
|
109
|
-
|
|
110
|
-
const notifyManager = createNotifyManager();
|
|
111
|
-
|
|
112
|
-
exports.createNotifyManager = createNotifyManager;
|
|
113
|
-
exports.notifyManager = notifyManager;
|
|
114
|
-
//# sourceMappingURL=notifyManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notifyManager.js","sources":["../../src/notifyManager.ts"],"sourcesContent":["import { scheduleMicrotask } from './utils'\n\n// TYPES\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\nexport function createNotifyManager() {\n let queue: NotifyCallback[] = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n\n const batch = <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n }\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleMicrotask(() => {\n notifyFn(callback)\n })\n }\n }\n\n /**\n * All calls to the wrapped function will be batched.\n */\n const batchCalls = <T extends Function>(callback: T): T => {\n return ((...args: any[]) => {\n schedule(() => {\n callback(...args)\n })\n }) as any\n }\n\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleMicrotask(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n const setNotifyFunction = (fn: NotifyFunction) => {\n notifyFn = fn\n }\n\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n const setBatchNotifyFunction = (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n }\n\n return {\n batch,\n batchCalls,\n schedule,\n setNotifyFunction,\n setBatchNotifyFunction,\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"names":["createNotifyManager","queue","transactions","notifyFn","callback","batchNotifyFn","batch","result","flush","schedule","push","scheduleMicrotask","batchCalls","args","originalQueue","length","forEach","setNotifyFunction","fn","setBatchNotifyFunction","notifyManager"],"mappings":";;;;;;;;;;;;;;;;AAUO,SAASA,mBAAT,GAA+B;EACpC,IAAIC,KAAu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AM;AAClBS,UAAAA,aAAa,CAACE,OAAd,CAAuBZ,QAAD,IAAc;YAClCD,QAAQ,CAACC,QAAD,CAAR,CAAA;WADF,CAAA,CAAA;AAGD,SAJY,CAAb,CAAA;AAKD,OANgB,CAAjB,CAAA;AAOD,KAAA;GAXH,CAAA;AAcA;AACF;AACA;AACA;;;EACE,MAAMa,iBAAiB,GAAIC,EAAD,IAAwB;AAChDf,IAAAA,QAAQ,GAAGe,EAAX,CAAA;GADF,CAAA;AAIA;AACF;AACA;AACA;;;EACE,MAAMC,sBAAsB,GAAID,EAAD,IAA6B;AAC1Db,IAAAA,aAAa,GAAGa,EAAhB,CAAA;GADF,CAAA;;EAIA,OAAO;IACLZ,KADK;IAELM,UAFK;IAGLH,QAHK;IAILQ,iBAJK;AAKLE,IAAAA,sBAAAA;GALF,CAAA;AAOD;;AAGYC,MAAAA,aAAa,GAAGpB,mBAAmB;;;;;"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* query-core
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var subscribable = require('./subscribable.js');
|
|
16
|
-
var utils = require('./utils.js');
|
|
17
|
-
|
|
18
|
-
class OnlineManager extends subscribable.Subscribable {
|
|
19
|
-
constructor() {
|
|
20
|
-
super();
|
|
21
|
-
|
|
22
|
-
this.setup = onOnline => {
|
|
23
|
-
// addEventListener does not exist in React Native, but window does
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
25
|
-
if (!utils.isServer && window.addEventListener) {
|
|
26
|
-
const listener = () => onOnline(); // Listen to online
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
window.addEventListener('online', listener, false);
|
|
30
|
-
window.addEventListener('offline', listener, false);
|
|
31
|
-
return () => {
|
|
32
|
-
// Be sure to unsubscribe if a new handler is set
|
|
33
|
-
window.removeEventListener('online', listener);
|
|
34
|
-
window.removeEventListener('offline', listener);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
onSubscribe() {
|
|
41
|
-
if (!this.cleanup) {
|
|
42
|
-
this.setEventListener(this.setup);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
onUnsubscribe() {
|
|
47
|
-
if (!this.hasListeners()) {
|
|
48
|
-
var _this$cleanup;
|
|
49
|
-
|
|
50
|
-
(_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
|
|
51
|
-
this.cleanup = undefined;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
setEventListener(setup) {
|
|
56
|
-
var _this$cleanup2;
|
|
57
|
-
|
|
58
|
-
this.setup = setup;
|
|
59
|
-
(_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
|
|
60
|
-
this.cleanup = setup(online => {
|
|
61
|
-
if (typeof online === 'boolean') {
|
|
62
|
-
this.setOnline(online);
|
|
63
|
-
} else {
|
|
64
|
-
this.onOnline();
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
setOnline(online) {
|
|
70
|
-
this.online = online;
|
|
71
|
-
|
|
72
|
-
if (online) {
|
|
73
|
-
this.onOnline();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
onOnline() {
|
|
78
|
-
this.listeners.forEach(listener => {
|
|
79
|
-
listener();
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
isOnline() {
|
|
84
|
-
if (typeof this.online === 'boolean') {
|
|
85
|
-
return this.online;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (typeof navigator === 'undefined' || typeof navigator.onLine === 'undefined') {
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return navigator.onLine;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
const onlineManager = new OnlineManager();
|
|
97
|
-
|
|
98
|
-
exports.OnlineManager = OnlineManager;
|
|
99
|
-
exports.onlineManager = onlineManager;
|
|
100
|
-
//# sourceMappingURL=onlineManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onlineManager.js","sources":["../../src/onlineManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\nimport { isServer } from './utils'\n\ntype SetupFn = (\n setOnline: (online?: boolean) => void,\n) => (() => void) | undefined\n\nexport class OnlineManager extends Subscribable {\n private online?: boolean\n private cleanup?: () => void\n\n private setup: SetupFn\n\n constructor() {\n super()\n this.setup = (onOnline) => {\n // addEventListener does not exist in React Native, but window does\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!isServer && window.addEventListener) {\n const listener = () => onOnline()\n // Listen to online\n window.addEventListener('online', listener, false)\n window.addEventListener('offline', listener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('online', listener)\n window.removeEventListener('offline', listener)\n }\n }\n }\n }\n\n protected onSubscribe(): void {\n if (!this.cleanup) {\n this.setEventListener(this.setup)\n }\n }\n\n protected onUnsubscribe() {\n if (!this.hasListeners()) {\n this.cleanup?.()\n this.cleanup = undefined\n }\n }\n\n setEventListener(setup: SetupFn): void {\n this.setup = setup\n this.cleanup?.()\n this.cleanup = setup((online?: boolean) => {\n if (typeof online === 'boolean') {\n this.setOnline(online)\n } else {\n this.onOnline()\n }\n })\n }\n\n setOnline(online?: boolean): void {\n this.online = online\n\n if (online) {\n this.onOnline()\n }\n }\n\n onOnline(): void {\n this.listeners.forEach((listener) => {\n listener()\n })\n }\n\n isOnline(): boolean {\n if (typeof this.online === 'boolean') {\n return this.online\n }\n\n if (\n typeof navigator === 'undefined' ||\n typeof navigator.onLine === 'undefined'\n ) {\n return true\n }\n\n return navigator.onLine\n }\n}\n\nexport const onlineManager = new OnlineManager()\n"],"names":["OnlineManager","Subscribable","constructor","setup","onOnline","isServer","window","addEventListener","listener","removeEventListener","onSubscribe","cleanup","setEventListener","onUnsubscribe","hasListeners","undefined","online","setOnline","listeners","forEach","isOnline","navigator","onLine","onlineManager"],"mappings":";;;;;;;;;;;;;;;;;AAOO,MAAMA,aAAN,SAA4BC,yBAA5B,CAAyC;AAM9CC,EAAAA,WAAW,GAAG;AACZ,IAAA,KAAA,EAAA,CAAA;;IACA,IAAKC,CAAAA,KAAL,GAAcC,QAAD,IAAc;AACzB;AACA;AACA,MAAA,IAAI,CAACC,cAAD,IAAaC,MAAM,CAACC,gBAAxB,EAA0C;AACxC,QAAA,MAAMC,QAAQ,GAAG,MAAMJ,QAAQ,EAA/B,CADwC;;;AAGxCE,QAAAA,MAAM,CAACC,gBAAP,CAAwB,QAAxB,EAAkCC,QAAlC,EAA4C,KAA5C,CAAA,CAAA;AACAF,QAAAA,MAAM,CAACC,gBAAP,CAAwB,SAAxB,EAAmCC,QAAnC,EAA6C,KAA7C,CAAA,CAAA;AAEA,QAAA,OAAO,MAAM;AACX;AACAF,UAAAA,MAAM,CAACG,mBAAP,CAA2B,QAA3B,EAAqCD,QAArC,CAAA,CAAA;AACAF,UAAAA,MAAM,CAACG,mBAAP,CAA2B,SAA3B,EAAsCD,QAAtC,CAAA,CAAA;SAHF,CAAA;AAKD,OAAA;KAdH,CAAA;AAgBD,GAAA;;AAESE,EAAAA,WAAW,GAAS;IAC5B,IAAI,CAAC,IAAKC,CAAAA,OAAV,EAAmB;MACjB,IAAKC,CAAAA,gBAAL,CAAsB,IAAA,CAAKT,KAA3B,CAAA,CAAA;AACD,KAAA;AACF,GAAA;;AAESU,EAAAA,aAAa,GAAG;A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AAO,KAAKA,MAAZ,CAAA;AACD,KAAA;;IAED,IACE,OAAOK,SAAP,KAAqB,WAArB,IACA,OAAOA,SAAS,CAACC,MAAjB,KAA4B,WAF9B,EAGE;AACA,MAAA,OAAO,IAAP,CAAA;AACD,KAAA;;IAED,OAAOD,SAAS,CAACC,MAAjB,CAAA;AACD,GAAA;;AA9E6C,CAAA;AAiFnCC,MAAAA,aAAa,GAAG,IAAIvB,aAAJ;;;;;"}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* query-core
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var utils = require('./utils.js');
|
|
16
|
-
var notifyManager = require('./notifyManager.js');
|
|
17
|
-
var queryObserver = require('./queryObserver.js');
|
|
18
|
-
var subscribable = require('./subscribable.js');
|
|
19
|
-
|
|
20
|
-
class QueriesObserver extends subscribable.Subscribable {
|
|
21
|
-
constructor(client, queries) {
|
|
22
|
-
super();
|
|
23
|
-
this.client = client;
|
|
24
|
-
this.queries = [];
|
|
25
|
-
this.result = [];
|
|
26
|
-
this.observers = [];
|
|
27
|
-
this.observersMap = {};
|
|
28
|
-
|
|
29
|
-
if (queries) {
|
|
30
|
-
this.setQueries(queries);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
onSubscribe() {
|
|
35
|
-
if (this.listeners.length === 1) {
|
|
36
|
-
this.observers.forEach(observer => {
|
|
37
|
-
observer.subscribe(result => {
|
|
38
|
-
this.onUpdate(observer, result);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
onUnsubscribe() {
|
|
45
|
-
if (!this.listeners.length) {
|
|
46
|
-
this.destroy();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
destroy() {
|
|
51
|
-
this.listeners = [];
|
|
52
|
-
this.observers.forEach(observer => {
|
|
53
|
-
observer.destroy();
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
setQueries(queries, notifyOptions) {
|
|
58
|
-
this.queries = queries;
|
|
59
|
-
notifyManager.notifyManager.batch(() => {
|
|
60
|
-
const prevObservers = this.observers;
|
|
61
|
-
const newObserverMatches = this.findMatchingObservers(this.queries); // set options for the new observers to notify of changes
|
|
62
|
-
|
|
63
|
-
newObserverMatches.forEach(match => match.observer.setOptions(match.defaultedQueryOptions, notifyOptions));
|
|
64
|
-
const newObservers = newObserverMatches.map(match => match.observer);
|
|
65
|
-
const newObserversMap = Object.fromEntries(newObservers.map(observer => [observer.options.queryHash, observer]));
|
|
66
|
-
const newResult = newObservers.map(observer => observer.getCurrentResult());
|
|
67
|
-
const hasIndexChange = newObservers.some((observer, index) => observer !== prevObservers[index]);
|
|
68
|
-
|
|
69
|
-
if (prevObservers.length === newObservers.length && !hasIndexChange) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
this.observers = newObservers;
|
|
74
|
-
this.observersMap = newObserversMap;
|
|
75
|
-
this.result = newResult;
|
|
76
|
-
|
|
77
|
-
if (!this.hasListeners()) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
utils.difference(prevObservers, newObservers).forEach(observer => {
|
|
82
|
-
observer.destroy();
|
|
83
|
-
});
|
|
84
|
-
utils.difference(newObservers, prevObservers).forEach(observer => {
|
|
85
|
-
observer.subscribe(result => {
|
|
86
|
-
this.onUpdate(observer, result);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
this.notify();
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
getCurrentResult() {
|
|
94
|
-
return this.result;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
getOptimisticResult(queries) {
|
|
98
|
-
return this.findMatchingObservers(queries).map(match => match.observer.getOptimisticResult(match.defaultedQueryOptions));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
findMatchingObservers(queries) {
|
|
102
|
-
const prevObservers = this.observers;
|
|
103
|
-
const defaultedQueryOptions = queries.map(options => this.client.defaultQueryOptions(options));
|
|
104
|
-
const matchingObservers = defaultedQueryOptions.flatMap(defaultedOptions => {
|
|
105
|
-
const match = prevObservers.find(observer => observer.options.queryHash === defaultedOptions.queryHash);
|
|
106
|
-
|
|
107
|
-
if (match != null) {
|
|
108
|
-
return [{
|
|
109
|
-
defaultedQueryOptions: defaultedOptions,
|
|
110
|
-
observer: match
|
|
111
|
-
}];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return [];
|
|
115
|
-
});
|
|
116
|
-
const matchedQueryHashes = matchingObservers.map(match => match.defaultedQueryOptions.queryHash);
|
|
117
|
-
const unmatchedQueries = defaultedQueryOptions.filter(defaultedOptions => !matchedQueryHashes.includes(defaultedOptions.queryHash));
|
|
118
|
-
const unmatchedObservers = prevObservers.filter(prevObserver => !matchingObservers.some(match => match.observer === prevObserver));
|
|
119
|
-
|
|
120
|
-
const getObserver = options => {
|
|
121
|
-
const defaultedOptions = this.client.defaultQueryOptions(options);
|
|
122
|
-
const currentObserver = this.observersMap[defaultedOptions.queryHash];
|
|
123
|
-
return currentObserver != null ? currentObserver : new queryObserver.QueryObserver(this.client, defaultedOptions);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const newOrReusedObservers = unmatchedQueries.map((options, index) => {
|
|
127
|
-
if (options.keepPreviousData) {
|
|
128
|
-
// return previous data from one of the observers that no longer match
|
|
129
|
-
const previouslyUsedObserver = unmatchedObservers[index];
|
|
130
|
-
|
|
131
|
-
if (previouslyUsedObserver !== undefined) {
|
|
132
|
-
return {
|
|
133
|
-
defaultedQueryOptions: options,
|
|
134
|
-
observer: previouslyUsedObserver
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
defaultedQueryOptions: options,
|
|
141
|
-
observer: getObserver(options)
|
|
142
|
-
};
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const sortMatchesByOrderOfQueries = (a, b) => defaultedQueryOptions.indexOf(a.defaultedQueryOptions) - defaultedQueryOptions.indexOf(b.defaultedQueryOptions);
|
|
146
|
-
|
|
147
|
-
return matchingObservers.concat(newOrReusedObservers).sort(sortMatchesByOrderOfQueries);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
onUpdate(observer, result) {
|
|
151
|
-
const index = this.observers.indexOf(observer);
|
|
152
|
-
|
|
153
|
-
if (index !== -1) {
|
|
154
|
-
this.result = utils.replaceAt(this.result, index, result);
|
|
155
|
-
this.notify();
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
notify() {
|
|
160
|
-
notifyManager.notifyManager.batch(() => {
|
|
161
|
-
this.listeners.forEach(listener => {
|
|
162
|
-
listener(this.result);
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
exports.QueriesObserver = QueriesObserver;
|
|
170
|
-
//# sourceMappingURL=queriesObserver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queriesObserver.js","sources":["../../src/queriesObserver.ts"],"sourcesContent":["import { difference, replaceAt } from './utils'\nimport { notifyManager } from './notifyManager'\nimport type {\n QueryObserverOptions,\n QueryObserverResult,\n DefaultedQueryObserverOptions,\n} from './types'\nimport type { QueryClient } from './queryClient'\nimport { NotifyOptions, QueryObserver } from './queryObserver'\nimport { Subscribable } from './subscribable'\n\ntype QueriesObserverListener = (result: QueryObserverResult[]) => void\n\nexport class QueriesObserver extends Subscribable<QueriesObserverListener> {\n private client: QueryClient\n private result: QueryObserverResult[]\n private queries: QueryObserverOptions[]\n private observers: QueryObserver[]\n private observersMap: Record<string, QueryObserver>\n\n constructor(client: QueryClient, queries?: QueryObserverOptions[]) {\n super()\n\n this.client = client\n this.queries = []\n this.result = []\n this.observers = []\n this.observersMap = {}\n\n if (queries) {\n this.setQueries(queries)\n }\n }\n\n protected onSubscribe(): void {\n if (this.listeners.length === 1) {\n this.observers.forEach((observer) => {\n observer.subscribe((result) => {\n this.onUpdate(observer, result)\n })\n })\n }\n }\n\n protected onUnsubscribe(): void {\n if (!this.listeners.length) {\n this.destroy()\n }\n }\n\n destroy(): void {\n this.listeners = []\n this.observers.forEach((observer) => {\n observer.destroy()\n })\n }\n\n setQueries(\n queries: QueryObserverOptions[],\n notifyOptions?: NotifyOptions,\n ): void {\n this.queries = queries\n\n notifyManager.batch(() => {\n const prevObservers = this.observers\n\n const newObserverMatches = this.findMatchingObservers(this.queries)\n\n // set options for the new observers to notify of changes\n newObserverMatches.forEach((match) =>\n match.observer.setOptions(match.defaultedQueryOptions, notifyOptions),\n )\n\n const newObservers = newObserverMatches.map((match) => match.observer)\n const newObserversMap = Object.fromEntries(\n newObservers.map((observer) => [observer.options.queryHash, observer]),\n )\n const newResult = newObservers.map((observer) =>\n observer.getCurrentResult(),\n )\n\n const hasIndexChange = newObservers.some(\n (observer, index) => observer !== prevObservers[index],\n )\n if (prevObservers.length === newObservers.length && !hasIndexChange) {\n return\n }\n\n this.observers = newObservers\n this.observersMap = newObserversMap\n this.result = newResult\n\n if (!this.hasListeners()) {\n return\n }\n\n difference(prevObservers, newObservers).forEach((observer) => {\n observer.destroy()\n })\n\n difference(newObservers, prevObservers).forEach((observer) => {\n observer.subscribe((result) => {\n this.onUpdate(observer, result)\n })\n })\n\n this.notify()\n })\n }\n\n getCurrentResult(): QueryObserverResult[] {\n return this.result\n }\n\n getOptimisticResult(queries: QueryObserverOptions[]): QueryObserverResult[] {\n return this.findMatchingObservers(queries).map((match) =>\n match.observer.getOptimisticResult(match.defaultedQueryOptions),\n )\n }\n\n private findMatchingObservers(\n queries: QueryObserverOptions[],\n ): QueryObserverMatch[] {\n const prevObservers = this.observers\n const defaultedQueryOptions = queries.map((options) =>\n this.client.defaultQueryOptions(options),\n )\n\n const matchingObservers: QueryObserverMatch[] =\n defaultedQueryOptions.flatMap((defaultedOptions) => {\n const match = prevObservers.find(\n (observer) =>\n observer.options.queryHash === defaultedOptions.queryHash,\n )\n if (match != null) {\n return [{ defaultedQueryOptions: defaultedOptions, observer: match }]\n }\n return []\n })\n\n const matchedQueryHashes = matchingObservers.map(\n (match) => match.defaultedQueryOptions.queryHash,\n )\n const unmatchedQueries = defaultedQueryOptions.filter(\n (defaultedOptions) =>\n !matchedQueryHashes.includes(defaultedOptions.queryHash),\n )\n\n const unmatchedObservers = prevObservers.filter(\n (prevObserver) =>\n !matchingObservers.some((match) => match.observer === prevObserver),\n )\n\n const getObserver = (options: QueryObserverOptions): QueryObserver => {\n const defaultedOptions = this.client.defaultQueryOptions(options)\n const currentObserver = this.observersMap[defaultedOptions.queryHash!]\n return currentObserver ?? new QueryObserver(this.client, defaultedOptions)\n }\n\n const newOrReusedObservers: QueryObserverMatch[] = unmatchedQueries.map(\n (options, index) => {\n if (options.keepPreviousData) {\n // return previous data from one of the observers that no longer match\n const previouslyUsedObserver = unmatchedObservers[index]\n if (previouslyUsedObserver !== undefined) {\n return {\n defaultedQueryOptions: options,\n observer: previouslyUsedObserver,\n }\n }\n }\n return {\n defaultedQueryOptions: options,\n observer: getObserver(options),\n }\n },\n )\n\n const sortMatchesByOrderOfQueries = (\n a: QueryObserverMatch,\n b: QueryObserverMatch,\n ): number =>\n defaultedQueryOptions.indexOf(a.defaultedQueryOptions) -\n defaultedQueryOptions.indexOf(b.defaultedQueryOptions)\n\n return matchingObservers\n .concat(newOrReusedObservers)\n .sort(sortMatchesByOrderOfQueries)\n }\n\n private onUpdate(observer: QueryObserver, result: QueryObserverResult): void {\n const index = this.observers.indexOf(observer)\n if (index !== -1) {\n this.result = replaceAt(this.result, index, result)\n this.notify()\n }\n }\n\n private notify(): void {\n notifyManager.batch(() => {\n this.listeners.forEach((listener) => {\n listener(this.result)\n })\n })\n }\n}\n\ntype QueryObserverMatch = {\n defaultedQueryOptions: DefaultedQueryObserverOptions\n observer: QueryObserver\n}\n"],"names":["QueriesObserver","Subscribable","constructor","client","queries","result","observers","observersMap","setQueries","onSubscribe","listeners","length","forEach","observer","subscribe","onUpdate","onUnsubscribe","destroy","notifyOptions","notifyManager","batch","prevObservers","newObserverMatches","findMatchingObservers","match","setOptions","defaultedQueryOptions","newObservers","map","newObserversMap","Object","fromEntries","options","queryHash","newResult","getCurrentResult","hasIndexChange","some","index","hasListeners","difference","notify","getOptimisticResult","defaultQueryOptions","matchingObservers","flatMap","defaultedOptions","find","matchedQueryHashes","unmatchedQueries","filter","includes","unmatchedObservers","prevObserver","getObserver","currentObserver","QueryObserver","newOrReusedObservers","keepPreviousData","previouslyUsedObserver","undefined","sortMatchesByOrderOfQueries","a","b","indexOf","concat","sort","replaceAt","listener"],"mappings":";;;;;;;;;;;;;;;;;;;AAaO,MAAMA,eAAN,SAA8BC,yBAA9B,CAAoE;AAOzEC,EAAAA,WAAW,CAACC,MAAD,EAAsBC,OAAtB,EAAwD;AACjE,IAAA,KAAA,EAAA,CAAA;IAEA,IAAKD,CAAAA,MAAL,GAAcA,MAAd,CAAA;IACA,IAAKC,CAAAA,OAAL,GAAe,EAAf,CAAA;IACA,IAAKC,CAAAA,MAAL,GAAc,EAAd,CAAA;IACA,IAAKC,CAAAA,SAAL,GAAiB,EAAjB,CAAA;IACA,IAAKC,CAAAA,YAAL,GAAoB,EAApB,CAAA;;AAEA,IAAA,IAAIH,OAAJ,EAAa;MACX,IAAKI,CAAAA,UAAL,CAAgBJ,OAAhB,CAAA,CAAA;AACD,KAAA;AACF,GAAA;;AAESK,EAAAA,WAAW,GAAS;AAC5B,IAAA,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