From 111031a18ec0532f058780844f230da5839a25b3 Mon Sep 17 00:00:00 2001 From: twlite <46562212+twlite@users.noreply.github.com> Date: Thu, 3 Oct 2024 22:35:36 +0545 Subject: [PATCH] feat: add more apis --- Cargo.toml | 4 +- examples/html.js | 16 +- index.d.ts | 102 +++++++++++ index.js | 9 +- src/browser_window.rs | 399 ++++++++++++++++++++++++++++++++++++++++-- src/lib.rs | 100 ++++++++++- 6 files changed, 600 insertions(+), 30 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4626962..4bd584b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,10 +10,10 @@ version = "0.1.0" crate-type = ["cdylib"] [dependencies] -napi = "2" +napi = { version = "2", default-features = true, features = ["napi9"] } napi-derive = "2" tao = "0.30.2" -wry = { version = "0.45.0", features = ["devtools"] } +wry = { version = "0.45.0", features = ["devtools", "fullscreen"] } [build-dependencies] napi-build = "2" diff --git a/examples/html.js b/examples/html.js index c084c85..1f96706 100644 --- a/examples/html.js +++ b/examples/html.js @@ -1,7 +1,13 @@ -const requireScript = require('node:module').createRequire(__filename); -const { Application } = requireScript('../index.js'); +// const requireScript = require('node:module').createRequire(__filename); +// const { Application } = requireScript('../index.js'); +const { Application } = require('../index.js'); const app = new Application(); + +app.onIpcMessage((data) => { + console.log({ data }); +}); + const window = app.createBrowserWindow({ html: ` @@ -10,6 +16,12 @@ const window = app.createBrowserWindow({