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

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.
@@ -14793,8 +14793,18 @@ function selectAll() {
14793
14793
 
14794
14794
  class webamp_telegram_WinampTelegramCustomHandler {
14795
14795
  constructor() {
14796
+ defineProperty_default()(this, "webamp", void 0);
14797
+
14798
+ defineProperty_default()(this, "telegram", void 0);
14799
+
14800
+ defineProperty_default()(this, "initializeTelegramWebAppEvents", () => {
14801
+ this.telegram.offEvent("deactivated", () => {
14802
+ this.updateAppState();
14803
+ });
14804
+ });
14805
+
14796
14806
  defineProperty_default()(this, "updateAppState", () => {
14797
- localStorage.setItem('app-state', JSON.stringify(window.__webamp.store.getState()));
14807
+ localStorage.setItem("app-state", JSON.stringify(window.__webamp.store.getState()));
14798
14808
  });
14799
14809
 
14800
14810
  defineProperty_default()(this, "getFiles", async ln => {
@@ -14809,15 +14819,25 @@ class webamp_telegram_WinampTelegramCustomHandler {
14809
14819
  if (x.status === 200) {
14810
14820
  var _JSON$parse;
14811
14821
 
14812
- const playlistName = JSON.parse(x.responseText).name;
14813
14822
  const data = (_JSON$parse = JSON.parse(x.responseText)) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse._embedded.items;
14814
14823
  let i = 0;
14815
14824
  this.saveLastPlaylist(ln);
14816
14825
 
14817
14826
  for (const item of data) {
14818
- if (item.size > 0x1400000) {// size too large
14827
+ if (item.size > 0x1400000) {
14828
+ console.info(`File ${item.name} can't be loaded due oversize`);
14819
14829
  } else {
14820
- await fetch(item.file).then(resp => fetch(resp.url)).then(res => {
14830
+ await fetch(item.file, {
14831
+ headers: [['Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'], ['Content-Type', 'application/octet-stream']]
14832
+ }).then(response => response).then(resp => fetch(resp.url)).then(async response => {
14833
+ if (response.status === 302) {
14834
+ return await fetch(response.headers.get('Location'), {
14835
+ headers: [['Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'], ['Content-Type', 'application/octet-stream']]
14836
+ });
14837
+ } else {
14838
+ return response;
14839
+ }
14840
+ }).then(res => {
14821
14841
  var _res$body;
14822
14842
 
14823
14843
  console.log(res);
@@ -14866,6 +14886,10 @@ class webamp_telegram_WinampTelegramCustomHandler {
14866
14886
  };
14867
14887
  });
14868
14888
 
14889
+ defineProperty_default()(this, "saveLastPlaylist", playlistLink => {
14890
+ document.cookie = `lastlist=${playlistLink}; path=/;`;
14891
+ });
14892
+
14869
14893
  defineProperty_default()(this, "getCookie", name => {
14870
14894
  const regex = new RegExp(`(^| )${name}=([^;]+)`);
14871
14895
  const match = document.cookie.match(regex);
@@ -14919,44 +14943,58 @@ class webamp_telegram_WinampTelegramCustomHandler {
14919
14943
  i++;
14920
14944
  }
14921
14945
 
14922
- if (window.__webamp.store.getState().media.shuffle !== opts.media.shuffle) window.__webamp.store.dispatch({
14923
- type: "TOGGLE_SHUFFLE"
14924
- });
14925
- if (window.__webamp.store.getState().media.repeat !== opts.media.repeat) window.__webamp.store.dispatch({
14926
- type: "TOGGLE_REPEAT"
14927
- });
14946
+ if (window.__webamp.store.getState().media.shuffle !== opts.media.shuffle) {
14947
+ window.__webamp.store.dispatch({
14948
+ type: "TOGGLE_SHUFFLE"
14949
+ });
14950
+ }
14951
+
14952
+ if (window.__webamp.store.getState().media.repeat !== opts.media.repeat) {
14953
+ window.__webamp.store.dispatch({
14954
+ type: "TOGGLE_REPEAT"
14955
+ });
14956
+ }
14928
14957
  });
14929
14958
 
14930
- let lastList = this.getCookie('lastlist');
14959
+ const lastList = this.getCookie('lastlist');
14931
14960
 
14932
14961
  if (typeof lastList !== "undefined") {
14933
- this.getFiles(lastList).catch(err => 0x0);
14962
+ this.getFiles(lastList);
14934
14963
  }
14964
+ }
14935
14965
 
14936
- setTimeout(() => {
14937
- if (typeof localStorage.getItem('app-state') !== "undefined") this.loadOptions(JSON.parse(localStorage.getItem('app-state')));
14966
+ initialize() {
14967
+ var _window, _window$Telegram, _window2, _window2$Telegram;
14938
14968
 
14939
- window.__webamp.onTrackDidChange(() => {
14940
- this.updateAppState();
14941
- });
14969
+ // @ts-ignore | because no global var telegram avail in project types
14970
+ this.telegram = (_window = window) === null || _window === void 0 ? void 0 : (_window$Telegram = _window.Telegram) === null || _window$Telegram === void 0 ? void 0 : _window$Telegram.WebApp;
14942
14971
 
14943
- window.__webamp.onWillClose(() => {
14944
- this.updateAppState();
14945
- });
14972
+ if (!window.__webamp) {
14973
+ throw new Error("Webamp __webamp is undefined!!");
14974
+ } // @ts-ignore | because no global var telegram avail in project types
14946
14975
 
14947
- window.__webamp.store.dispatch({
14948
- type: "ENABLE_MILKDROP",
14949
- open: false
14950
- });
14951
- }, 2000);
14952
- }
14953
14976
 
14954
- saveLastPlaylist(playlistName) {
14955
- document.cookie = `lastlist=${playlistName}; path=/;`;
14977
+ if (!((_window2 = window) !== null && _window2 !== void 0 && (_window2$Telegram = _window2.Telegram) !== null && _window2$Telegram !== void 0 && _window2$Telegram.WebApp)) {
14978
+ console.error("Telegram is undefined!! Skipping Telegram.WebApp event handler...");
14979
+ }
14980
+
14981
+ if (typeof localStorage.getItem('app-state') !== "undefined") this.loadOptions(JSON.parse(localStorage.getItem('app-state')));
14982
+
14983
+ window.__webamp.onTrackDidChange(() => {
14984
+ this.updateAppState();
14985
+ });
14986
+
14987
+ window.__webamp.onWillClose(() => {
14988
+ this.updateAppState();
14989
+ });
14990
+
14991
+ window.__webamp.store.dispatch({
14992
+ type: "ENABLE_MILKDROP",
14993
+ open: false
14994
+ });
14956
14995
  }
14957
14996
 
14958
14997
  }
14959
- new webamp_telegram_WinampTelegramCustomHandler();
14960
14998
  // CONCATENATED MODULE: ./js/actionCreators/files.ts
14961
14999
 
14962
15000