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

@wildix/xbees-connect

v1.2.6

Published

This library provides easy communication between x-bees and integrated web applications

Downloads

1,443

Readme

x-bees-connect client

This package is the Community plan edition of the client for UI integration applications.

Installation

Install the package in your project directory with:

yarn add @wildix/xbees-connect
npm install @wildix/xbees-connect

Usage

import Client from "@wildix/xbees-connect";

const xBeesClient = Client.getInstance();

console.log(xBeesClient.version());

API

Initialization

ready()

Sends the signal to x-bees that iFrame is ready to be shown. iFrame should send it when the application starts and is ready.

isAuthorized: (payload: string) => Promise<ResponseFromChannel>

Sends the message to x-bees that the user is authorized and no more actions are required.

isNotAuthorized: (payload: string) => Promise<ResponseFromChannel>

Sends the message to x-bees that user actions are required:

Contacts search

onSuggestContacts: ((query: string, resolve: Resolve, reject: Reject) => void) => RemoveEventListener

Starts listen for the events of searching contacts and handle autosuggestion with the provided callback */

Client.getInstance().onSuggestContacts(async (query, resolve) => {
    try {
        const contacts = await fetchContacts(query);
        resolve(contacts);
    } catch (error) {
        console.log('catch', error);
    }
});

onLookupAndMatchContact: ((query: ContactQuery, resolve: Resolve, reject: Reject) => void) => RemoveEventListener

Starts listen for the events of searching contact info and handle match with the provided callback

Client.getInstance().onLookupAndMatchContact(async (query, resolve) => {
    try {
        const contact = await fetchContactAndMatch(query);
        resolve(contact);
    } catch (error) {
        console.log('catch', error);
    }
});

Context

getContext(): Promise<Response>

Retrieves current x-bees context data. The data may be different depending on context.

getCurrentContact(): Promise<Response>

Retrieves contact data currently opened in x-bees.

getCurrentConversation(): Promise<Response>

Retrieves conversation data ({id, type}) currently opened in x-bees. If the conversation is temporary - retrieves undefined

getThemeMode(): Promise<Response>

Retrieves current theme mode (light or dark)

getTheme(): Promise<Response>

Retrieves current theme mode and theme options

onThemeChange: (callback: ThemeChangeListenerCallback) => void;

Starts to listen for the events of changing theme and returns the provided callback

onPbxTokenChange: (callback: ListenerCallback) => void;

Starts to listen for the events of changing PBX token and returns the provided callback

onCallStarted: (callback: ListenerCallback) => void;

Starts to listen for the events of starting the call and returns the provided callback

onCallEnded: (callback: ListenerCallback) => void;

Starts to listen for the events of ending the call and returns the provided callback

off: (callback: ListenerCallback) => void;

Removes particular callback from handling events

Other

version(): string

Retrieves the version of xBeesConnect

startCall(phoneNumber: string)

Sends a request to x-bees to start a call with a number

reboot()

Sends a request to x-bees to restart the iFrame, reload with actual parameters and token

setViewport({height: number; width: number})

Sends a request to x-bees about changes of the current frame size

toClipboard(payload: string)

Sends a request to x-bees to put a string to the user's clipboard

addEventListener()

Starts listening for one of the x-bees events and returns the provided callback

removeEventListener()

Stops listening for one of the x-bees events with the particular callback

onLogout()

Starts listen on logout event and send event to the xbees about logout able

sendAnalytics()

Sends analytics data to xbees for track into analytics data

Known issues

The below function can fix cases when String.replaceAll() does not work in the mobile version. Most likely, this is some kind of WebView bug.

function replaceAll(str: string, search: string, replace: string) {
    return str.split(search).join(replace);
}