Find file History
pavel.mash
pavel.mash SyNode: new function TSMEngine.CallObjectFunctionVal + use this funct…
…ion for call timerLoop. A small optimization as a result
Latest commit f3d51b9 Dec 9, 2018
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Samples SyNode: Embadding JavaScript files into executable as a resources Nov 23, 2018
core_modules fixed potential GPF in latest pull request Nov 26, 2018
mozjs Pathed version of mozjs library is renamed Mar 20, 2018
tools SyNode: Embadding JavaScript files into executable as a resources Nov 23, 2018
.gitignore SyNode: Embadding JavaScript files into executable as a resources Nov 23, 2018
NSPRAPI.pas Delphi7 compilation fixes Nov 2, 2017
README.md SyNode: Embadding JavaScript files into executable as a resources Nov 23, 2018
SpiderMonkey.pas SyNode: fix delphi compilation + ensure worker.onterminate funcion ex… Aug 25, 2018
SyNode.inc SyNode: Embadding JavaScript files into executable as a resources Nov 23, 2018
SyNode.pas SyNode: new function TSMEngine.CallObjectFunctionVal + use this funct… Dec 9, 2018
SyNodeBinding_HTTPClient.pas implement a fs.realpath (windows version for a while) Nov 21, 2017
SyNodeBinding_buffer.pas remove unused parameter in anyBase64toBin Nov 16, 2018
SyNodeBinding_const.pas SyNode: extend consts binding by zlib and fs constants Jun 29, 2018
SyNodeBinding_fs.pas SyNode: fs.readdirSync() return folders and files for both platform. … Apr 22, 2018
SyNodeBinding_util.pas Minor changes Oct 31, 2017
SyNodeBinding_uv.pas SyNode linux64 build Oct 30, 2017
SyNodeBinding_worker.pas SyNode: fix delphi compilation + ensure worker.onterminate funcion ex… Aug 25, 2018
SyNodeNewProto.pas Download links update Mar 20, 2018
SyNodePluginIntf.pas SyNode: produce more human readable exception in case overload not fo… Sep 24, 2018
SyNodeProto.pas prevent redefining of prototype props in descendants Dec 9, 2018
SyNodeReadWrite.pas SyNode: fix delphi compilation + ensure worker.onterminate funcion ex… Aug 25, 2018
SyNodeRemoteDebugger.pas SyNode: Embadding JavaScript files into executable as a resources Nov 23, 2018
SyNodeSimpleProto.pas SyNode: fix write access to published property of type boolean for FPC Sep 23, 2018
_SynodePluginTemplate.dpr fixed [b846ed16e9af9] about invalid MS information Nov 7, 2016
build_res.sh SyNode: Embadding JavaScript files into executable as a resources Nov 23, 2018
core_modules.res SyNode: Embadding JavaScript files into executable as a resources Nov 23, 2018
modules_cjs.txt SyNode: Embadding JavaScript files into executable as a resources Nov 23, 2018
modules_es6.txt SyNode: Embadding JavaScript files into executable as a resources Nov 23, 2018
synodebinding_os.pas fixed FPC x86 compilation Aug 5, 2018

README.md

The server-side JavaScript execution using the SpiderMonkey library with nodeJS modules support

  • win32/64 target (FPC 3.1.1, Delphi), linux 64 (FPC 3.1.1)
  • based on SpiderMonkey52, almost full support of ES6
  • a remote debugger protocol, can be debugged remotely using Firefox - see SyNode\Samples\02 - Bindings
  • CommonJS modules, compatible with NPM modules
  • native modules can be implemented using Delphi/FPC (as a dll/so) - see SyNode\Samples\01 - Dll Modules
  • JavaScript prototype definition based on Delphi RTTI (supported both "new" and old)

SpiderMonkey library

SpiderMonkey 52 (recommended)

Precompiled binary can be downloaded here:

Or compiled from sources as described in instructions inside mozjs folder

SpiderMonkey 45 (not supported)

Precompiled binary can be downloaded here:

Embadding SyNode JavaScript files into executable

Files from core_modules folder can be embadded into executable by enabling CORE_MODULES_IN_RES define in the SyNode.inc file (enabled by default).

Compiled core_modules.res resources is commited into the git repositiry.

To create your own resource pack use a /tool/core_res tool to prepare files for embadding.

To compile rc -> res we use mingq tools under linux

sudo apt install mingw-w64 mingw-w64-tools
cd SyNode
./tools/core_res -i ./core_modules/ -o ./.resources/
cd ./resources
x86_64-w64-mingw32-windres ./core_res.rc ../core_modules.res

From inside JS files embadded into resources can be evaluated using process.binding('modules').runInThisContextRes function

Form Pascal code using TSMEngine.EvaluateRes() function