@exezt-/webamp 1.5.0-0x4 → 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.
package/built/webamp.bundle.js
CHANGED
|
@@ -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(
|
|
14807
|
+
localStorage.setItem("app-state", JSON.stringify(window.__webamp.store.getState()));
|
|
14798
14808
|
});
|
|
14799
14809
|
|
|
14800
14810
|
defineProperty_default()(this, "getFiles", async ln => {
|
|
@@ -14803,22 +14813,31 @@ class webamp_telegram_WinampTelegramCustomHandler {
|
|
|
14803
14813
|
x.open('get', `https://cloud-api.yandex.net/v1/disk/public/resources?public_key=${link}`, true);
|
|
14804
14814
|
x.setRequestHeader('Accept', 'application/json');
|
|
14805
14815
|
x.setRequestHeader('Content-Type', 'application/json');
|
|
14806
|
-
x.setRequestHeader('Access-Control-Allow-Origin', 'no-cors');
|
|
14807
14816
|
x.send();
|
|
14808
14817
|
|
|
14809
14818
|
x.onload = async () => {
|
|
14810
14819
|
if (x.status === 200) {
|
|
14811
14820
|
var _JSON$parse;
|
|
14812
14821
|
|
|
14813
|
-
const playlistName = JSON.parse(x.responseText).name;
|
|
14814
14822
|
const data = (_JSON$parse = JSON.parse(x.responseText)) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse._embedded.items;
|
|
14815
14823
|
let i = 0;
|
|
14816
14824
|
this.saveLastPlaylist(ln);
|
|
14817
14825
|
|
|
14818
14826
|
for (const item of data) {
|
|
14819
|
-
if (item.size > 0x1400000) {
|
|
14827
|
+
if (item.size > 0x1400000) {
|
|
14828
|
+
console.info(`File ${item.name} can't be loaded due oversize`);
|
|
14820
14829
|
} else {
|
|
14821
|
-
await fetch(item.file
|
|
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 => {
|
|
14822
14841
|
var _res$body;
|
|
14823
14842
|
|
|
14824
14843
|
console.log(res);
|
|
@@ -14867,6 +14886,10 @@ class webamp_telegram_WinampTelegramCustomHandler {
|
|
|
14867
14886
|
};
|
|
14868
14887
|
});
|
|
14869
14888
|
|
|
14889
|
+
defineProperty_default()(this, "saveLastPlaylist", playlistLink => {
|
|
14890
|
+
document.cookie = `lastlist=${playlistLink}; path=/;`;
|
|
14891
|
+
});
|
|
14892
|
+
|
|
14870
14893
|
defineProperty_default()(this, "getCookie", name => {
|
|
14871
14894
|
const regex = new RegExp(`(^| )${name}=([^;]+)`);
|
|
14872
14895
|
const match = document.cookie.match(regex);
|
|
@@ -14920,44 +14943,58 @@ class webamp_telegram_WinampTelegramCustomHandler {
|
|
|
14920
14943
|
i++;
|
|
14921
14944
|
}
|
|
14922
14945
|
|
|
14923
|
-
if (window.__webamp.store.getState().media.shuffle !== opts.media.shuffle)
|
|
14924
|
-
|
|
14925
|
-
|
|
14926
|
-
|
|
14927
|
-
|
|
14928
|
-
|
|
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
|
+
}
|
|
14929
14957
|
});
|
|
14930
14958
|
|
|
14931
|
-
|
|
14959
|
+
const lastList = this.getCookie('lastlist');
|
|
14932
14960
|
|
|
14933
14961
|
if (typeof lastList !== "undefined") {
|
|
14934
|
-
this.getFiles(lastList)
|
|
14962
|
+
this.getFiles(lastList);
|
|
14935
14963
|
}
|
|
14964
|
+
}
|
|
14936
14965
|
|
|
14937
|
-
|
|
14938
|
-
|
|
14966
|
+
initialize() {
|
|
14967
|
+
var _window, _window$Telegram, _window2, _window2$Telegram;
|
|
14939
14968
|
|
|
14940
|
-
|
|
14941
|
-
|
|
14942
|
-
});
|
|
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;
|
|
14943
14971
|
|
|
14944
|
-
|
|
14945
|
-
|
|
14946
|
-
|
|
14972
|
+
if (!window.__webamp) {
|
|
14973
|
+
throw new Error("Webamp __webamp is undefined!!");
|
|
14974
|
+
} // @ts-ignore | because no global var telegram avail in project types
|
|
14947
14975
|
|
|
14948
|
-
window.__webamp.store.dispatch({
|
|
14949
|
-
type: "ENABLE_MILKDROP",
|
|
14950
|
-
open: false
|
|
14951
|
-
});
|
|
14952
|
-
}, 2000);
|
|
14953
|
-
}
|
|
14954
14976
|
|
|
14955
|
-
|
|
14956
|
-
|
|
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
|
+
});
|
|
14957
14995
|
}
|
|
14958
14996
|
|
|
14959
14997
|
}
|
|
14960
|
-
new webamp_telegram_WinampTelegramCustomHandler();
|
|
14961
14998
|
// CONCATENATED MODULE: ./js/actionCreators/files.ts
|
|
14962
14999
|
|
|
14963
15000
|
|