Gluon v0.10

CanadaHonk · January 5, 2023

Only 2 days since v0.9, here’s another big update. Gluon v0.10.0 is out with IPC v2, new APIs, internal rewrites, and more!


IPC v2 Overhauled API

Expose Functions New API

IPC has been overhauled with new Expose APIs which allow you to easily expose Node functions to Web, wrapping the existing IPC APIs so most developers won’t need to use a more complicated event-based system. There are multiple ways of doing it, up to the developer’s choice.

node.js
// In your Node backend
import * as Gluon from '@gluon-framework/gluon';
const Window = await Gluon.open('');

// Use a setter, or
Window.ipc.functionOne = () => console.log('function one called!');

// Use the expose function with a key and function, or
Window.ipc.expose('functionTwo', () => console.log('function two called!'));

// Use the expose function with an object to expose multiple in one
Window.ipc.expose({
  functionThree: () => console.log('function three called!'),
  functionFour: () => 'returned value!'
});
site.js
// In your website's JS

// While the Node functions in the example are not async,
// due to using IPC, all exposed functions are async.

await Gluon.ipc.functionOne();
await Gluon.ipc.functionTwo();
await Gluon.ipc.functionThree();

await Gluon.ipc.functionFour(); // 'returned value!'

Page Improved API

The previous Window API has been renamed to Page as its a better representation of what it’s used for (Window.window -> Window.page).

Await Page Load New API

The Node backend can now await page load via await Window.page.loaded.

node.js
// In your Node backend
import * as Gluon from '@gluon-framework/gluon';
const Window = await Gluon.open('');

await Window.page.loaded;
// Page is now loaded!

Eval Improved API

The eval function has changed to return only the result like regular eval().

node.js
// In your Node backend
import * as Gluon from '@gluon-framework/gluon';
const Window = await Gluon.open('');

// Get the current title of the document
const currentTitle = await Window.page.eval(`document.title`);

Stability Improvements

  • Tweaked the initial browser connection to be more stable
  • Data paths are now isolated per browser to fix conflicts when using multiple in one app
  • Fixed Node not closing after the browser has been closed

More Browsers Supported

Gluon now supports over double the browsers than previously, and more install locations, enabling it to work on more setups.