@meetelise/chat
Advanced tools
Comparing version 1.0.0-rc.6 to 1.0.0-rc.7
@@ -11,2 +11,5 @@ declare module "src/fetchBuildingInfo" { | ||
} | ||
declare module "src/getChatID" { | ||
export function getChatID(): string; | ||
} | ||
declare module "src/startTalkJS" { | ||
@@ -13,0 +16,0 @@ import { Building } from "src/fetchBuildingInfo"; |
@@ -31,2 +31,67 @@ // src/fetchBuildingInfo.ts | ||
// 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/getChatID.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; | ||
} | ||
// src/startTalkJS.ts | ||
@@ -36,3 +101,3 @@ async function startTalkJS(building) { | ||
const me = new index_esnext_default.User({ | ||
id: `lead_${(Math.random() * 1e8).toFixed(0)}`, | ||
id: "anonymous", | ||
name: "Me", | ||
@@ -54,5 +119,8 @@ email: null, | ||
}); | ||
const conversation = session.getOrCreateConversation(index_esnext_default.oneOnOneId(me, agent)); | ||
const conversation = session.getOrCreateConversation(getChatID()); | ||
conversation.setParticipant(me); | ||
conversation.setParticipant(agent); | ||
conversation.custom = { | ||
buildingId: building.id.toString() | ||
}; | ||
const popup = session.createPopup(conversation); | ||
@@ -59,0 +127,0 @@ return popup.mount({ show: false }); |
{ | ||
"name": "@meetelise/chat", | ||
"version": "1.0.0-rc.6", | ||
"version": "1.0.0-rc.7", | ||
"description": "", | ||
@@ -12,3 +12,3 @@ "main": "dist/index.js", | ||
"build": "tsc --listEmittedFiles && esbuild index.ts --format=esm --bundle --sourcemap --outfile=dist/index.js", | ||
"prepublish": "npm run build" | ||
"prepublishOnly": "npm run build" | ||
}, | ||
@@ -15,0 +15,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25352
265