Skip to content

untrustedmodders/plugify-module-v8

Repository files navigation

Русский

JavaScript (V8) Language Module for Plugify

The Plugify JavaScript Language Module enables developers to write plugins in modern JavaScript (ECMAScript 2023) and run them using the high-performance V8 engine. With this module, you can harness the flexibility of JavaScript while fully integrating into the Plugify plugin ecosystem.

Features

  • JavaScript-Powered Plugins: Write your plugins entirely in JavaScript using familiar syntax and tools.
  • Seamless Integration: Integrate JavaScript plugins smoothly into the Plugify system alongside other supported languages.
  • Cross-Language Communication: Interact effortlessly with plugins written in C++, Python, Lua, and more.
  • Sandboxed Execution: Run JavaScript code safely in a sandboxed V8 environment with controlled access to native APIs.

Getting Started

Prerequisites

  • JavaScript ES6 is recommended.
  • Plugify Framework Installed

Installation

Option 1: Install via Plugify Plugin Manager

plg install plugify-module-v8

Option 2: Manual Installation

  1. Install dependencies:

    a. Windows

    Setting up CMake tools with Visual Studio Installer

    b. Linux:

    sudo apt-get install -y build-essential cmake ninja-build

    c. Mac:

    brew install cmake ninja
  2. Clone this repository:

    git clone https://github.com/untrustedmodders/plugify-module-v8.git --recursive
  3. Build the JavaScript language module:

    mkdir build && cd build
    cmake ..
    cmake --build .

Usage

  1. Integration with Plugify

    Ensure that your JavaScript language module is available in the same directory as your Plugify setup.

  2. Write JavaScript Plugins

    Develop your plugins in JavaScript using the Plugify V8 API. Refer to the Plugify JavaScript Plugin Guide for detailed instructions.

  3. Build and Install Plugins

    Put your JavaScript files in a directory accessible to the Plugify core.

  4. Run Plugify

    Start the Plugify framework, and it will dynamically load your JavaScript plugins.

Example

import { Plugin } from 'plugify';

export class ExamplePlugin extends Plugin {
    pluginStart() {
        console.log('ExamplePlugin::pluginStart');
    }
    pluginUpdate(dt) {
        console.log('ExamplePlugin::pluginUpdate');
    }
    pluginEnd() {
        console.log('ExamplePlugin::pluginEnd');
    }
}

API References

  • assert Provides a set of assertion tests
    • assert.ok() Checks if a value is true.
    • assert.equal() Checks if two values are equal, using the equal operator (==).
    • assert.notEqual() Checks if two values are not equal, using the not equal operator (!=)
  • buffer To handle binary data
    • TODO
  • console Console object.
    • console.log() Outputs a message to the console.
    • console.info() Outputs a message to the console.
    • console.warn() Outputs a message to the console.
    • console.error() Outputs a message to the console.
    • console.debug() Outputs a message to the console.
  • child_process To run a child process
    • TODO
  • cluster To split a single Node process into multiple processes
    • TODO
  • crypto To handle OpenSSL cryptographic functions
    • TODO
  • dgram Provides implementation of UDP datagram sockets
    • TODO
  • dns To do DNS lookups and name resolution functions
    • TODO
  • events To handle events
    • TODO
  • fs To handle the file system - fs.rename() rename the file.
    • fs.exists()
    • fs.rmdir() remove the dir.
    • fs.mkdir() create the dir.
    • fs.stat() get the stat of the given pathname.
    • fs.readdir() read the directory.
    • fs.readFile() read the file of the given pathname.
    • fs.writeFile() write the file of the given pathname and bytes/string.
    • fs.appendFile() append to the file of the given pathname and bytes/string.
  • http To make Node.js act as an HTTP server
    • TODO
  • https To make Node.js act as an HTTPS server.
    • TODO
  • net To create servers and clients
    • TODO
  • os Provides information about the operation system
    • os.tmpdir() Returns the operating system's default directory for temporary files.
    • os.homedir() Returns the operating system's home directory.
    • os.endianness() Returns the endianness of the CPU.
    • os.type() Returns the name of the operating system.
    • os.platform() Returns information about the operating system's platform.
    • os.arch() Returns the operating system CPU architecture.
  • path To handle file paths
    • path.normalize() normalize the path string.
    • path.join() Joins the specified paths into one.
    • path.resolve() Resolves the specified paths into an absolute path.
    • path.isAbsolute() return if a path is in absolute.
    • path.relative() normalize the path string.
    • path.dirname() return the directory name of the path.
    • path.basename() return the basename of the path.
    • path.extname() return the ext name.
  • querystring To handle URL query strings
    • TODO
  • readlin To handle readable streams one line at the time
    • TODO
  • stream To handle streaming data
    • TODO
  • string_decoder To decode buffer objects into strings
    • TODO
  • timers To execute a function after a given number of milliseconds
    • timers.setTimeout() Executes a given function after a given time (in milliseconds).
    • timers.clearTimeout() Cancels a Timeout object.
  • tls To implement TLS and SSL protocols
    • TODO
  • tty Provides classes used by a text terminal
    • TODO
  • url To parse URL strings
    • TODO
  • util To access utility functions
    • TODO
  • v8 To access information about V8 (the JavaScript engine)
    • TODO
  • vm To compile JavaScript code in a virtual machine
    • TODO
  • zlib To compress or decompress files
    • TODO

Documentation

For comprehensive documentation on writing plugins in JavaScript using the Plugify framework, refer to the Plugify Documentation.

Contributing

Feel free to contribute by opening issues or submitting pull requests. We welcome your feedback and ideas!

License

This JavaScript (V8) Language Module for Plugify is licensed under the MIT License.