diff --git a/src/lib/element.js b/src/lib/element.js index e3b6053..2d790ed 100644 --- a/src/lib/element.js +++ b/src/lib/element.js @@ -28,7 +28,7 @@ export const waitForVisibility = (element) => { } }); - window.requestAnimationFrame(() => { + globalThis.requestAnimationFrame(() => { observer.observe(element); }); }); diff --git a/src/lib/misc.js b/src/lib/misc.js index 8707338..176d737 100644 --- a/src/lib/misc.js +++ b/src/lib/misc.js @@ -6,7 +6,7 @@ */ export const sleep = (ms = 1000) => new Promise((resolve) => { - window.setTimeout(() => { + globalThis.setTimeout(() => { resolve(void 0); }, ms); }); diff --git a/src/lib/storage/indexed-db.js b/src/lib/storage/indexed-db.js index c7bddf3..c34749f 100644 --- a/src/lib/storage/indexed-db.js +++ b/src/lib/storage/indexed-db.js @@ -41,7 +41,7 @@ export default class IndexedDB { */ async #openDatabase(version) { return new Promise((resolve) => { - const request = window.indexedDB.open(this.#databaseName, version); + const request = globalThis.indexedDB.open(this.#databaseName, version); request.onupgradeneeded = () => { request.result.createObjectStore(this.#storeName); diff --git a/src/lib/storage/local-storage.js b/src/lib/storage/local-storage.js index 1347f0c..f2e7950 100644 --- a/src/lib/storage/local-storage.js +++ b/src/lib/storage/local-storage.js @@ -12,7 +12,7 @@ export default class LocalStorage { * @throws {DOMException} When storage access is denied. */ static async set(key, value) { - window.localStorage.setItem(key, JSON.stringify(value)); + globalThis.localStorage.setItem(key, JSON.stringify(value)); } /** @@ -22,7 +22,7 @@ export default class LocalStorage { * @throws {DOMException} When storage access is denied. */ static async get(key) { - const cache = window.localStorage.getItem(key); + const cache = globalThis.localStorage.getItem(key); return cache ? JSON.parse(cache) : null; } @@ -33,7 +33,7 @@ export default class LocalStorage { * @throws {DOMException} When storage access is denied. */ static async delete(key) { - window.localStorage.removeItem(key); + globalThis.localStorage.removeItem(key); } /** @@ -41,7 +41,7 @@ export default class LocalStorage { * @throws {DOMException} When storage access is denied. */ static async clear() { - window.localStorage.clear(); + globalThis.localStorage.clear(); } /** @@ -50,7 +50,7 @@ export default class LocalStorage { * @throws {DOMException} When storage access is denied. */ static async keys() { - return Object.keys(window.localStorage); + return Object.keys(globalThis.localStorage); } /** @@ -59,7 +59,7 @@ export default class LocalStorage { * @throws {DOMException} When storage access is denied. */ static async values() { - return Object.values(window.localStorage).map((value) => JSON.parse(value)); + return Object.values(globalThis.localStorage).map((value) => JSON.parse(value)); } /** @@ -68,6 +68,6 @@ export default class LocalStorage { * @throws {DOMException} When storage access is denied. */ static async entries() { - return Object.entries(window.localStorage).map(([key, value]) => [key, JSON.parse(value)]); + return Object.entries(globalThis.localStorage).map(([key, value]) => [key, JSON.parse(value)]); } }