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

@yealink_dev/yealink-ipc-helper-rcc

v1.0.1

Published

Makes @yealink_dev/yealink-node-sdk-rcc available for Electron's renderer process

Downloads

2

Readme

Yealink Node.js Electron Renderer Helper

This optional package allows a secure render process in ElectronJs (https://electronjs.org/) to transparently access the full Yealink 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 Yealink 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 Yealink 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 [Yealink API Key] from yealink teams

  2. Install dependencies to your existing electron project

    npm install yealink-node-sdk
    npm install yealink-ipc-helper
  3. Configure your existing MAIN process script

    Add a top level imports and global:

    import { app, BrowserWindow, ipcMain } from 'electron';
    import { ConfigParamsCloud } from '@yealink_dev/yealink-node-sdk-rcc';
    import { YLIPCServerFactory, YLIPCServer } from '@yealink_dev/yealink-ipc-helper-rcc';
    
    let ylIPCServerFactory: YLIPCServerFactory | null = null;
    let ylIPCServer: YLIPCServer | null = null;

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

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

    Setup yealink api server when electron is ready:

    app.on("ready", async () => {
      // Setup the yealink server factory BEFORE creating GUI.
      ylIPCServerFactory = new YLIPCServerFactory(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.
      ylIPCServer = await ylIPCServerFactory.create('<Set your Yealink API key here>', 
                                                    { /* config here if needed */}, 
                                                    false,
                                                    fullyLoadedWindow);
    });

    Cleanup when closing:

    app.on("window-all-closed", async () => {
        if (process.platform !== "darwin") {
            if (ylIPCServer) {
                await ylIPCServer.shutdown();
                ylIPCServer = 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 { createIPCClient } from '@yealink_dev/yealink-ipc-helper-rcc';
    import { DeviceImpl, YLSdkImpl, ylEventsList, DeviceEventsList } from '@yealink_dev/yealink-node-sdk-rcc';
    
    createIPCClient(window.electron.ipcRenderer).then((client) => {    
        client.on('attach', (device) => {
            // TODO: Add code here to call into provided DeviceImpl proxy. 
        });
    
        client.on('detach', (device) => {
        // TODO: Add code here if needed.
        });
    }).catch( (err) => {
        console.error("Could not initialize Yealink 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 democallcontrol for a complete example of how to use this package.