BLUE
PHP 7.4.33
Path:
/var/www/gtechmarathon2026.bitkit.dk/httpdocs/node_modules/@tanstack/query-core/src
Run
Logout
Edit File
Size: 6.86 KB
Close
/var/www/gtechmarathon2026.bitkit.dk/httpdocs/node_modules/@tanstack/query-core/src/mutationCache.ts
Text
Base64
import { notifyManager } from './notifyManager' import { Mutation } from './mutation' import { matchMutation, noop } from './utils' import { Subscribable } from './subscribable' import type { MutationObserver } from './mutationObserver' import type { DefaultError, MutationOptions, NotifyEvent } from './types' import type { QueryClient } from './queryClient' import type { Action, MutationState } from './mutation' import type { MutationFilters } from './utils' // TYPES interface MutationCacheConfig { onError?: ( error: DefaultError, variables: unknown, context: unknown, mutation: Mutation<unknown, unknown, unknown>, ) => Promise<unknown> | unknown onSuccess?: ( data: unknown, variables: unknown, context: unknown, mutation: Mutation<unknown, unknown, unknown>, ) => Promise<unknown> | unknown onMutate?: ( variables: unknown, mutation: Mutation<unknown, unknown, unknown>, ) => Promise<unknown> | unknown onSettled?: ( data: unknown | undefined, error: DefaultError | null, variables: unknown, context: unknown, mutation: Mutation<unknown, unknown, unknown>, ) => Promise<unknown> | unknown } interface NotifyEventMutationAdded extends NotifyEvent { type: 'added' mutation: Mutation<any, any, any, any> } interface NotifyEventMutationRemoved extends NotifyEvent { type: 'removed' mutation: Mutation<any, any, any, any> } interface NotifyEventMutationObserverAdded extends NotifyEvent { type: 'observerAdded' mutation: Mutation<any, any, any, any> observer: MutationObserver<any, any, any> } interface NotifyEventMutationObserverRemoved extends NotifyEvent { type: 'observerRemoved' mutation: Mutation<any, any, any, any> observer: MutationObserver<any, any, any> } interface NotifyEventMutationObserverOptionsUpdated extends NotifyEvent { type: 'observerOptionsUpdated' mutation?: Mutation<any, any, any, any> observer: MutationObserver<any, any, any, any> } interface NotifyEventMutationUpdated extends NotifyEvent { type: 'updated' mutation: Mutation<any, any, any, any> action: Action<any, any, any, any> } export type MutationCacheNotifyEvent = | NotifyEventMutationAdded | NotifyEventMutationRemoved | NotifyEventMutationObserverAdded | NotifyEventMutationObserverRemoved | NotifyEventMutationObserverOptionsUpdated | NotifyEventMutationUpdated type MutationCacheListener = (event: MutationCacheNotifyEvent) => void // CLASS export class MutationCache extends Subscribable<MutationCacheListener> { #mutations: Set<Mutation<any, any, any, any>> #scopes: Map<string, Array<Mutation<any, any, any, any>>> #mutationId: number constructor(public config: MutationCacheConfig = {}) { super() this.#mutations = new Set() this.#scopes = new Map() this.#mutationId = 0 } build<TData, TError, TVariables, TContext>( client: QueryClient, options: MutationOptions<TData, TError, TVariables, TContext>, state?: MutationState<TData, TError, TVariables, TContext>, ): Mutation<TData, TError, TVariables, TContext> { const mutation = new Mutation({ mutationCache: this, mutationId: ++this.#mutationId, options: client.defaultMutationOptions(options), state, }) this.add(mutation) return mutation } add(mutation: Mutation<any, any, any, any>): void { this.#mutations.add(mutation) const scope = scopeFor(mutation) if (typeof scope === 'string') { const scopedMutations = this.#scopes.get(scope) if (scopedMutations) { scopedMutations.push(mutation) } else { this.#scopes.set(scope, [mutation]) } } this.notify({ type: 'added', mutation }) } remove(mutation: Mutation<any, any, any, any>): void { if (this.#mutations.delete(mutation)) { const scope = scopeFor(mutation) if (typeof scope === 'string') { const scopedMutations = this.#scopes.get(scope) if (scopedMutations) { if (scopedMutations.length > 1) { const index = scopedMutations.indexOf(mutation) if (index !== -1) { scopedMutations.splice(index, 1) } } else if (scopedMutations[0] === mutation) { this.#scopes.delete(scope) } } } } // Currently we notify the removal even if the mutation was already removed. // Consider making this an error or not notifying of the removal depending on the desired semantics. this.notify({ type: 'removed', mutation }) } canRun(mutation: Mutation<any, any, any, any>): boolean { const scope = scopeFor(mutation) if (typeof scope === 'string') { const mutationsWithSameScope = this.#scopes.get(scope) const firstPendingMutation = mutationsWithSameScope?.find( (m) => m.state.status === 'pending', ) // we can run if there is no current pending mutation (start use-case) // or if WE are the first pending mutation (continue use-case) return !firstPendingMutation || firstPendingMutation === mutation } else { // For unscoped mutations there are never any pending mutations in front of the // current mutation return true } } runNext(mutation: Mutation<any, any, any, any>): Promise<unknown> { const scope = scopeFor(mutation) if (typeof scope === 'string') { const foundMutation = this.#scopes .get(scope) ?.find((m) => m !== mutation && m.state.isPaused) return foundMutation?.continue() ?? Promise.resolve() } else { return Promise.resolve() } } clear(): void { notifyManager.batch(() => { this.#mutations.forEach((mutation) => { this.notify({ type: 'removed', mutation }) }) this.#mutations.clear() this.#scopes.clear() }) } getAll(): Array<Mutation> { return Array.from(this.#mutations) } find< TData = unknown, TError = DefaultError, TVariables = any, TContext = unknown, >( filters: MutationFilters, ): Mutation<TData, TError, TVariables, TContext> | undefined { const defaultedFilters = { exact: true, ...filters } return this.getAll().find((mutation) => matchMutation(defaultedFilters, mutation), ) as Mutation<TData, TError, TVariables, TContext> | undefined } findAll(filters: MutationFilters = {}): Array<Mutation> { return this.getAll().filter((mutation) => matchMutation(filters, mutation)) } notify(event: MutationCacheNotifyEvent) { notifyManager.batch(() => { this.listeners.forEach((listener) => { listener(event) }) }) } resumePausedMutations(): Promise<unknown> { const pausedMutations = this.getAll().filter((x) => x.state.isPaused) return notifyManager.batch(() => Promise.all( pausedMutations.map((mutation) => mutation.continue().catch(noop)), ), ) } } function scopeFor(mutation: Mutation<any, any, any, any>) { return mutation.options.scope?.id }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 22
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
focusManager.ts
2.06 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
hydration.ts
8.08 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.ts
1.52 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
infiniteQueryBehavior.ts
5.27 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
infiniteQueryObserver.ts
4.69 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
mutation.ts
8.98 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
mutationCache.ts
6.86 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
mutationObserver.ts
4.76 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
notifyManager.ts
2.36 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
onlineManager.ts
1.77 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
queriesObserver.ts
7.54 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
query.ts
18.48 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
queryCache.ts
5.55 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
queryClient.ts
16.36 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
queryObserver.ts
22.87 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
removable.ts
851 B
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
retryer.ts
5.50 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
streamedQuery.ts
2.71 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
subscribable.ts
557 B
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
thenable.ts
2.87 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
types.ts
38.76 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
utils.ts
11.10 KB
lrw-r--r--
2025-07-14 06:33:17
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).