WidgetCore ๐Ÿš€

WidgetCore is a high-performance, cross-platform library built with Node.js and C++ for creating interactive and persistent desktop widgets. It leverages native OS webview engines (WebView2 on Windows, WKWebView on macOS, and WebKitGTK on Linux) to provide a seamless, lightweight, and hardware-accelerated widget experience.

๐Ÿ—๏ธ Architecture Overview

WidgetCore uses a hybrid architecture where the core logic is managed in Node.js, while windowing and webview rendering are handled by a native C++ module (widget_core.node).
graph TD
    A[Node.js App] --> B[DesktopWidget Class]
    B --> C[WidgetRegistry]
    B --> D[AutostartManager]
    B --> E[Native Module C++]
    E --> F{Platform}
    F -->|Linux| G[WebKitGTK + GTK3]
    F -->|macOS| H[WKWebView + Cocoa]
    F -->|Windows| I[WebView2 + Win32]
    G --> J[Desktop Widget Window]
    H --> J
    I --> J

โœจ Core Capabilities


๐Ÿ”’ Security Shield

Security is a primary concern for widgets. WidgetCore implements a multi-layer "Shield" to protect the host system:

๐Ÿš€ Detailed Usage

Advanced HTML Widget Example

You can create complex, self-contained widgets using a single string:
import { DesktopWidget } from 'widget-core';

const clockHTML = `
  
00:00:00
`; const widget = new DesktopWidget("", { html: clockHTML, width: 300, height: 100, x: 50, y: 50, scroll: false, interactive: false // Clocks usually don't need input }); // Make it stay after reboot await widget.makePersistent(widget.options);

Static Global Management

// Stop all running widgets across the system
const stopped = DesktopWidget.stopAll();

// Get list of all registered widgets
const widgets = DesktopWidget.listWidgets();
widgets.forEach(w => console.log(ID: ${w.id}, URL: ${w.url}, Active: ${w.active}));

๐Ÿ› ๏ธ API Documentation

WidgetOptions

Property Type Description
width number Width in pixels.
height number Height in pixels.
x number X coordinate from top-left.
y number Y coordinate from top-left.
opacity number Window opacity (0.0 to 1.0). Default: 1.0.
interactive boolean If true, clicks pass through to the widget. Default: false.
html string Raw HTML/CSS source code to load.
scroll boolean If false, overflow: hidden is applied. Default: true.
blur boolean Platform-specific background blur effect.

Instance Methods


๐Ÿง Linux Platform Notes (GTK/WebKit)

On Linux, WidgetCore uses GTK and WebKitGTK. For full transparency, ensure your window manager/compositor (like Mutter on GNOME or KWin on KDE) is configured correctly.

๐ŸŽ macOS Platform Notes (Cocoa/WKWebView)


๐Ÿ’ป Windows Platform Notes (Win32/WebView2)


๐Ÿงช Development & Testing

We use Vitest for unit testing. The native layer is mocked automatically during tests.

Install dependencies

npm install

Build native module & TypeScript

npm run build

Run tests

npm test

๐Ÿ› Troubleshooting


๐Ÿ“ License

MIT License. Copyright (c) 2026 Osman Beyhan. Contributions are welcome!

Author: Osman Beyhan


โค๏ธ Make via MDtoWeb