I read about the architecture of Gobject introspection. On one side i have a .so dynamic library, on the other side i have a gir file (some sort of xml file) for javascript bindings, which leads to the compiled typelib file.
Most of my typelib files are in the directory /lib/x86_64-linux-gnu/girepository-1.0 for example WebKit2-4.0.typelib.
how do i know, that i have to use, (where are the definitions?)
const Webkit=imports.gi.WebKit2;
because i tried
const Webkit=imports.gi["WebKit2-4.0"];
or
const Webkit=imports.gi.WebKit;
if i use imports.gi , gjs searches for a typelib file. The directories where it searches, i can get with
const Gir=imports.gi.GIRepository; log (Gir.Repository.get_search_path());
for other ids then 'gi', imports[directory][...][filename], it searches in the directories defined in the array imports.searchPath for a Javascript file, right?
last problem - the references on gjs page: there are a lot of functions, which exists in the references, but then are not available. Are there any other good references outthere, with examples?
how do i know, that i have to use, (where are the definitions?)
Probably the easiest way to find a GIR import name you don't know is by browsing the API Documentation, such as for WebKit2
. Of course, you'll have to have the appropriate packages installed for those libraries.
for other ids then 'gi', imports[directory][...][filename], it searches in the directories defined in the array imports.searchPath for a Javascript file, right?
Yes, the imports.searchPath
array is for JavaScript sources. You can read about those imports in the GJS project documentation.
the references on gjs page: there are a lot of functions, which exists in the references, but then are not available. Are there any other good references outthere, with examples?
You'd have to be clearer about which GJS page you're looking at and which functions. Below are some links to documentation for GJS:
We also have Matrix channels for GJS where you can ask for help: