sessioncontact 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +34 -33
- package/dist/index.mjs +34 -33
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -36,13 +36,17 @@
|
|
|
36
36
|
interface SessionContactSettings {
|
|
37
37
|
/** Your SessionContact app ID (required) */
|
|
38
38
|
app_id: string;
|
|
39
|
+
/** Convex URL for real-time connection */
|
|
40
|
+
convex_url?: string;
|
|
41
|
+
/** JWT identity token for user verification */
|
|
42
|
+
identity_token?: string;
|
|
39
43
|
/** Unique identifier for the user */
|
|
40
44
|
user_id?: string;
|
|
41
45
|
/** User's email address */
|
|
42
46
|
email?: string;
|
|
43
47
|
/** User's display name */
|
|
44
48
|
name?: string;
|
|
45
|
-
/** Server-generated hash for identity verification */
|
|
49
|
+
/** Server-generated hash for identity verification (deprecated, use identity_token) */
|
|
46
50
|
user_hash?: string;
|
|
47
51
|
/** Custom attributes for the user */
|
|
48
52
|
custom_attributes?: Record<string, any>;
|
|
@@ -52,8 +56,14 @@ interface SessionContactSettings {
|
|
|
52
56
|
declare global {
|
|
53
57
|
interface Window {
|
|
54
58
|
sessionContactSettings?: SessionContactSettings;
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
sessionChatSettings?: {
|
|
60
|
+
orgId: string;
|
|
61
|
+
convexUrl?: string;
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
};
|
|
64
|
+
SessionChat?: {
|
|
65
|
+
init: (config?: any) => void;
|
|
66
|
+
destroy: () => void;
|
|
57
67
|
};
|
|
58
68
|
}
|
|
59
69
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -36,13 +36,17 @@
|
|
|
36
36
|
interface SessionContactSettings {
|
|
37
37
|
/** Your SessionContact app ID (required) */
|
|
38
38
|
app_id: string;
|
|
39
|
+
/** Convex URL for real-time connection */
|
|
40
|
+
convex_url?: string;
|
|
41
|
+
/** JWT identity token for user verification */
|
|
42
|
+
identity_token?: string;
|
|
39
43
|
/** Unique identifier for the user */
|
|
40
44
|
user_id?: string;
|
|
41
45
|
/** User's email address */
|
|
42
46
|
email?: string;
|
|
43
47
|
/** User's display name */
|
|
44
48
|
name?: string;
|
|
45
|
-
/** Server-generated hash for identity verification */
|
|
49
|
+
/** Server-generated hash for identity verification (deprecated, use identity_token) */
|
|
46
50
|
user_hash?: string;
|
|
47
51
|
/** Custom attributes for the user */
|
|
48
52
|
custom_attributes?: Record<string, any>;
|
|
@@ -52,8 +56,14 @@ interface SessionContactSettings {
|
|
|
52
56
|
declare global {
|
|
53
57
|
interface Window {
|
|
54
58
|
sessionContactSettings?: SessionContactSettings;
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
sessionChatSettings?: {
|
|
60
|
+
orgId: string;
|
|
61
|
+
convexUrl?: string;
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
};
|
|
64
|
+
SessionChat?: {
|
|
65
|
+
init: (config?: any) => void;
|
|
66
|
+
destroy: () => void;
|
|
57
67
|
};
|
|
58
68
|
}
|
|
59
69
|
}
|
package/dist/index.js
CHANGED
|
@@ -24,72 +24,73 @@ __export(index_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(index_exports);
|
|
26
26
|
var initialized = false;
|
|
27
|
-
var pendingCallbacks = [];
|
|
28
27
|
function SessionContact(settings) {
|
|
29
|
-
var _a;
|
|
28
|
+
var _a, _b;
|
|
30
29
|
if (typeof window === "undefined") return;
|
|
31
30
|
window.sessionContactSettings = settings;
|
|
31
|
+
window.sessionChatSettings = {
|
|
32
|
+
orgId: settings.app_id,
|
|
33
|
+
convexUrl: settings.convex_url,
|
|
34
|
+
// Pass through user identity if provided
|
|
35
|
+
...settings.identity_token && { identityToken: settings.identity_token },
|
|
36
|
+
...settings.user_id && { userId: settings.user_id },
|
|
37
|
+
...settings.email && { email: settings.email },
|
|
38
|
+
...settings.name && { name: settings.name }
|
|
39
|
+
};
|
|
32
40
|
if (!initialized) {
|
|
33
41
|
const script = document.createElement("script");
|
|
34
|
-
script.src =
|
|
42
|
+
script.src = "https://widget.sessioncontact.com/sessioncontact-widget.js";
|
|
35
43
|
script.async = true;
|
|
36
44
|
script.onload = () => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
pendingCallbacks = [];
|
|
45
|
+
if (window.SessionChat && !document.getElementById("sessioncontact-chat-widget")) {
|
|
46
|
+
window.SessionChat.init();
|
|
47
|
+
}
|
|
42
48
|
};
|
|
43
49
|
document.head.appendChild(script);
|
|
44
50
|
initialized = true;
|
|
45
51
|
} else {
|
|
46
|
-
(_a = window.
|
|
52
|
+
(_a = window.SessionChat) == null ? void 0 : _a.destroy();
|
|
53
|
+
(_b = window.SessionChat) == null ? void 0 : _b.init();
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
SessionContact.show = () => {
|
|
50
|
-
|
|
51
|
-
(_a = window.SessionContactWidget) == null ? void 0 : _a.call(window, "show");
|
|
57
|
+
console.log("SessionContact.show() - not yet implemented in widget");
|
|
52
58
|
};
|
|
53
59
|
SessionContact.hide = () => {
|
|
54
|
-
|
|
55
|
-
(_a = window.SessionContactWidget) == null ? void 0 : _a.call(window, "hide");
|
|
60
|
+
console.log("SessionContact.hide() - not yet implemented in widget");
|
|
56
61
|
};
|
|
57
62
|
SessionContact.update = (data) => {
|
|
58
|
-
var _a;
|
|
59
63
|
if (window.sessionContactSettings) {
|
|
60
64
|
window.sessionContactSettings = { ...window.sessionContactSettings, ...data };
|
|
61
65
|
}
|
|
62
|
-
(
|
|
66
|
+
if (window.sessionChatSettings) {
|
|
67
|
+
window.sessionChatSettings = {
|
|
68
|
+
...window.sessionChatSettings,
|
|
69
|
+
...data.app_id && { orgId: data.app_id },
|
|
70
|
+
...data.identity_token && { identityToken: data.identity_token },
|
|
71
|
+
...data.user_id && { userId: data.user_id },
|
|
72
|
+
...data.email && { email: data.email },
|
|
73
|
+
...data.name && { name: data.name }
|
|
74
|
+
};
|
|
75
|
+
}
|
|
63
76
|
};
|
|
64
77
|
SessionContact.shutdown = () => {
|
|
65
78
|
var _a;
|
|
66
|
-
(_a = window.
|
|
79
|
+
(_a = window.SessionChat) == null ? void 0 : _a.destroy();
|
|
67
80
|
window.sessionContactSettings = void 0;
|
|
81
|
+
window.sessionChatSettings = void 0;
|
|
68
82
|
initialized = false;
|
|
69
83
|
};
|
|
70
84
|
SessionContact.onShow = (callback) => {
|
|
71
|
-
|
|
72
|
-
window.SessionContactWidget("onShow", callback);
|
|
73
|
-
} else {
|
|
74
|
-
pendingCallbacks.push({ event: "onShow", callback });
|
|
75
|
-
}
|
|
85
|
+
console.log("SessionContact.onShow() - not yet implemented in widget");
|
|
76
86
|
};
|
|
77
87
|
SessionContact.onHide = (callback) => {
|
|
78
|
-
|
|
79
|
-
window.SessionContactWidget("onHide", callback);
|
|
80
|
-
} else {
|
|
81
|
-
pendingCallbacks.push({ event: "onHide", callback });
|
|
82
|
-
}
|
|
88
|
+
console.log("SessionContact.onHide() - not yet implemented in widget");
|
|
83
89
|
};
|
|
84
90
|
SessionContact.onMessage = (callback) => {
|
|
85
|
-
|
|
86
|
-
window.SessionContactWidget("onMessage", callback);
|
|
87
|
-
} else {
|
|
88
|
-
pendingCallbacks.push({ event: "onMessage", callback });
|
|
89
|
-
}
|
|
91
|
+
console.log("SessionContact.onMessage() - not yet implemented in widget");
|
|
90
92
|
};
|
|
91
93
|
SessionContact.getUnreadCount = () => {
|
|
92
|
-
|
|
93
|
-
return (_b = (_a = window.SessionContactWidget) == null ? void 0 : _a.call(window, "getUnreadCount")) != null ? _b : 0;
|
|
94
|
+
return 0;
|
|
94
95
|
};
|
|
95
96
|
var index_default = SessionContact;
|
package/dist/index.mjs
CHANGED
|
@@ -1,72 +1,73 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
var initialized = false;
|
|
3
|
-
var pendingCallbacks = [];
|
|
4
3
|
function SessionContact(settings) {
|
|
5
|
-
var _a;
|
|
4
|
+
var _a, _b;
|
|
6
5
|
if (typeof window === "undefined") return;
|
|
7
6
|
window.sessionContactSettings = settings;
|
|
7
|
+
window.sessionChatSettings = {
|
|
8
|
+
orgId: settings.app_id,
|
|
9
|
+
convexUrl: settings.convex_url,
|
|
10
|
+
// Pass through user identity if provided
|
|
11
|
+
...settings.identity_token && { identityToken: settings.identity_token },
|
|
12
|
+
...settings.user_id && { userId: settings.user_id },
|
|
13
|
+
...settings.email && { email: settings.email },
|
|
14
|
+
...settings.name && { name: settings.name }
|
|
15
|
+
};
|
|
8
16
|
if (!initialized) {
|
|
9
17
|
const script = document.createElement("script");
|
|
10
|
-
script.src =
|
|
18
|
+
script.src = "https://widget.sessioncontact.com/sessioncontact-widget.js";
|
|
11
19
|
script.async = true;
|
|
12
20
|
script.onload = () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
pendingCallbacks = [];
|
|
21
|
+
if (window.SessionChat && !document.getElementById("sessioncontact-chat-widget")) {
|
|
22
|
+
window.SessionChat.init();
|
|
23
|
+
}
|
|
18
24
|
};
|
|
19
25
|
document.head.appendChild(script);
|
|
20
26
|
initialized = true;
|
|
21
27
|
} else {
|
|
22
|
-
(_a = window.
|
|
28
|
+
(_a = window.SessionChat) == null ? void 0 : _a.destroy();
|
|
29
|
+
(_b = window.SessionChat) == null ? void 0 : _b.init();
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
32
|
SessionContact.show = () => {
|
|
26
|
-
|
|
27
|
-
(_a = window.SessionContactWidget) == null ? void 0 : _a.call(window, "show");
|
|
33
|
+
console.log("SessionContact.show() - not yet implemented in widget");
|
|
28
34
|
};
|
|
29
35
|
SessionContact.hide = () => {
|
|
30
|
-
|
|
31
|
-
(_a = window.SessionContactWidget) == null ? void 0 : _a.call(window, "hide");
|
|
36
|
+
console.log("SessionContact.hide() - not yet implemented in widget");
|
|
32
37
|
};
|
|
33
38
|
SessionContact.update = (data) => {
|
|
34
|
-
var _a;
|
|
35
39
|
if (window.sessionContactSettings) {
|
|
36
40
|
window.sessionContactSettings = { ...window.sessionContactSettings, ...data };
|
|
37
41
|
}
|
|
38
|
-
(
|
|
42
|
+
if (window.sessionChatSettings) {
|
|
43
|
+
window.sessionChatSettings = {
|
|
44
|
+
...window.sessionChatSettings,
|
|
45
|
+
...data.app_id && { orgId: data.app_id },
|
|
46
|
+
...data.identity_token && { identityToken: data.identity_token },
|
|
47
|
+
...data.user_id && { userId: data.user_id },
|
|
48
|
+
...data.email && { email: data.email },
|
|
49
|
+
...data.name && { name: data.name }
|
|
50
|
+
};
|
|
51
|
+
}
|
|
39
52
|
};
|
|
40
53
|
SessionContact.shutdown = () => {
|
|
41
54
|
var _a;
|
|
42
|
-
(_a = window.
|
|
55
|
+
(_a = window.SessionChat) == null ? void 0 : _a.destroy();
|
|
43
56
|
window.sessionContactSettings = void 0;
|
|
57
|
+
window.sessionChatSettings = void 0;
|
|
44
58
|
initialized = false;
|
|
45
59
|
};
|
|
46
60
|
SessionContact.onShow = (callback) => {
|
|
47
|
-
|
|
48
|
-
window.SessionContactWidget("onShow", callback);
|
|
49
|
-
} else {
|
|
50
|
-
pendingCallbacks.push({ event: "onShow", callback });
|
|
51
|
-
}
|
|
61
|
+
console.log("SessionContact.onShow() - not yet implemented in widget");
|
|
52
62
|
};
|
|
53
63
|
SessionContact.onHide = (callback) => {
|
|
54
|
-
|
|
55
|
-
window.SessionContactWidget("onHide", callback);
|
|
56
|
-
} else {
|
|
57
|
-
pendingCallbacks.push({ event: "onHide", callback });
|
|
58
|
-
}
|
|
64
|
+
console.log("SessionContact.onHide() - not yet implemented in widget");
|
|
59
65
|
};
|
|
60
66
|
SessionContact.onMessage = (callback) => {
|
|
61
|
-
|
|
62
|
-
window.SessionContactWidget("onMessage", callback);
|
|
63
|
-
} else {
|
|
64
|
-
pendingCallbacks.push({ event: "onMessage", callback });
|
|
65
|
-
}
|
|
67
|
+
console.log("SessionContact.onMessage() - not yet implemented in widget");
|
|
66
68
|
};
|
|
67
69
|
SessionContact.getUnreadCount = () => {
|
|
68
|
-
|
|
69
|
-
return (_b = (_a = window.SessionContactWidget) == null ? void 0 : _a.call(window, "getUnreadCount")) != null ? _b : 0;
|
|
70
|
+
return 0;
|
|
70
71
|
};
|
|
71
72
|
var index_default = SessionContact;
|
|
72
73
|
export {
|