@gjsify/canvas2d 0.62.0 → 0.63.1-next.235
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/lib/types/canvas2d-bridge.d.ts +31 -19
- package/package.json +14 -13
|
@@ -7,7 +7,19 @@ import { HTMLCanvasElement as GjsifyHTMLCanvasElement } from '@gjsify/dom-elemen
|
|
|
7
7
|
import '@gjsify/dom-elements/register/canvas';
|
|
8
8
|
import '@gjsify/canvas2d-core/gdk';
|
|
9
9
|
import type { CanvasRenderingContext2D } from '@gjsify/canvas2d-core';
|
|
10
|
-
|
|
10
|
+
/** `FrameRequestCallback` without `lib.dom`: a GJS program has none. */
|
|
11
|
+
export type FrameCallback = (time: number) => void;
|
|
12
|
+
/**
|
|
13
|
+
* The canvas type handed to consumers: the DOM `HTMLCanvasElement` when the consumer loads
|
|
14
|
+
* `lib.dom`, gjsify's own element otherwise. Resolved through `globalThis` so this file never
|
|
15
|
+
* names a lib.dom type directly.
|
|
16
|
+
*/
|
|
17
|
+
export type BridgeCanvas = typeof globalThis extends {
|
|
18
|
+
HTMLCanvasElement: {
|
|
19
|
+
prototype: infer T;
|
|
20
|
+
};
|
|
21
|
+
} ? T : GjsifyHTMLCanvasElement;
|
|
22
|
+
type Canvas2DReadyCallback = (canvas: BridgeCanvas, ctx: CanvasRenderingContext2D) => void;
|
|
11
23
|
/**
|
|
12
24
|
* A `Gtk.DrawingArea` subclass that creates an `HTMLCanvasElement` +
|
|
13
25
|
* `CanvasRenderingContext2D` on first draw and blits its Cairo surface each frame.
|
|
@@ -30,12 +42,12 @@ export declare const Canvas2DBridge: {
|
|
|
30
42
|
_readyCallbacks: Canvas2DReadyCallback[];
|
|
31
43
|
_resizeCallbacks: ((w: number, h: number) => void)[];
|
|
32
44
|
_tickCallbackId: number | null;
|
|
33
|
-
_frameCallback:
|
|
45
|
+
_frameCallback: FrameCallback | null;
|
|
34
46
|
_timeOrigin: number;
|
|
35
47
|
/** @internal Draw function called by GTK. Blits the Cairo surface to screen. */
|
|
36
48
|
_onDraw(_area: Gtk.DrawingArea, cr: Cairo.Context, width: number, height: number): void;
|
|
37
49
|
/** The HTMLCanvasElement backing this widget. Available after the first draw. */
|
|
38
|
-
get canvas():
|
|
50
|
+
get canvas(): BridgeCanvas | null;
|
|
39
51
|
/** The 2D rendering context; available after the first draw. */
|
|
40
52
|
getContext(_id: "2d"): CanvasRenderingContext2D | null;
|
|
41
53
|
/** Runs `cb` once the 2D context is ready — synchronously if it already is. */
|
|
@@ -49,7 +61,7 @@ export declare const Canvas2DBridge: {
|
|
|
49
61
|
* Browser `requestAnimationFrame`, driven by the vsync-synced GTK frame clock.
|
|
50
62
|
* Always returns 0: there is no `cancelAnimationFrame` here to hand a handle to.
|
|
51
63
|
*/
|
|
52
|
-
requestAnimationFrame(cb:
|
|
64
|
+
requestAnimationFrame(cb: FrameCallback): number;
|
|
53
65
|
/**
|
|
54
66
|
* Sets browser globals (`requestAnimationFrame`, `performance`) so that
|
|
55
67
|
* browser-targeted code works unchanged on GJS.
|
|
@@ -450,12 +462,12 @@ export declare const Canvas2DBridge: {
|
|
|
450
462
|
_readyCallbacks: Canvas2DReadyCallback[];
|
|
451
463
|
_resizeCallbacks: ((w: number, h: number) => void)[];
|
|
452
464
|
_tickCallbackId: number | null;
|
|
453
|
-
_frameCallback:
|
|
465
|
+
_frameCallback: FrameCallback | null;
|
|
454
466
|
_timeOrigin: number;
|
|
455
467
|
/** @internal Draw function called by GTK. Blits the Cairo surface to screen. */
|
|
456
468
|
_onDraw(_area: Gtk.DrawingArea, cr: Cairo.Context, width: number, height: number): void;
|
|
457
469
|
/** The HTMLCanvasElement backing this widget. Available after the first draw. */
|
|
458
|
-
get canvas():
|
|
470
|
+
get canvas(): BridgeCanvas | null;
|
|
459
471
|
/** The 2D rendering context; available after the first draw. */
|
|
460
472
|
getContext(_id: "2d"): CanvasRenderingContext2D | null;
|
|
461
473
|
/** Runs `cb` once the 2D context is ready — synchronously if it already is. */
|
|
@@ -469,7 +481,7 @@ export declare const Canvas2DBridge: {
|
|
|
469
481
|
* Browser `requestAnimationFrame`, driven by the vsync-synced GTK frame clock.
|
|
470
482
|
* Always returns 0: there is no `cancelAnimationFrame` here to hand a handle to.
|
|
471
483
|
*/
|
|
472
|
-
requestAnimationFrame(cb:
|
|
484
|
+
requestAnimationFrame(cb: FrameCallback): number;
|
|
473
485
|
/**
|
|
474
486
|
* Sets browser globals (`requestAnimationFrame`, `performance`) so that
|
|
475
487
|
* browser-targeted code works unchanged on GJS.
|
|
@@ -870,12 +882,12 @@ export declare const Canvas2DBridge: {
|
|
|
870
882
|
_readyCallbacks: Canvas2DReadyCallback[];
|
|
871
883
|
_resizeCallbacks: ((w: number, h: number) => void)[];
|
|
872
884
|
_tickCallbackId: number | null;
|
|
873
|
-
_frameCallback:
|
|
885
|
+
_frameCallback: FrameCallback | null;
|
|
874
886
|
_timeOrigin: number;
|
|
875
887
|
/** @internal Draw function called by GTK. Blits the Cairo surface to screen. */
|
|
876
888
|
_onDraw(_area: Gtk.DrawingArea, cr: Cairo.Context, width: number, height: number): void;
|
|
877
889
|
/** The HTMLCanvasElement backing this widget. Available after the first draw. */
|
|
878
|
-
get canvas():
|
|
890
|
+
get canvas(): BridgeCanvas | null;
|
|
879
891
|
/** The 2D rendering context; available after the first draw. */
|
|
880
892
|
getContext(_id: "2d"): CanvasRenderingContext2D | null;
|
|
881
893
|
/** Runs `cb` once the 2D context is ready — synchronously if it already is. */
|
|
@@ -889,7 +901,7 @@ export declare const Canvas2DBridge: {
|
|
|
889
901
|
* Browser `requestAnimationFrame`, driven by the vsync-synced GTK frame clock.
|
|
890
902
|
* Always returns 0: there is no `cancelAnimationFrame` here to hand a handle to.
|
|
891
903
|
*/
|
|
892
|
-
requestAnimationFrame(cb:
|
|
904
|
+
requestAnimationFrame(cb: FrameCallback): number;
|
|
893
905
|
/**
|
|
894
906
|
* Sets browser globals (`requestAnimationFrame`, `performance`) so that
|
|
895
907
|
* browser-targeted code works unchanged on GJS.
|
|
@@ -1290,12 +1302,12 @@ export declare const Canvas2DBridge: {
|
|
|
1290
1302
|
_readyCallbacks: Canvas2DReadyCallback[];
|
|
1291
1303
|
_resizeCallbacks: ((w: number, h: number) => void)[];
|
|
1292
1304
|
_tickCallbackId: number | null;
|
|
1293
|
-
_frameCallback:
|
|
1305
|
+
_frameCallback: FrameCallback | null;
|
|
1294
1306
|
_timeOrigin: number;
|
|
1295
1307
|
/** @internal Draw function called by GTK. Blits the Cairo surface to screen. */
|
|
1296
1308
|
_onDraw(_area: Gtk.DrawingArea, cr: Cairo.Context, width: number, height: number): void;
|
|
1297
1309
|
/** The HTMLCanvasElement backing this widget. Available after the first draw. */
|
|
1298
|
-
get canvas():
|
|
1310
|
+
get canvas(): BridgeCanvas | null;
|
|
1299
1311
|
/** The 2D rendering context; available after the first draw. */
|
|
1300
1312
|
getContext(_id: "2d"): CanvasRenderingContext2D | null;
|
|
1301
1313
|
/** Runs `cb` once the 2D context is ready — synchronously if it already is. */
|
|
@@ -1309,7 +1321,7 @@ export declare const Canvas2DBridge: {
|
|
|
1309
1321
|
* Browser `requestAnimationFrame`, driven by the vsync-synced GTK frame clock.
|
|
1310
1322
|
* Always returns 0: there is no `cancelAnimationFrame` here to hand a handle to.
|
|
1311
1323
|
*/
|
|
1312
|
-
requestAnimationFrame(cb:
|
|
1324
|
+
requestAnimationFrame(cb: FrameCallback): number;
|
|
1313
1325
|
/**
|
|
1314
1326
|
* Sets browser globals (`requestAnimationFrame`, `performance`) so that
|
|
1315
1327
|
* browser-targeted code works unchanged on GJS.
|
|
@@ -1710,12 +1722,12 @@ export declare const Canvas2DBridge: {
|
|
|
1710
1722
|
_readyCallbacks: Canvas2DReadyCallback[];
|
|
1711
1723
|
_resizeCallbacks: ((w: number, h: number) => void)[];
|
|
1712
1724
|
_tickCallbackId: number | null;
|
|
1713
|
-
_frameCallback:
|
|
1725
|
+
_frameCallback: FrameCallback | null;
|
|
1714
1726
|
_timeOrigin: number;
|
|
1715
1727
|
/** @internal Draw function called by GTK. Blits the Cairo surface to screen. */
|
|
1716
1728
|
_onDraw(_area: Gtk.DrawingArea, cr: Cairo.Context, width: number, height: number): void;
|
|
1717
1729
|
/** The HTMLCanvasElement backing this widget. Available after the first draw. */
|
|
1718
|
-
get canvas():
|
|
1730
|
+
get canvas(): BridgeCanvas | null;
|
|
1719
1731
|
/** The 2D rendering context; available after the first draw. */
|
|
1720
1732
|
getContext(_id: "2d"): CanvasRenderingContext2D | null;
|
|
1721
1733
|
/** Runs `cb` once the 2D context is ready — synchronously if it already is. */
|
|
@@ -1729,7 +1741,7 @@ export declare const Canvas2DBridge: {
|
|
|
1729
1741
|
* Browser `requestAnimationFrame`, driven by the vsync-synced GTK frame clock.
|
|
1730
1742
|
* Always returns 0: there is no `cancelAnimationFrame` here to hand a handle to.
|
|
1731
1743
|
*/
|
|
1732
|
-
requestAnimationFrame(cb:
|
|
1744
|
+
requestAnimationFrame(cb: FrameCallback): number;
|
|
1733
1745
|
/**
|
|
1734
1746
|
* Sets browser globals (`requestAnimationFrame`, `performance`) so that
|
|
1735
1747
|
* browser-targeted code works unchanged on GJS.
|
|
@@ -2130,12 +2142,12 @@ export declare const Canvas2DBridge: {
|
|
|
2130
2142
|
_readyCallbacks: Canvas2DReadyCallback[];
|
|
2131
2143
|
_resizeCallbacks: ((w: number, h: number) => void)[];
|
|
2132
2144
|
_tickCallbackId: number | null;
|
|
2133
|
-
_frameCallback:
|
|
2145
|
+
_frameCallback: FrameCallback | null;
|
|
2134
2146
|
_timeOrigin: number;
|
|
2135
2147
|
/** @internal Draw function called by GTK. Blits the Cairo surface to screen. */
|
|
2136
2148
|
_onDraw(_area: Gtk.DrawingArea, cr: Cairo.Context, width: number, height: number): void;
|
|
2137
2149
|
/** The HTMLCanvasElement backing this widget. Available after the first draw. */
|
|
2138
|
-
get canvas():
|
|
2150
|
+
get canvas(): BridgeCanvas | null;
|
|
2139
2151
|
/** The 2D rendering context; available after the first draw. */
|
|
2140
2152
|
getContext(_id: "2d"): CanvasRenderingContext2D | null;
|
|
2141
2153
|
/** Runs `cb` once the 2D context is ready — synchronously if it already is. */
|
|
@@ -2149,7 +2161,7 @@ export declare const Canvas2DBridge: {
|
|
|
2149
2161
|
* Browser `requestAnimationFrame`, driven by the vsync-synced GTK frame clock.
|
|
2150
2162
|
* Always returns 0: there is no `cancelAnimationFrame` here to hand a handle to.
|
|
2151
2163
|
*/
|
|
2152
|
-
requestAnimationFrame(cb:
|
|
2164
|
+
requestAnimationFrame(cb: FrameCallback): number;
|
|
2153
2165
|
/**
|
|
2154
2166
|
* Sets browser globals (`requestAnimationFrame`, `performance`) so that
|
|
2155
2167
|
* browser-targeted code works unchanged on GJS.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/canvas2d",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.1-next.235",
|
|
4
4
|
"description": "Canvas 2D rendering context for GJS, backed by Cairo; Canvas2DBridge on GJS, the browser and NativeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -62,17 +62,17 @@
|
|
|
62
62
|
"@girs/gtk-4.0": "5.4.0",
|
|
63
63
|
"@girs/pango-1.0": "5.4.0",
|
|
64
64
|
"@girs/pangocairo-1.0": "5.4.0",
|
|
65
|
-
"@gjsify/canvas2d-core": "
|
|
66
|
-
"@gjsify/dom-elements": "
|
|
67
|
-
"@gjsify/dom-events": "
|
|
68
|
-
"@gjsify/event-bridge": "
|
|
69
|
-
"@gjsify/utils": "
|
|
65
|
+
"@gjsify/canvas2d-core": "0.63.1-next.235",
|
|
66
|
+
"@gjsify/dom-elements": "0.63.1-next.235",
|
|
67
|
+
"@gjsify/dom-events": "0.63.1-next.235",
|
|
68
|
+
"@gjsify/event-bridge": "0.63.1-next.235",
|
|
69
|
+
"@gjsify/utils": "0.63.1-next.235"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@gjsify/adwaita-nativescript": "
|
|
73
|
-
"@gjsify/adwaita-web": "
|
|
74
|
-
"@gjsify/cli": "
|
|
75
|
-
"@gjsify/unit": "
|
|
72
|
+
"@gjsify/adwaita-nativescript": "0.63.1-next.235",
|
|
73
|
+
"@gjsify/adwaita-web": "0.63.1-next.235",
|
|
74
|
+
"@gjsify/cli": "0.63.1-next.235",
|
|
75
|
+
"@gjsify/unit": "0.63.1-next.235",
|
|
76
76
|
"@types/node": "^25.9.2",
|
|
77
77
|
"typescript": "^6.0.3"
|
|
78
78
|
},
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
},
|
|
97
97
|
"homepage": "https://github.com/gjsify/gjsify/tree/main/packages/framework/canvas2d#readme",
|
|
98
98
|
"peerDependencies": {
|
|
99
|
-
"@gjsify/adwaita-web": "
|
|
100
|
-
"@gjsify/adwaita-nativescript": "
|
|
99
|
+
"@gjsify/adwaita-web": "0.63.1-next.235",
|
|
100
|
+
"@gjsify/adwaita-nativescript": "0.63.1-next.235"
|
|
101
101
|
},
|
|
102
102
|
"peerDependenciesMeta": {
|
|
103
103
|
"@gjsify/adwaita-web": {
|
|
@@ -106,5 +106,6 @@
|
|
|
106
106
|
"@gjsify/adwaita-nativescript": {
|
|
107
107
|
"optional": true
|
|
108
108
|
}
|
|
109
|
-
}
|
|
109
|
+
},
|
|
110
|
+
"gitHead": "9d2cca56170a0215b3e0792e98421ed1f83e7f72"
|
|
110
111
|
}
|