app
The app object provides methods to control the Novadesk application: reloading scripts, exiting, logging control, and querying version info.
app is exported from the novadesk module.
import { app } from 'novadesk';Note
Available only in the Main script.
Table of Contents
Lifecycle
app.reload()/app.refresh()
Reloads all active widget scripts.
Example
app.reload();
app.refresh();app.exit()
Exits the Novadesk application.
Example
app.exit();app.requestSingleInstanceLock()
Requests ownership of the single-instance lock.
Return Value
- Type:
boolean - Description:
trueif the lock was acquired, otherwisefalse.
Example
const hasLock = app.requestSingleInstanceLock();
console.log("Single instance lock:", hasLock);app.releaseSingleInstanceLock()
Releases the single-instance lock.
Return Value
- Type:
boolean - Description: Returns
trueafter release is requested.
Example
app.releaseSingleInstanceLock();app.isFirstRun()
Description: Returns true on the first launch when the settings file is missing or empty. Returns false on normal subsequent launches.
Example
// Check whether this is the first run
const isFirstRun = app.isFirstRun();
console.log("Is First Run: " + isFirstRun);Settings
app.saveLogToFile(bool)
Enables or disables logging to a file (logs.log) in the application's AppData directory.
Parameters
bool- Type:
boolean - Description:
trueto enable file logging,falseto disable.
- Type:
Example
// Enable logging to file
app.saveLogToFile(true);app.enableDebugging(bool)
Sets the global log level. When enabled, debug-level messages will be visible in the console and log file.
Parameters
bool- Type:
boolean - Description:
trueto enable debug logging,falseto use standard informational logging.
- Type:
Example
app.enableDebugging(true);
console.debug("Detailed diagnostic information");app.disableLogging(bool)
Completely disables or enables all logging output (both console and file).
Parameters
bool- Type:
boolean - Description:
trueto silence all logs,falseto resume logging based on other settings.
- Type:
Example
// Silence all output for production
app.disableLogging(true);app.useHardwareAcceleration(bool)
Enables or disables Direct2D hardware acceleration.
Parameters
bool- Type:
boolean - Description:
trueto use hardware-accelerated rendering (Default),falseto use software rendering.
- Type:
Note
Changing this setting requires an application restart to take effect.
Example
// Enable hardware acceleration
app.useHardwareAcceleration(true);Utils
app.isPortable()
Description: Returns true when Novadesk is running in portable mode, otherwise false.
Note
Portable mode is detected at runtime based on the executable location and whether Novadesk can write in that directory.
Example
// Check whether Novadesk is running in portable mode
const isPortable = app.isPortable();
console.log("Is Portable: " + isPortable);app.getProductVersion()
Returns the product version from the executable metadata.
Return Value
- Type:
string
Note
Standalone widget applications built with nwm report the version from meta.json.
Example
console.log("Product version:", app.getProductVersion());app.getFileVersion()
Returns the file version from the executable metadata.
Return Value
- Type:
string
Note
Standalone widget applications built with nwm report the value from meta.json.
Example
console.log("File version:", app.getFileVersion());app.getNovadeskVersion()
Returns the hardcoded Novadesk engine version. This value is constant regardless of nwm packaging.
Return Value
- Type:
string
Example
console.log("Novadesk version:", app.getNovadeskVersion());app.getAppDataPath()
Description: Returns the absolute path to the Novadesk AppData directory (%APPDATA%\Novadesk\). This directory is used for storing persistent settings, logs, and configuration.
Example
// Get the path to Novadesk AppData
const appData = app.getAppDataPath();
console.log("AppData Path: " + appData);app.getSettingsFilePath()
Description: Returns the absolute path to the settings.json file.
Example
// Get the settings file path
const settingsPath = app.getSettingsFilePath();
console.log("Settings Path: " + settingsPath);app.getLogPath()
Description: Returns the absolute path to the current log file (logs.log).
Example
// Get the log file path
const logPath = app.getLogPath();
console.log("Log Path: " + logPath);