@buncanvas/core 0.0.0-stage → 0.1.2
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 +22 -2
- package/dom/DOMMatrix.d.ts +70 -0
- package/index.d.ts +12 -0
- package/index.js +26 -0
- package/internal/WindowThread.d.ts +1 -0
- package/internal/colorCheck.d.ts +1 -0
- package/internal/loader.d.ts +1 -0
- package/internal/pointers.d.ts +1 -0
- package/internal/symbols.d.ts +401 -0
- package/jsconfig.json +30 -0
- package/package.json +18 -4
- package/src/Audio.d.ts +7 -0
- package/src/Canvas.d.ts +114 -0
- package/src/Event.d.ts +6 -0
- package/src/FontFace.d.ts +7 -0
- package/src/Image.d.ts +14 -0
- package/src/ImageData.d.ts +6 -0
- package/src/KeyboardEvent.d.ts +24 -0
- package/src/MouseEvent.d.ts +16 -0
- package/src/Path2D.d.ts +14 -0
- package/src/TextMetrics.d.ts +15 -0
- package/src/WheelEvent.d.ts +6 -0
- package/src/Window.d.ts +32 -0
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# buncanvas
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
To install dependencies:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
bun install
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
To run:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun run index.js
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
To type check:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bun check
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Run `bun fmt` to format the code.
|
|
22
|
+
|
|
23
|
+
This project was created using `bun init` in bun v1.4.4. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export declare function multipliedMatrices(a: Float64Array | Float32Array, b: Float64Array | Float32Array): Float64Array<ArrayBuffer>;
|
|
2
|
+
export declare class DOMMatrix {
|
|
3
|
+
#private;
|
|
4
|
+
get a(): number;
|
|
5
|
+
set a(v: any);
|
|
6
|
+
get b(): number;
|
|
7
|
+
set b(v: any);
|
|
8
|
+
get c(): number;
|
|
9
|
+
set c(v: any);
|
|
10
|
+
get d(): number;
|
|
11
|
+
set d(v: any);
|
|
12
|
+
get e(): number;
|
|
13
|
+
set e(v: any);
|
|
14
|
+
get f(): number;
|
|
15
|
+
set f(v: any);
|
|
16
|
+
is2D: boolean;
|
|
17
|
+
get isIdentity(): boolean;
|
|
18
|
+
get m11(): number;
|
|
19
|
+
set m11(v: any);
|
|
20
|
+
get m12(): number;
|
|
21
|
+
set m12(v: any);
|
|
22
|
+
get m13(): number;
|
|
23
|
+
set m13(v: any);
|
|
24
|
+
get m14(): number;
|
|
25
|
+
set m14(v: any);
|
|
26
|
+
get m21(): number;
|
|
27
|
+
set m21(v: any);
|
|
28
|
+
get m22(): number;
|
|
29
|
+
set m22(v: any);
|
|
30
|
+
get m23(): number;
|
|
31
|
+
set m23(v: any);
|
|
32
|
+
get m24(): number;
|
|
33
|
+
set m24(v: any);
|
|
34
|
+
get m31(): number;
|
|
35
|
+
set m31(v: any);
|
|
36
|
+
get m32(): number;
|
|
37
|
+
set m32(v: any);
|
|
38
|
+
get m33(): number;
|
|
39
|
+
set m33(v: any);
|
|
40
|
+
get m34(): number;
|
|
41
|
+
set m34(v: any);
|
|
42
|
+
get m41(): number;
|
|
43
|
+
set m41(v: any);
|
|
44
|
+
get m42(): number;
|
|
45
|
+
set m42(v: any);
|
|
46
|
+
get m43(): number;
|
|
47
|
+
set m43(v: any);
|
|
48
|
+
get m44(): number;
|
|
49
|
+
set m44(v: any);
|
|
50
|
+
multiplySelf(other: DOMMatrix): this;
|
|
51
|
+
preMultiplySelf(other: DOMMatrix): this;
|
|
52
|
+
translateSelf(tx?: number, ty?: number, tz?: number): this;
|
|
53
|
+
scaleSelf(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): this;
|
|
54
|
+
scale3dSelf(scale: number, originX?: number, originY?: number, originZ?: number): this;
|
|
55
|
+
rotateSelf(rotZ: number): DOMMatrix;
|
|
56
|
+
rotateSelf(rotX: number, rotY: number): DOMMatrix;
|
|
57
|
+
rotateSelf(rotX: number, rotY: number, rotZ: number): DOMMatrix;
|
|
58
|
+
rotateAxisAngleSelf(x?: number, y?: number, z?: number, angle?: number): this;
|
|
59
|
+
rotateFromVectorSelf(x?: number, y?: number): DOMMatrix;
|
|
60
|
+
skewXSelf(sx?: number): this;
|
|
61
|
+
skewYSelf(sy?: number): this;
|
|
62
|
+
setMatrixValue(value: string): this | undefined;
|
|
63
|
+
toString(): string;
|
|
64
|
+
constructor();
|
|
65
|
+
constructor(matrix: Array<number> | ArrayBufferLike | ArrayLike<number>);
|
|
66
|
+
get ptr(): import("bun:ffi").Pointer;
|
|
67
|
+
static fromFloat32Array(arr: Float32Array): DOMMatrix | void;
|
|
68
|
+
static fromFloat64Array(arr: Float64Array): DOMMatrix | void;
|
|
69
|
+
static fromMatrix(arr: any): DOMMatrix;
|
|
70
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Image } from "./src/Image";
|
|
2
|
+
export { FontFace } from "./src/FontFace";
|
|
3
|
+
export { TextMetrics } from "./src/TextMetrics";
|
|
4
|
+
export { Event } from "./src/Event";
|
|
5
|
+
export { MouseEvent } from "./src/MouseEvent";
|
|
6
|
+
export { WheelEvent } from "./src/WheelEvent";
|
|
7
|
+
export { KeyboardEvent } from "./src/KeyboardEvent";
|
|
8
|
+
export { Canvas } from "./src/Canvas";
|
|
9
|
+
export { DOMMatrix } from "./dom/DOMMatrix";
|
|
10
|
+
export { Path2D } from "./src/Path2D";
|
|
11
|
+
export { Window, requestAnimationFrame } from "./src/Window";
|
|
12
|
+
export { Audio } from "./src/Audio";
|
package/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var U=import.meta.require;import{createHash as dt}from"crypto";import{basename as pt,join as gt}from"path";import{tmpdir as bt}from"os";import{dlopen as ft,FFIType as Xt,suffix as et}from"bun:ffi";var K;if(!process.argv.includes("--XX:BunCanvas.IgnoreImport"))K=U(`@buncanvas/native-${process.platform}-${process.arch}`);else K=`BunCanvas.${process.arch}.${et}`;console.log(K);if(!K)console.error(`BunCanvas.${process.arch}.${et} binary was not found in the working directory!`),process.exit(-1);var V=K,u=new TextEncoder,tt=new Map;function N(t){let e=tt.get(t);if(e)return e;return e=u.encode(t+"\x00"),tt.set(t,e),e}var n=ft(V,{glfw_init:{args:[],returns:"void"},get_wPropertiesViewer:{args:[],returns:"ptr"},get_mMoveViewer:{args:[],returns:"ptr"},get_mClickViewer:{args:[],returns:"ptr"},get_mDownViewer:{args:[],returns:"ptr"},get_mUpViewer:{args:[],returns:"ptr"},get_kDownViewer:{args:[],returns:"ptr"},get_kUpViewer:{args:[],returns:"ptr"},get_mWheelViewer:{args:[],returns:"ptr"},signal_frame_ready:{args:[],returns:"void"},set_vsync:{args:["bool"],returns:"void"},create_window:{args:["int","int","cstring"],returns:"void"},update_window:{args:["ptr"],returns:"void"},destroy_window:{args:[],returns:"void"},canvas_init_gpu_context:{args:[],returns:"bool"},canvas_flush_gpu:{args:[],returns:"void"},canvas_create:{args:["int","int","bool"],returns:"ptr"},canvas_resize:{args:["ptr","int","int"],returns:"void"},canvas_append:{args:["ptr"],returns:"void"},canvas_get_context2D:{args:["ptr","ptr","bool","bool"],returns:"ptr"},canvas_set_fill_style:{args:["ptr","cstring"],returns:"bool"},canvas_set_fill_style_gradient:{args:["ptr","int","ptr","int","ptr","ptr"],returns:"bool"},canvas_set_stroke_style:{args:["ptr","cstring"],returns:"bool"},canvas_set_stroke_style_gradient:{args:["ptr","int","ptr","int","ptr","ptr"],returns:"bool"},canvas_set_stroke_width:{args:["ptr","float"],returns:"bool"},canvas_fill_rect:{args:["ptr","int","int","int","int"],returns:"void"},canvas_stroke_rect:{args:["ptr","int","int","int","int"],returns:"void"},canvas_clear_rect:{args:["ptr","int","int","int","int"],returns:"void"},canvas_path_begin:{args:["ptr"],returns:"void"},canvas_path_move_to:{args:["ptr","int","int"],returns:"void"},canvas_path_line_to:{args:["ptr","int","int"],returns:"void"},canvas_path_arc:{args:["ptr","float","float","float","float","float"],returns:"void"},canvas_path_arc_to:{args:["ptr","float","float","float","float","float"],returns:"void"},canvas_path_bezier_to:{args:["ptr","float","float","float","float","float","float"],returns:"void"},canvas_path_quad_to:{args:["ptr","float","float","float","float"],returns:"void"},canvas_path_ellipse:{args:["ptr","float","float","float","float","float","float","float","bool"],returns:"void"},canvas_path_fill:{args:["ptr","ptr"],returns:"void"},canvas_path_stroke:{args:["ptr","ptr"],returns:"void"},canvas_path_close:{args:["ptr"],returns:"void"},canvas_path_rect:{args:["ptr","float","float","float","float"],returns:"void"},canvas_path_roundrect:{args:["ptr","float","float","float","float","float"],returns:"void"},canvas_path_roundrect_array:{args:["ptr","float","float","float","float","ptr","int"],returns:"void"},canvas_set_composite_operation:{args:["ptr","cstring"],returns:"bool"},canvas_draw_image_imageType:{args:["ptr","ptr","ptr","int"],returns:"void"},canvas_draw_image_canvasType:{args:["ptr","ptr","ptr","int"],returns:"void"},canvas_get_image_data:{args:["ptr","int","int","int","int","ptr"],returns:"bool"},canvas_put_image_data:{args:["ptr","int","int","int","int","ptr"],returns:"bool"},canvas_set_global_alpha:{args:["ptr","float"],returns:"float"},canvas_save:{args:["ptr"],returns:"float"},canvas_restore:{args:["ptr"],returns:"float"},canvas_translate:{args:["ptr","float","float"],returns:"void"},canvas_rotate:{args:["ptr","float"],returns:"float"},canvas_set_font:{args:["ptr","cstring"],returns:"bool"},canvas_fill_text:{args:["ptr","cstring","float","float","float"],returns:"void"},canvas_stroke_text:{args:["ptr","cstring","float","float","float"],returns:"void"},canvas_set_shadow_blur:{args:["ptr","float"],returns:"void"},canvas_set_shadow_color:{args:["ptr","cstring"],returns:"void"},canvas_set_shadow_offsetX:{args:["ptr","float"],returns:"void"},canvas_set_shadow_offsetY:{args:["ptr","float"],returns:"void"},canvas_set_image_smoothing_quality:{args:["ptr","int"],returns:"bool"},canvas_set_image_smoothing_enabled:{args:["ptr","bool"],returns:"bool"},canvas_get_transform:{args:["ptr","ptr"],returns:"void"},canvas_set_transform:{args:["ptr","ptr"],returns:"void"},canvas_reset_transform:{args:["ptr"],returns:"void"},canvas_set_filter:{args:["ptr","cstring"],returns:"bool"},canvas_set_line_dash:{args:["ptr","ptr","int","float"],returns:"bool"},canvas_set_line_join:{args:["ptr","int"],returns:"bool"},canvas_path_clip:{args:["ptr"],returns:"void"},canvas_set_text_baseline:{args:["ptr","int"],returns:"void"},canvas_set_text_align:{args:["ptr","int"],returns:"void"},canvas_measure_text:{args:["ptr","cstring","ptr"],returns:"void"},canvas_destroy:{args:["ptr"],returns:"void"},image_create:{args:[],returns:"ptr"},images_cleanup:{args:[],returns:"void"},image_set_src:{args:["ptr","cstring","bool"],returns:"void"},image_load:{args:["ptr","ptr"],returns:"bool"},image_destroy:{args:["ptr"],returns:"void"},font_load:{args:["cstring"],returns:"ptr"},audio_backend_init:{args:[],returns:"void"},audio_create:{args:["cstring"],returns:"ptr"},audio_set_src:{args:["ptr","cstring"],returns:"void"},audio_play:{args:["ptr"],returns:"void"},audio_stop:{args:["ptr"],returns:"void"},audio_destroy:{args:["ptr"],returns:"void"},path2d_create:{args:[],returns:"ptr"},path2d_create_from_copy:{args:["ptr"],returns:"ptr"},path2d_destroy:{args:["ptr"],returns:"void"},path2d_move_to:{args:["ptr","int","int"],returns:"void"},path2d_line_to:{args:["ptr","int","int"],returns:"void"},path2d_arc:{args:["ptr","float","float","float","float","float"],returns:"void"},path2d_arc_to:{args:["ptr","float","float","float","float","float"],returns:"void"},path2d_bezier_to:{args:["ptr","float","float","float","float","float","float"],returns:"void"},path2d_quad_to:{args:["ptr","float","float","float","float"],returns:"void"},path2d_ellipse:{args:["ptr","float","float","float","float","float","float","float","bool"],returns:"void"},path2d_close:{args:["ptr"],returns:"void"},path2d_rect:{args:["ptr","float","float","float","float"],returns:"void"},path2d_roundrect:{args:["ptr","float","float","float","float","float"],returns:"void"},path2d_roundrect_array:{args:["ptr","float","float","float","float","ptr","int"],returns:"void"},font_add_to_registry:{args:["cstring","ptr"],returns:"void"}});class d{type=null;target=null;timeStamp=performance.now();constructor(t,e){this.type=t,this.target=e}}import{ptr as st}from"bun:ffi";var P=new WeakMap,yt=new FinalizationRegistry((t)=>{n.symbols.image_destroy(t),console.log("destroy!")});function rt(t){let e=dt("sha256").update(t).digest("hex").slice(0,16),s=new URL(t),r=pt(s.pathname)||"index";return gt(bt(),`${e}-${r}`)}function _t(t,e){return(async()=>{let s=e??rt(t),r=await fetch(t);if(!r.ok||!r.body)throw Error(`HTTP ${r.status}: ${t}`);let i=await r.arrayBuffer();return await Bun.write(s,i),s})()}var wt=/^https?:\/\/(?:www\.)?[^\s/$.?#].[^\s]*$/;class T{#t=null;#e=0;#s=!1;#a=0;#l=!1;#i="";constructor(){let t=n.symbols.image_create();P.set(this,t),yt.register(this,t)}onload=null;onerror=null;set src(t){if(this.#i=t,wt.test(t)){let e=new WeakRef(this),s=rt(t),r=P.get(this);n.symbols.image_set_src(r,u.encode(`${s}\x00`),!0),_t(t,s).then(()=>{let i=new Int32Array(2),o=e.deref();if(!o)return;if(n.symbols.image_load(r,st(i)))this.#e=!this.#s?i[0]:this.#e,this.#a=!this.#l?i[1]:this.#a,o.onload?.call(o,new d("load",o));else o.onerror?.call(o,new d("error",o))}).catch((i)=>{let o=e.deref();if(!o)return;o.onerror?.call(o,new d("error",o))}).finally(()=>{});return}else{let e=new WeakRef(this);n.symbols.image_set_src(P.get(this),u.encode(`${t}\x00`),!1);let s=setTimeout(()=>{let r=e.deref();if(!r){clearTimeout(s);return}let i=P.get(r),o=new Int32Array(2);if(n.symbols.image_load(i,st(o)))this.#e=!this.#s?o[0]:this.#e,this.#a=!this.#l?o[1]:this.#a,r.onload?.call(r,new d("load",r));else r.onerror?.call(r,new d("error",r));clearTimeout(s)},0)}}get src(){return this.#i}get ptr(){return P.get(this)}get width(){return this.#e}get height(){return this.#a}set width(t){this.#s=!0,this.#e=t}set height(t){this.#l=!0,this.#a=t}}{let t=T.prototype;for(let e of Object.getOwnPropertyNames(t)){let s=Object.getOwnPropertyDescriptor(t,e);if(e=="constructor"){s&&(s.value.toString=()=>`function ${t.constructor.name}() { [native code] }`);continue}if(typeof s?.value==="function")s.value.toString=()=>`function ${e}() { [native code] }`}}class j{#t="";#e="";_nativePtr=null;constructor(t,e){this.#t=t.toLowerCase(),this.#e=e.trim().replaceAll("url(","").replaceAll('"',"").replaceAll("'","").replaceAll(")","").trim()}get family(){return this.#t}async load(){return new Promise((t,e)=>{if(this._nativePtr=n.symbols.font_load(u.encode(`${this.#e}\x00`)),console.log(this._nativePtr,this.#e),this._nativePtr)t();else e()})}}{let t=j.prototype;for(let e of Object.getOwnPropertyNames(t)){let s=Object.getOwnPropertyDescriptor(t,e);if(e=="constructor"){s&&(s.value.toString=()=>`function ${t.constructor.name}() { [native code] }`);continue}if(typeof s?.value==="function")s.value.toString=()=>`function ${e}() { [native code] }`}}class W{width;actualBoundingBoxLeft;actualBoundingBoxRight;actualBoundingBoxAscent;actualBoundingBoxDescent;fontBoundingBoxAscent;fontBoundingBoxDescent;emHeightAscent;emHeightDescent;alphabeticBaseline;hangingBaseline;ideographicBaseline;constructor(t,e,s,r,i,o,l,h,m,f,g,F){this.width=t,this.actualBoundingBoxLeft=e,this.actualBoundingBoxRight=s,this.actualBoundingBoxAscent=r,this.actualBoundingBoxDescent=i,this.fontBoundingBoxAscent=o,this.fontBoundingBoxDescent=l,this.emHeightAscent=h,this.emHeightDescent=m,this.alphabeticBaseline=f,this.hangingBaseline=g,this.ideographicBaseline=F}}class w extends d{altKey=!1;button=0;buttons=0;clientX=0;clientY=0;movementX=0;movementY=0;ctrlKey=!1;metaKey=!1;screenX=0;screenY=0;shiftKey=!1;constructor(t,e={altKey:!1,button:0,buttons:0,clientX:0,clientY:0,movementX:0,movementY:0,ctrlKey:!1,metaKey:!1,screenX:0,screenY:0,shiftKey:!1,target:null}){super(t,e.target);this.altKey=e.altKey,this.button=e.button,this.buttons=e.buttons,this.clientX=e.clientX,this.clientY=e.clientY,this.movementX=e.movementX,this.movementY=e.movementY,this.ctrlKey=e.ctrlKey,this.metaKey=e.metaKey,this.screenX=e.screenX,this.screenY=e.screenY,this.shiftKey=e.shiftKey}}var z=w.prototype;for(let t of Object.getOwnPropertyNames(z)){let e=Object.getOwnPropertyDescriptor(z,t);if(t=="constructor"){e&&(e.value.toString=()=>`function ${z.constructor.name}() { [native code] }`);continue}if(typeof e?.value==="function")e.value.toString=()=>`function ${t}() { [native code] }`}class I extends w{deltaX=0;deltaY=0;constructor(t,e={altKey:!1,button:0,buttons:0,clientX:0,clientY:0,movementX:0,movementY:0,deltaX:0,deltaY:0,ctrlKey:!1,metaKey:!1,screenX:0,screenY:0,shiftKey:!1,target:null}){super(t,e);this.deltaX=e.deltaX??0,this.deltaY=e.deltaY??0}}var vt={"-1":"Unknown",32:" ",39:"'",44:",",45:"-",46:".",47:"/",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:"[",92:"\\",93:"]",96:"`",161:"World1",162:"World2",256:"Escape",257:"Enter",258:"Tab",259:"Backspace",260:"Insert",261:"Delete",262:"ArrowRight",263:"ArrowLeft",264:"ArrowDown",265:"ArrowUp",266:"PageUp",267:"PageDown",268:"Home",269:"End",280:"CapsLock",281:"ScrollLock",282:"NumLock",283:"PrintScreen",284:"Pause",290:"F1",291:"F2",292:"F3",293:"F4",294:"F5",295:"F6",296:"F7",297:"F8",298:"F9",299:"F10",300:"F11",301:"F12",302:"F13",303:"F14",304:"F15",305:"F16",306:"F17",307:"F18",308:"F19",309:"F20",310:"F21",311:"F22",312:"F23",313:"F24",314:"F25",320:"0",321:"1",322:"2",323:"3",324:"4",325:"5",326:"6",327:"7",328:"8",329:"9",330:".",331:"/",332:"*",333:"-",334:"+",335:"Enter",336:"=",340:"Shift",341:"Control",342:"Alt",343:"Meta",344:"Shift",345:"Control",346:"Alt",347:"Meta",348:"ContextMenu"},Ft={"-1":"Unknown",32:" ",39:'"',44:"<",45:"_",46:">",47:"?",48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",91:"{",92:"|",93:"}",96:"~",161:"World1",162:"World2",256:"Escape",257:"Enter",258:"Tab",259:"Backspace",260:"Insert",261:"Delete",262:"ArrowRight",263:"ArrowLeft",264:"ArrowDown",265:"ArrowUp",266:"PageUp",267:"PageDown",268:"Home",269:"End",280:"CapsLock",281:"ScrollLock",282:"NumLock",283:"PrintScreen",284:"Pause",290:"F1",291:"F2",292:"F3",293:"F4",294:"F5",295:"F6",296:"F7",297:"F8",298:"F9",299:"F10",300:"F11",301:"F12",302:"F13",303:"F14",304:"F15",305:"F16",306:"F17",307:"F18",308:"F19",309:"F20",310:"F21",311:"F22",312:"F23",313:"F24",314:"F25",320:"0",321:"1",322:"2",323:"3",324:"4",325:"5",326:"6",327:"7",328:"8",329:"9",330:".",331:"/",332:"*",333:"-",334:"+",335:"Enter",336:"=",340:"Shift",341:"Control",342:"Alt",343:"Meta",344:"Shift",345:"Control",346:"Alt",347:"Meta",348:"ContextMenu"},xt={"-1":"Unknown",32:"Space",39:"Quote",44:"Comma",45:"Minus",46:"Period",47:"Slash",48:"Digit0",49:"Digit1",50:"Digit2",51:"Digit3",52:"Digit4",53:"Digit5",54:"Digit6",55:"Digit7",56:"Digit8",57:"Digit9",59:"Semicolon",61:"Equal",65:"KeyA",66:"KeyB",67:"KeyC",68:"KeyD",69:"KeyE",70:"KeyF",71:"KeyG",72:"KeyH",73:"KeyI",74:"KeyJ",75:"KeyK",76:"KeyL",77:"KeyM",78:"KeyN",79:"KeyO",80:"KeyP",81:"KeyQ",82:"KeyR",83:"KeyS",84:"KeyT",85:"KeyU",86:"KeyV",87:"KeyW",88:"KeyX",89:"KeyY",90:"KeyZ",91:"BracketLeft",92:"Backslash",93:"BracketRight",96:"Backquote",161:"IntlBackslash",256:"Escape",257:"Enter",258:"Tab",259:"Backspace",260:"Insert",261:"Delete",262:"ArrowRight",263:"ArrowLeft",264:"ArrowDown",265:"ArrowUp",266:"PageUp",267:"PageDown",268:"Home",269:"End",280:"CapsLock",281:"ScrollLock",282:"NumLock",283:"PrintScreen",284:"Pause",290:"F1",291:"F2",292:"F3",293:"F4",294:"F5",295:"F6",296:"F7",297:"F8",298:"F9",299:"F10",300:"F11",301:"F12",302:"F13",303:"F14",304:"F15",305:"F16",306:"F17",307:"F18",308:"F19",309:"F20",310:"F21",311:"F22",312:"F23",313:"F24",314:"F25",320:"Numpad0",321:"Numpad1",322:"Numpad2",323:"Numpad3",324:"Numpad4",325:"Numpad5",326:"Numpad6",327:"Numpad7",328:"Numpad8",329:"Numpad9",330:"NumpadDecimal",331:"NumpadDivide",332:"NumpadMultiply",333:"NumpadSubtract",334:"NumpadAdd",335:"NumpadEnter",336:"NumpadEqual",340:"ShiftLeft",341:"ControlLeft",342:"AltLeft",343:"MetaLeft",344:"ShiftRight",345:"ControlRight",346:"AltRight",347:"MetaRight",348:"ContextMenu"};class O extends d{target=null;key="";code="";location=0;repeat=!1;ctrlKey=!1;shiftKey=!1;altKey=!1;metaKey=!1;constructor(t,e={target:null,key:"",code:"",location:0,repeat:!1,ctrlKey:!1,shiftKey:!1,altKey:!1,metaKey:!1},s=null,r=null,i=!1,o=!1,l=!1,h=!1,m=!1){super(t,e?e.target:r);if(e)this.key=e.key,this.code=e.code,this.location=e.location,this.repeat=e.repeat,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey;else{let f=s;if(f>=65&&f<=90){let g=String.fromCharCode(f);this.key=o??e.shiftKey?g:g.toLowerCase()}else this.key=o??e.shiftKey?Ft[s]:vt[s];this.code=xt[s],this.location=0,this.repeat=!1,this.shiftKey=o,this.ctrlKey=l,this.altKey=h,this.metaKey=m}}}import{ptr as y,JSCallback as Ct}from"bun:ffi";class L{width;height;data;constructor(t,e,s){this.width=t,this.height=e,this.data=s}}import{ptr as kt}from"bun:ffi";function Mt(t){return t==null||Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function v(t,e){let s=new Float64Array(16);return s[0]=t[0]*e[0]+t[1]*e[4]+t[2]*e[8]+t[3]*e[12],s[1]=t[0]*e[1]+t[1]*e[5]+t[2]*e[9]+t[3]*e[13],s[2]=t[0]*e[2]+t[1]*e[6]+t[2]*e[10]+t[3]*e[14],s[3]=t[0]*e[3]+t[1]*e[7]+t[2]*e[11]+t[3]*e[15],s[4]=t[4]*e[0]+t[5]*e[4]+t[6]*e[8]+t[7]*e[12],s[5]=t[4]*e[1]+t[5]*e[5]+t[6]*e[9]+t[7]*e[13],s[6]=t[4]*e[2]+t[5]*e[6]+t[6]*e[10]+t[7]*e[14],s[7]=t[4]*e[3]+t[5]*e[7]+t[6]*e[11]+t[7]*e[15],s[8]=t[8]*e[0]+t[9]*e[4]+t[10]*e[8]+t[11]*e[12],s[9]=t[8]*e[1]+t[9]*e[5]+t[10]*e[9]+t[11]*e[13],s[10]=t[8]*e[2]+t[9]*e[6]+t[10]*e[10]+t[11]*e[14],s[11]=t[8]*e[3]+t[9]*e[7]+t[10]*e[11]+t[11]*e[15],s[12]=t[12]*e[0]+t[13]*e[4]+t[14]*e[8]+t[15]*e[12],s[13]=t[12]*e[1]+t[13]*e[5]+t[14]*e[9]+t[15]*e[13],s[14]=t[12]*e[2]+t[13]*e[6]+t[14]*e[10]+t[15]*e[14],s[15]=t[12]*e[3]+t[13]*e[7]+t[14]*e[11]+t[15]*e[15],s}function c(t,e){throw SyntaxError(`Failed to execute '${t}' on 'DOMMatrix': Failed to parse '${e}'.`)}class b{#t=new Float64Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);#e=!0;#s(){this.#e=this.#t[0]==1&&this.#t[1]==0&&this.#t[2]==0&&this.#t[3]==0&&this.#t[4]==0&&this.#t[5]==1&&this.#t[6]==0&&this.#t[7]==0&&this.#t[8]==0&&this.#t[9]==0&&this.#t[10]==1&&this.#t[11]==0&&this.#t[12]==0&&this.#t[13]==0&&this.#t[14]==0&&this.#t[15]==1}get a(){return this.m11}set a(t){this.m11=t}get b(){return this.m12}set b(t){this.m12=t}get c(){return this.m21}set c(t){this.m21=t}get d(){return this.m22}set d(t){this.m22=t}get e(){return this.m41}set e(t){this.m41=t}get f(){return this.m42}set f(t){this.m42=t}is2D=!0;get isIdentity(){return this.#e}get m11(){return this.#t[0]}set m11(t){if(this.#t[0]=t,!this.#e){if(t==1)this.#s()}else if(t!=1)this.#e=!1}get m12(){return this.#t[4]}set m12(t){if(this.#t[4]=t,!this.#e){if(t==0)this.#s()}else if(t!=0)this.#e=!1}get m13(){return this.#t[8]}set m13(t){if(this.#t[8]=t,!this.#e){if(t==0)this.#s()}else if(t!=0)this.#e=!1}get m14(){return this.#t[12]}set m14(t){if(this.#t[12]=t,!this.#e){if(t==0)this.#s()}else if(t!=0)this.#e=!1}get m21(){return this.#t[1]}set m21(t){if(this.#t[1]=t,!this.#e){if(t==0)this.#s()}else if(t!=0)this.#e=!1}get m22(){return this.#t[5]}set m22(t){if(this.#t[5]=t,!this.#e){if(t==1)this.#s()}else if(t!=1)this.#e=!1}get m23(){return this.#t[9]}set m23(t){if(this.#t[9]=t,!this.#e){if(t==0)this.#s()}else if(t!=0)this.#e=!1}get m24(){return this.#t[13]}set m24(t){if(this.#t[13]=t,!this.#e){if(t==0)this.#s()}else if(t!=0)this.#e=!1}get m31(){return this.#t[2]}set m31(t){if(this.#t[2]=t,!this.#e){if(t==0)this.#s()}else if(t!=0)this.#e=!1}get m32(){return this.#t[6]}set m32(t){if(this.#t[6]=t,!this.#e){if(t==0)this.#s()}else if(t!=0)this.#e=!1}get m33(){return this.#t[10]}set m33(t){if(this.#t[10]=t,!this.#e){if(t==1)this.#s()}else if(t!=1)this.#e=!1}get m34(){return this.#t[14]}set m34(t){if(this.#t[14]=t,!this.#e){if(t==0)this.#s()}else if(t!=0)this.#e=!1}get m41(){return this.#t[3]}set m41(t){if(this.#t[3]=t,!this.#e){if(t==0)this.#s()}else if(t!=0)this.#e=!1}get m42(){return this.#t[7]}set m42(t){if(this.#t[7]=t,!this.#e){if(t==0)this.#s()}else if(t!=0)this.#e=!1}get m43(){return this.#t[11]}set m43(t){if(this.#t[11]=t,!this.#e){if(t==0)this.#s()}else if(t!=0)this.#e=!1}get m44(){return this.#t[15]}set m44(t){if(this.#t[15]=t,!this.#e){if(t==1)this.#s()}else if(t!=1)this.#e=!1}multiplySelf(t){let e=this.#t,s=t.#t;return this.#t.set(v(e,s)),this.is2D&&=t.is2D,this}preMultiplySelf(t){let e=this.#t,s=t.#t;return this.#t.set(v(s,e)),this.is2D&&=t.is2D,this}translateSelf(t=0,e=0,s=0){let r=new Float64Array([1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1]);if(this.#t.set(v(this.#t,r)),s!==0)this.is2D=!1;return this}scaleSelf(t=1,e=t,s=1,r=0,i=0,o=0){if(r||i||o)this.translateSelf(r,i,o);let l=new Float64Array([t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1]);if(this.#t.set(v(this.#t,l)),r||i||o)this.translateSelf(-r,-i,-o);if(s!==1||o!==0)this.is2D=!1;return this}scale3dSelf(t,e=0,s=0,r=0){return this.scaleSelf(t,t,t,e,s,r)}rotateSelf(...t){if(t[1]===void 0&&t[2]===void 0)t[2]=t[0],t[0]=0,t[1]=0;else t[1]??=0,t[2]??=0;let e=t[0]*Math.PI/180,s=t[1]*Math.PI/180,r=t[2]*Math.PI/180,i=Math.sin(e),o=Math.cos(e),l=Math.sin(s),h=Math.cos(s),m=Math.sin(r),f=Math.cos(r);if(t[2]!==0)this.#t.set(v(this.#t,new Float64Array([f,-m,0,0,m,f,0,0,0,0,1,0,0,0,0,1])));if(t[1]!==0)this.#t.set(v(new Float64Array([h,0,l,0,0,1,0,0,-l,0,h,0,0,0,0,1]),this.#t));if(t[0]!==0)this.#t.set(v(new Float64Array([1,0,0,0,0,o,-i,0,0,i,o,0,0,0,0,1]),this.#t));if(t[0]!==0||t[1]!==0)this.is2D=!1;return this}rotateAxisAngleSelf(t=0,e=0,s=1,r=0){let i=Math.hypot(t,e,s);if(i===0)return this;t/=i,e/=i,s/=i;let o=r*Math.PI/180,l=Math.sin(o),h=Math.cos(o),m=1-h,f=new Float64Array([m*t*t+h,m*t*e-l*s,m*t*s+l*e,0,m*t*e+l*s,m*e*e+h,m*e*s-l*t,0,m*t*s-l*e,m*e*s+l*t,m*s*s+h,0,0,0,0,1]);if(this.#t.set(v(this.#t,f)),t!==0||e!==0)this.is2D=!1;return this}rotateFromVectorSelf(t=0,e=0){if(t===0&&e===0)return this;let s=Math.atan2(e,t)*180/Math.PI;return this.rotateSelf(s)}skewXSelf(t=0){let e=Math.tan(t*Math.PI/180);return this.#t.set(v(this.#t,new Float64Array([1,e,0,0,0,1,0,0,0,0,1,0,0,0,0,1]))),this}skewYSelf(t=0){let e=Math.tan(t*Math.PI/180);return this.#t.set(v(this.#t,new Float64Array([1,0,0,0,e,1,0,0,0,0,1,0,0,0,0,1]))),this}#a(t){let e=[],s=0;while(s<t.length){while(/\s/.test(t[s]))s++;if(s>=t.length)break;let r=s;while(/[A-Za-z0-9]/.test(t[s]))s++;let i=t.substring(r,s);while(/\s/.test(t[s]))s++;if(t[s]!=="(")return"error";s++;let o=1,l=s;while(s<t.length&&o>0){if(t[s]==="(")o++;else if(t[s]===")")o--;s++}if(o!==0)return"error";e.push({name:i,args:t.substring(l,s-1)})}return e}#l(t){let e=[],s="",r=0;for(let i of t){if(i==="(")r++;if(i===")")r--;if((i===","||/\s/.test(i))&&r===0){if(s.length)e.push(s),s="";continue}s+=i}if(s.length)e.push(s);return e}#i(t){if(t.endsWith("deg"))return Number.parseFloat(t);if(t.endsWith("rad"))return Number.parseFloat(t)*180/Math.PI;if(t.endsWith("grad"))return Number.parseFloat(t)*0.9;if(t.endsWith("turn"))return Number.parseFloat(t)*360;return Number.parseFloat(t)}#o(t){if(!t)return null;let e=16,s=16,r=8,i=8;if(t.endsWith("px"))return Number.parseFloat(t);if(t.endsWith("pt"))return Number.parseFloat(t)*1.3333333730697632;if(t.endsWith("pc"))return Number.parseFloat(t)*16;if(t.endsWith("in"))return Number.parseFloat(t)*96;if(t.endsWith("cm"))return Number.parseFloat(t)*37.79527559055118;if(t.endsWith("mm"))return Number.parseFloat(t)*3.7795275590551185;if(t.endsWith("q"))return Number.parseFloat(t)*0.9448818897637796;if(t.endsWith("em"))return Number.parseFloat(t)*s;if(t.endsWith("rem"))return Number.parseFloat(t)*e;if(t.endsWith("ex"))return Number.parseFloat(t)*r;if(t.endsWith("ch"))return Number.parseFloat(t)*i;if(t.endsWith("%"))return Number.parseFloat(t)*s/100;if(t.endsWith("px"))return Number.parseFloat(t);else if(t.endsWith("pt"))return Number.parseFloat(t)*1.3333333730697632;return null}setMatrixValue(t){if(t=t.trim(),t.length===0)throw new DOMException("Invalid transform.","SyntaxError");let e=this.#a(t);if(e=="error"){c("setMatrixValue",t);return}for(let s of e){let r=this.#l(s.args);switch(s.name){case"matrix":{if(r.length!==6)throw new DOMException("matrix() requires 6 arguments.","SyntaxError");let i=Number.parseFloat(r[0]),o=Number.parseFloat(r[1]),l=Number.parseFloat(r[2]),h=Number.parseFloat(r[3]);if(isNaN(i)||isNaN(o)||isNaN(l)||isNaN(h))c("setMatrixValue",t);this.a=i,this.b=o,this.c=l,this.d=h,this.e=this.#o(r[4]),this.f=this.#o(r[5]),this.is2D=!0;break}case"matrix3d":{if(r.length!==16)c("setMatrixValue",t);for(let i=0;i<16;i++)this.#t[i]=Number.parseFloat(r[i]);this.is2D=!1;break}case"translate":{if(r.length<1||r.length>2)c("setMatrixValue",t);let i=this.#o(r[0]),o=this.#o(r[1]);if(!i){c("setMatrixValue",t);return}let l=i,h=r.length===2?o??0:0;this.translateSelf(l,h);break}case"translateX":{if(r.length!==1)c("setMatrixValue",t);let i=this.#o(r[0]);if(!i){c("setMatrixValue",t);return}this.translateSelf(i,0);break}case"translateY":{if(r.length!==1)c("setMatrixValue",t);let i=this.#o(r[0]);if(!i){c("setMatrixValue",t);return}this.translateSelf(0,i);break}case"translateZ":{if(r.length!==1)c("setMatrixValue",t);let i=this.#o(r[0]);if(!i){c("setMatrixValue",t);return}this.translateSelf(0,0,i);break}case"translate3d":{if(r.length!==3)c("setMatrixValue",t);let i=this.#o(r[0]),o=this.#o(r[0]),l=this.#o(r[0]);if(!i||!o||!l){c("setMatrixValue",t);return}this.translateSelf(i,o,l);break}case"scale":{if(r.length<1||r.length>2)c("setMatrixValue",t);let i=Number.parseFloat(r[0]),o=r.length===2?Number.parseFloat(r[1]):i;this.scaleSelf(i,o);break}case"scaleX":{if(r.length!==1)c("setMatrixValue",t);this.scaleSelf(Number.parseFloat(r[0]),1);break}case"scaleY":{if(r.length!==1)c("setMatrixValue",t);this.scaleSelf(1,Number.parseFloat(r[0]));break}case"scaleZ":{if(r.length!==1)c("setMatrixValue",t);this.scaleSelf(1,1,Number.parseFloat(r[0]));break}case"scale3d":{if(r.length!==3)c("setMatrixValue",t);this.scale3dSelf(Number.parseFloat(r[0]),Number.parseFloat(r[1]),Number.parseFloat(r[2]));break}case"rotate":{if(r.length!==1)c("setMatrixValue",t);this.rotateSelf(this.#i(r[0]));break}case"rotateX":{if(r.length!==1)c("setMatrixValue",t);this.rotateSelf(this.#i(r[0]),0,0);break}case"rotateY":{if(r.length!==1)c("setMatrixValue",t);this.rotateSelf(0,this.#i(r[0]),0);break}case"rotateZ":{if(r.length!==1)c("setMatrixValue",t);this.rotateSelf(0,0,this.#i(r[0]));break}case"rotate3d":{if(r.length!==4)c("setMatrixValue",t);this.rotateAxisAngleSelf(Number.parseFloat(r[0]),Number.parseFloat(r[1]),Number.parseFloat(r[2]),this.#i(r[3]));break}case"skew":{if(r.length<1||r.length>2)c("setMatrixValue",t);if(this.skewXSelf(this.#i(r[0])),r.length===2)this.skewYSelf(this.#i(r[1]));break}case"skewX":{if(r.length!==1)c("setMatrixValue",t);this.skewXSelf(this.#i(r[0]));break}case"skewY":{if(r.length!==1)c("setMatrixValue",t);this.skewYSelf(this.#i(r[0]));break}case"perspective":{if(r.length!==1)c("setMatrixValue",t);let i=this.#o(r[0]);if(i===0||!i){c("setMatrixValue",t);return}this.#t.set(v(this.#t,new Float64Array([1,0,0,0,0,1,0,0,0,0,1,-1/i,0,0,0,1]))),this.is2D=!1;break}default:c("setMatrixValue",t)}}return this}toString(){return this.is2D?`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.e}, ${this.f})`:`matrix3d(${this.m11}, ${this.m12}, ${this.m13}, ${this.m14}, ${this.m21}, ${this.m22}, ${this.m23}, ${this.m24}, ${this.m31}, ${this.m32}, ${this.m33}, ${this.m34}, ${this.m41}, ${this.m42}, ${this.m43}, ${this.m44})`}constructor(...t){if(!Mt(t[0]))throw SyntaxError(`Failed to construct 'DOMMatrix': Failed to parse '${t[0]}'.`);if(t[0]){let e=t[0].length;if(e!=6&&e!=16)throw TypeError("Failed to construct 'DOMMatrix': The sequence must contain 6 elements for a 2D matrix or 16 elements for a 3D matrix.");let s=t[0];if(e==6)this.a=s[0],this.b=s[1],this.c=s[2],this.d=s[3],this.e=s[4],this.f=s[5];else{let r=0;for(let i of s)this.#t[r]=i,r++}this.#e=s[0]==1&&s[1]==0&&s[2]==0&&s[3]==0&&s[4]==0&&s[5]==1&&s[6]==0&&s[7]==0&&s[8]==0&&s[9]==0&&s[10]==1&&s[11]==0&&s[12]==0&&s[13]==0&&s[14]==0&&s[15]==1}}get ptr(){return kt(this.#t)}static fromFloat32Array(t){if(t instanceof Float32Array)return new b(t);throw TypeError("Failed to execute 'fromFloat32Array' on 'DOMMatrix': parameter 1 is not of type 'Float32Array'.")}static fromFloat64Array(t){if(t instanceof Float64Array)return new b(t);throw TypeError("Failed to execute 'fromFloat64Array' on 'DOMMatrix': parameter 1 is not of type 'Float64Array'.")}static fromMatrix(t){if(!t)return new b;if(t.a!=t.m11||t.b!=t.m21||t.c!=t.m12||t.d!=t.m22||t.e!=t.m41||t.f!=t.m42)throw TypeError("Failed to execute 'fromMatrix' on 'DOMMatrix': Property mismatch on matrix initialization.");let e=t.a??void 0,s=t.b??void 0,r=t.c??void 0,i=t.d??void 0,o=t.e??void 0,l=t.f??void 0,h=t.m11??e??1,m=t.m12??s??0,f=t.m13??0,g=t.m14??0,F=t.m21??r??0,_=t.m22??i??1,x=t.m23??0,S=t.m24??0,k=t.m31??0,G=t.m32??0,C=t.m33??1,lt=t.m34??0,ht=t.m41??o??0,ct=t.m42??l??0,mt=t.m43??0,ut=t.m44??1;return new b([h,m,f,g,F,_,x,S,k,G,C,lt,ht,ct,mt,ut])}}var H=b.prototype;for(let t of Object.getOwnPropertyNames(H)){let e=Object.getOwnPropertyDescriptor(H,t);if(t=="constructor"){e&&(e.value.toString=()=>`function ${H.constructor.name}() { [native code] }`);continue}if(typeof e?.value==="function")e.value.toString=()=>`function ${t}() { [native code] }`}var St=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),At=/^#(?:[0-9a-fA-F]{3,4}){1,2}$/,Dt=/^rgba?\(\s*(?:\d+(?:\.\d+)?%?|\.\d+%?)\s*[, ]\s*(?:\d+(?:\.\d+)?%?|\.\d+%?)\s*[, ]\s*(?:\d+(?:\.\d+)?%?|\.\d+%?)(?:\s*[,/]\s*(?:\d+(?:\.\d+)?%?|\.\d+%?))?\s*\)$/i,Et=/^(?:hsl|hsla|hwb)\(\s*(?:\d+(?:\.\d+)?(?:deg|rad|turn)?|\.\d+(?:deg|rad|turn)?)\s*[, ]\s*(?:\d+(?:\.\d+)?%|\.\d+%)\s*[, ]\s*(?:\d+(?:\.\d+)?%|\.\d+%)(?:\s*[,/]\s*(?:\d+(?:\.\d+)?%?|\.\d+%?))?\s*\)$/i;function nt(t){if(typeof t!=="string")return!1;let e=t.trim().toLowerCase();if(e==="")return!1;if(St.has(e))return!0;if(e.startsWith("#"))return At.test(e);return Dt.test(e)||Et.test(e)}var a=new WeakMap,Kt=new FinalizationRegistry((t)=>{n.symbols.canvas_destroy(t),console.log("destroyed Canvas!")});class D{type;points=new Float32Array(6);offsets=[];colors=[];constructor(...t){switch(this.type=t[0],this.type){case 0:{this.points[0]=t[1],this.points[1]=t[2],this.points[2]=t[3],this.points[3]=t[4];break}case 1:{this.points[0]=t[1],this.points[1]=t[2],this.points[2]=t[3],this.points[3]=t[4],this.points[4]=t[5],this.points[5]=t[6];break}case 2:{this.points[0]=t[1],this.points[1]=t[2],this.points[2]=t[3];break}}}addColorStop(t,e){if(t<0||t>1)throw RangeError(`Failed to execute 'addColorStop' on 'CanvasGradient': The provided value (${t}) is outside the range (0.0, 1.0).`);if(!nt(e))throw SyntaxError(`Failed to execute 'addColorStop' on 'CanvasGradient': The value provided ('${e}') could not be parsed as a color.`);let s=this.offsets.findIndex((i)=>i>t),r=s===-1?this.offsets.length:s;this.offsets.splice(r,0,t),this.colors.splice(r,0,N(e))}}class E{lineWidth=0;globalAlpha=1;imageSmoothingQuality="low";imageSmoothingEnabled=!0;fillStyle="#000000";strokeStyle="#000000";compositeOperation="source-over";filter="none";fontCss="10px sans-serif";textBaseline="alphabetic";textAlign="start";lineDash=[];lineDashOffset=0;lineJoin="miter";constructor(t){if(t instanceof E)this.lineWidth=t.lineWidth,this.globalAlpha=t.globalAlpha,this.imageSmoothingQuality=t.imageSmoothingQuality,this.imageSmoothingEnabled=t.imageSmoothingEnabled,this.fillStyle=t.fillStyle,this.strokeStyle=t.strokeStyle,this.compositeOperation=t.compositeOperation,this.filter=t.filter,this.fontCss=t.fontCss,this.textBaseline=t.textBaseline,this.textAlign=t.textAlign,this.lineDash=t.lineDash,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin}copyFrom(t){if(t instanceof E)this.lineWidth=t.lineWidth,this.globalAlpha=t.globalAlpha,this.imageSmoothingQuality=t.imageSmoothingQuality,this.imageSmoothingEnabled=t.imageSmoothingEnabled,this.fillStyle=t.fillStyle,this.strokeStyle=t.strokeStyle,this.compositeOperation=t.compositeOperation,this.filter=t.filter,this.fontCss=t.fontCss,this.textBaseline=t.textBaseline,this.textAlign=t.textAlign,this.lineDash=t.lineDash,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin}}class J{#t=new E;#e=new E;#s;#a(){this.#t=new E}#l(t,e){let s=t.colors.length,r=new BigUint64Array(s);for(let l=0;l<s;l++)r[l]=BigInt(y(t.colors[l]));let i=new Float32Array(t.offsets);return(e?n.symbols.canvas_set_stroke_style_gradient:n.symbols.canvas_set_fill_style_gradient)(a.get(this),t.type,y(t.points),s,y(r),y(i))}get canvas(){return this.#s}set font(t){this.#t.fontCss=t.trim().toLowerCase(),n.symbols.canvas_set_font(a.get(this),u.encode(`${this.#t.fontCss}\x00`))}get font(){return this.#t.fontCss}set fillStyle(t){if(t==this.#t.fillStyle)return;let e=!1;if(typeof t==="string")e=n.symbols.canvas_set_fill_style(a.get(this),N(t));else if(t instanceof D)e=this.#l(t,!1);if(e)this.#t.fillStyle=t}get fillStyle(){return this.#t.fillStyle}set strokeStyle(t){if(t==this.#t.strokeStyle)return;let e=!1;if(typeof t==="string")e=n.symbols.canvas_set_stroke_style(a.get(this),u.encode(`${t.trim()}\x00`));else if(t instanceof D)e=this.#l(t,!0);if(e)this.#t.strokeStyle=t}get strokeStyle(){return this.#t.strokeStyle}set lineWidth(t){let e=t<1?1:t;n.symbols.canvas_set_stroke_width(a.get(this),e),this.#t.lineWidth=e}get lineWidth(){return this.#t.lineWidth}set globalAlpha(t){this.#t.globalAlpha=n.symbols.canvas_set_global_alpha(a.get(this),t)}get globalAlpha(){return this.#t.globalAlpha}set imageSmoothingQuality(t){let e=!1;switch(t){case"low":{e=n.symbols.canvas_set_image_smoothing_quality(a.get(this),1);break}case"medium":{e=n.symbols.canvas_set_image_smoothing_quality(a.get(this),2);break}case"high":{e=n.symbols.canvas_set_image_smoothing_quality(a.get(this),3);break}}if(e)this.#t.imageSmoothingQuality=t}get imageSmoothingQuality(){return this.#t.imageSmoothingQuality}set imageSmoothingEnabled(t){this.#t.imageSmoothingEnabled=n.symbols.canvas_set_image_smoothing_enabled(a.get(this),t)}get imageSmoothingEnabled(){return this.#t.imageSmoothingEnabled}set filter(t){if(n.symbols.canvas_set_filter(a.get(this),u.encode(`${t}\x00`)))this.#t.filter=t}get filter(){return this.#t.filter}set globalCompositeOperation(t){if(n.symbols.canvas_set_composite_operation(a.get(this),u.encode(`${t}\x00`))==!0)this.#t.compositeOperation=t}get globalCompositeOperation(){return this.#t.compositeOperation}fillRect(t,e,s,r){n.symbols.canvas_fill_rect(a.get(this),t,e,s,r)}strokeRect(t,e,s,r){n.symbols.canvas_stroke_rect(a.get(this),t,e,s,r)}clearRect(t,e,s,r){n.symbols.canvas_clear_rect(a.get(this),t,e,s,r)}fillText(t,e,s,r=-1){n.symbols.canvas_fill_text(a.get(this),u.encode(`${t}\x00`),e,s,r)}strokeText(t,e,s,r=-1){n.symbols.canvas_stroke_text(a.get(this),u.encode(`${t}\x00`),e,s,r)}beginPath(){n.symbols.canvas_path_begin(a.get(this))}moveTo(t,e){n.symbols.canvas_path_move_to(a.get(this),t,e)}lineTo(t,e){n.symbols.canvas_path_line_to(a.get(this),t,e)}arc(t,e,s,r,i){n.symbols.canvas_path_arc(a.get(this),t,e,s,r,i)}ellipse(t,e,s,r,i,o,l,h=!1){n.symbols.canvas_path_ellipse(a.get(this),t,e,s,r,i,o,l,h)}arcTo(t,e,s,r,i){n.symbols.canvas_path_arc_to(a.get(this),t,e,s,r,i)}bezierCurveTo(t,e,s,r,i,o){n.symbols.canvas_path_bezier_to(a.get(this),t,e,s,r,i,o)}quadraticCurveTo(t,e,s,r){n.symbols.canvas_path_quad_to(a.get(this),t,e,s,r)}closePath(){n.symbols.canvas_path_close(a.get(this))}rect(t,e,s,r){n.symbols.canvas_path_rect(a.get(this),t,e,s,r)}roundRect(t,e,s,r,i){if(i.constructor.name.toLowerCase().includes("array")){let o=new Float32Array(i);if(o.some(Number.isNaN))return;let l=o.length;n.symbols.canvas_path_roundrect_array(a.get(this),t,e,s,r,y(o),l);return}else n.symbols.canvas_path_roundrect(a.get(this),t,e,s,r,i)}fill(t){n.symbols.canvas_path_fill(a.get(this),t?t.ptr:void 0)}stroke(t){n.symbols.canvas_path_stroke(a.get(this),t?t.ptr:void 0)}set shadowBlur(t){n.symbols.canvas_set_shadow_blur(a.get(this),t)}set shadowColor(t){n.symbols.canvas_set_shadow_color(a.get(this),u.encode(`${t}\x00`))}set shadowOffsetX(t){n.symbols.canvas_set_shadow_offsetX(a.get(this),t)}set shadowOffsetY(t){n.symbols.canvas_set_shadow_offsetY(a.get(this),t)}set lineJoin(t){let e=!1;switch(t){case"round":{e=n.symbols.canvas_set_line_join(a.get(this),1);break}case"bevel":{e=n.symbols.canvas_set_line_join(a.get(this),2);break}case"miter":{e=n.symbols.canvas_set_line_join(a.get(this),3);break}}if(e)this.#t.lineJoin=t}get lineJoin(){return this.#t.lineJoin}drawImage(t,...e){let s=e.length==2?[...e,t.width,t.height]:e,r=new Float32Array(s),i=r.length;if(t instanceof T){n.symbols.canvas_draw_image_imageType(a.get(this),t.ptr,y(r),i);return}if(t instanceof X){n.symbols.canvas_draw_image_canvasType(a.get(this),a.get(t),y(r),i);return}throw TypeError("Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(Image or Canvas)'.")}getImageData(t,e,s,r){let i=new Uint8Array(s*r*4);return n.symbols.canvas_get_image_data(a.get(this),t,e,s,r,y(i)),new L(s,r,i)}putImageData(t,e,s,r=0,i=0,o=t.width,l=t.height){if(!(t instanceof L))throw TypeError("Failed to execute 'putImageData' on 'CanvasRenderingContext2D': parameter 1 is not of type 'ImageData'");n.symbols.canvas_put_image_data(a.get(this),e,s,t.width,t.height,r,i,o,l,y(t.data))}save(){this.#e?.copyFrom(this.#t),n.symbols.canvas_save(a.get(this))}restore(){if(!this.#e)return;this.#t?.copyFrom(this.#e),n.symbols.canvas_restore(a.get(this))}translate(t,e){n.symbols.canvas_translate(a.get(this),t,e)}rotate(t){n.symbols.canvas_rotate(a.get(this),t)}createConicGradient(...t){if(t.length<3)throw TypeError(`Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': 3 arguments required, but only ${t.length} present.`);return new D(2,...t)}createLinearGradient(...t){if(t.length<4)throw TypeError(`Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': 4 arguments required, but only ${t.length} present.`);return new D(0,...t)}createRadialGradient(...t){if(t.length<6)throw TypeError(`Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': 6 arguments required, but only ${t.length} present.`);return new D(1,...t)}getTransform(){let t=new Float32Array(16);return n.symbols.canvas_get_transform(a.get(this),y(t)),new b(t)}setTransform(...t){if(t[0]instanceof b)n.symbols.canvas_set_transform(a.get(this),t[0].ptr);if(t.length==6){let e=new b([t[0],t[1],t[2],t[3],t[4],t[5]]);n.symbols.canvas_set_transform(a.get(this),e.ptr)}if(t.length==16)n.symbols.canvas_set_transform(a.get(this),new b([t[0],t[1],t[2],t[3],t[4],t[5],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15]]).ptr)}transform(t,e,s,r,i,o){let l=this.getTransform(),h=new b([t,e,s,r,i,o]);l.multiplySelf(h),this.setTransform(l)}resetTransform(){n.symbols.canvas_reset_transform(a.get(this))}setLineDash(t){if(t.constructor.name.toLowerCase().includes("array")){let e;if(t.length&1)e=t.concat(Array.from(t));else e=t;let s=new Float32Array(e);if(s.some(Number.isNaN))return;n.symbols.canvas_set_line_dash(a.get(this),y(s),s.length,this.#t.lineDashOffset),this.#t.lineDash=e;return}throw TypeError("Failed to execute 'setLineDash' on 'CanvasRenderingContext2D': The provided value cannot be converted to a sequence.")}getLineDash(){return this.#t.lineDash}clip(){n.symbols.canvas_path_clip(a.get(this))}set lineDashOffset(t){if(this.#t.lineDash.length<=0){this.#t.lineDashOffset=0;return}let e=new Float32Array(this.#t.lineDash);n.symbols.canvas_set_line_dash(a.get(this),y(e),e.length,t),this.#t.lineDashOffset=t}set textBaseline(t){let e=-1;switch(t){case"top":e=0;break;case"hanging":e=1;break;case"middle":e=2;break;case"alphabetic":e=3;break;case"ideographic":e=4;break;case"bottom":e=5;break}if(e!=-1)n.symbols.canvas_set_text_baseline(a.get(this),e)}set textAlign(t){let e=-1;switch(t){case"left":e=0;break;case"right":e=1;break;case"center":e=2;break;case"start":e=3;break;case"end":e=4;break}if(e!=-1)n.symbols.canvas_set_text_align(a.get(this),e)}measureText(t){let e=new Float32Array(12);return n.symbols.canvas_measure_text(a.get(this),u.encode(`${t}\x00`),y(e)),new W(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11])}constructor(t,e,s){let{desynchronized:r=!1,alpha:i=!0}=s??{},o=new Ct(this.#a.bind(this),{args:[],returns:"void"}),l=n.symbols.canvas_get_context2D(t,o.ptr,r,i);this.#s=e,a.set(this,l)}}{let t=J.prototype;for(let e of Object.getOwnPropertyNames(t)){let s=Object.getOwnPropertyDescriptor(t,e);if(e=="constructor"){s&&(s.value.toString=()=>`function ${t.constructor.name}() { [native code] }`);continue}if(typeof s?.value==="function")s.value.toString=()=>`function ${e}() { [native code] }`}}class X{#t=new Float64Array(2);#e={cb:()=>{}};constructor(t=1,e=1,s){this.#t[0]=t,this.#t[1]=e;let{gpu:r=!0}=s??{},i=n.symbols.canvas_create(t,e,r);a.set(this,i),Kt.register(this,i)}get _ptr(){return a.get(this)}set width(t){this.#t[0]=Number.parseInt(t),this.#e.cb(),n.symbols.canvas_resize(a.get(this),this.#t[0],this.#t[1])}set height(t){this.#t[1]=Number.parseInt(t),this.#e.cb(),n.symbols.canvas_resize(a.get(this),this.#t[0],this.#t[1])}get width(){return this.#t[0]}get height(){return this.#t[1]}getContext(t,e){if(t=="2d")return new J(a.get(this),this,e)}getBoundingClientRect(){return{x:0,y:0,width:this.#t[0],height:this.#t[1],top:0,bottom:this.#t[1],left:0,right:this.#t[0]}}}{let t=X.prototype;for(let e of Object.getOwnPropertyNames(t)){let s=Object.getOwnPropertyDescriptor(t,e);if(e=="constructor"){s&&(s.value.toString=()=>`function ${t.constructor.name}() { [native code] }`);continue}if(typeof s?.value==="function")s.value.toString=()=>`function ${e}() { [native code] }`}}import{ptr as Nt}from"bun:ffi";var it=new FinalizationRegistry((t)=>{n.symbols.path2d_destroy(t)}),p=new WeakMap;class Y{constructor(t){if(t&&t instanceof Y){let e=n.symbols.path2d_create_from_copy(t.ptr);p.set(this,e),it.register(this,e)}else{let e=n.symbols.path2d_create();p.set(this,e),it.register(this,e)}}moveTo(t,e){n.symbols.path2d_move_to(p.get(this),t,e)}lineTo(t,e){n.symbols.path2d_line_to(p.get(this),t,e)}arc(t,e,s,r,i){n.symbols.path2d_arc(p.get(this),t,e,s,r,i)}ellipse(t,e,s,r,i,o,l,h=!1){n.symbols.path2d_ellipse(p.get(this),t,e,s,r,i,o,l,h)}arcTo(t,e,s,r,i){n.symbols.path2d_arc_to(p.get(this),t,e,s,r,i)}bezierCurveTo(t,e,s,r,i,o){n.symbols.path2d_bezier_to(p.get(this),t,e,s,r,i,o)}quadraticCurveTo(t,e,s,r){n.symbols.path2d_quad_to(p.get(this),t,e,s,r)}rect(t,e,s,r){n.symbols.path2d_rect(p.get(this),t,e,s,r)}roundRect(t,e,s,r,i){if(i.constructor.name.toLowerCase().includes("array")){let o=new Float32Array(i);if(o.some(Number.isNaN))return;let l=o.length;n.symbols.path2d_roundrect_array(p.get(this),t,e,s,r,Nt(o),l);return}else n.symbols.path2d_rect(p.get(this),t,e,s,r,i)}closePath(){n.symbols.path2d_close(p.get(this))}get ptr(){return p.get(this)}}var Q=Y.prototype;for(let t of Object.getOwnPropertyNames(Q)){let e=Object.getOwnPropertyDescriptor(Q,t);if(t=="constructor"){e&&(e.value.toString=()=>`function ${Q.constructor.name}() { [native code] }`);continue}if(typeof e?.value==="function")e.value.toString=()=>`function ${t}() { [native code] }`}import{dlopen as $t,toArrayBuffer as M}from"bun:ffi";var ot=`import { dlopen, FFIType, JSCallback } from "bun:ffi";
|
|
3
|
+
|
|
4
|
+
const MessagePost = new JSCallback((instruction)=>{
|
|
5
|
+
self.postMessage(instruction);
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
args: ["int"],
|
|
9
|
+
returns: "void"
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
self.onmessage = (msg)=>{
|
|
14
|
+
const { w = 1, h = 1, t = "App", vsync = true, nativePath = "" } = msg.data ?? {};
|
|
15
|
+
|
|
16
|
+
const lib = dlopen(nativePath, {
|
|
17
|
+
setup_render_thread: {
|
|
18
|
+
args: ["int","int","cstring","ptr","bool"],
|
|
19
|
+
returns: "void",
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
lib.symbols.setup_render_thread(w,h,t,MessagePost.ptr,vsync);
|
|
23
|
+
self.postMessage(2)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
`;var A=[],B;n.symbols.glfw_init();if(process.platform!=="darwin")B=new Worker(URL.createObjectURL(new Blob([ot],{type:"application/javascript"})),{ref:!1});n.symbols.canvas_init_gpu_context();var Tt=!1;class Z{#t=new Map;#e=new Map;#s=new Map;#a=new Map;#l=new Map;#i=new Map;#o=new Map;#b=new Map;#d=new Int32Array(M(n.symbols.get_wPropertiesViewer(),0,16));#r=new Float64Array(M(n.symbols.get_mMoveViewer(),0,72));#h=new Float64Array(M(n.symbols.get_mClickViewer(),0,72));#c=new Float64Array(M(n.symbols.get_mDownViewer(),0,72));#m=new Float64Array(M(n.symbols.get_mUpViewer(),0,72));#u=new Int32Array(M(n.symbols.get_kDownViewer(),0,28));#f=new Int32Array(M(n.symbols.get_kUpViewer(),0,28));#p=new Float64Array(M(n.symbols.get_mWheelViewer(),0,40));#n=new WeakMap;#w=[];#y=0;#_(){if(this.#d[0]!=0){this.#d[0]=0;let t=new d("resize",this);if(this.onresize)this.onresize(t);this.#t.forEach((e,s)=>{e.cb(t)})}if(this.#r[0]!=0){this.#r[0]=0;let t=new w("move",{target:this,altKey:!1,button:0,buttons:this.#r[5],clientX:this.#r[1],clientY:this.#r[2],movementX:this.#r[3],movementY:this.#r[4],ctrlKey:!1,metaKey:!1,screenX:0,screenY:0,shiftKey:!1});if(this.onmousemove)this.onmousemove(t);this.#e.forEach((e,s)=>{e.cb(t)})}if(this.#r[0]!=0){this.#r[0]=0;let t=new w("move",{target:this,altKey:!1,button:0,buttons:this.#r[5],clientX:this.#r[1],clientY:this.#r[2],movementX:this.#r[3],movementY:this.#r[4],ctrlKey:!1,metaKey:!1,screenX:0,screenY:0,shiftKey:!1});if(this.onmousemove)this.onmousemove(t);this.#e.forEach((e,s)=>{e.cb(t)})}if(this.#c[0]!=0){this.#c[0]=0;let t=new w("down",{target:this,altKey:this.#c[7],button:this.#c[3],buttons:this.#c[4],clientX:this.#c[1],clientY:this.#c[2],movementX:0,movementY:0,ctrlKey:this.#c[6],metaKey:this.#c[8],screenX:this.#c[1],screenY:this.#c[2],shiftKey:this.#c[5]});if(this.onmousedown)this.onmousedown(t);this.#s.forEach((e,s)=>{e.cb(t)})}if(this.#m[0]!=0){this.#m[0]=0;let t=new w("up",{target:this,altKey:this.#m[7],button:this.#m[3],buttons:this.#m[4],clientX:this.#m[1],clientY:this.#m[2],movementX:0,movementY:0,ctrlKey:this.#m[6],metaKey:this.#m[8],screenX:this.#m[1],screenY:this.#m[2],shiftKey:this.#m[5]});if(this.onmouseup)this.onmouseup(t);this.#a.forEach((e,s)=>{e.cb(t)})}if(this.#h[0]!=0){this.#h[0]=0;let t=new w("click",{target:this,altKey:this.#h[7],button:this.#h[3],buttons:this.#h[4],clientX:this.#h[1],clientY:this.#h[2],movementX:0,movementY:0,ctrlKey:this.#h[6],metaKey:this.#h[8],screenX:this.#h[1],screenY:this.#h[2],shiftKey:this.#h[5]});if(this.onclick)this.onclick(t);this.#i.forEach((e,s)=>{e.cb(t)})}if(this.#p[0]!=0){this.#p[0]=0;let t=new I("wheel",{target:this,altKey:this.#r[7],button:this.#p[3],buttons:this.#p[4],clientX:this.#r[3],clientY:this.#r[4],deltaX:-this.#p[1]*120,deltaY:-this.#p[2]*120,movementX:0,movementY:0,ctrlKey:this.#r[6],metaKey:this.#r[8],screenX:this.#r[3],screenY:this.#r[4],shiftKey:this.#r[5]});if(this.onwheel)this.onwheel(t);this.#l.forEach((e,s)=>{e.cb(t)})}if(this.#u[0]!=0){this.#u[0]=0;let t=new O("down",null,this.#u[2],this,this.#u[1],this.#u[3],this.#u[4],this.#u[5],this.#u[6]);if(this.onkeydown)this.onkeydown(t);this.#o.forEach((e,s)=>{e.cb(t)})}if(this.#f[0]!=0){this.#f[0]=0;let t=new O("up",null,this.#f[2],this,this.#f[1],this.#f[3],this.#f[4],this.#f[5],this.#f[6]);if(this.onkeyup)this.onkeyup(t);this.#b.forEach((e,s)=>{e.cb(t)})}}maxFramerate=0;#g=!0;get vsync(){return this.#g}set vsync(t){this.#g=t,n.symbols.set_vsync(t)}fonts={add(t){if(!t._nativePtr)throw TypeError("Font was not loaded");n.symbols.font_add_to_registry(u.encode(`${t.family}\x00`),t._nativePtr)}};onresize=null;onmousemove=null;onmousedown=null;onmouseup=null;onclick=null;onkeydown=null;onkeyup=null;onwheel=null;get innerWidth(){return this.#d[1]}get innerHeight(){return this.#d[2]}constructor(t,e,s="App",r){if(process.platform!=="darwin")B.ref?.();Tt=!0,this.#d[1]=t,this.#d[2]=e;let{vsync:i=!0,maxFramerate:o=0}=r??{};this.#g=i,this.maxFramerate=o;let l=performance.now();if(process.platform!=="darwin"){B.onerror=(g)=>{console.error("Render thread error:",g)};let h=u.encode(`${s}\x00`);B.postMessage({w:t,h:e,t:h,vsync:this.#g,nativePath:V});let m=!1,f=performance.now();B.onmessage=(g)=>{let F=g.data;if(F===2){n.symbols.destroy_window(),n.symbols.images_cleanup(),process.exit(0);return}if(F===1)n.symbols.create_window(t,e,h);n.symbols.signal_frame_ready();let _=this.maxFramerate>0?1000/this.maxFramerate:0,x=performance.now(),S=x-f;if(_===0||this.#g||S>=_){if(_>0)f=x-S%_;if(!m)m=!0,n.symbols.canvas_flush_gpu(),setImmediate(()=>{let k=A.length;if(k>0){let G=A;A=[];for(let C=0;C<k;C++)G[C](x)}m=!1})}this.#_()}}else{let h=$t(V,{setup_render_thread:{args:["int","int","cstring","ptr","bool"],returns:"void"}}),m=u.encode(`${s}\x00`);h.symbols.setup_render_thread(t,e,m,0,i),n.symbols.create_window(t,e,m);let f=this.maxFramerate>0?1000/this.maxFramerate:0,g=performance.now(),F=()=>{if(this.#d[3]==1){n.symbols.destroy_window(),process.exit(0);return}let _=performance.now(),x=_-g;if(f===0||x>=f){if(g=f>0?_-x%f:_,this.#_(),A.length>0){let S=A;A=[];for(let k=0;k<S.length;k++)S[k](_)}n.symbols.update_window()}setImmediate(F)};F()}}addEventListener(t,e){let s=this.#w.pop(),r=s!=null?s:this.#y;if(r==this.#y)this.#y++;if(t=="resize")this.#t.set(r,{name:t,cb:e}),this.#n.set(e,r);else if(t=="mousemove")this.#e.set(r,{name:t,cb:e}),this.#n.set(e,r);else if(t=="mousedown")this.#s.set(r,{name:t,cb:e}),this.#n.set(e,r);else if(t=="mouseup")this.#a.set(r,{name:t,cb:e}),this.#n.set(e,r);else if(t=="wheel")this.#l.set(r,{name:t,cb:e}),this.#n.set(e,r);else if(t=="click")this.#i.set(r,{name:t,cb:e}),this.#n.set(e,r);else if(t=="keydown")this.#o.set(r,{name:t,cb:e}),this.#n.set(e,r);else if(t=="keyup")this.#b.set(r,{name:t,cb:e}),this.#n.set(e,r)}removeEventListener(t,e){let s=this.#n.get(e);if(t=="resize"){if(s!=null)this.#t.delete(s),this.#n.delete(e)}else if(t=="mousemove"){if(s!=null)this.#e.delete(s),this.#n.delete(e)}else if(t=="mousedown"){if(s!=null)this.#s.delete(s),this.#n.delete(e)}else if(t=="mouseup"){if(s!=null)this.#a.delete(s),this.#n.delete(e)}else if(t=="wheel"){if(s!=null)this.#l.delete(s),this.#n.delete(e)}else if(t=="click"){if(s!=null)this.#i.delete(s),this.#n.delete(e)}else if(t=="keydown"){if(s!=null)this.#o.delete(s),this.#n.delete(e)}else if(t=="keyup"){if(s!=null)this.#b.delete(s),this.#n.delete(e)}}append(t){let e=t._ptr;if(e==null){console.error("Canvas was not found");return}n.symbols.canvas_append(e)}}{let t=Z.prototype;for(let e of Object.getOwnPropertyNames(t)){let s=Object.getOwnPropertyDescriptor(t,e);if(e=="constructor"){s&&(s.value.toString=()=>`function ${t.constructor.name}() { [native code] }`);continue}if(typeof s?.value==="function")s.value.toString=()=>`function ${e}() { [native code] }`}}var R;if(globalThis.requestAnimationFrame)R=globalThis.requestAnimationFrame;else R=function(e){setImmediate(()=>{A.push(e)})},R.toString=()=>"function requestAnimationFrame() { [native code] }";var Ot=R;var q=new WeakMap;n.symbols.audio_backend_init();class at{constructor(t){if(t)q.set(this,n.symbols.audio_create(u.encode(`${t}\x00`)));else q.set(this,n.symbols.audio_create())}set src(t){n.symbols.audio_set_src(N(t))}play(){n.symbols.audio_play(q.get(this))}stop(){n.symbols.audio_stop(q.get(this))}}export{at as Audio,X as Canvas,b as DOMMatrix,d as Event,j as FontFace,T as Image,O as KeyboardEvent,w as MouseEvent,Y as Path2D,W as TextMetrics,I as WheelEvent,Z as Window,Ot as requestAnimationFrame};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isValidColor(str: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getNativePath(): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ptrs: WeakMap<WeakKey, any>;
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
export declare const dlPath: any;
|
|
2
|
+
export declare const encoder: TextEncoder;
|
|
3
|
+
export declare function encodeCString(str: any): any;
|
|
4
|
+
export declare const lib: import("bun:ffi").Library<{
|
|
5
|
+
glfw_init: {
|
|
6
|
+
args: never[];
|
|
7
|
+
returns: "void";
|
|
8
|
+
};
|
|
9
|
+
get_wPropertiesViewer: {
|
|
10
|
+
args: never[];
|
|
11
|
+
returns: "ptr";
|
|
12
|
+
};
|
|
13
|
+
get_mMoveViewer: {
|
|
14
|
+
args: never[];
|
|
15
|
+
returns: "ptr";
|
|
16
|
+
};
|
|
17
|
+
get_mClickViewer: {
|
|
18
|
+
args: never[];
|
|
19
|
+
returns: "ptr";
|
|
20
|
+
};
|
|
21
|
+
get_mDownViewer: {
|
|
22
|
+
args: never[];
|
|
23
|
+
returns: "ptr";
|
|
24
|
+
};
|
|
25
|
+
get_mUpViewer: {
|
|
26
|
+
args: never[];
|
|
27
|
+
returns: "ptr";
|
|
28
|
+
};
|
|
29
|
+
get_kDownViewer: {
|
|
30
|
+
args: never[];
|
|
31
|
+
returns: "ptr";
|
|
32
|
+
};
|
|
33
|
+
get_kUpViewer: {
|
|
34
|
+
args: never[];
|
|
35
|
+
returns: "ptr";
|
|
36
|
+
};
|
|
37
|
+
get_mWheelViewer: {
|
|
38
|
+
args: never[];
|
|
39
|
+
returns: "ptr";
|
|
40
|
+
};
|
|
41
|
+
signal_frame_ready: {
|
|
42
|
+
args: never[];
|
|
43
|
+
returns: "void";
|
|
44
|
+
};
|
|
45
|
+
set_vsync: {
|
|
46
|
+
args: "bool"[];
|
|
47
|
+
returns: "void";
|
|
48
|
+
};
|
|
49
|
+
create_window: {
|
|
50
|
+
args: ("cstring" | "int")[];
|
|
51
|
+
returns: "void";
|
|
52
|
+
};
|
|
53
|
+
update_window: {
|
|
54
|
+
args: "ptr"[];
|
|
55
|
+
returns: "void";
|
|
56
|
+
};
|
|
57
|
+
destroy_window: {
|
|
58
|
+
args: never[];
|
|
59
|
+
returns: "void";
|
|
60
|
+
};
|
|
61
|
+
canvas_init_gpu_context: {
|
|
62
|
+
args: never[];
|
|
63
|
+
returns: "bool";
|
|
64
|
+
};
|
|
65
|
+
canvas_flush_gpu: {
|
|
66
|
+
args: never[];
|
|
67
|
+
returns: "void";
|
|
68
|
+
};
|
|
69
|
+
canvas_create: {
|
|
70
|
+
args: ("bool" | "int")[];
|
|
71
|
+
returns: "ptr";
|
|
72
|
+
};
|
|
73
|
+
canvas_resize: {
|
|
74
|
+
args: ("int" | "ptr")[];
|
|
75
|
+
returns: "void";
|
|
76
|
+
};
|
|
77
|
+
canvas_append: {
|
|
78
|
+
args: "ptr"[];
|
|
79
|
+
returns: "void";
|
|
80
|
+
};
|
|
81
|
+
canvas_get_context2D: {
|
|
82
|
+
args: ("bool" | "ptr")[];
|
|
83
|
+
returns: "ptr";
|
|
84
|
+
};
|
|
85
|
+
canvas_set_fill_style: {
|
|
86
|
+
args: ("cstring" | "ptr")[];
|
|
87
|
+
returns: "bool";
|
|
88
|
+
};
|
|
89
|
+
canvas_set_fill_style_gradient: {
|
|
90
|
+
args: ("int" | "ptr")[];
|
|
91
|
+
returns: "bool";
|
|
92
|
+
};
|
|
93
|
+
canvas_set_stroke_style: {
|
|
94
|
+
args: ("cstring" | "ptr")[];
|
|
95
|
+
returns: "bool";
|
|
96
|
+
};
|
|
97
|
+
canvas_set_stroke_style_gradient: {
|
|
98
|
+
args: ("int" | "ptr")[];
|
|
99
|
+
returns: "bool";
|
|
100
|
+
};
|
|
101
|
+
canvas_set_stroke_width: {
|
|
102
|
+
args: ("float" | "ptr")[];
|
|
103
|
+
returns: "bool";
|
|
104
|
+
};
|
|
105
|
+
canvas_fill_rect: {
|
|
106
|
+
args: ("int" | "ptr")[];
|
|
107
|
+
returns: "void";
|
|
108
|
+
};
|
|
109
|
+
canvas_stroke_rect: {
|
|
110
|
+
args: ("int" | "ptr")[];
|
|
111
|
+
returns: "void";
|
|
112
|
+
};
|
|
113
|
+
canvas_clear_rect: {
|
|
114
|
+
args: ("int" | "ptr")[];
|
|
115
|
+
returns: "void";
|
|
116
|
+
};
|
|
117
|
+
canvas_path_begin: {
|
|
118
|
+
args: "ptr"[];
|
|
119
|
+
returns: "void";
|
|
120
|
+
};
|
|
121
|
+
canvas_path_move_to: {
|
|
122
|
+
args: ("int" | "ptr")[];
|
|
123
|
+
returns: "void";
|
|
124
|
+
};
|
|
125
|
+
canvas_path_line_to: {
|
|
126
|
+
args: ("int" | "ptr")[];
|
|
127
|
+
returns: "void";
|
|
128
|
+
};
|
|
129
|
+
canvas_path_arc: {
|
|
130
|
+
args: ("float" | "ptr")[];
|
|
131
|
+
returns: "void";
|
|
132
|
+
};
|
|
133
|
+
canvas_path_arc_to: {
|
|
134
|
+
args: ("float" | "ptr")[];
|
|
135
|
+
returns: "void";
|
|
136
|
+
};
|
|
137
|
+
canvas_path_bezier_to: {
|
|
138
|
+
args: ("float" | "ptr")[];
|
|
139
|
+
returns: "void";
|
|
140
|
+
};
|
|
141
|
+
canvas_path_quad_to: {
|
|
142
|
+
args: ("float" | "ptr")[];
|
|
143
|
+
returns: "void";
|
|
144
|
+
};
|
|
145
|
+
canvas_path_ellipse: {
|
|
146
|
+
args: ("bool" | "float" | "ptr")[];
|
|
147
|
+
returns: "void";
|
|
148
|
+
};
|
|
149
|
+
canvas_path_fill: {
|
|
150
|
+
args: "ptr"[];
|
|
151
|
+
returns: "void";
|
|
152
|
+
};
|
|
153
|
+
canvas_path_stroke: {
|
|
154
|
+
args: "ptr"[];
|
|
155
|
+
returns: "void";
|
|
156
|
+
};
|
|
157
|
+
canvas_path_close: {
|
|
158
|
+
args: "ptr"[];
|
|
159
|
+
returns: "void";
|
|
160
|
+
};
|
|
161
|
+
canvas_path_rect: {
|
|
162
|
+
args: ("float" | "ptr")[];
|
|
163
|
+
returns: "void";
|
|
164
|
+
};
|
|
165
|
+
canvas_path_roundrect: {
|
|
166
|
+
args: ("float" | "ptr")[];
|
|
167
|
+
returns: "void";
|
|
168
|
+
};
|
|
169
|
+
canvas_path_roundrect_array: {
|
|
170
|
+
args: ("float" | "int" | "ptr")[];
|
|
171
|
+
returns: "void";
|
|
172
|
+
};
|
|
173
|
+
canvas_set_composite_operation: {
|
|
174
|
+
args: ("cstring" | "ptr")[];
|
|
175
|
+
returns: "bool";
|
|
176
|
+
};
|
|
177
|
+
canvas_draw_image_imageType: {
|
|
178
|
+
args: ("int" | "ptr")[];
|
|
179
|
+
returns: "void";
|
|
180
|
+
};
|
|
181
|
+
canvas_draw_image_canvasType: {
|
|
182
|
+
args: ("int" | "ptr")[];
|
|
183
|
+
returns: "void";
|
|
184
|
+
};
|
|
185
|
+
canvas_get_image_data: {
|
|
186
|
+
args: ("int" | "ptr")[];
|
|
187
|
+
returns: "bool";
|
|
188
|
+
};
|
|
189
|
+
canvas_put_image_data: {
|
|
190
|
+
args: ("int" | "ptr")[];
|
|
191
|
+
returns: "bool";
|
|
192
|
+
};
|
|
193
|
+
canvas_set_global_alpha: {
|
|
194
|
+
args: ("float" | "ptr")[];
|
|
195
|
+
returns: "float";
|
|
196
|
+
};
|
|
197
|
+
canvas_save: {
|
|
198
|
+
args: "ptr"[];
|
|
199
|
+
returns: "float";
|
|
200
|
+
};
|
|
201
|
+
canvas_restore: {
|
|
202
|
+
args: "ptr"[];
|
|
203
|
+
returns: "float";
|
|
204
|
+
};
|
|
205
|
+
canvas_translate: {
|
|
206
|
+
args: ("float" | "ptr")[];
|
|
207
|
+
returns: "void";
|
|
208
|
+
};
|
|
209
|
+
canvas_rotate: {
|
|
210
|
+
args: ("float" | "ptr")[];
|
|
211
|
+
returns: "float";
|
|
212
|
+
};
|
|
213
|
+
canvas_set_font: {
|
|
214
|
+
args: ("cstring" | "ptr")[];
|
|
215
|
+
returns: "bool";
|
|
216
|
+
};
|
|
217
|
+
canvas_fill_text: {
|
|
218
|
+
args: ("cstring" | "float" | "ptr")[];
|
|
219
|
+
returns: "void";
|
|
220
|
+
};
|
|
221
|
+
canvas_stroke_text: {
|
|
222
|
+
args: ("cstring" | "float" | "ptr")[];
|
|
223
|
+
returns: "void";
|
|
224
|
+
};
|
|
225
|
+
canvas_set_shadow_blur: {
|
|
226
|
+
args: ("float" | "ptr")[];
|
|
227
|
+
returns: "void";
|
|
228
|
+
};
|
|
229
|
+
canvas_set_shadow_color: {
|
|
230
|
+
args: ("cstring" | "ptr")[];
|
|
231
|
+
returns: "void";
|
|
232
|
+
};
|
|
233
|
+
canvas_set_shadow_offsetX: {
|
|
234
|
+
args: ("float" | "ptr")[];
|
|
235
|
+
returns: "void";
|
|
236
|
+
};
|
|
237
|
+
canvas_set_shadow_offsetY: {
|
|
238
|
+
args: ("float" | "ptr")[];
|
|
239
|
+
returns: "void";
|
|
240
|
+
};
|
|
241
|
+
canvas_set_image_smoothing_quality: {
|
|
242
|
+
args: ("int" | "ptr")[];
|
|
243
|
+
returns: "bool";
|
|
244
|
+
};
|
|
245
|
+
canvas_set_image_smoothing_enabled: {
|
|
246
|
+
args: ("bool" | "ptr")[];
|
|
247
|
+
returns: "bool";
|
|
248
|
+
};
|
|
249
|
+
canvas_get_transform: {
|
|
250
|
+
args: "ptr"[];
|
|
251
|
+
returns: "void";
|
|
252
|
+
};
|
|
253
|
+
canvas_set_transform: {
|
|
254
|
+
args: "ptr"[];
|
|
255
|
+
returns: "void";
|
|
256
|
+
};
|
|
257
|
+
canvas_reset_transform: {
|
|
258
|
+
args: "ptr"[];
|
|
259
|
+
returns: "void";
|
|
260
|
+
};
|
|
261
|
+
canvas_set_filter: {
|
|
262
|
+
args: ("cstring" | "ptr")[];
|
|
263
|
+
returns: "bool";
|
|
264
|
+
};
|
|
265
|
+
canvas_set_line_dash: {
|
|
266
|
+
args: ("float" | "int" | "ptr")[];
|
|
267
|
+
returns: "bool";
|
|
268
|
+
};
|
|
269
|
+
canvas_set_line_join: {
|
|
270
|
+
args: ("int" | "ptr")[];
|
|
271
|
+
returns: "bool";
|
|
272
|
+
};
|
|
273
|
+
canvas_path_clip: {
|
|
274
|
+
args: "ptr"[];
|
|
275
|
+
returns: "void";
|
|
276
|
+
};
|
|
277
|
+
canvas_set_text_baseline: {
|
|
278
|
+
args: ("int" | "ptr")[];
|
|
279
|
+
returns: "void";
|
|
280
|
+
};
|
|
281
|
+
canvas_set_text_align: {
|
|
282
|
+
args: ("int" | "ptr")[];
|
|
283
|
+
returns: "void";
|
|
284
|
+
};
|
|
285
|
+
canvas_measure_text: {
|
|
286
|
+
args: ("cstring" | "ptr")[];
|
|
287
|
+
returns: "void";
|
|
288
|
+
};
|
|
289
|
+
canvas_destroy: {
|
|
290
|
+
args: "ptr"[];
|
|
291
|
+
returns: "void";
|
|
292
|
+
};
|
|
293
|
+
image_create: {
|
|
294
|
+
args: never[];
|
|
295
|
+
returns: "ptr";
|
|
296
|
+
};
|
|
297
|
+
images_cleanup: {
|
|
298
|
+
args: never[];
|
|
299
|
+
returns: "void";
|
|
300
|
+
};
|
|
301
|
+
image_set_src: {
|
|
302
|
+
args: ("bool" | "cstring" | "ptr")[];
|
|
303
|
+
returns: "void";
|
|
304
|
+
};
|
|
305
|
+
image_load: {
|
|
306
|
+
args: "ptr"[];
|
|
307
|
+
returns: "bool";
|
|
308
|
+
};
|
|
309
|
+
image_destroy: {
|
|
310
|
+
args: "ptr"[];
|
|
311
|
+
returns: "void";
|
|
312
|
+
};
|
|
313
|
+
font_load: {
|
|
314
|
+
args: "cstring"[];
|
|
315
|
+
returns: "ptr";
|
|
316
|
+
};
|
|
317
|
+
audio_backend_init: {
|
|
318
|
+
args: never[];
|
|
319
|
+
returns: "void";
|
|
320
|
+
};
|
|
321
|
+
audio_create: {
|
|
322
|
+
args: "cstring"[];
|
|
323
|
+
returns: "ptr";
|
|
324
|
+
};
|
|
325
|
+
audio_set_src: {
|
|
326
|
+
args: ("cstring" | "ptr")[];
|
|
327
|
+
returns: "void";
|
|
328
|
+
};
|
|
329
|
+
audio_play: {
|
|
330
|
+
args: "ptr"[];
|
|
331
|
+
returns: "void";
|
|
332
|
+
};
|
|
333
|
+
audio_stop: {
|
|
334
|
+
args: "ptr"[];
|
|
335
|
+
returns: "void";
|
|
336
|
+
};
|
|
337
|
+
audio_destroy: {
|
|
338
|
+
args: "ptr"[];
|
|
339
|
+
returns: "void";
|
|
340
|
+
};
|
|
341
|
+
path2d_create: {
|
|
342
|
+
args: never[];
|
|
343
|
+
returns: "ptr";
|
|
344
|
+
};
|
|
345
|
+
path2d_create_from_copy: {
|
|
346
|
+
args: "ptr"[];
|
|
347
|
+
returns: "ptr";
|
|
348
|
+
};
|
|
349
|
+
path2d_destroy: {
|
|
350
|
+
args: "ptr"[];
|
|
351
|
+
returns: "void";
|
|
352
|
+
};
|
|
353
|
+
path2d_move_to: {
|
|
354
|
+
args: ("int" | "ptr")[];
|
|
355
|
+
returns: "void";
|
|
356
|
+
};
|
|
357
|
+
path2d_line_to: {
|
|
358
|
+
args: ("int" | "ptr")[];
|
|
359
|
+
returns: "void";
|
|
360
|
+
};
|
|
361
|
+
path2d_arc: {
|
|
362
|
+
args: ("float" | "ptr")[];
|
|
363
|
+
returns: "void";
|
|
364
|
+
};
|
|
365
|
+
path2d_arc_to: {
|
|
366
|
+
args: ("float" | "ptr")[];
|
|
367
|
+
returns: "void";
|
|
368
|
+
};
|
|
369
|
+
path2d_bezier_to: {
|
|
370
|
+
args: ("float" | "ptr")[];
|
|
371
|
+
returns: "void";
|
|
372
|
+
};
|
|
373
|
+
path2d_quad_to: {
|
|
374
|
+
args: ("float" | "ptr")[];
|
|
375
|
+
returns: "void";
|
|
376
|
+
};
|
|
377
|
+
path2d_ellipse: {
|
|
378
|
+
args: ("bool" | "float" | "ptr")[];
|
|
379
|
+
returns: "void";
|
|
380
|
+
};
|
|
381
|
+
path2d_close: {
|
|
382
|
+
args: "ptr"[];
|
|
383
|
+
returns: "void";
|
|
384
|
+
};
|
|
385
|
+
path2d_rect: {
|
|
386
|
+
args: ("float" | "ptr")[];
|
|
387
|
+
returns: "void";
|
|
388
|
+
};
|
|
389
|
+
path2d_roundrect: {
|
|
390
|
+
args: ("float" | "ptr")[];
|
|
391
|
+
returns: "void";
|
|
392
|
+
};
|
|
393
|
+
path2d_roundrect_array: {
|
|
394
|
+
args: ("float" | "int" | "ptr")[];
|
|
395
|
+
returns: "void";
|
|
396
|
+
};
|
|
397
|
+
font_add_to_registry: {
|
|
398
|
+
args: ("cstring" | "ptr")[];
|
|
399
|
+
returns: "void";
|
|
400
|
+
};
|
|
401
|
+
}>;
|
package/jsconfig.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Environment setup & latest features
|
|
4
|
+
"lib": ["ESNext"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "Preserve",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"types": ["bun"],
|
|
11
|
+
|
|
12
|
+
// Bundler mode
|
|
13
|
+
"moduleResolution": "bundler",
|
|
14
|
+
"allowImportingTsExtensions": true,
|
|
15
|
+
"verbatimModuleSyntax": true,
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
|
|
18
|
+
// Best practices
|
|
19
|
+
"strict": true,
|
|
20
|
+
"skipLibCheck": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
"noUncheckedIndexedAccess": true,
|
|
23
|
+
"noImplicitOverride": true,
|
|
24
|
+
|
|
25
|
+
// Some stricter flags (disabled by default)
|
|
26
|
+
"noUnusedLocals": false,
|
|
27
|
+
"noUnusedParameters": false,
|
|
28
|
+
"noPropertyAccessFromIndexSignature": false
|
|
29
|
+
}
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buncanvas/core",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"module": "index.js",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "0.1.2",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@types/bun": "latest"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"typescript": "^7"
|
|
14
|
+
},
|
|
15
|
+
"optionalDependencies": {
|
|
16
|
+
"@buncanvas/native-linux-x64": "0.1.2",
|
|
17
|
+
"@buncanvas/native-win32-x64": "0.1.2",
|
|
18
|
+
"@buncanvas/native-darwin-arm64": "0.1.2"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/Audio.d.ts
ADDED
package/src/Canvas.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Pointer } from "bun:ffi";
|
|
2
|
+
import { Image } from "./Image.js";
|
|
3
|
+
import { ImageData } from "./ImageData.js";
|
|
4
|
+
import { DOMMatrix } from "../dom/DOMMatrix.js";
|
|
5
|
+
import { TextMetrics } from "./TextMetrics.js";
|
|
6
|
+
import { Path2D } from "./Path2D.js";
|
|
7
|
+
declare enum GradientType {
|
|
8
|
+
Linear = 0,
|
|
9
|
+
Radial = 1,
|
|
10
|
+
Conic = 2
|
|
11
|
+
}
|
|
12
|
+
declare class CanvasGradient {
|
|
13
|
+
type: GradientType;
|
|
14
|
+
points: Float32Array<ArrayBuffer>;
|
|
15
|
+
offsets: number[];
|
|
16
|
+
colors: Uint8Array[];
|
|
17
|
+
constructor(type: GradientType, a: number, x1: number, y1: number);
|
|
18
|
+
constructor(type: GradientType, x1: number, y1: number, x2: number, y2: number);
|
|
19
|
+
constructor(type: GradientType, x1: number, y1: number, x2: number, y2: number, r0: number, r1: number);
|
|
20
|
+
addColorStop(offset: number, color: string): void;
|
|
21
|
+
}
|
|
22
|
+
declare class CanvasRenderingContext2D {
|
|
23
|
+
#private;
|
|
24
|
+
get canvas(): Canvas;
|
|
25
|
+
set font(css: string);
|
|
26
|
+
get font(): string;
|
|
27
|
+
set fillStyle(style: string | CanvasGradient);
|
|
28
|
+
get fillStyle(): string | CanvasGradient;
|
|
29
|
+
set strokeStyle(style: string | CanvasGradient);
|
|
30
|
+
get strokeStyle(): string | CanvasGradient;
|
|
31
|
+
set lineWidth(width: number);
|
|
32
|
+
get lineWidth(): number;
|
|
33
|
+
set globalAlpha(a: number);
|
|
34
|
+
get globalAlpha(): number;
|
|
35
|
+
set imageSmoothingQuality(v: string);
|
|
36
|
+
get imageSmoothingQuality(): string;
|
|
37
|
+
set imageSmoothingEnabled(v: boolean);
|
|
38
|
+
get imageSmoothingEnabled(): boolean;
|
|
39
|
+
set filter(v: string);
|
|
40
|
+
get filter(): string;
|
|
41
|
+
set globalCompositeOperation(operation: string);
|
|
42
|
+
get globalCompositeOperation(): string;
|
|
43
|
+
fillRect(x: number, y: number, w: number, h: number): void;
|
|
44
|
+
strokeRect(x: number, y: number, w: number, h: number): void;
|
|
45
|
+
clearRect(x: number, y: number, w: number, h: number): void;
|
|
46
|
+
fillText(text: string, x: number, y: number, maxWidth?: number): void;
|
|
47
|
+
strokeText(text: string, x: number, y: number, maxWidth?: number): void;
|
|
48
|
+
beginPath(): void;
|
|
49
|
+
moveTo(x: number, y: number): void;
|
|
50
|
+
lineTo(x: number, y: number): void;
|
|
51
|
+
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number): void;
|
|
52
|
+
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
|
|
53
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
|
|
54
|
+
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
|
|
55
|
+
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
|
|
56
|
+
closePath(): void;
|
|
57
|
+
rect(x: number, y: number, width: number, height: number): void;
|
|
58
|
+
roundRect(x: number, y: number, width: number, height: number, radii: any): void;
|
|
59
|
+
fill(path?: Path2D): void;
|
|
60
|
+
stroke(path?: Path2D): void;
|
|
61
|
+
set shadowBlur(blur: number);
|
|
62
|
+
set shadowColor(col: string);
|
|
63
|
+
set shadowOffsetX(x: number);
|
|
64
|
+
set shadowOffsetY(y: number);
|
|
65
|
+
set lineJoin(joinType: string);
|
|
66
|
+
get lineJoin(): string;
|
|
67
|
+
drawImage(img: Image | Canvas, x: number, y: number, w: number, h: number): void;
|
|
68
|
+
drawImage(img: Image | Canvas, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void;
|
|
69
|
+
getImageData(x: number, y: number, w: number, h: number): ImageData;
|
|
70
|
+
putImageData(data: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void;
|
|
71
|
+
save(): void;
|
|
72
|
+
restore(): void;
|
|
73
|
+
translate(x: number, y: number): void;
|
|
74
|
+
rotate(deg: number): void;
|
|
75
|
+
createConicGradient(a: number, x1: number, y1: number): CanvasGradient;
|
|
76
|
+
createLinearGradient(x1: number, y1: number, x2: number, y2: number): CanvasGradient;
|
|
77
|
+
createRadialGradient(x1: number, y1: number, x2: number, y2: number, r0: number, r1: number): CanvasGradient;
|
|
78
|
+
getTransform(): DOMMatrix;
|
|
79
|
+
setTransform(matrix: DOMMatrix): void;
|
|
80
|
+
setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
81
|
+
transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
82
|
+
resetTransform(): void;
|
|
83
|
+
setLineDash(lines: number[]): void;
|
|
84
|
+
getLineDash(): number[];
|
|
85
|
+
clip(): void;
|
|
86
|
+
set lineDashOffset(v: number);
|
|
87
|
+
set textBaseline(baseline: string);
|
|
88
|
+
set textAlign(alignment: string);
|
|
89
|
+
measureText(text: string): TextMetrics;
|
|
90
|
+
constructor(iptr: Pointer | null, cnv: Canvas, args: any);
|
|
91
|
+
}
|
|
92
|
+
export declare class Canvas {
|
|
93
|
+
#private;
|
|
94
|
+
constructor(w?: number, h?: number, options?: {
|
|
95
|
+
gpu: boolean;
|
|
96
|
+
});
|
|
97
|
+
get _ptr(): any;
|
|
98
|
+
set width(v: string);
|
|
99
|
+
set height(v: string);
|
|
100
|
+
get width(): number;
|
|
101
|
+
get height(): number;
|
|
102
|
+
getContext(contextType: string, args: any): CanvasRenderingContext2D | undefined;
|
|
103
|
+
getBoundingClientRect(): {
|
|
104
|
+
x: number;
|
|
105
|
+
y: number;
|
|
106
|
+
width: number;
|
|
107
|
+
height: number;
|
|
108
|
+
top: number;
|
|
109
|
+
bottom: number;
|
|
110
|
+
left: number;
|
|
111
|
+
right: number;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export {};
|
package/src/Event.d.ts
ADDED
package/src/Image.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Event } from "./Event.js";
|
|
2
|
+
export declare class Image {
|
|
3
|
+
#private;
|
|
4
|
+
constructor();
|
|
5
|
+
onload: ((this: Image, evt: Event) => any) | null;
|
|
6
|
+
onerror: ((this: Image, evt: Event) => any) | null;
|
|
7
|
+
set src(path: string);
|
|
8
|
+
get src(): string;
|
|
9
|
+
get ptr(): any;
|
|
10
|
+
get width(): number;
|
|
11
|
+
get height(): number;
|
|
12
|
+
set width(v: number);
|
|
13
|
+
set height(v: number);
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Event } from "./Event";
|
|
2
|
+
export declare class KeyboardEvent extends Event {
|
|
3
|
+
target: null;
|
|
4
|
+
key: string;
|
|
5
|
+
code: string;
|
|
6
|
+
location: number;
|
|
7
|
+
repeat: boolean;
|
|
8
|
+
ctrlKey: boolean;
|
|
9
|
+
shiftKey: boolean;
|
|
10
|
+
altKey: boolean;
|
|
11
|
+
metaKey: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} type
|
|
14
|
+
* @param {any} args
|
|
15
|
+
* @param {any} kcode
|
|
16
|
+
* @param {any} target
|
|
17
|
+
* @param {any} repeat
|
|
18
|
+
* @param {any} shiftKey
|
|
19
|
+
* @param {any} ctrlKey
|
|
20
|
+
* @param {any} altKey
|
|
21
|
+
* @param {any} metaKey
|
|
22
|
+
*/
|
|
23
|
+
constructor(type: string, args?: any, kcode?: any, target?: any, repeat?: any, shiftKey?: any, ctrlKey?: any, altKey?: any, metaKey?: any);
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Event } from "./Event";
|
|
2
|
+
export declare class MouseEvent extends Event {
|
|
3
|
+
altKey: boolean;
|
|
4
|
+
button: number;
|
|
5
|
+
buttons: number;
|
|
6
|
+
clientX: number;
|
|
7
|
+
clientY: number;
|
|
8
|
+
movementX: number;
|
|
9
|
+
movementY: number;
|
|
10
|
+
ctrlKey: boolean;
|
|
11
|
+
metaKey: boolean;
|
|
12
|
+
screenX: number;
|
|
13
|
+
screenY: number;
|
|
14
|
+
shiftKey: boolean;
|
|
15
|
+
constructor(type: string, args?: any);
|
|
16
|
+
}
|
package/src/Path2D.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class Path2D {
|
|
2
|
+
constructor(path: Path2D);
|
|
3
|
+
moveTo(x: number, y: number): void;
|
|
4
|
+
lineTo(x: number, y: number): void;
|
|
5
|
+
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number): void;
|
|
6
|
+
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
|
|
7
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
|
|
8
|
+
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
|
|
9
|
+
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
|
|
10
|
+
rect(x: number, y: number, width: number, height: number): void;
|
|
11
|
+
roundRect(x: number, y: number, width: number, height: number, radii: any): void;
|
|
12
|
+
closePath(): void;
|
|
13
|
+
get ptr(): any;
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class TextMetrics {
|
|
2
|
+
readonly width: number;
|
|
3
|
+
readonly actualBoundingBoxLeft: number;
|
|
4
|
+
readonly actualBoundingBoxRight: number;
|
|
5
|
+
readonly actualBoundingBoxAscent: number;
|
|
6
|
+
readonly actualBoundingBoxDescent: number;
|
|
7
|
+
readonly fontBoundingBoxAscent: number;
|
|
8
|
+
readonly fontBoundingBoxDescent: number;
|
|
9
|
+
readonly emHeightAscent: number;
|
|
10
|
+
readonly emHeightDescent: number;
|
|
11
|
+
readonly alphabeticBaseline: number;
|
|
12
|
+
readonly hangingBaseline: number;
|
|
13
|
+
readonly ideographicBaseline: number;
|
|
14
|
+
constructor(width: number, actualBoundingBoxLeft: number, actualBoundingBoxRight: number, actualBoundingBoxAscent: number, actualBoundingBoxDescent: number, fontBoundingBoxAscent: number, fontBoundingBoxDescent: number, emHeightAscent: number, emHeightDescent: number, alphabeticBaseline: number, hangingBaseline: number, ideographicBaseline: number);
|
|
15
|
+
}
|
package/src/Window.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Event } from "./Event.js";
|
|
2
|
+
import { MouseEvent } from "./MouseEvent.js";
|
|
3
|
+
import { KeyboardEvent } from "./KeyboardEvent.js";
|
|
4
|
+
import { FontFace } from "./FontFace.js";
|
|
5
|
+
import { Canvas } from "./Canvas.js";
|
|
6
|
+
export declare class Window {
|
|
7
|
+
#private;
|
|
8
|
+
maxFramerate: number;
|
|
9
|
+
get vsync(): boolean;
|
|
10
|
+
set vsync(v: boolean);
|
|
11
|
+
fonts: {
|
|
12
|
+
add(font: FontFace): void;
|
|
13
|
+
};
|
|
14
|
+
onresize: ((this: Window, evt: Event) => any) | null;
|
|
15
|
+
onmousemove: ((evt: MouseEvent) => any) | null;
|
|
16
|
+
onmousedown: ((evt: MouseEvent) => any) | null;
|
|
17
|
+
onmouseup: ((evt: MouseEvent) => any) | null;
|
|
18
|
+
onclick: ((evt: MouseEvent) => any) | null;
|
|
19
|
+
onkeydown: ((evt: KeyboardEvent) => any) | null;
|
|
20
|
+
onkeyup: ((evt: KeyboardEvent) => any) | null;
|
|
21
|
+
onwheel: ((evt: MouseEvent) => any) | null;
|
|
22
|
+
get innerWidth(): number;
|
|
23
|
+
get innerHeight(): number;
|
|
24
|
+
constructor(width: number, height: number, title: string | undefined, args: {
|
|
25
|
+
vsync: boolean;
|
|
26
|
+
maxFramerate: number;
|
|
27
|
+
});
|
|
28
|
+
addEventListener(name: string, fn: ((event: any) => void)): void;
|
|
29
|
+
removeEventListener(name: string, fn: ((event: any) => void)): void;
|
|
30
|
+
append(canvas: Canvas): void;
|
|
31
|
+
}
|
|
32
|
+
export declare const requestAnimationFrame: (callback: (cb: any) => void) => void;
|