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

222 lines
7.4 KiB
TypeScript
Raw Normal View History

2026-08-05 07:35:12 +00:00
// Module ID: 10488
// Function ID: 10489
2026-07-29 08:29:29 +00:00
// Name: postMessageToWebView
2026-08-05 07:35:12 +00:00
// Dependencies: [5, 17, 10478, 676, 4280, 7703, 501, 10489, 10490, 1208, 10491, 10511, 4594, 1236, 1351, 10482, 709, 1231, 514, 2]
2026-07-20 16:05:17 +00:00
2026-08-05 07:35:12 +00:00
// Module 10488 (postMessageToWebView)
2026-07-29 08:29:29 +00:00
import closure_3 from "WebView";
import map from "map";
2026-07-23 10:11:24 +00:00
import { ComponentActions } from "ME";
2026-07-29 08:29:29 +00:00
import { DISALLOWED_NAVIGATION_ERROR_CLOSE_ACTIVITY as closure_6 } from "items3";
2026-07-23 10:11:24 +00:00
import WebView from "WebView";
2026-07-29 08:29:29 +00:00
import PlatformTypes from "PlatformTypes";
import "prototype";
2026-07-23 10:11:24 +00:00
const 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) => {
let closure_0 = arg0;
let c5 = 0;
let c6 = 0;
let c4 = 0;
return (function*(arg0) {
2026-08-04 21:03:28 +00:00
const table = tmp3;
let c4 = 1;
yield outer1_7.injectJavaScript(outer1_1(outer1_2[8])(closure_0));
if (1 === tmp7) {
c4 = 0;
closure_0 = closure_3;
const obj1 = callback(table[9]);
obj1.captureException(closure_0);
let c6 = 3;
} 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
})();
});
const _postMessageToWebView = tmp;
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()) {
nativeEventEmitter = new require("ComponentDispatcher").NativeEventEmitter(require("enforcing"));
}
class FramesNativeManager extends tmp5 {
_initialize() {
self = this;
self = this;
_initializeResult = super._initialize();
lifecycleSubscription = this.lifecycleSubscription;
if (lifecycleSubscription != null) {
removeResult = lifecycleSubscription.remove();
}
obj = c8;
addListenerResult = undefined;
if (c8 != null) {
str = "onHostDestroy";
addListenerResult = obj.addListener("onHostDestroy", () => {
const connectedFrame = outer1_4.getConnectedFrame();
if (null != connectedFrame) {
const obj = { applicationId: null };
obj[0] = connectedFrame.applicationId;
self.leaveFrame(obj);
}
});
}
self.lifecycleSubscription = addListenerResult;
scriptMessageSubscription = self.scriptMessageSubscription;
if (scriptMessageSubscription != null) {
removeResult1 = scriptMessageSubscription.remove();
}
self.scriptMessageSubscription = getWebViewProxy.addOnMessageListener((data) => {
try {
const _JSON = JSON;
const parsed = JSON.parse(data.data);
const connectedFrame = outer1_4.getConnectedFrame();
if (connectedFrame != null) {
const url = connectedFrame.url;
}
2026-08-04 08:36:32 +00:00
const iframeId = self.iframeId;
2026-08-04 21:03:28 +00:00
let tmp11 = typeof parsed === "object";
if (typeof parsed === "object") {
2026-08-04 08:36:32 +00:00
tmp11 = null != tmp8;
2026-07-29 08:29:29 +00:00
}
2026-08-04 08:36:32 +00:00
if (tmp11) {
tmp11 = null != iframeId;
}
if (tmp11) {
2026-07-29 08:29:29 +00:00
let obj = outer1_1(outer1_2[11]);
2026-08-04 08:36:32 +00:00
obj = { origin: null, iframeId: null };
obj[0] = url;
obj[1] = iframeId;
obj.handleMessage(parsed, obj, outer1_9);
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-07-29 08:29:29 +00:00
if (tmp2.data === outer1_6) {
const connectedFrame1 = outer1_4.getConnectedFrame();
let applicationId;
if (connectedFrame1 != null) {
applicationId = connectedFrame1.applicationId;
}
if (null != applicationId) {
obj = { applicationId: null };
obj[0] = applicationId;
self.leaveFrame(obj);
2026-08-04 08:36:32 +00:00
const obj1 = { body: null, confirmText: null };
2026-07-29 08:29:29 +00:00
const intl = self(outer1_2[13]).intl;
2026-08-04 08:36:32 +00:00
obj1[0] = intl.string(self(outer1_2[13]).t.tYBBWz);
2026-07-29 08:29:29 +00:00
const intl2 = self(outer1_2[13]).intl;
2026-08-04 08:36:32 +00:00
obj1[1] = intl2.string(self(outer1_2[13]).t.BddRzS);
outer1_1(outer1_2[12]).show(obj1);
const obj4 = outer1_1(outer1_2[12]);
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-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const prototype = FramesNativeManager.prototype;
prototype["showRPCDisconnectErrorUI"] = function showRPCDisconnectErrorUI(reason) {
let code;
let message;
({ code, message } = reason);
2026-08-05 07:35:12 +00:00
let obj = importDefault(4594);
2026-07-29 08:29:29 +00:00
obj = { title: null, body: null };
const intl = require(1236) /* getSystemLocale */.intl;
obj[0] = intl.formatToPlainString(require(1236) /* getSystemLocale */.t.hbiAO6, { code });
obj[1] = message;
obj.show(obj);
};
prototype["leaveFrame"] = function leaveFrame(applicationId) {
const self = this;
applicationId = applicationId.applicationId;
this.releaseWebView();
let obj = require(1351) /* isDiscordFrontendDevelopment */;
if (obj.isNotNullish(applicationId)) {
obj = { applicationId: null };
obj[0] = applicationId;
self.clearFrameState(obj);
}
};
prototype["clearFrameState"] = function clearFrameState(applicationId) {
applicationId = applicationId.applicationId;
2026-08-05 07:35:12 +00:00
importDefault(10482).stopFrame({ applicationId });
const obj = importDefault(10482);
2026-07-29 08:29:29 +00:00
importDefault(709).dispatch({ type: "FRAME_SET_ORIENTATION_LOCK_STATE", applicationId, lockState: null, pictureInPictureLockState: null });
};
prototype["releaseWebView"] = function releaseWebView() {
2026-08-04 08:36:32 +00:00
const releaseIframeIdResult = this.releaseIframeId();
if (null != releaseIframeIdResult) {
2026-07-29 08:29:29 +00:00
const ComponentDispatch = require(1231) /* ComponentDispatcher */.ComponentDispatch;
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);
closure_7.releaseWebView();
}
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 {
const v4Result = require(514) /* 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();
const result = require("map").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";