- I'm an ordinay IT amateur.
- I only publish my reposity in GitHub and Codeburg.
Avatar credit: γγγγγ‘γΌγ«γΌ
A Node.js binding to webview
License: Apache License 2.0
Avatar credit: γγγγγ‘γΌγ«γΌ
Is there a way to change the position of the window. For example, I'd like to make it in the center of the screen. Thank you!
When installing v0.4.0 on Windows 10, I got the error 'OMG CMake is not installed. Install CMake.'
I was able to solve this by running winget install Kitware.CMake
. I also had to close and re-open my console to get the path to update.
Just putting this here in case anyone else gets stuck. Would be good to add this info to the readme.
When opening multiple windows, closing one will cause other windows crash.
Hi,
I revisited this project and realized that something is not working for me in the latest version 0.2.4.
When I start a new project with npm install webview-nodejs
not everything seems to be installed.
Downgrading to 0.1.3 makes the examples work again. According to my tests, just the trivial hello world example works, the more sophisticated ones (which use bind
like this one at the bottom) do not work for me.
I am on node 19.9.
Thanks,
Dirk
Provide same API like webview_deno and webview-bun
Currently we are using ffi-napi as our way to call C++ code from Node.js, It has pros and cons:
Pros:
Cons:
We may consider using Node-API(NAPI), the official way to call C++ code.
Pros:
Cons:
Make a decision:
CmakeList to CMakeList
This command failed: sh -c node-gyp-build when trying to build (arch === arm64). I did a prior successful npm i node-gyp. Any hints?
I'll try to follow what webview_deno do.
Originally posted by faveoled January 26, 2023
I noticed that setInterval
routine stops working after I call show()
on a webview. It there a way to go around that?
hello guys,
in my code, I need to open a window, do some processing then terminate it then continue doing some processing.
but once I terminate the window the whole node code stop suddenly without any error, nothing is getting executed after window termination.
For example the Link to "Examples" is no longer valid.
Would be great if you could update the documentation.
During build, there is a deprecation notice about the function call webkit_web_view_run_javascript()
in webview.h:689.
The warning says: warning: 'void webkit_web_view_run_javascript(WebKitWebView*, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)' is deprecated: Use 'webkit_web_view_evaluate_javascript' instead [-Wdeprecated-declarations]
As of now, this warning doesn't cause any issues, but it may be worth being aware of.
Environment: Debian 12 with libwebkit2gtk-4.0-dev
I have been using webview-nodejs @0.1.5 on a Mac (Ventura) for a WebRTC app. Suddenly, (today) it stopped working because navigator.mediaDevices is now undefined. The same app works in a browser. I did not touch the webview-nodejs node modules. Is it possible that webview-nodejs is now denied user media access? I looked in system settings/privacy and security/camera and I don't see a webview entry but I never had to add it here before. As an aside, I cannot add apps to access the camera.
I've shutdown and restarted, to no avail. Any suggestions on how to troubleshoot this are appreciated.
Hi,
here's a minimal text editor:
https://gist.github.com/dirkk0/583c9633ea817f6a028939c4dc6dd729
Cheers, Dirk
Here's the one-fileversion:
---snip---
'use strict';
const { Webview } = require('webview-nodejs');
const fs = require("fs");
let w = null
let txt = "";
let path = "texteditor.txt";
let html = `
<html>
<style>
#text {
width: 100%;
height: 90%;
}
</style>
<body>
<button onclick="doCmd('load')">load</button>
<button onclick="doCmd('save', getText());">save</button>
<button onclick="doCmd('quit');">quit </button>
<div id="text" contenteditable>type something here ...</div>
</body>
<script>
'use strict';
function setText(t) {
document.querySelector("#text").innerText = t
}
function getText() {
return document.querySelector("#text").innerText
}
doCmd("load")
</script>
</html>
`
function main() {
// let html = fs.readFileSync("texteditor.html", { encoding: "utf8", flag: "r" });
w = new Webview(true);
w.title("Minimal Text Editor");
w.size(600, 400, 3);
w.html(html);
w.bind("doCmd", (w, c, t) => {
console.log("cmd:", c);
if (c == "quit") w.terminate();
if (c == "load") {
txt = fs.readFileSync(path, { encoding: "utf8", flag: "r" });
txt = JSON.stringify(txt)
w.eval(`setText(${txt})`);
}
if (c == "save") fs.writeFileSync(path, t, { encoding: "utf8" });
});
w.show();
};
main()
Hi,
thanks for the nodejs bindings, much appreciated!
Because it wasn't completely obvious for me I created an example with keybindings (which are platform specific, this is for a Mac) and logging.
Maybe this is helpful for someone.
const { Webview } = require("webview-nodejs");
html = `
<body>
<div id="d1"></div>
<script>
let counter = 0
window.addEventListener("keypress", (event) => {
if (event.metaKey && event.key === 'q') {
doCmd("quit")
event.preventDefault();
}
})
setInterval(function () {
document.querySelector("#d1").innerText = counter
doLog("counter is " + counter)
counter += 1
}, 1000);
</script>
</body>
`
let w = new Webview(true);
w.size(600, 600);
w.html(html);
w.bind("doLog", (w, t) => {
console.log(t);
w.title(t)
});
w.bind("doCmd", (w, cmd) => {
console.log("cmd:", cmd);
if (cmd == "quit") w.terminate();
});
w.show();
Personally, I don't like TypeScript, so I decide to remove it later. A .d.ts
file will still exist for users.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.