Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DelphiLibNodeJS

A Windows DLL with embedded Node.js for Delphi applications.

DelphiLibNodeJS lets you run JavaScript/Node.js code directly inside a Delphi process — no separate node.exe, no libnode.dll, no third-party DLLs in the distribution package. All dependencies (V8, libuv, OpenSSL, ICU, zlib…) are statically linked into a single DLL.

The API follows the COM style: one flat C export DN_CreateFactory, everything else via COM interfaces with HRESULT return values.

Quick Start

uses DelphiLibNodeJS;

var
  Factory : INodeFactory;
  Runtime : INodeRuntime;
  Log     : INodeLog;
  Cfg     : TDNRuntimeConfig;
  Rec     : TDNLogRecord;
begin
  OleCheck(DN_CreateFactory(nil, Factory));

  FillChar(Cfg, SizeOf(Cfg), 0);
  Cfg.size := SizeOf(Cfg);
  OleCheck(Factory.CreateRuntime(@Cfg, Runtime));

  Log := Runtime as INodeLog;
  OleCheck(Runtime.Start);

  Runtime.RunScriptText('console.log("Hello from Node.js " + process.version)', nil);
  Runtime.Stop;
  Runtime.Join(5000, nil);

  // Delphi ARC: Log, Runtime, Factory are released when they go out of scope
end.

Key Features

  • Single DLL — no third-party DLLs in the distribution; only system Windows DLLs
  • COM-style APIINodeFactory, INodeRuntime, INodeLog, INodeNpm, INodeBridge; Delphi as operator and ARC work natively
  • npm integrationINodeNpm.Install, InstallFromPackageJson directly from Delphi
  • Structured log — ring buffer with poll/push modes; captures console.*, stdout, stderr, unhandled exceptions
  • ESM and CJS — support for .mjs/import, top-level await, auto-detect by file extension
  • Shared node_modulesextra_module_paths_utf8 for reusing installed packages
  • Bidirectional RPC bridgeINodeBridge: Delphi calls JS functions (CallFunction), JS calls Delphi objects via IDispatch (RegisterExport)

Demo Run

# Build the DLL (requires VS 2022 + ClangCL + Python 3.14 + Rust)
.\scripts\BuildHostDll.ps1

# Build and run examples
.\examples\BuildExamples.ps1
.\examples\06_gis\Win64\Release\ExGIS.exe

Documentation

Section Description
Getting Started Requirements, installation, first run
API Reference All interfaces, structs, HRESULT codes
INodeBridge API Bidirectional bridge: full reference
INodeBridge Guide Step-by-step bridge guide
Build from Source Node.js + DLL: step-by-step instructions
Examples Description of all 20 examples (0–19)
Build Notes Node.js version, toolchain, build artifacts

System Requirements

Component Version
Windows 10 / Server 2016 x64 or later
Visual Studio 2022 ≥ 17.4 (with ClangCL components)
Python 3.14+
Rust / cargo stable x86_64-pc-windows-msvc
Delphi / RAD Studio 12+
npm any current version (for examples 1, 5, 6)

License

Node.js (node/) — MIT-compatible component licenses. See node/LICENSE. DLL and example code — see LICENSE in the repository root.

About

DelphiLibNodeJS - is a DLL-wrapper that allows you to run JavaScript/Node.js code inside the application process

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages