Skip to content

Instantly share code, notes, and snippets.

@ovistoica
Created June 7, 2024 07:19
Show Gist options
  • Save ovistoica/5ac1f11d4394cc22b4bdbbed44c754e9 to your computer and use it in GitHub Desktop.
Save ovistoica/5ac1f11d4394cc22b4bdbbed44c754e9 to your computer and use it in GitHub Desktop.
Patch for @tanstack/query-core to work correctly with ClojureScript and Google Closure compiler
diff --git a/node_modules/@tanstack/query-core/build/modern/focusManager.cjs b/node_modules/@tanstack/query-core/build/modern/focusManager.cjs
index 7e872d0..930e91d 100644
--- a/node_modules/@tanstack/query-core/build/modern/focusManager.cjs
+++ b/node_modules/@tanstack/query-core/build/modern/focusManager.cjs
@@ -4,91 +4,98 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
- for (var name in all)
- __defProp(target, name, { get: all[name], enumerable: true });
+ for (var name in all)
+ __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
- if (from && typeof from === "object" || typeof from === "function") {
- for (let key of __getOwnPropNames(from))
- if (!__hasOwnProp.call(to, key) && key !== except)
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
- }
- return to;
+ if ((from && typeof from === "object") || typeof from === "function") {
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key) && key !== except)
+ __defProp(to, key, {
+ get: () => from[key],
+ enumerable:
+ !(desc = __getOwnPropDesc(from, key)) ||
+ desc.enumerable,
+ });
+ }
+ return to;
};
-var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
+var __toCommonJS = (mod) =>
+ __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/focusManager.ts
var focusManager_exports = {};
__export(focusManager_exports, {
- FocusManager: () => FocusManager,
- focusManager: () => focusManager
+ FocusManager: () => FocusManager,
+ focusManager: () => focusManager,
});
module.exports = __toCommonJS(focusManager_exports);
var import_subscribable = require("./subscribable.cjs");
var import_utils = require("./utils.cjs");
var FocusManager = class extends import_subscribable.Subscribable {
- #focused;
- #cleanup;
- #setup;
- constructor() {
- super();
- this.#setup = (onFocus) => {
- if (!import_utils.isServer && window.addEventListener) {
- const listener = () => onFocus();
- window.addEventListener("visibilitychange", listener, false);
- return () => {
- window.removeEventListener("visibilitychange", listener);
+ focused;
+ cleanup;
+ setup;
+ constructor() {
+ super();
+ this.setup = (onFocus) => {
+ if (!import_utils.isServer && window.addEventListener) {
+ const listener = () => onFocus();
+ window.addEventListener("visibilitychange", listener, false);
+ return () => {
+ window.removeEventListener("visibilitychange", listener);
+ };
+ }
+ return;
};
- }
- return;
- };
- }
- onSubscribe() {
- if (!this.#cleanup) {
- this.setEventListener(this.#setup);
}
- }
- onUnsubscribe() {
- if (!this.hasListeners()) {
- this.#cleanup?.();
- this.#cleanup = void 0;
+ onSubscribe() {
+ if (!this.cleanup) {
+ this.setEventListener(this.setup);
+ }
}
- }
- setEventListener(setup) {
- this.#setup = setup;
- this.#cleanup?.();
- this.#cleanup = setup((focused) => {
- if (typeof focused === "boolean") {
- this.setFocused(focused);
- } else {
- this.onFocus();
- }
- });
- }
- setFocused(focused) {
- const changed = this.#focused !== focused;
- if (changed) {
- this.#focused = focused;
- this.onFocus();
+ onUnsubscribe() {
+ if (!this.hasListeners()) {
+ this.cleanup?.();
+ this.cleanup = void 0;
+ }
}
- }
- onFocus() {
- const isFocused = this.isFocused();
- this.listeners.forEach((listener) => {
- listener(isFocused);
- });
- }
- isFocused() {
- if (typeof this.#focused === "boolean") {
- return this.#focused;
+ setEventListener(setup) {
+ this.setup = setup;
+ this.cleanup?.();
+ this.cleanup = setup((focused) => {
+ if (typeof focused === "boolean") {
+ this.setFocused(focused);
+ } else {
+ this.onFocus();
+ }
+ });
+ }
+ setFocused(focused) {
+ const changed = this.focused !== focused;
+ if (changed) {
+ this.focused = focused;
+ this.onFocus();
+ }
+ }
+ onFocus() {
+ const isFocused = this.isFocused();
+ this.listeners.forEach((listener) => {
+ listener(isFocused);
+ });
+ }
+ isFocused() {
+ if (typeof this.focused === "boolean") {
+ return this.focused;
+ }
+ return globalThis.document?.visibilityState !== "hidden";
}
- return globalThis.document?.visibilityState !== "hidden";
- }
};
var focusManager = new FocusManager();
// Annotate the CommonJS export names for ESM import in node:
-0 && (module.exports = {
- FocusManager,
- focusManager
-});
+0 &&
+ (module.exports = {
+ FocusManager,
+ focusManager,
+ });
//# sourceMappingURL=focusManager.cjs.map
diff --git a/node_modules/@tanstack/query-core/build/modern/mutation.cjs b/node_modules/@tanstack/query-core/build/modern/mutation.cjs
index 9929e8e..30cbe18 100644
--- a/node_modules/@tanstack/query-core/build/modern/mutation.cjs
+++ b/node_modules/@tanstack/query-core/build/modern/mutation.cjs
@@ -28,14 +28,14 @@ var import_notifyManager = require("./notifyManager.cjs");
var import_removable = require("./removable.cjs");
var import_retryer = require("./retryer.cjs");
var Mutation = class extends import_removable.Removable {
- #observers;
- #mutationCache;
- #retryer;
+ observers;
+ mutationCache;
+ retryer;
constructor(config) {
super();
this.mutationId = config.mutationId;
- this.#mutationCache = config.mutationCache;
- this.#observers = [];
+ this.mutationCache = config.mutationCache;
+ this.observers = [];
this.state = config.state || getDefaultState();
this.setOptions(config.options);
this.scheduleGc();
@@ -48,10 +48,10 @@ var Mutation = class extends import_removable.Removable {
return this.options.meta;
}
addObserver(observer) {
- if (!this.#observers.includes(observer)) {
- this.#observers.push(observer);
+ if (!this.observers.includes(observer)) {
+ this.observers.push(observer);
this.clearGcTimeout();
- this.#mutationCache.notify({
+ this.mutationCache.notify({
type: "observerAdded",
mutation: this,
observer
@@ -59,29 +59,29 @@ var Mutation = class extends import_removable.Removable {
}
}
removeObserver(observer) {
- this.#observers = this.#observers.filter((x) => x !== observer);
+ this.observers = this.observers.filter((x) => x !== observer);
this.scheduleGc();
- this.#mutationCache.notify({
+ this.mutationCache.notify({
type: "observerRemoved",
mutation: this,
observer
});
}
optionalRemove() {
- if (!this.#observers.length) {
+ if (!this.observers.length) {
if (this.state.status === "pending") {
this.scheduleGc();
} else {
- this.#mutationCache.remove(this);
+ this.mutationCache.remove(this);
}
}
}
continue() {
- return this.#retryer?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
+ return this.retryer?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
this.execute(this.state.variables);
}
async execute(variables) {
- this.#retryer = (0, import_retryer.createRetryer)({
+ this.retryer = (0, import_retryer.createRetryer)({
fn: () => {
if (!this.options.mutationFn) {
return Promise.reject(new Error("No mutationFn found"));
@@ -89,31 +89,31 @@ var Mutation = class extends import_removable.Removable {
return this.options.mutationFn(variables);
},
onFail: (failureCount, error) => {
- this.#dispatch({ type: "failed", failureCount, error });
+ this.dispatch({ type: "failed", failureCount, error });
},
onPause: () => {
- this.#dispatch({ type: "pause" });
+ this.dispatch({ type: "pause" });
},
onContinue: () => {
- this.#dispatch({ type: "continue" });
+ this.dispatch({ type: "continue" });
},
retry: this.options.retry ?? 0,
retryDelay: this.options.retryDelay,
networkMode: this.options.networkMode,
- canRun: () => this.#mutationCache.canRun(this)
+ canRun: () => this.mutationCache.canRun(this)
});
const restored = this.state.status === "pending";
- const isPaused = !this.#retryer.canStart();
+ const isPaused = !this.retryer.canStart();
try {
if (!restored) {
- this.#dispatch({ type: "pending", variables, isPaused });
- await this.#mutationCache.config.onMutate?.(
+ this.dispatch({ type: "pending", variables, isPaused });
+ await this.mutationCache.config.onMutate?.(
variables,
this
);
const context = await this.options.onMutate?.(variables);
if (context !== this.state.context) {
- this.#dispatch({
+ this.dispatch({
type: "pending",
context,
variables,
@@ -121,15 +121,15 @@ var Mutation = class extends import_removable.Removable {
});
}
}
- const data = await this.#retryer.start();
- await this.#mutationCache.config.onSuccess?.(
+ const data = await this.retryer.start();
+ await this.mutationCache.config.onSuccess?.(
data,
variables,
this.state.context,
this
);
await this.options.onSuccess?.(data, variables, this.state.context);
- await this.#mutationCache.config.onSettled?.(
+ await this.mutationCache.config.onSettled?.(
data,
null,
this.state.variables,
@@ -137,11 +137,11 @@ var Mutation = class extends import_removable.Removable {
this
);
await this.options.onSettled?.(data, null, variables, this.state.context);
- this.#dispatch({ type: "success", data });
+ this.dispatch({ type: "success", data });
return data;
} catch (error) {
try {
- await this.#mutationCache.config.onError?.(
+ await this.mutationCache.config.onError?.(
error,
variables,
this.state.context,
@@ -152,7 +152,7 @@ var Mutation = class extends import_removable.Removable {
variables,
this.state.context
);
- await this.#mutationCache.config.onSettled?.(
+ await this.mutationCache.config.onSettled?.(
void 0,
error,
this.state.variables,
@@ -167,13 +167,13 @@ var Mutation = class extends import_removable.Removable {
);
throw error;
} finally {
- this.#dispatch({ type: "error", error });
+ this.dispatch({ type: "error", error });
}
} finally {
- this.#mutationCache.runNext(this);
+ this.mutationCache.runNext(this);
}
}
- #dispatch(action) {
+ dispatch(action) {
const reducer = (state) => {
switch (action.type) {
case "failed":
@@ -229,10 +229,10 @@ var Mutation = class extends import_removable.Removable {
};
this.state = reducer(this.state);
import_notifyManager.notifyManager.batch(() => {
- this.#observers.forEach((observer) => {
+ this.observers.forEach((observer) => {
observer.onMutationUpdate(action);
});
- this.#mutationCache.notify({
+ this.mutationCache.notify({
mutation: this,
type: "updated",
action
diff --git a/node_modules/@tanstack/query-core/build/modern/mutationCache.cjs b/node_modules/@tanstack/query-core/build/modern/mutationCache.cjs
index 84943e8..ff6bffd 100644
--- a/node_modules/@tanstack/query-core/build/modern/mutationCache.cjs
+++ b/node_modules/@tanstack/query-core/build/modern/mutationCache.cjs
@@ -31,15 +31,15 @@ var MutationCache = class extends import_subscribable.Subscribable {
constructor(config = {}) {
super();
this.config = config;
- this.#mutations = /* @__PURE__ */ new Map();
- this.#mutationId = Date.now();
+ this.mutations = /* @__PURE__ */ new Map();
+ this.mutationId = Date.now();
}
- #mutations;
- #mutationId;
+ mutations;
+ mutationId;
build(client, options, state) {
const mutation = new import_mutation.Mutation({
mutationCache: this,
- mutationId: ++this.#mutationId,
+ mutationId: ++this.mutationId,
options: client.defaultMutationOptions(options),
state
});
@@ -48,31 +48,31 @@ var MutationCache = class extends import_subscribable.Subscribable {
}
add(mutation) {
const scope = scopeFor(mutation);
- const mutations = this.#mutations.get(scope) ?? [];
+ const mutations = this.mutations.get(scope) ?? [];
mutations.push(mutation);
- this.#mutations.set(scope, mutations);
+ this.mutations.set(scope, mutations);
this.notify({ type: "added", mutation });
}
remove(mutation) {
const scope = scopeFor(mutation);
- if (this.#mutations.has(scope)) {
- const mutations = this.#mutations.get(scope)?.filter((x) => x !== mutation);
+ if (this.mutations.has(scope)) {
+ const mutations = this.mutations.get(scope)?.filter((x) => x !== mutation);
if (mutations) {
if (mutations.length === 0) {
- this.#mutations.delete(scope);
+ this.mutations.delete(scope);
} else {
- this.#mutations.set(scope, mutations);
+ this.mutations.set(scope, mutations);
}
}
}
this.notify({ type: "removed", mutation });
}
canRun(mutation) {
- const firstPendingMutation = this.#mutations.get(scopeFor(mutation))?.find((m) => m.state.status === "pending");
+ const firstPendingMutation = this.mutations.get(scopeFor(mutation))?.find((m) => m.state.status === "pending");
return !firstPendingMutation || firstPendingMutation === mutation;
}
runNext(mutation) {
- const foundMutation = this.#mutations.get(scopeFor(mutation))?.find((m) => m !== mutation && m.state.isPaused);
+ const foundMutation = this.mutations.get(scopeFor(mutation))?.find((m) => m !== mutation && m.state.isPaused);
return foundMutation?.continue() ?? Promise.resolve();
}
clear() {
@@ -83,7 +83,7 @@ var MutationCache = class extends import_subscribable.Subscribable {
});
}
getAll() {
- return [...this.#mutations.values()].flat();
+ return [...this.mutations.values()].flat();
}
find(filters) {
const defaultedFilters = { exact: true, ...filters };
diff --git a/node_modules/@tanstack/query-core/build/modern/mutationObserver.cjs b/node_modules/@tanstack/query-core/build/modern/mutationObserver.cjs
index f53f065..2fbc0c0 100644
--- a/node_modules/@tanstack/query-core/build/modern/mutationObserver.cjs
+++ b/node_modules/@tanstack/query-core/build/modern/mutationObserver.cjs
@@ -4,23 +4,29 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
- for (var name in all)
- __defProp(target, name, { get: all[name], enumerable: true });
+ for (var name in all)
+ __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
- if (from && typeof from === "object" || typeof from === "function") {
- for (let key of __getOwnPropNames(from))
- if (!__hasOwnProp.call(to, key) && key !== except)
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
- }
- return to;
+ if ((from && typeof from === "object") || typeof from === "function") {
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key) && key !== except)
+ __defProp(to, key, {
+ get: () => from[key],
+ enumerable:
+ !(desc = __getOwnPropDesc(from, key)) ||
+ desc.enumerable,
+ });
+ }
+ return to;
};
-var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
+var __toCommonJS = (mod) =>
+ __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/mutationObserver.ts
var mutationObserver_exports = {};
__export(mutationObserver_exports, {
- MutationObserver: () => MutationObserver
+ MutationObserver: () => MutationObserver,
});
module.exports = __toCommonJS(mutationObserver_exports);
var import_mutation = require("./mutation.cjs");
@@ -28,100 +34,123 @@ var import_notifyManager = require("./notifyManager.cjs");
var import_subscribable = require("./subscribable.cjs");
var import_utils = require("./utils.cjs");
var MutationObserver = class extends import_subscribable.Subscribable {
- #client;
- #currentResult = void 0;
- #currentMutation;
- #mutateOptions;
- constructor(client, options) {
- super();
- this.#client = client;
- this.setOptions(options);
- this.bindMethods();
- this.#updateResult();
- }
- bindMethods() {
- this.mutate = this.mutate.bind(this);
- this.reset = this.reset.bind(this);
- }
- setOptions(options) {
- const prevOptions = this.options;
- this.options = this.#client.defaultMutationOptions(options);
- if (!(0, import_utils.shallowEqualObjects)(this.options, prevOptions)) {
- this.#client.getMutationCache().notify({
- type: "observerOptionsUpdated",
- mutation: this.#currentMutation,
- observer: this
- });
+ client;
+ currentResult = void 0;
+ currentMutation;
+ mutateOptions;
+ constructor(client, options) {
+ super();
+ this.client = client;
+ this.setOptions(options);
+ this.bindMethods();
+ this.updateResult();
}
- if (prevOptions?.mutationKey && this.options.mutationKey && (0, import_utils.hashKey)(prevOptions.mutationKey) !== (0, import_utils.hashKey)(this.options.mutationKey)) {
- this.reset();
- } else if (this.#currentMutation?.state.status === "pending") {
- this.#currentMutation.setOptions(this.options);
+ bindMethods() {
+ this.mutate = this.mutate.bind(this);
+ this.reset = this.reset.bind(this);
}
- }
- onUnsubscribe() {
- if (!this.hasListeners()) {
- this.#currentMutation?.removeObserver(this);
+ setOptions(options) {
+ const prevOptions = this.options;
+ this.options = this.client.defaultMutationOptions(options);
+ if (!(0, import_utils.shallowEqualObjects)(this.options, prevOptions)) {
+ this.client.getMutationCache().notify({
+ type: "observerOptionsUpdated",
+ mutation: this.currentMutation,
+ observer: this,
+ });
+ }
+ if (
+ prevOptions?.mutationKey &&
+ this.options.mutationKey &&
+ (0, import_utils.hashKey)(prevOptions.mutationKey) !==
+ (0, import_utils.hashKey)(this.options.mutationKey)
+ ) {
+ this.reset();
+ } else if (this.currentMutation?.state.status === "pending") {
+ this.currentMutation.setOptions(this.options);
+ }
}
- }
- onMutationUpdate(action) {
- this.#updateResult();
- this.#notify(action);
- }
- getCurrentResult() {
- return this.#currentResult;
- }
- reset() {
- this.#currentMutation?.removeObserver(this);
- this.#currentMutation = void 0;
- this.#updateResult();
- this.#notify();
- }
- mutate(variables, options) {
- this.#mutateOptions = options;
- this.#currentMutation?.removeObserver(this);
- this.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options);
- this.#currentMutation.addObserver(this);
- return this.#currentMutation.execute(variables);
- }
- #updateResult() {
- const state = this.#currentMutation?.state ?? (0, import_mutation.getDefaultState)();
- this.#currentResult = {
- ...state,
- isPending: state.status === "pending",
- isSuccess: state.status === "success",
- isError: state.status === "error",
- isIdle: state.status === "idle",
- mutate: this.mutate,
- reset: this.reset
- };
- }
- #notify(action) {
- import_notifyManager.notifyManager.batch(() => {
- if (this.#mutateOptions && this.hasListeners()) {
- const variables = this.#currentResult.variables;
- const context = this.#currentResult.context;
- if (action?.type === "success") {
- this.#mutateOptions.onSuccess?.(action.data, variables, context);
- this.#mutateOptions.onSettled?.(action.data, null, variables, context);
- } else if (action?.type === "error") {
- this.#mutateOptions.onError?.(action.error, variables, context);
- this.#mutateOptions.onSettled?.(
- void 0,
- action.error,
- variables,
- context
- );
+ onUnsubscribe() {
+ if (!this.hasListeners()) {
+ this.currentMutation?.removeObserver(this);
}
- }
- this.listeners.forEach((listener) => {
- listener(this.#currentResult);
- });
- });
- }
+ }
+ onMutationUpdate(action) {
+ this.updateResult();
+ this.notify(action);
+ }
+ getCurrentResult() {
+ return this.currentResult;
+ }
+ reset() {
+ this.currentMutation?.removeObserver(this);
+ this.currentMutation = void 0;
+ this.updateResult();
+ this.notify();
+ }
+ mutate(variables, options) {
+ this.mutateOptions = options;
+ this.currentMutation?.removeObserver(this);
+ this.currentMutation = this.client
+ .getMutationCache()
+ .build(this.client, this.options);
+ this.currentMutation.addObserver(this);
+ return this.currentMutation.execute(variables);
+ }
+ updateResult() {
+ const state =
+ this.currentMutation?.state ??
+ (0, import_mutation.getDefaultState)();
+ this.currentResult = {
+ ...state,
+ isPending: state.status === "pending",
+ isSuccess: state.status === "success",
+ isError: state.status === "error",
+ isIdle: state.status === "idle",
+ mutate: this.mutate,
+ reset: this.reset,
+ };
+ }
+ notify(action) {
+ import_notifyManager.notifyManager.batch(() => {
+ if (this.mutateOptions && this.hasListeners()) {
+ const variables = this.currentResult.variables;
+ const context = this.currentResult.context;
+ if (action?.type === "success") {
+ this.mutateOptions.onSuccess?.(
+ action.data,
+ variables,
+ context,
+ );
+ this.mutateOptions.onSettled?.(
+ action.data,
+ null,
+ variables,
+ context,
+ );
+ } else if (action?.type === "error") {
+ this.mutateOptions.onError?.(
+ action.error,
+ variables,
+ context,
+ );
+ this.mutateOptions.onSettled?.(
+ void 0,
+ action.error,
+ variables,
+ context,
+ );
+ }
+ }
+ this.listeners.forEach((listener) => {
+ listener(this.currentResult);
+ });
+ });
+ }
};
// Annotate the CommonJS export names for ESM import in node:
-0 && (module.exports = {
- MutationObserver
-});
+0 &&
+ (module.exports = {
+ MutationObserver,
+ });
//# sourceMappingURL=mutationObserver.cjs.map
diff --git a/node_modules/@tanstack/query-core/build/modern/onlineManager.cjs b/node_modules/@tanstack/query-core/build/modern/onlineManager.cjs
index 69196cf..6ac4627 100644
--- a/node_modules/@tanstack/query-core/build/modern/onlineManager.cjs
+++ b/node_modules/@tanstack/query-core/build/modern/onlineManager.cjs
@@ -4,81 +4,88 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
- for (var name in all)
- __defProp(target, name, { get: all[name], enumerable: true });
+ for (var name in all)
+ __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
- if (from && typeof from === "object" || typeof from === "function") {
- for (let key of __getOwnPropNames(from))
- if (!__hasOwnProp.call(to, key) && key !== except)
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
- }
- return to;
+ if ((from && typeof from === "object") || typeof from === "function") {
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key) && key !== except)
+ __defProp(to, key, {
+ get: () => from[key],
+ enumerable:
+ !(desc = __getOwnPropDesc(from, key)) ||
+ desc.enumerable,
+ });
+ }
+ return to;
};
-var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
+var __toCommonJS = (mod) =>
+ __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/onlineManager.ts
var onlineManager_exports = {};
__export(onlineManager_exports, {
- OnlineManager: () => OnlineManager,
- onlineManager: () => onlineManager
+ OnlineManager: () => OnlineManager,
+ onlineManager: () => onlineManager,
});
module.exports = __toCommonJS(onlineManager_exports);
var import_subscribable = require("./subscribable.cjs");
var import_utils = require("./utils.cjs");
var OnlineManager = class extends import_subscribable.Subscribable {
- #online = true;
- #cleanup;
- #setup;
- constructor() {
- super();
- this.#setup = (onOnline) => {
- if (!import_utils.isServer && window.addEventListener) {
- const onlineListener = () => onOnline(true);
- const offlineListener = () => onOnline(false);
- window.addEventListener("online", onlineListener, false);
- window.addEventListener("offline", offlineListener, false);
- return () => {
- window.removeEventListener("online", onlineListener);
- window.removeEventListener("offline", offlineListener);
+ online = true;
+ cleanup;
+ setup;
+ constructor() {
+ super();
+ this.setup = (onOnline) => {
+ if (!import_utils.isServer && window.addEventListener) {
+ const onlineListener = () => onOnline(true);
+ const offlineListener = () => onOnline(false);
+ window.addEventListener("online", onlineListener, false);
+ window.addEventListener("offline", offlineListener, false);
+ return () => {
+ window.removeEventListener("online", onlineListener);
+ window.removeEventListener("offline", offlineListener);
+ };
+ }
+ return;
};
- }
- return;
- };
- }
- onSubscribe() {
- if (!this.#cleanup) {
- this.setEventListener(this.#setup);
}
- }
- onUnsubscribe() {
- if (!this.hasListeners()) {
- this.#cleanup?.();
- this.#cleanup = void 0;
+ onSubscribe() {
+ if (!this.cleanup) {
+ this.setEventListener(this.setup);
+ }
+ }
+ onUnsubscribe() {
+ if (!this.hasListeners()) {
+ this.cleanup?.();
+ this.cleanup = void 0;
+ }
+ }
+ setEventListener(setup) {
+ this.setup = setup;
+ this.cleanup?.();
+ this.cleanup = setup(this.setOnline.bind(this));
}
- }
- setEventListener(setup) {
- this.#setup = setup;
- this.#cleanup?.();
- this.#cleanup = setup(this.setOnline.bind(this));
- }
- setOnline(online) {
- const changed = this.#online !== online;
- if (changed) {
- this.#online = online;
- this.listeners.forEach((listener) => {
- listener(online);
- });
+ setOnline(online) {
+ const changed = this.online !== online;
+ if (changed) {
+ this.online = online;
+ this.listeners.forEach((listener) => {
+ listener(online);
+ });
+ }
+ }
+ isOnline() {
+ return this.online;
}
- }
- isOnline() {
- return this.#online;
- }
};
var onlineManager = new OnlineManager();
// Annotate the CommonJS export names for ESM import in node:
-0 && (module.exports = {
- OnlineManager,
- onlineManager
-});
+0 &&
+ (module.exports = {
+ OnlineManager,
+ onlineManager,
+ });
//# sourceMappingURL=onlineManager.cjs.map
diff --git a/node_modules/@tanstack/query-core/build/modern/queriesObserver.cjs b/node_modules/@tanstack/query-core/build/modern/queriesObserver.cjs
index 6c957e0..3d890aa 100644
--- a/node_modules/@tanstack/query-core/build/modern/queriesObserver.cjs
+++ b/node_modules/@tanstack/query-core/build/modern/queriesObserver.cjs
@@ -36,26 +36,26 @@ function replaceAt(array, index, value) {
return copy;
}
var QueriesObserver = class extends import_subscribable.Subscribable {
- #client;
- #result;
- #queries;
- #observers;
- #combinedResult;
- #lastCombine;
- #lastResult;
+ client;
+ result;
+ queries;
+ observers;
+ combinedResult;
+ lastCombine;
+ lastResult;
constructor(client, queries, _options) {
super();
- this.#client = client;
- this.#queries = [];
- this.#observers = [];
- this.#result = [];
+ this.client = client;
+ this.queries = [];
+ this.observers = [];
+ this.result = [];
this.setQueries(queries);
}
onSubscribe() {
if (this.listeners.size === 1) {
- this.#observers.forEach((observer) => {
+ this.observers.forEach((observer) => {
observer.subscribe((result) => {
- this.#onUpdate(observer, result);
+ this.onUpdate(observer, result);
});
});
}
@@ -67,15 +67,15 @@ var QueriesObserver = class extends import_subscribable.Subscribable {
}
destroy() {
this.listeners = /* @__PURE__ */ new Set();
- this.#observers.forEach((observer) => {
+ this.observers.forEach((observer) => {
observer.destroy();
});
}
setQueries(queries, _options, notifyOptions) {
- this.#queries = queries;
+ this.queries = queries;
import_notifyManager.notifyManager.batch(() => {
- const prevObservers = this.#observers;
- const newObserverMatches = this.#findMatchingObservers(this.#queries);
+ const prevObservers = this.observers;
+ const newObserverMatches = this.findMatchingObservers(this.queries);
newObserverMatches.forEach(
(match) => match.observer.setOptions(match.defaultedQueryOptions, notifyOptions)
);
@@ -89,8 +89,8 @@ var QueriesObserver = class extends import_subscribable.Subscribable {
if (prevObservers.length === newObservers.length && !hasIndexChange) {
return;
}
- this.#observers = newObservers;
- this.#result = newResult;
+ this.observers = newObservers;
+ this.result = newResult;
if (!this.hasListeners()) {
return;
}
@@ -99,30 +99,30 @@ var QueriesObserver = class extends import_subscribable.Subscribable {
});
difference(newObservers, prevObservers).forEach((observer) => {
observer.subscribe((result) => {
- this.#onUpdate(observer, result);
+ this.onUpdate(observer, result);
});
});
- this.#notify();
+ this.notify();
});
}
getCurrentResult() {
- return this.#result;
+ return this.result;
}
getQueries() {
- return this.#observers.map((observer) => observer.getCurrentQuery());
+ return this.observers.map((observer) => observer.getCurrentQuery());
}
getObservers() {
- return this.#observers;
+ return this.observers;
}
getOptimisticResult(queries, combine) {
- const matches = this.#findMatchingObservers(queries);
+ const matches = this.findMatchingObservers(queries);
const result = matches.map(
(match) => match.observer.getOptimisticResult(match.defaultedQueryOptions)
);
return [
result,
(r) => {
- return this.#combineResult(r ?? result, combine);
+ return this.combineResult(r ?? result, combine);
},
() => {
return matches.map((match, index) => {
@@ -136,27 +136,27 @@ var QueriesObserver = class extends import_subscribable.Subscribable {
}
];
}
- #combineResult(input, combine) {
+ combineResult(input, combine) {
if (combine) {
- if (!this.#combinedResult || this.#result !== this.#lastResult || combine !== this.#lastCombine) {
- this.#lastCombine = combine;
- this.#lastResult = this.#result;
- this.#combinedResult = (0, import_utils.replaceEqualDeep)(
- this.#combinedResult,
+ if (!this.combinedResult || this.result !== this.lastResult || combine !== this.lastCombine) {
+ this.lastCombine = combine;
+ this.lastResult = this.result;
+ this.combinedResult = (0, import_utils.replaceEqualDeep)(
+ this.combinedResult,
combine(input)
);
}
- return this.#combinedResult;
+ return this.combinedResult;
}
return input;
}
- #findMatchingObservers(queries) {
- const prevObservers = this.#observers;
+ findMatchingObservers(queries) {
+ const prevObservers = this.observers;
const prevObserversMap = new Map(
prevObservers.map((observer) => [observer.options.queryHash, observer])
);
const defaultedQueryOptions = queries.map(
- (options) => this.#client.defaultQueryOptions(options)
+ (options) => this.client.defaultQueryOptions(options)
);
const matchingObservers = defaultedQueryOptions.flatMap((defaultedOptions) => {
const match = prevObserversMap.get(defaultedOptions.queryHash);
@@ -172,11 +172,11 @@ var QueriesObserver = class extends import_subscribable.Subscribable {
(defaultedOptions) => !matchedQueryHashes.has(defaultedOptions.queryHash)
);
const getObserver = (options) => {
- const defaultedOptions = this.#client.defaultQueryOptions(options);
- const currentObserver = this.#observers.find(
+ const defaultedOptions = this.client.defaultQueryOptions(options);
+ const currentObserver = this.observers.find(
(o) => o.options.queryHash === defaultedOptions.queryHash
);
- return currentObserver ?? new import_queryObserver.QueryObserver(this.#client, defaultedOptions);
+ return currentObserver ?? new import_queryObserver.QueryObserver(this.client, defaultedOptions);
};
const newOrReusedObservers = unmatchedQueries.map((options) => {
return {
@@ -187,17 +187,17 @@ var QueriesObserver = class extends import_subscribable.Subscribable {
const sortMatchesByOrderOfQueries = (a, b) => defaultedQueryOptions.indexOf(a.defaultedQueryOptions) - defaultedQueryOptions.indexOf(b.defaultedQueryOptions);
return matchingObservers.concat(newOrReusedObservers).sort(sortMatchesByOrderOfQueries);
}
- #onUpdate(observer, result) {
- const index = this.#observers.indexOf(observer);
+ onUpdate(observer, result) {
+ const index = this.observers.indexOf(observer);
if (index !== -1) {
- this.#result = replaceAt(this.#result, index, result);
- this.#notify();
+ this.result = replaceAt(this.result, index, result);
+ this.notify();
}
}
- #notify() {
+ notify() {
import_notifyManager.notifyManager.batch(() => {
this.listeners.forEach((listener) => {
- listener(this.#result);
+ listener(this.result);
});
});
}
diff --git a/node_modules/@tanstack/query-core/build/modern/query.cjs b/node_modules/@tanstack/query-core/build/modern/query.cjs
index 2924944..8ae8d4c 100644
--- a/node_modules/@tanstack/query-core/build/modern/query.cjs
+++ b/node_modules/@tanstack/query-core/build/modern/query.cjs
@@ -29,43 +29,43 @@ var import_notifyManager = require("./notifyManager.cjs");
var import_retryer = require("./retryer.cjs");
var import_removable = require("./removable.cjs");
var Query = class extends import_removable.Removable {
- #initialState;
- #revertState;
- #cache;
- #retryer;
- #defaultOptions;
- #abortSignalConsumed;
+ initialState;
+ revertState;
+ cache;
+ retryer;
+ defaultOptions;
+ abortSignalConsumed;
constructor(config) {
super();
- this.#abortSignalConsumed = false;
- this.#defaultOptions = config.defaultOptions;
+ this.abortSignalConsumed = false;
+ this.defaultOptions = config.defaultOptions;
this.setOptions(config.options);
this.observers = [];
- this.#cache = config.cache;
+ this.cache = config.cache;
this.queryKey = config.queryKey;
this.queryHash = config.queryHash;
- this.#initialState = config.state || getDefaultState(this.options);
- this.state = this.#initialState;
+ this.initialState = config.state || getDefaultState(this.options);
+ this.state = this.initialState;
this.scheduleGc();
}
get meta() {
return this.options.meta;
}
get promise() {
- return this.#retryer?.promise;
+ return this.retryer?.promise;
}
setOptions(options) {
- this.options = { ...this.#defaultOptions, ...options };
+ this.options = { ...this.defaultOptions, ...options };
this.updateGcTime(this.options.gcTime);
}
optionalRemove() {
if (!this.observers.length && this.state.fetchStatus === "idle") {
- this.#cache.remove(this);
+ this.cache.remove(this);
}
}
setData(newData, options) {
const data = (0, import_utils.replaceData)(this.state.data, newData, this.options);
- this.#dispatch({
+ this.dispatch({
data,
type: "success",
dataUpdatedAt: options?.updatedAt,
@@ -74,11 +74,11 @@ var Query = class extends import_removable.Removable {
return data;
}
setState(state, setStateOptions) {
- this.#dispatch({ type: "setState", state, setStateOptions });
+ this.dispatch({ type: "setState", state, setStateOptions });
}
cancel(options) {
- const promise = this.#retryer?.promise;
- this.#retryer?.cancel(options);
+ const promise = this.retryer?.promise;
+ this.retryer?.cancel(options);
return promise ? promise.then(import_utils.noop).catch(import_utils.noop) : Promise.resolve();
}
destroy() {
@@ -87,7 +87,7 @@ var Query = class extends import_removable.Removable {
}
reset() {
this.destroy();
- this.setState(this.#initialState);
+ this.setState(this.initialState);
}
isActive() {
return this.observers.some((observer) => observer.options.enabled !== false);
@@ -112,34 +112,34 @@ var Query = class extends import_removable.Removable {
onFocus() {
const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus());
observer?.refetch({ cancelRefetch: false });
- this.#retryer?.continue();
+ this.retryer?.continue();
}
onOnline() {
const observer = this.observers.find((x) => x.shouldFetchOnReconnect());
observer?.refetch({ cancelRefetch: false });
- this.#retryer?.continue();
+ this.retryer?.continue();
}
addObserver(observer) {
if (!this.observers.includes(observer)) {
this.observers.push(observer);
this.clearGcTimeout();
- this.#cache.notify({ type: "observerAdded", query: this, observer });
+ this.cache.notify({ type: "observerAdded", query: this, observer });
}
}
removeObserver(observer) {
if (this.observers.includes(observer)) {
this.observers = this.observers.filter((x) => x !== observer);
if (!this.observers.length) {
- if (this.#retryer) {
- if (this.#abortSignalConsumed) {
- this.#retryer.cancel({ revert: true });
+ if (this.retryer) {
+ if (this.abortSignalConsumed) {
+ this.retryer.cancel({ revert: true });
} else {
- this.#retryer.cancelRetry();
+ this.retryer.cancelRetry();
}
}
this.scheduleGc();
}
- this.#cache.notify({ type: "observerRemoved", query: this, observer });
+ this.cache.notify({ type: "observerRemoved", query: this, observer });
}
}
getObserversCount() {
@@ -147,16 +147,16 @@ var Query = class extends import_removable.Removable {
}
invalidate() {
if (!this.state.isInvalidated) {
- this.#dispatch({ type: "invalidate" });
+ this.dispatch({ type: "invalidate" });
}
}
fetch(options, fetchOptions) {
if (this.state.fetchStatus !== "idle") {
if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) {
this.cancel({ silent: true });
- } else if (this.#retryer) {
- this.#retryer.continueRetry();
- return this.#retryer.promise;
+ } else if (this.retryer) {
+ this.retryer.continueRetry();
+ return this.retryer.promise;
}
}
if (options) {
@@ -180,7 +180,7 @@ var Query = class extends import_removable.Removable {
Object.defineProperty(object, "signal", {
enumerable: true,
get: () => {
- this.#abortSignalConsumed = true;
+ this.abortSignalConsumed = true;
return abortController.signal;
}
});
@@ -192,7 +192,7 @@ var Query = class extends import_removable.Removable {
meta: this.meta
};
addSignalProperty(queryFnContext);
- this.#abortSignalConsumed = false;
+ this.abortSignalConsumed = false;
if (this.options.persister) {
return this.options.persister(
queryFn,
@@ -214,23 +214,23 @@ var Query = class extends import_removable.Removable {
context,
this
);
- this.#revertState = this.state;
+ this.revertState = this.state;
if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) {
- this.#dispatch({ type: "fetch", meta: context.fetchOptions?.meta });
+ this.dispatch({ type: "fetch", meta: context.fetchOptions?.meta });
}
const onError = (error) => {
if (!((0, import_retryer.isCancelledError)(error) && error.silent)) {
- this.#dispatch({
+ this.dispatch({
type: "error",
error
});
}
if (!(0, import_retryer.isCancelledError)(error)) {
- this.#cache.config.onError?.(
+ this.cache.config.onError?.(
error,
this
);
- this.#cache.config.onSettled?.(
+ this.cache.config.onSettled?.(
this.state.data,
error,
this
@@ -241,7 +241,7 @@ var Query = class extends import_removable.Removable {
}
this.isFetchingOptimistic = false;
};
- this.#retryer = (0, import_retryer.createRetryer)({
+ this.retryer = (0, import_retryer.createRetryer)({
initialPromise: fetchOptions?.initialPromise,
fn: context.fetchFn,
abort: abortController.abort.bind(abortController),
@@ -256,8 +256,8 @@ var Query = class extends import_removable.Removable {
return;
}
this.setData(data);
- this.#cache.config.onSuccess?.(data, this);
- this.#cache.config.onSettled?.(
+ this.cache.config.onSuccess?.(data, this);
+ this.cache.config.onSettled?.(
data,
this.state.error,
this
@@ -269,22 +269,22 @@ var Query = class extends import_removable.Removable {
},
onError,
onFail: (failureCount, error) => {
- this.#dispatch({ type: "failed", failureCount, error });
+ this.dispatch({ type: "failed", failureCount, error });
},
onPause: () => {
- this.#dispatch({ type: "pause" });
+ this.dispatch({ type: "pause" });
},
onContinue: () => {
- this.#dispatch({ type: "continue" });
+ this.dispatch({ type: "continue" });
},
retry: context.options.retry,
retryDelay: context.options.retryDelay,
networkMode: context.options.networkMode,
canRun: () => true
});
- return this.#retryer.start();
+ return this.retryer.start();
}
- #dispatch(action) {
+ dispatch(action) {
const reducer = (state) => {
switch (action.type) {
case "failed":
@@ -326,8 +326,8 @@ var Query = class extends import_removable.Removable {
};
case "error":
const error = action.error;
- if ((0, import_retryer.isCancelledError)(error) && error.revert && this.#revertState) {
- return { ...this.#revertState, fetchStatus: "idle" };
+ if ((0, import_retryer.isCancelledError)(error) && error.revert && this.revertState) {
+ return { ...this.revertState, fetchStatus: "idle" };
}
return {
...state,
@@ -356,7 +356,7 @@ var Query = class extends import_removable.Removable {
this.observers.forEach((observer) => {
observer.onQueryUpdate();
});
- this.#cache.notify({ query: this, type: "updated", action });
+ this.cache.notify({ query: this, type: "updated", action });
});
}
};
diff --git a/node_modules/@tanstack/query-core/build/modern/queryCache.cjs b/node_modules/@tanstack/query-core/build/modern/queryCache.cjs
index a58b6dc..596d1fb 100644
--- a/node_modules/@tanstack/query-core/build/modern/queryCache.cjs
+++ b/node_modules/@tanstack/query-core/build/modern/queryCache.cjs
@@ -33,7 +33,7 @@ var QueryCache = class extends import_subscribable.Subscribable {
this.config = config;
this.#queries = /* @__PURE__ */ new Map();
}
- #queries;
+ queries;
build(client, options, state) {
const queryKey = options.queryKey;
const queryHash = options.queryHash ?? (0, import_utils.hashQueryKeyByOptions)(queryKey, options);
@@ -52,8 +52,8 @@ var QueryCache = class extends import_subscribable.Subscribable {
return query;
}
add(query) {
- if (!this.#queries.has(query.queryHash)) {
- this.#queries.set(query.queryHash, query);
+ if (!this.queries.has(query.queryHash)) {
+ this.queries.set(query.queryHash, query);
this.notify({
type: "added",
query
@@ -61,11 +61,11 @@ var QueryCache = class extends import_subscribable.Subscribable {
}
}
remove(query) {
- const queryInMap = this.#queries.get(query.queryHash);
+ const queryInMap = this.queries.get(query.queryHash);
if (queryInMap) {
query.destroy();
if (queryInMap === query) {
- this.#queries.delete(query.queryHash);
+ this.queries.delete(query.queryHash);
}
this.notify({ type: "removed", query });
}
@@ -78,10 +78,10 @@ var QueryCache = class extends import_subscribable.Subscribable {
});
}
get(queryHash) {
- return this.#queries.get(queryHash);
+ return this.queries.get(queryHash);
}
getAll() {
- return [...this.#queries.values()];
+ return [...this.queries.values()];
}
find(filters) {
const defaultedFilters = { exact: true, ...filters };
diff --git a/node_modules/@tanstack/query-core/build/modern/queryClient.cjs b/node_modules/@tanstack/query-core/build/modern/queryClient.cjs
index 9dea4a2..bb51852 100644
--- a/node_modules/@tanstack/query-core/build/modern/queryClient.cjs
+++ b/node_modules/@tanstack/query-core/build/modern/queryClient.cjs
@@ -31,57 +31,57 @@ var import_onlineManager = require("./onlineManager.cjs");
var import_notifyManager = require("./notifyManager.cjs");
var import_infiniteQueryBehavior = require("./infiniteQueryBehavior.cjs");
var QueryClient = class {
- #queryCache;
- #mutationCache;
- #defaultOptions;
- #queryDefaults;
- #mutationDefaults;
- #mountCount;
- #unsubscribeFocus;
- #unsubscribeOnline;
+ queryCache;
+ mutationCache;
+ defaultOptions;
+ queryDefaults;
+ mutationDefaults;
+ mountCount;
+ unsubscribeFocus;
+ unsubscribeOnline;
constructor(config = {}) {
- this.#queryCache = config.queryCache || new import_queryCache.QueryCache();
- this.#mutationCache = config.mutationCache || new import_mutationCache.MutationCache();
- this.#defaultOptions = config.defaultOptions || {};
- this.#queryDefaults = /* @__PURE__ */ new Map();
- this.#mutationDefaults = /* @__PURE__ */ new Map();
- this.#mountCount = 0;
+ this.queryCache = config.queryCache || new import_queryCache.QueryCache();
+ this.mutationCache = config.mutationCache || new import_mutationCache.MutationCache();
+ this.defaultOptions = config.defaultOptions || {};
+ this.queryDefaults = /* @__PURE__ */ new Map();
+ this.mutationDefaults = /* @__PURE__ */ new Map();
+ this.mountCount = 0;
}
mount() {
- this.#mountCount++;
- if (this.#mountCount !== 1)
+ this.mountCount++;
+ if (this.mountCount !== 1)
return;
- this.#unsubscribeFocus = import_focusManager.focusManager.subscribe(async (focused) => {
+ this.unsubscribeFocus = import_focusManager.focusManager.subscribe(async (focused) => {
if (focused) {
await this.resumePausedMutations();
- this.#queryCache.onFocus();
+ this.queryCache.onFocus();
}
});
- this.#unsubscribeOnline = import_onlineManager.onlineManager.subscribe(async (online) => {
+ this.unsubscribeOnline = import_onlineManager.onlineManager.subscribe(async (online) => {
if (online) {
await this.resumePausedMutations();
- this.#queryCache.onOnline();
+ this.queryCache.onOnline();
}
});
}
unmount() {
- this.#mountCount--;
- if (this.#mountCount !== 0)
+ this.mountCount--;
+ if (this.mountCount !== 0)
return;
- this.#unsubscribeFocus?.();
- this.#unsubscribeFocus = void 0;
- this.#unsubscribeOnline?.();
- this.#unsubscribeOnline = void 0;
+ this.unsubscribeFocus?.();
+ this.unsubscribeFocus = void 0;
+ this.unsubscribeOnline?.();
+ this.unsubscribeOnline = void 0;
}
isFetching(filters) {
- return this.#queryCache.findAll({ ...filters, fetchStatus: "fetching" }).length;
+ return this.queryCache.findAll({ ...filters, fetchStatus: "fetching" }).length;
}
isMutating(filters) {
- return this.#mutationCache.findAll({ ...filters, status: "pending" }).length;
+ return this.mutationCache.findAll({ ...filters, status: "pending" }).length;
}
getQueryData(queryKey) {
const options = this.defaultQueryOptions({ queryKey });
- return this.#queryCache.get(options.queryHash)?.state.data;
+ return this.queryCache.get(options.queryHash)?.state.data;
}
ensureQueryData(options) {
const cachedData = this.getQueryData(options.queryKey);
@@ -89,7 +89,7 @@ var QueryClient = class {
return this.fetchQuery(options);
else {
const defaultedOptions = this.defaultQueryOptions(options);
- const query = this.#queryCache.build(this, defaultedOptions);
+ const query = this.queryCache.build(this, defaultedOptions);
if (options.revalidateIfStale && query.isStaleByTime(defaultedOptions.staleTime)) {
void this.prefetchQuery(defaultedOptions);
}
@@ -97,14 +97,14 @@ var QueryClient = class {
}
}
getQueriesData(filters) {
- return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
+ return this.queryCache.findAll(filters).map(({ queryKey, state }) => {
const data = state.data;
return [queryKey, data];
});
}
setQueryData(queryKey, updater, options) {
const defaultedOptions = this.defaultQueryOptions({ queryKey });
- const query = this.#queryCache.get(
+ const query = this.queryCache.get(
defaultedOptions.queryHash
);
const prevData = query?.state.data;
@@ -112,11 +112,11 @@ var QueryClient = class {
if (data === void 0) {
return void 0;
}
- return this.#queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true });
+ return this.queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true });
}
setQueriesData(filters, updater, options) {
return import_notifyManager.notifyManager.batch(
- () => this.#queryCache.findAll(filters).map(({ queryKey }) => [
+ () => this.queryCache.findAll(filters).map(({ queryKey }) => [
queryKey,
this.setQueryData(queryKey, updater, options)
])
@@ -124,10 +124,10 @@ var QueryClient = class {
}
getQueryState(queryKey) {
const options = this.defaultQueryOptions({ queryKey });
- return this.#queryCache.get(options.queryHash)?.state;
+ return this.queryCache.get(options.queryHash)?.state;
}
removeQueries(filters) {
- const queryCache = this.#queryCache;
+ const queryCache = this.queryCache;
import_notifyManager.notifyManager.batch(() => {
queryCache.findAll(filters).forEach((query) => {
queryCache.remove(query);
@@ -135,7 +135,7 @@ var QueryClient = class {
});
}
resetQueries(filters, options) {
- const queryCache = this.#queryCache;
+ const queryCache = this.queryCache;
const refetchFilters = {
type: "active",
...filters
@@ -150,13 +150,13 @@ var QueryClient = class {
cancelQueries(filters = {}, cancelOptions = {}) {
const defaultedCancelOptions = { revert: true, ...cancelOptions };
const promises = import_notifyManager.notifyManager.batch(
- () => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions))
+ () => this.queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions))
);
return Promise.all(promises).then(import_utils.noop).catch(import_utils.noop);
}
invalidateQueries(filters = {}, options = {}) {
return import_notifyManager.notifyManager.batch(() => {
- this.#queryCache.findAll(filters).forEach((query) => {
+ this.queryCache.findAll(filters).forEach((query) => {
query.invalidate();
});
if (filters.refetchType === "none") {
@@ -175,7 +175,7 @@ var QueryClient = class {
cancelRefetch: options?.cancelRefetch ?? true
};
const promises = import_notifyManager.notifyManager.batch(
- () => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled()).map((query) => {
+ () => this.queryCache.findAll(filters).filter((query) => !query.isDisabled()).map((query) => {
let promise = query.fetch(void 0, fetchOptions);
if (!fetchOptions.throwOnError) {
promise = promise.catch(import_utils.noop);
@@ -190,7 +190,7 @@ var QueryClient = class {
if (defaultedOptions.retry === void 0) {
defaultedOptions.retry = false;
}
- const query = this.#queryCache.build(this, defaultedOptions);
+ const query = this.queryCache.build(this, defaultedOptions);
return query.isStaleByTime(defaultedOptions.staleTime) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
}
prefetchQuery(options) {
@@ -205,30 +205,30 @@ var QueryClient = class {
}
resumePausedMutations() {
if (import_onlineManager.onlineManager.isOnline()) {
- return this.#mutationCache.resumePausedMutations();
+ return this.mutationCache.resumePausedMutations();
}
return Promise.resolve();
}
getQueryCache() {
- return this.#queryCache;
+ return this.queryCache;
}
getMutationCache() {
- return this.#mutationCache;
+ return this.mutationCache;
}
getDefaultOptions() {
- return this.#defaultOptions;
+ return this.defaultOptions;
}
setDefaultOptions(options) {
- this.#defaultOptions = options;
+ this.defaultOptions = options;
}
setQueryDefaults(queryKey, options) {
- this.#queryDefaults.set((0, import_utils.hashKey)(queryKey), {
+ this.queryDefaults.set((0, import_utils.hashKey)(queryKey), {
queryKey,
defaultOptions: options
});
}
getQueryDefaults(queryKey) {
- const defaults = [...this.#queryDefaults.values()];
+ const defaults = [...this.queryDefaults.values()];
let result = {};
defaults.forEach((queryDefault) => {
if ((0, import_utils.partialMatchKey)(queryKey, queryDefault.queryKey)) {
@@ -238,13 +238,13 @@ var QueryClient = class {
return result;
}
setMutationDefaults(mutationKey, options) {
- this.#mutationDefaults.set((0, import_utils.hashKey)(mutationKey), {
+ this.mutationDefaults.set((0, import_utils.hashKey)(mutationKey), {
mutationKey,
defaultOptions: options
});
}
getMutationDefaults(mutationKey) {
- const defaults = [...this.#mutationDefaults.values()];
+ const defaults = [...this.mutationDefaults.values()];
let result = {};
defaults.forEach((queryDefault) => {
if ((0, import_utils.partialMatchKey)(mutationKey, queryDefault.mutationKey)) {
@@ -258,7 +258,7 @@ var QueryClient = class {
return options;
}
const defaultedOptions = {
- ...this.#defaultOptions.queries,
+ ...this.defaultOptions.queries,
...this.getQueryDefaults(options.queryKey),
...options,
_defaulted: true
@@ -288,15 +288,15 @@ var QueryClient = class {
return options;
}
return {
- ...this.#defaultOptions.mutations,
+ ...this.defaultOptions.mutations,
...options?.mutationKey && this.getMutationDefaults(options.mutationKey),
...options,
_defaulted: true
};
}
clear() {
- this.#queryCache.clear();
- this.#mutationCache.clear();
+ this.queryCache.clear();
+ this.mutationCache.clear();
}
};
// Annotate the CommonJS export names for ESM import in node:
diff --git a/node_modules/@tanstack/query-core/build/modern/queryObserver.cjs b/node_modules/@tanstack/query-core/build/modern/queryObserver.cjs
index 3e657e1..f1423eb 100644
--- a/node_modules/@tanstack/query-core/build/modern/queryObserver.cjs
+++ b/node_modules/@tanstack/query-core/build/modern/queryObserver.cjs
@@ -32,39 +32,39 @@ var QueryObserver = class extends import_subscribable.Subscribable {
constructor(client, options) {
super();
this.options = options;
- this.#client = client;
- this.#selectError = null;
+ this.client = client;
+ this.selectError = null;
this.bindMethods();
this.setOptions(options);
}
- #client;
- #currentQuery = void 0;
- #currentQueryInitialState = void 0;
- #currentResult = void 0;
- #currentResultState;
- #currentResultOptions;
- #selectError;
- #selectFn;
- #selectResult;
+ client;
+ currentQuery = void 0;
+ currentQueryInitialState = void 0;
+ currentResult = void 0;
+ currentResultState;
+ currentResultOptions;
+ selectError;
+ selectFn;
+ selectResult;
// This property keeps track of the last query with defined data.
// It will be used to pass the previous data and query to the placeholder function between renders.
- #lastQueryWithDefinedData;
- #staleTimeoutId;
- #refetchIntervalId;
- #currentRefetchInterval;
- #trackedProps = /* @__PURE__ */ new Set();
+ lastQueryWithDefinedData;
+ staleTimeoutId;
+ refetchIntervalId;
+ currentRefetchInterval;
+ trackedProps = /* @__PURE__ */ new Set();
bindMethods() {
this.refetch = this.refetch.bind(this);
}
onSubscribe() {
if (this.listeners.size === 1) {
- this.#currentQuery.addObserver(this);
- if (shouldFetchOnMount(this.#currentQuery, this.options)) {
- this.#executeFetch();
+ this.currentQuery.addObserver(this);
+ if (shouldFetchOnMount(this.currentQuery, this.options)) {
+ this.executeFetch();
} else {
this.updateResult();
}
- this.#updateTimers();
+ this.updateTimers();
}
}
onUnsubscribe() {
@@ -74,70 +74,70 @@ var QueryObserver = class extends import_subscribable.Subscribable {
}
shouldFetchOnReconnect() {
return shouldFetchOn(
- this.#currentQuery,
+ this.currentQuery,
this.options,
this.options.refetchOnReconnect
);
}
shouldFetchOnWindowFocus() {
return shouldFetchOn(
- this.#currentQuery,
+ this.currentQuery,
this.options,
this.options.refetchOnWindowFocus
);
}
destroy() {
this.listeners = /* @__PURE__ */ new Set();
- this.#clearStaleTimeout();
- this.#clearRefetchInterval();
- this.#currentQuery.removeObserver(this);
+ this.clearStaleTimeout();
+ this.clearRefetchInterval();
+ this.currentQuery.removeObserver(this);
}
setOptions(options, notifyOptions) {
const prevOptions = this.options;
- const prevQuery = this.#currentQuery;
- this.options = this.#client.defaultQueryOptions(options);
+ const prevQuery = this.currentQuery;
+ this.options = this.client.defaultQueryOptions(options);
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean") {
throw new Error("Expected enabled to be a boolean");
}
- this.#updateQuery();
- this.#currentQuery.setOptions(this.options);
+ this.updateQuery();
+ this.currentQuery.setOptions(this.options);
if (prevOptions._defaulted && !(0, import_utils.shallowEqualObjects)(this.options, prevOptions)) {
- this.#client.getQueryCache().notify({
+ this.client.getQueryCache().notify({
type: "observerOptionsUpdated",
- query: this.#currentQuery,
+ query: this.currentQuery,
observer: this
});
}
const mounted = this.hasListeners();
if (mounted && shouldFetchOptionally(
- this.#currentQuery,
+ this.currentQuery,
prevQuery,
this.options,
prevOptions
)) {
- this.#executeFetch();
+ this.executeFetch();
}
this.updateResult(notifyOptions);
- if (mounted && (this.#currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) {
- this.#updateStaleTimeout();
+ if (mounted && (this.currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) {
+ this.updateStaleTimeout();
}
- const nextRefetchInterval = this.#computeRefetchInterval();
- if (mounted && (this.#currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== this.#currentRefetchInterval)) {
- this.#updateRefetchInterval(nextRefetchInterval);
+ const nextRefetchInterval = this.computeRefetchInterval();
+ if (mounted && (this.currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== this.currentRefetchInterval)) {
+ this.updateRefetchInterval(nextRefetchInterval);
}
}
getOptimisticResult(options) {
- const query = this.#client.getQueryCache().build(this.#client, options);
+ const query = this.client.getQueryCache().build(this.client, options);
const result = this.createResult(query, options);
if (shouldAssignObserverCurrentProperties(this, result)) {
- this.#currentResult = result;
- this.#currentResultOptions = this.options;
- this.#currentResultState = this.#currentQuery.state;
+ this.currentResult = result;
+ this.currentResultOptions = this.options;
+ this.currentResultState = this.currentQuery.state;
}
return result;
}
getCurrentResult() {
- return this.#currentResult;
+ return this.currentResult;
}
trackResult(result, onPropTracked) {
const trackedResult = {};
@@ -155,10 +155,10 @@ var QueryObserver = class extends import_subscribable.Subscribable {
return trackedResult;
}
trackProp(key) {
- this.#trackedProps.add(key);
+ this.trackedProps.add(key);
}
getCurrentQuery() {
- return this.#currentQuery;
+ return this.currentQuery;
}
refetch({ ...options } = {}) {
return this.fetch({
@@ -166,23 +166,23 @@ var QueryObserver = class extends import_subscribable.Subscribable {
});
}
fetchOptimistic(options) {
- const defaultedOptions = this.#client.defaultQueryOptions(options);
- const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
+ const defaultedOptions = this.client.defaultQueryOptions(options);
+ const query = this.client.getQueryCache().build(this.client, defaultedOptions);
query.isFetchingOptimistic = true;
return query.fetch().then(() => this.createResult(query, defaultedOptions));
}
fetch(fetchOptions) {
- return this.#executeFetch({
+ return this.executeFetch({
...fetchOptions,
cancelRefetch: fetchOptions.cancelRefetch ?? true
}).then(() => {
this.updateResult();
- return this.#currentResult;
+ return this.currentResult;
});
}
- #executeFetch(fetchOptions) {
- this.#updateQuery();
- let promise = this.#currentQuery.fetch(
+ executeFetch(fetchOptions) {
+ this.updateQuery();
+ let promise = this.currentQuery.fetch(
this.options,
fetchOptions
);
@@ -191,61 +191,61 @@ var QueryObserver = class extends import_subscribable.Subscribable {
}
return promise;
}
- #updateStaleTimeout() {
- this.#clearStaleTimeout();
- if (import_utils.isServer || this.#currentResult.isStale || !(0, import_utils.isValidTimeout)(this.options.staleTime)) {
+ updateStaleTimeout() {
+ this.clearStaleTimeout();
+ if (import_utils.isServer || this.currentResult.isStale || !(0, import_utils.isValidTimeout)(this.options.staleTime)) {
return;
}
const time = (0, import_utils.timeUntilStale)(
- this.#currentResult.dataUpdatedAt,
+ this.currentResult.dataUpdatedAt,
this.options.staleTime
);
const timeout = time + 1;
- this.#staleTimeoutId = setTimeout(() => {
- if (!this.#currentResult.isStale) {
+ this.staleTimeoutId = setTimeout(() => {
+ if (!this.currentResult.isStale) {
this.updateResult();
}
}, timeout);
}
- #computeRefetchInterval() {
- return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
+ computeRefetchInterval() {
+ return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.currentQuery) : this.options.refetchInterval) ?? false;
}
- #updateRefetchInterval(nextInterval) {
- this.#clearRefetchInterval();
- this.#currentRefetchInterval = nextInterval;
- if (import_utils.isServer || this.options.enabled === false || !(0, import_utils.isValidTimeout)(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
+ updateRefetchInterval(nextInterval) {
+ this.clearRefetchInterval();
+ this.currentRefetchInterval = nextInterval;
+ if (import_utils.isServer || this.options.enabled === false || !(0, import_utils.isValidTimeout)(this.currentRefetchInterval) || this.currentRefetchInterval === 0) {
return;
}
- this.#refetchIntervalId = setInterval(() => {
+ this.refetchIntervalId = setInterval(() => {
if (this.options.refetchIntervalInBackground || import_focusManager.focusManager.isFocused()) {
- this.#executeFetch();
+ this.executeFetch();
}
- }, this.#currentRefetchInterval);
+ }, this.currentRefetchInterval);
}
- #updateTimers() {
- this.#updateStaleTimeout();
- this.#updateRefetchInterval(this.#computeRefetchInterval());
+ updateTimers() {
+ this.updateStaleTimeout();
+ this.updateRefetchInterval(this.computeRefetchInterval());
}
- #clearStaleTimeout() {
- if (this.#staleTimeoutId) {
- clearTimeout(this.#staleTimeoutId);
- this.#staleTimeoutId = void 0;
+ clearStaleTimeout() {
+ if (this.staleTimeoutId) {
+ clearTimeout(this.staleTimeoutId);
+ this.staleTimeoutId = void 0;
}
}
- #clearRefetchInterval() {
- if (this.#refetchIntervalId) {
- clearInterval(this.#refetchIntervalId);
- this.#refetchIntervalId = void 0;
+ clearRefetchInterval() {
+ if (this.refetchIntervalId) {
+ clearInterval(this.refetchIntervalId);
+ this.refetchIntervalId = void 0;
}
}
createResult(query, options) {
- const prevQuery = this.#currentQuery;
+ const prevQuery = this.currentQuery;
const prevOptions = this.options;
- const prevResult = this.#currentResult;
- const prevResultState = this.#currentResultState;
- const prevResultOptions = this.#currentResultOptions;
+ const prevResult = this.currentResult;
+ const prevResultState = this.currentResultState;
+ const prevResultOptions = this.currentResultOptions;
const queryChange = query !== prevQuery;
- const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;
+ const queryInitialState = queryChange ? query.state : this.currentQueryInitialState;
const { state } = query;
let newState = { ...state };
let isPlaceholderData = false;
@@ -266,17 +266,17 @@ var QueryObserver = class extends import_subscribable.Subscribable {
}
let { error, errorUpdatedAt, status } = newState;
if (options.select && newState.data !== void 0) {
- if (prevResult && newState.data === prevResultState?.data && options.select === this.#selectFn) {
- data = this.#selectResult;
+ if (prevResult && newState.data === prevResultState?.data && options.select === this.selectFn) {
+ data = this.selectResult;
} else {
try {
- this.#selectFn = options.select;
+ this.selectFn = options.select;
data = options.select(newState.data);
data = (0, import_utils.replaceData)(prevResult?.data, data, options);
- this.#selectResult = data;
- this.#selectError = null;
+ this.selectResult = data;
+ this.selectError = null;
} catch (selectError) {
- this.#selectError = selectError;
+ this.selectError = selectError;
}
}
} else {
@@ -288,15 +288,15 @@ var QueryObserver = class extends import_subscribable.Subscribable {
placeholderData = prevResult.data;
} else {
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
- this.#lastQueryWithDefinedData?.state.data,
- this.#lastQueryWithDefinedData
+ this.lastQueryWithDefinedData?.state.data,
+ this.lastQueryWithDefinedData
) : options.placeholderData;
if (options.select && placeholderData !== void 0) {
try {
placeholderData = options.select(placeholderData);
- this.#selectError = null;
+ this.selectError = null;
} catch (selectError) {
- this.#selectError = selectError;
+ this.selectError = selectError;
}
}
}
@@ -310,9 +310,9 @@ var QueryObserver = class extends import_subscribable.Subscribable {
isPlaceholderData = true;
}
}
- if (this.#selectError) {
- error = this.#selectError;
- data = this.#selectResult;
+ if (this.selectError) {
+ error = this.selectError;
+ data = this.selectResult;
errorUpdatedAt = Date.now();
status = "error";
}
@@ -350,17 +350,17 @@ var QueryObserver = class extends import_subscribable.Subscribable {
return result;
}
updateResult(notifyOptions) {
- const prevResult = this.#currentResult;
- const nextResult = this.createResult(this.#currentQuery, this.options);
- this.#currentResultState = this.#currentQuery.state;
- this.#currentResultOptions = this.options;
- if (this.#currentResultState.data !== void 0) {
- this.#lastQueryWithDefinedData = this.#currentQuery;
+ const prevResult = this.currentResult;
+ const nextResult = this.createResult(this.currentQuery, this.options);
+ this.currentResultState = this.currentQuery.state;
+ this.currentResultOptions = this.options;
+ if (this.currentResultState.data !== void 0) {
+ this.lastQueryWithDefinedData = this.currentQuery;
}
if ((0, import_utils.shallowEqualObjects)(nextResult, prevResult)) {
return;
}
- this.#currentResult = nextResult;
+ this.currentResult = nextResult;
const defaultNotifyOptions = {};
const shouldNotifyListeners = () => {
if (!prevResult) {
@@ -368,34 +368,34 @@ var QueryObserver = class extends import_subscribable.Subscribable {
}
const { notifyOnChangeProps } = this.options;
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
- if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) {
+ if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.trackedProps.size) {
return true;
}
const includedProps = new Set(
- notifyOnChangePropsValue ?? this.#trackedProps
+ notifyOnChangePropsValue ?? this.trackedProps
);
if (this.options.throwOnError) {
includedProps.add("error");
}
- return Object.keys(this.#currentResult).some((key) => {
+ return Object.keys(this.currentResult).some((key) => {
const typedKey = key;
- const changed = this.#currentResult[typedKey] !== prevResult[typedKey];
+ const changed = this.currentResult[typedKey] !== prevResult[typedKey];
return changed && includedProps.has(typedKey);
});
};
if (notifyOptions?.listeners !== false && shouldNotifyListeners()) {
defaultNotifyOptions.listeners = true;
}
- this.#notify({ ...defaultNotifyOptions, ...notifyOptions });
+ this.notify({ ...defaultNotifyOptions, ...notifyOptions });
}
- #updateQuery() {
- const query = this.#client.getQueryCache().build(this.#client, this.options);
- if (query === this.#currentQuery) {
+ updateQuery() {
+ const query = this.client.getQueryCache().build(this.client, this.options);
+ if (query === this.currentQuery) {
return;
}
- const prevQuery = this.#currentQuery;
- this.#currentQuery = query;
- this.#currentQueryInitialState = query.state;
+ const prevQuery = this.currentQuery;
+ this.currentQuery = query;
+ this.currentQueryInitialState = query.state;
if (this.hasListeners()) {
prevQuery?.removeObserver(this);
query.addObserver(this);
@@ -404,18 +404,18 @@ var QueryObserver = class extends import_subscribable.Subscribable {
onQueryUpdate() {
this.updateResult();
if (this.hasListeners()) {
- this.#updateTimers();
+ this.updateTimers();
}
}
- #notify(notifyOptions) {
+ notify(notifyOptions) {
import_notifyManager.notifyManager.batch(() => {
if (notifyOptions.listeners) {
this.listeners.forEach((listener) => {
- listener(this.#currentResult);
+ listener(this.currentResult);
});
}
- this.#client.getQueryCache().notify({
- query: this.#currentQuery,
+ this.client.getQueryCache().notify({
+ query: this.currentQuery,
type: "observerResultsUpdated"
});
});
diff --git a/node_modules/@tanstack/query-core/build/modern/removable.cjs b/node_modules/@tanstack/query-core/build/modern/removable.cjs
index 58533b0..ba8b4e0 100644
--- a/node_modules/@tanstack/query-core/build/modern/removable.cjs
+++ b/node_modules/@tanstack/query-core/build/modern/removable.cjs
@@ -25,14 +25,14 @@ __export(removable_exports, {
module.exports = __toCommonJS(removable_exports);
var import_utils = require("./utils.cjs");
var Removable = class {
- #gcTimeout;
+ gcTimeout;
destroy() {
this.clearGcTimeout();
}
scheduleGc() {
this.clearGcTimeout();
if ((0, import_utils.isValidTimeout)(this.gcTime)) {
- this.#gcTimeout = setTimeout(() => {
+ this.gcTimeout = setTimeout(() => {
this.optionalRemove();
}, this.gcTime);
}
@@ -44,9 +44,9 @@ var Removable = class {
);
}
clearGcTimeout() {
- if (this.#gcTimeout) {
- clearTimeout(this.#gcTimeout);
- this.#gcTimeout = void 0;
+ if (this.gcTimeout) {
+ clearTimeout(this.gcTimeout);
+ this.gcTimeout = void 0;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment