@chanl/widget-sdk 0.2.0-canary.0

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.
Files changed (128) hide show
  1. package/README.md +257 -0
  2. package/dist/auth.d.ts +26 -0
  3. package/dist/auth.d.ts.map +1 -0
  4. package/dist/auth.js +36 -0
  5. package/dist/auth.js.map +1 -0
  6. package/dist/chat/chat-client.d.ts +81 -0
  7. package/dist/chat/chat-client.d.ts.map +1 -0
  8. package/dist/chat/chat-client.js +192 -0
  9. package/dist/chat/chat-client.js.map +1 -0
  10. package/dist/chat/stream-parser.d.ts +20 -0
  11. package/dist/chat/stream-parser.d.ts.map +1 -0
  12. package/dist/chat/stream-parser.js +134 -0
  13. package/dist/chat/stream-parser.js.map +1 -0
  14. package/dist/chat/widget-config.d.ts +7 -0
  15. package/dist/chat/widget-config.d.ts.map +1 -0
  16. package/dist/chat/widget-config.js +26 -0
  17. package/dist/chat/widget-config.js.map +1 -0
  18. package/dist/client.d.ts +66 -0
  19. package/dist/client.d.ts.map +1 -0
  20. package/dist/client.js +49 -0
  21. package/dist/client.js.map +1 -0
  22. package/dist/defaults.d.ts +12 -0
  23. package/dist/defaults.d.ts.map +1 -0
  24. package/dist/defaults.js +27 -0
  25. package/dist/defaults.js.map +1 -0
  26. package/dist/embed/loader-types.d.ts +119 -0
  27. package/dist/embed/loader-types.d.ts.map +1 -0
  28. package/dist/embed/loader-types.js +20 -0
  29. package/dist/embed/loader-types.js.map +1 -0
  30. package/dist/embed/loader.d.ts +101 -0
  31. package/dist/embed/loader.d.ts.map +1 -0
  32. package/dist/embed/loader.js +439 -0
  33. package/dist/embed/loader.js.map +1 -0
  34. package/dist/embed/v1.global.js +5 -0
  35. package/dist/embed/v1.global.js.map +1 -0
  36. package/dist/events.d.ts +10 -0
  37. package/dist/events.d.ts.map +1 -0
  38. package/dist/events.js +25 -0
  39. package/dist/events.js.map +1 -0
  40. package/dist/index.d.ts +19 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +29 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/logger.d.ts +14 -0
  45. package/dist/logger.d.ts.map +1 -0
  46. package/dist/logger.js +3 -0
  47. package/dist/logger.js.map +1 -0
  48. package/dist/next/index.d.ts +58 -0
  49. package/dist/next/index.d.ts.map +1 -0
  50. package/dist/next/index.js +83 -0
  51. package/dist/next/index.js.map +1 -0
  52. package/dist/react/index.d.ts +16 -0
  53. package/dist/react/index.d.ts.map +1 -0
  54. package/dist/react/index.js +20 -0
  55. package/dist/react/index.js.map +1 -0
  56. package/dist/react/types.d.ts +27 -0
  57. package/dist/react/types.d.ts.map +1 -0
  58. package/dist/react/types.js +8 -0
  59. package/dist/react/types.js.map +1 -0
  60. package/dist/react/use-chanl.d.ts +27 -0
  61. package/dist/react/use-chanl.d.ts.map +1 -0
  62. package/dist/react/use-chanl.js +57 -0
  63. package/dist/react/use-chanl.js.map +1 -0
  64. package/dist/react/use-chat.d.ts +32 -0
  65. package/dist/react/use-chat.d.ts.map +1 -0
  66. package/dist/react/use-chat.js +224 -0
  67. package/dist/react/use-chat.js.map +1 -0
  68. package/dist/react/use-voice.d.ts +37 -0
  69. package/dist/react/use-voice.d.ts.map +1 -0
  70. package/dist/react/use-voice.js +268 -0
  71. package/dist/react/use-voice.js.map +1 -0
  72. package/dist/react/widget.d.ts +43 -0
  73. package/dist/react/widget.d.ts.map +1 -0
  74. package/dist/react/widget.js +188 -0
  75. package/dist/react/widget.js.map +1 -0
  76. package/dist/storage/session-storage.d.ts +48 -0
  77. package/dist/storage/session-storage.d.ts.map +1 -0
  78. package/dist/storage/session-storage.js +84 -0
  79. package/dist/storage/session-storage.js.map +1 -0
  80. package/dist/types.d.ts +140 -0
  81. package/dist/types.d.ts.map +1 -0
  82. package/dist/types.js +7 -0
  83. package/dist/types.js.map +1 -0
  84. package/dist/voice/audio-recorder.d.ts +43 -0
  85. package/dist/voice/audio-recorder.d.ts.map +1 -0
  86. package/dist/voice/audio-recorder.js +127 -0
  87. package/dist/voice/audio-recorder.js.map +1 -0
  88. package/dist/voice/index.d.ts +13 -0
  89. package/dist/voice/index.d.ts.map +1 -0
  90. package/dist/voice/index.js +16 -0
  91. package/dist/voice/index.js.map +1 -0
  92. package/dist/voice/mock-mode.d.ts +93 -0
  93. package/dist/voice/mock-mode.d.ts.map +1 -0
  94. package/dist/voice/mock-mode.js +375 -0
  95. package/dist/voice/mock-mode.js.map +1 -0
  96. package/dist/voice/transports/index.d.ts +5 -0
  97. package/dist/voice/transports/index.d.ts.map +1 -0
  98. package/dist/voice/transports/index.js +10 -0
  99. package/dist/voice/transports/index.js.map +1 -0
  100. package/dist/voice/transports/transport.d.ts +70 -0
  101. package/dist/voice/transports/transport.d.ts.map +1 -0
  102. package/dist/voice/transports/transport.js +12 -0
  103. package/dist/voice/transports/transport.js.map +1 -0
  104. package/dist/voice/transports/vapi.d.ts +147 -0
  105. package/dist/voice/transports/vapi.d.ts.map +1 -0
  106. package/dist/voice/transports/vapi.js +337 -0
  107. package/dist/voice/transports/vapi.js.map +1 -0
  108. package/dist/voice/transports/webrtc.d.ts +58 -0
  109. package/dist/voice/transports/webrtc.d.ts.map +1 -0
  110. package/dist/voice/transports/webrtc.js +318 -0
  111. package/dist/voice/transports/webrtc.js.map +1 -0
  112. package/dist/voice/transports/websocket.d.ts +39 -0
  113. package/dist/voice/transports/websocket.d.ts.map +1 -0
  114. package/dist/voice/transports/websocket.js +280 -0
  115. package/dist/voice/transports/websocket.js.map +1 -0
  116. package/dist/voice/types.d.ts +323 -0
  117. package/dist/voice/types.d.ts.map +1 -0
  118. package/dist/voice/types.js +41 -0
  119. package/dist/voice/types.js.map +1 -0
  120. package/dist/voice/utils.d.ts +22 -0
  121. package/dist/voice/utils.d.ts.map +1 -0
  122. package/dist/voice/utils.js +44 -0
  123. package/dist/voice/utils.js.map +1 -0
  124. package/dist/voice/voice-client.d.ts +231 -0
  125. package/dist/voice/voice-client.d.ts.map +1 -0
  126. package/dist/voice/voice-client.js +1187 -0
  127. package/dist/voice/voice-client.js.map +1 -0
  128. package/package.json +91 -0
@@ -0,0 +1,439 @@
1
+ "use strict";
2
+ /**
3
+ * Chanl Chat Widget — Embed Loader
4
+ *
5
+ * <script src="https://chat.channel.tel/widget/v1.js"></script>
6
+ * <script>
7
+ * ChanlChat.init({
8
+ * agentId: 'ag_xxx',
9
+ * apiKey: 'pub_xxx',
10
+ * theme: 'dark',
11
+ * proactiveMessages: [
12
+ * { text: 'Hey! Need help?', delay: 2000 },
13
+ * { text: 'Ask me anything.', delay: 4000 },
14
+ * ],
15
+ * });
16
+ * </script>
17
+ *
18
+ * This file is the source of truth for the embed loader. It is bundled to
19
+ * `dist/embed/v1.js` as a self-contained IIFE with zero external deps. Any
20
+ * visual or behavioral change must preserve the current launcher + iframe
21
+ * look & feel — embedders rely on it.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ /* eslint-disable @typescript-eslint/no-explicit-any */
25
+ const session_storage_1 = require("../storage/session-storage");
26
+ (function () {
27
+ 'use strict';
28
+ if (typeof window === 'undefined')
29
+ return;
30
+ if (window.ChanlChat && window.ChanlChat._initialized)
31
+ window.ChanlChat.destroy();
32
+ // Host that serves the chat iframe. Defaults to the loader's origin so that
33
+ // `chat.channel.tel/widget/v1.js` → `chat.channel.tel/chat/<agentId>`.
34
+ const BASE = window.location.origin;
35
+ // Resolve platform API base URL — auto-detect dev vs prod.
36
+ function resolvePlatformBase(explicit) {
37
+ if (explicit)
38
+ return explicit;
39
+ const host = window.location.hostname;
40
+ if (host === 'localhost' || host === '127.0.0.1' || host.indexOf('.local') !== -1) {
41
+ return 'http://localhost:3100';
42
+ }
43
+ return 'https://platform.channel.tel';
44
+ }
45
+ const Z = 2147483647;
46
+ const s = {
47
+ open: false,
48
+ config: null,
49
+ iframe: null,
50
+ launcher: null,
51
+ chat: null,
52
+ toasts: null,
53
+ timers: [],
54
+ msgs: [],
55
+ listeners: {},
56
+ };
57
+ function css() {
58
+ if (document.getElementById('chanl-css'))
59
+ return;
60
+ const el = document.createElement('style');
61
+ el.id = 'chanl-css';
62
+ el.textContent = [
63
+ /* Launcher */
64
+ '.chanl-btn{position:fixed;bottom:20px;cursor:pointer;width:56px;height:56px;border-radius:50%;display:flex;align-items:center;justify-content:center;border:none;outline:none;padding:0;z-index:' +
65
+ Z +
66
+ ';transition:opacity .15s ease,box-shadow .15s ease;box-shadow:0 4px 16px -2px rgba(0,0,0,.2)}',
67
+ '.chanl-btn:hover{opacity:.85}',
68
+ '.chanl-btn svg{width:26px;height:26px}',
69
+ /* Chat iframe */
70
+ '.chanl-chat{position:fixed;bottom:88px;width:400px;height:620px;border-radius:16px;overflow:hidden;z-index:' +
71
+ Z +
72
+ ';opacity:0;transform:translateY(10px);transition:opacity .2s ease,transform .2s ease;pointer-events:none;box-shadow:0 20px 50px -10px rgba(0,0,0,.25),0 0 0 1px rgba(0,0,0,.05)}',
73
+ '.chanl-chat.open{opacity:1;transform:translateY(0);pointer-events:auto}',
74
+ '.chanl-chat iframe{width:100%;height:100%;border:none}',
75
+ /* Toast stack — simple column, newest at bottom */
76
+ '.chanl-toasts{position:fixed;bottom:88px;display:flex;flex-direction:column;gap:8px;z-index:' +
77
+ (Z - 1) +
78
+ ';max-width:300px}',
79
+ /* Individual toast */
80
+ '.chanl-toast{padding:12px 16px;border-radius:12px;background:#fff;color:#1a1a1a;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;font-size:14px;line-height:1.5;box-shadow:0 2px 12px -2px rgba(0,0,0,.1),0 1px 4px rgba(0,0,0,.06);cursor:pointer;opacity:0;transform:translateY(8px);transition:opacity .35s ease,transform .35s ease;width:fit-content;max-width:100%;align-self:flex-end}',
81
+ '.chanl-toast.show{opacity:1;transform:translateY(0)}',
82
+ '.chanl-toast:hover{background:#f5f5f5}',
83
+ /* Mobile */
84
+ '@media(max-width:480px){.chanl-chat{bottom:0!important;right:0!important;left:0!important;width:100%!important;height:100%!important;border-radius:0!important}.chanl-btn.hide{display:none!important}.chanl-toasts{right:12px!important;left:12px!important;max-width:100%}}',
85
+ ].join('\n');
86
+ document.head.appendChild(el);
87
+ }
88
+ const ICO_CHAT = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/></svg>';
89
+ const ICO_X = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>';
90
+ function side(cfg) {
91
+ return cfg.position === 'bottom-left' ? 'left' : 'right';
92
+ }
93
+ function mkLauncher(cfg) {
94
+ const b = document.createElement('button');
95
+ b.className = 'chanl-btn';
96
+ b.setAttribute('aria-label', 'Open chat');
97
+ b.style.backgroundColor = cfg.color || '#c0673b';
98
+ b.style.color = '#fff';
99
+ b.style[side(cfg)] = '20px';
100
+ b.innerHTML = ICO_CHAT;
101
+ b.onclick = function () {
102
+ window.ChanlChat.toggle();
103
+ };
104
+ document.body.appendChild(b);
105
+ return b;
106
+ }
107
+ function mkChat(cfg) {
108
+ const d = document.createElement('div');
109
+ d.className = 'chanl-chat';
110
+ d.style[side(cfg)] = '20px';
111
+ const p = new URLSearchParams();
112
+ p.set('theme', cfg.theme || 'dark');
113
+ if (cfg.branding === false)
114
+ p.set('branding', 'false');
115
+ if (cfg.locale)
116
+ p.set('locale', cfg.locale);
117
+ if (cfg.privacyUrl)
118
+ p.set('privacyUrl', cfg.privacyUrl);
119
+ if (cfg.agentName)
120
+ p.set('name', cfg.agentName);
121
+ if (cfg.agentSubtitle)
122
+ p.set('subtitle', cfg.agentSubtitle);
123
+ if (cfg.agentInitials)
124
+ p.set('initials', cfg.agentInitials);
125
+ if (cfg.agentAvatarUrl)
126
+ p.set('avatar', cfg.agentAvatarUrl);
127
+ if (cfg.greeting)
128
+ p.set('greeting', cfg.greeting);
129
+ if (cfg.placeholder)
130
+ p.set('placeholder', cfg.placeholder);
131
+ if (cfg.darkBg)
132
+ p.set('darkBg', cfg.darkBg);
133
+ if (cfg.apiKey)
134
+ p.set('apiKey', cfg.apiKey);
135
+ // Always set baseUrl (auto-resolved if not provided)
136
+ p.set('baseUrl', resolvePlatformBase(cfg.baseUrl));
137
+ // Session resume — if a previous session's JWT is stashed in localStorage,
138
+ // forward it to the iframe so the chat-client calls /resume instead of
139
+ // /chat on mount. localStorage is per-origin and the iframe is on a
140
+ // different origin (chat host) — so we read it here in the host origin
141
+ // and pass the value across via URL. The server-side JWT signature is
142
+ // the security boundary; URL-as-transport is fine because workspaceId +
143
+ // interactionId are tamper-evidently bound to it.
144
+ if (cfg.apiKey) {
145
+ const existingToken = (0, session_storage_1.readSessionToken)(cfg.apiKey, cfg.agentId);
146
+ if (existingToken)
147
+ p.set('sessionToken', existingToken);
148
+ }
149
+ const host = cfg.chatHost || BASE;
150
+ const f = document.createElement('iframe');
151
+ f.src = host + '/chat/' + cfg.agentId + '?' + p.toString();
152
+ f.allow = 'microphone';
153
+ f.title = 'Chanl Chat';
154
+ d.appendChild(f);
155
+ document.body.appendChild(d);
156
+ return { el: d, iframe: f };
157
+ }
158
+ /* ── Proactive toasts ── */
159
+ function mkToasts(cfg) {
160
+ const wrap = document.createElement('div');
161
+ wrap.className = 'chanl-toasts';
162
+ wrap.style[side(cfg)] = '20px';
163
+ document.body.appendChild(wrap);
164
+ return wrap;
165
+ }
166
+ function addToast(text, wrap) {
167
+ const t = document.createElement('div');
168
+ t.className = 'chanl-toast';
169
+ t.textContent = text;
170
+ t.onclick = function () {
171
+ window.ChanlChat.open();
172
+ };
173
+ wrap.appendChild(t);
174
+ s.msgs.push(text);
175
+ // trigger animation next frame
176
+ requestAnimationFrame(function () {
177
+ requestAnimationFrame(function () {
178
+ t.classList.add('show');
179
+ });
180
+ });
181
+ }
182
+ /**
183
+ * Schedule the proactive toast bubbles.
184
+ *
185
+ * @param cfg The current widget config (reads `proactiveMessages` from it)
186
+ * @param force When true, bypass the `if (!s.open)` guard so toasts show
187
+ * even if the chat panel is currently open. Used by `update()`
188
+ * — when a customer explicitly re-pushes proactive messages
189
+ * after init they want to see them immediately. The default
190
+ * (false) preserves the production behavior where toasts only
191
+ * fire when the chat is still closed.
192
+ */
193
+ function scheduleToasts(cfg, force) {
194
+ const list = cfg.proactiveMessages;
195
+ if (!list || !list.length)
196
+ return;
197
+ const wrap = mkToasts(cfg);
198
+ s.toasts = wrap;
199
+ list.forEach(function (m, i) {
200
+ const text = typeof m === 'string' ? m : m.text;
201
+ const delay = typeof m === 'string' ? 2000 + i * 1500 : m.delay || 2000 + i * 1500;
202
+ s.timers.push(setTimeout(function () {
203
+ if (force || !s.open)
204
+ addToast(text, wrap);
205
+ }, delay));
206
+ });
207
+ }
208
+ function clearToasts() {
209
+ s.timers.forEach(clearTimeout);
210
+ s.timers = [];
211
+ if (s.toasts) {
212
+ s.toasts.style.opacity = '0';
213
+ s.toasts.style.transition = 'opacity .25s ease';
214
+ const el = s.toasts;
215
+ setTimeout(function () {
216
+ el.remove();
217
+ }, 250);
218
+ s.toasts = null;
219
+ }
220
+ }
221
+ /* ── PostMessage ── */
222
+ function post(type, payload) {
223
+ if (s.iframe && s.iframe.contentWindow)
224
+ s.iframe.contentWindow.postMessage({ type: 'chanl:' + type, payload: payload }, '*');
225
+ }
226
+ window.addEventListener('message', function (e) {
227
+ if (!e.data || typeof e.data.type !== 'string' || !e.data.type.startsWith('chanl:'))
228
+ return;
229
+ const evt = e.data.type.replace('chanl:', '');
230
+ // Session-token lifecycle — the iframe issued/refreshed a JWT, or asked
231
+ // us to clear because the server rejected the token (4xx). The loader
232
+ // is the sole persistence boundary (iframe + host on different origins),
233
+ // so write/clear here. apiKey + agentId scope the storage key so a
234
+ // multi-agent host site (sales + support widgets) keeps independent
235
+ // resumable sessions.
236
+ if (s.config && s.config.apiKey) {
237
+ if (evt === 'session-token-issued') {
238
+ const payload = e.data.payload;
239
+ if (payload && typeof payload.token === 'string' && payload.token.length > 0) {
240
+ (0, session_storage_1.writeSessionToken)(s.config.apiKey, s.config.agentId, payload.token);
241
+ }
242
+ }
243
+ else if (evt === 'session-token-cleared') {
244
+ (0, session_storage_1.clearSessionToken)(s.config.apiKey, s.config.agentId);
245
+ }
246
+ }
247
+ emit(evt, e.data.payload);
248
+ });
249
+ function emit(n, d) {
250
+ (s.listeners[n] || []).forEach(function (fn) {
251
+ try {
252
+ fn(d);
253
+ }
254
+ catch (err) {
255
+ // eslint-disable-next-line no-console
256
+ console.error('[ChanlChat]', err);
257
+ }
258
+ });
259
+ }
260
+ /* ── API ── */
261
+ window.ChanlChat = {
262
+ _initialized: false,
263
+ init: function (cfg) {
264
+ if (!cfg || !cfg.agentId) {
265
+ // eslint-disable-next-line no-console
266
+ console.error('[ChanlChat] agentId required');
267
+ return;
268
+ }
269
+ s.config = Object.assign({
270
+ theme: 'dark',
271
+ position: 'bottom-right',
272
+ branding: true,
273
+ color: '#c0673b',
274
+ }, cfg);
275
+ css();
276
+ s.launcher = mkLauncher(s.config);
277
+ const c = mkChat(s.config);
278
+ s.chat = c.el;
279
+ s.iframe = c.iframe;
280
+ scheduleToasts(s.config);
281
+ this._initialized = true;
282
+ },
283
+ /**
284
+ * Live-update widget config without re-mounting the iframe.
285
+ * See `ChanlChatApi.update` JSDoc for the split between launcher-level
286
+ * and iframe-level fields.
287
+ */
288
+ update: function (partial) {
289
+ if (!s.config || !s.launcher) {
290
+ // eslint-disable-next-line no-console
291
+ console.warn('[ChanlChat] update() called before init()');
292
+ return;
293
+ }
294
+ // Fields that CANNOT be updated live — they'd require a different
295
+ // agent, session, or iframe URL. Warn + skip silently.
296
+ const frozen = ['agentId', 'apiKey', 'chatHost', 'baseUrl'];
297
+ const frozenChanged = frozen.filter(function (k) {
298
+ return k in partial && partial[k] !== s.config[k];
299
+ });
300
+ if (frozenChanged.length > 0) {
301
+ // eslint-disable-next-line no-console
302
+ console.warn('[ChanlChat] update() cannot change these fields live — use destroy() + init():', frozenChanged);
303
+ }
304
+ // ── 1. Merge into tracked config (drop frozen changes) ──
305
+ const next = Object.assign({}, s.config);
306
+ Object.keys(partial).forEach(function (k) {
307
+ if (frozen.indexOf(k) === -1 && partial[k] !== undefined) {
308
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
309
+ next[k] = partial[k];
310
+ }
311
+ });
312
+ s.config = next;
313
+ // ── 2. Launcher-level DOM patches ──
314
+ if ('color' in partial && partial.color && s.launcher) {
315
+ s.launcher.style.backgroundColor = partial.color;
316
+ }
317
+ if ('position' in partial && partial.position) {
318
+ const newSide = side(s.config);
319
+ const oldSide = newSide === 'left' ? 'right' : 'left';
320
+ // Launcher
321
+ if (s.launcher) {
322
+ s.launcher.style[oldSide] = '';
323
+ s.launcher.style[newSide] = '20px';
324
+ }
325
+ // Chat panel
326
+ if (s.chat) {
327
+ s.chat.style[oldSide] = '';
328
+ s.chat.style[newSide] = '20px';
329
+ }
330
+ // Toasts stack
331
+ if (s.toasts) {
332
+ s.toasts.style[oldSide] = '';
333
+ s.toasts.style[newSide] = '20px';
334
+ }
335
+ }
336
+ if ('proactiveMessages' in partial) {
337
+ // Teardown + re-schedule with the new list. Pass force=true so the
338
+ // toasts fire even if the chat panel is already open — the customer
339
+ // is explicitly re-pushing proactive messages after init and expects
340
+ // to see them immediately. (At init time, the chat is closed by
341
+ // default and the open-check is sufficient.)
342
+ clearToasts();
343
+ s.msgs = [];
344
+ scheduleToasts(s.config, true);
345
+ }
346
+ // ── 3. Iframe-level postMessage ──
347
+ // Any remaining fields that the chat page cares about get forwarded.
348
+ // The chat page listens for `chanl:update-config` and merges them into
349
+ // its own React state.
350
+ const iframeKeys = [
351
+ 'theme',
352
+ 'agentName',
353
+ 'agentSubtitle',
354
+ 'agentInitials',
355
+ 'agentAvatarUrl',
356
+ 'greeting',
357
+ 'placeholder',
358
+ 'privacyUrl',
359
+ 'branding',
360
+ 'darkBg',
361
+ 'locale',
362
+ ];
363
+ const iframePatch = {};
364
+ let hasIframePatch = false;
365
+ iframeKeys.forEach(function (k) {
366
+ if (k in partial) {
367
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
368
+ iframePatch[k] = partial[k];
369
+ hasIframePatch = true;
370
+ }
371
+ });
372
+ if (hasIframePatch)
373
+ post('update-config', iframePatch);
374
+ },
375
+ open: function () {
376
+ if (!s.chat)
377
+ return;
378
+ s.open = true;
379
+ clearToasts();
380
+ s.chat.classList.add('open');
381
+ if (s.launcher)
382
+ s.launcher.innerHTML = ICO_X;
383
+ // Send proactive messages into the chat
384
+ if (s.msgs.length) {
385
+ setTimeout(function () {
386
+ post('init-messages', s.msgs);
387
+ s.msgs = [];
388
+ }, 500);
389
+ }
390
+ emit('open');
391
+ },
392
+ close: function () {
393
+ if (!s.chat)
394
+ return;
395
+ s.open = false;
396
+ s.chat.classList.remove('open');
397
+ if (s.launcher)
398
+ s.launcher.innerHTML = ICO_CHAT;
399
+ emit('close');
400
+ },
401
+ toggle: function () {
402
+ if (s.open)
403
+ this.close();
404
+ else
405
+ this.open();
406
+ },
407
+ destroy: function () {
408
+ clearToasts();
409
+ if (s.launcher)
410
+ s.launcher.remove();
411
+ if (s.chat)
412
+ s.chat.remove();
413
+ s.open = false;
414
+ s.iframe = null;
415
+ s.launcher = null;
416
+ s.chat = null;
417
+ s.msgs = [];
418
+ this._initialized = false;
419
+ },
420
+ setUser: function (u) {
421
+ post('set-user', u);
422
+ },
423
+ setContext: function (c) {
424
+ post('set-context', c);
425
+ },
426
+ sendMessage: function (t) {
427
+ post('send-message', { text: t });
428
+ },
429
+ on: function (e, fn) {
430
+ (s.listeners[e] = s.listeners[e] || []).push(fn);
431
+ },
432
+ off: function (e, fn) {
433
+ s.listeners[e] = (s.listeners[e] || []).filter(function (f) {
434
+ return f !== fn;
435
+ });
436
+ },
437
+ };
438
+ })();
439
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1 @@
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cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE;YACjB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,GAAG,EAAE,UAAU,CAAC,EAAE,EAAE;YAClB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;gBACxD,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ (function(){'use strict';/*! @chanl/widget-sdk embed loader v1 — https://github.com/chanl-ai/chanl-sdk */
2
+ var L="_chanl_session_";function C(s,r){return `${L}${s}_${r}`}function x(s,r){if(typeof window=="undefined"||!window.localStorage)return null;try{return window.localStorage.getItem(C(s,r))}catch(d){return null}}function v(s,r,d){if(!(typeof window=="undefined"||!window.localStorage))try{window.localStorage.setItem(C(s,r),d);}catch(n){}}function b(s,r){if(!(typeof window=="undefined"||!window.localStorage))try{window.localStorage.removeItem(C(s,r));}catch(d){}}(function(){if(typeof window=="undefined")return;window.ChanlChat&&window.ChanlChat._initialized&&window.ChanlChat.destroy();let s=window.location.origin;function r(t){if(t)return t;let e=window.location.hostname;return e==="localhost"||e==="127.0.0.1"||e.indexOf(".local")!==-1?"http://localhost:3100":"https://platform.channel.tel"}let d=2147483647,n={open:false,config:null,iframe:null,launcher:null,chat:null,toasts:null,timers:[],msgs:[],listeners:{}};function k(){if(document.getElementById("chanl-css"))return;let t=document.createElement("style");t.id="chanl-css",t.textContent=[".chanl-btn{position:fixed;bottom:20px;cursor:pointer;width:56px;height:56px;border-radius:50%;display:flex;align-items:center;justify-content:center;border:none;outline:none;padding:0;z-index:"+d+";transition:opacity .15s ease,box-shadow .15s ease;box-shadow:0 4px 16px -2px rgba(0,0,0,.2)}",".chanl-btn:hover{opacity:.85}",".chanl-btn svg{width:26px;height:26px}",".chanl-chat{position:fixed;bottom:88px;width:400px;height:620px;border-radius:16px;overflow:hidden;z-index:"+d+";opacity:0;transform:translateY(10px);transition:opacity .2s ease,transform .2s ease;pointer-events:none;box-shadow:0 20px 50px -10px rgba(0,0,0,.25),0 0 0 1px rgba(0,0,0,.05)}",".chanl-chat.open{opacity:1;transform:translateY(0);pointer-events:auto}",".chanl-chat iframe{width:100%;height:100%;border:none}",".chanl-toasts{position:fixed;bottom:88px;display:flex;flex-direction:column;gap:8px;z-index:"+(d-1)+";max-width:300px}",'.chanl-toast{padding:12px 16px;border-radius:12px;background:#fff;color:#1a1a1a;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;font-size:14px;line-height:1.5;box-shadow:0 2px 12px -2px rgba(0,0,0,.1),0 1px 4px rgba(0,0,0,.06);cursor:pointer;opacity:0;transform:translateY(8px);transition:opacity .35s ease,transform .35s ease;width:fit-content;max-width:100%;align-self:flex-end}',".chanl-toast.show{opacity:1;transform:translateY(0)}",".chanl-toast:hover{background:#f5f5f5}","@media(max-width:480px){.chanl-chat{bottom:0!important;right:0!important;left:0!important;width:100%!important;height:100%!important;border-radius:0!important}.chanl-btn.hide{display:none!important}.chanl-toasts{right:12px!important;left:12px!important;max-width:100%}}"].join(`
3
+ `),document.head.appendChild(t);}let y='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/></svg>',I='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>';function f(t){return t.position==="bottom-left"?"left":"right"}function T(t){let e=document.createElement("button");return e.className="chanl-btn",e.setAttribute("aria-label","Open chat"),e.style.backgroundColor=t.color||"#c0673b",e.style.color="#fff",e.style[f(t)]="20px",e.innerHTML=y,e.onclick=function(){window.ChanlChat.toggle();},document.body.appendChild(e),e}function E(t){let e=document.createElement("div");e.className="chanl-chat",e.style[f(t)]="20px";let o=new URLSearchParams;if(o.set("theme",t.theme||"dark"),t.branding===false&&o.set("branding","false"),t.locale&&o.set("locale",t.locale),t.privacyUrl&&o.set("privacyUrl",t.privacyUrl),t.agentName&&o.set("name",t.agentName),t.agentSubtitle&&o.set("subtitle",t.agentSubtitle),t.agentInitials&&o.set("initials",t.agentInitials),t.agentAvatarUrl&&o.set("avatar",t.agentAvatarUrl),t.greeting&&o.set("greeting",t.greeting),t.placeholder&&o.set("placeholder",t.placeholder),t.darkBg&&o.set("darkBg",t.darkBg),t.apiKey&&o.set("apiKey",t.apiKey),o.set("baseUrl",r(t.baseUrl)),t.apiKey){let c=x(t.apiKey,t.agentId);c&&o.set("sessionToken",c);}let l=t.chatHost||s,a=document.createElement("iframe");return a.src=l+"/chat/"+t.agentId+"?"+o.toString(),a.allow="microphone",a.title="Chanl Chat",e.appendChild(a),document.body.appendChild(e),{el:e,iframe:a}}function S(t){let e=document.createElement("div");return e.className="chanl-toasts",e.style[f(t)]="20px",document.body.appendChild(e),e}function M(t,e){let o=document.createElement("div");o.className="chanl-toast",o.textContent=t,o.onclick=function(){window.ChanlChat.open();},e.appendChild(o),n.msgs.push(t),requestAnimationFrame(function(){requestAnimationFrame(function(){o.classList.add("show");});});}function w(t,e){let o=t.proactiveMessages;if(!o||!o.length)return;let l=S(t);n.toasts=l,o.forEach(function(a,c){let u=typeof a=="string"?a:a.text,i=typeof a=="string"?2e3+c*1500:a.delay||2e3+c*1500;n.timers.push(setTimeout(function(){(e||!n.open)&&M(u,l);},i));});}function g(){if(n.timers.forEach(clearTimeout),n.timers=[],n.toasts){n.toasts.style.opacity="0",n.toasts.style.transition="opacity .25s ease";let t=n.toasts;setTimeout(function(){t.remove();},250),n.toasts=null;}}function h(t,e){n.iframe&&n.iframe.contentWindow&&n.iframe.contentWindow.postMessage({type:"chanl:"+t,payload:e},"*");}window.addEventListener("message",function(t){if(!t.data||typeof t.data.type!="string"||!t.data.type.startsWith("chanl:"))return;let e=t.data.type.replace("chanl:","");if(n.config&&n.config.apiKey)if(e==="session-token-issued"){let o=t.data.payload;o&&typeof o.token=="string"&&o.token.length>0&&v(n.config.apiKey,n.config.agentId,o.token);}else e==="session-token-cleared"&&b(n.config.apiKey,n.config.agentId);p(e,t.data.payload);});function p(t,e){(n.listeners[t]||[]).forEach(function(o){try{o(e);}catch(l){console.error("[ChanlChat]",l);}});}window.ChanlChat={_initialized:false,init:function(t){if(!t||!t.agentId){console.error("[ChanlChat] agentId required");return}n.config=Object.assign({theme:"dark",position:"bottom-right",branding:true,color:"#c0673b"},t),k(),n.launcher=T(n.config);let e=E(n.config);n.chat=e.el,n.iframe=e.iframe,w(n.config),this._initialized=true;},update:function(t){if(!n.config||!n.launcher){console.warn("[ChanlChat] update() called before init()");return}let e=["agentId","apiKey","chatHost","baseUrl"],o=e.filter(function(i){return i in t&&t[i]!==n.config[i]});o.length>0&&console.warn("[ChanlChat] update() cannot change these fields live \u2014 use destroy() + init():",o);let l=Object.assign({},n.config);if(Object.keys(t).forEach(function(i){e.indexOf(i)===-1&&t[i]!==void 0&&(l[i]=t[i]);}),n.config=l,"color"in t&&t.color&&n.launcher&&(n.launcher.style.backgroundColor=t.color),"position"in t&&t.position){let i=f(n.config),m=i==="left"?"right":"left";n.launcher&&(n.launcher.style[m]="",n.launcher.style[i]="20px"),n.chat&&(n.chat.style[m]="",n.chat.style[i]="20px"),n.toasts&&(n.toasts.style[m]="",n.toasts.style[i]="20px");}"proactiveMessages"in t&&(g(),n.msgs=[],w(n.config,true));let a=["theme","agentName","agentSubtitle","agentInitials","agentAvatarUrl","greeting","placeholder","privacyUrl","branding","darkBg","locale"],c={},u=false;a.forEach(function(i){i in t&&(c[i]=t[i],u=true);}),u&&h("update-config",c);},open:function(){n.chat&&(n.open=true,g(),n.chat.classList.add("open"),n.launcher&&(n.launcher.innerHTML=I),n.msgs.length&&setTimeout(function(){h("init-messages",n.msgs),n.msgs=[];},500),p("open"));},close:function(){n.chat&&(n.open=false,n.chat.classList.remove("open"),n.launcher&&(n.launcher.innerHTML=y),p("close"));},toggle:function(){n.open?this.close():this.open();},destroy:function(){g(),n.launcher&&n.launcher.remove(),n.chat&&n.chat.remove(),n.open=false,n.iframe=null,n.launcher=null,n.chat=null,n.msgs=[],this._initialized=false;},setUser:function(t){h("set-user",t);},setContext:function(t){h("set-context",t);},sendMessage:function(t){h("send-message",{text:t});},on:function(t,e){(n.listeners[t]=n.listeners[t]||[]).push(e);},off:function(t,e){n.listeners[t]=(n.listeners[t]||[]).filter(function(o){return o!==e});}};})();
4
+ })();//# sourceMappingURL=v1.global.js.map
5
+ //# sourceMappingURL=v1.global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/storage/session-storage.ts","../../src/embed/loader.ts"],"names":["KEY_PREFIX","makeKey","publicKey","agentId","readSessionToken","e","writeSessionToken","token","clearSessionToken","BASE","resolvePlatformBase","explicit","host","Z","s","css","el","ICO_CHAT","ICO_X","side","cfg","mkLauncher","b","mkChat","d","p","existingToken","f","mkToasts","wrap","addToast","text","t","scheduleToasts","force","list","m","i","delay","clearToasts","post","type","payload","evt","emit","n","fn","err","c","partial","frozen","frozenChanged","k","next","newSide","oldSide","iframeKeys","iframePatch","hasIframePatch","u"],"mappings":";AA+BA,IAAMA,CAAAA,CAAa,kBAEnB,SAASC,CAAAA,CAAQC,EAAmBC,CAAAA,CAAyB,CAC3D,OAAO,CAAA,EAAGH,CAAU,CAAA,EAAGE,CAAS,CAAA,CAAA,EAAIC,CAAO,CAAA,CAC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AE,SAAA,CAAUT,CAAC,GAAKS,CAAAA,CAAE,SAAA,CAAUT,CAAC,CAAA,EAAK,EAAC,EAAG,MAAA,CAAO,SAAUsB,CAAAA,CAAG,CAC1D,OAAOA,CAAAA,GAAMmB,CACf,CAAC,EACH,CACF,EACF,CAAA,GAAG","file":"v1.global.js","sourcesContent":["/**\n * Widget Session Storage — localStorage helpers for the persistent-session\n * feature (int-050).\n *\n * Lifecycle:\n * 1. Widget loader on host page reads `_chanl_session_{publicKey}_{agentId}`\n * on init.\n * 2. If present, loader passes the token into the iframe URL so the\n * chat-client can call GET /interactions/:id/resume.\n * 3. On createSession or successful resume, the iframe posts the new\n * token back to the loader via postMessage; loader writes it.\n * 4. On 4xx from resume (signature mismatch, expired, deleted), the\n * iframe posts `session-token-cleared`; loader clears the key.\n *\n * Per-publicKey + per-agent scoping: a single host site can mount multiple\n * agents (sales + support widgets side-by-side) — each gets its own\n * resumable session. publicKey is already in loader config; agentId is\n * already in the widget mount call. No extra wiring needed to namespace.\n *\n * Failure mode: localStorage can throw (Safari private mode, quota\n * exceeded, sandboxed iframe with storage blocked). All three helpers\n * catch and fail-silent so the widget keeps working — just without\n * resumability (= fresh session every load, the pre-int-050 behavior).\n *\n * Note: these helpers run in the LOADER's host-origin context. The chat\n * iframe is on a different origin and CANNOT touch this localStorage —\n * all I/O bounces through postMessage. Anyone tempted to call these from\n * inside the iframe will succeed locally but the loader won't see the\n * value because they're separate origin localStorage stores.\n */\n\nconst KEY_PREFIX = '_chanl_session_';\n\nfunction makeKey(publicKey: string, agentId: string): string {\n return `${KEY_PREFIX}${publicKey}_${agentId}`;\n}\n\n/**\n * Read a previously-stored session token. Returns the raw JWT string, or\n * `null` when no token exists, the storage call throws, or we're in a\n * non-browser context (SSR).\n */\nexport function readSessionToken(publicKey: string, agentId: string): string | null {\n if (typeof window === 'undefined' || !window.localStorage) return null;\n try {\n return window.localStorage.getItem(makeKey(publicKey, agentId));\n } catch {\n return null;\n }\n}\n\n/**\n * Persist a freshly-issued session token. No-op on storage error so the\n * widget continues to function (just without resumability on next load).\n */\nexport function writeSessionToken(publicKey: string, agentId: string, token: string): void {\n if (typeof window === 'undefined' || !window.localStorage) return;\n try {\n window.localStorage.setItem(makeKey(publicKey, agentId), token);\n } catch {\n // localStorage quota, sandboxed iframe, etc. Fail silent.\n }\n}\n\n/**\n * Clear the stored token. Called when the server tells us the token is no\n * longer valid (403/410/404) or when the host explicitly resets the\n * conversation via the \"New conversation\" button.\n */\nexport function clearSessionToken(publicKey: string, agentId: string): void {\n if (typeof window === 'undefined' || !window.localStorage) return;\n try {\n window.localStorage.removeItem(makeKey(publicKey, agentId));\n } catch {\n // ignore\n }\n}\n","/**\n * Chanl Chat Widget — Embed Loader\n *\n * <script src=\"https://chat.channel.tel/widget/v1.js\"></script>\n * <script>\n * ChanlChat.init({\n * agentId: 'ag_xxx',\n * apiKey: 'pub_xxx',\n * theme: 'dark',\n * proactiveMessages: [\n * { text: 'Hey! Need help?', delay: 2000 },\n * { text: 'Ask me anything.', delay: 4000 },\n * ],\n * });\n * </script>\n *\n * This file is the source of truth for the embed loader. It is bundled to\n * `dist/embed/v1.js` as a self-contained IIFE with zero external deps. Any\n * visual or behavioral change must preserve the current launcher + iframe\n * look & feel — embedders rely on it.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n readSessionToken,\n writeSessionToken,\n clearSessionToken,\n} from '../storage/session-storage';\n\nexport interface ChanlChatProactiveMessage {\n text: string;\n delay?: number;\n}\n\nexport interface ChanlChatInitConfig {\n /** Agent to load. Required. */\n agentId: string;\n /** Public key (`pub_xxx`) for origin-scoped auth. Recommended. */\n apiKey?: string;\n /** Visual theme for the chat iframe. */\n theme?: 'dark' | 'light';\n /** Launcher position. */\n position?: 'bottom-right' | 'bottom-left';\n /** Launcher button background color. */\n color?: string;\n /** Show the \"Powered by Chanl\" footer. Default true. */\n branding?: boolean;\n /** Locale code to load localized agent copy. */\n locale?: string;\n /** Link to your privacy policy, shown in the disclaimer. */\n privacyUrl?: string;\n /** Override the agent's display name in the header. */\n agentName?: string;\n /** Subtitle shown under the agent name. */\n agentSubtitle?: string;\n /** 1–2 character initials for the avatar fallback. */\n agentInitials?: string;\n /** Avatar image URL. */\n agentAvatarUrl?: string;\n /** Override the greeting message shown when the chat panel first opens. */\n greeting?: string;\n /** Input placeholder text. */\n placeholder?: string;\n /** Override the dark theme background color. */\n darkBg?: string;\n /** Proactive toast messages shown before the user opens the chat. */\n proactiveMessages?: Array<string | ChanlChatProactiveMessage>;\n /** Override the Chanl platform API base URL (auto-resolved by default). */\n baseUrl?: string;\n /**\n * Override the chat iframe host URL. Defaults to `window.location.origin`,\n * which is the correct value when the loader is served from the same origin\n * as the chat UI (e.g. `chat.channel.tel`).\n */\n chatHost?: string;\n}\n\nexport interface ChanlChatApi {\n _initialized: boolean;\n init: (cfg: ChanlChatInitConfig) => void;\n /**\n * Apply config changes in-place WITHOUT re-mounting the iframe.\n *\n * Launcher-level options (`color`, `position`, `proactiveMessages`) are\n * patched directly on the DOM. Iframe-level options (`theme`, `agentName`,\n * `agentSubtitle`, `agentInitials`, `agentAvatarUrl`, `greeting`,\n * `placeholder`, `privacyUrl`, `branding`, `darkBg`, `locale`) are\n * pushed into the iframe via postMessage. The chat page inside the iframe\n * listens for `chanl:update-config` and patches its own React state.\n *\n * Auth/identity fields (`agentId`, `apiKey`, `chatHost`, `baseUrl`) cannot\n * be updated live — they change which agent is loaded or where the iframe\n * is served from. Pass those via `init()` + `destroy()` instead.\n */\n update: (partial: Partial<ChanlChatInitConfig>) => void;\n open: () => void;\n close: () => void;\n toggle: () => void;\n destroy: () => void;\n setUser: (user: Record<string, unknown>) => void;\n setContext: (ctx: Record<string, unknown>) => void;\n sendMessage: (text: string) => void;\n on: (event: string, fn: (data?: unknown) => void) => void;\n off: (event: string, fn: (data?: unknown) => void) => void;\n}\n\ndeclare global {\n interface Window {\n ChanlChat: ChanlChatApi;\n }\n}\n\ninterface LoaderState {\n open: boolean;\n config: ChanlChatInitConfig | null;\n iframe: HTMLIFrameElement | null;\n launcher: HTMLButtonElement | null;\n chat: HTMLDivElement | null;\n toasts: HTMLDivElement | null;\n timers: ReturnType<typeof setTimeout>[];\n msgs: string[];\n listeners: Record<string, Array<(data?: unknown) => void>>;\n}\n\n(function () {\n 'use strict';\n if (typeof window === 'undefined') return;\n if (window.ChanlChat && window.ChanlChat._initialized) window.ChanlChat.destroy();\n\n // Host that serves the chat iframe. Defaults to the loader's origin so that\n // `chat.channel.tel/widget/v1.js` → `chat.channel.tel/chat/<agentId>`.\n const BASE = window.location.origin;\n\n // Resolve platform API base URL — auto-detect dev vs prod.\n function resolvePlatformBase(explicit?: string): string {\n if (explicit) return explicit;\n const host = window.location.hostname;\n if (host === 'localhost' || host === '127.0.0.1' || host.indexOf('.local') !== -1) {\n return 'http://localhost:3100';\n }\n return 'https://platform.channel.tel';\n }\n\n const Z = 2147483647;\n\n const s: LoaderState = {\n open: false,\n config: null,\n iframe: null,\n launcher: null,\n chat: null,\n toasts: null,\n timers: [],\n msgs: [],\n listeners: {},\n };\n\n function css(): void {\n if (document.getElementById('chanl-css')) return;\n const el = document.createElement('style');\n el.id = 'chanl-css';\n el.textContent = [\n /* Launcher */\n '.chanl-btn{position:fixed;bottom:20px;cursor:pointer;width:56px;height:56px;border-radius:50%;display:flex;align-items:center;justify-content:center;border:none;outline:none;padding:0;z-index:' +\n Z +\n ';transition:opacity .15s ease,box-shadow .15s ease;box-shadow:0 4px 16px -2px rgba(0,0,0,.2)}',\n '.chanl-btn:hover{opacity:.85}',\n '.chanl-btn svg{width:26px;height:26px}',\n\n /* Chat iframe */\n '.chanl-chat{position:fixed;bottom:88px;width:400px;height:620px;border-radius:16px;overflow:hidden;z-index:' +\n Z +\n ';opacity:0;transform:translateY(10px);transition:opacity .2s ease,transform .2s ease;pointer-events:none;box-shadow:0 20px 50px -10px rgba(0,0,0,.25),0 0 0 1px rgba(0,0,0,.05)}',\n '.chanl-chat.open{opacity:1;transform:translateY(0);pointer-events:auto}',\n '.chanl-chat iframe{width:100%;height:100%;border:none}',\n\n /* Toast stack — simple column, newest at bottom */\n '.chanl-toasts{position:fixed;bottom:88px;display:flex;flex-direction:column;gap:8px;z-index:' +\n (Z - 1) +\n ';max-width:300px}',\n\n /* Individual toast */\n '.chanl-toast{padding:12px 16px;border-radius:12px;background:#fff;color:#1a1a1a;font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,sans-serif;font-size:14px;line-height:1.5;box-shadow:0 2px 12px -2px rgba(0,0,0,.1),0 1px 4px rgba(0,0,0,.06);cursor:pointer;opacity:0;transform:translateY(8px);transition:opacity .35s ease,transform .35s ease;width:fit-content;max-width:100%;align-self:flex-end}',\n '.chanl-toast.show{opacity:1;transform:translateY(0)}',\n '.chanl-toast:hover{background:#f5f5f5}',\n\n /* Mobile */\n '@media(max-width:480px){.chanl-chat{bottom:0!important;right:0!important;left:0!important;width:100%!important;height:100%!important;border-radius:0!important}.chanl-btn.hide{display:none!important}.chanl-toasts{right:12px!important;left:12px!important;max-width:100%}}',\n ].join('\\n');\n document.head.appendChild(el);\n }\n\n const ICO_CHAT =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M7.9 20A9 9 0 1 0 4 16.1L2 22Z\"/></svg>';\n const ICO_X =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 6 6 18\"/><path d=\"m6 6 12 12\"/></svg>';\n\n function side(cfg: ChanlChatInitConfig): 'left' | 'right' {\n return cfg.position === 'bottom-left' ? 'left' : 'right';\n }\n\n function mkLauncher(cfg: ChanlChatInitConfig): HTMLButtonElement {\n const b = document.createElement('button');\n b.className = 'chanl-btn';\n b.setAttribute('aria-label', 'Open chat');\n b.style.backgroundColor = cfg.color || '#c0673b';\n b.style.color = '#fff';\n b.style[side(cfg)] = '20px';\n b.innerHTML = ICO_CHAT;\n b.onclick = function () {\n window.ChanlChat.toggle();\n };\n document.body.appendChild(b);\n return b;\n }\n\n function mkChat(cfg: ChanlChatInitConfig): { el: HTMLDivElement; iframe: HTMLIFrameElement } {\n const d = document.createElement('div');\n d.className = 'chanl-chat';\n d.style[side(cfg)] = '20px';\n const p = new URLSearchParams();\n p.set('theme', cfg.theme || 'dark');\n if (cfg.branding === false) p.set('branding', 'false');\n if (cfg.locale) p.set('locale', cfg.locale);\n if (cfg.privacyUrl) p.set('privacyUrl', cfg.privacyUrl);\n if (cfg.agentName) p.set('name', cfg.agentName);\n if (cfg.agentSubtitle) p.set('subtitle', cfg.agentSubtitle);\n if (cfg.agentInitials) p.set('initials', cfg.agentInitials);\n if (cfg.agentAvatarUrl) p.set('avatar', cfg.agentAvatarUrl);\n if (cfg.greeting) p.set('greeting', cfg.greeting);\n if (cfg.placeholder) p.set('placeholder', cfg.placeholder);\n if (cfg.darkBg) p.set('darkBg', cfg.darkBg);\n if (cfg.apiKey) p.set('apiKey', cfg.apiKey);\n // Always set baseUrl (auto-resolved if not provided)\n p.set('baseUrl', resolvePlatformBase(cfg.baseUrl));\n // Session resume — if a previous session's JWT is stashed in localStorage,\n // forward it to the iframe so the chat-client calls /resume instead of\n // /chat on mount. localStorage is per-origin and the iframe is on a\n // different origin (chat host) — so we read it here in the host origin\n // and pass the value across via URL. The server-side JWT signature is\n // the security boundary; URL-as-transport is fine because workspaceId +\n // interactionId are tamper-evidently bound to it.\n if (cfg.apiKey) {\n const existingToken = readSessionToken(cfg.apiKey, cfg.agentId);\n if (existingToken) p.set('sessionToken', existingToken);\n }\n const host = cfg.chatHost || BASE;\n const f = document.createElement('iframe');\n f.src = host + '/chat/' + cfg.agentId + '?' + p.toString();\n f.allow = 'microphone';\n f.title = 'Chanl Chat';\n d.appendChild(f);\n document.body.appendChild(d);\n return { el: d, iframe: f };\n }\n\n /* ── Proactive toasts ── */\n\n function mkToasts(cfg: ChanlChatInitConfig): HTMLDivElement {\n const wrap = document.createElement('div');\n wrap.className = 'chanl-toasts';\n wrap.style[side(cfg)] = '20px';\n document.body.appendChild(wrap);\n return wrap;\n }\n\n function addToast(text: string, wrap: HTMLDivElement): void {\n const t = document.createElement('div');\n t.className = 'chanl-toast';\n t.textContent = text;\n t.onclick = function () {\n window.ChanlChat.open();\n };\n wrap.appendChild(t);\n s.msgs.push(text);\n // trigger animation next frame\n requestAnimationFrame(function () {\n requestAnimationFrame(function () {\n t.classList.add('show');\n });\n });\n }\n\n /**\n * Schedule the proactive toast bubbles.\n *\n * @param cfg The current widget config (reads `proactiveMessages` from it)\n * @param force When true, bypass the `if (!s.open)` guard so toasts show\n * even if the chat panel is currently open. Used by `update()`\n * — when a customer explicitly re-pushes proactive messages\n * after init they want to see them immediately. The default\n * (false) preserves the production behavior where toasts only\n * fire when the chat is still closed.\n */\n function scheduleToasts(cfg: ChanlChatInitConfig, force?: boolean): void {\n const list = cfg.proactiveMessages;\n if (!list || !list.length) return;\n const wrap = mkToasts(cfg);\n s.toasts = wrap;\n list.forEach(function (m, i) {\n const text = typeof m === 'string' ? m : m.text;\n const delay = typeof m === 'string' ? 2000 + i * 1500 : m.delay || 2000 + i * 1500;\n s.timers.push(\n setTimeout(function () {\n if (force || !s.open) addToast(text, wrap);\n }, delay),\n );\n });\n }\n\n function clearToasts(): void {\n s.timers.forEach(clearTimeout);\n s.timers = [];\n if (s.toasts) {\n s.toasts.style.opacity = '0';\n s.toasts.style.transition = 'opacity .25s ease';\n const el = s.toasts;\n setTimeout(function () {\n el.remove();\n }, 250);\n s.toasts = null;\n }\n }\n\n /* ── PostMessage ── */\n\n function post(type: string, payload?: unknown): void {\n if (s.iframe && s.iframe.contentWindow)\n s.iframe.contentWindow.postMessage({ type: 'chanl:' + type, payload: payload }, '*');\n }\n\n window.addEventListener('message', function (e: MessageEvent) {\n if (!e.data || typeof e.data.type !== 'string' || !e.data.type.startsWith('chanl:')) return;\n const evt = e.data.type.replace('chanl:', '');\n\n // Session-token lifecycle — the iframe issued/refreshed a JWT, or asked\n // us to clear because the server rejected the token (4xx). The loader\n // is the sole persistence boundary (iframe + host on different origins),\n // so write/clear here. apiKey + agentId scope the storage key so a\n // multi-agent host site (sales + support widgets) keeps independent\n // resumable sessions.\n if (s.config && s.config.apiKey) {\n if (evt === 'session-token-issued') {\n const payload = e.data.payload as { token?: string } | undefined;\n if (payload && typeof payload.token === 'string' && payload.token.length > 0) {\n writeSessionToken(s.config.apiKey, s.config.agentId, payload.token);\n }\n } else if (evt === 'session-token-cleared') {\n clearSessionToken(s.config.apiKey, s.config.agentId);\n }\n }\n\n emit(evt, e.data.payload);\n });\n\n function emit(n: string, d?: unknown): void {\n (s.listeners[n] || []).forEach(function (fn) {\n try {\n fn(d);\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('[ChanlChat]', err);\n }\n });\n }\n\n /* ── API ── */\n\n window.ChanlChat = {\n _initialized: false,\n\n init: function (cfg: ChanlChatInitConfig) {\n if (!cfg || !cfg.agentId) {\n // eslint-disable-next-line no-console\n console.error('[ChanlChat] agentId required');\n return;\n }\n s.config = Object.assign(\n {\n theme: 'dark' as const,\n position: 'bottom-right' as const,\n branding: true,\n color: '#c0673b',\n },\n cfg,\n );\n css();\n s.launcher = mkLauncher(s.config);\n const c = mkChat(s.config);\n s.chat = c.el;\n s.iframe = c.iframe;\n scheduleToasts(s.config);\n this._initialized = true;\n },\n\n /**\n * Live-update widget config without re-mounting the iframe.\n * See `ChanlChatApi.update` JSDoc for the split between launcher-level\n * and iframe-level fields.\n */\n update: function (partial: Partial<ChanlChatInitConfig>) {\n if (!s.config || !s.launcher) {\n // eslint-disable-next-line no-console\n console.warn('[ChanlChat] update() called before init()');\n return;\n }\n\n // Fields that CANNOT be updated live — they'd require a different\n // agent, session, or iframe URL. Warn + skip silently.\n const frozen: Array<keyof ChanlChatInitConfig> = ['agentId', 'apiKey', 'chatHost', 'baseUrl'];\n const frozenChanged = frozen.filter(function (k) {\n return k in partial && partial[k] !== s.config![k];\n });\n if (frozenChanged.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(\n '[ChanlChat] update() cannot change these fields live — use destroy() + init():',\n frozenChanged,\n );\n }\n\n // ── 1. Merge into tracked config (drop frozen changes) ──\n const next = Object.assign({}, s.config) as ChanlChatInitConfig;\n (Object.keys(partial) as Array<keyof ChanlChatInitConfig>).forEach(function (k) {\n if (frozen.indexOf(k) === -1 && partial[k] !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (next as any)[k] = partial[k];\n }\n });\n s.config = next;\n\n // ── 2. Launcher-level DOM patches ──\n if ('color' in partial && partial.color && s.launcher) {\n s.launcher.style.backgroundColor = partial.color;\n }\n\n if ('position' in partial && partial.position) {\n const newSide = side(s.config);\n const oldSide = newSide === 'left' ? 'right' : 'left';\n // Launcher\n if (s.launcher) {\n s.launcher.style[oldSide] = '';\n s.launcher.style[newSide] = '20px';\n }\n // Chat panel\n if (s.chat) {\n s.chat.style[oldSide] = '';\n s.chat.style[newSide] = '20px';\n }\n // Toasts stack\n if (s.toasts) {\n s.toasts.style[oldSide] = '';\n s.toasts.style[newSide] = '20px';\n }\n }\n\n if ('proactiveMessages' in partial) {\n // Teardown + re-schedule with the new list. Pass force=true so the\n // toasts fire even if the chat panel is already open — the customer\n // is explicitly re-pushing proactive messages after init and expects\n // to see them immediately. (At init time, the chat is closed by\n // default and the open-check is sufficient.)\n clearToasts();\n s.msgs = [];\n scheduleToasts(s.config, true);\n }\n\n // ── 3. Iframe-level postMessage ──\n // Any remaining fields that the chat page cares about get forwarded.\n // The chat page listens for `chanl:update-config` and merges them into\n // its own React state.\n const iframeKeys: Array<keyof ChanlChatInitConfig> = [\n 'theme',\n 'agentName',\n 'agentSubtitle',\n 'agentInitials',\n 'agentAvatarUrl',\n 'greeting',\n 'placeholder',\n 'privacyUrl',\n 'branding',\n 'darkBg',\n 'locale',\n ];\n const iframePatch: Partial<ChanlChatInitConfig> = {};\n let hasIframePatch = false;\n iframeKeys.forEach(function (k) {\n if (k in partial) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (iframePatch as any)[k] = partial[k];\n hasIframePatch = true;\n }\n });\n if (hasIframePatch) post('update-config', iframePatch);\n },\n\n open: function () {\n if (!s.chat) return;\n s.open = true;\n clearToasts();\n s.chat.classList.add('open');\n if (s.launcher) s.launcher.innerHTML = ICO_X;\n // Send proactive messages into the chat\n if (s.msgs.length) {\n setTimeout(function () {\n post('init-messages', s.msgs);\n s.msgs = [];\n }, 500);\n }\n emit('open');\n },\n\n close: function () {\n if (!s.chat) return;\n s.open = false;\n s.chat.classList.remove('open');\n if (s.launcher) s.launcher.innerHTML = ICO_CHAT;\n emit('close');\n },\n\n toggle: function () {\n if (s.open) this.close();\n else this.open();\n },\n\n destroy: function () {\n clearToasts();\n if (s.launcher) s.launcher.remove();\n if (s.chat) s.chat.remove();\n s.open = false;\n s.iframe = null;\n s.launcher = null;\n s.chat = null;\n s.msgs = [];\n this._initialized = false;\n },\n\n setUser: function (u) {\n post('set-user', u);\n },\n setContext: function (c) {\n post('set-context', c);\n },\n sendMessage: function (t) {\n post('send-message', { text: t });\n },\n on: function (e, fn) {\n (s.listeners[e] = s.listeners[e] || []).push(fn);\n },\n off: function (e, fn) {\n s.listeners[e] = (s.listeners[e] || []).filter(function (f) {\n return f !== fn;\n });\n },\n };\n})();\n"]}
@@ -0,0 +1,10 @@
1
+ export interface Listener<T extends any[]> {
2
+ (...args: T): void;
3
+ }
4
+ export declare class CustomEventEmitter<EventMap extends Record<string, (...args: any[]) => void>> {
5
+ private listeners;
6
+ on<K extends keyof EventMap>(event: K, listener: Listener<Parameters<EventMap[K]>>): this;
7
+ off<K extends keyof EventMap>(event: K, listener: Listener<Parameters<EventMap[K]>>): this;
8
+ emit<K extends keyof EventMap>(event: K, ...args: Parameters<EventMap[K]>): this;
9
+ }
10
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,GAAG,EAAE;IACvC,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;CACpB;AAED,qBAAa,kBAAkB,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IACvF,OAAO,CAAC,SAAS,CAAuE;IAExF,EAAE,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAKzF,GAAG,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAM1F,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;CAIjF"}
package/dist/events.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomEventEmitter = void 0;
4
+ class CustomEventEmitter {
5
+ constructor() {
6
+ this.listeners = {};
7
+ }
8
+ on(event, listener) {
9
+ var _a;
10
+ ((_a = this.listeners)[event] || (_a[event] = [])).push(listener);
11
+ return this;
12
+ }
13
+ off(event, listener) {
14
+ const arr = this.listeners[event];
15
+ if (arr)
16
+ this.listeners[event] = arr.filter((l) => l !== listener);
17
+ return this;
18
+ }
19
+ emit(event, ...args) {
20
+ (this.listeners[event] || []).forEach((l) => l(...args));
21
+ return this;
22
+ }
23
+ }
24
+ exports.CustomEventEmitter = CustomEventEmitter;
25
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;AAIA,MAAa,kBAAkB;IAA/B;QACU,cAAS,GAAoE,EAAE,CAAC;IAiB1F,CAAC;IAfC,EAAE,CAA2B,KAAQ,EAAE,QAA2C;;QAChF,OAAC,IAAI,CAAC,SAAS,EAAC,KAAK,SAAL,KAAK,IAAM,EAAE,EAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAA2B,KAAQ,EAAE,QAA2C;QACjF,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,GAAG;YAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAA2B,KAAQ,EAAE,GAAG,IAA6B;QACvE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAlBD,gDAkBC"}