These are the gentle beginnings of Bare bindings for the C library webview for creating webviews on macos, linux, and windows.
Using bare-webview right now requires participating in its development. I'd be happy for the help!
Here's a demonstration of what works so far:
const Worker = require('bare-worker')
const addon = require('.')
// We run the webview in the main thread
if (Worker.isMainThread) {
const webview = addon.create()
const worker = new Worker(__filename, {
workerData: { webview },
})
worker.on('message', console.log)
worker.on('exit', (code) => {
console.log('Worker exited with code', code)
// Destroy must be called from the main thread
addon.destroy(webview)
})
addon.set_title(webview, 'hiiiiii')
addon.set_size(webview, 200, 200, 0)
addon.set_html(webview, 'hi!')
// Run takes over the main loop.
// In this example we're using a worker to handle
// anything that needs to happen other than running the webview,
// including telling the webview to shut down.
addon.run(webview)
} else {
// We do other stuff in the worker.
// In this demo all we're doing is telling the
// webview we're ready for it to shut down.
const webview = Worker.workerData.webview
setTimeout(() => {
// Terminate can be called from the worker thread
addon.terminate(webview)
// Shut down the worker
Worker.parentPort.exit()
}, 2000)
}https://github.com/holepunchto/bare-make is used for compiling the native bindings in binding.c. Start by installing the tool globally:
npm i -g bare-makeNext, generate the build system for compiling the bindings, optionally setting the --debug flag to enable debug symbols and assertions:
bare-make generate [--debug]This only has to be run once per repository checkout. When updating bare-make or your compiler toolchain it might also be necessary to regenerate the build system. To do so, run the command again with the --no-cache flag set to disregard the existing build system cache:
bare-make generate [--debug] --no-cacheWith a build system generated, the bindings can be compiled:
bare-make buildThis will compile the bindings and output the resulting shared library module to the build/ directory. To install it into the prebuilds/ directory where the Bare addon resolution algorithm expects to find it, do:
bare-make installTo make iteration faster during development, the shared library module can also be linked into the prebuilds/ directory rather than copied. To do so, set the --link flag:
bare-make install --linkPrior to publishing the module, make sure that no links exist within the prebuilds/ directory as these will not be included in the resulting package archive.
To publish an addon, make sure to first compile bindings for the targets you wish to support. The prebuild workflow defined in .github/workflows/prebuild.yml automates this process for all tier 1 targets supported by Bare. The whole process can be handily orchestrated by the GitHub CLI. As the package version is part of the compiled bindings, make sure to first commit and push a version update:
npm version <increment>
git push
git push --tagsTo start the prebuild workflow for the newly pushed version, do:
gh workflow run prebuild --ref <version>To watch the status of the workflow run until it finishes, do:
gh run watchWhen finished, the resulting prebuilds can be downloaded to the prebuilds/ directory by doing:
gh run download --name prebuilds --dir prebuildsApache-2.0