globular-element
Version:
Collection of webcomponent to work with globular
99 lines (98 loc) • 3.7 kB
TypeScript
import * as GlobularWebClient from "globular-web-client";
import { Peer } from "globular-web-client/resource/resource_pb";
import Toastify from "toastify-js";
import "toastify-js/src/toastify.css";
import "@polymer/paper-input/paper-input";
import '@polymer/paper-radio-button/paper-radio-button.js';
import '@polymer/paper-radio-group/paper-radio-group.js';
/**
* Returns the URL for the given globule.
* @param globule - The globule object.
* @returns The URL of the globule.
*/
export declare function getUrl(globule?: GlobularWebClient.Globular): string;
export declare function displayMessage(msg: string, duration?: number): {
readonly options: Toastify.Options;
readonly toastElement: Element | null;
showToast(): void;
hideToast(): void;
};
/**
* Display an error message to the user
* @param {*} err
*/
export declare function displayError(err: any, duration?: number): void;
/**
* Display a success message to the user
* @param {*} msg
*/
export declare function displaySuccess(msg: string, duration?: number): void;
/**
*
* @param msg The authentication message.
* @param globule
* @param successCallback
* @param errorCallback
* @returns
*/
export declare function displayAuthentication(msg: string, globule: GlobularWebClient.Globular, successCallback: (token: string) => void, errorCallback: (err: any) => void): void;
/**
* Generates a peer token for the given globule, with automatic token refresh.
* @param globule - The globule object.
* @param callback - The success callback function.
* @param errorCallback - The error callback function.
*/
export declare function generatePeerToken(globule: GlobularWebClient.Globular, callback: (token: string) => void, errorCallback: (err: any) => void): void;
export declare class Backend {
private static globule;
/**
* The domain of the application.
*/
static domain: string;
/**
* The address of the application.
*/
static address: string;
/**
* A map of connected globules, indexed by their addresses.
*/
static globules: Map<string, GlobularWebClient.Globular>;
/**
* Returns the globule associated with the given address.
* @param address - The address of the desired globule.
* @returns The globule with the provided address.
*/
static getGlobule(address: string): GlobularWebClient.Globular;
/**
* Returns an array of unique connected globules.
* @returns An array of connected globules without duplicates.
*/
static getGlobules(): Array<GlobularWebClient.Globular>;
/**
* Returns the globule where the application is running.
*/
static get globular(): GlobularWebClient.Globular;
static get eventHub(): GlobularWebClient.EventHub;
static publish(name: string, data: any, local: boolean): void;
static subscribe(name: string, onSubscribe: (uuid: string) => void, onEvent: (data: any) => void, local: boolean): void;
constructor();
/**
* Connect with the backend and get the initial configuration.
* @param url The url of the backend
* @param initCallback On success callback
* @param errorCallback On error callback
*/
static init(url: string, initCallback: () => void, errorCallback: (err: any) => void): void;
/**
* Initialyse the peer.
* @param peer The peer to initialyse
* @param callback The success callback
* @param errorCallback The error callback
*/
static initPeer(peer: Peer, callback: () => void, errorCallback: (err: any) => void): void;
/**
* Remove the peer from the list of active globule.
* @param peer
*/
static removePeer(peer: Peer): void;
}