From 4efbf7ae579366b6e4ec7f295d35b6701623697c Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Wed, 13 Mar 2024 22:13:58 +0100 Subject: [PATCH] Examples: Fix some global type settings --- examples/gjs/gio-2-dbus/package.json | 1 + examples/gjs/gio-2-dbus/tsconfig.json | 2 +- examples/gjs/gio-2-list-model/package.json | 3 +++ examples/gjs/gtk-4-custom-widget/index.ts | 5 ----- examples/gjs/gtk-4-custom-widget/package.json | 7 ++++++- examples/gjs/gtk-4-custom-widget/tsconfig.json | 2 +- examples/gjs/gtk-4-list-store/package.json | 1 + examples/gjs/gtk-4-list-store/tsconfig.json | 2 +- examples/gjs/gtk-4-template/package.json | 4 +++- .../templates/gjs/module-ambient.d.ts | 4 ++-- types | 2 +- yarn.lock | 10 ++++++++++ 12 files changed, 30 insertions(+), 13 deletions(-) diff --git a/examples/gjs/gio-2-dbus/package.json b/examples/gjs/gio-2-dbus/package.json index c1c190e31..2bde0c7e5 100644 --- a/examples/gjs/gio-2-dbus/package.json +++ b/examples/gjs/gio-2-dbus/package.json @@ -27,6 +27,7 @@ "typescript": "^5.4.2" }, "dependencies": { + "@girs/gio-2.0": "workspace:^", "@girs/gjs": "workspace:^" } } diff --git a/examples/gjs/gio-2-dbus/tsconfig.json b/examples/gjs/gio-2-dbus/tsconfig.json index 8b39e8c7f..0cc95fc22 100644 --- a/examples/gjs/gio-2-dbus/tsconfig.json +++ b/examples/gjs/gio-2-dbus/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "lib": ["ESNext"], - "types": ["@girs/gjs"], + "types": ["@girs/gjs", "@girs/gio-2.0"], "target": "ESNext", "module": "ESNext", "moduleResolution": "bundler", diff --git a/examples/gjs/gio-2-list-model/package.json b/examples/gjs/gio-2-list-model/package.json index 5eb18503c..f69f25c8c 100644 --- a/examples/gjs/gio-2-list-model/package.json +++ b/examples/gjs/gio-2-list-model/package.json @@ -21,5 +21,8 @@ "devDependencies": { "esbuild": "^0.20.1", "typescript": "^5.4.2" + }, + "dependencies": { + "@girs/gjs": "workspace:^" } } diff --git a/examples/gjs/gtk-4-custom-widget/index.ts b/examples/gjs/gtk-4-custom-widget/index.ts index a7da510d1..f79ae9419 100644 --- a/examples/gjs/gtk-4-custom-widget/index.ts +++ b/examples/gjs/gtk-4-custom-widget/index.ts @@ -1,10 +1,5 @@ // This example is based on https://github.com/romgrk/node-gtk/blob/master/examples/gtk-4-custom-widget.js -import '@girs/gjs'; -import '@girs/gjs/dom'; -import '@girs/gio-2.0'; -import '@girs/gtk-4.0'; - import GObject from 'gi://GObject?version=2.0'; import GLib from 'gi://GLib?version=2.0'; import Gtk from 'gi://Gtk?version=4.0'; diff --git a/examples/gjs/gtk-4-custom-widget/package.json b/examples/gjs/gtk-4-custom-widget/package.json index b9590e342..6cdff526e 100644 --- a/examples/gjs/gtk-4-custom-widget/package.json +++ b/examples/gjs/gtk-4-custom-widget/package.json @@ -25,8 +25,13 @@ "typescript": "^5.4.2" }, "dependencies": { + "@girs/freetype2-2.0": "workspace:^", "@girs/gio-2.0": "workspace:^", "@girs/gjs": "workspace:^", - "@girs/gtk-4.0": "workspace:^" + "@girs/glib-2.0": "workspace:^", + "@girs/gobject-2.0": "workspace:^", + "@girs/graphene-1.0": "workspace:^", + "@girs/gtk-4.0": "workspace:^", + "@girs/harfbuzz-0.0": "workspace:^" } } diff --git a/examples/gjs/gtk-4-custom-widget/tsconfig.json b/examples/gjs/gtk-4-custom-widget/tsconfig.json index 07b4d8cde..fcc8834ef 100644 --- a/examples/gjs/gtk-4-custom-widget/tsconfig.json +++ b/examples/gjs/gtk-4-custom-widget/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "lib": ["ESNext"], - "types": ["@girs/gjs", "@girs/gjs/dom", "@girs/gtk-4.0"], + "types": ["@girs/gjs", "@girs/gjs/dom", "@girs/gio-2.0", "@girs/gobject-2.0", "@girs/gtk-4.0", "@girs/graphene-1.0"], "target": "ESNext", "module": "ESNext", "moduleResolution": "bundler", diff --git a/examples/gjs/gtk-4-list-store/package.json b/examples/gjs/gtk-4-list-store/package.json index e650a4a5e..9ca4102ef 100644 --- a/examples/gjs/gtk-4-list-store/package.json +++ b/examples/gjs/gtk-4-list-store/package.json @@ -26,6 +26,7 @@ "dependencies": { "@girs/gio-2.0": "workspace:^", "@girs/gjs": "workspace:^", + "@girs/gobject-2.0": "workspace:^", "@girs/gtk-4.0": "workspace:^" } } diff --git a/examples/gjs/gtk-4-list-store/tsconfig.json b/examples/gjs/gtk-4-list-store/tsconfig.json index 14837b76f..6bc8c691b 100644 --- a/examples/gjs/gtk-4-list-store/tsconfig.json +++ b/examples/gjs/gtk-4-list-store/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "lib": ["ESNext"], - "types": ["@girs/gjs", "@girs/gjs/dom", "@girs/gtk-4.0"], + "types": ["@girs/gjs", "@girs/gjs/dom", "@girs/gtk-4.0", "@girs/gobject-2.0", "@girs/gio-2.0"], "target": "ESNext", "module": "ESNext", "moduleResolution": "bundler", diff --git a/examples/gjs/gtk-4-template/package.json b/examples/gjs/gtk-4-template/package.json index 6cda583d8..b8a09f045 100644 --- a/examples/gjs/gtk-4-template/package.json +++ b/examples/gjs/gtk-4-template/package.json @@ -27,6 +27,8 @@ "dependencies": { "@girs/gio-2.0": "workspace:^", "@girs/gjs": "workspace:^", - "@girs/gtk-4.0": "workspace:^" + "@girs/glib-2.0": "workspace:^", + "@girs/gtk-4.0": "workspace:^", + "@girs/harfbuzz-0.0": "workspace:^" } } diff --git a/packages/generator-typescript/templates/gjs/module-ambient.d.ts b/packages/generator-typescript/templates/gjs/module-ambient.d.ts index e4269ae8b..41e4b96e3 100644 --- a/packages/generator-typescript/templates/gjs/module-ambient.d.ts +++ b/packages/generator-typescript/templates/gjs/module-ambient.d.ts @@ -15,9 +15,9 @@ declare module 'gi://<%= name %>?version=<%= version %>' { export default <%- girModule.importNamespace -%>; } -<%# // Generate ambient module declarations Without version number if there are no conflicts or the target is an NPM package _%> +<%# // Generate ambient module declarations Without version number if this is the latest version _%> <%_ if (dep.isLatestVersion(pkg.namespace, pkg.version)) { _%> declare module 'gi://<%= name %>' { - export * from 'gi://<%= name %>?version=<%= version %>'; + export default 'gi://<%= name %>?version=<%= version %>'; } <%_ } _%> \ No newline at end of file diff --git a/types b/types index c855496a1..98ecb68d1 160000 --- a/types +++ b/types @@ -1 +1 @@ -Subproject commit c855496a1ae8cc52c78731766c9b7768f5f27aaf +Subproject commit 98ecb68d1105594e9386635e38a92e20d97c8b7c diff --git a/yarn.lock b/yarn.lock index 27b394478..5a132473f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6193,6 +6193,7 @@ __metadata: version: 0.0.0-use.local resolution: "@ts-for-gir-example/gio-2-dbus-example@workspace:examples/gjs/gio-2-dbus" dependencies: + "@girs/gio-2.0": "workspace:^" "@girs/gjs": "workspace:^" esbuild: "npm:^0.20.1" typescript: "npm:^5.4.2" @@ -6203,6 +6204,7 @@ __metadata: version: 0.0.0-use.local resolution: "@ts-for-gir-example/gio-2-list-model-example@workspace:examples/gjs/gio-2-list-model" dependencies: + "@girs/gjs": "workspace:^" esbuild: "npm:^0.20.1" typescript: "npm:^5.4.2" languageName: unknown @@ -6212,9 +6214,14 @@ __metadata: version: 0.0.0-use.local resolution: "@ts-for-gir-example/gjs-gtk-4-custom-widget-example@workspace:examples/gjs/gtk-4-custom-widget" dependencies: + "@girs/freetype2-2.0": "workspace:^" "@girs/gio-2.0": "workspace:^" "@girs/gjs": "workspace:^" + "@girs/glib-2.0": "workspace:^" + "@girs/gobject-2.0": "workspace:^" + "@girs/graphene-1.0": "workspace:^" "@girs/gtk-4.0": "workspace:^" + "@girs/harfbuzz-0.0": "workspace:^" "@ts-for-gir/cli": "workspace:^" esbuild: "npm:^0.20.1" typescript: "npm:^5.4.2" @@ -6378,6 +6385,7 @@ __metadata: dependencies: "@girs/gio-2.0": "workspace:^" "@girs/gjs": "workspace:^" + "@girs/gobject-2.0": "workspace:^" "@girs/gtk-4.0": "workspace:^" esbuild: "npm:^0.20.1" typescript: "npm:^5.4.2" @@ -6390,7 +6398,9 @@ __metadata: dependencies: "@girs/gio-2.0": "workspace:^" "@girs/gjs": "workspace:^" + "@girs/glib-2.0": "workspace:^" "@girs/gtk-4.0": "workspace:^" + "@girs/harfbuzz-0.0": "workspace:^" "@ts-for-gir/cli": "workspace:^" esbuild: "npm:^0.20.1" typescript: "npm:^5.4.2"