Skip to content

Commit

Permalink
upgrade to latest deno_bindgen (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
littledivy authored Oct 19, 2021
1 parent 1f7ab80 commit 53cb015
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 169 deletions.
14 changes: 12 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ path = "./src/lib.rs"
crate-type = ["cdylib"]

[dependencies]
deno_bindgen = "0.1.1"
deno_bindgen = { git = "https://github.com/littledivy/deno_bindgen", rev = "3ca55e7" }
autopilot = { path = "./autopilot-rs/" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
234 changes: 170 additions & 64 deletions bindings/bindings.ts
Original file line number Diff line number Diff line change
@@ -1,103 +1,209 @@
// Auto-generated with deno_bindgen
import { Plug } from "https://deno.land/x/[email protected]/mod.ts";
const encode = (s: string) => new TextEncoder().encode(s);
function encode(v: string | Uint8Array): Uint8Array {
if (typeof v !== "string") return v;
return new TextEncoder().encode(v);
}
const opts = {
name: "autopilot_deno",
url: "https://github.com/littledivy/autopilot-deno/releases/download/0.4.0",
url: "target/debug",
};
const _lib = await Plug.prepare(opts, {
mouse_pixel_color_g: { parameters: [], result: "u8" },
smooth_mouse_move: { parameters: ["buffer", "usize"], result: "void" },
mouse_pixel_color_b: { parameters: [], result: "u8" },
toggle_key: { parameters: ["buffer", "usize"], result: "void" },
screenscale: { parameters: [], result: "f64" },
mouse_pixel_color_r: { parameters: [], result: "u8" },
mouse_move: { parameters: ["buffer", "usize"], result: "void" },
mouse_scroll: { parameters: [], result: "void" },
notify: { parameters: ["buffer", "usize"], result: "void" },
type_: { parameters: ["buffer", "usize"], result: "void" },
screensize_width: { parameters: [], result: "f64" },
screenshot: { parameters: ["buffer", "usize"], result: "void" },
alert: { parameters: ["buffer", "usize"], result: "void" },
mouse_click: { parameters: ["buffer", "usize"], result: "void" },
screensize_height: { parameters: [], result: "f64" },
mouse_pos_x: { parameters: [], result: "f64" },
tap: { parameters: ["buffer", "usize"], result: "void" },
mouse_pixel_color_a: { parameters: [], result: "u8" },
mouse_pos_y: { parameters: [], result: "f64" },
mouse_pos_x: { parameters: [], result: "f64", nonblocking: false },
notify: {
parameters: ["buffer", "usize"],
result: "void",
nonblocking: false,
},
mouse_pixel_color_g: { parameters: [], result: "u8", nonblocking: false },
smooth_mouse_move: {
parameters: ["buffer", "usize"],
result: "void",
nonblocking: false,
},
mouse_move: {
parameters: ["buffer", "usize"],
result: "void",
nonblocking: false,
},
screensize_height: { parameters: [], result: "f64", nonblocking: false },
mouse_scroll: { parameters: [], result: "void", nonblocking: false },
mouse_pixel_color_r: { parameters: [], result: "u8", nonblocking: false },
mouse_pixel_color_a: { parameters: [], result: "u8", nonblocking: false },
screensize_width: { parameters: [], result: "f64", nonblocking: false },
mouse_pixel_color_b: { parameters: [], result: "u8", nonblocking: false },
tap: { parameters: ["buffer", "usize"], result: "void", nonblocking: false },
mouse_pos_y: { parameters: [], result: "f64", nonblocking: false },
alert: {
parameters: ["buffer", "usize"],
result: "void",
nonblocking: false,
},
type_: {
parameters: ["buffer", "usize"],
result: "void",
nonblocking: false,
},
mouse_click: {
parameters: ["buffer", "usize"],
result: "void",
nonblocking: false,
},
screenscale: { parameters: [], result: "f64", nonblocking: false },
toggle_key: {
parameters: ["buffer", "usize"],
result: "void",
nonblocking: false,
},
screenshot: {
parameters: ["buffer", "usize"],
result: "void",
nonblocking: false,
},
});
type MouseMoveParams = { d: any; y: number; x: number };
type KeyToggleParams = { key: any; down: any };
type NotifyParams = { title: any; body: any };
type Point = { x: number; y: number };
type StrArg = { text: any };
type AlertParams = { title: any; msg: any };
type MouseClickParamsWrapper = { params: any };
type ScreenSize = { width: number; height: number };
type Pixel = { a: number; r: number; g: number; b: number };
export type ScreenSize = {
height: number;
width: number;
};
export type Point = {
x: number;
y: number;
};
export type NotifyParams = {
title: string;
body: string;
};
export type AlertParams = {
msg: string;
title: string;
};
export type MouseMoveParams = {
x: number;
y: number;
d: number | undefined | null;
};
export type MouseClickParams =
| "left"
| "middle"
| "right";
export type KeyToggleParams = {
key: KeyCode;
down: boolean;
};
export type Pixel = {
r: number;
g: number;
b: number;
a: number;
};
export type KeyCode =
| "f1"
| "f2"
| "f3"
| "f4"
| "f5"
| "f6"
| "f7"
| "f8"
| "f9"
| "f10"
| "f11"
| "f12"
| "f13"
| "f14"
| "f15"
| "f16"
| "f17"
| "f18"
| "f19"
| "f20"
| "f21"
| "f22"
| "f23"
| "f24"
| "leftarrow"
| "uparrow"
| "rightarrow"
| "downarrow"
| "insert"
| "delete"
| "home"
| "end"
| "pageup"
| "pagedown"
| "tab"
| "backspace"
| "enter"
| "escape"
| "space"
| "meta"
| "alt"
| "control"
| "shift"
| "capslock";
export function mouse_pos_x() {
return _lib.symbols.mouse_pos_x() as number;
}
export function notify(a0: NotifyParams) {
const a0_buf = encode(JSON.stringify(a0));
return _lib.symbols.notify(a0_buf, a0_buf.byteLength) as null;
}
export function mouse_pixel_color_g() {
return _lib.symbols.mouse_pixel_color_g() as number;
}
export function smooth_mouse_move(a0: MouseMoveParams) {
const a0_buf = encode(JSON.stringify(a0));
return _lib.symbols.smooth_mouse_move(a0_buf, a0_buf.byteLength) as null;
}
export function mouse_pixel_color_b() {
return _lib.symbols.mouse_pixel_color_b() as number;
}
export function toggle_key(a0: KeyToggleParams) {
const a0_buf = encode(JSON.stringify(a0));
return _lib.symbols.toggle_key(a0_buf, a0_buf.byteLength) as null;
}
export function screenscale() {
return _lib.symbols.screenscale() as number;
}
export function mouse_pixel_color_r() {
return _lib.symbols.mouse_pixel_color_r() as number;
}
export function mouse_move(a0: MouseMoveParams) {
const a0_buf = encode(JSON.stringify(a0));
return _lib.symbols.mouse_move(a0_buf, a0_buf.byteLength) as null;
}
export function screensize_height() {
return _lib.symbols.screensize_height() as number;
}
export function mouse_scroll() {
return _lib.symbols.mouse_scroll() as null;
}
export function notify(a0: NotifyParams) {
const a0_buf = encode(JSON.stringify(a0));
return _lib.symbols.notify(a0_buf, a0_buf.byteLength) as null;
export function mouse_pixel_color_r() {
return _lib.symbols.mouse_pixel_color_r() as number;
}
export function type_(a0: StrArg) {
const a0_buf = encode(JSON.stringify(a0));
return _lib.symbols.type_(a0_buf, a0_buf.byteLength) as null;
export function mouse_pixel_color_a() {
return _lib.symbols.mouse_pixel_color_a() as number;
}
export function screensize_width() {
return _lib.symbols.screensize_width() as number;
}
export function screenshot(a0: StrArg) {
export function mouse_pixel_color_b() {
return _lib.symbols.mouse_pixel_color_b() as number;
}
export function tap(a0: KeyToggleParams) {
const a0_buf = encode(JSON.stringify(a0));
return _lib.symbols.screenshot(a0_buf, a0_buf.byteLength) as null;
return _lib.symbols.tap(a0_buf, a0_buf.byteLength) as null;
}
export function mouse_pos_y() {
return _lib.symbols.mouse_pos_y() as number;
}
export function alert(a0: AlertParams) {
const a0_buf = encode(JSON.stringify(a0));
return _lib.symbols.alert(a0_buf, a0_buf.byteLength) as null;
}
export function mouse_click(a0: MouseClickParamsWrapper) {
export function type_(a0: string) {
const a0_buf = encode(a0);
return _lib.symbols.type_(a0_buf, a0_buf.byteLength) as null;
}
export function mouse_click(a0: MouseClickParams) {
const a0_buf = encode(JSON.stringify(a0));
return _lib.symbols.mouse_click(a0_buf, a0_buf.byteLength) as null;
}
export function screensize_height() {
return _lib.symbols.screensize_height() as number;
}
export function mouse_pos_x() {
return _lib.symbols.mouse_pos_x() as number;
export function screenscale() {
return _lib.symbols.screenscale() as number;
}
export function tap(a0: KeyToggleParams) {
export function toggle_key(a0: KeyToggleParams) {
const a0_buf = encode(JSON.stringify(a0));
return _lib.symbols.tap(a0_buf, a0_buf.byteLength) as null;
}
export function mouse_pixel_color_a() {
return _lib.symbols.mouse_pixel_color_a() as number;
return _lib.symbols.toggle_key(a0_buf, a0_buf.byteLength) as null;
}
export function mouse_pos_y() {
return _lib.symbols.mouse_pos_y() as number;
export function screenshot(a0: string) {
const a0_buf = encode(a0);
return _lib.symbols.screenshot(a0_buf, a0_buf.byteLength) as null;
}
Loading

0 comments on commit 53cb015

Please sign in to comment.