Skip to content

clayrisser/babel-plugin-gjs

Repository files navigation

babel-plugin-gjs

GitHub stars

babel plugin for gjs

For best results, run transpiled code with CGJS

Please ★ this repo if you found it useful ★ ★ ★

Features

Wraps classes with GObject.registerClass

Before
class MyWindow extends Gtk.Window {
  constructor() {
    super({ title: 'Hello World' });
    this.button = new Gtk.Button({ label: 'Click here' });
    this.button.connect('clicked', this.handleClicked);
    this.add(this.button);
  }

  handleClicked() {
    console.log('Button clicked');
  }
}
After
const GObject = imports.gi.GObject;

const MyWindow = GObject.registerClass(
  class MyWindow extends Gtk.Window {
    _init() {
      super._init({ title: 'Hello World' });
      this.button = new Gtk.Button({ label: 'Click here' });
      this.button.connect('clicked', this.handleClicked);
      this.add(this.button);
    }

    handleClicked() {
      console.log('Button clicked');
    }
  }
);

Installation

npm install --save-dev babel-plugin-gjs

.babelrc

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "targets": {
          "node": "4"
        }
      }
    ]
  ],
  "plugins": ["gjs"]
}

Dependencies

Usage

babel src -d lib
cgjs lib

Support

Submit an issue

Screenshots

Contribute a screenshot

Contributing

Review the guidelines for contributing

License

MIT License

Jam Risser © 2018

Changelog

Review the changelog

Credits

Support on Liberapay

A ridiculous amount of coffee ☕ ☕ ☕ was consumed in the process of building this project.

Add some fuel if you'd like to keep me going!

Liberapay receiving Liberapay patrons