Files
discord-decomp/sources/modules/activities/native/EmbeddedActivitiesNativeManager.tsx
T
2026-07-28 01:06:53 +03:00

497 lines
27 KiB
TypeScript

/* Metro module 8092; source: modules/activities/native/EmbeddedActivitiesNativeManager.tsx; dependencies: [6, 7, 15, 17, 102, 18, 5, 27, 1379, 4294, 1378, 4237, 661, 5269, 477, 8070, 8071, 1216, 8072, 4496, 1244, 8093, 3774, 683, 694, 8095, 7860, 3857, 8096, 1239, 1360, 491, 8097, 2] */
import Module00005 from '../../../by-id/module-00005.js'; /* Metro dependency 5 */
import ClassCallCheck from '../../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from '../../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
import PossibleConstructorReturn from '../../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
import Module00017 from '../../../by-id/module-00017.js'; /* Metro dependency 17 */
import Inherits from '../../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
import Module00102 from '../../../by-id/module-00102.js'; /* Metro dependency 102 */
import AnalyticsUtils from '../../../utils/AnalyticsUtils.tsx'; /* Metro dependency 683 */
import Dispatcher from '../../../Dispatcher.tsx'; /* Metro dependency 694 */
import EmbeddedActivitiesStore from '../EmbeddedActivitiesStore.tsx'; /* Metro dependency 1378 */
import ChannelStore from '../../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */
import ToastActionCreators from '../../toast/native/ToastActionCreators.tsx'; /* Metro dependency 3857 */
import RTCConnectionStore from '../../../stores/RTCConnectionStore.tsx'; /* Metro dependency 4294 */
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactNativeModule from '../../../by-id/module-00027-ReactNative.js'; /* Metro dependency 27 */
import * as ConstantsModule from '../../../Constants.tsx'; /* Metro dependency 661 */
import * as IndexNativeModule from '../../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as EmbeddedActivityLocationUtilsModule from '../utils/embeddedActivityLocationUtils.tsx'; /* Metro dependency 3774 */
import * as ConstantsModule2 from '../Constants.tsx'; /* Metro dependency 4237 */
import * as Module05269Module from '../../../by-id/module-05269.js'; /* Metro dependency 5269 */
import * as EmbeddedActivitiesActionCreatorsModule from '../EmbeddedActivitiesActionCreators.tsx'; /* Metro dependency 7860 */
function _fun64844(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#64844, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:6, offset: 0x01bb6cf3, size: 505 bytes, params: 8, frame: 21
var nativeEventEmitter;
const env0_0 = require;
const postMessageToWebView_64850 = function() {
return _postMessageToWebView_64851.apply(this, arguments);
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const NativeEventEmitter = (ReactNativeModule).NativeEventEmitter;
let value = ConstantsModule;
const env0_14 = value.AnalyticEvents;
const env0_15 = value.ComponentActions;
const env0_16 = (Module05269Module).getWebViewProxy('EMBEDDED_ACTIVITY_WEB_VIEW_KEY');
value = require(477) /* metro dependency 477: PlatformUtils */;
value = value.isAndroid();
if (value) {
nativeEventEmitter = new NativeEventEmitter(importDefault(8070) /* metro dependency 8070: NativeAppLifecycleModule */);
}
value = importDefault(8097) /* metro dependency 8097: EmbeddedActivitiesManager */;
value = _fun64854(value);
value = new value();
(FileImportTrackerModule).fileFinishedImporting('modules/activities/native/EmbeddedActivitiesNativeManager.tsx');
exports.default = value;
exports.EMBEDDED_ACTIVITY_WEB_VIEW_KEY = 'EMBEDDED_ACTIVITY_WEB_VIEW_KEY';
function _isNativeReflectConstruct_64845() { // fn#64845, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:337, offset: 0x01bb6eec, size: 94 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_64845_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _superPropGet_64848(a0, a1, a2, a3) { // fn#64848, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:530, offset: 0x01bb6f4a, size: 99 bytes, params: 5, frame: 18
let value = a0;
const env0_0 = a2;
value = Module00017(1 & 3 ? value.prototype : value);
value = Module00102(value, a1, a2);
return 2 & 3 ? typeof value !== 'function' ? value : _fun64849 : value;
function _fun64849(a0) { // fn#64849, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:629, offset: 0x00c62408, size: 27 bytes, params: 2, frame: 13
return env0_1.apply(importDefault, a0);
}
}
function _postMessageToWebView_64851() { // fn#64851, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:862, offset: 0x01bb6fad, size: 48 bytes, params: 1, frame: 14
return Module00005(_fun64853).apply(this, arguments);
function* _fun64853(a0) { // fn#64853, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:927, offset: 0x01bb6fe6, size: 116 bytes, params: 2, frame: 15
var binding;
var injectJavaScript;
var binding2;
var binding3;
var property;
var value3;
var value4;
var value5;
var value6;
var value7;
var error;
if (true) {
value = environment.__proto__.__proto__;
try {
binding = env2_16;
} catch (error) {
binding = env2_1;
value = binding(env2_2[17]);
value.captureException(error);
return undefined;
}
try {
injectJavaScript = binding.injectJavaScript;
} catch (error) {
binding = env2_1;
value = binding(env2_2[17]);
value.captureException(error);
return undefined;
}
try {
binding2 = env2_1;
} catch (error) {
binding = env2_1;
value = binding(env2_2[17]);
value.captureException(error);
return undefined;
}
try {
binding3 = env2_2;
} catch (error) {
binding = env2_1;
value = binding(env2_2[17]);
value.captureException(error);
return undefined;
}
try {
property = binding3[16];
} catch (error) {
binding = env2_1;
value = binding(env2_2[17]);
value.captureException(error);
return undefined;
}
try {
value3 = binding2(property);
} catch (error) {
binding = env2_1;
value = binding(env2_2[17]);
value.captureException(error);
return undefined;
}
try {
value4 = value3(a0);
} catch (error) {
binding = env2_1;
value = binding(env2_2[17]);
value.captureException(error);
return undefined;
}
try {
value5 = Reflect.apply(injectJavaScript, binding, [value4]);
} catch (error) {
binding = env2_1;
value = binding(env2_2[17]);
value.captureException(error);
return undefined;
}
yield value5;
try {
value6 = undefined;
value7 = false;
} catch (error) {
binding = env2_1;
value = binding(env2_2[17]);
value.captureException(error);
return undefined;
}
if (value7) {
return value6;
}
}
}
}
function _fun64854(a0) { // fn#64854, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:1057, offset: 0x01bb705a, size: 329 bytes, params: 2, frame: 16
const EmbeddedActivitiesNativeManager2 = EmbeddedActivitiesNativeManager;
Inherits(EmbeddedActivitiesNativeManager2, a0);
return CreateClass(EmbeddedActivitiesNativeManager2, [{key: '_initialize', value: value_64857}, {key: '_terminate',
value: value_64861}, {key: 'showErrorModal', value: function({code, message}) {
var defaultImport = importDefault(dependencyMap[19]);
var object = {};
object.title = require(dependencyMap[20]).intl.formatToPlainString(require(dependencyMap[20]).t.hbiAO6,
{code: code});
object.body = message;
defaultImport.show(object);
}}, {key: 'showLaunchErrorModal', value: function(a0) {
var defaultImport = importDefault(dependencyMap[19]);
var object = {};
object.title = require(dependencyMap[20]).intl.string(require(dependencyMap[20]).t.PtobXW);
object.body = a0;
defaultImport.show(object);
}}, {key: 'showDevShelfOverrideEnabled', value: value_64864}, {key: 'releaseWebView', value: value_64865},
{key: 'leaveActivity', value: function({location, applicationId, showFeedback}) {
var clearEmbeddedActivityState;
var value = this.releaseWebView();
if (location != null && require(dependencyMap[30]).isNotNullish(applicationId)) {
clearEmbeddedActivityState = this.clearEmbeddedActivityState;
value = value != null;
Reflect.apply(clearEmbeddedActivityState, this, [location, applicationId, value && showFeedback]);
}
}}, {key: 'hidePIPEmbed', value: function(a0) {
if (a0 == null) {
throwTypeError(a0, "Cannot destructure 'undefined' or 'null'.", a0);
throw undefined;
}
}}, {key: 'clearEmbeddedActivityState', value: value_64868}, {key: 'releaseFrameId', value: function() {
var frameId = this.frameId;
this.frameId = undefined;
return frameId;
}}, {key: 'hasFrameId', value: function() {
return this.frameId != null;
}}, {key: 'getOrCreateFrameId', value: value_64871}]);
function EmbeddedActivitiesNativeManager(a0) { // fn#64855, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:1069, offset: 0x01bb71a3, size: 143 bytes, params: 2, frame: 20
var r0;
var Reflect;
let value = copyRestArgs(0, undefined);
let binding = env1_3;
binding(this, EmbeddedActivitiesNativeManager);
const items2 = [];
arraySpread(items2, value, 0, items2);
value = env1_6(EmbeddedActivitiesNativeManager);
binding = env1_5;
if (_isNativeReflectConstruct_64845()) {
Reflect = global.Reflect;
value = Reflect.construct(value, items2, env1_6(this).constructor);
r0 = value;
} else {
value = value.apply(this, items2);
r0 = value;
}
value = binding(this, r0);
value.handleRPCDisconnect = handleRPCDisconnect;
return value;
function handleRPCDisconnect({reason, application}) { // fn#64856, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:1370, owner: EmbeddedActivitiesNativeManager.handleRPCDisconnect, offset: 0x01bb7232, size: 101 bytes, params: 2, frame: 16
let value = environment.__proto__.__proto__;
value = EmbeddedActivitiesStore.getConnectedActivityLocation();
const id = application?.id;
const binding = env0_0;
binding.leaveActivity({location: value, applicationId: id});
binding.superHandleRPCDisconnect({reason: reason, application: application});
}
}
function value_64857() { // fn#64857, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:1666, offset: 0x01bb7297, size: 228 bytes, params: 1, frame: 21
var environment;
let value = environment.__proto__;
const _superPropGet_64848Binding = _superPropGet_64848;
const value3 = undefined;
_superPropGet_64848Binding(EmbeddedActivitiesNativeManager, '_initialize', this, 3)([]);
const lifecycleSubscription = this.lifecycleSubscription;
if (lifecycleSubscription != null) {
lifecycleSubscription.remove();
}
this.lifecycleSubscription = env1_17 == null ? value3 : env1_17.addListener('onHostDestroy', _fun64858);
const scriptMessageSubscription = this.scriptMessageSubscription;
if (scriptMessageSubscription != null) {
scriptMessageSubscription.remove();
}
const binding = env1_16;
this.scriptMessageSubscription = binding.addOnMessageListener(_fun64859);
const thermalStateSubscription = this.thermalStateSubscription;
if (thermalStateSubscription != null) {
thermalStateSubscription.remove();
}
value = importDefault(8093) /* metro dependency 8093: ThermalUtilsNative */;
this.thermalStateSubscription = value.addListener(_fun64860);
return value3;
function _fun64858() { // fn#64858, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:1881, offset: 0x01bb737b, size: 94 bytes, params: 1, frame: 13
const value = environment.__proto__.__proto__;
const connectedActivityLocation = EmbeddedActivitiesStore.getConnectedActivityLocation();
const value3 = null;
const r3 = value3 != connectedActivityLocation ? EmbeddedActivitiesStore.getSelfEmbeddedActivityForLocation(connectedActivityLocation) : value3;
if (value3 != r3 && value3 != connectedActivityLocation) {
env0_0.leaveActivity({location: connectedActivityLocation, applicationId: r3.applicationId});
}
}
function _fun64859(a0) { // fn#64859, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:2172, offset: 0x01bb73d9, size: 494 bytes, params: 2, frame: 25
var r9;
var url;
var applicationId;
var r1;
var r12;
var JSON;
var parse;
var data;
var value2;
var value3;
var connectedActivityLocation;
var value5;
var value6;
var selfEmbeddedActivityForLocation;
var value8;
var value9;
var value10;
var property;
var defaultImport;
var error;
var SyntaxError;
var value11;
var connectedActivityLocation2;
var selfEmbeddedActivityForLocation2;
var value14;
var value15;
var value16;
var binding;
var object;
var defaultImport2;
var show;
const intl = require(dependencyMap[20]).intl;
var string;
const t = require(dependencyMap[20]).t;
var tYBBWz;
var BddRzS;
const value = undefined;
try {
JSON = global.JSON;
parse = JSON.parse;
data = a0.data;
value2 = Reflect.apply(parse, JSON, [data]);
value3 = environment.__proto__.__proto__;
connectedActivityLocation = EmbeddedActivitiesStore.getConnectedActivityLocation();
value5 = null;
value6 = value5 != connectedActivityLocation;
if (value6) {
selfEmbeddedActivityForLocation = EmbeddedActivitiesStore.getSelfEmbeddedActivityForLocation(connectedActivityLocation);
r9 = selfEmbeddedActivityForLocation;
} else {
r9 = value5;
}
value8 = value5 == r9;
url = value8 ? value : r9.url;
value9 = typeof value2 === 'object';
if (value9) {
value10 = value5 != url;
r9 = value10;
} else {
r9 = value9;
}
if (r9) {
property = dependencyMap[18];
defaultImport = importDefault(property);
defaultImport.handleMessage(value2, url, postMessageToWebView_64850);
}
} catch (error) {
SyntaxError = global.SyntaxError;
if (!(error instanceof SyntaxError)) {
throw error;
}
data = a0.data;
value11 = environment.__proto__.__proto__;
if (data === DISALLOWED_NAVIGATION_ERROR_CLOSE_ACTIVITY) {
connectedActivityLocation2 = EmbeddedActivitiesStore.getConnectedActivityLocation();
if (connectedActivityLocation2 != null) {
selfEmbeddedActivityForLocation2 = EmbeddedActivitiesStore.getSelfEmbeddedActivityForLocation(connectedActivityLocation2);
applicationId = selfEmbeddedActivityForLocation2 == null ? value : selfEmbeddedActivityForLocation2.applicationId;
r1 = applicationId;
} else {
r1 = value;
}
value14 = connectedActivityLocation2 != null;
if (value14) {
value15 = r1 != null;
r12 = value15;
} else {
r12 = value14;
}
if (r12) {
value16 = environment;
binding = env0_0;
binding.leaveActivity({location: connectedActivityLocation2, applicationId: r1, showFeedback: false});
defaultImport2 = importDefault(dependencyMap[19]);
show = defaultImport2.show;
object = {};
string = intl.string;
tYBBWz = t.tYBBWz;
object.body = Reflect.apply(string, intl, [tYBBWz]);
string = intl.string;
BddRzS = t.BddRzS;
object.confirmText = Reflect.apply(string, intl, [BddRzS]);
Reflect.apply(show, defaultImport2, [object]);
}
}
}
return value;
}
function _fun64860({rawThermalState}) { // fn#64860, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:2902, offset: 0x01bb75c7, size: 382 bytes, params: 2, frame: 21
const value = environment.__proto__.__proto__;
const connectedActivityLocation = EmbeddedActivitiesStore.getConnectedActivityLocation();
const r4 = connectedActivityLocation != null ? EmbeddedActivitiesStore.getSelfEmbeddedActivityForLocation(connectedActivityLocation) : null;
const embeddedActivityLocationChannelId = (EmbeddedActivityLocationUtilsModule).getEmbeddedActivityLocationChannelId(connectedActivityLocation);
const basicChannel = ChannelStore.getBasicChannel(embeddedActivityLocationChannelId);
const compositeInstanceId = r4?.compositeInstanceId;
const applicationId = r4?.applicationId;
const defaultImport = AnalyticsUtils;
const track = defaultImport.track;
const ACTIVITY_DEVICE_THERMAL_STATE_CHANGED = AnalyticEvents.ACTIVITY_DEVICE_THERMAL_STATE_CHANGED;
const object = {channel_id: embeddedActivityLocationChannelId, application_id: applicationId,
activity_session_id: compositeInstanceId, thermal_state: rawThermalState};
object.guild_id = basicChannel?.guild_id;
object.media_session_id = RTCConnectionStore.getMediaSessionId();
Reflect.apply(track, defaultImport, [ACTIVITY_DEVICE_THERMAL_STATE_CHANGED, object]);
const defaultImport2 = Dispatcher;
defaultImport2.dispatch({type: 'THERMAL_STATE_CHANGE', applicationId: applicationId});
if (compositeInstanceId != null && applicationId != null && (require(8095) /* metro dependency 8095: useThermalState */).getThermalState() >= (require(8095) /* metro dependency 8095: useThermalState */).ThermalStates.SERIOUS) {
(require(7860) /* metro dependency 7860: EmbeddedActivitiesActionCreators */).requestRespondToSeriousThermalState();
}
}
}
function value_64861() { // fn#64861, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:3597, offset: 0x01bb7745, size: 108 bytes, params: 1, frame: 17
const value = environment.__proto__;
_superPropGet_64848(EmbeddedActivitiesNativeManager, '_terminate', this, 3)([]);
const lifecycleSubscription = this.lifecycleSubscription;
if (lifecycleSubscription != null) {
lifecycleSubscription.remove();
}
const scriptMessageSubscription = this.scriptMessageSubscription;
if (scriptMessageSubscription != null) {
scriptMessageSubscription.remove();
}
const thermalStateSubscription = this.thermalStateSubscription;
if (thermalStateSubscription != null) {
thermalStateSubscription.remove();
}
}
function value_64864() { // fn#64864, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:4159, offset: 0x01bb788e, size: 134 bytes, params: 1, frame: 18
const defaultImport = ToastActionCreators;
const open = defaultImport.open;
const object = {key: 'EMBEDDED_ACTIVITIES_DEV_SHELF_URL_OVERRIDE_ENABLED'};
const intl = (IndexNativeModule).intl;
const string = intl.string;
const JfA7IK = (IndexNativeModule).t.JfA7IK;
object.content = Reflect.apply(string, intl, [JfA7IK]);
object.icon = importDefault(8096) /* metro dependency 8096 */;
object.iconColor = 'status-positive';
Reflect.apply(open, defaultImport, [object]);
}
function value_64865() { // fn#64865, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:4366, offset: 0x01bb7914, size: 93 bytes, params: 1, frame: 16
var value2;
var ComponentDispatch;
const value = this.releaseFrameId();
if (value != null) {
value2 = environment.__proto__;
ComponentDispatch = (require(1239) /* metro dependency 1239: ComponentDispatchUtils */).ComponentDispatch;
ComponentDispatch.dispatch(ComponentActions.IFRAME_UNMOUNT, {id: value});
env1_16.releaseWebView();
}
return value;
}
function value_64868(a0, a1, a2) { // fn#64868, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:4785, offset: 0x01bb79fc, size: 108 bytes, params: 4, frame: 16
const value = environment.__proto__;
(EmbeddedActivitiesActionCreatorsModule).stopEmbeddedActivity({location: a0,
applicationId: a1, showFeedback: a2});
(Dispatcher).dispatch({'type': 'EMBEDDED_ACTIVITY_SET_ORIENTATION_LOCK_STATE',
'applicationId': null, 'lockState': null, 'pictureInPictureLockState': null, applicationId: a1});
}
function value_64871() { // fn#64871, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8277:5198, offset: 0x01bb7a68, size: 60 bytes, params: 1, frame: 13
const frameId = this.frameId;
if (frameId != null) {
return frameId;
}
let value = environment.__proto__;
value = require(491) /* metro dependency 491 */;
value = value.v4();
this.frameId = value;
return value;
}
}
}
global.__d(_fun64844, 8092, [6, 7, 15, 17, 102, 18, 5, 27, 1379, 4294, 1378, 4237, 661, 5269, 477, 8070, 8071, 1216,
8072, 4496, 1244, 8093, 3774, 683, 694, 8095, 7860, 3857, 8096, 1239, 1360, 491, 8097,
2]) /* metro module 8092, dependencies: [6, 7, 15, 17, 102, 18, 5, 27, 1379, 4294, 1378, 4237, 661, 5269, 477, 8070, 8071, 1216, 8072, 4496, 1244, 8093, 3774, 683, 694, 8095, 7860, 3857, 8096, 1239, 1360, 491, 8097, 2] */;