### Install Fedora Dependencies Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/contributing/framework-developer-guide.mdx Install development tools, GTK, WebKitGTK, and build system essentials for Fedora. ```bash sudo dnf install \ @development-tools \ gtk3 \ webkit2gtk3.x86_64 \ webkit2gtk3-devel.x86_64 \ libgtk-3-dev \ libwebkit2gtk-4.1-0 # or libwebkit2gtk-4.0-37 libglib2.0-dev \ libxrandr-dev \ cmake \ ninja-build ``` -------------------------------- ### Install Neutralinojs Client Library Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/getting-started/using-frontend-libraries.md Install the Neutralinojs client library for your frontend project using npm. ```bash cd react-src npm install @neutralinojs/lib ``` -------------------------------- ### Start Local Development Server Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/README.md Starts a local development server for live previewing changes. Changes are reflected live without requiring a server restart. ```bash yarn start ``` -------------------------------- ### Install Client Dependencies Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/contributing/framework-developer-guide.mdx Install the necessary Node.js dependencies for the neutralino.js client using npm. ```bash npm install ``` -------------------------------- ### Install Arch Linux Dependencies Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/contributing/framework-developer-guide.mdx Install GTK, WebKitGTK, CMake, and Ninja for building on Arch Linux. ```bash sudo pacman -S \ gtk3 \ webkit2gtk \ cmake \ ninja ``` -------------------------------- ### Install Node.js LTS Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/README.md Installs and uses the latest Node.js LTS version using nvm. ```bash nvm install nvm use ``` -------------------------------- ### Importing Neutralinojs Library Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/overview.md Demonstrates how to import Neutralinojs namespaces from the `@neutralinojs/lib` NPM module for use in frontend libraries. Shows an example of getting application configuration. ```javascript import { app } from '@neutralinojs/lib'; const conf = await app.getConfig(); // Vanilla Js: await Neutralino.app.getConfig() ``` -------------------------------- ### Install Dependencies Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/README.md Installs project dependencies using Yarn. ```bash yarn install ``` -------------------------------- ### Install Update and Restart App Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/how-to/auto-updater.md Compares the fetched manifest version with the current application version. If an update is available, it installs the update and restarts the application process. ```javascript try { let url = "http://example.com/updater_test/update_manifest.json"; let manifest = await Neutralino.updater.checkForUpdates(url); if(manifest.version != NL_APPVERSION) { await Neutralino.updater.install(); await Neutralino.app.restartProcess(); } } catch(err) { // Handle errors } ``` -------------------------------- ### Install WebKitGTK on Debian Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/contributing/framework-developer-guide.mdx Install the WebKitGTK library, required for rendering web content. Choose the appropriate version for your system. ```bash sudo apt install libwebkit2gtk-4.1-0 # --- or --- sudo apt install libwebkit2gtk-4.0-37 ``` -------------------------------- ### Initialize Neutralinojs and Show Message Box Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/init.md Call `Neutralino.init()` to start the application, followed by native API calls like `Neutralino.os.showMessageBox()`. ```javascript Neutralino.init(); Neutralino.os.showMessageBox('Welcome', 'Hello Neutralinojs'); ``` -------------------------------- ### Example neu run command Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/cli/internal-cli-arguments.md This example shows how the `neu run` command internally translates to specific Neutralinojs CLI arguments on Linux. ```bash ./bin/neutralino-linux_x64 --load-dir-res --path=. --neu-dev-extension --neu-dev-auto-reload ``` -------------------------------- ### Install Debian Dependencies Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/contributing/framework-developer-guide.mdx Install necessary development tools and libraries for building on Debian-based Linux distributions. ```bash sudo apt install libgtk-3-dev cmake ninja-build ``` -------------------------------- ### Get Mount Configurations Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/server.md Retrieves a list of all active directory mount configurations. This is useful for inspecting the current server setup. ```javascript let mounts = await Neutralino.server.getMounts(); console.log('Mounts:', mounts); ``` -------------------------------- ### Install macOS Build Tools Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/contributing/framework-developer-guide.mdx Install CMake and Ninja using Homebrew on macOS. Xcode Command Line Tools are also required. ```bash brew install cmake ninja ``` -------------------------------- ### Install neu CLI Globally Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/cli/neu-cli.md Install the neu CLI globally using npm. This makes the 'neu' command available system-wide. ```bash npm i -g @neutralinojs/neu ``` -------------------------------- ### Example neutralino.config.json for Windows Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/configuration/neutralino.config.json.md This configuration snippet demonstrates how to set Windows-specific metadata like application name, author, description, copyright, and icon. ```json { "applicationId": "cook.pancake.bakery", "version": "1.2.0", "applicationName": "Pancake Bakery", "author": "Sweet Pancakes LLC", "description": "Digital recipe book for pancakes from all over the world", "copyright": "Copyright © Sweet Pancakes LLC 2042. All rights reserved.", "applicationIcon": "buildAssets/appIcon.png", "cli": { "binaryName": "pancakebakery" } } ``` -------------------------------- ### Install neu CLI Globally Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/getting-started/your-first-neutralinojs-app.mdx Installs the Neutralinojs command-line interface globally using npm. This tool simplifies the creation and management of Neutralinojs applications. ```bash npm install -g @neutralinojs/neu ``` -------------------------------- ### Installing jq on macOS Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/distribution/overview.md Install the `jq` utility using Homebrew on macOS. This tool is required for parsing JSON files, often used in build and packaging processes. ```bash # On macOS: brew install jq ``` -------------------------------- ### Run Integration Tests Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/contributing/framework-developer-guide.mdx Execute the full integration test suite from the main codebase directory. Ensure you have installed dependencies first. ```bash cd spec npm install npm run test ``` -------------------------------- ### updater.install Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/updater.md Installs updates based on the previously downloaded update manifest. This function throws an error if no manifest has been loaded or if the installation process fails. ```APIDOC ## updater.install() ### Description Installs updates from the downloaded update manifest. Throws `NE_UP_UPDNOUF` if the manifest isn't loaded. If the update installation process fails, this function will throw `NE_UP_UPDINER`. ### Method POST (implied, as it performs an action) ### Endpoint (Not explicitly defined) ### Parameters None ### Request Example ```js let url = 'https://example.com/updates/manifest.json'; let manifest = await Neutralino.updater.checkForUpdates(url); if(manifest.version != NL_APPVERSION) { await Neutralino.updater.install(); } else { console.log('You are using the latest version!'); } ``` ``` -------------------------------- ### Create React Neutralinojs App with Template Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/getting-started/using-frontend-libraries.md Use the `neu` CLI to quickly create a new Neutralinojs application pre-configured with a React template. This is the recommended approach for starting new projects. ```bash neu create myapp --template codezri/neutralinojs-react cd myapp # Start the React development server with Neutralinojs neu run # Build the React and Neutralinojs app neu build ``` -------------------------------- ### Install missing package for Error Code 127 Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/contributing/frequently-asked-questions.md Use these commands to install the required package if you are using a lower framework version and encounter Error Code 127. Ensure you run these commands with sudo. ```bash apt update apt install -y libayatana-appindicator3-1 ``` -------------------------------- ### Run Neutralinojs Application Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/getting-started/your-first-neutralinojs-app.mdx Starts the Neutralinojs application from the project directory. The application will reload automatically when resource files are changed. ```bash cd myapp neu run ``` -------------------------------- ### Call Custom API Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md Example of how to call a custom backend API exposed through the Neutralinojs framework. ```javascript let res = await Neutralino.custom.fetch('https://neutralino.js.org'); ``` -------------------------------- ### Call Net API Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md Example of calling the built-in net.fetch API, demonstrating a standard network request. ```javascript let res = await Neutralino.net.fetch('https://neutralino.js.org'); ``` -------------------------------- ### Clone Neutralinojs Repository Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/contributing/framework-developer-guide.mdx Clone the main Neutralinojs repository to start contributing. Navigate into the cloned directory. ```bash git clone https://github.com/neutralinojs/neutralinojs.git cd neutralinojs ``` -------------------------------- ### Simulate Keyboard Events with Neutralinojs Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md Simulate keyboard events using `computer.sendKey`. This example shows how to press a single key and a key combination like Ctrl+V on GNU/Linux. Ensure the correct platform-specific key codes are used. ```javascript // Simulate letter 'a' press on GNU/Linux: await Neutralino.computer.sendKey(38) // Simulate Ctrl + V keyboard shortcut on GNU/Linux: await Neutralino.computer.sendKey(105, 'down') // Hold right control await Neutralino.computer.sendKey(55, 'down') // Hold letter 'v' await Neutralino.computer.sendKey(55, 'up') // Release letter 'v' await Neutralino.computer.sendKey(105, 'up') // Release right control ``` -------------------------------- ### Install a neu CLI Plugin Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/cli/neu-cli.md Use this command to add a published npm package as a neu CLI plugin to your project. ```bash neu plugins --add ``` -------------------------------- ### Get OS Information Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/computer.md Fetches detailed operating system information, such as name, description, and version. Helpful for displaying system details to the user. ```javascript let osInfo = await Neutralino.computer.getOSInfo(); console.log(`OS: ${osInfo.name}`); ``` -------------------------------- ### Get Hostname using OS API Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md Retrieve the hostname of the computer using the os.getHostname() function. ```javascript await Neutralino.os.getHostname(); ``` -------------------------------- ### Get Display Information Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/computer.md Fetches and logs information for all connected displays. This is useful for multi-monitor setups or adapting UI to different screen resolutions. ```javascript let displays = await Neutralino.computer.getDisplays(); for(let display of displays) { console.log(display); } ``` -------------------------------- ### Configuring Document Root and URL Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/configuration/neutralino.config.json.md Demonstrates the correct way to set the document root for the static server and configure the application URL to match. ```json { "documentRoot": "/resources/", "url": "/" } ``` ```json { "documentRoot": "/", "url": "/resources/" } ``` -------------------------------- ### Build with Release Option Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/cli/neu-cli.md Builds the application and creates a portable ZIP file of the application bundle. ```bash neu build --release ``` -------------------------------- ### Install Updates Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/updater.md Installs updates based on a previously downloaded update manifest. This function requires a manifest to be loaded and can throw errors if the manifest is not found or if the installation process fails. It's common to check the manifest version against the current app version before installing. ```javascript let url = 'https://example.com/updates/manifest.json'; let manifest = await Neutralino.updater.checkForUpdates(url); if(manifest.version != NL_APPVERSION) { await Neutralino.updater.install(); } else { console.log('You are using the latest version!'); } ``` -------------------------------- ### Set and Get File Permissions Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md Manage file permissions using `filesystem.setPermissions` and `filesystem.getPermissions`. Permissions can be set for all users or specific groups, and can be added or removed. ```javascript await Neutralino.filesystem.setPermissions(NL_PATH + '/my-directory-1', {ownerRead: true, groupRead: true}); await Neutralino.filesystem.setPermissions(NL_PATH + '/my-directory-2', {all: true}); await Neutralino.filesystem.setPermissions(NL_PATH + '/my-directory-3', {otherAll: true}, 'REMOVE'); const permissions = await Neutralino.filesystem.getPermissions(NL_PATH); // permissions -> {all:.., ownerRead, ownerWrite...} ``` -------------------------------- ### Server API: Get Mounts Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md The `server.getMounts` function retrieves a list of all currently active directory mappings configured for the Neutralinojs static server. ```APIDOC ## server.getMounts ### Description Retrieves a list of all currently active directory mappings. ### Method ``` server.getMounts() ``` ### Response #### Success Response - **mounts** (Array) - A list of active mounts, where each object contains `path` and `target` properties. ### Response Example ```json { "mounts": [ { "path": "/app-res", "target": "/path/to/your/app-res" } ] } ``` ``` -------------------------------- ### Initialize Empty Neutralinojs Project Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/getting-started/using-frontend-libraries.md Create a new, empty Neutralinojs project using the `neutralinojs/neutralinojs-zero` template. This serves as a base for manual integration of frontend frameworks. ```bash neu create myapp --template neutralinojs/neutralinojs-zero ``` -------------------------------- ### Running Neutralinojs with CLI Arguments Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/configuration/neutralino.config.json.md Demonstrates how to launch Neutralinojs applications using command-line arguments for URL and other settings, bypassing the need for a configuration file. ```bash # Loading a remote URL ./framework-bin --url=https://neutralino.js.org/docs # Launches a local static web app ./framework-bin --url="/" --document-root="/resources/" --window-title="My web app" --enable-server --enable-native-api ``` -------------------------------- ### Neutralinojs Native API Permissions Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/getting-started/your-first-neutralinojs-app.mdx Example configuration for `nativeAllowList` in Neutralinojs. This specifies which native OS functions the application's frontend is allowed to call. The default configuration allows the entire 'os' namespace. ```json "nativeAllowList": [ "app.*", "os.*", "debug.log" ], ``` -------------------------------- ### Build with MacOS Bundle Option Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/cli/neu-cli.md Builds the application and creates a minimal MacOS app bundle with the .app extension. ```bash neu build --macos-bundle ``` -------------------------------- ### Spawn Background Process and Handle Events Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/os.md Use `spawnProcess` to start a command in the background and manage it via Neutralino's event system. Listen for 'spawnedProcess' events to handle standard output, standard error, and process exit. ```javascript let pingProc = await Neutralino.os.spawnProcess('ping neutralino.js.org'); Neutralino.events.on('spawnedProcess', (evt) => { if(pingProc.id == evt.detail.id) { switch(evt.detail.action) { case 'stdOut': console.log(evt.detail.data); break; case 'stdErr': console.error(evt.detail.data); break; case 'exit': console.log(`Ping process terminated with exit code: ${evt.detail.data}`); break; } } }); ``` -------------------------------- ### Define Extensions in neutralinojs.config.json Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/how-to/extensions-overview.md Configure extensions by providing a unique ID and platform-specific or cross-platform commands to start them. Path constants like ${NL_PATH} are supported. ```json { "extensions": [ { "id": "js.neutralino.sampleextension", "commandLinux": "${NL_PATH}/extensions/binary/linux/ext_bin", "commandDarwin": "${NL_PATH}/extensions/binary/mac/ext_bin", "commandWindows": "${NL_PATH}/extensions/binary/win/ext_bin.exe" }, { "id": "js.neutralino.binaryextension", "command": "node ${NL_PATH}/extensions/binary/main.js" } ] } ``` -------------------------------- ### Print Version Information Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/cli/neu-cli.md Prints all version information. Shows project-specific details if executed from an application directory, otherwise shows global details. ```bash neu version ``` -------------------------------- ### Initialize Neutralinojs and Show Message Box on Ready Event Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/init.md Initialize the application with `Neutralino.init()` and then use the `ready` event to execute native API calls, ensuring they are made after the application is fully set up. ```javascript Neutralino.init(); Neutralino.events.on('ready', () => { Neutralino.os.showMessageBox('Welcome', 'Hello Neutralinojs'); }); ``` -------------------------------- ### Get File System Stats with Timestamps Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md The `filesystem.getStats` function now exposes `createdAt` and `modifiedAt` as JavaScript timestamps, providing more detailed information about file metadata. ```javascript const stats = await Neutralino.filesystem.getStats({ resource: "path/to/your/file.txt" }); console.log(stats.createdAt, stats.modifiedAt); ``` -------------------------------- ### Create Frontend Project within Neutralinojs App Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/getting-started/using-frontend-libraries.md Generate a new project for your chosen frontend framework (e.g., React) inside the existing Neutralinojs project directory. This example uses `create-react-app` for React. ```bash cd myapp npx create-react-app react-src ``` -------------------------------- ### Get Special Path Names using OS API Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md Retrieve predefined path names like 'home' and 'desktop' using the os.getPath() function. ```javascript await Neutralino.os.getPath('home'); ``` ```javascript await Neutralino.os.getPath('desktop'); ``` -------------------------------- ### Execute Command and Get Output Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/os.md Use `execCommand` to run a command and retrieve its standard output, standard error, and exit code. This is useful for checking tool versions or running simple scripts. ```javascript let info = await Neutralino.os.execCommand('python --version'); console.log(`Your Python version: ${info.stdOut}`); ``` -------------------------------- ### Build with Custom Config File Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/cli/neu-cli.md Builds the application using a custom app configuration file specifically for the packaging process. ```bash neu build --config-file= ``` -------------------------------- ### Get List of Spawned Processes Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md Retrieve a list of all currently spawned processes using `os.getSpawnedProcesses`. This can be useful for monitoring or managing active child processes. ```javascript Neutralino.os.getSpawnedProcesses(); ``` -------------------------------- ### Resources API: Get Stats Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md The `resources.getStats` function provides file system statistics for a given path, similar to `fs.stat` but operating within the Neutralinojs resource context. ```APIDOC ## resources.getStats ### Description Gets file system statistics for a given path. ### Method ``` resources.getStats(path: string) ``` ### Parameters #### Path Parameters - **path** (string) - Required - The path to the file or directory for which to get stats. ### Response #### Success Response - **stats** (Object) - An object containing file system statistics (e.g., size, modification time). ### Response Example ```json { "stats": { "size": 1024, "mtime": 1678886400000 } } ``` ``` -------------------------------- ### Get Network Interface Details using OS API Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md Retrieve detailed information about network interfaces, including IP, MAC, and type, using os.getNetworkInterfaces(). ```javascript await Neutralino.os.getNetworkInterfaces(); ``` -------------------------------- ### Build Windows Application Bundle Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/distribution/overview.md Run this command to generate a new application bundle for Windows. The build is created in the ./dist folder. You can optionally run install-icon.cmd to set the app icon. ```bash ./build-win.sh ``` -------------------------------- ### Build Linux Application Bundle Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/distribution/overview.md Run this script to generate a new application bundle for GNU/Linux. All build targets are created in the `./dist` folder. ```bash ./build-linux.sh ``` -------------------------------- ### Create Directory with Neutralino.filesystem Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/filesystem.md Use this method to create a new directory. It supports creating nested directories recursively. Ensure the path is valid to avoid errors. ```javascript await Neutralino.filesystem.createDirectory('./newDirectory'); ``` ```javascript await Neutralino.filesystem.createDirectory(NL_PATH + '/myFolder/api/fs'); ``` -------------------------------- ### computer.getMousePosition() Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/computer.md Gets the current position of the mouse cursor on the screen. ```APIDOC ## computer.getMousePosition() ### Description Returns the current mouse cursor position. ### Return Object (awaited): - `x` Number: Distance from the left edge of the screen in pixels. - `y` Number: Distance from the top edge of the screen in pixels. ### Request Example ```js let pos = await Neutralino.computer.getMousePosition(); console.log(`Pos: ${pos.x}, ${pos.y}`); ``` ``` -------------------------------- ### Add yarn global bin to PATH Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/contributing/frequently-asked-questions.md If `yarn global add @neutralinojs/neu` does not complete the installation process and neu commands are not recognized, add this export command to your shell's initialization script (e.g., .bashrc). This ensures that globally installed yarn binaries are accessible. ```bash export PATH="$(yarn global bin):$PATH" ``` -------------------------------- ### Build with Copy Storage Option Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/cli/neu-cli.md Builds the application and copies the current snapshot of the Neutralinojs storage to the application bundle. ```bash neu build --copy-storage ``` -------------------------------- ### Get Window Title Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/window.md Retrieves the current title of the native window instance. ```javascript let title = await Neutralino.window.getTitle(); console.log(`title = ${title}`); ``` -------------------------------- ### Neutralino.init() Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/init.md Initializes the Neutralinojs application. This function should be called once in your application's main JavaScript file before invoking any native API calls. It sets up the necessary connection to the Neutralinojs server and prepares the environment for native API interactions. ```APIDOC ## Neutralino.init() ### Description Initializes the Neutralinojs application. This function should be called once in your application's main JavaScript file before invoking any native API calls. It sets up the necessary connection to the Neutralinojs server and prepares the environment for native API interactions. ### Method JavaScript Function Call ### Parameters This function does not accept any parameters. ### Usage Example ```javascript Neutralino.init(); // Subsequent native API calls can be made after initialization Neutralino.os.showMessageBox('Welcome', 'Hello Neutralinojs'); ``` ### Notes - The `init` function establishes an asynchronous WebSocket connection to the Neutralinojs server. - It registers an auto-reload event handler if the `--neu-dev-auto-reload` flag is active (typically set by the `neu run` command). - It defines `NL_CVERSION` in the `window` scope, indicating the client library version. - Native API calls made immediately after `init` might be queued until the WebSocket connection is established. For guaranteed execution after connection, consider using the `ready` event. ``` -------------------------------- ### Get Hostname Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/computer.md Retrieves the system's hostname. This is useful for identifying the machine on a network. ```javascript let hostname = await Neutralino.computer.getHostname(); console.log(hostname); ``` -------------------------------- ### computer.getOSInfo() Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/computer.md Returns operating system information, including name, description, and version. ```APIDOC ## computer.getOSInfo() ### Description Returns operating system information. ### Return Object (awaited): - `name` String: Operating system name. - `description` String: Operating system description. - `version` String: Version in the `..-` format. ### Example ```js let osInfo = await Neutralino.computer.getOSInfo(); console.log(`OS: ${osInfo.name}`); ``` ``` -------------------------------- ### Create Filesystem Watcher Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/filesystem.md Sets up a watcher for a specific directory to monitor file changes. If a watcher already exists for the path, its ID is returned. Event listeners should be set up to receive 'watchFile' events. ```javascript let watcherId = await Neutralino.filesystem.createWatcher(NL_PATH); Neutralino.events.on('watchFile', (evt) => { if(watcherId == evt.detail.id) { console.log(evt.detail); } }); console.log(`ID: ${watcherId}`); ``` -------------------------------- ### Get File Permissions Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/filesystem.md Retrieves file permissions for a given path. Ensure the path exists and is accessible. ```javascript const permissions = await Neutralino.filesystem.getPermissions(NL_PATH + '/my-directory-1'); ``` -------------------------------- ### Configure Frontend Library Development Commands Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/getting-started/using-frontend-libraries.md Configure frontend-library-specific development commands, including project path, initialization, development, and build commands, for seamless integration with neu CLI. ```json "cli": { // ---"other options "frontendLibrary": { "patchFile": "/react-src/public/index.html", "devUrl": "http://localhost:3000", "projectPath": "/react-src/", "initCommand": "npm install", "devCommand": "BROWSER=none npm start", "buildCommand": "npm run build" } } ``` -------------------------------- ### Get All Environment Variables - JavaScript Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/os.md Fetches all environment variables and their corresponding values as a key-value pair object. ```javascript let envs = await Neutralino.os.getEnvs(); console.log(envs); ``` -------------------------------- ### Get Mouse Position Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/computer.md Captures and logs the current X and Y coordinates of the mouse cursor relative to the screen. ```javascript let pos = await Neutralino.computer.getMousePosition(); console.log(`Pos: ${pos.x}, ${pos.y}`); ``` -------------------------------- ### Get Window Position Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/window.md Retrieves the current X and Y coordinates of the window's top-left corner on the screen. ```javascript let position = await Neutralino.window.getPosition(); console.log(position); ``` -------------------------------- ### Build Frontend Application Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/getting-started/using-frontend-libraries.md Execute the build command for your frontend framework to generate the production-ready static assets. For React, this is typically `npm run build` within the frontend project directory. ```bash cd react-src npm run build ``` -------------------------------- ### Get Window Size Information Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/window.md Retrieves the current dimensions, minimum/maximum constraints, and resizable status of the window. ```javascript let sizeInfo = await Neutralino.window.getSize(); console.log(sizeInfo); ``` -------------------------------- ### Create a New Neutralinojs App Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/getting-started/your-first-neutralinojs-app.mdx Scaffolds a new Neutralinojs application project. This command initializes the project structure and necessary files for a new app. ```bash neu create myapp ``` -------------------------------- ### Get CPU Information Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/computer.md Retrieves and logs the CPU model. Ensure the Neutralino API is initialized before calling this function. ```javascript let cpuInfo = await Neutralino.computer.getCPUInfo(); console.log(`CPU model: ${cpuInfo.model}`); ``` -------------------------------- ### Neutralino.window.create Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/window.md Creates a new application window with specified options. It can be configured with properties like title, icon, size, and behavior flags. The function returns a promise that resolves with information about the created process. ```APIDOC ## Neutralino.window.create ### Description Creates a new application window with specified options. It can be configured with properties like title, icon, size, and behavior flags. The function returns a promise that resolves with information about the created process. ### Parameters - `url` String: The URL of the HTML file to load in the new window. - `options` WindowOptions: An object containing various configuration options for the window. #### WindowOptions - `title` String: Window title. - `icon` String: Window icon path. - `fullScreen` Boolean: Sets full screen mode. - `alwaysOnTop` Boolean: Activates the top-most mode. - `enableInspector` Boolean: Activates developer tools and opens the web inspector window. - `borderless` Boolean: Makes the window borderless. - `maximize` Boolean: Launches the window maximized. - `hidden` Boolean: Hides the window. - `maximizable` Boolean: Makes the window maximizable or not. - `exitProcessOnClose` Boolean: Exits the application process when the user clicks the window's close button. - `width` Number: Window width. - `height` Number: Window height. - `x` Number: Window `x` position. - `y` Number: Window `y` position. - `minWidth` Number: Minimum width of the window. - `minHeight` Number: Minimum height of the window. - `maxWidth` Number: Maximum width of the window. - `maxHeight` Number: Maximum height of the window. - `extendUserAgentWith` String: Extends the user agent string of the webview instance. - `injectGlobals` Boolean: Injects global variables directly to the webview instance. - `injectClientLibrary` Boolean: Injects the client library source directly to the webview instance. - `injectScript` Boolean: A preload JavaScript source file that executes before web app resources. - `processArgs` String: Additional command-line arguments for the new window process. ### Return Object (awaited) - `pid` Number: Process identifier. - `stdOut` String: Standard output. This value is always empty since the new window process starts asynchronously. - `stdErr` String: Standard error. This value is always empty since the new window process starts asynchronously. - `exitCode` Number: Exit code of the process. ### Request Example ```js await Neutralino.window.create('/resources/aboutWindow.html', { icon: '/resources/icons/aboutIcon.png', enableInspector: false, width: 500, height: 300, maximizable: false, exitProcessOnClose: true, processArgs: '--window-id=W_ABOUT' }); ``` ``` -------------------------------- ### resources API - getStats and extractDirectory Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/client-library.md Export `resources.getStats()` to get statistics about resources and `resources.extractDirectory()` to extract a directory from resources. ```APIDOC ## API: resources ### `resources.getStats(path)` Returns statistics about a specified resource. ### `resources.extractDirectory(directoryPath, destinationPath)` Extracts an entire directory from the application's resources to a specified destination. ``` -------------------------------- ### Show Window Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/window.md Makes the native window visible. ```javascript await Neutralino.window.show(); ``` -------------------------------- ### Configure Extension Binary Path with Path Constants Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md Use extended path constants like `${NL_OSDOWNLOADSPATH}` to specify paths for extension binaries, especially on Linux. ```json "commandLinux": "${NL_OSDOWNLOADSPATH}/extensionBinary --load" ``` -------------------------------- ### Read Text File with Neutralinojs Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/filesystem.md Reads the content of a text file. Optionally specify the starting position and size for reading. ```javascript let data = await Neutralino.filesystem.readFile('./myFile.txt'); console.log(`Content: ${data}`); ``` ```javascript let data = await Neutralino.filesystem.readFile('./myFile.txt', { pos: 2, size: 10 }); console.log(`Content: ${data}`); ``` -------------------------------- ### Get Environment Variable - JavaScript Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/os.md Retrieves the value of a specific environment variable. Returns an empty string if the variable is not found. ```javascript let value = await Neutralino.os.getEnv('USER'); console.log(`USER = ${value}`); ``` -------------------------------- ### Configuring Native API Permissions Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/overview.md Illustrates how to configure permissions for native API calls using `nativeAllowList` and `nativeBlockList` in the application configuration file. ```json { "nativeAllowList": [ "app.*", "window.*", "os.execCommand" ], "nativeBlockList": [ "filesystem.remove", "extensions.*" ] } ``` -------------------------------- ### Configuring Application URL and Modes Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/configuration/neutralino.config.json.md Shows how to set a default application URL and define mode-specific URLs within the neutralino.config.json file. ```json { "url": "/" "modes": { "window": { "url": "/#window-mode" } } } ``` -------------------------------- ### filesystem.createDirectory Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/filesystem.md Creates a directory or multiple directories recursively. Throws NE_FS_DIRCRER if directory creation is not possible. ```APIDOC ## filesystem.createDirectory(path) ### Description Creates a directory or multiple directories recursively. Throws `NE_FS_DIRCRER` if directory creation is not possible. ### Parameters #### Path Parameters - **path** (String): New directory path. ### Request Example ```js await Neutralino.filesystem.createDirectory('./newDirectory'); await Neutralino.filesystem.createDirectory(NL_PATH + '/myFolder/api/fs'); ``` ``` -------------------------------- ### os API - spawnProcess options Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md Updates the `os.spawnProcess` function to accept an options object for configuring environment variables and the current working directory. ```APIDOC ## API: os.spawnProcess ### Description Spawns a new child process with configurable environment variables and current working directory. ### Method `os.spawnProcess(command, options)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **command** (string) - Required - The command to spawn. - **options** (object) - Required - Configuration options for the spawned process. - **cwd** (string) - Optional - The current working directory for the child process. - **envs** (object) - Optional - Key-value pairs of environment variables to set for the child process. - **VAR_NAME** (string) - Description of the environment variable. ### Example ```javascript await Neutralino.os.spawnProcess('env', { cwd: '/path/to/directory', envs: { VAR1: 'var1', VAR2: 'var2' } }); ``` ``` -------------------------------- ### Get File Watchers - JavaScript Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/filesystem.md Retrieves a list of all active file watchers. Iterates through the returned array to log information about each watcher. ```javascript let watchers = await Neutralino.filesystem.getWatchers(); for(let watcher of watchers) { console.log(watcher); } ``` -------------------------------- ### Initialize and Control Neutralinojs App with Node.js Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/cli.md This JavaScript code demonstrates how to use the 'node-neutralino' NPM package to launch and manage a Neutralinojs application within a Node.js environment. It shows initialization and setting the window title. ```javascript import NeutralinoApp from 'node-neutralino'; const app = new NeutralinoApp({ url: '/', windowOptions: { enableInspector: false, } }); app.init(); app.window.setTitle('Node.js'); ``` -------------------------------- ### Get CPU Architecture Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/computer.md Fetches the CPU architecture identifier. This can be 'x64', 'ia32', 'arm', 'itanium', or 'unknown'. Useful for platform-specific logic. ```javascript let arch = await Neutralino.computer.getArch(); console.log(arch); ``` -------------------------------- ### Get all keys from Neutralino.storage Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/storage.md Use getKeys to retrieve an array of all existing storage keys currently stored in Neutralinojs shared storage. ```javascript let keys = await Neutralino.storage.getKeys(); console.log('Keys: ', keys); ``` -------------------------------- ### Get Extension Statistics Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/extensions.md Retrieves details about extensions that are loaded and currently connected via WebSocket. Use this to monitor extension status. ```javascript let stats = await Neutralino.extensions.getStats(); console.log('stats: ', stats); ``` -------------------------------- ### Take Window Snapshot Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/window.md Captures a PNG image of the current window's client area and saves it to a specified file path. ```javascript await Neutralino.window.snapshot(NL_PATH + '/images/window.png'); ``` -------------------------------- ### window.create Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/window.md Creates a new native window for a multi-window Neutralinojs application. ```APIDOC ## window.create(url: String, options?: Object) ### Description Creates a native window. This method can be used to create new windows for multi-window Neutralinojs applications. Each native window runs in an isolated process. ### Parameters - `url` (String): The URL to be loaded in the new window. Supports both local (starting with `/`) and remote resources. - `options` (Object, optional): An instance of `WindowOptions` type to configure the new window. ``` -------------------------------- ### Get All Custom Methods Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/custom.md Retrieves a list of all custom methods that have been added by the application developer. This is useful for introspection and dynamic method calling. ```javascript let methods = await Neutralino.custom.getMethods(); console.log(methods); ``` -------------------------------- ### Load Neutralinojs Framework Without Configuration Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md Load the Neutralinojs framework using command-line arguments without a `neutralino.config.json` file. This method sets reasonable defaults for initialization. ```bash # Loading a remote URL ./framework-bin --url=https://neutralino.js.org/docs ``` ```bash # Launches a local static web app ./framework-bin --url="/resources/" --window-title="My web app" --enable-server ``` -------------------------------- ### Configure Native API Allow List Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/getting-started/using-frontend-libraries.md Update neutralino.config.json to specify which native APIs your application can access. This example allows 'app.*' and 'filesystem.readDirectory'. ```json "nativeAllowList": [ "app.*", "filesystem.readDirectory" ], ``` -------------------------------- ### Build macOS Application Bundle Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/distribution/overview.md Run this command to generate a new application bundle for macOS. The build is created in the ./dist folder. ```bash ./build-mac.sh ``` -------------------------------- ### Build Static Website Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/README.md Generates static content into the 'build' directory, suitable for hosting on any static content service. ```bash yarn build ``` -------------------------------- ### Get Absolute Path - Filesystem API Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/filesystem.md Converts a relative path to its absolute equivalent. This function works even if the path does not exist on the system. ```javascript let path = await Neutralino.filesystem.getAbsolutePath('./myFolder'); console.log(path); ``` -------------------------------- ### Get File Statistics - Filesystem API Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/filesystem.md Retrieves statistics for a given file or directory path. This can be used to check if a path exists and is accessible. ```javascript let stats = await Neutralino.filesystem.getStats('./sampleVideo.mp4'); console.log('Stats:', stats); ``` -------------------------------- ### window.show Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/window.md Makes the native window visible if it was previously hidden. ```APIDOC ## window.show() ### Description Shows the native window. ### Example ```js await Neutralino.window.show(); ``` ``` -------------------------------- ### Get Spawned Processes - Neutralinojs Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/os.md Retrieve a list of all currently spawned processes. This is useful for monitoring or managing background tasks initiated by your application. ```javascript await Neutralino.os.spawnProcess('ping neutralino.js.org'); await Neutralino.os.spawnProcess('ping codezri.org'); let processes = await Neutralino.os.getSpawnedProcesses(); console.log(processes); ``` -------------------------------- ### Capture Window Snapshot Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/release-notes/framework.md Capture the current state of the application window and save it as a PNG image file to a specified path. ```javascript await Neutralino.window.snapshot(path); ``` -------------------------------- ### Get All Embedded Files Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/api/resources.md Retrieves a list of all files and directories embedded within the resource bundle. This is useful for understanding the structure of your packaged resources. ```javascript let files = await Neutralino.resources.getFiles(); console.log('Files: ', files); ``` -------------------------------- ### Build Neutralinojs Application Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/cli/neu-cli.md Builds the Neutralinojs application, creating a 'dist' folder with binaries for supported platforms and the 'resources.neu' file. ```bash neu build ``` -------------------------------- ### Create a new Neutralinojs App Source: https://github.com/neutralinojs/neutralinojs.github.io/blob/main/docs/cli/neu-cli.md Create a new Neutralinojs application using a template. The basename of the path will be used as the app's binary name. ```bash neu create myapp neu create . ```