Kaynağa Gözat

ref: remove tslib & small refactors

Sv443 8 ay önce
ebeveyn
işleme
eb22bde5ec
5 değiştirilmiş dosya ile 7 ekleme ve 8 silme
  1. 0 1
      package.json
  2. 0 3
      pnpm-lock.yaml
  3. 1 1
      src/constants.ts
  4. 2 2
      src/features/songLists.ts
  5. 4 1
      src/utils/misc.ts

+ 0 - 1
package.json

@@ -106,7 +106,6 @@
     "storybook": "^8.1.10",
     "storybook-dark-mode": "^4.0.2",
     "ts-node": "^10.9.2",
-    "tslib": "^2.6.3",
     "typescript": "^5.5.2"
   },
   "browserslist": [

+ 0 - 3
pnpm-lock.yaml

@@ -129,9 +129,6 @@ importers:
       ts-node:
         specifier: ^10.9.2
         version: 10.9.2(@types/[email protected])([email protected])
-      tslib:
-        specifier: ^2.6.3
-        version: 2.6.3
       typescript:
         specifier: ^5.5.2
         version: 5.5.2

+ 1 - 1
src/constants.ts

@@ -32,7 +32,7 @@ export const platformNames: Record<typeof host, string> = {
 export const compressionFormat: CompressionFormat = "deflate-raw";
 
 /** Whether sessionStorage is available and working */
-export const sessionStorageAllowed =
+export const sessionStorageAvailable =
   typeof sessionStorage?.setItem === "function"
   && (() => {
     try {

+ 2 - 2
src/features/songLists.ts

@@ -1,5 +1,5 @@
 import { autoPlural, pauseFor } from "@sv443-network/userutils";
-import { clearInner, error, getResourceUrl, log, onInteraction, openInTab, t, warn } from "../utils/index.js";
+import { clearInner, error, getResourceUrl, info, log, onInteraction, openInTab, t } from "../utils/index.js";
 import { SiteEventsMap, siteEvents } from "../siteEvents.js";
 import { emitInterface } from "../interface.js";
 import { fetchLyricsUrlTop, createLyricsBtn, sanitizeArtists, sanitizeSong, splitVideoTitle } from "./lyrics.js";
@@ -254,7 +254,7 @@ async function addQueueButtons(
           dotsBtnElem.click();
         }
         else {
-          warn("Couldn't find three dots button in queue item, trying to open the context menu manually");
+          info("Couldn't find three dots button in queue item, trying to open the context menu manually");
           queueItem.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: false }));
         }
 

+ 4 - 1
src/utils/misc.ts

@@ -1,6 +1,6 @@
 import { compress, decompress, fetchAdvanced, openInNewTab, pauseFor, randomId } from "@sv443-network/userutils";
 import { marked } from "marked";
-import { branch, compressionFormat, repo } from "../constants.js";
+import { branch, compressionFormat, repo, sessionStorageAvailable } from "../constants.js";
 import { type Domain, type ResourceKey } from "../types.js";
 import { error, type TrLocale, warn, sendRequest } from "./index.js";
 import langMapping from "../../assets/locales.json" with { type: "json" };
@@ -27,6 +27,9 @@ export function getDomain(): Domain {
 /** Returns a pseudo-random ID unique to each session - returns null if sessionStorage is unavailable */
 export function getSessionId(): string | null {
   try {
+    if(!sessionStorageAvailable)
+      throw new Error("Session storage unavailable");
+
     let sesId = window.sessionStorage.getItem("_bytm-session-id");
 
     if(!sesId)