Download node_modules/@tanstack/query-core/build/modern/focusManager.cjs from metarm/QMetaRam: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/metarm/QMetaRam/resolve/main/node_modules/%40tanstack/query-core/build/modern/focusManager.cjs
- Command line
-
hf download hf://metarm/QMetaRam/node_modules/@tanstack/query-core/build/modern/focusManager.cjs
-
curl -L -o focusManager.cjs https://huggingface.co/metarm/QMetaRam/resolve/main/node_modules/%40tanstack/query-core/build/modern/focusManager.cjs
1.54 kB
| Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | |
| const require_subscribable = require("./subscribable.cjs"); | |
| //#region src/focusManager.ts | |
| var FocusManager = class extends require_subscribable.Subscribable { | |
| #focused; | |
| #cleanup; | |
| #setup; | |
| constructor() { | |
| super(); | |
| this.#setup = (onFocus) => { | |
| if (typeof window !== "undefined" && window.addEventListener) { | |
| const listener = () => onFocus(); | |
| window.addEventListener("visibilitychange", listener, false); | |
| return () => { | |
| window.removeEventListener("visibilitychange", listener); | |
| }; | |
| } | |
| }; | |
| } | |
| 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((focused) => { | |
| if (typeof focused === "boolean") this.setFocused(focused); | |
| else this.onFocus(); | |
| }); | |
| } | |
| setFocused(focused) { | |
| if (this.#focused !== focused) { | |
| 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"; | |
| } | |
| }; | |
| const focusManager = new FocusManager(); | |
| //#endregion | |
| exports.FocusManager = FocusManager; | |
| exports.focusManager = focusManager; | |
| //# sourceMappingURL=focusManager.cjs.map |