Files
2026-07-28 01:06:53 +03:00

355 lines
17 KiB
TypeScript

/* Metro module 10217; source: modules/spotify/SpotifyUtils.tsx; dependencies: [5, 4266, 6870, 6867, 6868, 661, 672, 4915, 6869, 10218, 2] */
import Module00005 from '../../by-id/module-00005.js'; /* Metro dependency 5 */
import Durations from '../../utils/Durations.tsx'; /* Metro dependency 672 */
import RunningGameStoreNative from '../game_detection/RunningGameStore.native.tsx'; /* Metro dependency 4266 */
import SpotifyStore from './SpotifyStore.tsx'; /* Metro dependency 6867 */
import SpotifyProtocolStore from './SpotifyProtocolStore.tsx'; /* Metro dependency 6870 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
import * as SpotifyConstantsModule from './SpotifyConstants.tsx'; /* Metro dependency 6868 */
function _fun79476(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#79476, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:6, offset: 0x01e54e7c, size: 369 bytes, params: 8, frame: 19
const env0_0 = require;
const _arrayLikeToArray_79479 = function(a0, a1) {
var r0;
var r1;
var r2;
var value3;
var length;
var value5;
var value = undefined;
var value2 = value == null;
reducibleJoin2: while (true) {
if (value2) {
r0 = value2;
break reducibleJoin2;
}
value3 = value > a0.length;
r0 = value3;
break reducibleJoin2;
}
reducibleJoin4: while (true) {
if (r0) {
length = a0.length;
r1 = length;
break reducibleJoin4;
}
r1 = value;
break reducibleJoin4;
}
value = (0, global.Array)(r1);
var value4 = 0;
if (value4 < r1) {
r2 = value4;
reducibleLoop5: while (true) {
value[r2] = a0[r2];
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
if (value5 < r1) {
r2 = value5;
continue reducibleLoop5;
}
break reducibleLoop5;
}
}
return value;
};
const asString_79480 = function(a0) {
if (typeof a0 === 'string') {
return a0;
}
var Error = global.Error;
throw new Error('value is not a string');
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const Millis = (Durations).Millis;
const SECOND = Millis.SECOND;
const env0_11 = 30 * SECOND;
(FileImportTrackerModule).fileFinishedImporting('modules/spotify/SpotifyUtils.tsx');
exports.isSpotifyPlayable = isSpotifyPlayable;
exports.ensureSpotifyPlayable = ensureSpotifyPlayable;
exports.isSpotifyPremium = isSpotifyPremium;
exports.ensureSpotifyPremium = ensureSpotifyPremium;
exports.getSpotifyMetadataFromActivity = function() {
return _getSpotifyMetadataFromActivity.apply(this, arguments);
};
function _createForOfIteratorHelperLoose_79477(a0, a1) { // fn#79477, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:253, offset: 0x01e54fed, size: 372 bytes, params: 3, frame: 20
var r6;
var r9;
var r5;
var value3;
var regexp;
const env0_0 = a0;
const Symbol = global.Symbol;
let value = typeof Symbol !== 'undefined';
let r1 = value && a0[global.Symbol.iterator];
r1 = !r1 ? a0['@@iterator'] : r1;
if (r1) {
value = r1.call(a0);
return value.next.bind(value);
}
const Array = global.Array;
if (Array.isArray(a0)) {
if (r1) {
}
return _fun79478;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_79479(a0, value);
r5 = value;
} else {
value3 = ({}).toString.call(a0).slice(8, -1);
r6 = value3 === 'Object' && a0.constructor;
r9 = r6 ? a0.constructor.name : value3;
if (r9 === 'Map') {
r6 = global.Array.from(a0);
} else if (r9 === 'Set') {
r6 = global.Array.from(a0);
} else if (r9 === 'Arguments') {
value = _arrayLikeToArray_79479(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_79479(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun79478;
}
const TypeError = global.TypeError;
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
function _fun79478() { // fn#79478, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:824, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
return env0_1 >= env0_0.length ? {done: true} : {done: false,
value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]};
}
}
function _getSpotifyMetadataFromActivity() { // fn#79481, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:1287, offset: 0x01e55195, size: 50 bytes, params: 1, frame: 14
return Module00005(_fun79483).apply(this, arguments);
function* _fun79483(a0, a1) { // fn#79483, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:1372, offset: 0x01e551d2, size: 348 bytes, params: 3, frame: 19
if (false) {
return undefined;
}
value = environment.__proto__.__proto__;
let binding = env2_0;
const value3 = undefined;
const value4 = binding(env2_2[9]);
const getMetadata = value4.getMetadata;
yield Reflect.apply(getMetadata, value4, [a0, a1]);
const value5 = undefined;
if (false) {
return value5;
}
binding = env2_9;
const binding2 = env2_14;
const r3 = value5.type ?? env2_8.TRACK;
binding2(r3);
const value7 = binding(r3);
if (value7 === null) {
throw new global.Error('invalid type ' + value5.type);
}
const object = {};
let context_uri = value5.context_uri;
context_uri = typeof context_uri !== 'string' ? value3 : value5.context_uri;
object.context_uri = context_uri;
binding = env2_14;
const album_id = value5.album_id;
binding(album_id);
object.album_id = album_id;
let Array = global.Array;
object.artist_ids = Array.isArray(value5.artist_ids) ? value5.artist_ids.map(env2_14) : [];
object.type = value7;
Array = global.Array;
object.button_urls = Array.isArray(value5.button_urls) ? value5.button_urls.map(env2_14) : [];
return object;
}
}
function isSpotifyPlayable(a0) { // fn#79484, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:1888, offset: 0x01e5532e, size: 41 bytes, params: 2, frame: 10
let value = a0.getActiveSocketAndDevice();
value = value != null;
return value || SpotifyProtocolStore.isProtocolRegistered();
}
function ensureSpotifyPlayable() { // fn#79485, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:2012, offset: 0x01e55357, size: 342 bytes, params: 1, frame: 19
var Promise;
var playableComputerDevices;
var runningGameStoreNativeBinding;
var isObservedAppRunning;
var defaultImport;
var promise;
var property;
var socket;
var device;
var value;
const activeSocketAndDevice = SpotifyStore.getActiveSocketAndDevice();
if (activeSocketAndDevice != null) {
return global.Promise.resolve(activeSocketAndDevice);
}
const spotifyProtocolStoreBinding = SpotifyProtocolStore;
if (spotifyProtocolStoreBinding.isProtocolRegistered()) {
playableComputerDevices = SpotifyStore.getPlayableComputerDevices();
runningGameStoreNativeBinding = RunningGameStoreNative;
isObservedAppRunning = runningGameStoreNativeBinding.isObservedAppRunning;
defaultImport = importDefault(4915) /* metro dependency 4915: Platforms */;
if (Reflect.apply(isObservedAppRunning, runningGameStoreNativeBinding,
[defaultImport.get(PlatformTypes.SPOTIFY).name])) {
if (playableComputerDevices.length > 0) {
property = playableComputerDevices[0];
socket = property.socket;
device = property.device;
value = require(6869) /* metro dependency 6869: SpotifyActionCreators */;
value.setActiveDevice(socket.accountId, device.id);
Promise = global.Promise;
return Promise.resolve({socket: socket, device: device});
}
Promise = global.Promise;
value = Object.create(Promise.prototype, {constructor: {value: Promise}});
promise = new Promise(_fun79486);
return promise instanceof Object ? promise : value;
}
Promise = global.Promise;
value = Object.create(Promise.prototype, {constructor: {value: Promise}});
promise = new Promise(_fun79486);
return promise instanceof Object ? promise : value;
}
Promise = global.Promise;
const reject = Promise.reject;
const Error = global.Error;
return Reflect.apply(reject, Promise, [new Error('protocol is not registered')]);
function _fun79486(a0, a1) { // fn#79486, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:2454, offset: 0x01e554ad, size: 124 bytes, params: 3, frame: 16
const env0_0 = a0;
const env0_1 = a1;
const env0_2 = global.setTimeout(_fun79487, env1_11);
SpotifyStore.addChangeListener(onSpotifyStoreChange);
global.window.open('' + SPOTIFY_APP_PROTOCOL + ':');
function _fun79487() { // fn#79487, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:2480, offset: 0x01e55529, size: 72 bytes, params: 1, frame: 12
const value = environment.__proto__.__proto__;
const spotifyStoreBinding = SpotifyStore;
spotifyStoreBinding.removeChangeListener(onSpotifyStoreChange);
const Error = global.Error;
require(new Error('timeout launching spotify'));
}
function onSpotifyStoreChange() { // fn#79488, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:2598, offset: 0x01e55571, size: 89 bytes, params: 1, frame: 15
var environment;
var r2;
var value3;
var socket;
var device;
var value4;
const onSpotifyStoreChange_loop2 = onSpotifyStoreChange_loop;
let value = environment.__proto__.__proto__;
const _createForOfIteratorHelperLoose_79477Binding = _createForOfIteratorHelperLoose_79477;
value = SpotifyStore.getPlayableComputerDevices();
value = _createForOfIteratorHelperLoose_79477Binding(value);
const value2 = value();
let done = value2.done;
if (!done) {
for (r2 = value2; true; r2 = value4) {
value3 = r2.value;
socket = value3.socket;
device = value3.device;
onSpotifyStoreChange_loop2(socket, device);
value4 = value();
done = value4.done;
if (done) {
break;
}
}
}
function onSpotifyStoreChange_loop(a0, a1) { // fn#79489, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:2619, owner: onSpotifyStoreChange._loop, offset: 0x01e555ca, size: 113 bytes, params: 3, frame: 14
var environment;
var clearTimeout;
var value2;
var spotifyStoreBinding;
const env0_0 = a0;
const env0_1 = a1;
let value = environment.__proto__.__proto__;
value = env2_0.find(function(a0) {
return a0.device.id === require.id;
});
if (value == null) {
clearTimeout = global.clearTimeout;
value = environment.__proto__;
clearTimeout(env1_2);
value2 = environment.__proto__.__proto__.__proto__;
spotifyStoreBinding = SpotifyStore;
spotifyStoreBinding.removeChangeListener(onSpotifyStoreChange);
global.setImmediate(_fun79491);
}
function _fun79491() { // fn#79491, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:2748, offset: 0x01e5565b, size: 85 bytes, params: 1, frame: 16
let value = environment.__proto__.__proto__.__proto__.__proto__;
value = require(6869) /* metro dependency 6869: SpotifyActionCreators */;
const setActiveDevice = value.setActiveDevice;
const binding = env0_0;
Reflect.apply(setActiveDevice, value, [binding.accountId, require.id]);
value = environment.__proto__.__proto__;
env2_0({socket: binding, device: require});
}
}
}
}
}
function isSpotifyPremium() { // fn#79492, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:3034, offset: 0x01e556b0, size: 40 bytes, params: 1, frame: 10
const activeSocketAndDevice = SpotifyStore.getActiveSocketAndDevice();
const value2 = null;
return value2 == activeSocketAndDevice ? value2 : activeSocketAndDevice.socket.isPremium;
}
function ensureSpotifyPremium() { // fn#79493, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:3161, offset: 0x01e556d8, size: 181 bytes, params: 1, frame: 14
var r0;
var Promise;
var value;
const activeSocketAndDevice = SpotifyStore.getActiveSocketAndDevice();
if (activeSocketAndDevice == null) {
Promise = global.Promise;
return Promise.reject(new global.Error('no active profile'));
}
const socket = activeSocketAndDevice.socket;
if (socket.isPremium) {
r0 = global.Promise.resolve();
} else {
value = require(6869) /* metro dependency 6869: SpotifyActionCreators */;
value = value.getProfile(socket.accountId, socket.accessToken);
value = value.then(_fun79494);
r0 = value;
}
return r0;
function _fun79494() { // fn#79494, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10403:3398, offset: 0x01e5578d, size: 73 bytes, params: 1, frame: 13
if (socket.isPremium) {
return undefined;
}
const Promise = global.Promise;
const reject = Promise.reject;
const Error = global.Error;
return Reflect.apply(reject, Promise, [new Error('spotify account is not premium')]);
}
}
}
global.__d(_fun79476, 10217, [5, 4266, 6870, 6867, 6868, 661, 672, 4915, 6869, 10218,
2]) /* metro module 10217, dependencies: [5, 4266, 6870, 6867, 6868, 661, 672, 4915, 6869, 10218, 2] */;