@gjsify/webgl 0.1.13 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @gjsify/webgl
2
2
 
3
- GJS implementation of WebGL 1.0/2.0 using a custom Vala extension (gwebgl). Provides CanvasWebGLWidget extending Gtk.GLArea.
3
+ GJS implementation of WebGL 1.0/2.0 using a custom Vala extension (gwebgl). Provides WebGLBridge extending Gtk.GLArea.
4
4
 
5
5
  Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
6
6
 
@@ -15,9 +15,9 @@ yarn add @gjsify/webgl
15
15
  ## Usage
16
16
 
17
17
  ```typescript
18
- import { CanvasWebGLWidget } from '@gjsify/webgl';
18
+ import { WebGLBridge } from '@gjsify/webgl';
19
19
 
20
- const widget = new CanvasWebGLWidget();
20
+ const widget = new WebGLBridge();
21
21
  widget.installGlobals();
22
22
 
23
23
  widget.onReady((canvas, gl) => {
@@ -36,6 +36,9 @@ This package ships prebuilt native libraries for supported platforms:
36
36
  prebuilds/
37
37
  linux-x86_64/ libgwebgl.so + Gwebgl-0.1.typelib
38
38
  linux-aarch64/ libgwebgl.so + Gwebgl-0.1.typelib
39
+ linux-ppc64/ libgwebgl.so + Gwebgl-0.1.typelib
40
+ linux-s390x/ libgwebgl.so + Gwebgl-0.1.typelib
41
+ linux-riscv64/ libgwebgl.so + Gwebgl-0.1.typelib
39
42
  ```
40
43
 
41
44
  Use the gjsify CLI to run your app — it automatically sets `LD_LIBRARY_PATH` and
@@ -71,7 +74,7 @@ yarn build:prebuilds
71
74
 
72
75
  ## Prebuilt binaries
73
76
 
74
- Prebuilds for `linux-x86_64` and `linux-aarch64` are built automatically by CI
77
+ Prebuilds for `linux-x86_64`, `linux-aarch64`, `linux-ppc64`, `linux-s390x`, and `linux-riscv64` are built automatically by CI
75
78
  (`.github/workflows/prebuilds.yml`) when the Vala source changes and committed back
76
79
  to the repository. They are included in the npm package via the `files` field.
77
80
 
@@ -1,4 +1,4 @@
1
- import { CanvasWebGLWidget } from "@gjsify/webgl";
1
+ import { WebGLBridge } from "@gjsify/webgl";
2
2
  import GLib from "@girs/glib-2.0";
3
3
  import Gtk from "@girs/gtk-4.0";
4
4
  function createGLSetup() {
@@ -7,7 +7,7 @@ function createGLSetup() {
7
7
  const readyLoop = new GLib.MainLoop(null, false);
8
8
  const win = new Gtk.Window({});
9
9
  win.set_default_size(200, 200);
10
- const glArea = new CanvasWebGLWidget();
10
+ const glArea = new WebGLBridge();
11
11
  glArea.onReady((canvas, g) => {
12
12
  try {
13
13
  const gl = g;
package/lib/esm/index.js CHANGED
@@ -6,7 +6,7 @@ import { WebGL2RenderingContext } from "./webgl2-rendering-context.js";
6
6
  globalThis.WebGLRenderingContext = WebGLRenderingContext;
7
7
  globalThis.WebGL2RenderingContext = WebGL2RenderingContext;
8
8
  export * from "./html-canvas-element.js";
9
- export * from "./canvas-webgl-widget.js";
9
+ export * from "./webgl-bridge.js";
10
10
  export * from "./webgl-active-info.js";
11
11
  export * from "./webgl-buffer.js";
12
12
  export * from "./webgl-context-attributes.js";
@@ -4,9 +4,9 @@ import Gtk from "gi://Gtk?version=4.0";
4
4
  import { HTMLCanvasElement as OurHTMLCanvasElement } from "./html-canvas-element.js";
5
5
  import { attachEventControllers } from "@gjsify/event-bridge";
6
6
  import { Event } from "@gjsify/dom-events";
7
- const CanvasWebGLWidget = GObject.registerClass(
8
- { GTypeName: "GjsifyCanvasWebGLWidget" },
9
- class CanvasWebGLWidget2 extends Gtk.GLArea {
7
+ const WebGLBridge = GObject.registerClass(
8
+ { GTypeName: "GjsifyWebGLBridge" },
9
+ class WebGLBridge2 extends Gtk.GLArea {
10
10
  constructor(params) {
11
11
  super(params);
12
12
  this._canvas = null;
@@ -24,6 +24,12 @@ const CanvasWebGLWidget = GObject.registerClass(
24
24
  this.set_has_depth_buffer(true);
25
25
  this.set_has_stencil_buffer(true);
26
26
  attachEventControllers(this, () => this._canvas, { captureKeys: true });
27
+ this._tickCallbackId = this.add_tick_callback((_widget, _frameClock) => {
28
+ if (this._frameCallback !== null) {
29
+ this.queue_render();
30
+ }
31
+ return GLib.SOURCE_CONTINUE;
32
+ });
27
33
  const initId = this.connect("render", () => {
28
34
  this.disconnect(initId);
29
35
  this.make_current();
@@ -39,6 +45,18 @@ const CanvasWebGLWidget = GObject.registerClass(
39
45
  }
40
46
  this._readyCallbacks = [];
41
47
  }
48
+ this._renderTag = this.connect("render", (_widget) => {
49
+ if (this._frameCallback !== null) {
50
+ const time = (GLib.get_monotonic_time() - this._timeOrigin) / 1e3;
51
+ if (globalThis.__GJSIFY_DEBUG_RAF === true) {
52
+ console.log(`[rAF] frame callback fires t=${time.toFixed(1)}`);
53
+ }
54
+ const cb = this._frameCallback;
55
+ this._frameCallback = null;
56
+ cb(time);
57
+ }
58
+ return true;
59
+ });
42
60
  return true;
43
61
  });
44
62
  this.connect("resize", () => {
@@ -102,30 +120,13 @@ const CanvasWebGLWidget = GObject.registerClass(
102
120
  }
103
121
  /**
104
122
  * Schedules a single animation frame callback, matching the browser `requestAnimationFrame` API.
105
- * Backed by GTK frame clock (vsync-synced) + the GLArea render signal.
106
- * Returns 0 (handle cancel not yet implemented).
123
+ * Backed by a persistent GTK frame clock tick callback (vsync-synced) + a persistent GLArea
124
+ * render signal handler. Both are installed once at construction / first render respectively,
125
+ * eliminating per-frame GLib.Source allocation and GObject signal connect/disconnect overhead.
126
+ * Returns 0 (handle — cancel via cancelAnimationFrame clears the pending callback).
107
127
  */
108
128
  requestAnimationFrame(cb) {
109
129
  this._frameCallback = cb;
110
- if (this._tickCallbackId === null) {
111
- this._tickCallbackId = this.add_tick_callback((_widget, _frameClock) => {
112
- this._tickCallbackId = null;
113
- if (this._renderTag === null) {
114
- this._renderTag = this.connect("render", (_widget2) => {
115
- this.disconnect(this._renderTag);
116
- this._renderTag = null;
117
- const time = (GLib.get_monotonic_time() - this._timeOrigin) / 1e3;
118
- if (globalThis.__GJSIFY_DEBUG_RAF === true) {
119
- console.log(`[rAF] frame callback fires t=${time.toFixed(1)}`);
120
- }
121
- this._frameCallback?.(time);
122
- return true;
123
- });
124
- }
125
- this.queue_render();
126
- return GLib.SOURCE_REMOVE;
127
- });
128
- }
129
130
  this.queue_render();
130
131
  return 0;
131
132
  }
@@ -147,5 +148,5 @@ const CanvasWebGLWidget = GObject.registerClass(
147
148
  }
148
149
  );
149
150
  export {
150
- CanvasWebGLWidget
151
+ WebGLBridge
151
152
  };
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, beforeEach, on } from "@gjsify/unit";
2
- import { CanvasWebGLWidget } from "@gjsify/webgl";
2
+ import { WebGLBridge } from "@gjsify/webgl";
3
3
  import {
4
4
  makeProgram,
5
5
  drawTriangle,
@@ -21,7 +21,7 @@ var webgl1_spec_default = async () => {
21
21
  const readyLoop = new GLib.MainLoop(null, false);
22
22
  const win = new Gtk.Window({});
23
23
  win.set_default_size(200, 200);
24
- glArea = new CanvasWebGLWidget();
24
+ glArea = new WebGLBridge();
25
25
  glArea.onReady((_c, g) => {
26
26
  gl = g;
27
27
  readyLoop.quit();
@@ -821,8 +821,18 @@ class WebGL2RenderingContext extends WebGLContextBase {
821
821
  this._native2.vertexAttribIPointer(index, size, type, stride, offset);
822
822
  }
823
823
  drawBuffers(buffers) {
824
- const mapped = buffers.map((b) => b === 1029 ? this.COLOR_ATTACHMENT0 : b);
825
- this._native2.drawBuffers(Array.from(mapped));
824
+ let hasBack = false;
825
+ for (let i = 0; i < buffers.length; i++) {
826
+ if (buffers[i] === 1029) {
827
+ hasBack = true;
828
+ break;
829
+ }
830
+ }
831
+ if (!hasBack) {
832
+ this._native2.drawBuffers(buffers);
833
+ return;
834
+ }
835
+ this._native2.drawBuffers(buffers.map((b) => b === 1029 ? this.COLOR_ATTACHMENT0 : b));
826
836
  }
827
837
  drawRangeElements(mode, start, end, count, type, offset) {
828
838
  if (count < 0 || offset < 0) {
@@ -919,10 +929,10 @@ class WebGL2RenderingContext extends WebGLContextBase {
919
929
  void drawbuffer;
920
930
  }
921
931
  invalidateFramebuffer(target, attachments) {
922
- this._native2.invalidateFramebuffer(target, Array.from(attachments));
932
+ this._native2.invalidateFramebuffer(target, attachments);
923
933
  }
924
934
  invalidateSubFramebuffer(target, attachments, x, y, width, height) {
925
- this._native2.invalidateSubFramebuffer(target, Array.from(attachments), x, y, width, height);
935
+ this._native2.invalidateSubFramebuffer(target, attachments, x, y, width, height);
926
936
  }
927
937
  readBuffer(src) {
928
938
  this._native2.readBuffer(src);
@@ -966,53 +976,53 @@ class WebGL2RenderingContext extends WebGLContextBase {
966
976
  uniform1uiv(location, data, _srcOffset, _srcLength) {
967
977
  if (!location) return;
968
978
  const arr = data instanceof Uint32Array ? data : new Uint32Array(data);
969
- this._native2.uniform1uiv(location._, arr.length, Array.from(arr));
979
+ this._native2.uniform1uiv(location._, arr.length, arr);
970
980
  }
971
981
  uniform2uiv(location, data, _srcOffset, _srcLength) {
972
982
  if (!location) return;
973
983
  const arr = data instanceof Uint32Array ? data : new Uint32Array(data);
974
- this._native2.uniform2uiv(location._, arr.length / 2, Array.from(arr));
984
+ this._native2.uniform2uiv(location._, arr.length / 2, arr);
975
985
  }
976
986
  uniform3uiv(location, data, _srcOffset, _srcLength) {
977
987
  if (!location) return;
978
988
  const arr = data instanceof Uint32Array ? data : new Uint32Array(data);
979
- this._native2.uniform3uiv(location._, arr.length / 3, Array.from(arr));
989
+ this._native2.uniform3uiv(location._, arr.length / 3, arr);
980
990
  }
981
991
  uniform4uiv(location, data, _srcOffset, _srcLength) {
982
992
  if (!location) return;
983
993
  const arr = data instanceof Uint32Array ? data : new Uint32Array(data);
984
- this._native2.uniform4uiv(location._, arr.length / 4, Array.from(arr));
994
+ this._native2.uniform4uiv(location._, arr.length / 4, arr);
985
995
  }
986
996
  // ─── Non-square Matrix Uniforms ───────────────────────────────────────
987
997
  uniformMatrix2x3fv(location, transpose, data, _srcOffset, _srcLength) {
988
998
  if (!location) return;
989
999
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
990
- this._native2.uniformMatrix2x3fv(location._, transpose, Array.from(arr));
1000
+ this._native2.uniformMatrix2x3fv(location._, transpose, arr);
991
1001
  }
992
1002
  uniformMatrix3x2fv(location, transpose, data, _srcOffset, _srcLength) {
993
1003
  if (!location) return;
994
1004
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
995
- this._native2.uniformMatrix3x2fv(location._, transpose, Array.from(arr));
1005
+ this._native2.uniformMatrix3x2fv(location._, transpose, arr);
996
1006
  }
997
1007
  uniformMatrix2x4fv(location, transpose, data, _srcOffset, _srcLength) {
998
1008
  if (!location) return;
999
1009
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
1000
- this._native2.uniformMatrix2x4fv(location._, transpose, Array.from(arr));
1010
+ this._native2.uniformMatrix2x4fv(location._, transpose, arr);
1001
1011
  }
1002
1012
  uniformMatrix4x2fv(location, transpose, data, _srcOffset, _srcLength) {
1003
1013
  if (!location) return;
1004
1014
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
1005
- this._native2.uniformMatrix4x2fv(location._, transpose, Array.from(arr));
1015
+ this._native2.uniformMatrix4x2fv(location._, transpose, arr);
1006
1016
  }
1007
1017
  uniformMatrix3x4fv(location, transpose, data, _srcOffset, _srcLength) {
1008
1018
  if (!location) return;
1009
1019
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
1010
- this._native2.uniformMatrix3x4fv(location._, transpose, Array.from(arr));
1020
+ this._native2.uniformMatrix3x4fv(location._, transpose, arr);
1011
1021
  }
1012
1022
  uniformMatrix4x3fv(location, transpose, data, _srcOffset, _srcLength) {
1013
1023
  if (!location) return;
1014
1024
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
1015
- this._native2.uniformMatrix4x3fv(location._, transpose, Array.from(arr));
1025
+ this._native2.uniformMatrix4x3fv(location._, transpose, arr);
1016
1026
  }
1017
1027
  // ─── getUniform — WebGL2 uint type support ────────────────────────────
1018
1028
  /** WebGL1 getUniform falls to default:null for UNSIGNED_INT types. Handle them here. */
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, beforeEach, on } from "@gjsify/unit";
2
- import { WebGL2RenderingContext as OurWebGL2RenderingContext, CanvasWebGLWidget } from "@gjsify/webgl";
2
+ import { WebGL2RenderingContext as OurWebGL2RenderingContext, WebGLBridge } from "@gjsify/webgl";
3
3
  import {
4
4
  makeProgram,
5
5
  drawTriangle,
@@ -21,7 +21,7 @@ var webgl2_spec_default = async () => {
21
21
  const readyLoop = new GLib.MainLoop(null, false);
22
22
  const win = new Gtk.Window({});
23
23
  win.set_default_size(200, 200);
24
- glArea = new CanvasWebGLWidget();
24
+ glArea = new WebGLBridge();
25
25
  glArea.onReady((c, _g) => {
26
26
  gl2 = c.getContext("webgl2");
27
27
  readyLoop.quit();
@@ -1,13 +1,13 @@
1
- import { CanvasWebGLWidget } from '@gjsify/webgl';
1
+ import { WebGLBridge } from '@gjsify/webgl';
2
2
  import Gtk from '@girs/gtk-4.0';
3
3
  export interface GLSetup {
4
4
  gl: WebGLRenderingContext;
5
5
  gl2: WebGL2RenderingContext | null;
6
- glArea: CanvasWebGLWidget;
6
+ glArea: WebGLBridge;
7
7
  win: Gtk.Window;
8
8
  }
9
9
  /**
10
- * Synchronously initialises a GTK window + CanvasWebGLWidget and blocks until
10
+ * Synchronously initialises a GTK window + WebGLBridge and blocks until
11
11
  * the GL context is ready (or 10 s timeout).
12
12
  * Returns null when no display is available.
13
13
  */
@@ -2,7 +2,7 @@ import '@girs/gjs';
2
2
  import '@girs/gio-2.0';
3
3
  import '@girs/gtk-4.0';
4
4
  export * from './html-canvas-element.js';
5
- export * from './canvas-webgl-widget.js';
5
+ export * from './webgl-bridge.js';
6
6
  export * from './webgl-active-info.js';
7
7
  export * from './webgl-buffer.js';
8
8
  export * from './webgl-context-attributes.js';
@@ -14,7 +14,7 @@ type WebGLReadyCallback = (canvas: globalThis.HTMLCanvasElement, gl: globalThis.
14
14
  *
15
15
  * Usage:
16
16
  * ```ts
17
- * const widget = new CanvasWebGLWidget();
17
+ * const widget = new WebGLBridge();
18
18
  * widget.installGlobals(); // sets globalThis.requestAnimationFrame
19
19
  * widget.onReady((canvas, gl) => {
20
20
  * gl.clearColor(0, 0, 0, 1);
@@ -23,7 +23,7 @@ type WebGLReadyCallback = (canvas: globalThis.HTMLCanvasElement, gl: globalThis.
23
23
  * window.set_child(widget);
24
24
  * ```
25
25
  */
26
- export declare const CanvasWebGLWidget: {
26
+ export declare const WebGLBridge: {
27
27
  new (params?: Partial<Gtk.GLArea.ConstructorProps>): {
28
28
  _canvas: OurHTMLCanvasElement | null;
29
29
  _readyCallbacks: WebGLReadyCallback[];
@@ -53,8 +53,10 @@ export declare const CanvasWebGLWidget: {
53
53
  onResize(cb: (width: number, height: number) => void): void;
54
54
  /**
55
55
  * Schedules a single animation frame callback, matching the browser `requestAnimationFrame` API.
56
- * Backed by GTK frame clock (vsync-synced) + the GLArea render signal.
57
- * Returns 0 (handle cancel not yet implemented).
56
+ * Backed by a persistent GTK frame clock tick callback (vsync-synced) + a persistent GLArea
57
+ * render signal handler. Both are installed once at construction / first render respectively,
58
+ * eliminating per-frame GLib.Source allocation and GObject signal connect/disconnect overhead.
59
+ * Returns 0 (handle — cancel via cancelAnimationFrame clears the pending callback).
58
60
  */
59
61
  requestAnimationFrame(cb: FrameRequestCallback): number;
60
62
  /**
@@ -71,7 +73,7 @@ export declare const CanvasWebGLWidget: {
71
73
  set auto_render(val: boolean);
72
74
  get autoRender(): boolean;
73
75
  set autoRender(val: boolean);
74
- get context(): Gdk.GLContext;
76
+ get context(): (Gdk.GLContext | null);
75
77
  get has_depth_buffer(): boolean;
76
78
  set has_depth_buffer(val: boolean);
77
79
  get hasDepthBuffer(): boolean;
@@ -98,8 +100,8 @@ export declare const CanvasWebGLWidget: {
98
100
  get_allowed_apis(): Gdk.GLAPI;
99
101
  get_api(): Gdk.GLAPI;
100
102
  get_auto_render(): boolean;
101
- get_context(): Gdk.GLContext | null;
102
- get_error(): GLib.Error | null;
103
+ get_context(): (Gdk.GLContext | null);
104
+ get_error(): (GLib.Error | null);
103
105
  get_has_depth_buffer(): boolean;
104
106
  get_has_stencil_buffer(): boolean;
105
107
  get_required_version(): [number, number];
@@ -108,7 +110,7 @@ export declare const CanvasWebGLWidget: {
108
110
  queue_render(): void;
109
111
  set_allowed_apis(apis: Gdk.GLAPI): void;
110
112
  set_auto_render(auto_render: boolean): void;
111
- set_error(error?: GLib.Error | null): void;
113
+ set_error(error: (GLib.Error | null)): void;
112
114
  set_has_depth_buffer(has_depth_buffer: boolean): void;
113
115
  set_has_stencil_buffer(has_stencil_buffer: boolean): void;
114
116
  set_required_version(major: number, minor: number): void;
@@ -118,76 +120,40 @@ export declare const CanvasWebGLWidget: {
118
120
  get accessibleRole(): Gtk.AccessibleRole;
119
121
  set accessibleRole(val: Gtk.AccessibleRole);
120
122
  announce(message: string, priority: Gtk.AccessibleAnnouncementPriority): void;
121
- get_accessible_id(): string | null;
122
- get_accessible_parent(): Gtk.Accessible | null;
123
+ get_accessible_id(): (string | null);
124
+ get_accessible_parent(): (Gtk.Accessible | null);
123
125
  get_accessible_role(): Gtk.AccessibleRole;
124
126
  get_at_context(): Gtk.ATContext;
125
127
  get_bounds(): [boolean, number, number, number, number];
126
- get_first_accessible_child(): Gtk.Accessible | null;
127
- get_next_accessible_sibling(): Gtk.Accessible | null;
128
+ get_first_accessible_child(): (Gtk.Accessible | null);
129
+ get_next_accessible_sibling(): (Gtk.Accessible | null);
128
130
  get_platform_state(state: Gtk.AccessiblePlatformState): boolean;
129
131
  reset_property(property: Gtk.AccessibleProperty): void;
130
132
  reset_relation(relation: Gtk.AccessibleRelation): void;
131
133
  reset_state(state: Gtk.AccessibleState): void;
132
- set_accessible_parent(parent?: Gtk.Accessible | null, next_sibling?: Gtk.Accessible | null): void;
133
- update_next_accessible_sibling(new_sibling?: Gtk.Accessible | null): void;
134
+ set_accessible_parent(parent: (Gtk.Accessible | null), next_sibling: (Gtk.Accessible | null)): void;
135
+ update_next_accessible_sibling(new_sibling: (Gtk.Accessible | null)): void;
134
136
  update_platform_state(state: Gtk.AccessiblePlatformState): void;
135
137
  update_property(properties: Gtk.AccessibleProperty[], values: (GObject.Value | any)[]): void;
136
138
  update_relation(relations: Gtk.AccessibleRelation[], values: (GObject.Value | any)[]): void;
137
139
  update_state(states: Gtk.AccessibleState[], values: (GObject.Value | any)[]): void;
138
- vfunc_get_accessible_id(): string | null;
139
- vfunc_get_accessible_parent(): Gtk.Accessible | null;
140
- vfunc_get_at_context(): Gtk.ATContext | null;
140
+ vfunc_get_accessible_id(): (string | null);
141
+ vfunc_get_accessible_parent(): (Gtk.Accessible | null);
142
+ vfunc_get_at_context(): (Gtk.ATContext | null);
141
143
  vfunc_get_bounds(): [boolean, number, number, number, number];
142
- vfunc_get_first_accessible_child(): Gtk.Accessible | null;
143
- vfunc_get_next_accessible_sibling(): Gtk.Accessible | null;
144
+ vfunc_get_first_accessible_child(): (Gtk.Accessible | null);
145
+ vfunc_get_next_accessible_sibling(): (Gtk.Accessible | null);
144
146
  vfunc_get_platform_state(state: Gtk.AccessiblePlatformState): boolean;
145
- get_buildable_id(): string | null;
146
- vfunc_add_child(builder: Gtk.Builder, child: GObject.Object, type?: string | null): void;
147
- vfunc_custom_finished(builder: Gtk.Builder, child: GObject.Object | null, tagname: string, data?: any | null): void;
148
- vfunc_custom_tag_end(builder: Gtk.Builder, child: GObject.Object | null, tagname: string, data?: any | null): void;
149
- vfunc_custom_tag_start(builder: Gtk.Builder, child: GObject.Object | null, tagname: string): [boolean, Gtk.BuildableParser, any];
147
+ get_buildable_id(): (string | null);
148
+ vfunc_add_child(builder: Gtk.Builder, child: GObject.Object, type: (string | null)): void;
149
+ vfunc_custom_finished(builder: Gtk.Builder, child: (GObject.Object | null), tagname: string, data: (any | null)): void;
150
+ vfunc_custom_tag_end(builder: Gtk.Builder, child: (GObject.Object | null), tagname: string, data: (any | null)): void;
151
+ vfunc_custom_tag_start(builder: Gtk.Builder, child: (GObject.Object | null), tagname: string): [boolean, Gtk.BuildableParser, any];
150
152
  vfunc_get_id(): string;
151
153
  vfunc_get_internal_child<T = GObject.Object>(builder: Gtk.Builder, childname: string): T;
152
154
  vfunc_parser_finished(builder: Gtk.Builder): void;
153
155
  vfunc_set_buildable_property(builder: Gtk.Builder, name: string, value: unknown): void;
154
156
  vfunc_set_id(id: string): void;
155
- bind_property(source_property: string, target: GObject.Object, target_property: string, flags: GObject.BindingFlags): GObject.Binding;
156
- bind_property_full(source_property: string, target: GObject.Object, target_property: string, flags: GObject.BindingFlags, transform_to?: GObject.BindingTransformFunc | null, transform_from?: GObject.BindingTransformFunc | null, notify?: GLib.DestroyNotify | null): GObject.Binding;
157
- bind_property_full(...args: never[]): any;
158
- force_floating(): void;
159
- freeze_notify(): void;
160
- get_data(key: string): any | null;
161
- get_property(property_name: string, value: GObject.Value | any): any;
162
- get_qdata(quark: GLib.Quark): any | null;
163
- getv(names: string[], values: (GObject.Value | any)[]): void;
164
- is_floating(): boolean;
165
- notify(property_name: string): void;
166
- notify_by_pspec(pspec: GObject.ParamSpec): void;
167
- ref(): GObject.Object;
168
- ref_sink(): GObject.Object;
169
- run_dispose(): void;
170
- set_data(key: string, data?: any | null): void;
171
- set_property(property_name: string, value: GObject.Value | any): void;
172
- steal_data(key: string): any | null;
173
- steal_qdata(quark: GLib.Quark): any | null;
174
- thaw_notify(): void;
175
- unref(): void;
176
- watch_closure(closure: GObject.Closure): void;
177
- vfunc_constructed(): void;
178
- vfunc_dispatch_properties_changed(n_pspecs: number, pspecs: GObject.ParamSpec): void;
179
- vfunc_dispose(): void;
180
- vfunc_finalize(): void;
181
- vfunc_get_property(property_id: number, value: unknown, pspec: GObject.ParamSpec): void;
182
- vfunc_notify(pspec: GObject.ParamSpec): void;
183
- vfunc_set_property(property_id: number, value: unknown, pspec: GObject.ParamSpec): void;
184
- disconnect(id: number): void;
185
- set(properties: {
186
- [key: string]: any;
187
- }): void;
188
- block_signal_handler(id: number): void;
189
- unblock_signal_handler(id: number): void;
190
- stop_emission_by_name(detailedName: string): void;
191
157
  get can_focus(): boolean;
192
158
  set can_focus(val: boolean);
193
159
  get canFocus(): boolean;
@@ -202,8 +168,8 @@ export declare const CanvasWebGLWidget: {
202
168
  set cssClasses(val: string[]);
203
169
  get css_name(): string;
204
170
  get cssName(): string;
205
- get cursor(): Gdk.Cursor;
206
- set cursor(val: Gdk.Cursor);
171
+ get cursor(): (Gdk.Cursor | null);
172
+ set cursor(val: (Gdk.Cursor | null));
207
173
  get focus_on_click(): boolean;
208
174
  set focus_on_click(val: boolean);
209
175
  get focusOnClick(): boolean;
@@ -230,10 +196,10 @@ export declare const CanvasWebGLWidget: {
230
196
  set hexpand_set(val: boolean);
231
197
  get hexpandSet(): boolean;
232
198
  set hexpandSet(val: boolean);
233
- get layout_manager(): Gtk.LayoutManager;
234
- set layout_manager(val: Gtk.LayoutManager);
235
- get layoutManager(): Gtk.LayoutManager;
236
- set layoutManager(val: Gtk.LayoutManager);
199
+ get layout_manager(): (Gtk.LayoutManager | null);
200
+ set layout_manager(val: (Gtk.LayoutManager | null));
201
+ get layoutManager(): (Gtk.LayoutManager | null);
202
+ set layoutManager(val: (Gtk.LayoutManager | null));
237
203
  get limit_events(): boolean;
238
204
  set limit_events(val: boolean);
239
205
  get limitEvents(): boolean;
@@ -260,24 +226,24 @@ export declare const CanvasWebGLWidget: {
260
226
  set opacity(val: number);
261
227
  get overflow(): Gtk.Overflow;
262
228
  set overflow(val: Gtk.Overflow);
263
- get parent(): Gtk.Widget;
229
+ get parent(): (Gtk.Widget | null);
264
230
  get receives_default(): boolean;
265
231
  set receives_default(val: boolean);
266
232
  get receivesDefault(): boolean;
267
233
  set receivesDefault(val: boolean);
268
- get root(): Gtk.Root;
234
+ get root(): (Gtk.Root | null);
269
235
  get scale_factor(): number;
270
236
  get scaleFactor(): number;
271
237
  get sensitive(): boolean;
272
238
  set sensitive(val: boolean);
273
- get tooltip_markup(): string;
274
- set tooltip_markup(val: string);
275
- get tooltipMarkup(): string;
276
- set tooltipMarkup(val: string);
277
- get tooltip_text(): string;
278
- set tooltip_text(val: string);
279
- get tooltipText(): string;
280
- set tooltipText(val: string);
239
+ get tooltip_markup(): (string | null);
240
+ set tooltip_markup(val: (string | null));
241
+ get tooltipMarkup(): (string | null);
242
+ set tooltipMarkup(val: (string | null));
243
+ get tooltip_text(): (string | null);
244
+ set tooltip_text(val: (string | null));
245
+ get tooltipText(): (string | null);
246
+ set tooltipText(val: (string | null));
281
247
  get valign(): Gtk.Align;
282
248
  set valign(val: Gtk.Align);
283
249
  get vexpand(): boolean;
@@ -308,7 +274,7 @@ export declare const CanvasWebGLWidget: {
308
274
  vfunc_query_tooltip(x: number, y: number, keyboard_tooltip: boolean, tooltip: Gtk.Tooltip): boolean;
309
275
  vfunc_realize(): void;
310
276
  vfunc_root(): void;
311
- vfunc_set_focus_child(child?: Gtk.Widget | null): void;
277
+ vfunc_set_focus_child(child: (Gtk.Widget | null)): void;
312
278
  vfunc_show(): void;
313
279
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
314
280
  vfunc_snapshot(snapshot: Gtk.Snapshot): void;
@@ -319,13 +285,13 @@ export declare const CanvasWebGLWidget: {
319
285
  vfunc_unroot(): void;
320
286
  action_set_enabled(action_name: string, enabled: boolean): void;
321
287
  activate(): boolean;
322
- activate_action(name: string, args?: GLib.Variant | null): boolean;
288
+ activate_action(name: string, args: (GLib.Variant | null)): boolean;
323
289
  activate_default(): void;
324
290
  add_controller(controller: Gtk.EventController): void;
325
291
  add_css_class(css_class: string): void;
326
292
  add_mnemonic_label(label: Gtk.Widget): void;
327
293
  add_tick_callback(callback: Gtk.TickCallback): number;
328
- allocate(width: number, height: number, baseline: number, transform?: import("@girs/gsk-4.0").default.Transform | null): void;
294
+ allocate(width: number, height: number, baseline: number, transform: (import("@girs/gsk-4.0").default.Transform | null)): void;
329
295
  child_focus(direction: Gtk.DirectionType): boolean;
330
296
  compute_bounds(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Rect];
331
297
  compute_expand(orientation: Gtk.Orientation): boolean;
@@ -333,7 +299,7 @@ export declare const CanvasWebGLWidget: {
333
299
  compute_transform(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Matrix];
334
300
  contains(x: number, y: number): boolean;
335
301
  create_pango_context(): import("@girs/pango-1.0").default.Context;
336
- create_pango_layout(text?: string | null): import("@girs/pango-1.0").default.Layout;
302
+ create_pango_layout(text: (string | null)): import("@girs/pango-1.0").default.Layout;
337
303
  dispose_template(widget_type: GObject.GType): void;
338
304
  drag_check_threshold(start_x: number, start_y: number, current_x: number, current_y: number): boolean;
339
305
  error_bell(): void;
@@ -341,7 +307,7 @@ export declare const CanvasWebGLWidget: {
341
307
  get_allocated_height(): number;
342
308
  get_allocated_width(): number;
343
309
  get_allocation(): Gtk.Allocation;
344
- get_ancestor(widget_type: GObject.GType): Gtk.Widget | null;
310
+ get_ancestor(widget_type: GObject.GType): (Gtk.Widget | null);
345
311
  get_baseline(): number;
346
312
  get_can_focus(): boolean;
347
313
  get_can_target(): boolean;
@@ -350,23 +316,23 @@ export declare const CanvasWebGLWidget: {
350
316
  get_color(): Gdk.RGBA;
351
317
  get_css_classes(): string[];
352
318
  get_css_name(): string;
353
- get_cursor(): Gdk.Cursor | null;
319
+ get_cursor(): (Gdk.Cursor | null);
354
320
  get_direction(): Gtk.TextDirection;
355
321
  get_display(): Gdk.Display;
356
- get_first_child(): Gtk.Widget | null;
357
- get_focus_child(): Gtk.Widget | null;
322
+ get_first_child(): (Gtk.Widget | null);
323
+ get_focus_child(): (Gtk.Widget | null);
358
324
  get_focus_on_click(): boolean;
359
325
  get_focusable(): boolean;
360
- get_font_map(): import("@girs/pango-1.0").default.FontMap | null;
361
- get_font_options(): import("@girs/gjs/cairo").default.FontOptions | null;
362
- get_frame_clock(): Gdk.FrameClock | null;
326
+ get_font_map(): (import("@girs/pango-1.0").default.FontMap | null);
327
+ get_font_options(): (import("@girs/gjs/cairo").default.FontOptions | null);
328
+ get_frame_clock(): (Gdk.FrameClock | null);
363
329
  get_halign(): Gtk.Align;
364
330
  get_has_tooltip(): boolean;
365
331
  get_height(): number;
366
332
  get_hexpand(): boolean;
367
333
  get_hexpand_set(): boolean;
368
- get_last_child(): Gtk.Widget | null;
369
- get_layout_manager(): Gtk.LayoutManager | null;
334
+ get_last_child(): (Gtk.Widget | null);
335
+ get_layout_manager(): (Gtk.LayoutManager | null);
370
336
  get_limit_events(): boolean;
371
337
  get_mapped(): boolean;
372
338
  get_margin_bottom(): number;
@@ -374,19 +340,19 @@ export declare const CanvasWebGLWidget: {
374
340
  get_margin_start(): number;
375
341
  get_margin_top(): number;
376
342
  get_name(): string;
377
- get_native(): Gtk.Native | null;
378
- get_next_sibling(): Gtk.Widget | null;
343
+ get_native(): (Gtk.Native | null);
344
+ get_next_sibling(): (Gtk.Widget | null);
379
345
  get_opacity(): number;
380
346
  get_overflow(): Gtk.Overflow;
381
347
  get_pango_context(): import("@girs/pango-1.0").default.Context;
382
- get_parent(): Gtk.Widget | null;
348
+ get_parent(): (Gtk.Widget | null);
383
349
  get_preferred_size(): [Gtk.Requisition | null, Gtk.Requisition | null];
384
- get_prev_sibling(): Gtk.Widget | null;
350
+ get_prev_sibling(): (Gtk.Widget | null);
385
351
  get_primary_clipboard(): Gdk.Clipboard;
386
352
  get_realized(): boolean;
387
353
  get_receives_default(): boolean;
388
354
  get_request_mode(): Gtk.SizeRequestMode;
389
- get_root(): Gtk.Root | null;
355
+ get_root(): (Gtk.Root | null);
390
356
  get_scale_factor(): number;
391
357
  get_sensitive(): boolean;
392
358
  get_settings(): Gtk.Settings;
@@ -395,8 +361,8 @@ export declare const CanvasWebGLWidget: {
395
361
  get_state_flags(): Gtk.StateFlags;
396
362
  get_style_context(): Gtk.StyleContext;
397
363
  get_template_child<T = GObject.Object>(widget_type: GObject.GType, name: string): T;
398
- get_tooltip_markup(): string | null;
399
- get_tooltip_text(): string | null;
364
+ get_tooltip_markup(): (string | null);
365
+ get_tooltip_text(): (string | null);
400
366
  get_valign(): Gtk.Align;
401
367
  get_vexpand(): boolean;
402
368
  get_vexpand_set(): boolean;
@@ -408,9 +374,9 @@ export declare const CanvasWebGLWidget: {
408
374
  hide(): void;
409
375
  in_destruction(): boolean;
410
376
  init_template(): void;
411
- insert_action_group(name: string, group?: import("@girs/gio-2.0").default.ActionGroup | null): void;
412
- insert_after(parent: Gtk.Widget, previous_sibling?: Gtk.Widget | null): void;
413
- insert_before(parent: Gtk.Widget, next_sibling?: Gtk.Widget | null): void;
377
+ insert_action_group(name: string, group: (import("@girs/gio-2.0").default.ActionGroup | null)): void;
378
+ insert_after(parent: Gtk.Widget, previous_sibling: (Gtk.Widget | null)): void;
379
+ insert_before(parent: Gtk.Widget, next_sibling: (Gtk.Widget | null)): void;
414
380
  is_ancestor(ancestor: Gtk.Widget): boolean;
415
381
  is_drawable(): boolean;
416
382
  is_focus(): boolean;
@@ -423,7 +389,7 @@ export declare const CanvasWebGLWidget: {
423
389
  mnemonic_activate(group_cycling: boolean): boolean;
424
390
  observe_children(): import("@girs/gio-2.0").default.ListModel;
425
391
  observe_controllers(): import("@girs/gio-2.0").default.ListModel;
426
- pick(x: number, y: number, flags: Gtk.PickFlags): Gtk.Widget | null;
392
+ pick(x: number, y: number, flags: Gtk.PickFlags): (Gtk.Widget | null);
427
393
  queue_allocate(): void;
428
394
  queue_draw(): void;
429
395
  queue_resize(): void;
@@ -436,19 +402,19 @@ export declare const CanvasWebGLWidget: {
436
402
  set_can_target(can_target: boolean): void;
437
403
  set_child_visible(child_visible: boolean): void;
438
404
  set_css_classes(classes: string[]): void;
439
- set_cursor(cursor?: Gdk.Cursor | null): void;
440
- set_cursor_from_name(name?: string | null): void;
405
+ set_cursor(cursor: (Gdk.Cursor | null)): void;
406
+ set_cursor_from_name(name: (string | null)): void;
441
407
  set_direction(dir: Gtk.TextDirection): void;
442
- set_focus_child(child?: Gtk.Widget | null): void;
408
+ set_focus_child(child: (Gtk.Widget | null)): void;
443
409
  set_focus_on_click(focus_on_click: boolean): void;
444
410
  set_focusable(focusable: boolean): void;
445
- set_font_map(font_map?: import("@girs/pango-1.0").default.FontMap | null): void;
446
- set_font_options(options?: import("@girs/gjs/cairo").default.FontOptions | null): void;
411
+ set_font_map(font_map: (import("@girs/pango-1.0").default.FontMap | null)): void;
412
+ set_font_options(options: (import("@girs/gjs/cairo").default.FontOptions | null)): void;
447
413
  set_halign(align: Gtk.Align): void;
448
414
  set_has_tooltip(has_tooltip: boolean): void;
449
415
  set_hexpand(expand: boolean): void;
450
416
  set_hexpand_set(set: boolean): void;
451
- set_layout_manager(layout_manager?: Gtk.LayoutManager | null): void;
417
+ set_layout_manager(layout_manager: (Gtk.LayoutManager | null)): void;
452
418
  set_limit_events(limit_events: boolean): void;
453
419
  set_margin_bottom(margin: number): void;
454
420
  set_margin_end(margin: number): void;
@@ -462,8 +428,8 @@ export declare const CanvasWebGLWidget: {
462
428
  set_sensitive(sensitive: boolean): void;
463
429
  set_size_request(width: number, height: number): void;
464
430
  set_state_flags(flags: Gtk.StateFlags, clear: boolean): void;
465
- set_tooltip_markup(markup?: string | null): void;
466
- set_tooltip_text(text?: string | null): void;
431
+ set_tooltip_markup(markup: (string | null)): void;
432
+ set_tooltip_text(text: (string | null)): void;
467
433
  set_valign(align: Gtk.Align): void;
468
434
  set_vexpand(expand: boolean): void;
469
435
  set_vexpand_set(set: boolean): void;
@@ -479,6 +445,41 @@ export declare const CanvasWebGLWidget: {
479
445
  unrealize(): void;
480
446
  unset_state_flags(flags: Gtk.StateFlags): void;
481
447
  [Symbol.iterator]: () => IterableIterator<Gtk.Widget>;
448
+ vfunc_constructed(): void;
449
+ vfunc_dispatch_properties_changed(n_pspecs: number, pspecs: GObject.ParamSpec): void;
450
+ vfunc_dispose(): void;
451
+ vfunc_finalize(): void;
452
+ vfunc_get_property(property_id: number, value: unknown, pspec: GObject.ParamSpec): void;
453
+ vfunc_notify(pspec: GObject.ParamSpec): void;
454
+ vfunc_set_property(property_id: number, value: unknown, pspec: GObject.ParamSpec): void;
455
+ bind_property(source_property: string, target: GObject.Object, target_property: string, flags: GObject.BindingFlags): GObject.Binding;
456
+ bind_property_full(source_property: string, target: GObject.Object, target_property: string, flags: GObject.BindingFlags, transform_to: (GObject.Closure | null), transform_from: (GObject.Closure | null)): GObject.Binding;
457
+ force_floating(): void;
458
+ freeze_notify(): void;
459
+ get_data(key: string): (any | null);
460
+ get_property(property_name: string, value: (GObject.Value | any)): any;
461
+ get_qdata(quark: GLib.Quark): (any | null);
462
+ getv(names: string[], values: (GObject.Value | any)[]): void;
463
+ is_floating(): boolean;
464
+ notify(property_name: string): void;
465
+ notify_by_pspec(pspec: GObject.ParamSpec): void;
466
+ ref(): GObject.Object;
467
+ ref_sink(): GObject.Object;
468
+ run_dispose(): void;
469
+ set_data(key: string, data: (any | null)): void;
470
+ set_property(property_name: string, value: (GObject.Value | any)): void;
471
+ steal_data(key: string): (any | null);
472
+ steal_qdata(quark: GLib.Quark): (any | null);
473
+ thaw_notify(): void;
474
+ unref(): void;
475
+ watch_closure(closure: GObject.Closure): void;
476
+ disconnect(id: number): void;
477
+ set(properties: {
478
+ [key: string]: any;
479
+ }): void;
480
+ block_signal_handler(id: number): void;
481
+ unblock_signal_handler(id: number): void;
482
+ stop_emission_by_name(detailedName: string): void;
482
483
  };
483
484
  $gtype: GObject.GType<Gtk.GLArea>;
484
485
  "new"(): Gtk.GLArea;
@@ -486,12 +487,12 @@ export declare const CanvasWebGLWidget: {
486
487
  set_default_direction(dir: Gtk.TextDirection): void;
487
488
  add_shortcut(shortcut: Gtk.Shortcut): void;
488
489
  bind_template_callback_full(callback_name: string, callback_symbol: GObject.Callback): void;
489
- bind_template_child_full(name: string, internal_child: boolean, struct_offset: bigint | number): void;
490
+ bind_template_child_full(name: string, internal_child: boolean, struct_offset: (bigint | number)): void;
490
491
  get_accessible_role(): Gtk.AccessibleRole;
491
492
  get_activate_signal(): number;
492
493
  get_css_name(): string;
493
494
  get_layout_manager_type(): GObject.GType;
494
- install_action(action_name: string, parameter_type: string | null, activate: Gtk.WidgetActionActivateFunc): void;
495
+ install_action(action_name: string, parameter_type: (string | null), activate: Gtk.WidgetActionActivateFunc): void;
495
496
  install_property_action(action_name: string, property_name: string): void;
496
497
  query_action(index_: number): [boolean, GObject.GType, string, GLib.VariantType | null, string];
497
498
  set_accessible_role(accessible_role: Gtk.AccessibleRole): void;
@@ -499,11 +500,11 @@ export declare const CanvasWebGLWidget: {
499
500
  set_activate_signal_from_name(signal_name: string): void;
500
501
  set_css_name(name: string): void;
501
502
  set_layout_manager_type(type: GObject.GType): void;
502
- set_template(template_bytes: GLib.Bytes | Uint8Array): void;
503
+ set_template(template_bytes: (GLib.Bytes | Uint8Array)): void;
503
504
  set_template_from_resource(resource_name: string): void;
504
505
  set_template_scope(scope: Gtk.BuilderScope): void;
505
506
  newv(object_type: GObject.GType, parameters: GObject.Parameter[]): GObject.Object;
506
- compat_control(what: bigint | number, data?: any | null): number;
507
+ compat_control(what: (bigint | number), data: (any | null)): number;
507
508
  interface_find_property(g_iface: GObject.TypeInterface, property_name: string): GObject.ParamSpec;
508
509
  interface_install_property(g_iface: GObject.TypeInterface, pspec: GObject.ParamSpec): void;
509
510
  interface_list_properties(g_iface: GObject.TypeInterface): GObject.ParamSpec[];
@@ -514,5 +515,5 @@ export declare const CanvasWebGLWidget: {
514
515
  override_property(property_id: number, name: string): void;
515
516
  _classInit(klass: any): any;
516
517
  };
517
- export type CanvasWebGLWidget = InstanceType<typeof CanvasWebGLWidget>;
518
+ export type WebGLBridge = InstanceType<typeof WebGLBridge>;
518
519
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/webgl",
3
- "version": "0.1.13",
3
+ "version": "0.2.0",
4
4
  "description": "WebGL module for Gjs",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "check": "tsc --noEmit",
24
24
  "init:meson": "meson setup build .",
25
25
  "init:meson:wipe": "yarn init:meson --wipe",
26
- "build": "yarn build:meson && yarn build:gjsify && yarn build:types",
26
+ "build": "yarn build:gjsify && yarn build:types",
27
27
  "build:gjsify": "gjsify build --library 'src/ts/**/*.{ts,js}'",
28
28
  "build:meson": "yarn init:meson && meson compile -C build",
29
29
  "build:types": "tsc",
@@ -39,19 +39,19 @@
39
39
  "WebGL"
40
40
  ],
41
41
  "devDependencies": {
42
- "@gjsify/cli": "^0.1.13",
43
- "@gjsify/unit": "^0.1.13",
42
+ "@gjsify/cli": "^0.2.0",
43
+ "@gjsify/unit": "^0.2.0",
44
44
  "@types/bit-twiddle": "^1.0.3",
45
45
  "@types/node": "^25.6.0",
46
- "typescript": "^6.0.2"
46
+ "typescript": "^6.0.3"
47
47
  },
48
48
  "dependencies": {
49
- "@girs/gjs": "^4.0.0-rc.3",
50
- "@girs/gtk-4.0": "^4.23.0-4.0.0-rc.3",
51
- "@girs/gwebgl-0.1": "^0.1.0-4.0.0-rc.3",
52
- "@gjsify/dom-elements": "^0.1.13",
53
- "@gjsify/event-bridge": "^0.1.13",
54
- "@gjsify/utils": "^0.1.13",
49
+ "@girs/gjs": "^4.0.0-rc.9",
50
+ "@girs/gtk-4.0": "^4.23.0-4.0.0-rc.9",
51
+ "@girs/gwebgl-0.1": "^0.1.0-4.0.0-rc.5",
52
+ "@gjsify/dom-elements": "^0.2.0",
53
+ "@gjsify/event-bridge": "^0.2.0",
54
+ "@gjsify/utils": "^0.2.0",
55
55
  "bit-twiddle": "^1.0.2",
56
56
  "glsl-tokenizer": "^2.1.5"
57
57
  }
Binary file