Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@meetelise/chat

Package Overview
Dependencies
Maintainers
1
Versions
376
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meetelise/chat - npm Package Compare versions

Comparing version 1.0.0-rc.10 to 1.0.0-rc.11

dist/src/chatID.d.ts

174

dist/index.d.ts

@@ -1,173 +0,1 @@

declare module "src/fetchBuildingInfo" {
/**
* The response from the API.
*/
export interface Building {
id: number;
avatarInitials: string | null;
avatarSrc: string | null;
backgroundColor: string | null;
bannerColor: string | null;
chatSubtitle: string | null;
chatTitle: string | null;
launchButtonColor: string | null;
launchButtonIconColor: string | null;
launchButtonSize: string | null;
logoSrc: string | null;
messageColor: string | null;
name: string;
primaryColor: string | null;
userFirstName: string;
userId: number;
userLastName: string | null;
welcomeMessage: string | null;
}
/**
* Load the publicly-available info for a building.
*
* @param orgSlug - The org slug, e.g. "big-prop-co"
* @param buildingSlug - The buidling slug, e.g. "gravity-falls"
* @returns The building's ID, name, theme, and agent.
*/
export default function fetchBuildingInfo(orgSlug: string, buildingSlug: string): Promise<Building>;
}
declare module "src/getAvatarUrl" {
import { Building } from "src/fetchBuildingInfo";
/**
* Get the avatar URL for a building.
*
* If the client has uploaded an image, returns its URL. If the client
* hasn't uploaded an image but has set their initials, returns an SVG
* data URL of a circle with their initials in it. If the client hasn't
* chosen an image or initials, returns null.
*
* @param building The building public theme info.
* @returns a URL suitable for use as a CSS background-image or <img> src.
*/
export default function getAvatarURL(building: Building): string;
}
declare module "src/chatID" {
/**
* Get or create a UUID that is the same between browser sessions.
*
* @returns the chat ID.
*/
export function getChatID(): string;
/**
* Create a new chat ID and discard any old one.
*/
export function createChatID(): string;
}
declare module "src/resolveTheme" {
import { Building } from "src/fetchBuildingInfo";
export interface Theme {
avatarInitials: string;
avatarSrc: string | null;
bannerColor: string;
bannerTextColor: string;
chatSubtitle?: string | null;
chatTitle: string;
launchButtonColor: string;
launchButtonIconColor: string;
launchButtonSize: string;
messageColor: string;
messageTextColor: string;
}
export default function resolveTheme(building: Building, theme: Partial<Theme>): Theme;
}
declare module "src/talkjsFns" {
import Talk from 'talkjs';
import { Building } from "src/fetchBuildingInfo";
import { Theme } from "src/resolveTheme";
export function initialize(): Promise<void>;
/**
* Initialize TalkJS and show the chat widget on the screen.
*
* @param building - The building to communicate with
*/
export function createTalkJSPopup(building: Building, theme: Theme): Talk.Popup;
export function restartConversation(building: Building, theme: Theme): void;
export function updateTheme(building: Building, theme: Theme): void;
}
declare module "src/getIcons" {
import { Theme } from "src/resolveTheme";
/**
* Get a pair of close, open icons for a building.
*
* @param theme - The building, to get theme colors.
* @returns a pair of svg data URLs.
*/
export default function getIcons(theme: Theme): [string, string];
}
declare module "src/installTalkJSStyles" {
import { Theme } from "src/resolveTheme";
/**
* Overrides the TalkJS stylesheet so our icons have the right colors.
*
* This is done via stylesheets so that we can change the style
* _before_ the launcher is added to the DOM.
*/
export default function installTalkJSStyles(theme: Theme): void;
}
declare module "src/MEChat" {
import { Theme } from "src/resolveTheme";
/**
* The interface to MeetElise chat.
*
* To add meetelise chat to the screen, call its static method
* `start()` with your building and organization slug.
*
* @example
* MEChat.start({
* organization: 'the-jacobson-group',
* building: 'twin-rivers-pointe'
* });
*/
export default class MEChat {
/**
* Start an instance of MeetElise chat and add to the web page.
*
* @param opts The organization, building, and theme overrides.
* @returns An instance of MeetElise chat.
*/
static start(opts: Options): MEChat;
/**
* Remove the instance from the screen.
*
* Chat will be unusable after this. If you just need to hide the
* chat button, use {@link MEChat#hide} instead.
*/
remove(): void;
/**
* Clear all messages from the window and start a new conversation.
*/
restartConversation(): void;
/**
* Update the theme of the running chat instance.
*
* @param theme The updated theme
*/
setTheme(theme: Partial<Theme>): void;
/** Open the messages window */
open(): void;
/** Close the messages window */
close(): void;
/** Show the chat button on the screen if it was previously hidden. */
show(): void;
/** Hide the chat button from the screen (but don't remove from the DOM). */
hide(): void;
private popup;
private launcher;
private building;
private theme;
private constructor();
}
export interface Options {
building: string;
organization: string;
theme?: Partial<Theme>;
}
}
declare module "index" {
export { default, Options } from "src/MEChat";
}
export { default, Options } from './src/MEChat';

@@ -1,300 +0,2 @@

// src/fetchBuildingInfo.ts
async function fetchBuildingInfo(orgSlug, buildingSlug) {
const host = "https://app.meetelise.com";
const url = `${host}/api/pub/v1/organization/${orgSlug}/building/${buildingSlug}`;
const response = await fetch(url);
const building = await response.json();
return building;
}
// node_modules/talkjs/src/index.esnext.js
if (typeof window === "undefined") {
throw new Error("[TalkJS] The TalkJS JavaScript SDK only works in browsers (and not, for example, in Node.js)");
}
(function(t, a, l, k, j, s) {
s = a.createElement("script");
s.async = 1;
s.src = "https://cdn.talkjs.com/talk.js";
a.head.appendChild(s);
k = t.Promise;
t.Talk = { v: 3, ready: { then: function(f) {
if (k)
return new k(function(r, e) {
l.push([f, r, e]);
});
l.push([f]);
}, catch: function() {
return k && new k();
}, c: l } };
})(window, document, []);
var Talk = window.Talk;
var index_esnext_default = Talk;
// src/getAvatarUrl.ts
function getAvatarURL(building) {
if (building.avatarSrc)
return building.avatarSrc;
const initials = building.avatarInitials;
const bgColor = building.launchButtonColor;
const initialsSvg = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<rect x="0" y="0" width="100" height="100" fill="${bgColor}" />
<text
x="50%"
y="54%"
dominant-baseline="middle"
font-size="34"
font-family="San Francisco, Segoe UI, Helvetica Neue, Arial, Helvetica, sans-serif"
fill="#fff"
text-anchor="middle"
>${initials}</text>
</svg>
`.trim().replace(/\s+/, " ");
const b64svg = btoa(initialsSvg);
return `data:image/svg+xml;base64,${b64svg}`;
}
// node_modules/uuid/dist/esm-browser/rng.js
var getRandomValues;
var rnds8 = new Uint8Array(16);
function rng() {
if (!getRandomValues) {
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== "undefined" && typeof msCrypto.getRandomValues === "function" && msCrypto.getRandomValues.bind(msCrypto);
if (!getRandomValues) {
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
}
}
return getRandomValues(rnds8);
}
// node_modules/uuid/dist/esm-browser/regex.js
var regex_default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
// node_modules/uuid/dist/esm-browser/validate.js
function validate(uuid) {
return typeof uuid === "string" && regex_default.test(uuid);
}
var validate_default = validate;
// node_modules/uuid/dist/esm-browser/stringify.js
var byteToHex = [];
for (var i = 0; i < 256; ++i) {
byteToHex.push((i + 256).toString(16).substr(1));
}
function stringify(arr) {
var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
if (!validate_default(uuid)) {
throw TypeError("Stringified UUID is invalid");
}
return uuid;
}
var stringify_default = stringify;
// node_modules/uuid/dist/esm-browser/v4.js
function v4(options, buf, offset) {
options = options || {};
var rnds = options.random || (options.rng || rng)();
rnds[6] = rnds[6] & 15 | 64;
rnds[8] = rnds[8] & 63 | 128;
if (buf) {
offset = offset || 0;
for (var i = 0; i < 16; ++i) {
buf[offset + i] = rnds[i];
}
return buf;
}
return stringify_default(rnds);
}
var v4_default = v4;
// src/chatID.ts
var key = "com.meetelise.chatID";
function getChatID() {
const existingID = localStorage.getItem(key);
if (existingID)
return existingID;
const id = v4_default();
localStorage.setItem(key, id);
return id;
}
function createChatID() {
const id = v4_default();
localStorage.setItem(key, id);
return id;
}
// src/talkjsFns.ts
var me;
var session;
async function initialize() {
await index_esnext_default.ready;
me = new index_esnext_default.User({
id: "anonymous",
name: "Me",
email: null,
role: "default"
});
session = new index_esnext_default.Session({
appId: "t1OiQxbE",
me
});
}
function createTalkJSPopup(building, theme) {
const popup = session.createPopup(createConversation(building, theme, getChatID()));
return popup;
}
function restartConversation(building, theme) {
const popup = session.getPopups()[0];
popup.select(createConversation(building, theme, createChatID()));
}
function updateTheme(building, theme) {
const popup = session.getPopups()[0];
popup.select(createConversation(building, theme, getChatID()));
}
function createConversation(building, theme, chatID) {
const agent = new index_esnext_default.User({
id: `building_${building.id}`,
name: building.userFirstName,
email: null,
photoUrl: getAvatarURL(building),
role: "default",
welcomeMessage: building.welcomeMessage
});
const conversation = session.getOrCreateConversation(chatID);
conversation.subject = theme.chatTitle;
conversation.setParticipant(me);
conversation.setParticipant(agent);
conversation.custom = {
buildingId: building.id.toString(),
userId: building.userId.toString(),
subtitle: theme.chatSubtitle ?? null,
bannerColor: theme.bannerColor,
bannerTextColor: theme.bannerTextColor,
messageColor: theme.messageColor,
messageTextColor: theme.messageTextColor
};
return conversation;
}
// src/getIcons.ts
function getIcons(theme) {
const close = toDataUrl(`
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="312px" height="312px" viewBox="0 0 312 312" version="1.1">
<g id="Page-1" stroke="none" stroke-width="1" fill="${theme.launchButtonIconColor}" fill-rule="evenodd">
<path d="M178.500682,155.862614 L306.579682,28.4831591 C312.720136,22.4048864 312.720136,12.5646136 306.579682,6.50188636 C300.454773,0.423613636 290.505682,0.423613636 284.380773,6.50188636 L156.410591,133.772523 L27.2589545,4.60534091 C21.1340455,-1.53511364 11.1849545,-1.53511364 5.06004545,4.60534091 C-1.06486364,10.7613409 -1.06486364,20.7259773 5.06004545,26.8664318 L134.118409,155.940341 L4.59368182,284.749977 C-1.53122727,290.82825 -1.53122727,300.668523 4.59368182,306.73125 C10.7185909,312.809523 20.6676818,312.809523 26.7925909,306.73125 L156.2085,178.030432 L284.847136,306.684614 C290.972045,312.825068 300.921136,312.825068 307.046045,306.684614 C313.170955,300.528614 313.170955,290.563977 307.046045,284.423523 L178.500682,155.862614 L178.500682,155.862614 Z" id="Close" fill="${theme.launchButtonIconColor}"/>
</g>
</svg>`);
const open = toDataUrl(`
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="420px" height="420px" viewBox="0 0 420 420" version="1.1">
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Shape" fill="${theme.launchButtonIconColor}">
<path d="M187.402765,324.536547 L305.950138,417.398656 C307.890958,418.88487 309.079928,419.636719 310.233929,419.636719 C313.521083,419.636719 314.500236,417.416141 314.500236,413.726835 L314.500236,325.900367 C314.500236,319.69324 318.574209,314.762509 324.081941,314.762509 L367.182129,314.727539 C405.981041,314.727539 419.636719,295.599099 419.636719,279.757812 L419.636719,34.9697266 C419.636719,17.4848633 406.558041,0 366.937341,0 L52.2622563,0 C14.0228604,0 0,16.9428325 0,34.9697266 L0,279.757812 C0,296.700645 14.4774668,314.727539 52.4545898,314.727539 L157.36377,314.727539 C157.36377,314.727539 179.307273,315.339509 187.402765,324.536547 L187.402765,324.536547 Z" fill="${theme.launchButtonIconColor}"/>
<ellipse id="Oval-1" fill="${theme.launchButtonColor}" cx="115.347661" cy="162.184556" rx="28.3476608" ry="28.1845557"/>
<ellipse id="Oval-1" fill="${theme.launchButtonColor}" cx="210.698884" cy="162.184556" rx="28.3476608" ry="28.1845557"/>
<ellipse id="Oval-1" fill="${theme.launchButtonColor}" cx="306.050106" cy="162.184556" rx="28.3476608" ry="28.1845557"/>
</g>
</g>
</svg>
`);
return [open, close];
}
var toDataUrl = (svg) => {
const trimmed = svg.replace(/\s+/, " ").trim();
return `data:image/svg+xml;base64,${btoa(trimmed)}`;
};
// src/installTalkJSStyles.ts
function installTalkJSStyles(theme) {
const styleOverrides = document.createElement("style");
document.head.appendChild(styleOverrides);
const [openIcon, closeIcon] = getIcons(theme);
styleOverrides.sheet?.insertRule(`#__talkjs_launcher {
background-color: ${theme.launchButtonColor};
}`);
styleOverrides.sheet?.insertRule(`#__talkjs_launcher.closed {
background-image: url(${openIcon});
}`);
styleOverrides.sheet?.insertRule(`#__talkjs_launcher.open {
background-image: url(${closeIcon});
}`);
}
// src/resolveTheme.ts
function resolveTheme(building, theme) {
return {
avatarInitials: theme.avatarInitials ?? building.avatarInitials ?? building.userFirstName[0],
avatarSrc: theme.avatarSrc ?? building.avatarSrc,
bannerColor: theme.bannerColor ?? building.bannerColor ?? "#e7ecee",
bannerTextColor: "rgba(0, 0, 0, 0.88)",
chatSubtitle: theme.chatSubtitle ?? building.chatSubtitle,
chatTitle: theme.chatTitle ?? building.chatTitle ?? building.userFirstName,
launchButtonColor: theme.launchButtonColor ?? building.launchButtonColor ?? "#0785f2",
launchButtonIconColor: theme.launchButtonIconColor ?? building.launchButtonIconColor ?? "#ffffff",
launchButtonSize: theme.launchButtonSize ?? building.launchButtonSize ?? "60px",
messageColor: theme.messageColor ?? building.messageColor ?? "#0785f2",
messageTextColor: "#fff"
};
}
// src/MEChat.ts
var MEChat = class {
static start(opts) {
return new MEChat(opts);
}
remove() {
this.popup.then((p) => p.destroy());
this.popup = Promise.reject(new Error("MeetElise chat remove() has already been called."));
}
restartConversation() {
this.building.then((b) => {
restartConversation(b, resolveTheme(b, this.theme));
});
}
setTheme(theme) {
this.close();
this.building.then((b) => {
const resolvedTheme = this.theme = resolveTheme(b, {
...this.theme,
...theme
});
updateTheme(b, resolvedTheme);
this.open();
});
}
open() {
this.popup.then((p) => p.show());
}
close() {
this.popup.then((p) => p.hide());
}
show() {
this.launcher.then((a) => a.style.display = "");
}
hide() {
this.launcher.then((a) => a.style.display = "none");
}
constructor({ organization, building, theme = {} }) {
this.theme = theme;
this.building = fetchBuildingInfo(organization, building);
this.popup = Promise.all([
this.building,
initialize()
]).then(([building2]) => {
const resolvedTheme = this.theme = resolveTheme(building2, theme);
installTalkJSStyles(resolvedTheme);
const p = createTalkJSPopup(building2, resolvedTheme);
return p.mount({ show: false }).then(() => p);
});
this.launcher = this.popup.then(() => {
const a = document.querySelector("a#__talkjs_launcher");
if (!a)
throw new Error("MeetElise Chat: Could not locate launcher.");
return a;
});
}
};
export {
MEChat as default
};
//# sourceMappingURL=index.js.map
export { default } from './src/MEChat';
//# sourceMappingURL=index.js.map
{
"name": "@meetelise/chat",
"version": "1.0.0-rc.10",
"version": "1.0.0-rc.11",
"description": "",
"type": "module",
"main": "dist/index.js",

@@ -9,5 +10,5 @@ "module": "dist/index.js",

"scripts": {
"start": "esbuild index.ts --format=esm --servedir=demo --bundle",
"start": "web-dev-server",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc --listEmittedFiles && esbuild index.ts --format=esm --bundle --sourcemap --outfile=dist/index.js",
"build": "tsc",
"prepublishOnly": "npm run build"

@@ -28,4 +29,3 @@ },

"@types/uuid": "^8.3.1",
"concurrently": "^6.2.0",
"esbuild": "^0.12.15",
"@web/dev-server": "^0.1.22",
"typescript": "^4.3.5"

@@ -32,0 +32,0 @@ },

@@ -6,22 +6,20 @@ {

/* Basic Options */
"incremental": true, /* Enable incremental compilation */
//"target": "es2018", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"lib": ["es2017", "DOM"], /* Specify library files to be included in the compilation. */
"noEmitOnError": true,
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"lib": ["esnext", "dom"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
"outFile": "dist/index.d.ts", /* Concatenate and emit output to single file. */
"outDir": "dist", /* Redirect output structure to the directory. */
"rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
"tsBuildInfoFile": "./index.tsbuildinfo", /* Specify file to store incremental compilation information */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
"importHelpers": true, /* Import emit helpers from 'tslib'. */
"emitDeclarationOnly": true,
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */

@@ -50,3 +48,3 @@ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */

@@ -57,3 +55,3 @@ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */

// "types": [], /* Type declaration files to be included in compilation. */
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */

@@ -67,6 +65,6 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */

// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
"inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */

@@ -78,3 +76,3 @@

},
"include": ["**/*.ts"]
"include": ["./index.ts"]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc