decord/source/modules/frames/native/FramesNativeManager.tsx

225 lines
7.6 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 11065
// Function ID: 11066
2026-07-29 08:29:29 +00:00
// Name: postMessageToWebView
2026-08-25 06:04:03 +00:00
// Dependencies: [5, 17, 10677, 10678, 676, 4408, 4282, 7955, 501, 10687, 10688, 1208, 11066, 10820, 4745, 1236, 1370, 709, 1231, 514, 2]
2026-07-20 16:05:17 +00:00
2026-08-25 06:04:03 +00:00
// Module 11065 (postMessageToWebView)
2026-08-24 06:08:38 +00:00
import v1 from "v1" /* 514 */;
import dispatcherDefault from "dispatcher" /* 709 */;
import ComponentDispatcher from "ComponentDispatcher" /* 1231 */;
import getSystemLocale from "getSystemLocale" /* 1236 */;
import isDiscordFrontendDevelopment from "isDiscordFrontendDevelopment" /* 1370 */;
2026-08-25 06:04:03 +00:00
import _modDef4745 from "module_4745" /* 4745 */;
import enforcingDefault from "enforcing" /* 10687 */;
import leaveFrameDefault from "leaveFrame" /* 11066 */;
2026-08-24 06:08:38 +00:00
import closure_3 from "asyncGeneratorStep" /* 5 */;
2026-08-25 06:04:03 +00:00
import closure_4 from "map" /* 10677 */;
import { isLaunched } from "FrameLayoutModes" /* 10678 */;
2026-08-24 06:08:38 +00:00
import { ComponentActions } from "ME" /* 676 */;
2026-08-25 06:04:03 +00:00
import { DISALLOWED_NAVIGATION_ERROR_CLOSE_ACTIVITY as closure_7 } from "items3" /* 4408 */;
import { TransportTypes } from "RPC_SCOPE_CONFIG" /* 4282 */;
import WebView from "WebView" /* 7955 */;
2026-08-24 06:08:38 +00:00
import PlatformTypes from "PlatformTypes" /* 501 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-20 16:05:17 +00:00
function postMessageToWebView() {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = _postMessageToWebView.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
function _postMessageToWebView() {
2026-07-29 08:29:29 +00:00
const self = this;
const tmp = callback((arg0) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
c5 = 0;
c6 = 0;
c4 = 0;
2026-07-29 08:29:29 +00:00
return (function*(arg0) {
2026-08-04 21:03:28 +00:00
const table = tmp3;
2026-08-24 06:08:38 +00:00
c4 = 1;
yield closure_1_9.injectJavaScript(closure_1_1(closure_1_2[10])(closure_0));
2026-08-04 21:03:28 +00:00
if (1 === tmp7) {
c4 = 0;
2026-08-24 06:08:38 +00:00
closure_0 = closure_3;
obj1 = callback(table[11]);
2026-08-04 21:03:28 +00:00
obj1.captureException(closure_0);
2026-08-24 06:08:38 +00:00
c6 = 3;
2026-08-04 21:03:28 +00:00
} else if (arg0 === 1) {
2026-07-29 08:29:29 +00:00
c6 = 3;
2026-08-04 21:03:28 +00:00
throw arg1;
} else if (arg0 !== 2) {
c4 = 0;
2026-07-29 08:29:29 +00:00
}
2026-08-04 21:03:28 +00:00
c4 = 0;
return arg1;
2026-07-29 08:29:29 +00:00
})();
});
2026-08-24 06:08:38 +00:00
closure_12 = tmp;
2026-07-29 08:29:29 +00:00
const apply = tmp.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
const webViewProxy = WebView.getWebViewProxy("FRAME_WEB_VIEW_KEY");
2026-07-20 16:05:17 +00:00
let nativeEventEmitter = null;
2026-07-29 08:29:29 +00:00
if (PlatformTypes.isAndroid()) {
2026-08-24 06:08:38 +00:00
nativeEventEmitter = new require("get ActivityIndicator").NativeEventEmitter(enforcingDefault);
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
leaveFrameDefault;
2026-07-29 08:29:29 +00:00
class FramesNativeManager extends tmp5 {
_initialize() {
self = this;
self = this;
_initializeResult = super._initialize();
lifecycleSubscription = this.lifecycleSubscription;
if (lifecycleSubscription != null) {
removeResult = lifecycleSubscription.remove();
}
2026-08-24 06:08:38 +00:00
obj = closure_10;
2026-07-29 08:29:29 +00:00
addListenerResult = undefined;
2026-08-24 06:08:38 +00:00
if (closure_10 != null) {
2026-07-29 08:29:29 +00:00
str = "onHostDestroy";
addListenerResult = obj.addListener("onHostDestroy", () => {
2026-08-06 08:05:19 +00:00
const managedFrame = self.getManagedFrame();
if (null != managedFrame) {
self.leaveFrame(managedFrame.id);
2026-07-29 08:29:29 +00:00
}
});
}
self.lifecycleSubscription = addListenerResult;
scriptMessageSubscription = self.scriptMessageSubscription;
if (scriptMessageSubscription != null) {
removeResult1 = scriptMessageSubscription.remove();
}
2026-08-24 06:08:38 +00:00
self.scriptMessageSubscription = closure_9.addOnMessageListener((data) => {
2026-07-29 08:29:29 +00:00
try {
const _JSON = JSON;
const parsed = JSON.parse(data.data);
2026-08-06 08:05:19 +00:00
const managedFrame = self.getManagedFrame();
let tmp9 = typeof parsed === "object";
2026-08-04 21:03:28 +00:00
if (typeof parsed === "object") {
2026-08-24 06:08:38 +00:00
tmp9 = closure_1_5(managedFrame);
2026-07-29 08:29:29 +00:00
}
2026-08-06 08:05:19 +00:00
if (tmp9) {
tmp9 = null != managedFrame.data.iframeId;
2026-08-04 08:36:32 +00:00
}
2026-08-06 08:05:19 +00:00
if (tmp9) {
2026-08-24 06:08:38 +00:00
let obj = closure_1_1(closure_1_2[13]);
2026-08-06 08:05:19 +00:00
obj = { type: null, origin: null, iframeId: null };
2026-08-24 06:08:38 +00:00
obj[0] = closure_1_8.POST_MESSAGE;
2026-08-06 08:05:19 +00:00
obj[1] = managedFrame.data.url;
obj[2] = managedFrame.data.iframeId;
2026-08-24 06:08:38 +00:00
obj.handleMessage(parsed, obj, closure_1_11);
2026-07-29 08:29:29 +00:00
}
2026-08-04 08:36:32 +00:00
} catch (tmp18) {
2026-07-29 08:29:29 +00:00
const _SyntaxError = SyntaxError;
2026-08-04 08:36:32 +00:00
if (tmp18 instanceof SyntaxError) {
2026-08-24 06:08:38 +00:00
if (tmp2.data === closure_1_7) {
2026-08-06 08:05:19 +00:00
const managedFrame1 = self.getManagedFrame();
if (null != managedFrame1) {
obj3.leaveFrame(managedFrame1.id);
obj = { body: null, confirmText: null };
2026-08-24 06:08:38 +00:00
const intl = self(closure_1_2[15]).intl;
obj[0] = intl.string(self(closure_1_2[15]).t.tYBBWz);
const intl2 = self(closure_1_2[15]).intl;
obj[1] = intl2.string(self(closure_1_2[15]).t.BddRzS);
closure_1_1(closure_1_2[14]).show(obj);
const obj4 = closure_1_1(closure_1_2[14]);
2026-07-29 08:29:29 +00:00
}
2026-08-06 08:05:19 +00:00
obj3 = self;
const tmp23 = self;
2026-07-29 08:29:29 +00:00
}
} else {
2026-08-04 08:36:32 +00:00
throw tmp18;
2026-07-29 08:29:29 +00:00
}
}
});
return;
}
_terminate() {
_terminateResult = super._terminate();
lifecycleSubscription = this.lifecycleSubscription;
if (lifecycleSubscription != null) {
removeResult = lifecycleSubscription.remove();
}
scriptMessageSubscription = this.scriptMessageSubscription;
if (scriptMessageSubscription != null) {
removeResult1 = scriptMessageSubscription.remove();
}
return;
}
2026-08-07 06:50:47 +00:00
leaveFrame(arg0) {
releaseWebViewResult = this.releaseWebView();
tmp2 = closure_2;
obj = require("isDiscordFrontendDevelopment");
if (obj.isNotNullish(global)) {
tmp3 = closure_1;
obj2 = require("dispatcher");
obj = { type: "FRAME_SET_ORIENTATION_LOCK_STATE", frameId: null, lockState: null, pictureInPictureLockState: null };
obj[1] = global;
dispatchResult = obj2.dispatch(obj);
}
leaveFrameResult = super.leaveFrame(global);
return;
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const prototype = FramesNativeManager.prototype;
prototype["showRPCDisconnectErrorUI"] = function showRPCDisconnectErrorUI(reason) {
({ code, message } = reason);
2026-08-25 06:04:03 +00:00
let obj = _modDef4745;
2026-07-29 08:29:29 +00:00
obj = { title: null, body: null };
2026-08-24 06:08:38 +00:00
const intl = getSystemLocale.intl;
obj[0] = intl.formatToPlainString(getSystemLocale.t.hbiAO6, { code });
2026-07-29 08:29:29 +00:00
obj[1] = message;
obj.show(obj);
};
2026-08-06 08:05:19 +00:00
prototype["getManagedFrame"] = function getManagedFrame() {
let frameByIframeId;
if (null != this.iframeId) {
frameByIframeId = frameByIframeId.getFrameByIframeId(tmp.iframeId);
}
return frameByIframeId;
};
2026-07-29 08:29:29 +00:00
prototype["releaseWebView"] = function releaseWebView() {
2026-08-04 08:36:32 +00:00
const releaseIframeIdResult = this.releaseIframeId();
if (null != releaseIframeIdResult) {
2026-08-24 06:08:38 +00:00
const ComponentDispatch = ComponentDispatcher.ComponentDispatch;
2026-07-29 08:29:29 +00:00
const obj = { id: null };
2026-08-04 08:36:32 +00:00
obj[0] = releaseIframeIdResult;
2026-07-29 08:29:29 +00:00
ComponentDispatch.dispatch(ComponentActions.IFRAME_UNMOUNT, obj);
2026-08-06 08:05:19 +00:00
closure_9.releaseWebView();
2026-07-29 08:29:29 +00:00
}
2026-08-04 08:36:32 +00:00
return releaseIframeIdResult;
2026-07-29 08:29:29 +00:00
};
2026-08-04 08:36:32 +00:00
prototype["releaseIframeId"] = function releaseIframeId() {
this.iframeId = undefined;
return this.iframeId;
2026-07-29 08:29:29 +00:00
};
2026-08-04 08:36:32 +00:00
prototype["hasIframeId"] = function hasIframeId() {
return null != this.iframeId;
2026-07-29 08:29:29 +00:00
};
2026-08-04 08:36:32 +00:00
prototype["getOrCreateIframeId"] = function getOrCreateIframeId() {
const iframeId = this.iframeId;
if (null != iframeId) {
return iframeId;
2026-07-29 08:29:29 +00:00
} else {
2026-08-24 06:08:38 +00:00
const v4Result = v1.v4();
2026-08-04 08:36:32 +00:00
tmp.iframeId = v4Result;
2026-07-29 08:29:29 +00:00
return v4Result;
}
};
FramesNativeManager.displayName = "FramesNativeManager";
const framesNativeManager = new FramesNativeManager();
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/frames/native/FramesNativeManager.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default framesNativeManager;
2026-07-20 16:05:17 +00:00
export const FRAME_WEB_VIEW_KEY = "FRAME_WEB_VIEW_KEY";