npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@gnaudio/jabra-electron-renderer-helper

v2.0.2

Published

Makes jabra-node-sdk available for Electron's renderer process

Downloads

8

Readme

Jabra Node.js Electron Renderer Helper

This optional package allows a secure render process in ElectronJs (https://electronjs.org/) to transparently access the full Jabra Node.js SDK API through proxies implemented on top of Electron's IPC mechanism. This makes it much easier for a sandboxed render process to call into Jabra classes without having to pass messages around.

Note that this package is optional and only potentially useful in a sandboxed electron setup, where the render process does not have access rights to call into the node modules such as the Jabra Node.js API npm module. Even in this case this package is optional, as electron applications can perfectly decide to manage any such messaging themselves.

Usage tips

  1. Get a Jabra API Key

  2. Install dependencies to your existing electron project

    npm install @gnaudio/jabra-node-sdk
    npm install @gnaudio/jabra-electron-renderer-helper
  3. Configure your existing MAIN process script

    Add a top level imports and global:

    import { app, BrowserWindow, ipcMain } from 'electron';
    import { ConfigParamsCloud } from '@gnaudio/jabra-node-sdk';
    import { JabraApiServerFactory, JabraApiServer } from '@gnaudio/jabra-electron-renderer-helper';
    
    let jabraServerFactory : JabraApiServerFactory | null = null;
    let jabraServer: JabraApiServer | null = null;

    Add a preload script to your BrowserWindow instantiation if it is missing:

    preload: path.join(__dirname, 'preload.js')

    Setup jabra api server when electron is ready:

    app.on("ready", async () => {
      // Setup the jabra server factory BEFORE creating GUI.
      jabraServerFactory = new JabraApiServerFactory(ipcMain);
    
      // Code to create GUI window here
      // Tip: Return window.loadFile promise or wait for 'did-finish-load' event and convert it to a promise.
      let fullyLoadedWindow = await your_code_to_create_gui_that_resolves_when_loaded();
    
      // As window is now fully loaded we can instantiate our api server for the client.
      jabraServer = await jabraServerFactory.create('<Set your Jabra API key here>', 
                                                    { /* config here if needed */}, 
                                                    false, // set to true if support for non Jabra devices.
                                                    fullyLoadedWindow);
    });

    Cleanup when closing:

    app.on("window-all-closed", async () => {
        if (process.platform !== "darwin") {
            if (jabraServer) {
                await jabraServer.shutdown();
                jabraServer = null;
            }
            if (app) {
                app.quit();
            }
        }
    });
  4. Configure the preload script to expose ipcRender to the renderer process

    import { ipcRenderer } from 'electron';
    
    window.electron = { 
        ipcRenderer
    };
  5. Configure to your render javascript (loaded by your html)

    import { createApiClient } from '@gnaudio/jabra-electron-renderer-helper';
    import { JabraType, ClassEntry, JabraEventsList, DeviceEventsList } from '@gnaudio/jabra-node-sdk';
    
    createApiClient(window.electron.ipcRenderer).then((client) => {    
        client.on('attach', (device) => {
            // TODO: Add code here to call into provided DeviceType proxy. 
        });
    
        client.on('detach', (device) => {
        // TODO: Add code here if needed.
        });
    }).catch( (err) => {
        console.error("Could not initialize Jabra Api client : " + err);
    });
  6. Use typescript along with browserify, webpack or other build tool to produce a javascript bundle for the renderer.

Complete example and details.

Refer to the demoapp for a complete example of how to use this package.