From f67c2367f342d69bcb2fda4eca43910f02b52b3c Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Sun, 21 Jul 2024 18:56:44 +0200 Subject: [PATCH] Fix for invalid enums, should fix #181 --- examples/adw-1-hello/package.json | 2 +- examples/gio-2-cat/package.json | 2 +- examples/gio-2-dbus/package.json | 2 +- examples/gio-2-list-model/package.json | 2 +- examples/glib-2-spawn-command/package.json | 2 +- examples/glib-2-variant/package.json | 2 +- examples/gtk-3-browser/package.json | 2 +- examples/gtk-3-builder/package.json | 2 +- examples/gtk-3-calc/package.json | 2 +- examples/gtk-3-editor/package.json | 2 +- examples/gtk-3-hello-2/package.json | 2 +- examples/gtk-3-hello/package.json | 2 +- examples/gtk-3-template/package.json | 2 +- examples/gtk-3-webkit/package.json | 2 +- examples/gtk-4-application/package.json | 2 +- examples/gtk-4-custom-widget/package.json | 2 +- examples/gtk-4-gettext/package.json | 2 +- examples/gtk-4-list-store/package.json | 2 +- examples/gtk-4-template-vite/package.json | 2 +- examples/gtk-4-template/package.json | 2 +- examples/run-async/package.json | 2 +- examples/soup-3-http/package.json | 2 +- examples/soup-3-websocket/package.json | 2 +- examples/timers/package.json | 2 +- package.json | 4 ++-- packages/cli/package.json | 2 +- packages/generator-base/package.json | 2 +- packages/generator-html-doc/package.json | 2 +- packages/generator-typescript/package.json | 2 +- .../generator-typescript/src/module-generator.ts | 12 +++++++----- packages/lib/package.json | 2 +- types | 2 +- 32 files changed, 39 insertions(+), 37 deletions(-) diff --git a/examples/adw-1-hello/package.json b/examples/adw-1-hello/package.json index b2ebab47..e280f166 100644 --- a/examples/adw-1-hello/package.json +++ b/examples/adw-1-hello/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/adw-1-hello-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Simple GJS Typescript hello-world example using Libadwaita", "type": "module", "private": true, diff --git a/examples/gio-2-cat/package.json b/examples/gio-2-cat/package.json index 52cbd72e..3cceda1a 100644 --- a/examples/gio-2-cat/package.json +++ b/examples/gio-2-cat/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gio-2-cat-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "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", diff --git a/examples/gio-2-dbus/package.json b/examples/gio-2-dbus/package.json index e3832c83..a923e1cc 100644 --- a/examples/gio-2-dbus/package.json +++ b/examples/gio-2-dbus/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gio-2-dbus-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "GJS example showing how to build a DBus server/client", "main": "index.js", "type": "module", diff --git a/examples/gio-2-list-model/package.json b/examples/gio-2-list-model/package.json index 0058898d..0e9f9c60 100644 --- a/examples/gio-2-list-model/package.json +++ b/examples/gio-2-list-model/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gio-2-list-model-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "An example of implementing the GListModel interface in GJS", "main": "index.js", "type": "module", diff --git a/examples/glib-2-spawn-command/package.json b/examples/glib-2-spawn-command/package.json index 9d7439ef..13ba7033 100644 --- a/examples/glib-2-spawn-command/package.json +++ b/examples/glib-2-spawn-command/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/glib-2-spawn-command-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "", "type": "module", "private": true, diff --git a/examples/glib-2-variant/package.json b/examples/glib-2-variant/package.json index f721e804..0bb7eeec 100644 --- a/examples/glib-2-variant/package.json +++ b/examples/glib-2-variant/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/glib-2-variant-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "ts-for-gir GVariant example based on https://gjs.guide/guides/glib/gvariant.html", "type": "module", "private": true, diff --git a/examples/gtk-3-browser/package.json b/examples/gtk-3-browser/package.json index be3f6731..5bd8beba 100644 --- a/examples/gtk-3-browser/package.json +++ b/examples/gtk-3-browser/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-3-browser-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "type": "module", "private": true, "scripts": { diff --git a/examples/gtk-3-builder/package.json b/examples/gtk-3-builder/package.json index 4eda21aa..d849eedb 100644 --- a/examples/gtk-3-builder/package.json +++ b/examples/gtk-3-builder/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-3-builder-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "type": "module", "private": true, "scripts": { diff --git a/examples/gtk-3-calc/package.json b/examples/gtk-3-calc/package.json index b6f2281c..903cc98d 100644 --- a/examples/gtk-3-calc/package.json +++ b/examples/gtk-3-calc/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-3-calc-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Simple GJS Gtk 3 calculator example app", "type": "module", "private": true, diff --git a/examples/gtk-3-editor/package.json b/examples/gtk-3-editor/package.json index 89007016..843bd94d 100644 --- a/examples/gtk-3-editor/package.json +++ b/examples/gtk-3-editor/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-3-editor-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "type": "module", "targets": { ".": { diff --git a/examples/gtk-3-hello-2/package.json b/examples/gtk-3-hello-2/package.json index 187c0786..5b5a5d77 100644 --- a/examples/gtk-3-hello-2/package.json +++ b/examples/gtk-3-hello-2/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-3-hello-2-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Simple GJS Gtk 3 example app to demonstrate how you can connect to Gtk signals", "type": "module", "private": true, diff --git a/examples/gtk-3-hello/package.json b/examples/gtk-3-hello/package.json index 614c9b1f..8c6e0a11 100644 --- a/examples/gtk-3-hello/package.json +++ b/examples/gtk-3-hello/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-3-hello-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "type": "module", "private": true, "scripts": { diff --git a/examples/gtk-3-template/package.json b/examples/gtk-3-template/package.json index dbc69b10..7ae8df67 100644 --- a/examples/gtk-3-template/package.json +++ b/examples/gtk-3-template/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-3-template-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Simple GJS Gtk 3 example app to demonstrate how you can use .ui template XML files", "type": "module", "private": true, diff --git a/examples/gtk-3-webkit/package.json b/examples/gtk-3-webkit/package.json index f993940c..cc8a78fe 100644 --- a/examples/gtk-3-webkit/package.json +++ b/examples/gtk-3-webkit/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-3-webkit-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Simple GJS Gtk 3 example app to demonstrate how you can use WebKit2", "type": "module", "private": true, diff --git a/examples/gtk-4-application/package.json b/examples/gtk-4-application/package.json index 3021c009..136317d7 100644 --- a/examples/gtk-4-application/package.json +++ b/examples/gtk-4-application/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-4-application-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Simple GJS Gtk 4 example app to demonstrate how you can use and extend Gtk.Application", "type": "module", "private": true, diff --git a/examples/gtk-4-custom-widget/package.json b/examples/gtk-4-custom-widget/package.json index 53b29b72..dfa7e24c 100644 --- a/examples/gtk-4-custom-widget/package.json +++ b/examples/gtk-4-custom-widget/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gjs-gtk-4-custom-widget-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "This example shows the usage of custom widgets and virtual functions in GJS", "type": "module", "private": true, diff --git a/examples/gtk-4-gettext/package.json b/examples/gtk-4-gettext/package.json index 8943dc4a..5a054978 100644 --- a/examples/gtk-4-gettext/package.json +++ b/examples/gtk-4-gettext/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-4-gettext-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Simple GJS Gtk 3 example app that shows how you can translate strings with gettext", "type": "module", "private": true, diff --git a/examples/gtk-4-list-store/package.json b/examples/gtk-4-list-store/package.json index 41f6b5b1..b93e414e 100644 --- a/examples/gtk-4-list-store/package.json +++ b/examples/gtk-4-list-store/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-4-list-store-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "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, diff --git a/examples/gtk-4-template-vite/package.json b/examples/gtk-4-template-vite/package.json index 63fb4bdc..75cf552c 100644 --- a/examples/gtk-4-template-vite/package.json +++ b/examples/gtk-4-template-vite/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-4-template-vite", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "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, diff --git a/examples/gtk-4-template/package.json b/examples/gtk-4-template/package.json index 1f0abbeb..00f72099 100644 --- a/examples/gtk-4-template/package.json +++ b/examples/gtk-4-template/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-4-template", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Simple GJS Gtk 4 example app to demonstrate how you can use .ui template XML files over GJS itself", "type": "module", "private": true, diff --git a/examples/run-async/package.json b/examples/run-async/package.json index e959ed3e..38df48aa 100644 --- a/examples/run-async/package.json +++ b/examples/run-async/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/run-async-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Simple GJS Gtk 3 example app that shows how you can translate strings with gettext", "type": "module", "private": true, diff --git a/examples/soup-3-http/package.json b/examples/soup-3-http/package.json index 6d59672c..269113a7 100644 --- a/examples/soup-3-http/package.json +++ b/examples/soup-3-http/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/soup-3-http-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "GJS example showing how to build a http server/client using Soap 3", "type": "module", "private": true, diff --git a/examples/soup-3-websocket/package.json b/examples/soup-3-websocket/package.json index 3dba1576..296f226d 100644 --- a/examples/soup-3-websocket/package.json +++ b/examples/soup-3-websocket/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/soup-3-websocket-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Simple GJS Soup 3 example app to demonstrate how you can use WebSockets", "type": "module", "private": true, diff --git a/examples/timers/package.json b/examples/timers/package.json index 8e690c6d..5153a38e 100644 --- a/examples/timers/package.json +++ b/examples/timers/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/timers-example", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Simple GJS Gtk 4 example app to demonstrate how you can use .ui template XML files", "type": "module", "private": true, diff --git a/package.json b/package.json index 7d5f1ad9..2239458b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-for-gir", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Typescript .d.ts generator from GIR for gjs", "type": "module", "private": true, @@ -39,7 +39,7 @@ "build:types:packages:gtk4:no-install": "yarn ts-for-gir generate --configName='.ts-for-gir.packages-gtk4.rc.js'", "build:types:packages:gtk4": "yarn build:types:packages:gtk4:no-install && yarn install", "copy:girs": "yarn start copy --configName='.ts-for-gir.copy-all.rc.js' --verbose", - "validate": "yarn workspaces foreach -v --all --parallel run validate", + "validate": "yarn workspaces foreach -v --all --parallel run validate && yarn validate:types:packages", "validate:types": "yarn workspaces foreach -v --all --parallel run validate:types", "validate:examples": "yarn workspaces foreach -v --all --include '@ts-for-gir-example/*' --parallel run validate", "validate:types:packages": "yarn workspaces foreach -v --all --parallel --include '@girs/*' run test", diff --git a/packages/cli/package.json b/packages/cli/package.json index 37439e67..39fd6df3 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir/cli", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "TypeScript type definition generator for GObject introspection GIR files", "module": "lib/index.js", "main": "lib/index.js", diff --git a/packages/generator-base/package.json b/packages/generator-base/package.json index 567bacd2..58e36e87 100644 --- a/packages/generator-base/package.json +++ b/packages/generator-base/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir/generator-base", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Base generator for ts-for-gir", "module": "lib/index.js", "main": "lib/index.js", diff --git a/packages/generator-html-doc/package.json b/packages/generator-html-doc/package.json index 2e8f96b9..5658bb26 100644 --- a/packages/generator-html-doc/package.json +++ b/packages/generator-html-doc/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir/generator-html-doc", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "HTML Documentation generator for ts-for-gir", "module": "lib/index.js", "main": "lib/index.js", diff --git a/packages/generator-typescript/package.json b/packages/generator-typescript/package.json index f4d7b707..8031dd62 100644 --- a/packages/generator-typescript/package.json +++ b/packages/generator-typescript/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir/generator-typescript", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "TypeScript type definition generator for ts-for-gir", "module": "lib/index.js", "main": "lib/index.js", diff --git a/packages/generator-typescript/src/module-generator.ts b/packages/generator-typescript/src/module-generator.ts index c1ec64dd..59666953 100644 --- a/packages/generator-typescript/src/module-generator.ts +++ b/packages/generator-typescript/src/module-generator.ts @@ -779,11 +779,6 @@ export class ModuleGenerator extends FormatGenerator { const desc: string[] = [] const { name, namespace } = girEnum - desc.push(`export namespace ${name} {`) - desc.push(` export const $gtype: ${namespace.namespace !== 'GObject' ? 'GObject.' : ''}GType<${name}>;`) - desc.push(`}`) - desc.push(``) - desc.push(...this.addGirDocComment(girEnum.doc, [], indentCount)) // Enums can't have numerical keys @@ -797,6 +792,13 @@ export class ModuleGenerator extends FormatGenerator { return desc } + desc.push(``) + desc.push(...this.addGirDocComment(girEnum.doc, [], indentCount)) + desc.push(`export namespace ${name} {`) + desc.push(` export const $gtype: ${namespace.namespace !== 'GObject' ? 'GObject.' : ''}GType<${name}>;`) + desc.push(`}`) + desc.push(``) + desc.push(this.generateExport('enum', name, '{', indentCount)) if (girEnum.members) { for (const girEnumMember of girEnum.members.values()) { diff --git a/packages/lib/package.json b/packages/lib/package.json index f6bd8694..99367e1c 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir/lib", - "version": "4.0.0-beta.9", + "version": "4.0.0-beta.10", "description": "Typescript .d.ts generator from GIR for gjs", "module": "lib/index.js", "main": "lib/index.js", diff --git a/types b/types index 876bddb0..18f0e587 160000 --- a/types +++ b/types @@ -1 +1 @@ -Subproject commit 876bddb0f218fe84d18ddebb2b4b9e14cd384ad8 +Subproject commit 18f0e587ccdc09bfd0d893ff5f33d62f27d310f5