Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to toggle between package.json support + further cleanups from the gi.ts merge #176

Merged
merged 33 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5a4314a
CLI argument: Renamed packageYarn to workspace
JumpLink Jul 15, 2024
651635d
New generate option to to prevent ambient modules without version prefix
JumpLink Jul 15, 2024
d54d79b
Update types git submodule repo
JumpLink Jul 15, 2024
57c1121
Prepare the test for locally generated types
JumpLink Jul 15, 2024
e11d911
Initial work to make the package.json support optionally
JumpLink Jul 15, 2024
c25c345
Generate index files to export ambient, imports.gi and namespace
JumpLink Jul 16, 2024
6aff108
Fix relative import in ambient modules
JumpLink Jul 17, 2024
b9f56bb
Revert relative import in ambient modules, use NodeNext in tsconfig a…
JumpLink Jul 17, 2024
11eb0c7
Cleanup package.json mode
JumpLink Jul 17, 2024
3dc84ae
Generate ambient modules only if package.json support is disabled
JumpLink Jul 18, 2024
3d5ce1f
Cleanup ambient module wrapping
JumpLink Jul 18, 2024
abf5b30
Fix ambient module without version
JumpLink Jul 18, 2024
bda7d1c
GJS: Generate ambient modules only if package.json support is disabled
JumpLink Jul 18, 2024
371a753
Fix GJS core types for ambient modules without package.json support
JumpLink Jul 18, 2024
6b90cec
Upgrade dependencies
JumpLink Jul 18, 2024
9ae504d
GJS: Make use of Triple-Slash Directives to import dependencies if pa…
JumpLink Jul 19, 2024
2ef32ce
Cleanup util methods and duplicate synchronous methods removed
JumpLink Jul 19, 2024
e766f96
Resolve merge conflict
JumpLink Jul 19, 2024
2df1cae
Split ModuleGenerator, NpmPackage and TypeDefinitionGenerator into se…
JumpLink Jul 19, 2024
72b4d57
Fix get dependency in README-GJS.md template file
JumpLink Jul 19, 2024
cf64260
Do not create a directory for each module if package.json mode is dis…
JumpLink Jul 19, 2024
aebfcfc
Cleanup package.json
JumpLink Jul 19, 2024
7713ab2
Template files: Removed enviroment directory
JumpLink Jul 19, 2024
b77dc89
Moved ambient module generation to the template files
JumpLink Jul 19, 2024
7e6e59d
Moved dependencies generation to the template files
JumpLink Jul 19, 2024
d253312
Replace console with logger on remaining locations
JumpLink Jul 19, 2024
e6cf4cd
Renamed test: types-package -> types-locally
JumpLink Jul 19, 2024
744469f
Update gir files from latest GNOME OS
JumpLink Jul 19, 2024
06b3010
Generate index.d.ts files types without package.json support
JumpLink Jul 19, 2024
1fc9c4c
Cleanup CLI generation arguments
JumpLink Jul 19, 2024
2f225bd
Moved namespace generation to template + moved formatting to Template…
JumpLink Jul 19, 2024
b361244
Disabled json formatting for now
JumpLink Jul 19, 2024
c95701b
Bump version 4.0.0-beta.7
JumpLink Jul 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ examples/**/node_modules/
examples/**/dist/
examples/**/tsconfig.alias.json

# Locally generated types
@types/

tests/**/dist/

debug.txt
Expand Down
2 changes: 1 addition & 1 deletion .ts-for-gir.all.rc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default {
],
ignoreVersionConflicts: true,
promisify: true,
packageYarn: true,
workspace: true,
ignore: [
'*/Colorhug-1.0', // Duplicate of ColorHug-1.0
'*/GUPnP-DLNA-1.0', // Same namespace as GUPnP-1.0.gir, is this a bug or should we merge the type definitions?
Expand Down
4 changes: 3 additions & 1 deletion .ts-for-gir.packages-all.rc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ export default {
],
ignoreVersionConflicts: true,
promisify: true,
packageYarn: true,
workspace: true,
onlyVersionPrefix: false,
package: true,
}
6 changes: 3 additions & 3 deletions .ts-for-gir.packages-gtk4.rc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import allPackagesConfig from './.ts-for-gir.packages-all.rc.js';
import gtk4PackagesConfig from './.ts-for-gir.gtk4.rc.js';

export default {
...allPackagesConfig,
modules: ['Gtk-4.0', 'Adw-1.0']
...gtk4PackagesConfig,
package: true,
}
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
"typescript.enablePromptUseWorkspaceTsdk": true,
"cSpell.words": [
"outdir"
]
}
2 changes: 1 addition & 1 deletion .yarn/sdks/prettier/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prettier",
"version": "3.3.2-sdk",
"version": "3.3.3-sdk",
"main": "./index.cjs",
"type": "commonjs",
"bin": "./bin/prettier.cjs"
Expand Down
49 changes: 16 additions & 33 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,19 @@ Install the dependencies and build:

```bash
yarn install
yarn run build
yarn build
```

Generate example type definitions:

```bash
yarn run test:girs:local:gtk4
yarn build:types:packages:gtk4
```

## Gir XML Format

See [gobject-introspection/docs/gir-1.2.rnc](https://gitlab.gnome.org/GNOME/gobject-introspection/-/blob/master/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](https://github.com/nvm-sh/nvm) and yarn was installed globally using npm.

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

https://user-images.githubusercontent.com/1073989/150143112-1c0a2dab-3d4c-4472-818f-8404a620cc53.mp4

## Yarn

We are using [Yarn](https://yarnpkg.com/) and its [workspace feature](https://yarnpkg.com/features/workspaces).
Expand All @@ -100,30 +91,12 @@ We have created some of them for development.
npm install -g yarn
```

### Validate
## Validate

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

```bash
yarn run validate:types:local
```

To validate only your type definition files for GJS

```bash
yarn run validate:types:gjs
```

To validate only your type definition files for node-gtk

```bash
yarn run validate:types:node
```

You can also validate a single type definition file like this

```bash
yarn run validate -- ./@types/gobject-2.0.d.ts
yarn validate:types:packages
```

## Test
Expand All @@ -141,9 +114,19 @@ git submodule update --init
Now you can run the test with

```bash
yarn run test:girs:local
yarn test:girs:packages
```

## Update gir files

To update the gir files we have introduced a new cli command `copy`, you can run it with our default settings as follows:

```bash
yarn copy:girs
```

This copies the latest gir file found on your machine into this repository, so that we can ensure that all developers can use the same gir files and that we always use the latest versions if possible.

# FAQ

Problem: I get the following error:
Expand All @@ -156,7 +139,7 @@ Solution:

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

# Related Projects
Expand Down
4 changes: 2 additions & 2 deletions examples/adw-1-hello/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/adw-1-hello-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "Simple GJS Typescript hello-world example using Libadwaita",
"type": "module",
"private": true,
Expand All @@ -19,7 +19,7 @@
"license": "MIT",
"devDependencies": {
"typescript": "^5.5.3",
"vite": "^5.3.3"
"vite": "^5.3.4"
},
"dependencies": {
"@girs/adw-1": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion examples/gio-2-cat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gio-2-cat-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "Simple GJS Gtk 3 example app that shows how to use Gio-2.0 to read a file from the local file system",
"main": "index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion examples/gio-2-dbus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gio-2-dbus-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "GJS example showing how to build a DBus server/client",
"main": "index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion examples/gio-2-list-model/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gio-2-list-model-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "An example of implementing the GListModel interface in GJS",
"main": "index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion examples/glib-2-spawn-command/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/glib-2-spawn-command-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/glib-2-variant/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/glib-2-variant-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "ts-for-gir GVariant example based on https://gjs.guide/guides/glib/gvariant.html",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-3-browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-3-browser-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"type": "module",
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-3-builder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-3-builder-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"type": "module",
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-3-calc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-3-calc-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "Simple GJS Gtk 3 calculator example app",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-3-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-3-editor-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"type": "module",
"targets": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-3-gettext/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-3-gettext-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "Simple GJS Gtk 3 example app that shows how you can translate strings with gettext",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-3-hello-2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-3-hello-2-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "Simple GJS Gtk 3 example app to demonstrate how you can connect to Gtk signals",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-3-hello/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-3-hello-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"type": "module",
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-3-template/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-3-template-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "Simple GJS Gtk 3 example app to demonstrate how you can use .ui template XML files",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-3-webkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-3-webkit-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "Simple GJS Gtk 3 example app to demonstrate how you can use WebKit2",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-4-application/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-4-application-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "Simple GJS Gtk 4 example app to demonstrate how you can use and extend Gtk.Application",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-4-custom-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gjs-gtk-4-custom-widget-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "This example shows the usage of custom widgets and virtual functions in GJS",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-4-list-store/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-4-list-store-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "It takes the hassle away from building Gtk4 application in Python So you can create a cool application, without all the boilerplate code",
"type": "module",
"private": true,
Expand Down
6 changes: 3 additions & 3 deletions examples/gtk-4-template-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ts-for-gir-example/gtk-4-template-vite",
"version": "4.0.0-beta.6",
"description": "Simple GJS Gtk 4 example app to demonstrate how you can use .ui template XML files over a bundler",
"version": "4.0.0-beta.7",
"description": "Simple GJS Gtk 4 example app to demonstrate how you can use .ui template XML files over the Vite bundler",
"type": "module",
"private": true,
"scripts": {
Expand All @@ -19,7 +19,7 @@
"license": "MIT",
"devDependencies": {
"typescript": "^5.5.3",
"vite": "^5.3.3"
"vite": "^5.3.4"
},
"dependencies": {
"@girs/gdk-4.0": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-4-template/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-4-template",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "Simple GJS Gtk 4 example app to demonstrate how you can use .ui template XML files over GJS itself",
"type": "module",
"private": true,
Expand Down
6 changes: 0 additions & 6 deletions examples/run-async/.ts-for-girrc.json

This file was deleted.

33 changes: 0 additions & 33 deletions examples/run-async/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,7 @@
// SPDX-FileCopyrightText: 2009 Red Hat, Inc.
// Based on https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/gio-cat.js

/*
* Make sure you have a non english locale installed, for example fr_FR and run
* LANGUAGE=fr_FR gjs gettext.js
* the label should show a translation of 'Print help'
*/

// import Adw from "gi://Adw";
// import GLib from "gi://GLib";
import Gio from "gi://Gio";
// import Gtk from "gi://Gtk?version=4.0";

// const mainLoop = new GLib.MainLoop(null, false);
// mainLoop.runAsync().then(() => {
// log(`Exited main loop`);
// }).catch((error) => {
// logError(error);
// });

const gioApp = new Gio.Application();
gioApp.runAsync(ARGV).then((exitStatus: number) => {
Expand All @@ -27,23 +11,6 @@ gioApp.runAsync(ARGV).then((exitStatus: number) => {
logError(error);
});

// const gtkApp = new Gtk.Application();
// gtkApp.runAsync(ARGV).then((exitStatus: number) => {
// log(`Exited with status: ${exitStatus}`);
// }).catch((error) => {
// logError(error);
// });

// const adwApp = new Adw.Application();
// adwApp.runAsync(ARGV).then((exitStatus: number) => {
// log(`Exited with status: ${exitStatus}`);
// }).catch((error) => {
// logError(error);
// });

setTimeout(() => {
// mainLoop.quit();
gioApp.quit();
// gtkApp.quit();
// adwApp.quit();
}, 1000);
2 changes: 1 addition & 1 deletion examples/run-async/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/run-async-example",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "Simple GJS Gtk 3 example app that shows how you can translate strings with gettext",
"type": "module",
"private": true,
Expand Down
Loading
Loading