app
Control the Novadesk runtime, manage settings and logging preferences, query paths, and persist widget state across sessions.
import { app } from 'novadesk';Availability
Available in the Main script only.
Table of Contents
Lifecycle
Reloads all active widget scripts. Equivalent to app.refresh().
app.reload();Alias of app.reload(). Reloads all active widget scripts.
app.refresh();Exits the Novadesk application gracefully.
app.exit();Attempts to acquire the global single-instance mutex. Returns true on success. If another Novadesk instance already holds the lock, returns false. Use this when building standalone launcher widgets that should only run once.
boolean true if the single-instance lock was acquired, false if another instance already holds it.const hasLock = app.requestSingleInstanceLock();
if (!hasLock) {
console.log("Another instance is already running");
app.exit();
}Releases the single-instance lock acquired by app.requestSingleInstanceLock().
boolean Always returns true.app.releaseSingleInstanceLock();Returns whether this is the first time Novadesk has been launched. Useful for showing onboarding UI or setting initial defaults.
boolean true on the first launch when no settings file exists, false on subsequent launches.if (app.isFirstRun()) {
console.log("Welcome! Running for the first time.");
app.storage.set("ui.theme", "dark");
}Settings and Logging
For a full explanation of how these settings interact, see the Logging page.
Sets the global log level. When true, console.debug() output becomes visible in the log and console. Persisted to settings.json.
PARAMETERS
app.enableDebugging(true);
console.debug("Diagnostic info now visible");Completely suppresses all logging output when true. Both console and file output are stopped. Persisted to settings.json.
PARAMETERS
app.disableLogging(true); // silence everything in productionEnables or disables persistent log file output. When true, logs are appended to logs.log in the AppData directory. Persisted to settings.json.
PARAMETERS
app.saveLogToFile(true);
console.log("Log path:", app.getLogPath());Enables or disables Direct2D hardware acceleration. Persisted to settings.json.
Requires restart
This setting is saved immediately but only takes effect after restarting Novadesk.
PARAMETERS
app.useHardwareAcceleration(false); // switch to software renderingPaths and Version
Returns the path to the Novadesk AppData folder used for settings, logs, and storage. In portable mode this is the executable directory. Otherwise it is %APPDATA%\Novadesk\.
string Absolute path to the Novadesk AppData directory, ending with a path separator.console.log(app.getAppDataPath());
// "C:/Users/Me/AppData/Roaming/Novadesk/"Returns the full path to the Novadesk settings file.
string Absolute path to the active settings.json file.console.log(app.getSettingsFilePath());Returns the path to the current log file. Only non-empty when app.saveLogToFile(true) has been called or the saveLogToFile setting is enabled.
string Absolute path to logs.log if file logging is enabled, or an empty string if it is not.const logPath = app.getLogPath();
if (logPath) {
console.log("Logging to:", logPath);
}Returns whether Novadesk is running in portable mode. Portable mode is detected at runtime based on whether the executable directory is writable and is not a system directory.
boolean true when running in portable mode, false otherwise.if (app.isPortable()) {
console.log("Portable mode — data stored next to the exe");
}Returns the product version. For widgets packaged with nwm, this reports the version from meta.json.
string The product version string from the executable's version resources.console.log("Version:", app.getProductVersion()); // e.g. "1.2.0.0"Returns the file version from the executable. For nwm-packaged widgets, this reports the value from meta.json.
string The file version string from the executable's version resources.console.log("File version:", app.getFileVersion());Returns the Novadesk engine version. This is always the engine version, even inside nwm-packaged widgets where getProductVersion() would return the widget's own version.
string The hardcoded Novadesk engine version string.console.log("Engine:", app.getNovadeskVersion()); // e.g. "0.9.9.0"Storage
app.storage is a simple persistent key/value store. Values are JSON-serialized and saved to storage.json in the AppData directory. Keys are strings; values can be any JSON-serializable type.
Read-modify-write on every call
Each set and remove call reads the full storage.json file, applies the change in memory, and writes the entire file back. For high-frequency updates, batch changes or use the fs module to manage your own storage file.
Reads a value from persistent storage. Loads the storage file fresh on every call.
PARAMETERS
any The stored value if the key exists, otherwise defaultValue or undefined.const theme = app.storage.get("ui.theme", "dark");
const count = app.storage.get("session.count", 0);
const profile = app.storage.get("profile"); // undefined if not setWrites a value to persistent storage. Creates the storage file if it does not exist.
PARAMETERS
boolean true if the value was saved successfully, false if the file could not be written.app.storage.set("ui.theme", "dark");
app.storage.set("profile", { name: "Alice", pro: true });
app.storage.set("session.count", 42);Deletes a key from persistent storage.
PARAMETERS
boolean true if the key existed and was removed and the file was saved successfully. false if the key was not found or the file could not be written.const removed = app.storage.remove("session.count");
if (!removed) {
console.log("Key did not exist");
}