From 0ca99da6dd7ffdb5ea8bd408624f6603197a16cb Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Wed, 24 Jul 2024 17:01:41 +0200 Subject: [PATCH 01/10] Re-export cairo in override module --- .../templates/gjs/cairo-1.0.d.ts | 9 --------- .../templates/gjs/cairo.d.ts | 20 ++++++++++++++++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/generator-typescript/templates/gjs/cairo-1.0.d.ts b/packages/generator-typescript/templates/gjs/cairo-1.0.d.ts index cff49e757..e69de29bb 100644 --- a/packages/generator-typescript/templates/gjs/cairo-1.0.d.ts +++ b/packages/generator-typescript/templates/gjs/cairo-1.0.d.ts @@ -1,9 +0,0 @@ -// TODO -// See -// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/installed-tests/js/testCairoModule.js -// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/installed-tests/js/testCairo.js -// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/doc/cairo.md - -// image_surface_create -> ImageSurface -// Context.constructor(surface: cairo.ImageSurface) -// ... diff --git a/packages/generator-typescript/templates/gjs/cairo.d.ts b/packages/generator-typescript/templates/gjs/cairo.d.ts index d2f3cfc6e..33d586b71 100644 --- a/packages/generator-typescript/templates/gjs/cairo.d.ts +++ b/packages/generator-typescript/templates/gjs/cairo.d.ts @@ -1,11 +1,25 @@ +<%_ const Cairo = await dep.get('cairo', '1.0') _%> + <%_ if(!package){ -%> declare module 'cairo' { <% } -%> -// TODO: See ./cairo-1.0.d.ts -<%- package ? 'declare' : '' %> const Cairo: any; +// Cairo 1.0 +<%- Cairo ? Cairo.importDef : '' %> + +// TODO: Add overrides here + +// See +// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/installed-tests/js/testCairoModule.js +// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/installed-tests/js/testCairo.js +// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/doc/cairo.md + +// image_surface_create -> ImageSurface +// Context.constructor(surface: cairo.ImageSurface) +// ... -export default Cairo; +// Re-export Cairo 1.0 +export default <%- Cairo ? Cairo.importName : '' %>; <%_ if(!package){ -%> } From 8f75dda3cd0f96179c3b071c5194f9ee87e4885f Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Wed, 24 Jul 2024 17:34:48 +0200 Subject: [PATCH 02/10] Add Cairo-1.0 to core dependencies and fix re-export --- packages/generator-typescript/templates/gjs/cairo.d.ts | 2 +- packages/lib/src/dependency-manager.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/generator-typescript/templates/gjs/cairo.d.ts b/packages/generator-typescript/templates/gjs/cairo.d.ts index 33d586b71..17bdd2dc4 100644 --- a/packages/generator-typescript/templates/gjs/cairo.d.ts +++ b/packages/generator-typescript/templates/gjs/cairo.d.ts @@ -19,7 +19,7 @@ declare module 'cairo' { // ... // Re-export Cairo 1.0 -export default <%- Cairo ? Cairo.importName : '' %>; +export default <%- Cairo ? Cairo.namespace : '' %>; <%_ if(!package){ -%> } diff --git a/packages/lib/src/dependency-manager.ts b/packages/lib/src/dependency-manager.ts index 85dedb0e0..e118be684 100644 --- a/packages/lib/src/dependency-manager.ts +++ b/packages/lib/src/dependency-manager.ts @@ -105,7 +105,12 @@ export class DependencyManager extends GirNSRegistry { * @returns */ async core(): Promise { - return [await this.get('GObject', '2.0'), await this.get('GLib', '2.0'), await this.get('Gio', '2.0')] + return [ + await this.get('GObject', '2.0'), + await this.get('GLib', '2.0'), + await this.get('Gio', '2.0'), + await this.get('Cairo', '1.0'), + ] } createImportProperties(namespace: string, packageName: string, version: string) { From 4703b0074d274bbcb535957a683df02445d2d1fb Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Wed, 24 Jul 2024 18:46:52 +0200 Subject: [PATCH 03/10] cairo: Basic overrides added --- .../templates/gjs/cairo.d.ts | 182 +++++++++++++++++- 1 file changed, 174 insertions(+), 8 deletions(-) diff --git a/packages/generator-typescript/templates/gjs/cairo.d.ts b/packages/generator-typescript/templates/gjs/cairo.d.ts index 17bdd2dc4..b798160d0 100644 --- a/packages/generator-typescript/templates/gjs/cairo.d.ts +++ b/packages/generator-typescript/templates/gjs/cairo.d.ts @@ -5,21 +5,187 @@ declare module 'cairo' { <% } -%> // Cairo 1.0 -<%- Cairo ? Cairo.importDef : '' %> +import type Cairo from '<%- Cairo.importPath %>'; -// TODO: Add overrides here +<%- package ? 'declare' : '' %> namespace giCairo { +// Add overrides here // See +// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/doc/cairo.md // - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/installed-tests/js/testCairoModule.js // - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/installed-tests/js/testCairo.js -// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/doc/cairo.md +// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/cairo-context.cpp + +// Re-exported enums +export type Status = Cairo.Status; +export type Content = Cairo.Content; +export type Operator = Cairo.Operator; +export type Antialias = Cairo.Antialias; +export type FillRule = Cairo.FillRule; +export type LineCap = Cairo.LineCap; +export type LineJoin = Cairo.LineJoin; +export type TextClusterFlags = Cairo.TextClusterFlags; +export type FontSlant = Cairo.FontSlant; +export type FontWeight = Cairo.FontWeight; +export type SubpixelOrder = Cairo.SubpixelOrder; +export type HintStyle = Cairo.HintStyle; +export type HintMetrics = Cairo.HintMetrics; +export type FontType = Cairo.FontType; +export type PathDataType = Cairo.PathDataType; +export type DeviceType = Cairo.DeviceType; +export type SurfaceType = Cairo.SurfaceType; +export type Format = Cairo.Format; +export type PatternType = Cairo.PatternType; +export type Extend = Cairo.Extend; +export type Filter = Cairo.Filter; +export type RegionOverlap = Cairo.RegionOverlap; + +export class Context extends Cairo.Context { + constructor(surface: Surface); + + arc(xc: number, yc: number, radius: number, angle1: number, angle2: number): void; + arcNegative(xc: number, yc: number, radius: number, angle1: number, angle2: number): void; + curveTo(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void; + clip(): void; + clipPreserve(): void; + clipExtents(): [number, number, number, number]; + closePath(): void; + copyPage(): void; + deviceToUser(x: number, y: number): [number, number]; + deviceToUserDistance(x: number, y: number): [number, number]; + fill(): void; + fillPreserve(): void; + fillExtents(): [number, number, number, number]; + getAntialias(): Antialias; + getCurrentPoint(): [number, number]; + getDashCount(): number; + getFillRule(): FillRule; + getLineCap(): LineCap; + getLineJoin(): LineJoin; + getLineWidth(): number; + getMiterLimit(): number; + getOperator(): Operator; + getTolerance(): number; + hasCurrentPoint(): boolean; + identityMatrix(): void; + inFill(x: number, y: number): boolean; + inStroke(x: number, y: number): boolean; + lineTo(x: number, y: number): void; + moveTo(x: number, y: number): void; + newPath(): void; + newSubPath(): void; + paint(): void; + paintWithAlpha(alpha: number): void; + pathExtents(): [number, number, number, number]; + popGroup(): Pattern; + popGroupToSource(): void; + pushGroup(): void; + pushGroupWithContent(content: Content): void; + rectangle(x: number, y: number, width: number, height: number): void; + relCurveTo(dx1: number, dy1: number, dx2: number, dy2: number, dx3: number, dy3: number): void; + relLineTo(dx: number, dy: number): void; + relMoveTo(dx: number, dy: number): void; + resetClip(): void; + restore(): void; + rotate(angle: number): void; + save(): void; + scale(sx: number, sy: number): void; + selectFontFace(family: string, slant: number, weight: number): void; + setAntialias(antialias: Antialias): void; + setDash(dashes: number[], offset: number): void; + setFontSize(size: number): void; + setFillRule(fillRule: FillRule): void; + setLineCap(lineCap: LineCap): void; + setLineJoin(lineJoin: LineJoin): void; + setLineWidth(width: number): void; + setMiterLimit(limit: number): void; + setOperator(op: Operator): void; + setSource(pattern: Pattern): void; + setSourceRGB(red: number, green: number, blue: number): void; + setSourceRGBA(red: number, green: number, blue: number, alpha: number): void; + setSourceSurface(surface: Surface, x: number, y: number): void; + setTolerance(tolerance: number): void; + showPage(): void; + showText(utf8: string): void; + stroke(): void; + strokePreserve(): void; + strokeExtents(): [number, number, number, number]; + textExtents(utf8: string): TextExtents; + translate(tx: number, ty: number): void; + userToDevice(x: number, y: number): [number, number]; + userToDeviceDistance(x: number, y: number): [number, number]; +} + +export abstract class Surface extends Cairo.Surface { + // TODO +} + +export class ImageSurface extends Surface { + constructor(format: Format, width: number, height: number); + + static createFromPNG(filename: string): ImageSurface; + + // TODO +} + +export class PDFSurface extends Surface { + constructor(filename: string, width: number, height: number); + + // TODO +} + +export class PSSurface extends Surface { + constructor(filename: string, width: number, height: number); + + // TODO +} + +export class SVGSurface extends Surface { + constructor(filename: string, width: number, height: number); -// image_surface_create -> ImageSurface -// Context.constructor(surface: cairo.ImageSurface) -// ... + // TODO +} + +export class Pattern extends Cairo.Pattern { + // TODO +} + +export class Gradient extends Pattern { + // TODO +} + +export class LinearGradient extends Gradient { + // TODO +} + +export class RadialGradient extends Gradient { + // TODO +} + +export class SurfacePattern extends Pattern { + // TODO +} + +export class SolidPattern extends Pattern { + // TODO +} + +export class Path extends Cairo.Path { + // TODO +} + +export interface TextExtents { + xBearing: number; + yBearing: number; + width: number; + height: number; + xAdvance: number; + yAdvance: number; +} + +} -// Re-export Cairo 1.0 -export default <%- Cairo ? Cairo.namespace : '' %>; +export default giCairo; <%_ if(!package){ -%> } From a9fb152e918e1b6854e108a10c6626f42f06ae16 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Wed, 24 Jul 2024 18:47:11 +0200 Subject: [PATCH 04/10] New clutter gtk3 example added --- examples/gtk-3-clutter-tsc/main.ts | 195 +++++++++++++++++++++++ examples/gtk-3-clutter-tsc/package.json | 32 ++++ examples/gtk-3-clutter-tsc/tsconfig.json | 18 +++ yarn.lock | 18 ++- 4 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 examples/gtk-3-clutter-tsc/main.ts create mode 100644 examples/gtk-3-clutter-tsc/package.json create mode 100644 examples/gtk-3-clutter-tsc/tsconfig.json diff --git a/examples/gtk-3-clutter-tsc/main.ts b/examples/gtk-3-clutter-tsc/main.ts new file mode 100644 index 000000000..39376866e --- /dev/null +++ b/examples/gtk-3-clutter-tsc/main.ts @@ -0,0 +1,195 @@ +#!/usr/bin/gjs + +/* +Credits: https://raw.githubusercontent.com/optimisme/gjs-examples/master/egCairo.js +GJS example showing how to build Gtk javascript applications +using Gtk and Cairo, the left example adds one Cairo actor to +Clutter, the example on the right adds one Cairo widget to GTK +using GtkClutter.Embed, Gtk.DrawingArea, Cairo.Context, +Clutter.Canvas + +Run it with: + gjs egCairo.js +*/ +import type Cairo from 'cairo'; +import Clutter from 'gi://Clutter?version=1.0'; +import GtkClutter from 'gi://GtkClutter?version=1.0'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import Gtk from 'gi://Gtk?version=3.0'; + +// Get application folder and add it into the imports path +function getAppFileInfo() { + let stack = (new Error()).stack, + stackLine = stack?.split('\n')[1], + coincidence, path, file; + + if (!stackLine) throw new Error('Could not find current file (1)'); + + coincidence = new RegExp('@(.+):\\d+').exec(stackLine); + if (!coincidence) throw new Error('Could not find current file (2)'); + + path = coincidence[1]; + file = Gio.File.new_for_path(path); + return [file.get_path(), file.get_parent()!.get_path(), file.get_basename()]; +} +const path = getAppFileInfo()[1]; +imports.searchPath.push(path!); + +class App { + title: string; + application?: Gtk.Application; + window?: Gtk.ApplicationWindow; + constructor() { + this.title = 'Example Cairo'; + GLib.set_prgname(this.title); + } + + run(argv: string[] | null | undefined): number { + this.application = new Gtk.Application(); + this.application.connect('activate', () => { this.onActivate(); }); + this.application.connect('startup', () => { this.onStartup(); }); + return this.application.run([]); + } + + onActivate() { + this.window!.show_all(); + } + + + onStartup() { + this.initClutter(); + this.buildUI(); + }; + + initClutter() { + + GtkClutter.init(null); + Clutter.init(null); + }; + + buildUI() { + + this.window = new Gtk.ApplicationWindow({ application: this.application, + title: this.title, + default_height: 300, + default_width: 500, + window_position: Gtk.WindowPosition.CENTER }); + try { + this.window.set_icon_from_file(path + '/assets/appIcon.png'); + } catch (err) { + this.window.set_icon_name('application-x-executable'); + } + + this.window.add(this.buildBody()); + }; + + buildBody() { + + const embed = new GtkClutter.Embed(); + embed.set_size_request(250, 300); + + const area = new Gtk.DrawingArea(); + area.set_size_request(250, 300); + area.connect('draw', (area, ctx) => { this.drawRed(area, ctx as Cairo.Context); }); + + const grid = new Gtk.Grid({ column_spacing: 6, margin: 15, row_spacing: 6 }); + grid.attach(embed, 0, 0, 1, 1); + grid.attach(area, 1, 0, 1, 1); + + const stage = embed.get_stage(); + stage.backgroundColor = new Clutter.Color({ red: 255, green: 255, blue: 255, alpha: 255 }); + stage.add_child(this.getClutterActor()); + + return grid; + }; + + getClutterActor() { + + let canvas, actor; + + canvas = new Clutter.Canvas({ + height: 100, + width: 100 + }); + canvas.set_size(100,100); + canvas.connect('draw', (area, ctx) => { this.drawGreen(area, ctx as Cairo.Context); }); + canvas.invalidate(); + + actor = new Clutter.Actor({ + x: 75, y: 100, + height: 100, width: 100 + }); + actor.set_content(canvas); + + return actor; + }; + + drawRed(area: Gtk.DrawingArea, ctx: Cairo.Context) { + + // area is Gtk.DrawingArea + // ctx is Cairo.Context + + let height, width; + + height = area.get_allocated_height(); + width = area.get_allocated_width(); + + this.draw(ctx, height, width, 'red'); + }; + + drawGreen(canvas: Clutter.Canvas, ctx: Cairo.Context) { + + // canvas is Clutter.Canvas + // ctx is Cairo.Context + + let height, width; + + height = canvas.height; + width = canvas.width; + + this.draw(ctx, height, width, 'green'); + }; + + draw(ctx: Cairo.Context, height: number, width: number, color: string) { + + let xc, yc; + + xc = width / 2; + yc = height / 2; + + ctx.save(); + if (color === 'red') { + // Set black background for 'red' + ctx.setSourceRGBA(0, 0, 0, 1); + } else { + // Set grey background + ctx.setSourceRGBA(0.75, 0.75, 0.75, 1); + } + ctx.paint(); + ctx.restore(); + + if (color === 'red') { + ctx.setSourceRGBA(1, 0, 0, 1); + } else { + ctx.setSourceRGBA(0, 0.5, 0, 1); + } + + ctx.moveTo(0, 0); + ctx.lineTo(xc, yc); + ctx.lineTo(0, height); + ctx.moveTo(xc, yc); + ctx.lineTo(width, yc); + ctx.stroke(); + + return false; + }; +} + + + + +//Run the application +let app = new App(); +app.run(ARGV); + diff --git a/examples/gtk-3-clutter-tsc/package.json b/examples/gtk-3-clutter-tsc/package.json new file mode 100644 index 000000000..40ed69644 --- /dev/null +++ b/examples/gtk-3-clutter-tsc/package.json @@ -0,0 +1,32 @@ +{ + "name": "@ts-for-gir-example/gtk-3-clutter-tsc-tsc", + "version": "4.0.0-beta.10", + "description": "Simple GJS GTK+3 Clutter example app", + "type": "module", + "private": true, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "build:app": "tsc", + "build": "yarn build:app", + "start:app": "gjs -m dist/main.js", + "debug:app": "GTK_DEBUG=interactive yarn start:app", + "start": "yarn build && yarn start:app", + "validate": "yarn validate:types", + "validate:types": "tsc --noEmit", + "clear": "rm -rf dist @types" + }, + "author": "Pascal Garber ", + "license": "MIT", + "devDependencies": { + "typescript": "^5.5.3" + }, + "dependencies": { + "@girs/clutter-1.0": "workspace:^", + "@girs/gdk-3.0": "workspace:^", + "@girs/gio-2.0": "workspace:^", + "@girs/gjs": "workspace:^", + "@girs/glib-2.0": "workspace:^", + "@girs/gtk-3.0": "workspace:^", + "@girs/gtkclutter-1.0": "workspace:^" + } +} diff --git a/examples/gtk-3-clutter-tsc/tsconfig.json b/examples/gtk-3-clutter-tsc/tsconfig.json new file mode 100644 index 000000000..e41cc2aa7 --- /dev/null +++ b/examples/gtk-3-clutter-tsc/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "lib": ["ESNext"], + "types": ["@girs/gjs", "@girs/gjs/dom", "@girs/gio-2.0", "@girs/glib-2.0", "@girs/gtk-3.0", "@girs/clutter-1.0", "@girs/gtkclutter-1.0"], + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "bundler", + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "noImplicitThis": true, + "alwaysStrict": true, + "outDir": "./dist" + }, + "files": [ + "main.ts", + ] +} diff --git a/yarn.lock b/yarn.lock index fa73f837d..6cf4249e0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4047,6 +4047,7 @@ __metadata: version: 0.0.0-use.local resolution: "@girs/gjs@workspace:types/gjs" dependencies: + "@girs/cairo-1.0": "workspace:^" "@girs/gio-2.0": "workspace:^" "@girs/glib-2.0": "workspace:^" "@girs/gobject-2.0": "workspace:^" @@ -5793,7 +5794,7 @@ __metadata: languageName: unknown linkType: soft -"@girs/gtkclutter-1.0@workspace:types/gtkclutter-1.0": +"@girs/gtkclutter-1.0@workspace:^, @girs/gtkclutter-1.0@workspace:types/gtkclutter-1.0": version: 0.0.0-use.local resolution: "@girs/gtkclutter-1.0@workspace:types/gtkclutter-1.0" dependencies: @@ -12443,6 +12444,21 @@ __metadata: languageName: unknown linkType: soft +"@ts-for-gir-example/gtk-3-clutter-tsc-tsc@workspace:examples/gtk-3-clutter-tsc": + version: 0.0.0-use.local + resolution: "@ts-for-gir-example/gtk-3-clutter-tsc-tsc@workspace:examples/gtk-3-clutter-tsc" + dependencies: + "@girs/clutter-1.0": "workspace:^" + "@girs/gdk-3.0": "workspace:^" + "@girs/gio-2.0": "workspace:^" + "@girs/gjs": "workspace:^" + "@girs/glib-2.0": "workspace:^" + "@girs/gtk-3.0": "workspace:^" + "@girs/gtkclutter-1.0": "workspace:^" + typescript: "npm:^5.5.3" + languageName: unknown + linkType: soft + "@ts-for-gir-example/gtk-3-editor-example@workspace:examples/gtk-3-editor": version: 0.0.0-use.local resolution: "@ts-for-gir-example/gtk-3-editor-example@workspace:examples/gtk-3-editor" From 52a49acef4772bfea742e51f2cebb5efd71b502a Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Wed, 24 Jul 2024 18:51:55 +0200 Subject: [PATCH 05/10] Add example to README --- examples/README.md | 37 +++++++++++++++++++++---- examples/gtk-3-clutter-tsc/main.ts | 2 +- examples/gtk-3-clutter-tsc/preview.png | Bin 0 -> 7212 bytes 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 examples/gtk-3-clutter-tsc/preview.png diff --git a/examples/README.md b/examples/README.md index 2ae76919c..88dca36fc 100644 --- a/examples/README.md +++ b/examples/README.md @@ -57,10 +57,10 @@ Run the client: yarn start:client ``` -## Gtk-3.0 Browser +## Gtk3 Browser ![gtk-3-browser](gtk-3-browser/preview.png) -A simple browser using Gtk-3.0 and WebKit-2.0 +A simple browser using Gtk3 and WebKit-2.0 Source: [gtk-3-browser](gtk-3-browser) Bundler: Webpack @@ -71,7 +71,7 @@ cd /examples/gtk-3-browser yarn start ``` -## Gtk-3.0 Builder +## Gtk3 Builder ![gtk-3-builder](gtk-3-builder/preview.png) Source: [gtk-3-builder](gtk-3-builder) @@ -83,7 +83,32 @@ cd /examples/gtk-3-builder yarn start ``` -## Gtk-3.0 Editor +## Gtk3 Calc +![gtk-3-calc](gtk-3-calc/preview.png) + +Source: [gtk-3-calc](gtk-3-calc) +Bundler: Esbuild + +Build and run: +```bash +cd /examples/gtk-3-calc +yarn start +``` + +## Gtk3 Clutter (TSC) +![gtk-3-clutter](gtk-3-clutter-tsc/preview.png) + +Source: [gtk-3-clutter](gtk-3-clutter-tsc) +Bundler: TSC + +Build and run: +```bash +cd /examples/gtk-3-clutter-tsc +yarn start +``` + + +## Gtk3 Editor ![gtk-3-editor](gtk-3-editor/preview.png) Source: [gtk-3-editor](gtk-3-editor) @@ -95,7 +120,7 @@ cd /examples/gtk-3-editor yarn start ``` -## Gtk-3.0 Hello Gtk +## Gtk3 Hello Gtk ![gtk-3-hello](gtk-3-hello/preview.png) Source: [gtk-3-hello](gtk-3-hello) @@ -107,7 +132,7 @@ cd /examples/gtk-3-hello yarn start ``` -## Gtk-4.0 ListStore +## Gtk4 ListStore ![gtk-4-list-store](gtk-4-list-store/preview.png) GJS example showing how to build Gtk4 applications using `Gtk.TreeView` and `Gtk.ListStore` diff --git a/examples/gtk-3-clutter-tsc/main.ts b/examples/gtk-3-clutter-tsc/main.ts index 39376866e..f00b3d16c 100644 --- a/examples/gtk-3-clutter-tsc/main.ts +++ b/examples/gtk-3-clutter-tsc/main.ts @@ -41,7 +41,7 @@ class App { application?: Gtk.Application; window?: Gtk.ApplicationWindow; constructor() { - this.title = 'Example Cairo'; + this.title = 'Gtk3 Clutter'; GLib.set_prgname(this.title); } diff --git a/examples/gtk-3-clutter-tsc/preview.png b/examples/gtk-3-clutter-tsc/preview.png new file mode 100644 index 0000000000000000000000000000000000000000..3d05e0e082a3921da6b53fe38fc3adc4a725e4a7 GIT binary patch literal 7212 zcmai3c{tST+y9D4k)%_hPzEhT%~-R|v1Lo8g|cQF4k=_`r<2H$LYA=&=Ny#EzVFGt zjmVU>vSutbgJBrno6hfj&-GsKb-n!Yndg3<=W~Ca?Y{51Cj8Px9q!!%yAcH8*1e#4 z1wnRT5QOEAUF=}#WGI9Ju(|)LdvzE5`R}p~gEqg1mWhY4tG$PpwVNH{aL3ifPRiZJ z&Cc$QJI>W(fwfi@2A$d(q~T^~?cwNpN93xbiydOhSH0@}uR~YTvMd)mH%q< zin31*QP0W$)&6D(`olDiS#|T#0xRvdK9Q7z7)0GY!C8-ri{^+PN*edlm6Jcy zU|1^`bjKwlJMjeWrj0#O?DizeG}d;ZJ7~U8;z;1fbcxJ3yBB*7BUW6+eUyf!QRXy( zqUQcKTq5vTt910M-`-t(ebPz$t^HeIP`)XA+i7oNI%@D};K~;rvyD&fXI_3N_^XnB z5SjK`8sC@__FF$GKjJ-BtQ(kQYa{Bc-8E3;x6A4D*iJ**r^IJyw7Wojx$Z$>&yUtd z)nDD?&2Q#aIJzaPghbmsVKKOuEAejOK`O#%XqD#!dCxzS`10kdl}<=>4Pv zTe?A=>=y6pK#<;RYr|vofvHB_J5I{Y_6-USP9^7L`io1}Yx=2|dY{AxF!-7y_z~jy znReBs@TjBY!-u(L2{w6lvMKo&n+z5Uc6Rc}a?5sgNM0xyov|EQ&n>n!r7!G5E@>@& z`7%16-@PHNN2Q@Cf(}k{CCZDjo(_&pe)Ia3cD)xqO6Gi+(XU)9xPquZ|G>^3H<2GB zrXgjtS11AZt?yfRx+6Ei<(xBt8}Tr%js~)=9ag zCaa_yA_;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date: Wed, 24 Jul 2024 18:55:09 +0200 Subject: [PATCH 06/10] Update types submodule --- types | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types b/types index 88ef9dae1..30c98940f 160000 --- a/types +++ b/types @@ -1 +1 @@ -Subproject commit 88ef9dae197ef610481608dd1910264c3b30a253 +Subproject commit 30c98940fb55c4908c2a44d198413690fffd54f3 From f938f6f12884ca45cd1c52eac8e9294b8b6a8234 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Wed, 24 Jul 2024 19:15:14 +0200 Subject: [PATCH 07/10] New cairo example added --- examples/cairo-surfaces-tsc/main.ts | 11 +++++++++ examples/cairo-surfaces-tsc/package.json | 26 ++++++++++++++++++++++ examples/cairo-surfaces-tsc/preview.png | Bin 0 -> 7212 bytes examples/cairo-surfaces-tsc/tsconfig.json | 18 +++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 examples/cairo-surfaces-tsc/main.ts create mode 100644 examples/cairo-surfaces-tsc/package.json create mode 100644 examples/cairo-surfaces-tsc/preview.png create mode 100644 examples/cairo-surfaces-tsc/tsconfig.json diff --git a/examples/cairo-surfaces-tsc/main.ts b/examples/cairo-surfaces-tsc/main.ts new file mode 100644 index 000000000..6a87e986e --- /dev/null +++ b/examples/cairo-surfaces-tsc/main.ts @@ -0,0 +1,11 @@ +import Cairo from 'cairo'; + +const imageSurface = new Cairo.ImageSurface(Cairo.Format.ARGB32, 10, 10); + +const pngSurface = Cairo.ImageSurface.createFromPNG('filename.png'); + +const pdfSurface = new Cairo.PDFSurface('filename.pdf', 32, 32); + +const psSurface = new Cairo.PSSurface('filename.ps', 32, 32); + +const svgSurface = new Cairo.SVGSurface('filename.svg', 32, 32); \ No newline at end of file diff --git a/examples/cairo-surfaces-tsc/package.json b/examples/cairo-surfaces-tsc/package.json new file mode 100644 index 000000000..f038a76db --- /dev/null +++ b/examples/cairo-surfaces-tsc/package.json @@ -0,0 +1,26 @@ +{ + "name": "@ts-for-gir-example/cairo-surfaces-tsc", + "version": "4.0.0-beta.12", + "description": "Simple cairo-surfaces GJS example", + "type": "module", + "private": true, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "build:app": "tsc", + "build": "yarn build:app", + "start:app": "gjs -m dist/main.js", + "debug:app": "GTK_DEBUG=interactive yarn start:app", + "start": "yarn build && yarn start:app", + "validate": "yarn validate:types", + "validate:types": "tsc --noEmit", + "clear": "rm -rf dist @types" + }, + "author": "Pascal Garber ", + "license": "MIT", + "devDependencies": { + "typescript": "^5.5.3" + }, + "dependencies": { + "@girs/gjs": "workspace:^" + } +} diff --git a/examples/cairo-surfaces-tsc/preview.png b/examples/cairo-surfaces-tsc/preview.png new file mode 100644 index 0000000000000000000000000000000000000000..3d05e0e082a3921da6b53fe38fc3adc4a725e4a7 GIT binary patch literal 7212 zcmai3c{tST+y9D4k)%_hPzEhT%~-R|v1Lo8g|cQF4k=_`r<2H$LYA=&=Ny#EzVFGt zjmVU>vSutbgJBrno6hfj&-GsKb-n!Yndg3<=W~Ca?Y{51Cj8Px9q!!%yAcH8*1e#4 z1wnRT5QOEAUF=}#WGI9Ju(|)LdvzE5`R}p~gEqg1mWhY4tG$PpwVNH{aL3ifPRiZJ z&Cc$QJI>W(fwfi@2A$d(q~T^~?cwNpN93xbiydOhSH0@}uR~YTvMd)mH%q< zin31*QP0W$)&6D(`olDiS#|T#0xRvdK9Q7z7)0GY!C8-ri{^+PN*edlm6Jcy zU|1^`bjKwlJMjeWrj0#O?DizeG}d;ZJ7~U8;z;1fbcxJ3yBB*7BUW6+eUyf!QRXy( zqUQcKTq5vTt910M-`-t(ebPz$t^HeIP`)XA+i7oNI%@D};K~;rvyD&fXI_3N_^XnB z5SjK`8sC@__FF$GKjJ-BtQ(kQYa{Bc-8E3;x6A4D*iJ**r^IJyw7Wojx$Z$>&yUtd z)nDD?&2Q#aIJzaPghbmsVKKOuEAejOK`O#%XqD#!dCxzS`10kdl}<=>4Pv zTe?A=>=y6pK#<;RYr|vofvHB_J5I{Y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c@r1gQRIO`de1G9N*p%t3lmnHj+T%rQE0>ix zpY})bQ=I=uU_r!ldJp}1gl?VHs@Y;9eA*TX{w8qRM9Ehw>qS#o7z<*rr^CzopC7>1 a>o+;{_O~mvvN8g;Y`R((HQ)Sdh5s*X`jT+~ literal 0 HcmV?d00001 diff --git a/examples/cairo-surfaces-tsc/tsconfig.json b/examples/cairo-surfaces-tsc/tsconfig.json new file mode 100644 index 000000000..d89d6540d --- /dev/null +++ b/examples/cairo-surfaces-tsc/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "lib": ["ESNext"], + "types": ["@girs/gjs", "@girs/gjs/dom"], + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "bundler", + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "noImplicitThis": true, + "alwaysStrict": true, + "outDir": "./dist" + }, + "files": [ + "main.ts", + ] +} From 200bae07ee195142506f809c294294f7649b7eb0 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Wed, 24 Jul 2024 19:16:15 +0200 Subject: [PATCH 08/10] Bump version 4.0.0-beta.12 --- 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-clutter-tsc/package.json | 4 +- 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-esbuild/package.json | 2 +- examples/gtk-4-template-tsc/package.json | 2 +- examples/gtk-4-template-vite/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 | 2 +- packages/cli/package.json | 2 +- packages/generator-base/package.json | 2 +- packages/generator-html-doc/package.json | 2 +- packages/generator-typescript/package.json | 2 +- .../templates/gjs/cairo.d.ts | 617 +++++++++++++----- packages/lib/package.json | 2 +- yarn.lock | 13 +- 34 files changed, 506 insertions(+), 190 deletions(-) diff --git a/examples/adw-1-hello/package.json b/examples/adw-1-hello/package.json index e280f1660..53a12d172 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.10", + "version": "4.0.0-beta.12", "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 3cceda1a6..488ef4475 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.10", + "version": "4.0.0-beta.12", "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 a923e1ccb..2fb473f85 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.10", + "version": "4.0.0-beta.12", "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 0e9f9c603..a8fedb64f 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.10", + "version": "4.0.0-beta.12", "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 13ba7033d..4d7604f3e 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.10", + "version": "4.0.0-beta.12", "description": "", "type": "module", "private": true, diff --git a/examples/glib-2-variant/package.json b/examples/glib-2-variant/package.json index 0bb7eeec7..a1bd398ab 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.10", + "version": "4.0.0-beta.12", "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 5bd8bebae..c41c898b4 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.10", + "version": "4.0.0-beta.12", "type": "module", "private": true, "scripts": { diff --git a/examples/gtk-3-builder/package.json b/examples/gtk-3-builder/package.json index d849eedbb..1f7036fab 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.10", + "version": "4.0.0-beta.12", "type": "module", "private": true, "scripts": { diff --git a/examples/gtk-3-calc/package.json b/examples/gtk-3-calc/package.json index 903cc98d8..88da6cb59 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.10", + "version": "4.0.0-beta.12", "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 40ed69644..f3a09ab13 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-tsc", - "version": "4.0.0-beta.10", + "name": "@ts-for-gir-example/gtk-3-clutter-tsc", + "version": "4.0.0-beta.12", "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 843bd94d7..0cd819fdf 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.10", + "version": "4.0.0-beta.12", "type": "module", "targets": { ".": { diff --git a/examples/gtk-3-hello-2/package.json b/examples/gtk-3-hello-2/package.json index 5b5a5d77f..db24852ce 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.10", + "version": "4.0.0-beta.12", "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 8c6e0a119..122b72b78 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.10", + "version": "4.0.0-beta.12", "type": "module", "private": true, "scripts": { diff --git a/examples/gtk-3-template/package.json b/examples/gtk-3-template/package.json index 7ae8df675..17add9eee 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.10", + "version": "4.0.0-beta.12", "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 cc8a78fe5..a3601113c 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.10", + "version": "4.0.0-beta.12", "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 136317d73..d2b384da4 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.10", + "version": "4.0.0-beta.12", "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 dfa7e24c2..b835a8c9e 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.10", + "version": "4.0.0-beta.12", "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 5a0549783..175feaf1d 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.10", + "version": "4.0.0-beta.12", "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 b93e414ee..9492dad2f 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.10", + "version": "4.0.0-beta.12", "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 b59880487..43d09367f 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.10", + "version": "4.0.0-beta.12", "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 29514f879..e12118579 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.10", + "version": "4.0.0-beta.12", "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 7a0c5fe25..8f0537ea8 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.10", + "version": "4.0.0-beta.12", "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/run-async/package.json b/examples/run-async/package.json index 38df48aa8..41d138484 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.10", + "version": "4.0.0-beta.12", "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 269113a7b..44d15de37 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.10", + "version": "4.0.0-beta.12", "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 296f226d1..227f75287 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.10", + "version": "4.0.0-beta.12", "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 5153a38e8..0a31e34ac 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.10", + "version": "4.0.0-beta.12", "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 4086f5911..6fe6402f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-for-gir", - "version": "4.0.0-beta.11", + "version": "4.0.0-beta.12", "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 3635fcc8d..79f884f60 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.11", + "version": "4.0.0-beta.12", "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 e35a2f064..f7486f26b 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.11", + "version": "4.0.0-beta.12", "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 2289eed62..d119d44f0 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.11", + "version": "4.0.0-beta.12", "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 9dba82de8..3855bdb75 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.11", + "version": "4.0.0-beta.12", "description": "TypeScript type definition generator for ts-for-gir", "module": "lib/index.js", "main": "lib/index.js", diff --git a/packages/generator-typescript/templates/gjs/cairo.d.ts b/packages/generator-typescript/templates/gjs/cairo.d.ts index b798160d0..071b45158 100644 --- a/packages/generator-typescript/templates/gjs/cairo.d.ts +++ b/packages/generator-typescript/templates/gjs/cairo.d.ts @@ -1,4 +1,5 @@ <%_ const Cairo = await dep.get('cairo', '1.0') _%> +<%_ const GObject = await dep.get('gobject', '2.0') _%> <%_ if(!package){ -%> declare module 'cairo' { @@ -6,182 +7,488 @@ declare module 'cairo' { // Cairo 1.0 import type Cairo from '<%- Cairo.importPath %>'; +import type GObject from '<%- GObject.importPath %>'; <%- package ? 'declare' : '' %> namespace giCairo { -// Add overrides here -// See -// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/doc/cairo.md -// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/installed-tests/js/testCairoModule.js -// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/installed-tests/js/testCairo.js -// - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/cairo-context.cpp - -// Re-exported enums -export type Status = Cairo.Status; -export type Content = Cairo.Content; -export type Operator = Cairo.Operator; -export type Antialias = Cairo.Antialias; -export type FillRule = Cairo.FillRule; -export type LineCap = Cairo.LineCap; -export type LineJoin = Cairo.LineJoin; -export type TextClusterFlags = Cairo.TextClusterFlags; -export type FontSlant = Cairo.FontSlant; -export type FontWeight = Cairo.FontWeight; -export type SubpixelOrder = Cairo.SubpixelOrder; -export type HintStyle = Cairo.HintStyle; -export type HintMetrics = Cairo.HintMetrics; -export type FontType = Cairo.FontType; -export type PathDataType = Cairo.PathDataType; -export type DeviceType = Cairo.DeviceType; -export type SurfaceType = Cairo.SurfaceType; -export type Format = Cairo.Format; -export type PatternType = Cairo.PatternType; -export type Extend = Cairo.Extend; -export type Filter = Cairo.Filter; -export type RegionOverlap = Cairo.RegionOverlap; - -export class Context extends Cairo.Context { - constructor(surface: Surface); - - arc(xc: number, yc: number, radius: number, angle1: number, angle2: number): void; - arcNegative(xc: number, yc: number, radius: number, angle1: number, angle2: number): void; - curveTo(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void; - clip(): void; - clipPreserve(): void; - clipExtents(): [number, number, number, number]; - closePath(): void; - copyPage(): void; - deviceToUser(x: number, y: number): [number, number]; - deviceToUserDistance(x: number, y: number): [number, number]; - fill(): void; - fillPreserve(): void; - fillExtents(): [number, number, number, number]; - getAntialias(): Antialias; - getCurrentPoint(): [number, number]; - getDashCount(): number; - getFillRule(): FillRule; - getLineCap(): LineCap; - getLineJoin(): LineJoin; - getLineWidth(): number; - getMiterLimit(): number; - getOperator(): Operator; - getTolerance(): number; - hasCurrentPoint(): boolean; - identityMatrix(): void; - inFill(x: number, y: number): boolean; - inStroke(x: number, y: number): boolean; - lineTo(x: number, y: number): void; - moveTo(x: number, y: number): void; - newPath(): void; - newSubPath(): void; - paint(): void; - paintWithAlpha(alpha: number): void; - pathExtents(): [number, number, number, number]; - popGroup(): Pattern; - popGroupToSource(): void; - pushGroup(): void; - pushGroupWithContent(content: Content): void; - rectangle(x: number, y: number, width: number, height: number): void; - relCurveTo(dx1: number, dy1: number, dx2: number, dy2: number, dx3: number, dy3: number): void; - relLineTo(dx: number, dy: number): void; - relMoveTo(dx: number, dy: number): void; - resetClip(): void; - restore(): void; - rotate(angle: number): void; - save(): void; - scale(sx: number, sy: number): void; - selectFontFace(family: string, slant: number, weight: number): void; - setAntialias(antialias: Antialias): void; - setDash(dashes: number[], offset: number): void; - setFontSize(size: number): void; - setFillRule(fillRule: FillRule): void; - setLineCap(lineCap: LineCap): void; - setLineJoin(lineJoin: LineJoin): void; - setLineWidth(width: number): void; - setMiterLimit(limit: number): void; - setOperator(op: Operator): void; - setSource(pattern: Pattern): void; - setSourceRGB(red: number, green: number, blue: number): void; - setSourceRGBA(red: number, green: number, blue: number, alpha: number): void; - setSourceSurface(surface: Surface, x: number, y: number): void; - setTolerance(tolerance: number): void; - showPage(): void; - showText(utf8: string): void; - stroke(): void; - strokePreserve(): void; - strokeExtents(): [number, number, number, number]; - textExtents(utf8: string): TextExtents; - translate(tx: number, ty: number): void; - userToDevice(x: number, y: number): [number, number]; - userToDeviceDistance(x: number, y: number): [number, number]; -} + // Add overrides here + // See + // - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/doc/cairo.md + // - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/installed-tests/js/testCairoModule.js + // - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/installed-tests/js/testCairo.js + // - https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/cairo-context.cpp -export abstract class Surface extends Cairo.Surface { - // TODO -} + // Re-exported enums + export namespace Status { + export const $gtype: GObject.GType; + } -export class ImageSurface extends Surface { - constructor(format: Format, width: number, height: number); + enum Status { + SUCCESS, + NO_MEMORY, + INVALID_RESTORE, + INVALID_POP_GROUP, + NO_CURRENT_POINT, + INVALID_MATRIX, + INVALID_STATUS, + NULL_POINTER, + INVALID_STRING, + INVALID_PATH_DATA, + READ_ERROR, + WRITE_ERROR, + SURFACE_FINISHED, + SURFACE_TYPE_MISMATCH, + PATTERN_TYPE_MISMATCH, + INVALID_CONTENT, + INVALID_FORMAT, + INVALID_VISUAL, + FILE_NOT_FOUND, + INVALID_DASH, + INVALID_DSC_COMMENT, + INVALID_INDEX, + CLIP_NOT_REPRESENTABLE, + TEMP_FILE_ERROR, + INVALID_STRIDE, + FONT_TYPE_MISMATCH, + USER_FONT_IMMUTABLE, + USER_FONT_ERROR, + NEGATIVE_COUNT, + INVALID_CLUSTERS, + INVALID_SLANT, + INVALID_WEIGHT, + INVALID_SIZE, + USER_FONT_NOT_IMPLEMENTED, + DEVICE_TYPE_MISMATCH, + DEVICE_ERROR, + INVALID_MESH_CONSTRUCTION, + DEVICE_FINISHED, + JBIG2_GLOBAL_MISSING, + } - static createFromPNG(filename: string): ImageSurface; + export namespace Content { + export const $gtype: GObject.GType; + } - // TODO -} + enum Content { + COLOR, + ALPHA, + COLOR_ALPHA, + } -export class PDFSurface extends Surface { - constructor(filename: string, width: number, height: number); + export namespace Operator { + export const $gtype: GObject.GType; + } - // TODO -} + enum Operator { + CLEAR, + SOURCE, + OVER, + IN, + OUT, + ATOP, + DEST, + DEST_OVER, + DEST_IN, + DEST_OUT, + DEST_ATOP, + XOR, + ADD, + SATURATE, + MULTIPLY, + SCREEN, + OVERLAY, + DARKEN, + LIGHTEN, + COLOR_DODGE, + COLOR_BURN, + HARD_LIGHT, + SOFT_LIGHT, + DIFFERENCE, + EXCLUSION, + HSL_HUE, + HSL_SATURATION, + HSL_COLOR, + HSL_LUMINOSITY, + } -export class PSSurface extends Surface { - constructor(filename: string, width: number, height: number); + export namespace Antialias { + export const $gtype: GObject.GType; + } - // TODO -} + enum Antialias { + DEFAULT, + NONE, + GRAY, + SUBPIXEL, + FAST, + GOOD, + BEST, + } -export class SVGSurface extends Surface { - constructor(filename: string, width: number, height: number); + export namespace FillRule { + export const $gtype: GObject.GType; + } - // TODO -} + enum FillRule { + WINDING, + EVEN_ODD, + } -export class Pattern extends Cairo.Pattern { - // TODO -} + export namespace LineCap { + export const $gtype: GObject.GType; + } -export class Gradient extends Pattern { - // TODO -} + enum LineCap { + BUTT, + ROUND, + SQUARE, + } -export class LinearGradient extends Gradient { - // TODO -} + export namespace LineJoin { + export const $gtype: GObject.GType; + } -export class RadialGradient extends Gradient { - // TODO -} + enum LineJoin { + MITER, + ROUND, + BEVEL, + } -export class SurfacePattern extends Pattern { - // TODO -} + export namespace TextClusterFlags { + export const $gtype: GObject.GType; + } -export class SolidPattern extends Pattern { - // TODO -} + enum TextClusterFlags { + BACKWARD, + } -export class Path extends Cairo.Path { - // TODO -} + export namespace FontSlant { + export const $gtype: GObject.GType; + } -export interface TextExtents { - xBearing: number; - yBearing: number; - width: number; - height: number; - xAdvance: number; - yAdvance: number; -} + enum FontSlant { + NORMAL, + ITALIC, + OBLIQUE, + } + + export namespace FontWeight { + export const $gtype: GObject.GType; + } + + enum FontWeight { + NORMAL, + BOLD, + } + + export namespace SubpixelOrder { + export const $gtype: GObject.GType; + } + + enum SubpixelOrder { + DEFAULT, + RGB, + BGR, + VRGB, + VBGR, + } + + export namespace HintStyle { + export const $gtype: GObject.GType; + } + + enum HintStyle { + DEFAULT, + NONE, + SLIGHT, + MEDIUM, + FULL, + } + + export namespace HintMetrics { + export const $gtype: GObject.GType; + } + + enum HintMetrics { + DEFAULT, + OFF, + ON, + } + + export namespace FontType { + export const $gtype: GObject.GType; + } + + enum FontType { + TOY, + FT, + WIN32, + QUARTZ, + USER, + } + + export namespace PathDataType { + export const $gtype: GObject.GType; + } + + enum PathDataType { + MOVE_TO, + LINE_TO, + CURVE_TO, + CLOSE_PATH, + } + + export namespace DeviceType { + export const $gtype: GObject.GType; + } + + enum DeviceType { + DRM, + GL, + SCRIPT, + XCB, + XLIB, + XML, + COGL, + WIN32, + INVALID, + } + + export namespace SurfaceType { + export const $gtype: GObject.GType; + } + + enum SurfaceType { + IMAGE, + PDF, + PS, + XLIB, + XCB, + GLITZ, + QUARTZ, + WIN32, + BEOS, + DIRECTFB, + SVG, + OS2, + WIN32_PRINTING, + QUARTZ_IMAGE, + SCRIPT, + QT, + RECORDING, + VG, + GL, + DRM, + TEE, + XML, + SKIA, + SUBSURFACE, + COGL, + } + + export namespace Format { + export const $gtype: GObject.GType; + } + + enum Format { + INVALID, + ARGB32, + RGB24, + A8, + A1, + RGB16_565, + RGB30, + } + + export namespace PatternType { + export const $gtype: GObject.GType; + } + + enum PatternType { + SOLID, + SURFACE, + LINEAR, + RADIAL, + MESH, + RASTER_SOURCE, + } + + export namespace Extend { + export const $gtype: GObject.GType; + } + + enum Extend { + NONE, + REPEAT, + REFLECT, + PAD, + } + + export namespace Filter { + export const $gtype: GObject.GType; + } + + enum Filter { + FAST, + GOOD, + BEST, + NEAREST, + BILINEAR, + GAUSSIAN, + } + + export namespace RegionOverlap { + export const $gtype: GObject.GType; + } + + enum RegionOverlap { + IN, + OUT, + PART, + } + + export class Context extends Cairo.Context { + constructor(surface: Surface); + + arc(xc: number, yc: number, radius: number, angle1: number, angle2: number): void; + arcNegative(xc: number, yc: number, radius: number, angle1: number, angle2: number): void; + curveTo(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void; + clip(): void; + clipPreserve(): void; + clipExtents(): [number, number, number, number]; + closePath(): void; + copyPage(): void; + deviceToUser(x: number, y: number): [number, number]; + deviceToUserDistance(x: number, y: number): [number, number]; + fill(): void; + fillPreserve(): void; + fillExtents(): [number, number, number, number]; + getAntialias(): Antialias; + getCurrentPoint(): [number, number]; + getDashCount(): number; + getFillRule(): FillRule; + getLineCap(): LineCap; + getLineJoin(): LineJoin; + getLineWidth(): number; + getMiterLimit(): number; + getOperator(): Operator; + getTolerance(): number; + hasCurrentPoint(): boolean; + identityMatrix(): void; + inFill(x: number, y: number): boolean; + inStroke(x: number, y: number): boolean; + lineTo(x: number, y: number): void; + moveTo(x: number, y: number): void; + newPath(): void; + newSubPath(): void; + paint(): void; + paintWithAlpha(alpha: number): void; + pathExtents(): [number, number, number, number]; + popGroup(): Pattern; + popGroupToSource(): void; + pushGroup(): void; + pushGroupWithContent(content: Content): void; + rectangle(x: number, y: number, width: number, height: number): void; + relCurveTo(dx1: number, dy1: number, dx2: number, dy2: number, dx3: number, dy3: number): void; + relLineTo(dx: number, dy: number): void; + relMoveTo(dx: number, dy: number): void; + resetClip(): void; + restore(): void; + rotate(angle: number): void; + save(): void; + scale(sx: number, sy: number): void; + selectFontFace(family: string, slant: number, weight: number): void; + setAntialias(antialias: Antialias): void; + setDash(dashes: number[], offset: number): void; + setFontSize(size: number): void; + setFillRule(fillRule: FillRule): void; + setLineCap(lineCap: LineCap): void; + setLineJoin(lineJoin: LineJoin): void; + setLineWidth(width: number): void; + setMiterLimit(limit: number): void; + setOperator(op: Operator): void; + setSource(pattern: Pattern): void; + setSourceRGB(red: number, green: number, blue: number): void; + setSourceRGBA(red: number, green: number, blue: number, alpha: number): void; + setSourceSurface(surface: Surface, x: number, y: number): void; + setTolerance(tolerance: number): void; + showPage(): void; + showText(utf8: string): void; + stroke(): void; + strokePreserve(): void; + strokeExtents(): [number, number, number, number]; + textExtents(utf8: string): TextExtents; + translate(tx: number, ty: number): void; + userToDevice(x: number, y: number): [number, number]; + userToDeviceDistance(x: number, y: number): [number, number]; + } + + export abstract class Surface extends Cairo.Surface { + // TODO + } + + export class ImageSurface extends Surface { + constructor(format: Format, width: number, height: number); + + static createFromPNG(filename: string): ImageSurface; + + // TODO + } + + export class PDFSurface extends Surface { + constructor(filename: string, width: number, height: number); + + // TODO + } + + export class PSSurface extends Surface { + constructor(filename: string, width: number, height: number); + + // TODO + } + + export class SVGSurface extends Surface { + constructor(filename: string, width: number, height: number); + + // TODO + } + + export class Pattern extends Cairo.Pattern { + // TODO + } + + export class Gradient extends Pattern { + // TODO + } + + export class LinearGradient extends Gradient { + // TODO + } + + export class RadialGradient extends Gradient { + // TODO + } + + export class SurfacePattern extends Pattern { + // TODO + } + + export class SolidPattern extends Pattern { + // TODO + } + + export class Path extends Cairo.Path { + // TODO + } + + export interface TextExtents { + xBearing: number; + yBearing: number; + width: number; + height: number; + xAdvance: number; + yAdvance: number; + } } diff --git a/packages/lib/package.json b/packages/lib/package.json index 933699fde..a3abf65a6 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.11", + "version": "4.0.0-beta.12", "description": "Typescript .d.ts generator from GIR for gjs", "module": "lib/index.js", "main": "lib/index.js", diff --git a/yarn.lock b/yarn.lock index 6cf4249e0..bdc2a6eeb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12326,6 +12326,15 @@ __metadata: languageName: unknown linkType: soft +"@ts-for-gir-example/cairo-surfaces-tsc@workspace:examples/cairo-surfaces-tsc": + version: 0.0.0-use.local + resolution: "@ts-for-gir-example/cairo-surfaces-tsc@workspace:examples/cairo-surfaces-tsc" + dependencies: + "@girs/gjs": "workspace:^" + typescript: "npm:^5.5.3" + languageName: unknown + linkType: soft + "@ts-for-gir-example/gio-2-cat-example@workspace:examples/gio-2-cat": version: 0.0.0-use.local resolution: "@ts-for-gir-example/gio-2-cat-example@workspace:examples/gio-2-cat" @@ -12444,9 +12453,9 @@ __metadata: languageName: unknown linkType: soft -"@ts-for-gir-example/gtk-3-clutter-tsc-tsc@workspace:examples/gtk-3-clutter-tsc": +"@ts-for-gir-example/gtk-3-clutter-tsc@workspace:examples/gtk-3-clutter-tsc": version: 0.0.0-use.local - resolution: "@ts-for-gir-example/gtk-3-clutter-tsc-tsc@workspace:examples/gtk-3-clutter-tsc" + resolution: "@ts-for-gir-example/gtk-3-clutter-tsc@workspace:examples/gtk-3-clutter-tsc" dependencies: "@girs/clutter-1.0": "workspace:^" "@girs/gdk-3.0": "workspace:^" From 5d1e31e1c5afefa6fd19fe3fe376e603e38fb303 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Wed, 24 Jul 2024 19:16:48 +0200 Subject: [PATCH 09/10] Update types submodule --- types | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types b/types index 30c98940f..1e5bc4764 160000 --- a/types +++ b/types @@ -1 +1 @@ -Subproject commit 30c98940fb55c4908c2a44d198413690fffd54f3 +Subproject commit 1e5bc476433dfde1508502957a16727906fab6d0 From 31839fc13eaf4dc743a1dab755f566f678b55390 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Wed, 24 Jul 2024 19:53:50 +0200 Subject: [PATCH 10/10] Fix get GObject dependency --- packages/generator-typescript/templates/gjs/cairo.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/generator-typescript/templates/gjs/cairo.d.ts b/packages/generator-typescript/templates/gjs/cairo.d.ts index 071b45158..06461955a 100644 --- a/packages/generator-typescript/templates/gjs/cairo.d.ts +++ b/packages/generator-typescript/templates/gjs/cairo.d.ts @@ -1,5 +1,5 @@ <%_ const Cairo = await dep.get('cairo', '1.0') _%> -<%_ const GObject = await dep.get('gobject', '2.0') _%> +<%_ const GObject = await dep.get('GObject', '2.0') _%> <%_ if(!package){ -%> declare module 'cairo' { @@ -7,7 +7,7 @@ declare module 'cairo' { // Cairo 1.0 import type Cairo from '<%- Cairo.importPath %>'; -import type GObject from '<%- GObject.importPath %>'; +<%- GObject.importDef %> <%- package ? 'declare' : '' %> namespace giCairo {