@astral/mobx-query 1.15.0 → 1.16.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/MobxQuery/MobxQuery.d.ts +13 -8
- package/MobxQuery/MobxQuery.js +19 -18
- package/MobxQuery/types.d.ts +22 -0
- package/MobxQuery/types.js +1 -0
- package/PollingService/PollingService.d.ts +34 -0
- package/PollingService/PollingService.js +95 -0
- package/PollingService/index.d.ts +1 -0
- package/PollingService/index.js +1 -0
- package/README.md +22 -0
- package/SynchronizationService/SynchronizationService.d.ts +5 -5
- package/SynchronizationService/SynchronizationService.js +4 -7
- package/__test/BroadcastChannel/BroadcastChannel.d.ts +1 -0
- package/__test/BroadcastChannel/BroadcastChannel.js +13 -0
- package/__test/BroadcastChannel/index.d.ts +1 -0
- package/__test/BroadcastChannel/index.js +1 -0
- package/__test/documentMock/documentMock.d.ts +380 -0
- package/__test/documentMock/documentMock.js +18 -0
- package/__test/documentMock/index.d.ts +1 -0
- package/__test/documentMock/index.js +1 -0
- package/__test/index.d.ts +2 -0
- package/__test/index.js +2 -0
- package/node/MobxQuery/MobxQuery.d.ts +13 -8
- package/node/MobxQuery/MobxQuery.js +19 -18
- package/node/MobxQuery/types.d.ts +22 -0
- package/node/MobxQuery/types.js +2 -0
- package/node/PollingService/PollingService.d.ts +34 -0
- package/node/PollingService/PollingService.js +99 -0
- package/node/PollingService/index.d.ts +1 -0
- package/node/PollingService/index.js +17 -0
- package/node/SynchronizationService/SynchronizationService.d.ts +5 -5
- package/node/SynchronizationService/SynchronizationService.js +4 -7
- package/node/__test/BroadcastChannel/BroadcastChannel.d.ts +1 -0
- package/node/__test/BroadcastChannel/BroadcastChannel.js +17 -0
- package/node/__test/BroadcastChannel/index.d.ts +1 -0
- package/node/__test/BroadcastChannel/index.js +17 -0
- package/node/__test/documentMock/documentMock.d.ts +380 -0
- package/node/__test/documentMock/documentMock.js +22 -0
- package/node/__test/documentMock/index.d.ts +1 -0
- package/node/__test/documentMock/index.js +17 -0
- package/node/__test/index.d.ts +2 -0
- package/node/__test/index.js +18 -0
- package/package.json +4 -2
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
export declare const createDocumentMock: () => {
|
|
2
|
+
documentMock: {
|
|
3
|
+
readonly URL: string;
|
|
4
|
+
alinkColor: string;
|
|
5
|
+
readonly all: HTMLAllCollection;
|
|
6
|
+
readonly anchors: HTMLCollectionOf<HTMLAnchorElement>;
|
|
7
|
+
readonly applets: HTMLCollection;
|
|
8
|
+
bgColor: string;
|
|
9
|
+
body: HTMLElement;
|
|
10
|
+
readonly characterSet: string;
|
|
11
|
+
readonly charset: string;
|
|
12
|
+
readonly compatMode: string;
|
|
13
|
+
readonly contentType: string;
|
|
14
|
+
cookie: string;
|
|
15
|
+
readonly currentScript: HTMLOrSVGScriptElement | null;
|
|
16
|
+
readonly defaultView: (WindowProxy & typeof globalThis) | null;
|
|
17
|
+
designMode: string;
|
|
18
|
+
dir: string;
|
|
19
|
+
readonly doctype: DocumentType | null;
|
|
20
|
+
readonly documentElement: HTMLElement;
|
|
21
|
+
readonly documentURI: string;
|
|
22
|
+
domain: string;
|
|
23
|
+
readonly embeds: HTMLCollectionOf<HTMLEmbedElement>;
|
|
24
|
+
fgColor: string;
|
|
25
|
+
readonly forms: HTMLCollectionOf<HTMLFormElement>;
|
|
26
|
+
readonly fragmentDirective: FragmentDirective;
|
|
27
|
+
readonly fullscreen: boolean;
|
|
28
|
+
readonly fullscreenEnabled: boolean;
|
|
29
|
+
readonly head: HTMLHeadElement;
|
|
30
|
+
readonly hidden: boolean;
|
|
31
|
+
readonly images: HTMLCollectionOf<HTMLImageElement>;
|
|
32
|
+
readonly implementation: DOMImplementation;
|
|
33
|
+
readonly inputEncoding: string;
|
|
34
|
+
readonly lastModified: string;
|
|
35
|
+
linkColor: string;
|
|
36
|
+
readonly links: HTMLCollectionOf<HTMLAnchorElement | HTMLAreaElement>;
|
|
37
|
+
location: Location;
|
|
38
|
+
onfullscreenchange: ((this: Document, ev: Event) => any) | null;
|
|
39
|
+
onfullscreenerror: ((this: Document, ev: Event) => any) | null;
|
|
40
|
+
onpointerlockchange: ((this: Document, ev: Event) => any) | null;
|
|
41
|
+
onpointerlockerror: ((this: Document, ev: Event) => any) | null;
|
|
42
|
+
onreadystatechange: ((this: Document, ev: Event) => any) | null;
|
|
43
|
+
onvisibilitychange: ((this: Document, ev: Event) => any) | null;
|
|
44
|
+
readonly ownerDocument: null;
|
|
45
|
+
readonly pictureInPictureEnabled: boolean;
|
|
46
|
+
readonly plugins: HTMLCollectionOf<HTMLEmbedElement>;
|
|
47
|
+
readonly readyState: DocumentReadyState;
|
|
48
|
+
readonly referrer: string;
|
|
49
|
+
readonly rootElement: SVGSVGElement | null;
|
|
50
|
+
readonly scripts: HTMLCollectionOf<HTMLScriptElement>;
|
|
51
|
+
readonly scrollingElement: Element | null;
|
|
52
|
+
readonly timeline: DocumentTimeline;
|
|
53
|
+
title: string;
|
|
54
|
+
readonly visibilityState: DocumentVisibilityState;
|
|
55
|
+
vlinkColor: string;
|
|
56
|
+
adoptNode: (<T extends Node>(node: T) => T) & import("vitest-mock-extended").CalledWithMock<Node, [node: Node]>;
|
|
57
|
+
captureEvents: (() => void) & import("vitest-mock-extended").CalledWithMock<void, []>;
|
|
58
|
+
caretPositionFromPoint: ((x: number, y: number, options?: CaretPositionFromPointOptions) => CaretPosition | null) & import("vitest-mock-extended").CalledWithMock<CaretPosition | null, [x: number, y: number, options?: CaretPositionFromPointOptions | undefined]>;
|
|
59
|
+
caretRangeFromPoint: ((x: number, y: number) => Range | null) & import("vitest-mock-extended").CalledWithMock<Range | null, [x: number, y: number]>;
|
|
60
|
+
clear: (() => void) & import("vitest-mock-extended").CalledWithMock<void, []>;
|
|
61
|
+
close: (() => void) & import("vitest-mock-extended").CalledWithMock<void, []>;
|
|
62
|
+
createAttribute: ((localName: string) => Attr) & import("vitest-mock-extended").CalledWithMock<Attr, [localName: string]>;
|
|
63
|
+
createAttributeNS: ((namespace: string | null, qualifiedName: string) => Attr) & import("vitest-mock-extended").CalledWithMock<Attr, [namespace: string | null, qualifiedName: string]>;
|
|
64
|
+
createCDATASection: ((data: string) => CDATASection) & import("vitest-mock-extended").CalledWithMock<CDATASection, [data: string]>;
|
|
65
|
+
createComment: ((data: string) => Comment) & import("vitest-mock-extended").CalledWithMock<Comment, [data: string]>;
|
|
66
|
+
createDocumentFragment: (() => DocumentFragment) & import("vitest-mock-extended").CalledWithMock<DocumentFragment, []>;
|
|
67
|
+
createElement: {
|
|
68
|
+
<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K];
|
|
69
|
+
<K extends keyof HTMLElementDeprecatedTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementDeprecatedTagNameMap[K];
|
|
70
|
+
(tagName: string, options?: ElementCreationOptions): HTMLElement;
|
|
71
|
+
} & import("vitest-mock-extended").CalledWithMock<HTMLElement, [tagName: string, options?: ElementCreationOptions | undefined]>;
|
|
72
|
+
createElementNS: {
|
|
73
|
+
(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: string): HTMLElement;
|
|
74
|
+
<K extends keyof SVGElementTagNameMap>(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: K): SVGElementTagNameMap[K];
|
|
75
|
+
(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement;
|
|
76
|
+
<K extends keyof MathMLElementTagNameMap>(namespaceURI: "http://www.w3.org/1998/Math/MathML", qualifiedName: K): MathMLElementTagNameMap[K];
|
|
77
|
+
(namespaceURI: "http://www.w3.org/1998/Math/MathML", qualifiedName: string): MathMLElement;
|
|
78
|
+
(namespaceURI: string | null, qualifiedName: string, options?: ElementCreationOptions): Element;
|
|
79
|
+
(namespace: string | null, qualifiedName: string, options?: string | ElementCreationOptions): Element;
|
|
80
|
+
} & import("vitest-mock-extended").CalledWithMock<Element, [namespace: string | null, qualifiedName: string, options?: string | ElementCreationOptions | undefined]>;
|
|
81
|
+
createEvent: {
|
|
82
|
+
(eventInterface: "AnimationEvent"): AnimationEvent;
|
|
83
|
+
(eventInterface: "AnimationPlaybackEvent"): AnimationPlaybackEvent;
|
|
84
|
+
(eventInterface: "AudioProcessingEvent"): AudioProcessingEvent;
|
|
85
|
+
(eventInterface: "BeforeUnloadEvent"): BeforeUnloadEvent;
|
|
86
|
+
(eventInterface: "BlobEvent"): BlobEvent;
|
|
87
|
+
(eventInterface: "ClipboardEvent"): ClipboardEvent;
|
|
88
|
+
(eventInterface: "CloseEvent"): CloseEvent;
|
|
89
|
+
(eventInterface: "CompositionEvent"): CompositionEvent;
|
|
90
|
+
(eventInterface: "ContentVisibilityAutoStateChangeEvent"): ContentVisibilityAutoStateChangeEvent;
|
|
91
|
+
(eventInterface: "CustomEvent"): CustomEvent;
|
|
92
|
+
(eventInterface: "DeviceMotionEvent"): DeviceMotionEvent;
|
|
93
|
+
(eventInterface: "DeviceOrientationEvent"): DeviceOrientationEvent;
|
|
94
|
+
(eventInterface: "DragEvent"): DragEvent;
|
|
95
|
+
(eventInterface: "ErrorEvent"): ErrorEvent;
|
|
96
|
+
(eventInterface: "Event"): Event;
|
|
97
|
+
(eventInterface: "Events"): Event;
|
|
98
|
+
(eventInterface: "FocusEvent"): FocusEvent;
|
|
99
|
+
(eventInterface: "FontFaceSetLoadEvent"): FontFaceSetLoadEvent;
|
|
100
|
+
(eventInterface: "FormDataEvent"): FormDataEvent;
|
|
101
|
+
(eventInterface: "GamepadEvent"): GamepadEvent;
|
|
102
|
+
(eventInterface: "HashChangeEvent"): HashChangeEvent;
|
|
103
|
+
(eventInterface: "IDBVersionChangeEvent"): IDBVersionChangeEvent;
|
|
104
|
+
(eventInterface: "InputEvent"): InputEvent;
|
|
105
|
+
(eventInterface: "KeyboardEvent"): KeyboardEvent;
|
|
106
|
+
(eventInterface: "MIDIConnectionEvent"): MIDIConnectionEvent;
|
|
107
|
+
(eventInterface: "MIDIMessageEvent"): MIDIMessageEvent;
|
|
108
|
+
(eventInterface: "MediaEncryptedEvent"): MediaEncryptedEvent;
|
|
109
|
+
(eventInterface: "MediaKeyMessageEvent"): MediaKeyMessageEvent;
|
|
110
|
+
(eventInterface: "MediaQueryListEvent"): MediaQueryListEvent;
|
|
111
|
+
(eventInterface: "MediaStreamTrackEvent"): MediaStreamTrackEvent;
|
|
112
|
+
(eventInterface: "MessageEvent"): MessageEvent;
|
|
113
|
+
(eventInterface: "MouseEvent"): MouseEvent;
|
|
114
|
+
(eventInterface: "MouseEvents"): MouseEvent;
|
|
115
|
+
(eventInterface: "OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent;
|
|
116
|
+
(eventInterface: "PageRevealEvent"): PageRevealEvent;
|
|
117
|
+
(eventInterface: "PageSwapEvent"): PageSwapEvent;
|
|
118
|
+
(eventInterface: "PageTransitionEvent"): PageTransitionEvent;
|
|
119
|
+
(eventInterface: "PaymentMethodChangeEvent"): PaymentMethodChangeEvent;
|
|
120
|
+
(eventInterface: "PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent;
|
|
121
|
+
(eventInterface: "PictureInPictureEvent"): PictureInPictureEvent;
|
|
122
|
+
(eventInterface: "PointerEvent"): PointerEvent;
|
|
123
|
+
(eventInterface: "PopStateEvent"): PopStateEvent;
|
|
124
|
+
(eventInterface: "ProgressEvent"): ProgressEvent;
|
|
125
|
+
(eventInterface: "PromiseRejectionEvent"): PromiseRejectionEvent;
|
|
126
|
+
(eventInterface: "RTCDTMFToneChangeEvent"): RTCDTMFToneChangeEvent;
|
|
127
|
+
(eventInterface: "RTCDataChannelEvent"): RTCDataChannelEvent;
|
|
128
|
+
(eventInterface: "RTCErrorEvent"): RTCErrorEvent;
|
|
129
|
+
(eventInterface: "RTCPeerConnectionIceErrorEvent"): RTCPeerConnectionIceErrorEvent;
|
|
130
|
+
(eventInterface: "RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent;
|
|
131
|
+
(eventInterface: "RTCTrackEvent"): RTCTrackEvent;
|
|
132
|
+
(eventInterface: "SecurityPolicyViolationEvent"): SecurityPolicyViolationEvent;
|
|
133
|
+
(eventInterface: "SpeechSynthesisErrorEvent"): SpeechSynthesisErrorEvent;
|
|
134
|
+
(eventInterface: "SpeechSynthesisEvent"): SpeechSynthesisEvent;
|
|
135
|
+
(eventInterface: "StorageEvent"): StorageEvent;
|
|
136
|
+
(eventInterface: "SubmitEvent"): SubmitEvent;
|
|
137
|
+
(eventInterface: "TextEvent"): TextEvent;
|
|
138
|
+
(eventInterface: "ToggleEvent"): ToggleEvent;
|
|
139
|
+
(eventInterface: "TouchEvent"): TouchEvent;
|
|
140
|
+
(eventInterface: "TrackEvent"): TrackEvent;
|
|
141
|
+
(eventInterface: "TransitionEvent"): TransitionEvent;
|
|
142
|
+
(eventInterface: "UIEvent"): UIEvent;
|
|
143
|
+
(eventInterface: "UIEvents"): UIEvent;
|
|
144
|
+
(eventInterface: "WebGLContextEvent"): WebGLContextEvent;
|
|
145
|
+
(eventInterface: "WheelEvent"): WheelEvent;
|
|
146
|
+
(eventInterface: string): Event;
|
|
147
|
+
} & import("vitest-mock-extended").CalledWithMock<Event, [eventInterface: string]>;
|
|
148
|
+
createNodeIterator: ((root: Node, whatToShow?: number, filter?: NodeFilter | null) => NodeIterator) & import("vitest-mock-extended").CalledWithMock<NodeIterator, [root: Node, whatToShow?: number | undefined, filter?: NodeFilter | null | undefined]>;
|
|
149
|
+
createProcessingInstruction: ((target: string, data: string) => ProcessingInstruction) & import("vitest-mock-extended").CalledWithMock<ProcessingInstruction, [target: string, data: string]>;
|
|
150
|
+
createRange: (() => Range) & import("vitest-mock-extended").CalledWithMock<Range, []>;
|
|
151
|
+
createTextNode: ((data: string) => Text) & import("vitest-mock-extended").CalledWithMock<Text, [data: string]>;
|
|
152
|
+
createTreeWalker: ((root: Node, whatToShow?: number, filter?: NodeFilter | null) => TreeWalker) & import("vitest-mock-extended").CalledWithMock<TreeWalker, [root: Node, whatToShow?: number | undefined, filter?: NodeFilter | null | undefined]>;
|
|
153
|
+
execCommand: ((commandId: string, showUI?: boolean, value?: string) => boolean) & import("vitest-mock-extended").CalledWithMock<boolean, [commandId: string, showUI?: boolean | undefined, value?: string | undefined]>;
|
|
154
|
+
exitFullscreen: (() => Promise<void>) & import("vitest-mock-extended").CalledWithMock<Promise<void>, []>;
|
|
155
|
+
exitPictureInPicture: (() => Promise<void>) & import("vitest-mock-extended").CalledWithMock<Promise<void>, []>;
|
|
156
|
+
exitPointerLock: (() => void) & import("vitest-mock-extended").CalledWithMock<void, []>;
|
|
157
|
+
getElementById: ((elementId: string) => HTMLElement | null) & import("vitest-mock-extended").CalledWithMock<HTMLElement | null, [elementId: string]>;
|
|
158
|
+
getElementsByClassName: ((classNames: string) => HTMLCollectionOf<Element>) & import("vitest-mock-extended").CalledWithMock<HTMLCollectionOf<Element>, [classNames: string]>;
|
|
159
|
+
getElementsByName: ((elementName: string) => NodeListOf<HTMLElement>) & import("vitest-mock-extended").CalledWithMock<NodeListOf<HTMLElement>, [elementName: string]>;
|
|
160
|
+
getElementsByTagName: {
|
|
161
|
+
<K extends keyof HTMLElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>;
|
|
162
|
+
<K extends keyof SVGElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>;
|
|
163
|
+
<K extends keyof MathMLElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<MathMLElementTagNameMap[K]>;
|
|
164
|
+
<K extends keyof HTMLElementDeprecatedTagNameMap>(qualifiedName: K): HTMLCollectionOf<HTMLElementDeprecatedTagNameMap[K]>;
|
|
165
|
+
(qualifiedName: string): HTMLCollectionOf<Element>;
|
|
166
|
+
} & import("vitest-mock-extended").CalledWithMock<HTMLCollectionOf<Element>, [qualifiedName: string]>;
|
|
167
|
+
getElementsByTagNameNS: {
|
|
168
|
+
(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf<HTMLElement>;
|
|
169
|
+
(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>;
|
|
170
|
+
(namespaceURI: "http://www.w3.org/1998/Math/MathML", localName: string): HTMLCollectionOf<MathMLElement>;
|
|
171
|
+
(namespace: string | null, localName: string): HTMLCollectionOf<Element>;
|
|
172
|
+
} & import("vitest-mock-extended").CalledWithMock<HTMLCollectionOf<Element>, [namespace: string | null, localName: string]>;
|
|
173
|
+
getSelection: (() => Selection | null) & import("vitest-mock-extended").CalledWithMock<Selection | null, []>;
|
|
174
|
+
hasFocus: (() => boolean) & import("vitest-mock-extended").CalledWithMock<boolean, []>;
|
|
175
|
+
hasStorageAccess: (() => Promise<boolean>) & import("vitest-mock-extended").CalledWithMock<Promise<boolean>, []>;
|
|
176
|
+
importNode: (<T extends Node>(node: T, subtree?: boolean) => T) & import("vitest-mock-extended").CalledWithMock<Node, [node: Node, subtree?: boolean | undefined]>;
|
|
177
|
+
open: {
|
|
178
|
+
(unused1?: string, unused2?: string): Document;
|
|
179
|
+
(url: string | URL, name: string, features: string): WindowProxy | null;
|
|
180
|
+
} & import("vitest-mock-extended").CalledWithMock<Window | null, [url: string | URL, name: string, features: string]>;
|
|
181
|
+
queryCommandEnabled: ((commandId: string) => boolean) & import("vitest-mock-extended").CalledWithMock<boolean, [commandId: string]>;
|
|
182
|
+
queryCommandIndeterm: ((commandId: string) => boolean) & import("vitest-mock-extended").CalledWithMock<boolean, [commandId: string]>;
|
|
183
|
+
queryCommandState: ((commandId: string) => boolean) & import("vitest-mock-extended").CalledWithMock<boolean, [commandId: string]>;
|
|
184
|
+
queryCommandSupported: ((commandId: string) => boolean) & import("vitest-mock-extended").CalledWithMock<boolean, [commandId: string]>;
|
|
185
|
+
queryCommandValue: ((commandId: string) => string) & import("vitest-mock-extended").CalledWithMock<string, [commandId: string]>;
|
|
186
|
+
releaseEvents: (() => void) & import("vitest-mock-extended").CalledWithMock<void, []>;
|
|
187
|
+
requestStorageAccess: (() => Promise<void>) & import("vitest-mock-extended").CalledWithMock<Promise<void>, []>;
|
|
188
|
+
startViewTransition: ((callbackOptions?: ViewTransitionUpdateCallback) => ViewTransition) & import("vitest-mock-extended").CalledWithMock<ViewTransition, [callbackOptions?: ViewTransitionUpdateCallback | undefined]>;
|
|
189
|
+
write: ((...text: string[]) => void) & import("vitest-mock-extended").CalledWithMock<void, string[]>;
|
|
190
|
+
writeln: ((...text: string[]) => void) & import("vitest-mock-extended").CalledWithMock<void, string[]>;
|
|
191
|
+
addEventListener: {
|
|
192
|
+
<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
193
|
+
(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
194
|
+
} & import("vitest-mock-extended").CalledWithMock<void, [type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined]>;
|
|
195
|
+
removeEventListener: {
|
|
196
|
+
<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
197
|
+
(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
198
|
+
} & import("vitest-mock-extended").CalledWithMock<void, [type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined]>;
|
|
199
|
+
readonly baseURI: string;
|
|
200
|
+
readonly childNodes: NodeListOf<ChildNode>;
|
|
201
|
+
readonly firstChild: ChildNode | null;
|
|
202
|
+
readonly isConnected: boolean;
|
|
203
|
+
readonly lastChild: ChildNode | null;
|
|
204
|
+
readonly nextSibling: ChildNode | null;
|
|
205
|
+
readonly nodeName: string;
|
|
206
|
+
readonly nodeType: number;
|
|
207
|
+
nodeValue: string | null;
|
|
208
|
+
readonly parentElement: HTMLElement | null;
|
|
209
|
+
readonly parentNode: ParentNode | null;
|
|
210
|
+
readonly previousSibling: ChildNode | null;
|
|
211
|
+
textContent: string | null;
|
|
212
|
+
appendChild: (<T extends Node>(node: T) => T) & import("vitest-mock-extended").CalledWithMock<Node, [node: Node]>;
|
|
213
|
+
cloneNode: ((subtree?: boolean) => Node) & import("vitest-mock-extended").CalledWithMock<Node, [subtree?: boolean | undefined]>;
|
|
214
|
+
compareDocumentPosition: ((other: Node) => number) & import("vitest-mock-extended").CalledWithMock<number, [other: Node]>;
|
|
215
|
+
contains: ((other: Node | null) => boolean) & import("vitest-mock-extended").CalledWithMock<boolean, [other: Node | null]>;
|
|
216
|
+
getRootNode: ((options?: GetRootNodeOptions) => Node) & import("vitest-mock-extended").CalledWithMock<Node, [options?: GetRootNodeOptions | undefined]>;
|
|
217
|
+
hasChildNodes: (() => boolean) & import("vitest-mock-extended").CalledWithMock<boolean, []>;
|
|
218
|
+
insertBefore: (<T extends Node>(node: T, child: Node | null) => T) & import("vitest-mock-extended").CalledWithMock<Node, [node: Node, child: Node | null]>;
|
|
219
|
+
isDefaultNamespace: ((namespace: string | null) => boolean) & import("vitest-mock-extended").CalledWithMock<boolean, [namespace: string | null]>;
|
|
220
|
+
isEqualNode: ((otherNode: Node | null) => boolean) & import("vitest-mock-extended").CalledWithMock<boolean, [otherNode: Node | null]>;
|
|
221
|
+
isSameNode: ((otherNode: Node | null) => boolean) & import("vitest-mock-extended").CalledWithMock<boolean, [otherNode: Node | null]>;
|
|
222
|
+
lookupNamespaceURI: ((prefix: string | null) => string | null) & import("vitest-mock-extended").CalledWithMock<string | null, [prefix: string | null]>;
|
|
223
|
+
lookupPrefix: ((namespace: string | null) => string | null) & import("vitest-mock-extended").CalledWithMock<string | null, [namespace: string | null]>;
|
|
224
|
+
normalize: (() => void) & import("vitest-mock-extended").CalledWithMock<void, []>;
|
|
225
|
+
removeChild: (<T extends Node>(child: T) => T) & import("vitest-mock-extended").CalledWithMock<Node, [child: Node]>;
|
|
226
|
+
replaceChild: (<T extends Node>(node: Node, child: T) => T) & import("vitest-mock-extended").CalledWithMock<Node, [node: Node, child: Node]>;
|
|
227
|
+
readonly ELEMENT_NODE: 1;
|
|
228
|
+
readonly ATTRIBUTE_NODE: 2;
|
|
229
|
+
readonly TEXT_NODE: 3;
|
|
230
|
+
readonly CDATA_SECTION_NODE: 4;
|
|
231
|
+
readonly ENTITY_REFERENCE_NODE: 5;
|
|
232
|
+
readonly ENTITY_NODE: 6;
|
|
233
|
+
readonly PROCESSING_INSTRUCTION_NODE: 7;
|
|
234
|
+
readonly COMMENT_NODE: 8;
|
|
235
|
+
readonly DOCUMENT_NODE: 9;
|
|
236
|
+
readonly DOCUMENT_TYPE_NODE: 10;
|
|
237
|
+
readonly DOCUMENT_FRAGMENT_NODE: 11;
|
|
238
|
+
readonly NOTATION_NODE: 12;
|
|
239
|
+
readonly DOCUMENT_POSITION_DISCONNECTED: 1;
|
|
240
|
+
readonly DOCUMENT_POSITION_PRECEDING: 2;
|
|
241
|
+
readonly DOCUMENT_POSITION_FOLLOWING: 4;
|
|
242
|
+
readonly DOCUMENT_POSITION_CONTAINS: 8;
|
|
243
|
+
readonly DOCUMENT_POSITION_CONTAINED_BY: 16;
|
|
244
|
+
readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32;
|
|
245
|
+
dispatchEvent: ((event: Event) => boolean) & import("vitest-mock-extended").CalledWithMock<boolean, [event: Event]>;
|
|
246
|
+
readonly activeElement: Element | null;
|
|
247
|
+
adoptedStyleSheets: CSSStyleSheet[];
|
|
248
|
+
readonly fullscreenElement: Element | null;
|
|
249
|
+
readonly pictureInPictureElement: Element | null;
|
|
250
|
+
readonly pointerLockElement: Element | null;
|
|
251
|
+
readonly styleSheets: StyleSheetList;
|
|
252
|
+
elementFromPoint: ((x: number, y: number) => Element | null) & import("vitest-mock-extended").CalledWithMock<Element | null, [x: number, y: number]>;
|
|
253
|
+
elementsFromPoint: ((x: number, y: number) => Element[]) & import("vitest-mock-extended").CalledWithMock<Element[], [x: number, y: number]>;
|
|
254
|
+
getAnimations: (() => Animation[]) & import("vitest-mock-extended").CalledWithMock<Animation[], []>;
|
|
255
|
+
readonly fonts: FontFaceSet;
|
|
256
|
+
onabort: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
|
|
257
|
+
onanimationcancel: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
|
|
258
|
+
onanimationend: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
|
|
259
|
+
onanimationiteration: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
|
|
260
|
+
onanimationstart: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
|
|
261
|
+
onauxclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
262
|
+
onbeforeinput: ((this: GlobalEventHandlers, ev: InputEvent) => any) | null;
|
|
263
|
+
onbeforetoggle: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
264
|
+
onblur: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
|
|
265
|
+
oncancel: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
266
|
+
oncanplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
267
|
+
oncanplaythrough: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
268
|
+
onchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
269
|
+
onclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
270
|
+
onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
271
|
+
oncontextlost: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
272
|
+
oncontextmenu: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
273
|
+
oncontextrestored: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
274
|
+
oncopy: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
275
|
+
oncuechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
276
|
+
oncut: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
277
|
+
ondblclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
278
|
+
ondrag: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
279
|
+
ondragend: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
280
|
+
ondragenter: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
281
|
+
ondragleave: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
282
|
+
ondragover: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
283
|
+
ondragstart: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
284
|
+
ondrop: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
285
|
+
ondurationchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
286
|
+
onemptied: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
287
|
+
onended: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
288
|
+
onerror: OnErrorEventHandler;
|
|
289
|
+
onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
|
|
290
|
+
onformdata: ((this: GlobalEventHandlers, ev: FormDataEvent) => any) | null;
|
|
291
|
+
ongotpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
292
|
+
oninput: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
293
|
+
oninvalid: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
294
|
+
onkeydown: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
|
|
295
|
+
onkeypress: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
|
|
296
|
+
onkeyup: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
|
|
297
|
+
onload: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
298
|
+
onloadeddata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
299
|
+
onloadedmetadata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
300
|
+
onloadstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
301
|
+
onlostpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
302
|
+
onmousedown: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
303
|
+
onmouseenter: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
304
|
+
onmouseleave: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
305
|
+
onmousemove: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
306
|
+
onmouseout: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
307
|
+
onmouseover: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
308
|
+
onmouseup: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
309
|
+
onpaste: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
310
|
+
onpause: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
311
|
+
onplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
312
|
+
onplaying: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
313
|
+
onpointercancel: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
314
|
+
onpointerdown: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
315
|
+
onpointerenter: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
316
|
+
onpointerleave: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
317
|
+
onpointermove: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
318
|
+
onpointerout: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
319
|
+
onpointerover: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
320
|
+
onpointerup: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
321
|
+
onprogress: ((this: GlobalEventHandlers, ev: ProgressEvent) => any) | null;
|
|
322
|
+
onratechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
323
|
+
onreset: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
324
|
+
onresize: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
|
|
325
|
+
onscroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
326
|
+
onscrollend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
327
|
+
onsecuritypolicyviolation: ((this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any) | null;
|
|
328
|
+
onseeked: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
329
|
+
onseeking: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
330
|
+
onselect: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
331
|
+
onselectionchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
332
|
+
onselectstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
333
|
+
onslotchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
334
|
+
onstalled: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
335
|
+
onsubmit: ((this: GlobalEventHandlers, ev: SubmitEvent) => any) | null;
|
|
336
|
+
onsuspend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
337
|
+
ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
338
|
+
ontoggle: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
339
|
+
ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined | undefined;
|
|
340
|
+
ontouchend?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined | undefined;
|
|
341
|
+
ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined | undefined;
|
|
342
|
+
ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined | undefined;
|
|
343
|
+
ontransitioncancel: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
|
|
344
|
+
ontransitionend: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
|
|
345
|
+
ontransitionrun: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
|
|
346
|
+
ontransitionstart: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
|
|
347
|
+
onvolumechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
348
|
+
onwaiting: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
349
|
+
onwebkitanimationend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
350
|
+
onwebkitanimationiteration: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
351
|
+
onwebkitanimationstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
352
|
+
onwebkittransitionend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
353
|
+
onwheel: ((this: GlobalEventHandlers, ev: WheelEvent) => any) | null;
|
|
354
|
+
readonly childElementCount: number;
|
|
355
|
+
readonly children: HTMLCollection;
|
|
356
|
+
readonly firstElementChild: Element | null;
|
|
357
|
+
readonly lastElementChild: Element | null;
|
|
358
|
+
append: ((...nodes: (Node | string)[]) => void) & import("vitest-mock-extended").CalledWithMock<void, (string | Node)[]>;
|
|
359
|
+
prepend: ((...nodes: (Node | string)[]) => void) & import("vitest-mock-extended").CalledWithMock<void, (string | Node)[]>;
|
|
360
|
+
querySelector: {
|
|
361
|
+
<K extends keyof HTMLElementTagNameMap>(selectors: K): HTMLElementTagNameMap[K] | null;
|
|
362
|
+
<K extends keyof SVGElementTagNameMap>(selectors: K): SVGElementTagNameMap[K] | null;
|
|
363
|
+
<K extends keyof MathMLElementTagNameMap>(selectors: K): MathMLElementTagNameMap[K] | null;
|
|
364
|
+
<K extends keyof HTMLElementDeprecatedTagNameMap>(selectors: K): HTMLElementDeprecatedTagNameMap[K] | null;
|
|
365
|
+
<E extends Element = Element>(selectors: string): E | null;
|
|
366
|
+
} & import("vitest-mock-extended").CalledWithMock<Element | null, [selectors: string]>;
|
|
367
|
+
querySelectorAll: {
|
|
368
|
+
<K extends keyof HTMLElementTagNameMap>(selectors: K): NodeListOf<HTMLElementTagNameMap[K]>;
|
|
369
|
+
<K extends keyof SVGElementTagNameMap>(selectors: K): NodeListOf<SVGElementTagNameMap[K]>;
|
|
370
|
+
<K extends keyof MathMLElementTagNameMap>(selectors: K): NodeListOf<MathMLElementTagNameMap[K]>;
|
|
371
|
+
<K extends keyof HTMLElementDeprecatedTagNameMap>(selectors: K): NodeListOf<HTMLElementDeprecatedTagNameMap[K]>;
|
|
372
|
+
<E extends Element = Element>(selectors: string): NodeListOf<E>;
|
|
373
|
+
} & import("vitest-mock-extended").CalledWithMock<NodeListOf<Element>, [selectors: string]>;
|
|
374
|
+
replaceChildren: ((...nodes: (Node | string)[]) => void) & import("vitest-mock-extended").CalledWithMock<void, (string | Node)[]>;
|
|
375
|
+
createExpression: ((expression: string, resolver?: XPathNSResolver | null) => XPathExpression) & import("vitest-mock-extended").CalledWithMock<XPathExpression, [expression: string, resolver?: XPathNSResolver | null | undefined]>;
|
|
376
|
+
createNSResolver: ((nodeResolver: Node) => Node) & import("vitest-mock-extended").CalledWithMock<Node, [nodeResolver: Node]>;
|
|
377
|
+
evaluate: ((expression: string, contextNode: Node, resolver?: XPathNSResolver | null, type?: number, result?: XPathResult | null) => XPathResult) & import("vitest-mock-extended").CalledWithMock<XPathResult, [expression: string, contextNode: Node, resolver?: XPathNSResolver | null | undefined, type?: number | undefined, result?: XPathResult | null | undefined]>;
|
|
378
|
+
} & Document;
|
|
379
|
+
triggerVisibilityChange: () => void;
|
|
380
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// biome-ignore lint/correctness/noUndeclaredDependencies: требуется для тестов
|
|
2
|
+
import { mock } from 'vitest-mock-extended';
|
|
3
|
+
export const createDocumentMock = () => {
|
|
4
|
+
let isVisible = true;
|
|
5
|
+
const listeners = [];
|
|
6
|
+
const documentMock = mock({
|
|
7
|
+
addEventListener: (_, listener) => listeners.push(listener),
|
|
8
|
+
get visibilityState() {
|
|
9
|
+
return isVisible ? 'visible' : 'hidden';
|
|
10
|
+
},
|
|
11
|
+
set visibilityState(_) { },
|
|
12
|
+
});
|
|
13
|
+
const triggerVisibilityChange = () => {
|
|
14
|
+
isVisible = !isVisible;
|
|
15
|
+
listeners.forEach((listener) => listener());
|
|
16
|
+
};
|
|
17
|
+
return { documentMock, triggerVisibilityChange };
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './documentMock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './documentMock';
|
package/__test/index.js
ADDED
|
@@ -3,6 +3,7 @@ import { Mutation, type MutationExecutor, type MutationParams } from '../Mutatio
|
|
|
3
3
|
import { Query, type QueryExecutor, type QueryParams } from '../Query';
|
|
4
4
|
import { InfiniteQuerySet, type InfiniteQuerySetConfig, type InfiniteQuerySetConfigurator, MutationSet, QuerySet, type QuerySetConfig, type QuerySetConfigurator } from '../Sets';
|
|
5
5
|
import type { CacheKey, FetchPolicy } from '../types';
|
|
6
|
+
import type { UnknownCachedQuery } from './types';
|
|
6
7
|
/**
|
|
7
8
|
* Стандартный обработчик ошибки запроса,
|
|
8
9
|
* будет вызван, если при вызове sync не был передан отдельный onError параметр
|
|
@@ -15,6 +16,12 @@ type WithSynchronization = {
|
|
|
15
16
|
*/
|
|
16
17
|
enabledSynchronization?: boolean;
|
|
17
18
|
};
|
|
19
|
+
type WithPollingTime = {
|
|
20
|
+
/**
|
|
21
|
+
* Время в мс, раз в которое необходимо инвалидировать query
|
|
22
|
+
*/
|
|
23
|
+
pollingTime?: number;
|
|
24
|
+
};
|
|
18
25
|
type MobxQueryParams = {
|
|
19
26
|
/**
|
|
20
27
|
* Политика получения данных по умолчанию.
|
|
@@ -43,19 +50,15 @@ export type CreateQueryParams<TResult, TError, TIsBackground extends boolean> =
|
|
|
43
50
|
* @default false
|
|
44
51
|
*/
|
|
45
52
|
isBackground?: TIsBackground;
|
|
46
|
-
} & WithSynchronization;
|
|
53
|
+
} & WithSynchronization & WithPollingTime;
|
|
47
54
|
export type CreateInfiniteQueryParams<TResult, TError, TIsBackground extends boolean> = Omit<InfiniteQueryParams<TResult, TError, TIsBackground>, 'dataStorage' | 'statusStorage' | 'backgroundStatusStorage' | 'submitValidity'> & {
|
|
48
55
|
/**
|
|
49
56
|
* Режим фонового обновления
|
|
50
57
|
* @default false
|
|
51
58
|
*/
|
|
52
59
|
isBackground?: TIsBackground;
|
|
53
|
-
} & WithSynchronization;
|
|
60
|
+
} & WithSynchronization & WithPollingTime;
|
|
54
61
|
export type CreateMutationParams<TResult, TError> = MutationParams<TResult, TError>;
|
|
55
|
-
/**
|
|
56
|
-
* Внутриний тип кешируемого стора
|
|
57
|
-
*/
|
|
58
|
-
type CachedQuery<TResult, TError, TIsBackground extends boolean> = Query<TResult, TError, TIsBackground> | InfiniteQuery<TResult, TError, TIsBackground>;
|
|
59
62
|
/**
|
|
60
63
|
* Стратегия инвалидации кэша
|
|
61
64
|
* @property 'partial-match' - Проверяет наличие хотя бы одной части ключа в кэше
|
|
@@ -97,11 +100,12 @@ export declare class MobxQuery<TDefaultError = void> {
|
|
|
97
100
|
private readonly defaultEnabledAutoFetch;
|
|
98
101
|
private readonly defauleEnabledSynchronization;
|
|
99
102
|
private readonly synchronizationService;
|
|
103
|
+
private readonly pollingService;
|
|
100
104
|
private serialize;
|
|
101
105
|
constructor({ onError, fetchPolicy, enabledAutoFetch, enabledSynchronization, }?: MobxQueryParams, _BroadcastChannel?: {
|
|
102
106
|
new (name: string): BroadcastChannel;
|
|
103
107
|
prototype: BroadcastChannel;
|
|
104
|
-
});
|
|
108
|
+
}, _document?: Document);
|
|
105
109
|
/**
|
|
106
110
|
* Проверяет пересечение ключей в зависимости от стратегии
|
|
107
111
|
* @param invalidatedKeys - Ключи для инвалидации
|
|
@@ -123,6 +127,7 @@ export declare class MobxQuery<TDefaultError = void> {
|
|
|
123
127
|
* mobxQuery.invalidate(['users', '1'], 'chain-match'); // Инвалидирует только query с точным набором ключей ['users', '1']
|
|
124
128
|
*/
|
|
125
129
|
invalidate: (invalidatedKeys: CacheKey[], strategy?: InvalidateStrategy) => void;
|
|
130
|
+
private invalidateByKeyHash;
|
|
126
131
|
/**
|
|
127
132
|
* Метод для получения массива хешей ключей на основании ключей и стратегии
|
|
128
133
|
*/
|
|
@@ -130,7 +135,7 @@ export declare class MobxQuery<TDefaultError = void> {
|
|
|
130
135
|
/**
|
|
131
136
|
* метод для получения массива существующий квери на основании ключей и стратегии
|
|
132
137
|
*/
|
|
133
|
-
getExistsQueries: <TQuery =
|
|
138
|
+
getExistsQueries: <TQuery = UnknownCachedQuery>(keys: CacheKey[], strategy?: InvalidateStrategy) => TQuery[];
|
|
134
139
|
private submitValidity;
|
|
135
140
|
/**
|
|
136
141
|
* Метод инвалидации всех query
|
|
@@ -5,6 +5,7 @@ const AdaptableMap_1 = require("../AdaptableMap");
|
|
|
5
5
|
const DataStorage_1 = require("../DataStorage");
|
|
6
6
|
const InfiniteQuery_1 = require("../InfiniteQuery");
|
|
7
7
|
const Mutation_1 = require("../Mutation");
|
|
8
|
+
const PollingService_1 = require("../PollingService");
|
|
8
9
|
const Query_1 = require("../Query");
|
|
9
10
|
const Sets_1 = require("../Sets");
|
|
10
11
|
const StatusStorage_1 = require("../StatusStorage");
|
|
@@ -13,7 +14,7 @@ const SynchronizationService_1 = require("../SynchronizationService");
|
|
|
13
14
|
* Сервис, позволяющий кэшировать данные.
|
|
14
15
|
*/
|
|
15
16
|
class MobxQuery {
|
|
16
|
-
constructor({ onError, fetchPolicy = 'cache-first', enabledAutoFetch = false, enabledSynchronization = false, } = {}, _BroadcastChannel = globalThis.BroadcastChannel) {
|
|
17
|
+
constructor({ onError, fetchPolicy = 'cache-first', enabledAutoFetch = false, enabledSynchronization = false, } = {}, _BroadcastChannel = globalThis.BroadcastChannel, _document = globalThis.document) {
|
|
17
18
|
/**
|
|
18
19
|
* Объект соответствия хешей ключей и их значений
|
|
19
20
|
*/
|
|
@@ -58,13 +59,15 @@ class MobxQuery {
|
|
|
58
59
|
* mobxQuery.invalidate(['users', '1'], 'chain-match'); // Инвалидирует только query с точным набором ключей ['users', '1']
|
|
59
60
|
*/
|
|
60
61
|
this.invalidate = (invalidatedKeys, strategy = 'partial-match') => {
|
|
61
|
-
this.getExistsKeyHashes(invalidatedKeys, strategy).forEach(({ keyHash }) =>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
this.getExistsKeyHashes(invalidatedKeys, strategy).forEach(({ keyHash }) => this.invalidateByKeyHash(keyHash));
|
|
63
|
+
};
|
|
64
|
+
this.invalidateByKeyHash = (keyHash) => {
|
|
65
|
+
var _a;
|
|
66
|
+
(_a = this.queriesMap.get(keyHash)) === null || _a === void 0 ? void 0 : _a.invalidate();
|
|
67
|
+
// Конвертируем инвалидированный квери в слабый,
|
|
68
|
+
// чтобы сборщик мусора мог удалить неиспользуемые квери
|
|
69
|
+
this.queriesMap.convertToWeak(keyHash);
|
|
70
|
+
this.pollingService.clean(keyHash);
|
|
68
71
|
};
|
|
69
72
|
/**
|
|
70
73
|
* Метод для получения массива хешей ключей на основании ключей и стратегии
|
|
@@ -81,10 +84,13 @@ class MobxQuery {
|
|
|
81
84
|
*/
|
|
82
85
|
this.getExistsQueries = (keys, strategy = 'partial-match') => this.getExistsKeyHashes(keys, strategy).map(({ keyHash }) => this.queriesMap.get(keyHash));
|
|
83
86
|
// Метод для подтверждения того, что квери успешно получил валидные данные
|
|
84
|
-
this.submitValidity = (keys, isNetworkOnly, enabledSynchronization) => {
|
|
87
|
+
this.submitValidity = (keys, isNetworkOnly, enabledSynchronization, pollingTime) => {
|
|
85
88
|
if (enabledSynchronization) {
|
|
86
89
|
this.synchronizationService.emit(keys);
|
|
87
90
|
}
|
|
91
|
+
if (pollingTime) {
|
|
92
|
+
this.pollingService.setupTimer(keys.queryKeyHash, pollingTime);
|
|
93
|
+
}
|
|
88
94
|
// 'network-only' квери не будут конвертироваться,
|
|
89
95
|
// следовательно, они всегда будут храниться как "слабые",
|
|
90
96
|
// что позволит сборщику мусора удалять их из памяти при отсутствии ссылок
|
|
@@ -98,13 +104,7 @@ class MobxQuery {
|
|
|
98
104
|
/**
|
|
99
105
|
* Метод инвалидации всех query
|
|
100
106
|
*/
|
|
101
|
-
this.invalidateQueries = () =>
|
|
102
|
-
[...this.keys.keys()].forEach((keyHash) => {
|
|
103
|
-
var _a;
|
|
104
|
-
(_a = this.queriesMap.get(keyHash)) === null || _a === void 0 ? void 0 : _a.invalidate();
|
|
105
|
-
this.queriesMap.convertToWeak(keyHash);
|
|
106
|
-
});
|
|
107
|
-
};
|
|
107
|
+
this.invalidateQueries = () => [...this.keys.keys()].forEach(this.invalidateByKeyHash);
|
|
108
108
|
/**
|
|
109
109
|
* Метод, который занимается проверкой наличия квери по ключу,
|
|
110
110
|
* и если нет, создает новый, добавляет его к себе в память, и возвращает его пользователю
|
|
@@ -127,7 +127,7 @@ class MobxQuery {
|
|
|
127
127
|
backgroundStatusStorage: this.getBackgroundStatusStorage(keys.backgroundStatusKeyHash, Boolean(createParams === null || createParams === void 0 ? void 0 : createParams.isBackground)),
|
|
128
128
|
submitValidity: () => {
|
|
129
129
|
var _a;
|
|
130
|
-
return this.submitValidity(keys, fetchPolicy !== 'network-only', (_a = createParams === null || createParams === void 0 ? void 0 : createParams.enabledSynchronization) !== null && _a !== void 0 ? _a : this.defauleEnabledSynchronization);
|
|
130
|
+
return this.submitValidity(keys, fetchPolicy !== 'network-only', (_a = createParams === null || createParams === void 0 ? void 0 : createParams.enabledSynchronization) !== null && _a !== void 0 ? _a : this.defauleEnabledSynchronization, createParams === null || createParams === void 0 ? void 0 : createParams.pollingTime);
|
|
131
131
|
},
|
|
132
132
|
});
|
|
133
133
|
this.queriesMap.set(keys.queryKeyHash, query);
|
|
@@ -231,7 +231,8 @@ class MobxQuery {
|
|
|
231
231
|
this.defaultFetchPolicy = fetchPolicy;
|
|
232
232
|
this.defaultEnabledAutoFetch = enabledAutoFetch;
|
|
233
233
|
this.defauleEnabledSynchronization = enabledSynchronization;
|
|
234
|
-
this.
|
|
234
|
+
this.pollingService = new PollingService_1.PollingService(this.queriesMap, this.invalidateByKeyHash, _document);
|
|
235
|
+
this.synchronizationService = new SynchronizationService_1.SynchronizationService(this.statusStorageFactory, this.queryDataStorageFactory, this.pollingService, _BroadcastChannel);
|
|
235
236
|
}
|
|
236
237
|
}
|
|
237
238
|
exports.MobxQuery = MobxQuery;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type InfiniteQuery } from '../InfiniteQuery';
|
|
2
|
+
import { type Query } from '../Query';
|
|
3
|
+
import { type CacheKey } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Внутриний тип кешируемого стора
|
|
6
|
+
*/
|
|
7
|
+
export type CachedQuery<TResult, TError, TIsBackground extends boolean> = Query<TResult, TError, TIsBackground> | InfiniteQuery<TResult, TError, TIsBackground>;
|
|
8
|
+
export type UnknownCachedQuery = CachedQuery<unknown, unknown, false>;
|
|
9
|
+
/**
|
|
10
|
+
* Хэш ключа
|
|
11
|
+
*/
|
|
12
|
+
export type KeyHash = string;
|
|
13
|
+
/**
|
|
14
|
+
* Набор ключей
|
|
15
|
+
*/
|
|
16
|
+
export type Keys = {
|
|
17
|
+
queryKey: CacheKey[];
|
|
18
|
+
dataKeyHash: KeyHash;
|
|
19
|
+
statusKeyHash: KeyHash;
|
|
20
|
+
queryKeyHash: KeyHash;
|
|
21
|
+
backgroundStatusKeyHash: KeyHash;
|
|
22
|
+
};
|