From eef523919b0ea137ac7aa9ac00578821ce4d48a1 Mon Sep 17 00:00:00 2001 From: twlite <46562212+twlite@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:34:18 +0545 Subject: [PATCH] 0.1.1 --- README.md | 48 +++++++++++++++++++++++++++++++++++++++++++----- binding.d.ts | 2 ++ tsconfig.json | 3 ++- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d0b8724..2fa23e8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![https://github.com/webviewjs/webview/actions](https://github.com/webviewjs/webview/workflows/CI/badge.svg) -Robust cross-platform webview library for Node.js written in Rust. +Robust cross-platform webview library for Node.js written in Rust. It is a native binding to [tao](https://github.com/tauri-apps/tao) and [wry](https://github.com/tauri-apps/wry) allowing you to easily manage cross platform windowing and webview. ![preview](https://github.com/twlite/webview/raw/main/assets/preview.png) @@ -27,11 +27,11 @@ npm install @webviewjs/webview | armv7-linux-androideabi | ✅ | | aarch64-pc-windows-msvc | ✅ | -# Usage +# Examples -In this example, we will create a simple webview application that loads the Node.js website. +## Load external url -```javascript +```js import { Application } from '@webviewjs/webview'; // or const { Application } = require('@webviewjs/webview'); @@ -44,7 +44,45 @@ window.loadUrl('https://nodejs.org'); app.run(); ``` -# Examples +## IPC + +```js +import { Application } from '@webviewjs/webview'; + +const app = new Application(); + +app.onIpcMessage((data) => { + const reply = `You sent ${data.body.toString('utf-8')}`; + window.evaluateScript(`onIpcMessage("${reply}")`); +}); + +const window = app.createBrowserWindow({ + html: ` + +
+