decord/alpha/source/modules/activities/native/EmbeddedActivityView.tsx

307 lines
11 KiB
TypeScript
Raw Normal View History

// Module ID: 9802
// Function ID: 9803
// Name: EmbeddedActivityView
// Dependencies: [109, 32, 19, 17, 2041, 2004, 1349, 21, 4827, 9801, 1478, 573, 9803, 9804, 9806, 9799, 504, 9808, 9655, 9809, 9817, 2]
2026-07-20 16:05:17 +00:00
// Module 9802 (EmbeddedActivityView)
import DispatcherDefault from "Dispatcher" /* 573 */;
import EmbeddedActivitiesNativeManagerDefault from "EmbeddedActivitiesNativeManager" /* 9655 */;
import doesOrientationMatchLockStateDefault from "doesOrientationMatchLockState" /* 9803 */;
import WakeLockDefault from "WakeLock" /* 9806 */;
import _objectWithoutProperties from "_objectWithoutProperties" /* 109 */;
import _slicedToArray from "module_32" /* 32 */;
import noop from "module_19" /* 19 */;
import EmbeddedActivitiesStore from "EmbeddedActivitiesStore" /* 2041 */;
2026-07-23 10:11:24 +00:00
const require = fn;
2026-07-20 16:05:17 +00:00
function useBaseActivityView(orientationLockState) {
orientationLockState = orientationLockState.orientationLockState;
const showLoadingIndicator = orientationLockState.showLoadingIndicator;
const setShowLoadingStateForLockingOrientation = orientationLockState.setShowLoadingStateForLockingOrientation;
const application = orientationLockState.application;
const setOrientationLockState = orientationLockState.setOrientationLockState;
2026-07-29 08:29:29 +00:00
let isResetting;
let defaultOrientationLockState;
2026-07-23 10:11:24 +00:00
let first1;
2026-08-24 06:08:38 +00:00
closure_8 = undefined;
2026-07-20 16:05:17 +00:00
let isLandscape;
2026-08-24 06:08:38 +00:00
const setIsResetting = isResetting(defaultOrientationLockState.useState(false), 2);
2026-07-29 08:29:29 +00:00
isResetting = setIsResetting[0];
2026-08-24 06:08:38 +00:00
defaultOrientationLockState = orientationLockState(setShowLoadingStateForLockingOrientation[9]).getDefaultOrientationLockState(application);
2026-07-20 16:05:17 +00:00
let id;
2026-07-29 08:29:29 +00:00
if (application != null) {
2026-07-20 16:05:17 +00:00
id = application.id;
}
2026-08-24 06:08:38 +00:00
const tmpResult = isResetting(defaultOrientationLockState.useState(false), 2);
2026-07-29 08:29:29 +00:00
first1 = tmpResult[0];
closure_8 = tmpResult[1];
2026-08-24 06:08:38 +00:00
const size = showLoadingIndicator(setShowLoadingStateForLockingOrientation[10])();
2026-07-20 16:05:17 +00:00
isLandscape = size.width > size.height;
const items = [isLandscape];
2026-07-29 08:29:29 +00:00
const layoutEffect = obj.useLayoutEffect(() => {
DispatcherDefault.dispatch({ type: "ACTIVITY_SCREEN_ORIENTATION_UPDATE", screenOrientation: isLandscape ? constants.LANDSCAPE : constants.PORTRAIT });
2026-07-20 16:05:17 +00:00
}, items);
const items1 = [id];
2026-07-29 08:29:29 +00:00
const layoutEffect1 = obj.useLayoutEffect(() => {
closure_8(false);
2026-07-20 16:05:17 +00:00
}, items1);
const items2 = [defaultOrientationLockState, application, orientationLockState, isLandscape, first1, setShowLoadingStateForLockingOrientation, setOrientationLockState];
2026-07-29 08:29:29 +00:00
const layoutEffect2 = obj.useLayoutEffect(() => {
2026-07-20 16:05:17 +00:00
if (!first1) {
if (null == orientationLockState) {
if (!doesOrientationMatchLockStateDefault(isLandscape, defaultOrientationLockState)) {
2026-07-20 16:05:17 +00:00
setShowLoadingStateForLockingOrientation(true);
}
if (null != application) {
2026-07-29 08:29:29 +00:00
setOrientationLockState(tmp10, orientationLockState);
2026-07-20 16:05:17 +00:00
}
}
}
setShowLoadingStateForLockingOrientation(false);
}, items2);
const items3 = [orientationLockState, isLandscape, setShowLoadingStateForLockingOrientation];
2026-07-29 08:29:29 +00:00
const layoutEffect3 = obj.useLayoutEffect(() => {
if (doesOrientationMatchLockStateDefault(isLandscape, orientationLockState)) {
2026-07-20 16:05:17 +00:00
setShowLoadingStateForLockingOrientation(false);
}
}, items3);
const items4 = [showLoadingIndicator, isResetting];
2026-07-29 08:29:29 +00:00
const layoutEffect4 = obj.useLayoutEffect(() => {
2026-07-20 16:05:17 +00:00
let tmp = showLoadingIndicator;
if (!showLoadingIndicator) {
tmp = isResetting;
}
if (!tmp) {
closure_8(true);
2026-07-20 16:05:17 +00:00
}
}, items4);
return { isResetting, setIsResetting: setIsResetting[1], isLandscape };
}
class ActivityViewLoadingIndicator {
constructor() {
2026-08-24 06:08:38 +00:00
obj = { style: closure_16().loadingContainer, children: jsx(ActivityIndicator, { size: "large" }) };
2026-07-20 16:05:17 +00:00
return jsx(View, obj);
}
}
class BaseActivityView {
constructor(arg0) {
if (global.showLoadingIndicator) {
tmp10 = jsx;
tmp11 = ActivityViewLoadingIndicator;
tmp4 = jsx(ActivityViewLoadingIndicator, {});
} else {
tmp4 = null;
if (!tmp3) {
tmp5 = jsxs;
tmp6 = Fragment;
2026-07-29 08:29:29 +00:00
obj = { children: null };
2026-07-20 16:05:17 +00:00
tmp7 = jsx;
2026-07-23 10:11:24 +00:00
tmp8 = closure_1;
tmp9 = closure_2;
obj1 = { wakeLockKey: null };
obj1.wakeLockKey = tmp2;
2026-07-20 16:05:17 +00:00
items = [, ];
items[0] = jsx(closure_1(closure_2[14]), obj1);
2026-07-20 16:05:17 +00:00
items[1] = tmp;
obj.children = items;
2026-07-20 16:05:17 +00:00
tmp4 = jsxs(Fragment, obj);
}
}
return tmp4;
}
}
2026-08-24 06:08:38 +00:00
let closure_3 = ["ui_density"];
get_ActivityIndicator = fn(17);
({ ActivityIndicator: closure_7, View: closure_8 } = get_ActivityIndicator);
const Constants = fn(2004);
({ ActivityLayoutMode: c10, ActivityScreenOrientation: closure_11 } = Constants);
fn(1349).OBEY_SILENT_HARDWARE_SWITCH_APP_IDS;
const jsxProd = fn(21);
2026-08-24 06:08:38 +00:00
({ jsx: map1, Fragment: closure_14, jsxs: closure_15 } = jsxProd);
const createStyles = fn(4827);
const value = createStyles.createStyles({ loadingContainer: { flex: 1, justifyContent: "center" } });
const memoResult = noop.memo(function EmbeddedActivityViewInner(portraitSafeAreasConfig) {
2026-07-20 16:05:17 +00:00
({ channel, layoutMode } = portraitSafeAreasConfig);
let landscapeSafeAreasConfig = portraitSafeAreasConfig.portraitSafeAreasConfig;
2026-07-23 10:11:24 +00:00
let setIsResetting;
const currentEmbeddedActivity = EmbeddedActivitiesStore.getCurrentEmbeddedActivity();
const tmp4 = currentEmbeddedActivity(9799)();
2026-07-29 08:29:29 +00:00
dependencyMap = tmp4;
const items = [EmbeddedActivitiesStore];
2026-07-20 16:05:17 +00:00
const items1 = [tmp4];
const stateFromStores = layoutMode(504).useStateFromStores(items, () => {
2026-07-20 16:05:17 +00:00
let orientationLockStateForApp;
2026-08-24 06:08:38 +00:00
if (null != closure_2) {
orientationLockStateForApp = EmbeddedActivitiesStore.getOrientationLockStateForApp(tmp.id);
2026-07-20 16:05:17 +00:00
}
return orientationLockStateForApp;
}, items1);
let obj = layoutMode(504);
[tmp8, tmp9] = noop.useState(true);
2026-07-20 16:05:17 +00:00
if (null == currentEmbeddedActivity) {
let obj3 = { instance_id: "" };
2026-07-20 16:05:17 +00:00
} else {
const discordEnvQueryParams = tmp5(9804).getDiscordEnvQueryParams();
2026-08-24 06:08:38 +00:00
const ui_density = discordEnvQueryParams.ui_density;
const tmp38 = _objectWithoutProperties(discordEnvQueryParams, setIsResetting);
2026-07-20 16:05:17 +00:00
let launchId = currentEmbeddedActivity.compositeInstanceId;
2026-07-29 08:29:29 +00:00
if (launchId == null) {
2026-07-20 16:05:17 +00:00
launchId = currentEmbeddedActivity.launchId;
}
const obj4 = { instance_id: launchId, location_id: null, launch_id: null };
2026-07-23 10:11:24 +00:00
let _location = currentEmbeddedActivity.location;
let id1;
2026-07-29 08:29:29 +00:00
if (_location != null) {
id1 = _location.id;
2026-07-20 16:05:17 +00:00
}
obj4.location_id = id1;
obj4.launch_id = currentEmbeddedActivity.launchId;
2026-08-24 06:08:38 +00:00
const merged = Object.assign(tmp38);
2026-07-20 16:05:17 +00:00
if (null != currentEmbeddedActivity.proxyTicket) {
obj4.discord_proxy_ticket = currentEmbeddedActivity.proxyTicket;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
let tmp14 = null != channel && null != channel.id;
if (tmp14) {
tmp14 = "" !== channel.id;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
if (tmp14) {
obj4.channel_id = channel.id;
2026-07-20 16:05:17 +00:00
}
let guild_id;
2026-07-29 08:29:29 +00:00
if (channel != null) {
guild_id = channel.guild_id;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
let tmp16 = null != guild_id;
if (tmp16) {
2026-07-20 16:05:17 +00:00
let guild_id1;
2026-07-29 08:29:29 +00:00
if (channel != null) {
guild_id1 = channel.guild_id;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
tmp16 = "" !== guild_id1;
2026-07-20 16:05:17 +00:00
}
obj3 = obj4;
2026-08-24 06:08:38 +00:00
if (tmp16) {
2026-07-20 16:05:17 +00:00
let guild_id2;
2026-07-29 08:29:29 +00:00
if (channel != null) {
guild_id2 = channel.guild_id;
2026-07-20 16:05:17 +00:00
}
obj4.guild_id = guild_id2;
obj3 = obj4;
2026-07-20 16:05:17 +00:00
}
const tmp5Result = tmp5(9804);
2026-07-20 16:05:17 +00:00
}
currentEmbeddedActivity(9808)({ connectedEmbeddedActivity: currentEmbeddedActivity });
2026-07-20 16:05:17 +00:00
const items2 = [layoutMode, currentEmbeddedActivity];
const layoutEffect = obj2.useLayoutEffect(() => {
2026-07-20 16:05:17 +00:00
if (null != currentEmbeddedActivity) {
const obj2 = { type: "ACTIVITY_LAYOUT_MODE_UPDATE", layoutMode, applicationId: tmp.applicationId };
DispatcherDefault.dispatch(obj2);
2026-07-20 16:05:17 +00:00
}
}, items2);
const items3 = [tmp4, currentEmbeddedActivity];
const callback = obj2.useCallback(() => {
2026-07-20 16:05:17 +00:00
let _location;
2026-07-29 08:29:29 +00:00
if (currentEmbeddedActivity != null) {
2026-07-20 16:05:17 +00:00
_location = currentEmbeddedActivity.location;
}
const obj2 = { location: _location, applicationId: null };
2026-08-24 06:08:38 +00:00
id = undefined;
if (id != null) {
id = id.id;
2026-07-20 16:05:17 +00:00
}
obj2.applicationId = id;
EmbeddedActivitiesNativeManagerDefault.leaveActivity(obj2);
2026-07-20 16:05:17 +00:00
}, items3);
2026-07-29 08:29:29 +00:00
if (tmp4 != null) {
let id = tmp4.id;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
let tmp22 = null == currentEmbeddedActivity;
if (!tmp22) {
let launchId1;
2026-07-29 08:29:29 +00:00
if (currentEmbeddedActivity != null) {
launchId1 = currentEmbeddedActivity.launchId;
2026-07-20 16:05:17 +00:00
}
tmp22 = null == launchId1;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
if (!tmp22) {
tmp22 = tmp8;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
if (!tmp22) {
tmp22 = null == id;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
if (!tmp22) {
tmp22 = null == tmp4;
2026-07-20 16:05:17 +00:00
}
const tmp7 = _slicedToArray(noop.useState(true), 2);
const obj5 = { orientationLockState: stateFromStores, showLoadingIndicator: tmp22, setShowLoadingStateForLockingOrientation: tmp9, application: tmp4, setOrientationLockState: layoutMode(9801).setOrientationLockState };
setIsResetting = useBaseActivityView({ orientationLockState: stateFromStores, showLoadingIndicator: tmp22, setShowLoadingStateForLockingOrientation: tmp9, application: tmp4, setOrientationLockState: layoutMode(9801).setOrientationLockState }).setIsResetting;
2026-08-24 06:08:38 +00:00
let tmp28Result = null;
2026-07-20 16:05:17 +00:00
if (null != currentEmbeddedActivity) {
2026-08-24 06:08:38 +00:00
tmp28Result = null;
2026-07-20 16:05:17 +00:00
if (null != id) {
const obj6 = { wakeLockKey: "EmbeddedActivities", showLoadingIndicator: tmp22, isResetting: tmp25, children: null };
const obj7 = {
onActivityCrash() {
setIsResetting(true);
const timerId = setTimeout(() => setIsResetting(false), 0);
},
applicationId: id,
channelId: null,
guildId: null,
activityUrl: null,
currentEmbeddedActivity: null,
activitySessionId: null,
queryParams: null,
onLoadError: null,
allowPopups: null,
referrerPolicy: "origin",
isPipOrGridMode: null,
webViewKey: null,
safeAreasConfig: null,
ignoreSilentHardwareSwitch: null
2026-07-20 16:05:17 +00:00
};
let id2;
2026-07-29 08:29:29 +00:00
if (channel != null) {
id2 = channel.id;
2026-07-20 16:05:17 +00:00
}
obj7.channelId = id2;
2026-07-20 16:05:17 +00:00
let guild_id3;
2026-07-29 08:29:29 +00:00
if (channel != null) {
2026-07-20 16:05:17 +00:00
guild_id3 = channel.guild_id;
}
obj7.guildId = guild_id3;
obj7.activityUrl = currentEmbeddedActivity.url;
obj7.currentEmbeddedActivity = currentEmbeddedActivity;
2026-07-20 16:05:17 +00:00
let compositeInstanceId;
2026-07-29 08:29:29 +00:00
if (currentEmbeddedActivity != null) {
2026-07-20 16:05:17 +00:00
compositeInstanceId = currentEmbeddedActivity.compositeInstanceId;
}
obj7.activitySessionId = compositeInstanceId;
obj7.queryParams = obj3;
obj7.onLoadError = callback;
const tmp29 = BaseActivityView;
const tmp2Result = tmp2(9809);
obj7.allowPopups = tmp5(9817).allowPopups(tmp4);
obj7.isPipOrGridMode = layoutMode === constants.PIP || layoutMode === constants.GRID;
obj7.webViewKey = tmp5(9655).EMBEDDED_ACTIVITY_WEB_VIEW_KEY;
2026-08-24 06:08:38 +00:00
if (tmp26) {
2026-07-20 16:05:17 +00:00
landscapeSafeAreasConfig = portraitSafeAreasConfig.landscapeSafeAreasConfig;
}
obj7.safeAreasConfig = landscapeSafeAreasConfig;
obj7.ignoreSilentHardwareSwitch = !set.has(id);
obj6.children = closure_13(tmp2Result, obj7);
tmp28Result = tmp28(tmp29, obj6);
const tmp5Result2 = tmp5(9817);
2026-07-20 16:05:17 +00:00
}
}
2026-08-24 06:08:38 +00:00
return tmp28Result;
2026-07-20 16:05:17 +00:00
});
let size = fn(2);
const result = size.fileFinishedImporting("modules/activities/native/EmbeddedActivityView.tsx");
2026-07-20 16:05:17 +00:00
export default memoResult;
export { useBaseActivityView };
export { ActivityViewLoadingIndicator };
export { BaseActivityView };
export const EmbeddedActivityView = memoResult;