()
| 97 | document.addEventListener("menubutton", menuButtonHandler); |
| 98 | |
| 99 | async function onDeviceReady() { |
| 100 | await initEncodings(); // important to load encodings before anything else |
| 101 | |
| 102 | const isFreePackage = /(free)$/.test(BuildInfo.packageName); |
| 103 | const oldResolveURL = window.resolveLocalFileSystemURL; |
| 104 | const { |
| 105 | externalCacheDirectory, // |
| 106 | externalDataDirectory, |
| 107 | cacheDirectory, |
| 108 | dataDirectory, |
| 109 | } = cordova.file; |
| 110 | |
| 111 | window.app = document.body; |
| 112 | window.root = tag.get("#root"); |
| 113 | window.addedFolder = addedFolder; |
| 114 | window.editorManager = null; |
| 115 | window.toast = toast; |
| 116 | window.ASSETS_DIRECTORY = Url.join(cordova.file.applicationDirectory, "www"); |
| 117 | window.DATA_STORAGE = externalDataDirectory || dataDirectory; |
| 118 | window.CACHE_STORAGE = externalCacheDirectory || cacheDirectory; |
| 119 | window.PLUGIN_DIR = Url.join(DATA_STORAGE, "plugins"); |
| 120 | window.KEYBINDING_FILE = Url.join(DATA_STORAGE, ".key-bindings.json"); |
| 121 | window.log = logger.log.bind(logger); |
| 122 | |
| 123 | config.HAS_PRO = !isFreePackage; |
| 124 | |
| 125 | // Capture synchronous errors |
| 126 | window.addEventListener("error", (event) => { |
| 127 | const errorMsg = `Error: ${event.message}, Source: ${event.filename}, Line: ${event.lineno}, Column: ${event.colno}, Stack: ${event.error?.stack || "N/A"}`; |
| 128 | window.log("error", errorMsg); |
| 129 | }); |
| 130 | // Capture unhandled promise rejections |
| 131 | window.addEventListener("unhandledrejection", (event) => { |
| 132 | window.log( |
| 133 | "error", |
| 134 | `Unhandled rejection: ${event.reason ? event.reason.message : "Unknown reason"}\nStack: ${event.reason ? event.reason.stack : "No stack available"}`, |
| 135 | ); |
| 136 | }); |
| 137 | |
| 138 | let installSource = INSTALL_SOURCE_PLAY; |
| 139 | |
| 140 | try { |
| 141 | installSource = await helpers.promisify(system.getInstaller); |
| 142 | } catch (error) { |
| 143 | console.error(error); |
| 144 | } |
| 145 | |
| 146 | Object.defineProperty(window, "appInstallSource", { |
| 147 | get() { |
| 148 | return installSource; |
| 149 | }, |
| 150 | set() { |
| 151 | console.warn("appInstallSource is readonly"); |
| 152 | }, |
| 153 | configurable: false, |
| 154 | enumerable: false, |
| 155 | }); |
| 156 |
nothing calls this directly
no test coverage detected