Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
GJS TypeScript type definitions for Gjs using ts-for-gir v3.2.4.
GJS is a JavaScript runtime for the GNOME ecosystem. Using GJS and the type definitions in this NPM package, you can build GTK applications in JavaScript or TypeScript with type checking, better autocompletion and inline documentations.
To use this type definitions, install them with NPM:
npm install @girs/gjs
You can import this package into your project like this:
import Gjs from '@girs/gjs';
Or if you prefer CommonJS, you can also use this:
const Gjs = require('@girs/gjs');
After the import, the global types of GJS are also available:
import '@girs/gjs';
print('Hello World from print');
const ByteArray = imports.byteArray;
// And so on...
Some types that conflict with the DOM are outsourced to allow frameworks like Gjsify to rebuild the DOM API without causing type conflicts. But you can easily import them:
import '@girs/gjs/dom';
console.log('Hello World from console');
const encoder = new TextEncoder();
const encoded = encoder.encode('𝓽𝓮𝔁𝓽');
setTimeout(() => {
// ...
}, 1000);
// And so on...
To avoid a type conflict with the DOM types it is recommended to either modify your tsconfig.json
or jsconfig.json
file to exclude the DOM lib, or to enable the noLib
property.
You can import the built in ambient modules of GJS.
For this you need to include the @girs/gjs
or @girs/gjs/ambient
in your tsconfig
or entry point Typescript file:
index.ts
:
import '@girs/gjs'
tsconfig.json
:
{
"compilerOptions": {
...
},
"include": ["@girs/gjs"],
...
}
Now you can import gettext
, system
and cairo
in ESM style with Typescript support:
import gettext from 'gettext';
import system from 'system';
import cairo from 'cairo';
If you want to have types for GObject Introspection modules, you have to add them to your dependencies and import them as well, see the description of these modules, e.g. gtk-4.0, gio-2.0, adw-1 and much more.
These types will then be available to you:
import '@girs/gjs'
import '@girs/gjs/dom'
import '@girs/gio-2.0'
import '@girs/gtk-4.0'
import '@girs/adw-1'
import Gio from 'gi://Gio?version=2.0';
import Gtk from 'gi://Gtk?version=4.0';
import Adwaita from 'gi://adw?version=1';
const button = new Gtk.Button();
// ...
Depending on your project configuration, it is recommended to use a bundler like esbuild. You can find examples using different bundlers here.
All existing pre-generated packages can be found on gjsify/types.
FAQs
GJS TypeScript type definitions for Gjs
The npm package @girs/gjs receives a total of 5,611 weekly downloads. As such, @girs/gjs popularity was classified as popular.
We found that @girs/gjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.