https://github.com/clayrisser/babel-plugin-gjs
babel plugin for gjs
https://github.com/clayrisser/babel-plugin-gjs
babel cgjs gjs node plugin
Last synced: about 1 month ago
JSON representation
babel plugin for gjs
- Host: GitHub
- URL: https://github.com/clayrisser/babel-plugin-gjs
- Owner: clayrisser
- License: mit
- Created: 2019-08-20T19:27:16.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2023-07-11T06:16:46.000Z (almost 2 years ago)
- Last Synced: 2025-04-22T15:08:09.644Z (about 2 months ago)
- Topics: babel, cgjs, gjs, node, plugin
- Language: JavaScript
- Homepage: https://codejam.ninja
- Size: 1.11 MB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-gjs
[](https://github.com/codejamninja/babel-plugin-gjs)
> babel plugin for gjs
For best results, run transpiled code with [CGJS](https://github.com/cgjs/cgjs)
Please ★ this repo if you found it useful ★ ★ ★
## Features
#### Wraps classes with `GObject.registerClass`
##### Before
```js
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
```js
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
```sh
npm install --save-dev babel-plugin-gjs
```_.babelrc_
```json
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "4"
}
}
]
],
"plugins": ["gjs"]
}
```## Dependencies
- [CGJS](https://github.com/cgjs/cgjs)
- [GJS](https://wiki.gnome.org/Projects/Gjs)
- [NodeJS](https://nodejs.org)## Usage
```sh
babel src -d lib
cgjs lib
```## Support
Submit an [issue](https://github.com/codejamninja/babel-plugin-gjs/issues/new)
## Screenshots
[Contribute](https://github.com/codejamninja/babel-plugin-gjs/blob/master/CONTRIBUTING.md) a screenshot
## Contributing
Review the [guidelines for contributing](https://github.com/codejamninja/babel-plugin-gjs/blob/master/CONTRIBUTING.md)
## License
[MIT License](https://github.com/codejamninja/babel-plugin-gjs/blob/master/LICENSE)
[Jam Risser](https://codejam.ninja) © 2018
## Changelog
Review the [changelog](https://github.com/codejamninja/babel-plugin-gjs/blob/master/CHANGELOG.md)
## Credits
- [Jam Risser](https://codejam.ninja) - Author
## Support on Liberapay
A ridiculous amount of coffee ☕ ☕ ☕ was consumed in the process of building this project.
[Add some fuel](https://liberapay.com/codejamninja/donate) if you'd like to keep me going!
[](https://liberapay.com/codejamninja/donate)
[](https://liberapay.com/codejamninja/donate)