A CommonJS Runtime for GJS
Differently from jsgtk, this project has the following goals and features:
- 100% based on GJS. No wrapping, no runtime transpilation, pure ECMAScript 2015+ via SpiderMonkey 52+
- Gtk camelCase methods are provided only on demand and if needed. You are free to
require('Gtk')
, which will add camelCase method, or just regular GJSimports.gi.Gtk
, suggested to develop core modules too. - by default, the core brings in only most basic features to develop CommonJS modules for GJS:
- a
global
reference to the shared global GJS object - globally available timers such
setImmediate(fn, ...args)
,setInterval(fn, delay, ...args)
,setTimeout(fn, delay, ...args)
with also theirclearImmediate/Interval/Timeout(id)
counter functions - a spec compliant
require
function withrequire.cache
and arequire.resolve
implemented via the proper algorithm
- a
- all other core modules will be made available as soon as available
- each core module is developed a part:
- easier to maintain
- easier to update
- easier to track changes
- easier to also contribute 🎉
You need both npm and gjs available on your system.
Once you have both, you can install cgjs
either locally, and use it via npx cgjs
, or globally.
# global install example
npm install -g cgjs
# see default options
cgjs --help
By default, cgjs
includes few core modules, and following you can check their current status:
- assert module as @cgjs/assert
- buffer module as @cgjs/buffer
- child_process module as @cgjs/child_process
- cluster module as @cgjs/cluster
- console module as @cgjs/console
- crypto module as @cgjs/crypto
- dns module as @cgjs/dns
- events module as @cgjs/events
- fs module as @cgjs/fs
- http module as @cgjs/http
- http2 module as @cgjs/http2
- https module as @cgjs/https
- module module as @cgjs/module
- net module as @cgjs/net
- os module as @cgjs/os
- path module as @cgjs/path
- process module as @cgjs/process
- querystring module as @cgjs/querystring
- readline module as @cgjs/readline
- repl module as @cgjs/repl
- stream module as @cgjs/stream
- string_decoder module as @cgjs/string_decoder
- timers module as @cgjs/timers
- tls module as @cgjs/tls
- tty module as @cgjs/tty
- dgram module as @cgjs/dgram
- url module as @cgjs/url
- util module as @cgjs/util
- vm module as @cgjs/vm
- zlib module as @cgjs/zlib
You can install globally the cgjs-about utility and query it as described in the repository.
Together with grep
it's a great way to have a quick overview of every namespace.