Skip to content

Latest commit

 

History

History
172 lines (123 loc) · 4.3 KB

DEVELOPMENT.md

File metadata and controls

172 lines (123 loc) · 4.3 KB

Development

Install GObject Introspection Repository files:

# Ubuntu
sudo apt-get update && sudo apt-get install \
    libappindicator3-dev \
    libgda-5.0-dev \
    libgirepository1.0-dev \
    libgtk-3-dev \
    libgtk-4-dev \
    libgtksourceview-3.0-dev \
    libnotify-dev \
    libsoup2.4-dev \
    libsoup-3.0-dev \
    libwebkit2gtk-4.0-dev \
    libadwaita-1-dev

# Fedora
sudo dnf update && sudo dnf install \
    libappindicator-gtk3-devel \
    libgda-devel \
    gobject-introspection-devel \
    gtk3-devel \
    gtk4-devel \
    libsoup3-devel \
    gtksourceview3-devel \
    libnotify-devel \
    libsoup-devel \
    webkit2gtk3-devel \
    libadwaita-devel

GNOME Shell types

# Ubuntu
sudo apt-get install gnome-shell-common libmutter-10-dev libgcr-3-dev libgnome-desktop-3-dev

# Fedora
sudo dnf install gnome-shell gcr-devel gnome-desktop3-devel

Other GNOME types

# Fedora
sudo dnf install gnome-bluetooth-libs-devel

Checkout this repository:

git clone --recurse-submodules git@github.com:gjsify/ts-for-gir.git
cd ts-for-gir

Alternatively, you can fetch the submodules after cloning the repository:

cd ts-for-gir
git submodule update --init

Install the dependencies and build:

yarn install
yarn run build

Generate example type definitions:

yarn run test:girs:local:gtk4

Gir XML Format

See gobject-introspection/docs/gir-1.2.rnc for type definitions.

Debugging

It is strongly recommended to use the debugger. For Visual Studio Code there are some predefined launch configurations for it. The VSCode launch.json configuration is intended that Node was installed via NVM and yarn was installed globally using npm.

Take a look at the following video, to see how the debugging process looks like:

ts-for-gir-debugging.mp4

Yarn

We are using Yarn and its workspace feature. Yarn serves as a replacement for NPM, just like with NPM, you can run the scripts in the package.json. We have created some of them for development.

npm install -g yarn

Validate

To validate all your generated type definition files in this project run

yarn run validate:types:local

To validate only your type definition files for GJS

yarn run validate:types:gjs

To validate only your type definition files for node-gtk

yarn run validate:types:node

You can also validate a single type definition file like this

yarn run validate -- ./@types/gobject-2.0.d.ts

Test

Test gir files

We have a test which tries to generate the type definition files for all gir files from the vala-girs repository.

Before you can run this test you need to checkout the vala-girs submodule, to do that run this in the root of ts-for-gir:

git submodule update --init

Now you can run the test with

yarn run test:girs:local

FAQ

Problem: I get the following error:

FATAL ERROR: Scavenger: semi-space copy Allocation failed - JavaScript heap out of memory

Solution:

sudo sysctl -w vm.max_map_count=262144
NODE_OPTIONS=--max-old-space-size=25600 yarn run ...

Related Projects

  • gnome-gtk - Typescript bindings for gnome gtk
  • ts-gir - Typescript bindings for GJS
  • node-gir-typedef - TypeScript bindings for node-gir
  • gir2dts - The project this is inspired by
  • gir-dts-generator - The project that inspired this project
  • gjs-ts - Typescript bindings for GJS
  • Typescript Doclet - Experimental TypeScript binding generator written in Vala as a Valadoc extension
  • gi.ts - Highly accurate TypeScript bindings for GJS
  • gi-ts TypeScript Type definitions for the GNOME base stack (e.g. GLib, GObject)