diff --git a/README.md b/README.md index 5c50f21..1a33e40 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,9 @@ const { Application } = require('@webviewjs/webview'); const app = new Application(); const window = app.createBrowserWindow(); +const webview = window.createWebview(); -window.loadUrl('https://nodejs.org'); +webview.loadUrl('https://nodejs.org'); app.run(); ``` @@ -56,7 +57,8 @@ app.onIpcMessage((data) => { window.evaluateScript(`onIpcMessage("${reply}")`); }); -const window = app.createBrowserWindow({ +const window = app.createBrowserWindow(); +const webview = window.createWebview({ html: ` diff --git a/examples/html.js b/examples/html.js index 8d42f27..59bc86e 100644 --- a/examples/html.js +++ b/examples/html.js @@ -3,13 +3,9 @@ const { Application } = require('../index.js'); const app = new Application(); +const window = app.createBrowserWindow(); -app.onIpcMessage((data) => { - const reply = `You sent ${data.body.toString('utf-8')}`; - window.evaluateScript(`onIpcMessage("${reply}")`) -}) - -const window = app.createBrowserWindow({ +const webview = window.createWebview({ html: ` @@ -32,6 +28,11 @@ const window = app.createBrowserWindow({ }` }); -window.setTitle('WebviewJS + Node'); +if (!webview.isDevtoolsOpen()) webview.openDevtools(); + +webview.onIpcMessage((data) => { + const reply = `You sent ${data.body.toString('utf-8')}`; + window.evaluateScript(`onIpcMessage("${reply}")`) +}) app.run(); diff --git a/examples/http/webview.mjs b/examples/http/webview.mjs index f198a6a..ae8bedd 100644 --- a/examples/http/webview.mjs +++ b/examples/http/webview.mjs @@ -18,9 +18,10 @@ function createWindow() { const app = new Application(); const window = app.createBrowserWindow(); + const webview = window.createWebview(); - if (!window.isDevtoolsOpen()) window.openDevtools(); - window.loadUrl('http://localhost:3000'); + if (!webview.isDevtoolsOpen()) webview.openDevtools(); + webview.loadUrl('http://localhost:3000'); app.run(); } diff --git a/examples/multiple.mjs b/examples/multiple.mjs index 707aff7..89aa98d 100644 --- a/examples/multiple.mjs +++ b/examples/multiple.mjs @@ -2,9 +2,9 @@ import { Application } from '../index.js' const webview1 = new Application(); -webview1.createBrowserWindow({ url: 'https://nodejs.org' }); +webview1.createBrowserWindow().createWebview({ url: 'https://nodejs.org' }); const webview2 = new Application(); -webview2.createBrowserWindow({ url: 'https://wikipedia.org' }); +webview2.createBrowserWindow().createWebview({ url: 'https://wikipedia.org' }); await Promise.all([webview1.run(), webview2.run()]); \ No newline at end of file diff --git a/examples/url.mjs b/examples/url.mjs index efc3632..f25b184 100644 --- a/examples/url.mjs +++ b/examples/url.mjs @@ -1,7 +1,9 @@ import { Application, Theme } from '../index.js'; const app = new Application(); -const window = app.createBrowserWindow({ +const window = app.createBrowserWindow(); + +window.createWebview({ title: 'Hello world', url: 'https://nodejs.org', });