@buncanvas/core 0.2.0 → 0.3.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/dom/DOMMatrix.d.ts +126 -39
- package/index.d.ts +3 -2
- package/index.js +3798 -2128
- package/internal/Event/CanvasEventTarget.d.ts +0 -0
- package/internal/Event/KeyboardEventTarget.d.ts +14 -0
- package/internal/Event/MouseEventTarget.d.ts +18 -0
- package/internal/Event/WindowEventTarget.d.ts +30 -0
- package/internal/Event/setEventHandler.d.ts +1 -0
- package/internal/Mixin.d.ts +4 -0
- package/internal/native/enums.d.ts +119 -0
- package/internal/native/memWrite.d.ts +1 -0
- package/internal/symbols.d.ts +103 -22
- package/internal/window/glfwKeyMap.d.ts +368 -0
- package/package.json +11 -4
- package/src/Audio.d.ts +78 -4
- package/src/Canvas/RenderingContexts/2D/CanvasBatchedRenderingContext2D.d.ts +86 -0
- package/src/Canvas/RenderingContexts/2D/CanvasImmediateRenderingContext2D.d.ts +85 -0
- package/src/Canvas/RenderingContexts/2D/CanvasRenderingContext2DBase.d.ts +103 -0
- package/src/Canvas/RenderingContexts/CanvasRenderingContext2D.d.ts +3 -0
- package/src/Canvas/blendModes.d.ts +30 -0
- package/src/Canvas/canvasGradient.d.ts +11 -0
- package/src/Canvas/lineJoin.d.ts +7 -0
- package/src/Canvas/smoothingQuality.d.ts +7 -0
- package/src/Canvas/textAlignment.d.ts +9 -0
- package/src/Canvas/textBaseline.d.ts +10 -0
- package/src/Canvas.d.ts +11 -97
- package/src/Image.d.ts +13 -9
- package/src/KeyboardEvent.d.ts +43 -22
- package/src/MouseEvent.d.ts +51 -14
- package/src/Path2D.d.ts +1 -2
- package/src/WheelEvent.d.ts +16 -4
- package/src/Window.d.ts +8 -14
- package/src/Event.d.ts +0 -6
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Constructor } from "../Mixin";
|
|
2
|
+
export interface IKeyboardEventTarget {
|
|
3
|
+
onkeydown: ((evt: KeyboardEvent) => any) | null;
|
|
4
|
+
onkeyup: ((evt: KeyboardEvent) => any) | null;
|
|
5
|
+
}
|
|
6
|
+
export type KeyboardEventListenerNames = "keydown" | "keyup";
|
|
7
|
+
export declare function KeyboardEventMixin<TBase extends Constructor<EventTarget>>(Base: TBase): Constructor<IKeyboardEventTarget> & TBase;
|
|
8
|
+
declare const KeyboardEventTarget_base: Constructor<IKeyboardEventTarget> & {
|
|
9
|
+
new (): EventTarget;
|
|
10
|
+
prototype: EventTarget;
|
|
11
|
+
};
|
|
12
|
+
export declare class KeyboardEventTarget extends KeyboardEventTarget_base {
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Constructor } from "../Mixin";
|
|
2
|
+
export interface IMouseEventTarget {
|
|
3
|
+
onmousemove: ((evt: MouseEvent) => any) | null;
|
|
4
|
+
onmousedown: ((evt: MouseEvent) => any) | null;
|
|
5
|
+
onmouseup: ((evt: MouseEvent) => any) | null;
|
|
6
|
+
onclick: ((evt: MouseEvent) => any) | null;
|
|
7
|
+
oncontextmenu: ((evt: MouseEvent) => any) | null;
|
|
8
|
+
onwheel: ((evt: WheelEvent) => any) | null;
|
|
9
|
+
}
|
|
10
|
+
export type MouseEventListenerNames = "mousemove" | "mousedown" | "mouseup" | "click" | "contextmenu" | "wheel";
|
|
11
|
+
export declare function MouseEventMixin<TBase extends Constructor<EventTarget>>(Base: TBase): Constructor<IMouseEventTarget> & TBase;
|
|
12
|
+
declare const MouseEventTarget_base: Constructor<IMouseEventTarget> & {
|
|
13
|
+
new (): EventTarget;
|
|
14
|
+
prototype: EventTarget;
|
|
15
|
+
};
|
|
16
|
+
export declare class MouseEventTarget extends MouseEventTarget_base {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { KeyboardEventListenerNames } from "./KeyboardEventTarget";
|
|
2
|
+
import { MouseEventListenerNames } from "./MouseEventTarget";
|
|
3
|
+
export interface IWindowEventTarget {
|
|
4
|
+
onmousemove: ((evt: MouseEvent) => any) | null;
|
|
5
|
+
onmousedown: ((evt: MouseEvent) => any) | null;
|
|
6
|
+
onmouseup: ((evt: MouseEvent) => any) | null;
|
|
7
|
+
onclick: ((evt: MouseEvent) => any) | null;
|
|
8
|
+
oncontextmenu: ((evt: MouseEvent) => any) | null;
|
|
9
|
+
onwheel: ((evt: WheelEvent) => any) | null;
|
|
10
|
+
onkeydown: ((evt: KeyboardEvent) => any) | null;
|
|
11
|
+
onkeyup: ((evt: KeyboardEvent) => any) | null;
|
|
12
|
+
onresize: ((evt: Event) => any) | null;
|
|
13
|
+
onfocus: ((evt: FocusEvent) => any) | null;
|
|
14
|
+
onblur: ((evt: FocusEvent) => any) | null;
|
|
15
|
+
}
|
|
16
|
+
export type WindowEventListenerNames = "resize" | "focus" | "blur" | KeyboardEventListenerNames | MouseEventListenerNames;
|
|
17
|
+
declare const WindowEventTarget_base: {
|
|
18
|
+
new (): EventTarget;
|
|
19
|
+
prototype: EventTarget;
|
|
20
|
+
} & import("../Mixin").Constructor<import("./KeyboardEventTarget").IKeyboardEventTarget> & import("../Mixin").Constructor<EventTarget> & import("../Mixin").Constructor<import("./MouseEventTarget").IMouseEventTarget>;
|
|
21
|
+
export declare class WindowEventTarget extends WindowEventTarget_base implements EventTarget, IWindowEventTarget {
|
|
22
|
+
#private;
|
|
23
|
+
get onresize(): ((evt: Event) => any) | null;
|
|
24
|
+
set onresize(fn: ((evt: Event) => any) | null);
|
|
25
|
+
get onfocus(): ((evt: FocusEvent) => any) | null;
|
|
26
|
+
set onfocus(fn: ((evt: FocusEvent) => any) | null);
|
|
27
|
+
get onblur(): ((evt: FocusEvent) => any) | null;
|
|
28
|
+
set onblur(fn: ((evt: FocusEvent) => any) | null);
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setHandler(target: any, type: any, current: any, next: any): any;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type Constructor<T = {}> = new (...args: any[]) => T;
|
|
2
|
+
export declare function Mixin<TBase extends Constructor, TMixins extends Array<(base: any) => any>>(Base: TBase, ...mixins: TMixins): TBase & UnionToIntersection<ReturnType<TMixins[number]>>;
|
|
3
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export declare enum SkBlendMode {
|
|
2
|
+
kClear = 0,//!< r = 0
|
|
3
|
+
kSrc = 1,//!< r = s
|
|
4
|
+
kDst = 2,//!< r = d
|
|
5
|
+
kSrcOver = 3,//!< r = s + (1-sa)*d
|
|
6
|
+
kDstOver = 4,//!< r = d + (1-da)*s
|
|
7
|
+
kSrcIn = 5,//!< r = s * da
|
|
8
|
+
kDstIn = 6,//!< r = d * sa
|
|
9
|
+
kSrcOut = 7,//!< r = s * (1-da)
|
|
10
|
+
kDstOut = 8,//!< r = d * (1-sa)
|
|
11
|
+
kSrcATop = 9,//!< r = s*da + d*(1-sa)
|
|
12
|
+
kDstATop = 10,//!< r = d*sa + s*(1-da)
|
|
13
|
+
kXor = 11,//!< r = s*(1-da) + d*(1-sa)
|
|
14
|
+
kPlus = 12,//!< r = min(s + d, 1)
|
|
15
|
+
kModulate = 13,//!< r = s*d
|
|
16
|
+
kScreen = 14,//!< r = s + d - s*d
|
|
17
|
+
kOverlay = 15,//!< multiply or screen, depending on destination
|
|
18
|
+
kDarken = 16,//!< rc = s + d - max(s*da, d*sa), ra = kSrcOver
|
|
19
|
+
kLighten = 17,//!< rc = s + d - min(s*da, d*sa), ra = kSrcOver
|
|
20
|
+
kColorDodge = 18,//!< brighten destination to reflect source
|
|
21
|
+
kColorBurn = 19,//!< darken destination to reflect source
|
|
22
|
+
kHardLight = 20,//!< multiply or screen, depending on source
|
|
23
|
+
kSoftLight = 21,//!< lighten or darken, depending on source
|
|
24
|
+
kDifference = 22,//!< rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
|
|
25
|
+
kExclusion = 23,//!< rc = s + d - two(s*d), ra = kSrcOver
|
|
26
|
+
kMultiply = 24,//!< r = s*(1-da) + d*(1-sa) + s*d
|
|
27
|
+
kHue = 25,//!< hue of source with saturation and luminosity of destination
|
|
28
|
+
kSaturation = 26,//!< saturation of source with hue and luminosity of destination
|
|
29
|
+
kColor = 27,//!< hue and saturation of source with luminosity of destination
|
|
30
|
+
kLuminosity = 28,//!< luminosity of source with hue and saturation of destination
|
|
31
|
+
kLastCoeffMode = 14,//!< last porter duff blend mode
|
|
32
|
+
kLastSeparableMode = 24,//!< last blend mode operating separately on components
|
|
33
|
+
kLastMode = 28
|
|
34
|
+
}
|
|
35
|
+
export declare enum GradientType {
|
|
36
|
+
Linear = 0,
|
|
37
|
+
Radial = 1,
|
|
38
|
+
Conic = 2
|
|
39
|
+
}
|
|
40
|
+
export declare enum CanvasTextBaseLineEnum {
|
|
41
|
+
Top = 0,
|
|
42
|
+
Hanging = 1,
|
|
43
|
+
Middle = 2,
|
|
44
|
+
Alphabetic = 3,
|
|
45
|
+
Ideographic = 4,
|
|
46
|
+
Bottom = 5
|
|
47
|
+
}
|
|
48
|
+
export declare enum CanvasTextAlignmentEnum {
|
|
49
|
+
Left = 0,
|
|
50
|
+
Right = 1,
|
|
51
|
+
Center = 2,
|
|
52
|
+
Start = 3,
|
|
53
|
+
End = 4
|
|
54
|
+
}
|
|
55
|
+
export declare enum CanvasLineJoinEnum {
|
|
56
|
+
kMiter_Join = 0,//!< extends to miter limit
|
|
57
|
+
kRound_Join = 1,//!< adds circle
|
|
58
|
+
kBevel_Join = 2,//!< connects outside edges
|
|
59
|
+
kLast_Join = 2,//!< equivalent to the largest value for Join
|
|
60
|
+
kDefault_Join = 0
|
|
61
|
+
}
|
|
62
|
+
export declare enum CanvasSmoothingQualityEnum {
|
|
63
|
+
Low = 0,
|
|
64
|
+
Medium = 1,
|
|
65
|
+
High = 2
|
|
66
|
+
}
|
|
67
|
+
export declare enum CanvasBatchOperationType {
|
|
68
|
+
SetFont = 1,
|
|
69
|
+
SetFillStyleColor = 2,
|
|
70
|
+
SetFillStyleGradient = 3,
|
|
71
|
+
SetStrokeStyleColor = 4,
|
|
72
|
+
SetStrokeStyleGradient = 5,
|
|
73
|
+
SetLineWidth = 6,
|
|
74
|
+
SetGlobalAlpha = 7,
|
|
75
|
+
SetImageSmoothingQuality = 8,
|
|
76
|
+
SetImageSmoothingEnabled = 9,
|
|
77
|
+
SetFilter = 10,
|
|
78
|
+
SetGlobalCompositeOperation = 11,
|
|
79
|
+
SetShadowBlur = 12,
|
|
80
|
+
SetShadowColor = 13,
|
|
81
|
+
SetShadowOffsetX = 14,
|
|
82
|
+
SetShadowOffsetY = 15,
|
|
83
|
+
SetLineJoin = 16,
|
|
84
|
+
SetLineDash = 17,
|
|
85
|
+
SetLineDashOffset = 18,
|
|
86
|
+
SetTextBaseline = 19,
|
|
87
|
+
SetTextAlign = 20,
|
|
88
|
+
Save = 21,
|
|
89
|
+
Restore = 22,
|
|
90
|
+
UploadTransform = 23,
|
|
91
|
+
UploadTransformNoArray = 24,
|
|
92
|
+
FillRect = 25,
|
|
93
|
+
StrokeRect = 26,
|
|
94
|
+
ClearRect = 27,
|
|
95
|
+
FillText = 28,
|
|
96
|
+
StrokeText = 29,
|
|
97
|
+
BeginPath = 30,
|
|
98
|
+
MoveTo = 31,
|
|
99
|
+
LineTo = 32,
|
|
100
|
+
Arc = 33,
|
|
101
|
+
Ellipse = 34,
|
|
102
|
+
ArcTo = 35,
|
|
103
|
+
BezierCurveTo = 36,
|
|
104
|
+
QuadraticCurveTo = 37,
|
|
105
|
+
ClosePath = 38,
|
|
106
|
+
Rect = 39,
|
|
107
|
+
RoundRect = 40,
|
|
108
|
+
RoundRectArray = 41,
|
|
109
|
+
Fill = 42,// Uses current path
|
|
110
|
+
FillPath = 43,// Uses explicit Path2D*
|
|
111
|
+
Stroke = 44,// Uses current path
|
|
112
|
+
StrokePath = 45,// Uses explicit Path2D*
|
|
113
|
+
Clip = 46,
|
|
114
|
+
ClipPath = 47,
|
|
115
|
+
DrawImage_ImageType = 48,
|
|
116
|
+
DrawImage_CanvasType = 49,
|
|
117
|
+
PutImageData = 50,
|
|
118
|
+
Resize = 51
|
|
119
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function writePtrU64(buf: Uint32Array, index: number, ptr: number): number;
|
package/internal/symbols.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FFIType } from "bun:ffi";
|
|
1
2
|
export declare const dlPath: any;
|
|
2
3
|
export declare const encoder: TextEncoder;
|
|
3
4
|
export declare function encodeCString(str: any): any;
|
|
@@ -38,10 +39,6 @@ export declare const lib: import("bun:ffi").Library<{
|
|
|
38
39
|
args: never[];
|
|
39
40
|
returns: "ptr";
|
|
40
41
|
};
|
|
41
|
-
signal_frame_ready: {
|
|
42
|
-
args: never[];
|
|
43
|
-
returns: "void";
|
|
44
|
-
};
|
|
45
42
|
set_vsync: {
|
|
46
43
|
args: "bool"[];
|
|
47
44
|
returns: "void";
|
|
@@ -50,6 +47,14 @@ export declare const lib: import("bun:ffi").Library<{
|
|
|
50
47
|
args: ("cstring" | "int")[];
|
|
51
48
|
returns: "void";
|
|
52
49
|
};
|
|
50
|
+
setup_render_thread: {
|
|
51
|
+
args: ("bool" | "cstring" | "int" | "ptr")[];
|
|
52
|
+
returns: "void";
|
|
53
|
+
};
|
|
54
|
+
window_set_fullscreen: {
|
|
55
|
+
args: "bool"[];
|
|
56
|
+
returns: "void";
|
|
57
|
+
};
|
|
53
58
|
update_window: {
|
|
54
59
|
args: "ptr"[];
|
|
55
60
|
returns: "void";
|
|
@@ -79,7 +84,7 @@ export declare const lib: import("bun:ffi").Library<{
|
|
|
79
84
|
returns: "void";
|
|
80
85
|
};
|
|
81
86
|
canvas_get_context2D: {
|
|
82
|
-
args: ("bool" | "
|
|
87
|
+
args: ("bool" | "int")[];
|
|
83
88
|
returns: "ptr";
|
|
84
89
|
};
|
|
85
90
|
canvas_set_fill_style: {
|
|
@@ -171,7 +176,7 @@ export declare const lib: import("bun:ffi").Library<{
|
|
|
171
176
|
returns: "void";
|
|
172
177
|
};
|
|
173
178
|
canvas_set_composite_operation: {
|
|
174
|
-
args: ("
|
|
179
|
+
args: ("int" | "ptr")[];
|
|
175
180
|
returns: "bool";
|
|
176
181
|
};
|
|
177
182
|
canvas_draw_image_imageType: {
|
|
@@ -267,7 +272,7 @@ export declare const lib: import("bun:ffi").Library<{
|
|
|
267
272
|
returns: "bool";
|
|
268
273
|
};
|
|
269
274
|
canvas_set_line_join: {
|
|
270
|
-
args: ("
|
|
275
|
+
args: ("i8" | "ptr")[];
|
|
271
276
|
returns: "bool";
|
|
272
277
|
};
|
|
273
278
|
canvas_path_clip: {
|
|
@@ -276,16 +281,20 @@ export declare const lib: import("bun:ffi").Library<{
|
|
|
276
281
|
};
|
|
277
282
|
canvas_set_text_baseline: {
|
|
278
283
|
args: ("int" | "ptr")[];
|
|
279
|
-
returns: "
|
|
284
|
+
returns: "bool";
|
|
280
285
|
};
|
|
281
286
|
canvas_set_text_align: {
|
|
282
287
|
args: ("int" | "ptr")[];
|
|
283
|
-
returns: "
|
|
288
|
+
returns: "bool";
|
|
284
289
|
};
|
|
285
290
|
canvas_measure_text: {
|
|
286
291
|
args: ("cstring" | "ptr")[];
|
|
287
292
|
returns: "void";
|
|
288
293
|
};
|
|
294
|
+
canvas_submit_batch: {
|
|
295
|
+
args: ("bool" | "int" | "ptr")[];
|
|
296
|
+
returns: "void";
|
|
297
|
+
};
|
|
289
298
|
canvas_destroy: {
|
|
290
299
|
args: "ptr"[];
|
|
291
300
|
returns: "void";
|
|
@@ -320,27 +329,99 @@ export declare const lib: import("bun:ffi").Library<{
|
|
|
320
329
|
};
|
|
321
330
|
audio_backend_init: {
|
|
322
331
|
args: never[];
|
|
323
|
-
returns:
|
|
332
|
+
returns: FFIType.void;
|
|
324
333
|
};
|
|
325
334
|
audio_create: {
|
|
326
|
-
args:
|
|
327
|
-
returns:
|
|
335
|
+
args: FFIType.cstring[];
|
|
336
|
+
returns: FFIType.ptr;
|
|
328
337
|
};
|
|
329
|
-
|
|
330
|
-
args:
|
|
331
|
-
returns:
|
|
338
|
+
audio_destroy: {
|
|
339
|
+
args: FFIType.ptr[];
|
|
340
|
+
returns: FFIType.void;
|
|
341
|
+
};
|
|
342
|
+
audio_load: {
|
|
343
|
+
args: FFIType.ptr[];
|
|
344
|
+
returns: FFIType.bool;
|
|
332
345
|
};
|
|
333
346
|
audio_play: {
|
|
334
|
-
args:
|
|
335
|
-
returns:
|
|
347
|
+
args: FFIType.ptr[];
|
|
348
|
+
returns: FFIType.bool;
|
|
349
|
+
};
|
|
350
|
+
audio_pause: {
|
|
351
|
+
args: FFIType.ptr[];
|
|
352
|
+
returns: FFIType.void;
|
|
336
353
|
};
|
|
337
354
|
audio_stop: {
|
|
338
|
-
args:
|
|
339
|
-
returns:
|
|
355
|
+
args: FFIType.ptr[];
|
|
356
|
+
returns: FFIType.void;
|
|
340
357
|
};
|
|
341
|
-
|
|
342
|
-
args:
|
|
343
|
-
returns:
|
|
358
|
+
audio_set_src: {
|
|
359
|
+
args: (FFIType.ptr | FFIType.cstring)[];
|
|
360
|
+
returns: FFIType.void;
|
|
361
|
+
};
|
|
362
|
+
audio_get_src: {
|
|
363
|
+
args: FFIType.ptr[];
|
|
364
|
+
returns: FFIType.cstring;
|
|
365
|
+
};
|
|
366
|
+
audio_get_current_time: {
|
|
367
|
+
args: FFIType.ptr[];
|
|
368
|
+
returns: FFIType.double;
|
|
369
|
+
};
|
|
370
|
+
audio_set_current_time: {
|
|
371
|
+
args: (FFIType.double | FFIType.ptr)[];
|
|
372
|
+
returns: FFIType.void;
|
|
373
|
+
};
|
|
374
|
+
audio_get_duration: {
|
|
375
|
+
args: FFIType.ptr[];
|
|
376
|
+
returns: FFIType.double;
|
|
377
|
+
};
|
|
378
|
+
audio_get_volume: {
|
|
379
|
+
args: FFIType.ptr[];
|
|
380
|
+
returns: FFIType.float;
|
|
381
|
+
};
|
|
382
|
+
audio_set_volume: {
|
|
383
|
+
args: (FFIType.float | FFIType.ptr)[];
|
|
384
|
+
returns: FFIType.void;
|
|
385
|
+
};
|
|
386
|
+
audio_get_muted: {
|
|
387
|
+
args: FFIType.ptr[];
|
|
388
|
+
returns: FFIType.bool;
|
|
389
|
+
};
|
|
390
|
+
audio_set_muted: {
|
|
391
|
+
args: (FFIType.bool | FFIType.ptr)[];
|
|
392
|
+
returns: FFIType.void;
|
|
393
|
+
};
|
|
394
|
+
audio_get_loop: {
|
|
395
|
+
args: FFIType.ptr[];
|
|
396
|
+
returns: FFIType.bool;
|
|
397
|
+
};
|
|
398
|
+
audio_set_loop: {
|
|
399
|
+
args: (FFIType.bool | FFIType.ptr)[];
|
|
400
|
+
returns: FFIType.void;
|
|
401
|
+
};
|
|
402
|
+
audio_get_playback_rate: {
|
|
403
|
+
args: FFIType.ptr[];
|
|
404
|
+
returns: FFIType.float;
|
|
405
|
+
};
|
|
406
|
+
audio_set_playback_rate: {
|
|
407
|
+
args: (FFIType.float | FFIType.ptr)[];
|
|
408
|
+
returns: FFIType.void;
|
|
409
|
+
};
|
|
410
|
+
audio_get_paused: {
|
|
411
|
+
args: FFIType.ptr[];
|
|
412
|
+
returns: FFIType.bool;
|
|
413
|
+
};
|
|
414
|
+
audio_get_ended: {
|
|
415
|
+
args: FFIType.ptr[];
|
|
416
|
+
returns: FFIType.bool;
|
|
417
|
+
};
|
|
418
|
+
audio_get_ready_state: {
|
|
419
|
+
args: FFIType.ptr[];
|
|
420
|
+
returns: FFIType.uint16_t;
|
|
421
|
+
};
|
|
422
|
+
audio_get_has_error: {
|
|
423
|
+
args: FFIType.ptr[];
|
|
424
|
+
returns: FFIType.bool;
|
|
344
425
|
};
|
|
345
426
|
path2d_create: {
|
|
346
427
|
args: never[];
|