diff --git a/examples/adw-1-hello/package.json b/examples/adw-1-hello/package.json index 3a078139..93abf409 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.17", + "version": "4.0.0-beta.18", "description": "Simple GJS Typescript hello-world example using Libadwaita", "type": "module", "private": true, diff --git a/examples/cairo-surfaces-tsc/package.json b/examples/cairo-surfaces-tsc/package.json index 8f561770..587e2b16 100644 --- a/examples/cairo-surfaces-tsc/package.json +++ b/examples/cairo-surfaces-tsc/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/cairo-surfaces-tsc", - "version": "4.0.0-beta.17", + "version": "4.0.0-beta.18", "description": "Simple cairo-surfaces GJS example", "type": "module", "private": true, diff --git a/examples/console-tsc/package.json b/examples/console-tsc/package.json index eda09a2e..274083d5 100644 --- a/examples/console-tsc/package.json +++ b/examples/console-tsc/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/console-tsc", - "version": "4.0.0-beta.17", + "version": "4.0.0-beta.18", "description": "Simple console example", "type": "module", "private": true, diff --git a/examples/gio-2-async/main.ts b/examples/gio-2-async/main.ts index 42ed1466..5fdc1e20 100644 --- a/examples/gio-2-async/main.ts +++ b/examples/gio-2-async/main.ts @@ -3,14 +3,27 @@ import Gio from 'gi://Gio' // Example demonstrating promisified async file operations -// Promisify Gio.File.enumerate_children_async and Gio.FileEnumerator.next_files_async +// Promisify Gio.File operations Gio._promisify(Gio.File.prototype, 'enumerate_children_async', 'enumerate_children_finish') Gio._promisify(Gio.FileEnumerator.prototype, 'next_files_async', 'next_files_finish') +Gio._promisify(Gio.File.prototype, 'load_contents_async', 'load_contents_finish') async function main() { try { const dir = Gio.File.new_for_path('.') + // Test load_contents_async behavior + console.log('\nTesting load_contents_async:') + const thisFile = Gio.File.new_for_path('main.ts') + const contents = await thisFile.load_contents_async(null) + // contents is [Uint8Array, string], not [boolean, Uint8Array, string] + console.log('Number of returned items:', contents.length) + console.log( + 'Types of returned items:', + contents.map((item) => typeof item), + ) + console.log('Content preview:', new TextDecoder().decode(contents[0]).slice(0, 50)) + // List directory contents asynchronously const enumerator = await dir.enumerate_children_async( 'standard::*', diff --git a/examples/gio-2-async/package.json b/examples/gio-2-async/package.json index e29ac201..63565db8 100644 --- a/examples/gio-2-async/package.json +++ b/examples/gio-2-async/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gio-2-async", - "version": "4.0.0-beta.17", + "version": "4.0.0-beta.18", "description": "Example demonstrating promisified GIO async operations", "type": "module", "private": true, diff --git a/examples/gio-2-cat/package.json b/examples/gio-2-cat/package.json index c6306388..2d86d77e 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.17", + "version": "4.0.0-beta.18", "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 ba6a5c93..99ec6e3d 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.17", + "version": "4.0.0-beta.18", "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 de87f8c2..9e81a3c3 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.17", + "version": "4.0.0-beta.18", "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 2efed585..d42211fa 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.17", + "version": "4.0.0-beta.18", "description": "", "type": "module", "private": true, diff --git a/examples/glib-2-variant/package.json b/examples/glib-2-variant/package.json index 29838738..9de044be 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.17", + "version": "4.0.0-beta.18", "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 9506b316..93f6b388 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.17", + "version": "4.0.0-beta.18", "type": "module", "private": true, "scripts": { diff --git a/examples/gtk-3-builder/package.json b/examples/gtk-3-builder/package.json index 47eee6c9..171b579d 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.17", + "version": "4.0.0-beta.18", "type": "module", "private": true, "scripts": { diff --git a/examples/gtk-3-calc/package.json b/examples/gtk-3-calc/package.json index 9c9171d0..959d38de 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.17", + "version": "4.0.0-beta.18", "description": "Simple GJS Gtk 3 calculator example app", "type": "module", "private": true, diff --git a/examples/gtk-3-clutter-tsc/package.json b/examples/gtk-3-clutter-tsc/package.json index ecd7f1e4..b4d3976f 100644 --- a/examples/gtk-3-clutter-tsc/package.json +++ b/examples/gtk-3-clutter-tsc/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-3-clutter-tsc", - "version": "4.0.0-beta.17", + "version": "4.0.0-beta.18", "description": "Simple GJS GTK+3 Clutter example app", "type": "module", "private": true, diff --git a/examples/gtk-3-editor/package.json b/examples/gtk-3-editor/package.json index ec0fba80..c34adc1e 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.17", + "version": "4.0.0-beta.18", "type": "module", "targets": { ".": { diff --git a/examples/gtk-3-hello-2/package.json b/examples/gtk-3-hello-2/package.json index d7e389de..726c6269 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.17", + "version": "4.0.0-beta.18", "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 3aea92b4..b9382f73 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.17", + "version": "4.0.0-beta.18", "type": "module", "private": true, "scripts": { diff --git a/examples/gtk-3-template/package.json b/examples/gtk-3-template/package.json index ef6f8162..52c58355 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.17", + "version": "4.0.0-beta.18", "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 3bf9e945..e976fa24 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.17", + "version": "4.0.0-beta.18", "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 f8b9985a..88217704 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.17", + "version": "4.0.0-beta.18", "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 5fd5eda1..e412dfc9 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.17", + "version": "4.0.0-beta.18", "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 38a16703..a6d07133 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.17", + "version": "4.0.0-beta.18", "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 704fb240..48ddddbe 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.17", + "version": "4.0.0-beta.18", "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-esbuild/package.json b/examples/gtk-4-template-esbuild/package.json index dcb4eb54..917a2cdb 100644 --- a/examples/gtk-4-template-esbuild/package.json +++ b/examples/gtk-4-template-esbuild/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-4-template-esbuild", - "version": "4.0.0-beta.17", + "version": "4.0.0-beta.18", "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/gtk-4-template-tsc/package.json b/examples/gtk-4-template-tsc/package.json index 6698e402..70b757c4 100644 --- a/examples/gtk-4-template-tsc/package.json +++ b/examples/gtk-4-template-tsc/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/gtk-4-template-tsc", - "version": "4.0.0-beta.17", + "version": "4.0.0-beta.18", "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/gtk-4-template-vite/package.json b/examples/gtk-4-template-vite/package.json index 895b2b58..4aaee3b9 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.17", + "version": "4.0.0-beta.18", "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/pkg-tsc/package.json b/examples/pkg-tsc/package.json index 4fe5b1a4..bd15ac77 100644 --- a/examples/pkg-tsc/package.json +++ b/examples/pkg-tsc/package.json @@ -1,6 +1,6 @@ { "name": "@ts-for-gir-example/pkg-tsc", - "version": "4.0.0-beta.17", + "version": "4.0.0-beta.18", "description": "Simple pkg GJS example", "type": "module", "private": true, diff --git a/examples/run-async/package.json b/examples/run-async/package.json index ff72d062..22a140df 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.17", + "version": "4.0.0-beta.18", "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 d6bd4d74..6d994a30 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.17", + "version": "4.0.0-beta.18", "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 81acf01b..cbd42937 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.17", + "version": "4.0.0-beta.18", "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 7de2a3fa..c60a5982 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.17", + "version": "4.0.0-beta.18", "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 2529c1cb..305b7b36 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-for-gir", - "version": "4.0.0-beta.17", + "version": "4.0.0-beta.18", "description": "Typescript .d.ts generator from GIR for gjs", "type": "module", "private": true, diff --git a/packages/cli/package.json b/packages/cli/package.json index 39438b76..c0806c32 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.17", + "version": "4.0.0-beta.18", "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 b10e13cc..8392a5fe 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.17", + "version": "4.0.0-beta.18", "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 943d30d6..478a4bca 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.17", + "version": "4.0.0-beta.18", "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 347b4e37..9b4d2dd6 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.17", + "version": "4.0.0-beta.18", "description": "TypeScript type definition generator for ts-for-gir", "module": "lib/index.js", "main": "lib/index.js", diff --git a/packages/lib/package.json b/packages/lib/package.json index 5763df85..dbf32b27 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.17", + "version": "4.0.0-beta.18", "description": "Typescript .d.ts generator from GIR for gjs", "module": "lib/index.js", "main": "lib/index.js", diff --git a/packages/lib/src/gir/promisify.ts b/packages/lib/src/gir/promisify.ts index fd834da3..2028b455 100644 --- a/packages/lib/src/gir/promisify.ts +++ b/packages/lib/src/gir/promisify.ts @@ -118,6 +118,13 @@ function createAsyncReturn(async_res: IntrospectedClassFunction | IntrospectedCo return new PromiseType(output_parameters[0].type); } + // Special case: If return type is boolean and we have multiple output parameters, + // GJS drops the boolean from the tuple (as it's used for error handling) + if (return_type.equals(BooleanType) && output_parameters.length > 0) { + const [firstParam, ...restParams] = output_parameters; + return new PromiseType(new TupleType(firstParam.type, ...restParams.map(p => p.type))); + } + // Otherwise, return a tuple of [return_value, ...output_parameters] return new PromiseType(new TupleType(return_type, ...output_parameters.map(p => p.type))); } diff --git a/types b/types index 79d6e43a..d5f5308a 160000 --- a/types +++ b/types @@ -1 +1 @@ -Subproject commit 79d6e43a375547886307d13c4cf1fd36164be887 +Subproject commit d5f5308af78cb1fc0598399c7262e587234f9943