Skip to content

Commit

Permalink
Merge pull request #177 from gjsify/ewlsh/fix-promisifying
Browse files Browse the repository at this point in the history
gir: Promisify class members in typescript generator
  • Loading branch information
JumpLink authored Nov 3, 2024
2 parents ec732f1 + 8124d3f commit 8de2706
Show file tree
Hide file tree
Showing 230 changed files with 108,517 additions and 194,774 deletions.
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 gtk4PackagesConfig from './.ts-for-gir.gtk4.rc.js';
import allPackagesConfig from './.ts-for-gir.packages-all.rc.js';

export default {
...gtk4PackagesConfig,
package: true,
...allPackagesConfig,
modules: ['Gtk-4.0', 'Adw-1.0'],
}
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"recommendations": [
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
"esbenp.prettier-vscode",
"yoavbls.pretty-ts-errors"
]
}
2 changes: 1 addition & 1 deletion 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.16",
"version": "4.0.0-beta.17",
"description": "Simple GJS Typescript hello-world example using Libadwaita",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/cairo-surfaces-tsc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/cairo-surfaces-tsc",
"version": "4.0.0-beta.16",
"version": "4.0.0-beta.17",
"description": "Simple cairo-surfaces GJS example",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/console-tsc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/console-tsc",
"version": "4.0.0-beta.16",
"version": "4.0.0-beta.17",
"description": "Simple console example",
"type": "module",
"private": true,
Expand Down
58 changes: 58 additions & 0 deletions examples/gio-2-async/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import GLib from 'gi://GLib'
import Gio from 'gi://Gio'

// Example demonstrating promisified async file operations

// Promisify Gio.File.enumerate_children_async and Gio.FileEnumerator.next_files_async
Gio._promisify(Gio.File.prototype, 'enumerate_children_async', 'enumerate_children_finish')
Gio._promisify(Gio.FileEnumerator.prototype, 'next_files_async', 'next_files_finish')

async function main() {
try {
const dir = Gio.File.new_for_path('.')

// List directory contents asynchronously
const enumerator = await dir.enumerate_children_async(
'standard::*',
Gio.FileQueryInfoFlags.NONE,
GLib.PRIORITY_DEFAULT,
null,
)

while (true) {
// Get next files asynchronously
const files = await enumerator.next_files_async(
10, // Number of files to fetch
GLib.PRIORITY_DEFAULT,
null,
)

if (!files.length) {
break
}

// Process each file info
for (const info of files) {
const name = info.get_name()
const type = info.get_file_type()
const size = info.get_size()

console.log(`${name} (${type === Gio.FileType.DIRECTORY ? 'Directory' : 'File'}, ${size} bytes)`)
}
}
} catch (error) {
console.error('Error:', error)
}

// Required to properly terminate the program
mainLoop.quit()
}

// Create main loop
const mainLoop = new GLib.MainLoop(null, false)

// Start async operation
main()

// Run main loop
mainLoop.run()
23 changes: 23 additions & 0 deletions examples/gio-2-async/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@ts-for-gir-example/gio-2-async",
"version": "4.0.0-beta.17",
"description": "Example demonstrating promisified GIO async operations",
"type": "module",
"private": true,
"scripts": {
"build:app": "tsc",
"build": "yarn build:app",
"start:app": "gjs -m dist/main.js",
"start": "yarn build && yarn start:app",
"validate": "yarn validate:types",
"validate:types": "tsc --noEmit",
"clear": "rm -rf dist"
},
"devDependencies": {
"typescript": "^5.6.3"
},
"dependencies": {
"@girs/gio-2.0": "workspace:^",
"@girs/gjs": "workspace:^"
}
}
18 changes: 18 additions & 0 deletions examples/gio-2-async/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"types": ["@girs/gjs", "@girs/gjs/dom", "@girs/gio-2.0"],
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"outDir": "./dist"
},
"files": [
"main.ts"
]
}
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.16",
"version": "4.0.0-beta.17",
"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.16",
"version": "4.0.0-beta.17",
"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.16",
"version": "4.0.0-beta.17",
"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.16",
"version": "4.0.0-beta.17",
"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.16",
"version": "4.0.0-beta.17",
"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.16",
"version": "4.0.0-beta.17",
"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.16",
"version": "4.0.0-beta.17",
"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.16",
"version": "4.0.0-beta.17",
"description": "Simple GJS Gtk 3 calculator example app",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/gtk-3-clutter-tsc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-3-clutter-tsc",
"version": "4.0.0-beta.16",
"version": "4.0.0-beta.17",
"description": "Simple GJS GTK+3 Clutter 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.16",
"version": "4.0.0-beta.17",
"type": "module",
"targets": {
".": {
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.16",
"version": "4.0.0-beta.17",
"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.16",
"version": "4.0.0-beta.17",
"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.16",
"version": "4.0.0-beta.17",
"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.16",
"version": "4.0.0-beta.17",
"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.16",
"version": "4.0.0-beta.17",
"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.16",
"version": "4.0.0-beta.17",
"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-gettext/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-4-gettext-example",
"version": "4.0.0-beta.16",
"version": "4.0.0-beta.17",
"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-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.16",
"version": "4.0.0-beta.17",
"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
2 changes: 1 addition & 1 deletion examples/gtk-4-template-esbuild/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-4-template-esbuild",
"version": "4.0.0-beta.16",
"version": "4.0.0-beta.17",
"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
2 changes: 1 addition & 1 deletion examples/gtk-4-template-tsc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-4-template-tsc",
"version": "4.0.0-beta.16",
"version": "4.0.0-beta.17",
"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
2 changes: 1 addition & 1 deletion examples/gtk-4-template-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/gtk-4-template-vite",
"version": "4.0.0-beta.16",
"version": "4.0.0-beta.17",
"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,
Expand Down
1 change: 1 addition & 0 deletions examples/gtk-4-template-vite/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"diagnostics": true
},
"files": [
"main.ts",
Expand Down
2 changes: 1 addition & 1 deletion examples/pkg-tsc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/pkg-tsc",
"version": "4.0.0-beta.16",
"version": "4.0.0-beta.17",
"description": "Simple pkg GJS example",
"type": "module",
"private": true,
Expand Down
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.16",
"version": "4.0.0-beta.17",
"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/soup-3-http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/soup-3-http-example",
"version": "4.0.0-beta.16",
"version": "4.0.0-beta.17",
"description": "GJS example showing how to build a http server/client using Soap 3",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/soup-3-websocket/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/soup-3-websocket-example",
"version": "4.0.0-beta.16",
"version": "4.0.0-beta.17",
"description": "Simple GJS Soup 3 example app to demonstrate how you can use WebSockets",
"type": "module",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/timers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-for-gir-example/timers-example",
"version": "4.0.0-beta.16",
"version": "4.0.0-beta.17",
"description": "Simple GJS Gtk 4 example app to demonstrate how you can use .ui template XML files",
"type": "module",
"private": true,
Expand Down
Loading

0 comments on commit 8de2706

Please sign in to comment.