... | ... | @@ -6,68 +6,30 @@ If you use it, especially for GNOME-related projects, please follow the [Style G |
|
|
|
|
|
## Documentation
|
|
|
|
|
|
### Gnome API
|
|
|
|
|
|
Documentation for Gnome APIs (GLib, GObject, Gtk, etc) is currently hosted at https://devdocs.baznga.org/.
|
|
|
|
|
|
There are also a growing number of usage examples in the GitLab repository under [examples/][gjs-examples] and thorough tests of language features in the [test suite][gjs-tests].
|
|
|
GJS 1.50 is built on Mozilla's SpiderMonkey 52 and ES6 support (ECMAScript 2015) is nearly complete. Generally you can use the [MDN JavaScript Reference][mdn-reference] and check the feature's [Browser Compatibility][mdn-compatibility] table for Firefox.
|
|
|
|
|
|
### JavaScript
|
|
|
To confirm if or when a language feature was implemented in GJS (e.g. `Object.values()`, `async function`), review [NEWS][gjs-news] in the GitLab repository. In many cases you can support older versions of GJS using [polyfills][mdn-polyfills] and [legacy-style GJS classes](Modules#lang).
|
|
|
|
|
|
GJS 1.50 is based on Mozilla's SpiderMonkey 52 and ES6 support (AKA ECMAScript 2015) is nearly complete, while still including support for "legacy" style GJS classes.
|
|
|
GJS includes some built-in modules like Cairo and Gettext, as well as helpers for some core APIs like DBus and Variants. See the [Modules](Modules) page for an overview of the built-in modules and their usage.
|
|
|
|
|
|
If you are curious when (or if) a language feature landed or targeting a range of GJS versions, review [NEWS][gjs-news] in the GitLab repository. In many cases you can support older versions of GJS using [polyfills][mdn-polyfills] and legacy-style classes.
|
|
|
|
|
|
[gjs-examples]: https://gitlab.gnome.org/GNOME/gjs/tree/master/examples
|
|
|
[gjs-news]: https://gitlab.gnome.org/GNOME/gjs/raw/master/NEWS
|
|
|
[gjs-tests]: https://gitlab.gnome.org/GNOME/gjs/blob/master/installed-tests/js
|
|
|
[mdn-compatibility]: https://developer.mozilla.org//docs/MDN/Contribute/Structures/Compatibility_tables
|
|
|
[mdn-polyfills]: https://developer.mozilla.org/docs/Glossary/Polyfill
|
|
|
[mdn-reference]: https://developer.mozilla.org/docs/Web/JavaScript/Reference
|
|
|
|
|
|
### Mapping
|
|
|
|
|
|
Please see the [Mapping](Mapping) page for details and examples of mapping GLib function and constant names to GJS.
|
|
|
|
|
|
### Modules
|
|
|
|
|
|
GJS includes some built-in modules that are mostly undocumented containing a number of useful helper functions, such as the Gettext module, and API compatibility, such as the Cairo or Mainloop modules.
|
|
|
|
|
|
Please see the [Modules](Modules) page for an overview of the built-in modules and their usage.
|
|
|
|
|
|
|
|
|
### Overrides
|
|
|
|
|
|
GJS has overrides for some Gnome APIs, mostly for compatibility, but also providing some useful utilities.
|
|
|
|
|
|
* [GLib](https://gitlab.gnome.org/GNOME/gjs/blob/master/modules/overrides/GLib.js): GVariant, GBytes compatibility.
|
|
|
|
|
|
* `GLib.log_structured()`: Wrapper for g_log_variant()
|
|
|
* `GLib.Bytes.toArray()`: Convert a GBytes object to a native Array
|
|
|
* `GLib.Variant.unpack()`: Unpack a variant to a native type
|
|
|
* `GLib.Variant.deep_unpack()`: Recursively unpack
|
|
|
* [GObject](https://gitlab.gnome.org/GNOME/gjs/blob/master/modules/overrides/GObject.js): Mostly GObject implementation (properties, signals, GType mapping). May be useful as a reference.
|
|
|
* [Gio](https://gitlab.gnome.org/GNOME/gjs/blob/master/modules/overrides/Gio.js): Includes numerous utilities for DBus that will documented further at a later date.
|
|
|
|
|
|
* `Gio.DBus.session, Gio.DBus.system`
|
|
|
### Gnome API
|
|
|
|
|
|
Convenience properties that wrap Gio.bus_get_sync() to return DBus session/system connection
|
|
|
* `Gio.DBusInterfaceInfo.new_for_xml(xmlString)`: return a new Gio.DBusNodeInfo
|
|
|
* `Gio.DBusProxy.makeProxyWrapper(xmlString|Gio.DBusNodeInfo)`
|
|
|
There is now official [Gnome API Documentation][gjs-docs] including everything from GLib and Gtk to Soup and WebKit2.
|
|
|
|
|
|
Utility for creating DBus clients (See [here][old-dbus-example] for the original example).
|
|
|
The [Mapping](Mapping) page has an overview of Gnome API usage in GJS such as subclassing, constants and flags, functions with multiple return values, and more.
|
|
|
|
|
|
Returns a `function(bus, name, object, asyncCallback, cancellable)` which can be called to return a new `Gio.DBusProxy` for the first interface node of `xmlString|Gio.DBusNodeInfo`.
|
|
|
* `Gio.DBusExportedObject.wrapJSObject(Gio.DbusInterfaceInfo, jsObj)`
|
|
|
There are also a growing number of [examples][gjs-examples] and thorough tests of language features in the [test suite][gjs-tests].
|
|
|
|
|
|
Wrap the object instance `jsObj` which should implement the interface described by `Gio.DbusInterfaceInfo` and return an object with methods:
|
|
|
[gjs-docs]: https://devdocs.baznga.org/
|
|
|
[gjs-examples]: https://gitlab.gnome.org/GNOME/gjs/tree/master/examples
|
|
|
[gjs-news]: https://gitlab.gnome.org/GNOME/gjs/raw/master/NEWS
|
|
|
[gjs-tests]: https://gitlab.gnome.org/GNOME/gjs/blob/master/installed-tests/js
|
|
|
|
|
|
* `export(busConnection, objectPath)`
|
|
|
* `unexport()`
|
|
|
* `flush()`
|
|
|
* `emit_signal(name, variant)`
|
|
|
* `emit_property_changed(name, variant)`
|
|
|
* [Gtk](https://gitlab.gnome.org/GNOME/gjs/blob/master/modules/overrides/Gtk.js): Mostly composite template implementation. Nothing useful externally.
|
|
|
|
|
|
[old-dbus-example]: https://wiki.gnome.org/Gjs/Examples/DBusClient
|
|
|
|
|
|
## Standalone Applications
|
|
|
|
... | ... | |