refactor(general): Clean up and add a logger (#587)

* feat(utils): Add logger

* chore: Clean up some classes and add more logging

* chore: Fix conflicts
This commit is contained in:
Luan
2024-01-25 19:01:28 -03:00
committed by GitHub
parent 7fbc37f9d1
commit e86a0daf45
65 changed files with 432 additions and 350 deletions

View File

@@ -4,8 +4,10 @@ import { Platform } from '../utils/Utils.js';
import sha1Hash from './polyfills/web-crypto.js';
import package_json from '../../package.json' assert { type: 'json' };
import evaluate from './jsruntime/jinter.js';
import Log from '../utils/Log.js';
class Cache implements ICache {
#TAG = 'Cache';
#persistent_directory: string;
#persistent: boolean;
@@ -21,7 +23,7 @@ class Cache implements ICache {
#getBrowserDB() {
const indexedDB: IDBFactory = Reflect.get(globalThis, 'indexedDB') || Reflect.get(globalThis, 'webkitIndexedDB') || Reflect.get(globalThis, 'mozIndexedDB') || Reflect.get(globalThis, 'msIndexedDB');
if (!indexedDB) return console.log('IndexedDB is not supported. No cache will be used.');
if (!indexedDB) return Log.warn(this.#TAG, 'IndexedDB is not supported. No cache will be used.');
return new Promise<IDBDatabase>((resolve, reject) => {
const request = indexedDB.open('youtubei.js', 1);