### Create New Buntralino Project Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/get-started.md Installs the Buntralino CLI globally and then creates a new Buntralino project. Users will be prompted to enter project details and select a template. ```sh bun install -g buntralino-cli buntralino create # Then follow the instructions to input your project's name and template. ``` -------------------------------- ### Development Setup Source: https://github.com/buntralino/buntralino.github.io/blob/main/README.md Instructions to clone the Buntralino project repository, install its dependencies using npm, and start the local development server. This is the standard procedure for setting up the project for local development. ```sh git clone https://github.com/buntralino/buntralino.github.io.git cd ./buntralino.github.io npm install npm run dev ``` -------------------------------- ### Install Bun Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/get-started.md Installs or updates the Bun JavaScript runtime on your system. This command is universal across different operating systems, with specific variations for Linux/macOS and Windows. ```sh curl -fsSL https://bun.sh/install | bash ``` ```powershell powershell -c "irm bun.sh/install.ps1 | iex" ``` -------------------------------- ### Run Buntralino Application Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/get-started.md Starts the development server for a Buntralino application. This command works for both newly created projects and existing Neutralino.js projects that have Buntralino added. ```sh cd buntralino-app bun run dev ``` ```sh bun run dev ``` -------------------------------- ### Add Buntralino to Existing Neutralino.js Project Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/get-started.md Installs the Buntralino CLI globally and adds Buntralino functionality to an existing Neutralino.js project. This command should be run from the root directory of the Neutralino.js project. ```sh # Run this in the root of your Neutralino.js project bun install -g buntralino-cli buntralino add ``` -------------------------------- ### Build Buntralino Application Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/get-started.md Builds and packages the Buntralino application for distribution. The build process utilizes the configuration defined in `neutralino.config.json`. ```sh bun run build ``` -------------------------------- ### Install libwebkit2gtk on openSUSE Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/troubleshoot-linux.md Installs the libwebkit2gtk-4_0-37 package on openSUSE systems using zypper. This library is essential for Buntralino applications to create GUI windows. ```bash sudo zypper install libwebkit2gtk-4_0-37 ``` -------------------------------- ### Install Buntralino CLI Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/cli.md Installs the Buntralino CLI globally using Bun package manager. ```shell bun install --global buntralino-cli ``` -------------------------------- ### Install libwebkit2gtk on Ubuntu/Debian Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/troubleshoot-linux.md Installs the libwebkit2gtk-4.0-37 package on Ubuntu and Debian systems using apt. This library is essential for Buntralino applications to create GUI windows. ```bash sudo apt update sudo apt install libwebkit2gtk-4.0-37 ``` -------------------------------- ### Install buntralino-cli Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/cli-api.md Installs the buntralino-cli npm package as a development dependency using Bun. ```sh bun install --dev buntralino-cli ``` -------------------------------- ### Install libwebkit2gtk on Fedora Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/troubleshoot-linux.md Installs the webkit2gtk3 package on Fedora systems using dnf. This library is essential for Buntralino applications to create GUI windows. ```bash sudo dnf install webkit2gtk3 ``` -------------------------------- ### Buntralino Event Handling and Window Management Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/bun-api.md Provides examples for managing window connections and listening to events emitted by the Buntralino library. It covers creating windows, listening for 'open' and 'close' events, and exiting the application. ```typescript import * as buntralino from 'buntralino'; // Create main window await buntralino.create('/', { name: 'main', width: 800, height: 600 }); // Listen for window open events buntralino.events.on('open', (windowName: string) => { console.log(`Window "${windowName}" has been opened`); }); // Listen for window close events buntralino.events.on('close', (windowName: string) => { console.log(`Window "${windowName}" has been closed`); // Exit the application when main window is closed if (windowName === 'main') { process.exit(); } }); // Create another window later await buntralino.create('/secondary.html', { name: 'secondary', width: 400, height: 300 }); ``` -------------------------------- ### Broadcast Event to All Windows Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/bun-api.md Explains how to broadcast an event with optional data to all currently connected Buntralino windows using the `broadcast` method. Includes server-side sending and client-side listening examples. ```APIDOC broadcast(event: string, payload?: unknown): void Sends an event to all currently connected Neutralino windows. Parameters: - event: `string` - The name of the event to be broadcasted. - payload: `unknown` (optional) - An optional data object that will be sent along with the event. This can be any JSON-serializable value. Example (Server-side): ```typescript import * as buntralino from 'buntralino'; // Broadcast an event to all Neutralino windows await buntralino.broadcast('newUpdate', { version: '1.4.2' }); ``` Example (Client-side): ```javascript // Listen to events through Neutralino API: Neutralino.events.on('newUpdate', e => { const {version} = e.detail; console.log(`New version ${version} has been released!`); }); ``` ``` -------------------------------- ### Install libwebkit2gtk on Arch Linux Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/troubleshoot-linux.md Installs the webkit2gtk package on Arch Linux systems using pacman. This library is essential for Buntralino applications to create GUI windows. ```bash sudo pacman -S webkit2gtk ``` -------------------------------- ### Register Single Method with Buntralino Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/bun-api.md Demonstrates how to register a single method that can be invoked from a client-side context using the `registerMethod` function. It includes an example of simulating asynchronous work. ```typescript import * as buntralino from 'buntralino'; // Example using registerMethod for individual method registration buntralino.registerMethod('sayHello', async (payload: { name: string }) => { await Bun.sleep(500); // simulate some async work return `Hello, ${payload.name}!`; }); ``` -------------------------------- ### Send Event to Specific Window Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/bun-api.md Details how to send a custom event with optional data to a specific named Buntralino window using the `sendEvent` method. Includes server-side sending and client-side listening examples. ```APIDOC sendEvent(target: string, event: string, payload?: unknown): void Sends an event to a specific named Neutralino window. Parameters: - target: `string` - The name of the window to which the event should be sent. - event: `string` - The name of the event to be sent. - payload: `unknown` (optional) - An optional data object that will be sent along with the event. This can be any JSON-serializable value. Example (Server-side): ```typescript import * as buntralino from 'buntralino'; // Send an event to a specific Neutralino window buntralino.sendEvent('main', 'loginSuccessful', { username: 'Doofus3000' }); ``` Example (Client-side): ```javascript // Listen to events through Neutralino API: Neutralino.events.on('loginSuccessful', e => { const {username} = e.detail; console.log(`Logged in as ${username}!`); }); ``` ``` -------------------------------- ### Create Neutralino Window with Buntralino Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/bun-api.md Demonstrates how to create a new Neutralino window using the Buntralino library. It specifies the URL to load and various window configuration options. ```typescript import * as buntralino from 'buntralino'; await buntralino.create('/', { name: 'main', title: 'My App', width: 800, height: 600, center: true, resizable: true }); ``` -------------------------------- ### Buntralino CLI: Project Management Commands Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/cli.md This section details the core commands for managing Buntralino projects, including creation, adding to existing projects, running, and building. ```APIDOC buntralino create [name] [templateName] - Creates a new Buntralino project. - Parameters: - name (optional): Prefills the application name. Can be changed later in neutralino.config.json. - templateName (optional): Specifies the project template to copy and configure. Possible options are 'new' (default) and 'vite'. - Behavior: If arguments are omitted, an interactive prompt will appear. buntralino add - Adds Buntralino to an existing Neutralino.js project. - Usage: Run this command in the root directory of your Neutralino.js project (where neutralino.config.json is located). buntralino run [indexPath] (or buntralino start [indexPath]) - Runs the Buntralino project. - Parameters: - indexPath (optional): Path to the main Bun file that uses the buntralino package to manage windows. Defaults to 'index.ts' in the current working directory. - Additional Arguments: Pass arguments to the script using the '--' separator (e.g., buntralino run -- --devmode). buntralino build [indexPath] - Builds the project for distribution. - Process: Bundles Bun scripts into an executable and arranges files for portable distribution. - Parameters: - indexPath (optional): Path to the main Bun file. Defaults to 'index.ts' in the current working directory. - Configuration: Application name, icons, and metadata are taken from neutralino.config.json. - Additional Arguments: Pass arguments to the 'bun build' command with '--' separator (e.g., buntralino build src/bun/index.ts -- --external original-fs). - Note: Minification flags like --compile and --outfile are included by default and should not be duplicated. ``` -------------------------------- ### Buntralino Window Management API Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/bun-api.md Provides methods for controlling Neutralino windows. This includes creating, showing, hiding, closing, resizing, positioning, and navigating windows, as well as evaluating JavaScript within them. ```APIDOC create(url: string, options?: WindowOptions): Promise - Creates a new Neutralino window. - Parameters: - url: The URL to load in the window. - options: Window configuration options (see WindowOptions interface). - Returns: Promise resolving to the name of the created window. show(target: string): Promise - Makes the specified window visible. - Parameters: - target: The name of the window to show. hide(target: string): Promise - Hides the specified window. - Parameters: - target: The name of the window to hide. exit(target: string): Promise - Closes the specified window. - Alias: close(target: string) - Parameters: - target: The name of the window to close. setAlwaysOnTop(target: string, onTop: boolean): Promise - Sets whether the window should stay on top of other windows. - Parameters: - target: The name of the window. - onTop: Boolean indicating if the window should be always on top. getSize(target: string): Promise - Returns the current window size. - Parameters: - target: The name of the window. - Returns: Promise resolving to WindowSizeOptions object. setSize(target: string, options: WindowSizeOptions): Promise - Sets the window size. - Parameters: - target: The name of the window. - options: Partial WindowSizeOptions object; merges with the current size. getPosition(target: string): Promise - Returns the current window position. - Parameters: - target: The name of the window. - Returns: Promise resolving to WindowPosOptions object. move(target: string, x: number, y: number): Promise - Moves the window to specified coordinates. - Alias: setPosition(target: string, x: number, y: number) - Parameters: - target: The name of the window. - x: The new x-coordinate. - y: The new y-coordinate. center(target: string): Promise - Centers the window on the screen. - Parameters: - target: The name of the window. focus(target: string): Promise - Brings the window to front and gives it focus. - Parameters: - target: The name of the window. getTitle(target: string): Promise - Gets the window title. - Parameters: - target: The name of the window. - Returns: Promise resolving to the window's title. setTitle(target: string, title: string): Promise - Sets the window title. - Parameters: - target: The name of the window. - title: The new title for the window. navigate(target: string, url: string): Promise - Navigates the window to a new URL. - Parameters: - target: The name of the window. - url: The new URL to load. reload(target: string): Promise - Reloads the current window. - Parameters: - target: The name of the window. evalJs(target: string, js: string): Promise - Evaluates JavaScript code in the window context. - Parameters: - target: The name of the window. - js: The JavaScript code string to evaluate. ``` -------------------------------- ### Buntralino CLI: Utility Commands Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/cli.md Provides commands for checking the CLI version and displaying help information. ```APIDOC buntralino --version - Displays the current 'buntralino-cli' version. buntralino --help - Displays help information for available commands. ``` -------------------------------- ### Buntralino Client API Methods Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/client-api.md Provides methods to communicate with the main Bun process from Neutralino windows. These methods allow running registered functions, broadcasting events, sending events to specific windows, and managing the application lifecycle. ```APIDOC buntralino.run(method, payload) - Sends a request to the main Bun process to execute a registered method. - Parameters: - method: The name of the registered method to execute (string). - payload: Any JSON-serializable value to be passed as arguments or options to the method (any). - Returns: A Promise that resolves with the result of the executed method. - Example: const updates = await buntralino.run('loadUpdates'); await buntralino.run('downloadFile', { src: 'https://secret.bunnies.io/builds/windows.exe', dest: 'dependencies/secretBunnies.exe' }); buntralino.broadcast(eventName, eventDetails) - Sends an event to all connected Neutralino.js windows. - Parameters: - eventName: The name of the event to broadcast (string). - eventDetails: Data associated with the event, must be JSON-serializable (any). - Example: buntralino.broadcast('loginSuccessful', { username: 'Doofus3000' }); // Listen via Neutralino API: // Neutralino.events.on('loginSuccessful', e => { console.log(e.detail.username); }); buntralino.sendEvent(windowName, eventName, eventDetails) - Sends an event to a specific named Neutralino.js window. - Parameters: - windowName: The name of the target window (string). - eventName: The name of the event to send (string). - eventDetails: Data associated with the event, must be JSON-serializable (any). - Example: buntralino.sendEvent('main', 'loginSuccessful', { username: 'Doofus3000' }); // Listen via Neutralino API: // Neutralino.events.on('loginSuccessful', e => { console.log(e.detail.username); }); buntralino.shutdown() - Sends a signal to the main Bun process to exit the entire Buntralino application. - Example: buntralino.shutdown(); buntralino.disableBunCheck() - Disables the default behavior where the Buntralino client closes Neutralino windows not opened via Buntralino and attempts to launch the Buntralino executable. - Use this if you need to use `Neutralino.window.create` for third-party windows. - Must be called immediately after importing `buntralino-client`. - Example: import * as buntralino from 'buntralino-client'; buntralino.disableBunCheck(); ``` -------------------------------- ### Buntralino Window Size Options Interface Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/bun-api.md Defines the structure for specifying or retrieving window dimensions. Supports setting width, height, minimum/maximum dimensions, and resizability. ```typescript interface WindowSizeOptions { width?: number; height?: number; minWidth?: number; minHeight?: number; maxWidth?: number; maxHeight?: number; resizable?: boolean; } ``` -------------------------------- ### Import Buntralino Client Library Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/client-api.md Imports the buntralino-client library as an ESM module. This action automatically attempts to connect to the main Bun process. ```typescript import * as buntralino from 'buntralino-client'; ``` -------------------------------- ### Buntralino Window Options Interface Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/bun-api.md Defines the configuration options available when creating or modifying a Neutralino window. Includes custom Buntralino options and standard Neutralino.js options. ```typescript interface WindowOptions { // Custom Buntralino option name?: string; // Custom window identifier to use with other methods // If not set, a random name is generated. // Standard Neutralino.js WindowOptions (from @neutralinojs/lib) title?: string; // Window title icon?: string; // Path to window's icon // (PNG file, relative to Neutralino.js resources, // which is `app` in the default Buntralino template) enableInspector?: boolean; // Enable dev tools // (defaults to `true` when developing and `false` in production) alwaysOnTop?: boolean; // Whether the window always stays on top of other windows borderless?: boolean; // Create a borderless window (no titlebar or default OS frame) exitProcessOnClose?: boolean; // Exit the Neutralino process when window closes fullScreen?: boolean; // Whether to start in fullscreen hidden?: boolean; // Start hidden maximizable?: boolean; // Can be maximized maximize?: boolean; // Start maximized processArgs?: string; // Additional process arguments resizable?: boolean; // Whether the window can be resized useSavedState?: boolean; // Whether to save and load previous position of this window. x?: number; // Initial x position y?: number; // Initial y position width?: number; // Initial width height?: number; // Initial height minWidth?: number; // Minimum allowed window width minHeight?: number; // Minimum allowed window height maxWidth?: number; // Maximum allowed window width maxHeight?: number; // Maximum allowed window height } ``` -------------------------------- ### Register Multiple Methods with Buntralino Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/bun-api.md Shows how to register multiple methods simultaneously using `registerMethodMap`. This can be done by passing either a JavaScript object or a `Map` containing method names and their corresponding callables. ```typescript import * as buntralino from 'buntralino'; // Example using registerMethodMap for registering multiple methods at once // Using an object const methodMap = { add: (payload: { a: number, b: number }) => { return payload.a + payload.b; }, getCurrentTime: () => { return new Date().toISOString(); }, readFile: async (payload: { path: string }) => { const file = Bun.file(payload.path); return await file.text(); } }; buntralino.registerMethodMap(methodMap); // Alternative: using a Map const methodMapUsingMap = new Map([ ['multiply', (payload: { a: number, b: number }) => payload.a * payload.b], ['getSystemInfo', () => ({ platform: process.platform, arch: process.arch })] ]); buntralino.registerMethodMap(methodMapUsingMap); ``` -------------------------------- ### Buntralino API Interaction Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/README.md Demonstrates registering a method in the Bun process and invoking it from the UI client. The Bun process executes a task and returns a value, which is then displayed in the UI. This showcases the asynchronous communication between the Bun backend and the Neutralino.js frontend. ```typescript import {create, registerMethod, evalJs} from 'buntralino'; /* Add a Bun method to UI */ registerMethod('sayHello', async (payload: { message: string }) => { await Bun.sleep(1000); return `Bun says "${payload.message}"!`; }); /* Create a window named "main" */ await create('/', { name: 'main' }); /* Manipulate created windows */ evalJs('main', `console.log('👀');`); ``` ```typescript import * as buntralino from 'buntralino-client'; (async () => { /* Wait till Buntralino API is ready */ await buntralino.ready; /* Run a Bun method and get its return value */ const response = await buntralino.run('sayHello', { message: 'Hello, Buntralino!' }); console.log(response); })(); ``` -------------------------------- ### Buntralino Application Architecture Diagram Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/architecture.md Visual representation of the Buntralino application structure, illustrating the main Bun process and multiple Neutralino.js client windows connected via WebSockets. ```mermaid graph TB bun("Bun process (the main one, aka Bun side)") window1("Neutralino.js process (client window 1)") window2("Neutralino.js process (client window 2)") window3("Neutralino.js process (client window N)") bun<--WebSockets-->window1 bun<--WebSockets-->window2 bun<--WebSockets-->dotdot(...) bun<--WebSockets-->window3 ``` -------------------------------- ### Buntralino Window Position Options Interface Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/bun-api.md Defines the structure for specifying or retrieving window coordinates. Contains the x and y position of the window on the screen. ```typescript interface WindowPosOptions { x: number; y: number; } ``` -------------------------------- ### Wait for Buntralino Connection Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/client-api.md Waits for the Buntralino client to establish a connection with the main Bun process. This is achieved by awaiting the `ready` Promise exported by the client. ```typescript // Wait till the connection to Bun is up await buntralino.ready; ``` -------------------------------- ### Programmatic buntralino CLI Usage in TypeScript Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/cli-api.md Demonstrates how to import and use the buntralino-cli package as an ESM module in TypeScript. It covers running the application with and without arguments, and building the application with optional build flags. ```ts import * as buntralino from 'buntralino-cli'; // Specify the main Bun file where you open Buntralino windows; // it is passed to buntralino.run and buntralino.build as the only argument. const buntralinoIndex = 'src/bun/index.ts'; // Run the Buntralino application and wait until it is closed await buntralino.run(buntralinoIndex); // Run the Buntralino application and provide additional arguments to its main script. await buntralino.run(buntralinoIndex, '--devmode') // Packages the Buntralino application for redistribution. // Make sure to prebuild all the assets used by Neutralino beforehand. await buntralino.build(buntralinoIndex); // Build with additional arguments for the `bun build --compile` command await buntralino.build(buntralinoIndex, ['--external', 'original-fs']); ``` -------------------------------- ### Check Connection Status Source: https://github.com/buntralino/buntralino.github.io/blob/main/docs/bun-api.md Describes the `isConnectionOpen` method, which checks if a connection to a specifically named window is currently active. This is useful for verifying window availability or connection readiness. ```APIDOC isConnectionOpen(name: string): boolean Checks if a connection to a named window is currently open. Parameters: - name: `string` - The name of the window to check. Returns: - `boolean`: `true` if the connection is open, `false` otherwise. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.