@exezt-/webamp 1.5.0-0x1 → 1.5.0-0x3

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.
@@ -10084,21 +10084,11 @@ function selectAll() {
10084
10084
 
10085
10085
  class webamp_telegram_WinampTelegramCustomHandler {
10086
10086
  constructor() {
10087
- defineProperty_default()(this, "window_handlers", ['unload', 'beforeunload', 'pagehide']);
10088
-
10089
- defineProperty_default()(this, "registerDOMListeners", () => {
10090
- this.window_handlers.forEach(handler => {
10091
- window.addEventListener(handler, () => {
10092
- this.updateAppState();
10093
- });
10094
- });
10095
- });
10096
-
10097
10087
  defineProperty_default()(this, "updateAppState", () => {
10098
10088
  localStorage.setItem('app-state', JSON.stringify(window.__webamp.store.getState()));
10099
10089
  });
10100
10090
 
10101
- defineProperty_default()(this, "getFiles", ln => {
10091
+ defineProperty_default()(this, "getFiles", async ln => {
10102
10092
  const x = new XMLHttpRequest();
10103
10093
  const link = encodeURIComponent(ln);
10104
10094
  x.open('get', `https://cloud-api.yandex.net/v1/disk/public/resources?public_key=${link}`, true);
@@ -10106,7 +10096,7 @@ class webamp_telegram_WinampTelegramCustomHandler {
10106
10096
  x.setRequestHeader('Content-Type', 'application/json');
10107
10097
  x.send();
10108
10098
 
10109
- x.onload = () => {
10099
+ x.onload = async () => {
10110
10100
  if (x.status === 200) {
10111
10101
  var _JSON$parse;
10112
10102
 
@@ -10118,7 +10108,7 @@ class webamp_telegram_WinampTelegramCustomHandler {
10118
10108
  for (const item of data) {
10119
10109
  if (item.size > 0x1400000) {// size too large
10120
10110
  } else {
10121
- fetch(item.file).then(resp => fetch(resp.url)).then(res => {
10111
+ await fetch(item.file).then(resp => fetch(resp.url)).then(res => {
10122
10112
  var _res$body;
10123
10113
 
10124
10114
  console.log(res);
@@ -10147,9 +10137,6 @@ class webamp_telegram_WinampTelegramCustomHandler {
10147
10137
 
10148
10138
  });
10149
10139
  }).then(stream => new Response(stream)).then(response => response.blob()).then(blob => URL.createObjectURL(blob)).then(uri => {
10150
- this.openDb(playlistName, item.name, uri);
10151
- console.log(i);
10152
-
10153
10140
  if (i === 0) {
10154
10141
  window.__webamp.setTracksToPlay([{
10155
10142
  defaultName: item.name,
@@ -10170,19 +10157,6 @@ class webamp_telegram_WinampTelegramCustomHandler {
10170
10157
  };
10171
10158
  });
10172
10159
 
10173
- defineProperty_default()(this, "appendTracks", (openRequest, playlistName, item_name, val) => {
10174
- let data = openRequest.result;
10175
- console.log(data);
10176
-
10177
- try {
10178
- data.createObjectStore(`_${playlistName}`);
10179
- } catch (e) {}
10180
-
10181
- let query = data.transaction([`default`], 'readwrite').objectStore(`_${playlistName}`);
10182
- query.add(val, item_name);
10183
- data.close();
10184
- });
10185
-
10186
10160
  defineProperty_default()(this, "getCookie", name => {
10187
10161
  const regex = new RegExp(`(^| )${name}=([^;]+)`);
10188
10162
  const match = document.cookie.match(regex);
@@ -10247,12 +10221,11 @@ class webamp_telegram_WinampTelegramCustomHandler {
10247
10221
  let lastList = this.getCookie('lastlist');
10248
10222
 
10249
10223
  if (typeof lastList !== "undefined") {
10250
- this.getFiles(lastList);
10224
+ this.getFiles(lastList).catch(err => 0x0);
10251
10225
  }
10252
10226
 
10253
10227
  setTimeout(() => {
10254
10228
  if (typeof localStorage.getItem('app-state') !== "undefined") this.loadOptions(JSON.parse(localStorage.getItem('app-state')));
10255
- this.registerDOMListeners();
10256
10229
 
10257
10230
  window.__webamp.onTrackDidChange(() => {
10258
10231
  this.updateAppState();
@@ -10269,27 +10242,6 @@ class webamp_telegram_WinampTelegramCustomHandler {
10269
10242
  }, 2000);
10270
10243
  }
10271
10244
 
10272
- openDb(playlistName, item_name, val) {
10273
- const openRequest = indexedDB.open(playlistName);
10274
-
10275
- openRequest.onerror = e => {
10276
- console.error(e);
10277
- };
10278
-
10279
- openRequest.onsuccess = () => {
10280
- let db = openRequest.result;
10281
- if (!db.objectStoreNames.contains(`_${playlistName}`)) db.createObjectStore(`_${playlistName}`);
10282
- if (!db.objectStoreNames.contains('last-playlist')) db.createObjectStore('last-playlist');
10283
- this.appendTracks(openRequest, playlistName, item_name, val);
10284
- };
10285
-
10286
- openRequest.onupgradeneeded = ev => {
10287
- let db = openRequest.result;
10288
- if (!db.objectStoreNames.contains(`_${playlistName}`)) db.createObjectStore(`_${playlistName}`);
10289
- if (!db.objectStoreNames.contains('last-playlist')) db.createObjectStore('last-playlist');
10290
- };
10291
- }
10292
-
10293
10245
  saveLastPlaylist(playlistName) {
10294
10246
  document.cookie = `lastlist=${playlistName}; path=/;`;
10295
10247
  }