Skip to content

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.

javascript
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

javascript
app.reload();
app.refresh();

app.exit()

Exits the Novadesk application.

Example

javascript
app.exit();

app.requestSingleInstanceLock()

Requests ownership of the single-instance lock.

Return Value

  • Type: boolean
  • Description: true if the lock was acquired, otherwise false.

Example

javascript
const hasLock = app.requestSingleInstanceLock();
console.log("Single instance lock:", hasLock);

app.releaseSingleInstanceLock()

Releases the single-instance lock.

Return Value

  • Type: boolean
  • Description: Returns true after release is requested.

Example

javascript
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

javascript
// 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: true to enable file logging, false to disable.

Example

javascript
// 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: true to enable debug logging, false to use standard informational logging.

Example

javascript
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: true to silence all logs, false to resume logging based on other settings.

Example

javascript
// Silence all output for production
app.disableLogging(true);

app.useHardwareAcceleration(bool)

Enables or disables Direct2D hardware acceleration.

Parameters

  • bool
    • Type: boolean
    • Description: true to use hardware-accelerated rendering (Default), false to use software rendering.

Note

Changing this setting requires an application restart to take effect.

Example

javascript
// 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

javascript
// 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

javascript
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

javascript
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

javascript
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

javascript
// 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

javascript
// 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

javascript
// Get the log file path
const logPath = app.getLogPath();
console.log("Log Path: " + logPath);