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

353 lines
17 KiB
TypeScript

/* Metro module 4669; source: modules/native_permissions/mobile/NativePermissionUtils.native.tsx; dependencies: [6, 7, 15, 17, 18, 5, 31, 27, 4661, 33, 477, 1581, 3, 4670, 4672, 1962, 4497, 1244, 4666, 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 * 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 ReactModule from '../../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as JsxRuntimeModule from '../../../by-id/module-00033-JsxRuntime.js'; /* Metro dependency 33 */
import * as IndexNativeModule from '../../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as UseAlertStoreNativeModule from '../../../design/components/AlertModal/native/useAlertStore.native.tsx'; /* Metro dependency 4497 */
import * as NativePermissionBaseUtilsModule from '../NativePermissionBaseUtils.tsx'; /* Metro dependency 4666 */
function _fun40418(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#40418, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:6, offset: 0x010fff85, size: 954 bytes, params: 8, frame: 26
var r15;
var requestCameraAuthorization;
var requestAvatarCameraAuthorization;
const env0_0 = require;
const _arrayLikeToArray_40421 = 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 combineStatuses = function() {
return _combineStatuses.apply(this, arguments);
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = ReactNativeModule;
const NativeModules = value.NativeModules;
const Platform = value.Platform;
value = require(4661) /* metro dependency 4661: NativePermissionConstants */;
const NativePermissionTypes = value.NativePermissionTypes;
const env0_11 = value.NativePermissionStatus;
value = Reflect.apply((require(477) /* metro dependency 477: PlatformUtils */).isAndroid, value, []);
let r1 = value && Platform.constants.Version <= 28;
value = require(1581) /* metro dependency 1581: MetaQuestUtilsAndroid */;
value = value.isMetaQuest();
let r12 = r1 ? [NativeModules.NativePermissionManager.requestExternalStorageAuthorization] : [];
object = [];
let value2 = arraySpread(object, r12, 0, r15);
let NativePermissionManager = NativeModules.NativePermissionManager;
if (value) {
requestAvatarCameraAuthorization = NativePermissionManager.requestAvatarCameraAuthorization;
r12 = [requestAvatarCameraAuthorization];
r15 = requestAvatarCameraAuthorization;
} else {
requestCameraAuthorization = NativePermissionManager.requestCameraAuthorization;
r12 = [requestCameraAuthorization];
r15 = requestCameraAuthorization;
}
arraySpread(object, r12, value2, r15);
const r9 = r1 ? [NativeModules.NativePermissionManager.hasExternalStorageAuthorization] : [];
object = [];
let value3 = arraySpread(object, r9, 0, r15);
NativePermissionManager = NativeModules.NativePermissionManager;
arraySpread(object,
value ? [NativePermissionManager.hasAvatarCameraAuthorization] : [NativePermissionManager.hasCameraAuthorization],
value3, r15);
const NativePermissionBaseUtils = (NativePermissionBaseUtilsModule).NativePermissionBaseUtils;
value = _fun40429(NativePermissionBaseUtils);
object = {};
let CAMERA = NativePermissionTypes.CAMERA;
object[CAMERA] = _fun40438;
let HEADSET_CAMERA = NativePermissionTypes.HEADSET_CAMERA;
NativePermissionManager = NativeModules.NativePermissionManager;
object[HEADSET_CAMERA] = NativePermissionManager.requestHeadsetCameraAuthorization;
let AUDIO = NativePermissionTypes.AUDIO;
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
object[AUDIO] = platformUtilsModule.isAndroid() ? function() {
return combineStatuses([NativeModules.NativePermissionManager.requestMicrophoneAuthorization,
NativeModules.NativePermissionManager.requestModifyAudioAuthorization]);
} : NativeModules.NativePermissionManager.requestMicrophoneAuthorization;
const PHOTOS = NativePermissionTypes.PHOTOS;
NativePermissionManager = NativeModules.NativePermissionManager;
object[PHOTOS] = NativePermissionManager.requestPhotoAuthorization;
const CONTACTS = NativePermissionTypes.CONTACTS;
NativePermissionManager = NativeModules.NativePermissionManager;
object[CONTACTS] = NativePermissionManager.requestContactsAuthorization;
let INPUT_MONITORING = NativePermissionTypes.INPUT_MONITORING;
object[INPUT_MONITORING] = function() {
var Promise = global.Promise;
return Promise.resolve(NativePermissionStatus.AUTHORIZED);
};
value.requestPermissionLookup = object;
object = {};
CAMERA = NativePermissionTypes.CAMERA;
object[CAMERA] = _fun40441;
HEADSET_CAMERA = NativePermissionTypes.HEADSET_CAMERA;
NativePermissionManager = NativeModules.NativePermissionManager;
object[HEADSET_CAMERA] = NativePermissionManager.hasHeadsetCameraAuthorization;
AUDIO = NativePermissionTypes.AUDIO;
let value5 = platformUtilsModule;
object[AUDIO] = value5.isAndroid() ? function() {
return combineStatuses([NativeModules.NativePermissionManager.hasMicrophoneAuthorization,
NativeModules.NativePermissionManager.hasModifyAudioAuthorization]);
} : NativeModules.NativePermissionManager.hasMicrophoneAuthorization;
INPUT_MONITORING = NativePermissionTypes.INPUT_MONITORING;
object[INPUT_MONITORING] = function() {
var Promise = global.Promise;
return Promise.resolve(NativePermissionStatus.AUTHORIZED);
};
value.hasPermissionLookup = object;
value = new value();
(FileImportTrackerModule).fileFinishedImporting('modules/native_permissions/mobile/NativePermissionUtils.native.tsx');
exports.default = value;
function _createForOfIteratorHelperLoose_40419(a0, a1) { // fn#40419, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:292, offset: 0x0110033f, size: 370 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 _fun40420;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_40421(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_40421(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_40421(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun40420;
}
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 _fun40420() { // fn#40420, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:863, 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 _isNativeReflectConstruct_40422() { // fn#40422, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:1202, offset: 0x011004b1, 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_40422_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _combineStatuses() { // fn#40426, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:1468, offset: 0x0110050f, size: 48 bytes, params: 1, frame: 14
return Module00005(_fun40428).apply(this, arguments);
function* _fun40428(a0) { // fn#40428, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:1523, offset: 0x01100548, size: 111 bytes, params: 2, frame: 16
var r4;
var value5;
var value6;
var value7;
var AUTHORIZED;
var value8;
if (false) {
return undefined;
}
value = environment.__proto__.__proto__;
const value3 = env2_15(a0);
const value4 = value3();
let done = value4.done;
if (!done) {
r4 = value4;
reducibleLoop2: while (true) {
value5 = r4.value;
yield value5();
value6 = undefined;
value7 = false;
if (value7) {
return value6;
}
AUTHORIZED = env2_11.AUTHORIZED;
if (value6 !== AUTHORIZED) {
return value6;
}
value8 = value3();
done = value8.done;
if (done) {
return env2_11.AUTHORIZED;
}
r4 = value8;
continue reducibleLoop2;
}
}
return env2_11.AUTHORIZED;
}
}
function _fun40429(a0) { // fn#40429, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:2163, offset: 0x011005b7, size: 189 bytes, params: 2, frame: 16
const NativePermissionIOSUtils2 = NativePermissionIOSUtils;
Inherits(NativePermissionIOSUtils2, a0);
return CreateClass(NativePermissionIOSUtils2, [{key: 'requestPermissionCore', value: function(a0, a1) {
return this.performRequest(NativePermissionIOSUtils.requestPermissionLookup, a0, a1);
}}, {key: 'hasPermissionCore', value: function(a0, a1) {
return this.performRequest(NativePermissionIOSUtils.hasPermissionLookup, a0, a1);
}}, {key: 'performRequest', value: value_40433}, {key: 'didHavePermission', value: function(a0) {
return this.storage.hasPermission(a0);
}}, {key: 'openSettings', value: function() {
importDefault(dependencyMap[13])();
}}, {key: 'openAlertModal', value: value_40436}]);
function NativePermissionIOSUtils() { // fn#40430, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:2175, offset: 0x01100674, size: 113 bytes, params: 1, frame: 20
const value = environment.__proto__;
env1_3(this, NativePermissionIOSUtils);
const value3 = env1_6(NativePermissionIOSUtils);
return env1_5(this, _isNativeReflectConstruct_40422() ? global.Reflect.construct(value3, arguments,
env1_6(this).constructor) : value3.apply(this, arguments));
}
function value_40433(a0, a1, a2) { // fn#40433, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:2773, offset: 0x0110072f, size: 144 bytes, params: 4, frame: 17
var r0;
var value;
const property = a0[a1];
if (property == null) {
value = environment.__proto__;
value = importDefault(3) /* metro dependency 3: Logger */;
value = new value('NativePermissionUtils');
value.error('Unable to locate permission type ' + a1);
value = global.Promise.resolve(false);
r0 = value;
} else {
r0 = this.requestAuthorization(a1, property, a2);
}
return r0;
}
function value_40436({body, onConfirm}) { // fn#40436, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:3118, offset: 0x011007f7, size: 155 bytes, params: 2, frame: 22
var environment;
const value = environment.__proto__;
const value2 = env1_9.lazy(_fun40437);
const openAlert = UseAlertStoreNativeModule.openAlert;
const intl = (IndexNativeModule).intl;
Reflect.apply(openAlert, UseAlertStoreNativeModule, ['permission-denied',
((Component) => <Component title={intl.string((IndexNativeModule).t.sMFVrS)} body={body} onConfirm={onConfirm} />)(value2)]);
function _fun40437() { // fn#40437, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:3163, offset: 0x01100892, size: 45 bytes, params: 1, frame: 13
const value = environment.__proto__.__proto__;
return require(dependencyMap[15])(dependencyMap[14], dependencyMap.paths);
}
}
}
function _fun40438() { // fn#40438, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:3389, offset: 0x011008bf, size: 20 bytes, params: 1, frame: 11
return combineStatuses(env0_13);
}
function _fun40441() { // fn#40441, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4847:3939, offset: 0x0110092e, size: 20 bytes, params: 1, frame: 11
return combineStatuses(env0_14);
}
}
global.__d(_fun40418, 4669, [6, 7, 15, 17, 18, 5, 31, 27, 4661, 33, 477, 1581, 3, 4670, 4672, 1962, 4497, 1244,
4666,
2]) /* metro module 4669, dependencies: [6, 7, 15, 17, 18, 5, 31, 27, 4661, 33, 477, 1581, 3, 4670, 4672, 1962, 4497, 1244, 4666, 2] */;