@exezt-/webamp 1.5.0-0x603 → 1.5.0-0x604

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.
@@ -14792,21 +14792,13 @@ function selectAll() {
14792
14792
  // @ts-ignore
14793
14793
 
14794
14794
  class webamp_telegram_handler_WinampTelegramCustomHandler {
14795
- constructor() {
14796
- var _window, _window$Telegram, _window2, _window2$Telegram;
14797
-
14795
+ constructor(emit) {
14798
14796
  defineProperty_default()(this, "webamp", void 0);
14799
14797
 
14800
14798
  defineProperty_default()(this, "telegram", void 0);
14801
14799
 
14802
- defineProperty_default()(this, "initializeTelegramWebAppEvents", () => {
14803
- this.telegram.offEvent("deactivated", () => {
14804
- this.updateAppState();
14805
- });
14806
- });
14807
-
14808
14800
  defineProperty_default()(this, "updateAppState", () => {
14809
- localStorage.setItem("app-state", JSON.stringify(window.__webamp.store.getState()));
14801
+ localStorage.setItem("app-state", JSON.stringify(this.webamp.store.getState()));
14810
14802
  });
14811
14803
 
14812
14804
  defineProperty_default()(this, "getFiles", async ln => {
@@ -14867,12 +14859,12 @@ class webamp_telegram_handler_WinampTelegramCustomHandler {
14867
14859
  });
14868
14860
  }).then(stream => new Response(stream)).then(response => response.blob()).then(blob => URL.createObjectURL(blob)).then(uri => {
14869
14861
  if (i === 0) {
14870
- window.__webamp.setTracksToPlay([{
14862
+ this.webamp.setTracksToPlay([{
14871
14863
  defaultName: item.name,
14872
14864
  url: uri
14873
14865
  }]);
14874
14866
  } else {
14875
- window.__webamp.appendTracks([{
14867
+ this.webamp.appendTracks([{
14876
14868
  defaultName: item.name,
14877
14869
  url: uri
14878
14870
  }]);
@@ -14916,82 +14908,117 @@ class webamp_telegram_handler_WinampTelegramCustomHandler {
14916
14908
  let eq11 = opts.equalizer.sliders["16000"];
14917
14909
  let equal = [eq1, eq2, eq3, eq4, eq5, eq6, eq7, eq8, eq9, eq10, eq11];
14918
14910
  let bands = [60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000];
14919
-
14920
- window.__webamp.store.dispatch({
14911
+ this.webamp.store.dispatch({
14921
14912
  type: "SET_VOLUME",
14922
14913
  volume: clamp(vol, 0, 100)
14923
14914
  });
14924
-
14925
- window.__webamp.store.dispatch({
14915
+ this.webamp.store.dispatch({
14926
14916
  type: "SET_BALANCE",
14927
14917
  balance: balance
14928
14918
  });
14929
-
14930
- window.__webamp.store.dispatch({
14919
+ this.webamp.store.dispatch({
14931
14920
  type: "SET_BAND_VALUE",
14932
14921
  band: "preamp",
14933
14922
  value: opts.equalizer.sliders.preamp
14934
14923
  });
14935
14924
 
14936
14925
  for (const band of bands) {
14937
- window.__webamp.store.dispatch({
14926
+ this.webamp.store.dispatch({
14938
14927
  type: "SET_BAND_VALUE",
14939
14928
  band: band,
14940
14929
  value: equal[i]
14941
14930
  });
14942
-
14943
14931
  i++;
14944
14932
  }
14945
14933
 
14946
14934
  if (window.__webamp.store.getState().media.shuffle !== opts.media.shuffle) {
14947
- window.__webamp.store.dispatch({
14935
+ this.webamp.store.dispatch({
14948
14936
  type: "TOGGLE_SHUFFLE"
14949
14937
  });
14950
14938
  }
14951
14939
 
14952
14940
  if (window.__webamp.store.getState().media.repeat !== opts.media.repeat) {
14953
- window.__webamp.store.dispatch({
14941
+ this.webamp.store.dispatch({
14954
14942
  type: "TOGGLE_REPEAT"
14955
14943
  });
14956
14944
  }
14957
14945
  });
14958
14946
 
14959
- const lastList = this.getCookie('lastlist'); // @ts-ignore | because no global var telegram avail in project types
14947
+ if (emit !== false) {
14948
+ var _window, _window$Telegram, _window2, _window2$Telegram;
14960
14949
 
14961
- this.telegram = (_window = window) === null || _window === void 0 ? void 0 : (_window$Telegram = _window.Telegram) === null || _window$Telegram === void 0 ? void 0 : _window$Telegram.WebApp;
14950
+ const lastList = this.getCookie('lastlist'); // @ts-ignore | because no global var telegram avail in project types
14962
14951
 
14963
- if (typeof lastList !== "undefined") {
14964
- this.getFiles(lastList);
14965
- }
14952
+ this.telegram = (_window = window) === null || _window === void 0 ? void 0 : (_window$Telegram = _window.Telegram) === null || _window$Telegram === void 0 ? void 0 : _window$Telegram.WebApp;
14966
14953
 
14967
- if (!window.__webamp) {
14968
- throw new Error("Webamp __webamp is undefined!!");
14969
- } // @ts-ignore | because no global var telegram avail in project types
14954
+ if (typeof lastList !== "undefined") {
14955
+ this.getFiles(lastList);
14956
+ }
14970
14957
 
14958
+ if (!window.__webamp) {
14959
+ throw new Error("Webamp __webamp is undefined!!");
14960
+ } else {
14961
+ this.webamp = window.__webamp;
14962
+ } // @ts-ignore | because no global var telegram avail in project types
14971
14963
 
14972
- if (!((_window2 = window) !== null && _window2 !== void 0 && (_window2$Telegram = _window2.Telegram) !== null && _window2$Telegram !== void 0 && _window2$Telegram.WebApp)) {
14973
- console.error("Telegram is undefined!! Skipping Telegram.WebApp event handler...");
14974
- }
14975
14964
 
14976
- if (typeof localStorage.getItem('app-state') !== "undefined") {
14977
- this.loadOptions(JSON.parse(localStorage.getItem('app-state')));
14965
+ if (!((_window2 = window) !== null && _window2 !== void 0 && (_window2$Telegram = _window2.Telegram) !== null && _window2$Telegram !== void 0 && _window2$Telegram.WebApp)) {
14966
+ console.error("Telegram is undefined!! Skipping Telegram.WebApp event handler...");
14967
+ }
14968
+
14969
+ if (typeof localStorage.getItem('app-state') !== "undefined") {
14970
+ this.loadOptions(JSON.parse(localStorage.getItem('app-state')));
14971
+ }
14972
+
14973
+ this.initializeApplicationHandlers();
14978
14974
  }
14975
+ }
14979
14976
 
14980
- window.__webamp.onTrackDidChange(() => {
14977
+ initializeTelegramWebAppEvents() {
14978
+ this.telegram.offEvent("deactivated", () => {
14981
14979
  this.updateAppState();
14982
14980
  });
14981
+ }
14983
14982
 
14984
- window.__webamp.onWillClose(() => {
14983
+ initializeApplicationHandlers() {
14984
+ const window_handlers = ['unload', 'beforeunload', 'pagehide'];
14985
+ window_handlers.forEach(handler => {
14986
+ window.addEventListener(handler, () => {
14987
+ this.updateAppState();
14988
+ });
14989
+ });
14990
+ this.webamp.onTrackDidChange(() => {
14985
14991
  this.updateAppState();
14986
14992
  });
14987
-
14988
- window.__webamp.store.dispatch({
14993
+ this.webamp.onWillClose(() => {
14994
+ this.updateAppState();
14995
+ });
14996
+ this.webamp.onClose(() => {
14997
+ this.updateAppState();
14998
+ });
14999
+ this.webamp.onMinimize(() => {
15000
+ this.updateAppState();
15001
+ });
15002
+ this.webamp.store.dispatch({
14989
15003
  type: "ENABLE_MILKDROP",
14990
15004
  open: false
14991
15005
  });
15006
+ const ev = ['ended', 'playing', 'timeupdate', 'fileLoaded', 'waiting', 'stopWaiting'];
15007
+
15008
+ this.webamp.__onStateChange(() => {
15009
+ this.updateAppState();
15010
+ }); // this.webamp._actionEmitter.on('')
15011
+
15012
+
15013
+ ev.forEach(ev => this.webamp.media.on(ev, () => {
15014
+ this.updateAppState();
15015
+ }));
14992
15016
  }
14993
15017
 
14994
15018
  }
15019
+ setTimeout(() => {
15020
+ new webamp_telegram_handler_WinampTelegramCustomHandler(true);
15021
+ }, 1000);
14995
15022
  // CONCATENATED MODULE: ./js/actionCreators/files.ts
14996
15023
 
14997
15024
 
@@ -15404,7 +15431,7 @@ function files_addFilesFromUrl(atIndex = 0) {
15404
15431
  return async (dispatch, getState, {
15405
15432
  handleAddUrlEvent
15406
15433
  }) => {
15407
- await new webamp_telegram_handler_WinampTelegramCustomHandler().getFiles(prompt('Enter playlist link'));
15434
+ await new webamp_telegram_handler_WinampTelegramCustomHandler(false).getFiles(prompt('Enter playlist link'));
15408
15435
  };
15409
15436
  }
15410
15437
  function files_addFilesFromList() {