Skip to content

Commit

Permalink
examples: Rework sources and configurations for updated generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ewlsh committed Mar 12, 2024
1 parent 33b017e commit 941dc81
Show file tree
Hide file tree
Showing 70 changed files with 111 additions and 273 deletions.
9 changes: 4 additions & 5 deletions examples/gjs/adw-1-hello/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
* @see https://gitlab.gnome.org/GNOME/libadwaita/-/blob/main/examples/hello-world/hello.c
*/

import './@types/gjs/gjs';
import Gio from './@types/gio-2.0/gio-2.0';
import GLib from './@types/glib-2.0/glib-2.0';
import Gtk from './@types/gtk-4.0/gtk-4.0';
import Adw from './@types/adw-1/adw-1';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import Gtk from 'gi://Gtk';
import Adw from 'gi://Adw';

const loop = GLib.MainLoop.new(null, false)

Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/adw-1-hello/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Adw-1",
"build:types": "yarn ts-for-gir generate Adw-1 --outdir @types/@girs",
"build:app": "vite build",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gio-2-cat-alias/.ts-for-girrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"modules": ["Gio-2.0"],
"noNamespace": false,
"outdir": "./@types",
"outdir": "./@types/@girs",
"generateAlias": true
}
4 changes: 2 additions & 2 deletions examples/gjs/gio-2-cat-alias/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"extends": "./tsconfig.alias.json",
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"types": ["@girs/gjs", "@girs/gjs/dom"],
"typeRoots": ["./@types"],
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
},
"include": ["@types/gjs.d.ts", "@types/dom.d.ts"],
"files": [
"main.ts",
]
Expand Down
4 changes: 2 additions & 2 deletions examples/gjs/gio-2-cat-promisify/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"extends": "./tsconfig.alias.json",
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"types": ["@girs/gjs", "@girs/gjs/dom"],
"typeRoots": ["./@types"],
"target": "ESNext",
"module": "ESNext"
},
"include": ["@types/gjs.d.ts", "@types/dom.d.ts"],
"files": [
"main.ts",
]
Expand Down
4 changes: 2 additions & 2 deletions examples/gjs/gio-2-cat-types-only/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"types": ["@girs/gjs", "@girs/gjs/dom", "@girs/glib-2.0", "@girs/gio-2.0"],
"typeRoots": ["./@types"],
"target": "ESNext",
"module": "ESNext",
"strict": true,
Expand All @@ -10,7 +11,6 @@
"noImplicitThis": true,
"alwaysStrict": true
},
"include": ["@types/gjs.d.ts", "@types/dom.d.ts", "@types/gio-2.0.d.ts", "@types/glib-2.0.d.ts"],
"files": [
"main.ts",
]
Expand Down
5 changes: 3 additions & 2 deletions examples/gjs/gio-2-cat/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// <reference path="./@types/gjs/gjs.d.ts" />
/// <reference path="./@types/gjs/dom.d.ts" />

// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
// SPDX-FileCopyrightText: 2009 Red Hat, Inc.
// Based on https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/gio-cat.js
Expand All @@ -8,8 +11,6 @@
* the label should show a translation of 'Print help'
*/

import './@types/gjs/gjs';
import './@types/gjs/dom';
import GLib from './@types/glib-2.0/glib-2.0';
import Gio from './@types/gio-2.0/gio-2.0';

Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gio-2-cat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gio-2.0",
"build:types": "yarn ts-for-gir generate Gio-2.0 --outdir @types/@girs",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js main.ts",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gio-2-dbus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gio-2.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gio-2.0 --generateAlias --outdir=@types/@girs",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start": "yarn build && yarn start:server",
Expand Down
4 changes: 2 additions & 2 deletions examples/gjs/gio-2-dbus/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "./tsconfig.alias.json",
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"types": ["@girs/gjs"],
"typeRoots": ["./@types"],
"target": "ESNext",
"module": "ESNext",
"strict": true,
Expand All @@ -11,7 +12,6 @@
"noImplicitThis": true,
"alwaysStrict": true,
},
"include": ["@types/gjs.d.ts"],
"files": [
"dbus-client.ts",
"dbus-server.ts",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gio-2-list-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-4.0 --generateAlias --outdir=@types/@girs",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
4 changes: 2 additions & 2 deletions examples/gjs/gio-2-list-model/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "./tsconfig.alias.json",
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"types": ["@girs/gjs"],
"typeRoots": ["./@types"],
"target": "ESNext",
"module": "ESNext",
"strict": true,
Expand All @@ -11,7 +12,6 @@
"noImplicitThis": true,
"alwaysStrict": true,
},
"include": ["@types/gjs.d.ts"],
"files": [
"main.ts",
]
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/glib-2-spawn-command/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Example based on https://gist.github.com/buzztaiki/1487781/74ea93d3a30f20c7f094327db9cb263a6286f6d6
import * as GLib from './@types/glib-2.0.js';
import GLib from 'gi://GLib';
const textDecoder = new TextDecoder();

let [res, out, err, status] = GLib.spawn_command_line_sync('ls -la');
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/glib-2-spawn-command/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"watch": "yarn build:app --watch",
"build": "yarn build:types && yarn build:app",
"build:app": "yarn clear:ts && webpack --env production",
"build:types": "yarn ts-for-gir generate GLib-2.0 --noNamespace",
"build:types": "yarn ts-for-gir generate GLib-2.0 --outdir @types/@girs",
"clear:types": "rm -rf ./@types",
"clear:ts": "rm -rf ./dist",
"clear": "yarn clear:ts && yarn clear:types",
Expand Down
30 changes: 15 additions & 15 deletions examples/gjs/glib-2-spawn-command/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"target": "ESNext",
"module": "ESNext",
"strict": true,
"noImplicitAny": false,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
},
"include": ["@types/gjs.d.ts", "@types/dom.d.ts", "@types/ambient.d.ts"],
"files": [
"main.ts"
]
"compilerOptions": {
"lib": ["ESNext"],
"types": ["@girs/gjs", "@girs/gjs/dom", "@girs/glib-2.0", "@girs/gobject-2.0"],
"typeRoots": ["./@types"],
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"noImplicitAny": false,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"skipLibCheck": false
},
"files": ["main.ts"]
}
2 changes: 1 addition & 1 deletion examples/gjs/glib-2-variant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate GLib-2.0 Gio-2.0 --generateAlias",
"build:types": "yarn ts-for-gir generate GLib-2.0 Gio-2.0 --generateAlias --outdir=@types/@girs",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions examples/gjs/glib-2-variant/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "./tsconfig.alias.json",
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"types": ["@girs/gjs", "@girs/glib-2.0"],
"typeRoots": ["./@types"],
"target": "ESNext",
"module": "ESNext",
"strict": true,
Expand All @@ -11,7 +12,6 @@
"noImplicitThis": true,
"alwaysStrict": true,
},
"include": ["@types/gjs.d.ts"],
"files": [
"index.ts"
]
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-3-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"watch": "yarn build:app --watch",
"build": "yarn build:types && yarn build:app",
"build:app": "yarn clear:ts && webpack --config webpack.config.cjs --env production",
"build:types": "yarn ts-for-gir generate Gtk-3.0 Pango-1.0 WebKit2-4.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-3.0 Pango-1.0 WebKit2-4.0 --generateAlias --outdir=@types/@girs",
"clear:types": "rm -rf ./@types",
"clear:ts": "rm -rf ./dist",
"clear": "yarn clear:ts && yarn clear:types",
Expand Down
4 changes: 2 additions & 2 deletions examples/gjs/gtk-3-browser/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"types": ["@girs/gjs", "@girs/pango-1.0", "@girs/gtk-3.0", "@girs/webkit2-4.0"],
"typeRoots": ["./@types"],
"target": "ESNext",
"module": "ESNext",
"strict": true,
Expand All @@ -10,7 +11,6 @@
"noImplicitThis": true,
"alwaysStrict": true,
},
"include": ["@types/ambient.d.ts", "@types/pango-1.0-ambient.d.ts", "@types/gtk-3.0-ambient.d.ts", "@types/webkit2-4.0-ambient.d.ts"],
"files": [
"main.ts"
]
Expand Down
3 changes: 1 addition & 2 deletions examples/gjs/gtk-3-builder/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import './@types/gjs.js'
import gladeFile from './builderExample.glade'
import * as Gtk from './@types/gtk-3.0'
import Gtk from './@types/gtk-3.0/gtk-3.0'

Gtk.init(null)

Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-3-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"watch": "yarn build:app --watch",
"build": "yarn build:types && yarn build:app",
"build:app": "yarn clear:ts && webpack --env production",
"build:types": "yarn ts-for-gir generate Gtk-3.0 --noNamespace",
"build:types": "yarn ts-for-gir generate Gtk-3.0 --noNamespace --outdir=@types",
"clear:types": "rm -rf ./@types",
"clear:ts": "rm -rf ./dist",
"clear": "yarn clear:ts && yarn clear:types",
Expand Down
6 changes: 4 additions & 2 deletions examples/gjs/gtk-3-builder/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"typeRoots": ["./@types"],
"types": ["@girs/gjs"],
"target": "ESNext",
"module": "ESNext",
"strict": true,
"noImplicitAny": false,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"allowSyntheticDefaultImports": true,
},
"include": ["global.d.ts", "@types/gjs.d.ts", "@types/ambient.d.ts"],
"include": ["global.d.ts"],
"files": [
"main.ts"
]
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-3-calc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias --outdir=@types/@girs",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
4 changes: 2 additions & 2 deletions examples/gjs/gtk-3-calc/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "./tsconfig.alias.json",
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"types": ["@girs/gtk-3.0"],
"typeRoots": ["./@types"],
"target": "ESNext",
"module": "ESNext",
"strict": true,
Expand All @@ -11,7 +12,6 @@
"noImplicitThis": true,
"alwaysStrict": true,
},
"include": ["@types/gjs.d.ts"],
"files": [
"main.ts",
]
Expand Down
7 changes: 4 additions & 3 deletions examples/gjs/gtk-3-editor/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import imports from './@types/gjs.js'
import * as Gtk from './@types/gtk-3.0'
import * as GtkSource from './@types/gtksource-3.0'
/// <reference path="./@types/gjs/gjs.d.ts" />

import Gtk from './@types/gtk-3.0/gtk-3.0'
import GtkSource from './@types/gtksource-3.0/gtksource-3.0'
const { gettext } = imports;

Gtk.init(null)
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-3-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"build": "yarn build:types && yarn build:app",
"build:app": "yarn clear:app && webpack --env production",
"build:types": "yarn ts-for-gir generate Gtk-3.0 GtkSource-3.0 --noNamespace",
"build:types": "yarn ts-for-gir generate Gtk-3.0 GtkSource-3.0 --noNamespace --outdir=@types",
"clear:types": "rm -rf ./@types",
"clear:app": "rm -rf ./dist",
"clear": "yarn clear:app && yarn clear:types",
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-3-editor/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"target": "ESNext",
"module": "ESNext",
"strict": true,
"noImplicitAny": false,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"allowSyntheticDefaultImports": true,
},
"files": [
"main.ts"
Expand Down
2 changes: 1 addition & 1 deletion examples/gjs/gtk-3-gettext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias",
"build:types": "yarn ts-for-gir generate Gtk-3.0 --generateAlias --outdir=@types/@girs",
"build:app": "yarn node esbuild.js",
"build": "yarn build:types && yarn build:app",
"start:app": "gjs -m dist/main.js",
Expand Down
4 changes: 2 additions & 2 deletions examples/gjs/gtk-3-gettext/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "./tsconfig.alias.json",
"compilerOptions": {
"lib": ["ESNext"],
"types": [],
"types": ["@girs/gjs", "@girs/gtk-3.0"],
"typeRoots": ["./@types"],
"target": "ESNext",
"module": "ESNext",
"strict": true,
Expand All @@ -11,7 +12,6 @@
"noImplicitThis": true,
"alwaysStrict": true,
},
"include": ["@types/gjs.d.ts"],
"files": [
"main.ts",
]
Expand Down
2 changes: 0 additions & 2 deletions examples/gjs/gtk-3-hello-2/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// SPDX-FileCopyrightText: 2008 litl, LLC
// Based on https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/gtk.js

import imports from './@types/gjs.js';

// Include this in case both GTK3 and GTK4 installed, otherwise an exception
// will be thrown
imports.gi.versions.Gtk = '3.0';
Expand Down
Loading

0 comments on commit 941dc81

Please sign in to comment.