@convai/web-sdk 1.8.0-beta.6 → 1.8.0-beta.8

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 (99) hide show
  1. package/README.md +303 -1
  2. package/dist/core/ConvaiClient.d.ts +59 -2
  3. package/dist/core/ConvaiClient.d.ts.map +1 -1
  4. package/dist/core/ConvaiClient.js +457 -6
  5. package/dist/core/ConvaiClient.js.map +1 -1
  6. package/dist/core/MessageHandler.d.ts +11 -0
  7. package/dist/core/MessageHandler.d.ts.map +1 -1
  8. package/dist/core/MessageHandler.js +325 -30
  9. package/dist/core/MessageHandler.js.map +1 -1
  10. package/dist/core/SSESession.js +2 -2
  11. package/dist/core/SSESession.js.map +1 -1
  12. package/dist/core/connectRequest.d.ts +38 -3
  13. package/dist/core/connectRequest.d.ts.map +1 -1
  14. package/dist/core/connectRequest.js +57 -11
  15. package/dist/core/connectRequest.js.map +1 -1
  16. package/dist/core/index.d.ts +5 -1
  17. package/dist/core/index.d.ts.map +1 -1
  18. package/dist/core/index.js +8 -1
  19. package/dist/core/index.js.map +1 -1
  20. package/dist/core/logicalTurn.d.ts +4 -1
  21. package/dist/core/logicalTurn.d.ts.map +1 -1
  22. package/dist/core/logicalTurn.js +35 -4
  23. package/dist/core/logicalTurn.js.map +1 -1
  24. package/dist/core/modelOutput.d.ts +40 -0
  25. package/dist/core/modelOutput.d.ts.map +1 -0
  26. package/dist/core/modelOutput.js +187 -0
  27. package/dist/core/modelOutput.js.map +1 -0
  28. package/dist/core/publishedChat.d.ts +9 -0
  29. package/dist/core/publishedChat.d.ts.map +1 -0
  30. package/dist/core/publishedChat.js +13 -0
  31. package/dist/core/publishedChat.js.map +1 -0
  32. package/dist/core/types.d.ts +225 -25
  33. package/dist/core/types.d.ts.map +1 -1
  34. package/dist/core/types.js.map +1 -1
  35. package/dist/embed/ConvaiChatElement.d.ts +103 -0
  36. package/dist/embed/ConvaiChatElement.d.ts.map +1 -0
  37. package/dist/embed/ConvaiChatElement.js +679 -0
  38. package/dist/embed/ConvaiChatElement.js.map +1 -0
  39. package/dist/embed/browser.d.ts +3 -0
  40. package/dist/embed/browser.d.ts.map +1 -0
  41. package/dist/embed/browser.js +5 -0
  42. package/dist/embed/browser.js.map +1 -0
  43. package/dist/embed/chat-embed-v1.js +200 -0
  44. package/dist/embed/chat-embed-v1.js.map +7 -0
  45. package/dist/embed/index.d.ts +9 -0
  46. package/dist/embed/index.d.ts.map +1 -0
  47. package/dist/embed/index.js +9 -0
  48. package/dist/embed/index.js.map +1 -0
  49. package/dist/embed/publicationApi.d.ts +23 -0
  50. package/dist/embed/publicationApi.d.ts.map +1 -0
  51. package/dist/embed/publicationApi.js +141 -0
  52. package/dist/embed/publicationApi.js.map +1 -0
  53. package/dist/react/components/ConvaiWidget.d.ts +11 -1
  54. package/dist/react/components/ConvaiWidget.d.ts.map +1 -1
  55. package/dist/react/components/ConvaiWidget.js +67 -11
  56. package/dist/react/components/ConvaiWidget.js.map +1 -1
  57. package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +7 -0
  58. package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts.map +1 -1
  59. package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +111 -17
  60. package/dist/react/components/rtc-widget/components/MarkdownRenderer.js.map +1 -1
  61. package/dist/react/components/rtc-widget/components/UserMessage.js +1 -1
  62. package/dist/react/components/rtc-widget/components/UserMessage.js.map +1 -1
  63. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts +1 -1
  64. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts.map +1 -1
  65. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +2 -2
  66. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js.map +1 -1
  67. package/dist/react/hooks/useConvaiClient.d.ts +2 -0
  68. package/dist/react/hooks/useConvaiClient.d.ts.map +1 -1
  69. package/dist/react/hooks/useConvaiClient.js +8 -0
  70. package/dist/react/hooks/useConvaiClient.js.map +1 -1
  71. package/dist/react/index.d.ts +4 -1
  72. package/dist/react/index.d.ts.map +1 -1
  73. package/dist/react/index.js +8 -1
  74. package/dist/react/index.js.map +1 -1
  75. package/dist/utils/inlineMarkdown.d.ts +22 -0
  76. package/dist/utils/inlineMarkdown.d.ts.map +1 -1
  77. package/dist/utils/inlineMarkdown.js +84 -7
  78. package/dist/utils/inlineMarkdown.js.map +1 -1
  79. package/dist/vanilla/ConvaiWidget.d.ts.map +1 -1
  80. package/dist/vanilla/ConvaiWidget.js +290 -43
  81. package/dist/vanilla/ConvaiWidget.js.map +1 -1
  82. package/dist/vanilla/WidgetEventSubscriptions.d.ts +15 -0
  83. package/dist/vanilla/WidgetEventSubscriptions.d.ts.map +1 -0
  84. package/dist/vanilla/WidgetEventSubscriptions.js +37 -0
  85. package/dist/vanilla/WidgetEventSubscriptions.js.map +1 -0
  86. package/dist/vanilla/index.d.ts +3 -1
  87. package/dist/vanilla/index.d.ts.map +1 -1
  88. package/dist/vanilla/index.js +3 -1
  89. package/dist/vanilla/index.js.map +1 -1
  90. package/dist/vanilla/styles.d.ts.map +1 -1
  91. package/dist/vanilla/styles.js +12 -0
  92. package/dist/vanilla/styles.js.map +1 -1
  93. package/dist/vanilla/types.d.ts +8 -1
  94. package/dist/vanilla/types.d.ts.map +1 -1
  95. package/dist/vanilla/types.js.map +1 -1
  96. package/dist/version.d.ts +1 -1
  97. package/dist/version.js +1 -1
  98. package/dist/version.js.map +1 -1
  99. package/package.json +48 -13
@@ -0,0 +1,15 @@
1
+ type WidgetEventListener = (...args: unknown[]) => void;
2
+ type SubscribeToWidgetEvent = (listener: WidgetEventListener) => (() => void) | void;
3
+ /**
4
+ * Owns widget event listeners so a destroyed widget cannot mutate detached DOM
5
+ * or notify its host when a client event arrives late.
6
+ */
7
+ export declare class WidgetEventSubscriptions {
8
+ private readonly isDestroyed;
9
+ private readonly unsubscribes;
10
+ constructor(isDestroyed: () => boolean);
11
+ register(subscribe: SubscribeToWidgetEvent, listener: WidgetEventListener): void;
12
+ unsubscribeAll(): void;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=WidgetEventSubscriptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetEventSubscriptions.d.ts","sourceRoot":"","sources":["../../src/vanilla/WidgetEventSubscriptions.ts"],"names":[],"mappings":"AAAA,KAAK,mBAAmB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AACxD,KAAK,sBAAsB,GAAG,CAAC,QAAQ,EAAE,mBAAmB,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;AAErF;;;GAGG;AACH,qBAAa,wBAAwB;IAGvB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAFxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAyB;gBAEzB,WAAW,EAAE,MAAM,OAAO;IAEvD,QAAQ,CACN,SAAS,EAAE,sBAAsB,EACjC,QAAQ,EAAE,mBAAmB,GAC5B,IAAI;IAuBP,cAAc,IAAI,IAAI;CAKvB"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Owns widget event listeners so a destroyed widget cannot mutate detached DOM
3
+ * or notify its host when a client event arrives late.
4
+ */
5
+ export class WidgetEventSubscriptions {
6
+ constructor(isDestroyed) {
7
+ this.isDestroyed = isDestroyed;
8
+ this.unsubscribes = [];
9
+ }
10
+ register(subscribe, listener) {
11
+ if (this.isDestroyed())
12
+ return;
13
+ const unsubscribe = subscribe((...args) => {
14
+ if (!this.isDestroyed()) {
15
+ listener(...args);
16
+ }
17
+ });
18
+ // A hand-rolled IConvaiClient (the vanilla types allow one) may return
19
+ // nothing from on(); there is then nothing to tear down, and that is not
20
+ // an error -- the isDestroyed gate above still silences its listener.
21
+ if (typeof unsubscribe !== "function")
22
+ return;
23
+ // The browser event loop cannot interleave normal synchronous code, but
24
+ // preserve the lifecycle boundary for unusual synchronous subscriptions.
25
+ if (this.isDestroyed()) {
26
+ unsubscribe();
27
+ return;
28
+ }
29
+ this.unsubscribes.push(unsubscribe);
30
+ }
31
+ unsubscribeAll() {
32
+ for (const unsubscribe of this.unsubscribes.splice(0)) {
33
+ unsubscribe();
34
+ }
35
+ }
36
+ }
37
+ //# sourceMappingURL=WidgetEventSubscriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetEventSubscriptions.js","sourceRoot":"","sources":["../../src/vanilla/WidgetEventSubscriptions.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IAGnC,YAA6B,WAA0B;QAA1B,gBAAW,GAAX,WAAW,CAAe;QAFtC,iBAAY,GAAsB,EAAE,CAAC;IAEI,CAAC;IAE3D,QAAQ,CACN,SAAiC,EACjC,QAA6B;QAE7B,IAAI,IAAI,CAAC,WAAW,EAAE;YAAE,OAAO;QAE/B,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE;YACxC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,uEAAuE;QACvE,yEAAyE;QACzE,sEAAsE;QACtE,IAAI,OAAO,WAAW,KAAK,UAAU;YAAE,OAAO;QAE9C,wEAAwE;QACxE,yEAAyE;QACzE,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,WAAW,EAAE,CAAC;YACd,OAAO;QACT,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAED,cAAc;QACZ,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YACtD,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;CACF","sourcesContent":["type WidgetEventListener = (...args: unknown[]) => void;\ntype SubscribeToWidgetEvent = (listener: WidgetEventListener) => (() => void) | void;\n\n/**\n * Owns widget event listeners so a destroyed widget cannot mutate detached DOM\n * or notify its host when a client event arrives late.\n */\nexport class WidgetEventSubscriptions {\n private readonly unsubscribes: Array<() => void> = [];\n\n constructor(private readonly isDestroyed: () => boolean) {}\n\n register(\n subscribe: SubscribeToWidgetEvent,\n listener: WidgetEventListener,\n ): void {\n if (this.isDestroyed()) return;\n\n const unsubscribe = subscribe((...args) => {\n if (!this.isDestroyed()) {\n listener(...args);\n }\n });\n\n // A hand-rolled IConvaiClient (the vanilla types allow one) may return\n // nothing from on(); there is then nothing to tear down, and that is not\n // an error -- the isDestroyed gate above still silences its listener.\n if (typeof unsubscribe !== \"function\") return;\n\n // The browser event loop cannot interleave normal synchronous code, but\n // preserve the lifecycle boundary for unusual synchronous subscriptions.\n if (this.isDestroyed()) {\n unsubscribe();\n return;\n }\n this.unsubscribes.push(unsubscribe);\n }\n\n unsubscribeAll(): void {\n for (const unsubscribe of this.unsubscribes.splice(0)) {\n unsubscribe();\n }\n }\n}\n"]}
@@ -28,11 +28,13 @@
28
28
  * // - client.audioControls, videoControls, etc.
29
29
  * ```
30
30
  */
31
- export { ConvaiClient } from '../core/ConvaiClient.js';
31
+ export { ActionResultAckError, ConvaiClient } from '../core/ConvaiClient.js';
32
32
  export { CharacterVersionManager, CharacterApiError } from '../core/CharacterVersionManager.js';
33
33
  export { ConvaiRoomError } from '../core/ConvaiRoomError.js';
34
34
  export { AudioRenderer } from './AudioRenderer.js';
35
35
  export { createConvaiWidget, destroyConvaiWidget } from './ConvaiWidget.js';
36
36
  export * from '../core/types.js';
37
+ export { parseInlineMarkdown, mediaKindForUrl, isSafeHref, compactUrl } from '../utils/inlineMarkdown.js';
38
+ export type { InlineNode, MediaKind } from '../utils/inlineMarkdown.js';
37
39
  export type { VanillaWidget, VanillaWidgetOptions, WidgetPlacement, } from './types.js';
38
40
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vanilla/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGzE,cAAc,eAAe,CAAC;AAG9B,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,eAAe,GAChB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vanilla/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGzE,cAAc,eAAe,CAAC;AAG9B,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACvG,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGrE,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,eAAe,GAChB,MAAM,SAAS,CAAC"}
@@ -29,7 +29,7 @@
29
29
  * ```
30
30
  */
31
31
  // Main client for managing connections
32
- export { ConvaiClient } from '../core/ConvaiClient.js';
32
+ export { ActionResultAckError, ConvaiClient } from '../core/ConvaiClient.js';
33
33
  export { CharacterVersionManager, CharacterApiError } from '../core/CharacterVersionManager.js';
34
34
  export { ConvaiRoomError } from '../core/ConvaiRoomError.js';
35
35
  // AudioRenderer for custom UI builders (handles audio playback)
@@ -38,4 +38,6 @@ export { AudioRenderer } from './AudioRenderer.js';
38
38
  export { createConvaiWidget, destroyConvaiWidget } from './ConvaiWidget.js';
39
39
  // Re-export ALL core types for complete parity with React
40
40
  export * from '../core/types.js';
41
+ // Inline markdown tokenizer, for building a chat UI without createConvaiWidget.
42
+ export { parseInlineMarkdown, mediaKindForUrl, isSafeHref, compactUrl } from '../utils/inlineMarkdown.js';
41
43
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vanilla/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,gEAAgE;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,wCAAwC;AACxC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,0DAA0D;AAC1D,cAAc,eAAe,CAAC","sourcesContent":["/**\n * Convai Web SDK - Vanilla JavaScript/TypeScript Export\n * \n * This module provides vanilla JS/TS exports for the Convai SDK.\n * Use this for non-React applications.\n * \n * @example\n * ```typescript\n * import { ConvaiClient, createConvaiWidget } from '@convai/web-sdk/vanilla';\n * \n * // Pass config to constructor (same pattern as React's useConvaiClient)\n * const client = new ConvaiClient({\n * apiKey: 'your-api-key',\n * characterId: 'your-character-id',\n * enableVideo: true,\n * });\n * \n * // Create widget - auto-connects on first click\n * const widget = createConvaiWidget(document.body, {\n * convaiClient: client\n * });\n * \n * // Client has all functions for advanced usage:\n * // - client.connect() - manual connection\n * // - client.disconnect() - disconnect\n * // - client.reconnect() - reconnect\n * // - client.sendUserTextMessage() - send messages\n * // - client.audioControls, videoControls, etc.\n * ```\n */\n\n// Main client for managing connections\nexport { ConvaiClient } from '../core/ConvaiClient';\nexport { CharacterVersionManager, CharacterApiError } from '../core/CharacterVersionManager';\nexport { ConvaiRoomError } from '../core/ConvaiRoomError';\n\n// AudioRenderer for custom UI builders (handles audio playback)\nexport { AudioRenderer } from './AudioRenderer';\n\n// Vanilla widget - complete UI solution\nexport { createConvaiWidget, destroyConvaiWidget } from './ConvaiWidget';\n\n// Re-export ALL core types for complete parity with React\nexport * from '../core/types';\n\n// Widget-specific types\nexport type {\n VanillaWidget,\n VanillaWidgetOptions,\n WidgetPlacement,\n} from './types';\n\n\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vanilla/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,uCAAuC;AACvC,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,gEAAgE;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,wCAAwC;AACxC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,0DAA0D;AAC1D,cAAc,eAAe,CAAC;AAE9B,gFAAgF;AAChF,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["/**\n * Convai Web SDK - Vanilla JavaScript/TypeScript Export\n * \n * This module provides vanilla JS/TS exports for the Convai SDK.\n * Use this for non-React applications.\n * \n * @example\n * ```typescript\n * import { ConvaiClient, createConvaiWidget } from '@convai/web-sdk/vanilla';\n * \n * // Pass config to constructor (same pattern as React's useConvaiClient)\n * const client = new ConvaiClient({\n * apiKey: 'your-api-key',\n * characterId: 'your-character-id',\n * enableVideo: true,\n * });\n * \n * // Create widget - auto-connects on first click\n * const widget = createConvaiWidget(document.body, {\n * convaiClient: client\n * });\n * \n * // Client has all functions for advanced usage:\n * // - client.connect() - manual connection\n * // - client.disconnect() - disconnect\n * // - client.reconnect() - reconnect\n * // - client.sendUserTextMessage() - send messages\n * // - client.audioControls, videoControls, etc.\n * ```\n */\n\n// Main client for managing connections\nexport { ActionResultAckError, ConvaiClient } from '../core/ConvaiClient';\nexport { CharacterVersionManager, CharacterApiError } from '../core/CharacterVersionManager';\nexport { ConvaiRoomError } from '../core/ConvaiRoomError';\n\n// AudioRenderer for custom UI builders (handles audio playback)\nexport { AudioRenderer } from './AudioRenderer';\n\n// Vanilla widget - complete UI solution\nexport { createConvaiWidget, destroyConvaiWidget } from './ConvaiWidget';\n\n// Re-export ALL core types for complete parity with React\nexport * from '../core/types';\n\n// Inline markdown tokenizer, for building a chat UI without createConvaiWidget.\nexport { parseInlineMarkdown, mediaKindForUrl, isSafeHref, compactUrl } from '../utils/inlineMarkdown';\nexport type { InlineNode, MediaKind } from '../utils/inlineMarkdown';\n\n// Widget-specific types\nexport type {\n VanillaWidget,\n VanillaWidgetOptions,\n WidgetPlacement,\n} from './types';\n\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/vanilla/styles.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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form: scale(1) translateY(0); }
289
289
  }
290
290
 
291
+ /* Link-preview skeleton: one sweep across the placeholder while the media
292
+ * decodes. Lives here rather than in getGlobalStyles() because that string is
293
+ * pinned byte-for-byte by the inline-style parity fixture, and this is an
294
+ * addition no existing element uses. */
295
+ @keyframes convai-preview-shimmer {
296
+ from { background-position: 200% 0; }
297
+ to { background-position: -200% 0; }
298
+ }
299
+
291
300
  /* Connecting overlay: logo spin + label pulse. Values match the React
292
301
  * widget's framer-motion transitions (ConvaiWidget.tsx:681-737) exactly --
293
302
  * a full turn every 2s linear, and opacity 0.5 -> 1 -> 0.5 every 2s
@@ -335,6 +344,9 @@ const WIDGET_KEYFRAMES = `
335
344
  .convai-voice-avatar {
336
345
  animation: none !important;
337
346
  }
347
+ [data-convai-skeleton] {
348
+ animation: none !important;
349
+ }
338
350
  }
339
351
  `;
340
352
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/vanilla/styles.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,+CAA+C;AAC/C,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,MAAM,EAAE;QACN,OAAO,EAAE;YACP,EAAE,EAAE,SAAS;YACb,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;SACf;QACD,MAAM,EAAE;YACN,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,SAAS;SAChB;QACD,OAAO,EAAE;YACP,EAAE,EAAE,SAAS;YACb,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;YACd,G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,MAAM,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAE5C,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAAsB,QAAQ,EAAQ,EAAE;IACtE,IAAI,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO;IACzC,IAAI,YAAY,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAAE,CAAC;QAC9C,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC7B,OAAO;IACT,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,KAAK,CAAC,EAAE,GAAG,mBAAmB,CAAC;IAC/B,KAAK,CAAC,WAAW,GAAG,gBAAgB,CAAC;IACrC,SAAS,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAErC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAA2B,EAAU,EAAE;IAClE,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SAC1B,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACpB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5D,OAAO,GAAG,MAAM,KAAK,KAAK,EAAE,CAAC;IAC/B,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\n * Vanilla Styles - Port of React theme system for vanilla implementations\n */\n\n// Theme configuration (matching React version)\nexport const aeroTheme = {\n colors: {\n primary: {\n 50: \"#f0f9ff\",\n 100: \"#e0f2fe\",\n 200: \"#bae6fd\",\n 300: \"#7dd3fc\",\n 400: \"#38bdf8\",\n 500: \"#0ea5e9\",\n 600: \"#0284c7\",\n 700: \"#0369a1\",\n 800: \"#075985\",\n 900: \"#0c4a6e\",\n },\n convai: {\n light: \"#1EB453\",\n medium: \"#0b6049\",\n dark: \"#084c3a\",\n },\n neutral: {\n 50: \"#fafafa\",\n 100: \"#f5f5f5\",\n 200: \"#e5e5e5\",\n 300: \"#d4d4d4\",\n 400: \"#a3a3a3\",\n 500: \"#737373\",\n 600: \"#525252\",\n 700: \"#404040\",\n 800: \"#262626\",\n 900: \"#171717\",\n },\n glass: {\n light: \"rgba(255, 255, 255, 0.1)\",\n medium: \"rgba(255, 255, 255, 0.15)\",\n dark: \"rgba(0, 0, 0, 0.1)\",\n backdrop: \"rgba(255, 255, 255, 0.8)\",\n card: \"rgba(255, 255, 255, 0.9)\",\n backdropLight: \"blur(20px)\",\n borderLight: \"1px solid rgba(255, 255, 255, 0.2)\",\n },\n accent: {\n purple: \"#8b5cf6\",\n green: \"#10b981\",\n blue: \"#3b82f6\",\n orange: \"#f59e0b\",\n red: \"#ef4444\",\n },\n error: {\n 50: \"#fef2f2\",\n 100: \"#fee2e2\",\n 200: \"#fecaca\",\n 300: \"#fca5a5\",\n 400: \"#f87171\",\n 500: \"#ef4444\",\n 600: \"#dc2626\",\n 700: \"#b91c1c\",\n 800: \"#991b1b\",\n 900: \"#7f1d1d\",\n },\n text: {\n primary: \"#1f2937\",\n secondary: \"#6b7280\",\n tertiary: \"#9ca3af\",\n inverse: \"#ffffff\",\n },\n },\n typography: {\n fontFamily: {\n primary: '\"Noto Sans\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\n body: '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\n mono: 'SF Mono, Monaco, \"Cascadia Code\", \"Roboto Mono\", Consolas, \"Courier New\", monospace',\n },\n fontSize: {\n xs: \"12px\",\n sm: \"14px\",\n base: \"16px\",\n lg: \"18px\",\n xl: \"20px\",\n \"2xl\": \"24px\",\n \"3xl\": \"30px\",\n \"4xl\": \"36px\",\n },\n fontWeight: {\n normal: 400,\n medium: 500,\n semibold: 600,\n bold: 700,\n },\n },\n spacing: {\n xs: \"4px\",\n sm: \"8px\",\n md: \"16px\",\n lg: \"24px\",\n xl: \"32px\",\n \"2xl\": \"48px\",\n \"3xl\": \"64px\",\n },\n borderRadius: {\n none: \"0\",\n sm: \"4px\",\n md: \"8px\",\n lg: \"12px\",\n xl: \"16px\",\n \"2xl\": \"24px\",\n full: \"9999px\",\n },\n shadows: {\n sm: \"0 1px 2px 0 rgba(0, 0, 0, 0.05)\",\n md: \"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)\",\n lg: \"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)\",\n xl: \"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)\",\n glass: \"0 8px 32px rgba(0, 0, 0, 0.1)\",\n },\n glass: {\n backdrop: \"blur(20px)\",\n backdropLight: \"blur(10px)\",\n backdropHeavy: \"blur(40px)\",\n border: \"1px solid rgba(255, 255, 255, 0.2)\",\n borderLight: \"1px solid rgba(255, 255, 255, 0.1)\",\n },\n transitions: {\n fast: \"0.15s ease-in-out\",\n normal: \"0.2s ease-in-out\",\n slow: \"0.3s ease-in-out\",\n spring: \"0.4s cubic-bezier(0.4, 0, 0.2, 1)\",\n snappy: \"all 0.1s ease-out\",\n },\n zIndex: {\n base: 1,\n dropdown: 1000,\n sticky: 1020,\n fixed: 1030,\n modal: 1040,\n popover: 1050,\n tooltip: 1060,\n },\n};\n\n/**\n * Global CSS styles for the Convai widget\n * This should be injected once into the document head\n */\nexport const getGlobalStyles = (): string => `\n @keyframes convai-pulse {\n 0%, 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.5;\n }\n }\n\n @keyframes convai-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n\n @keyframes convai-bounce {\n 0%, 100% {\n transform: translateY(0);\n }\n 50% {\n transform: translateY(-10px);\n }\n }\n\n @keyframes convai-slide-up {\n from {\n transform: translateY(20px);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n }\n\n @keyframes convai-slide-down {\n from {\n transform: translateY(-20px);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n }\n\n @keyframes convai-fade-in {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n\n @keyframes convai-scale-in {\n from {\n transform: scale(0.8);\n opacity: 0;\n }\n to {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n .convai-widget * {\n box-sizing: border-box;\n }\n\n .convai-widget {\n font-family: var(--convai-font, ${aeroTheme.typography.fontFamily.primary});\n color: var(--convai-panel-fg, ${aeroTheme.colors.text.primary});\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n\n .convai-widget button {\n font-family: inherit;\n cursor: pointer;\n border: none;\n outline: none;\n background: none;\n padding: 0;\n margin: 0;\n }\n\n .convai-widget input {\n font-family: inherit;\n border: none;\n outline: none;\n background: none;\n }\n\n .convai-widget::-webkit-scrollbar {\n width: 6px;\n }\n\n .convai-widget::-webkit-scrollbar-track {\n background: rgba(0, 0, 0, 0.05);\n border-radius: 3px;\n }\n\n .convai-widget::-webkit-scrollbar-thumb {\n background: rgba(0, 0, 0, 0.2);\n border-radius: 3px;\n }\n\n .convai-widget::-webkit-scrollbar-thumb:hover {\n background: rgba(0, 0, 0, 0.3);\n }\n`;\n\n/**\n * A document (the default) or a shadow root the widget is mounted inside.\n * `@keyframes` and global styles must be injected per-target because\n * shadow trees do not resolve rules defined in the document head.\n */\nexport type StyleTarget = Document | ShadowRoot;\n\n/** Ids of the injected <style> nodes. Public in effect: hosts and a second\n * copy of the SDK on the same page both key off them. */\nconst WIDGET_STYLES_ID = 'convai-widget-styles';\nconst WIDGET_KEYFRAMES_ID = 'convai-widget-keyframes';\n\n/** Targets that already hold the widget stylesheet. Per-target, so multiple\n * widget instances and shadow roots each get their own copy. */\nconst styledTargets = new WeakSet<StyleTarget>();\n\n/** Targets that already hold the widget's `@keyframes`. */\nconst keyframedTargets = new WeakSet<StyleTarget>();\n\n/** Where a <style> node should be appended for a given target. */\nconst styleHost = (target: StyleTarget): ShadowRoot | HTMLHeadElement =>\n target instanceof ShadowRoot ? target : target.head;\n\n/**\n * True when `target` already holds a <style> with this id.\n *\n * The WeakSets above dedup within one module instance. This is the\n * cross-bundle guard: two copies of the SDK on one page (an app bundling it\n * and an embed script loading its own) each get their own WeakSet, so without\n * an existence check they would both append a <style> carrying the same id.\n * Inert, but the pre-refactor inline code checked for this and it should not\n * regress.\n */\nconst hasStyleNode = (target: StyleTarget, id: string): boolean =>\n styleHost(target).querySelector(`#${id}`) !== null;\n\nconst WIDGET_KEYFRAMES = `\n @keyframes popIn {\n from { opacity: 0; transform: scale(0.95) translateY(-10px); }\n to { opacity: 1; transform: scale(1) translateY(0); }\n }\n\n /* Connecting overlay: logo spin + label pulse. Values match the React\n * widget's framer-motion transitions (ConvaiWidget.tsx:681-737) exactly --\n * a full turn every 2s linear, and opacity 0.5 -> 1 -> 0.5 every 2s\n * ease-in-out. React does not honour prefers-reduced-motion; vanilla does,\n * via the media query below, since a full-turn infinite spin plus a\n * pulsing label is exactly what that setting exists for. */\n @keyframes convaiConnectingSpin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n\n @keyframes convaiConnectingPulse {\n 0%, 100% { opacity: 0.5; }\n 50% { opacity: 1; }\n }\n\n /* Voice mode's avatar: two counter-rotating liquid-gradient layers behind\n * the character image. Matches the React overlay's framer-motion values\n * (VoiceModeOverlay.tsx) — 20s clockwise for the conic layer, 15s\n * anticlockwise for the radial one, both linear and infinite — and the\n * gentle scale breathing it applies while the character is speaking. */\n @keyframes convaiVoiceSpin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n\n @keyframes convaiVoiceSpinReverse {\n from { transform: rotate(360deg); }\n to { transform: rotate(0deg); }\n }\n\n @keyframes convaiVoiceBreathe {\n 0%, 100% { transform: scale(1); }\n 50% { transform: scale(1.05); }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .convai-connecting-spin {\n animation: none !important;\n }\n .convai-connecting-pulse {\n animation: none !important;\n }\n .convai-voice-gradient,\n .convai-voice-avatar {\n animation: none !important;\n }\n }\n`;\n\n/**\n * Inject the widget's global styles into a document or a shadow root.\n * Defaults to the document, so existing callers are unaffected.\n */\nexport const injectGlobalStyles = (target: StyleTarget = document): void => {\n if (styledTargets.has(target)) return;\n if (hasStyleNode(target, WIDGET_STYLES_ID)) {\n styledTargets.add(target);\n return;\n }\n\n const styleElement = document.createElement('style');\n styleElement.id = WIDGET_STYLES_ID;\n styleElement.textContent = getGlobalStyles();\n styleHost(target).appendChild(styleElement);\n\n styledTargets.add(target);\n};\n\n/**\n * Inject the widget's `@keyframes` (e.g. the settings tray's `popIn`)\n * into a document or a shadow root. `@keyframes` defined in the document\n * do not resolve for shadow content, so they must be injected into each\n * shadow root that uses them.\n */\nexport const injectKeyframes = (target: StyleTarget = document): void => {\n if (keyframedTargets.has(target)) return;\n if (hasStyleNode(target, WIDGET_KEYFRAMES_ID)) {\n keyframedTargets.add(target);\n return;\n }\n\n const style = document.createElement('style');\n style.id = WIDGET_KEYFRAMES_ID;\n style.textContent = WIDGET_KEYFRAMES;\n styleHost(target).appendChild(style);\n\n keyframedTargets.add(target);\n};\n\n/**\n * Helper to create inline styles object from theme\n */\nexport const createStyles = (styles: Record<string, any>): string => {\n return Object.entries(styles)\n .map(([key, value]) => {\n const cssKey = key.replace(/([A-Z])/g, '-$1').toLowerCase();\n return `${cssKey}: ${value}`;\n })\n .join('; ');\n};\n\n"]}
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/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AAM,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAErC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAA2B,EAAU,EAAE;IAClE,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SAC1B,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACpB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5D,OAAO,GAAG,MAAM,KAAK,KAAK,EAAE,CAAC;IAC/B,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\n * Vanilla Styles - Port of React theme system for vanilla implementations\n */\n\n// Theme configuration (matching React version)\nexport const aeroTheme = {\n colors: {\n primary: {\n 50: \"#f0f9ff\",\n 100: \"#e0f2fe\",\n 200: \"#bae6fd\",\n 300: \"#7dd3fc\",\n 400: \"#38bdf8\",\n 500: \"#0ea5e9\",\n 600: \"#0284c7\",\n 700: \"#0369a1\",\n 800: \"#075985\",\n 900: \"#0c4a6e\",\n },\n convai: {\n light: \"#1EB453\",\n medium: \"#0b6049\",\n dark: \"#084c3a\",\n },\n neutral: {\n 50: \"#fafafa\",\n 100: \"#f5f5f5\",\n 200: \"#e5e5e5\",\n 300: \"#d4d4d4\",\n 400: \"#a3a3a3\",\n 500: \"#737373\",\n 600: \"#525252\",\n 700: \"#404040\",\n 800: \"#262626\",\n 900: \"#171717\",\n },\n glass: {\n light: \"rgba(255, 255, 255, 0.1)\",\n medium: \"rgba(255, 255, 255, 0.15)\",\n dark: \"rgba(0, 0, 0, 0.1)\",\n backdrop: \"rgba(255, 255, 255, 0.8)\",\n card: \"rgba(255, 255, 255, 0.9)\",\n backdropLight: \"blur(20px)\",\n borderLight: \"1px solid rgba(255, 255, 255, 0.2)\",\n },\n accent: {\n purple: \"#8b5cf6\",\n green: \"#10b981\",\n blue: \"#3b82f6\",\n orange: \"#f59e0b\",\n red: \"#ef4444\",\n },\n error: {\n 50: \"#fef2f2\",\n 100: \"#fee2e2\",\n 200: \"#fecaca\",\n 300: \"#fca5a5\",\n 400: \"#f87171\",\n 500: \"#ef4444\",\n 600: \"#dc2626\",\n 700: \"#b91c1c\",\n 800: \"#991b1b\",\n 900: \"#7f1d1d\",\n },\n text: {\n primary: \"#1f2937\",\n secondary: \"#6b7280\",\n tertiary: \"#9ca3af\",\n inverse: \"#ffffff\",\n },\n },\n typography: {\n fontFamily: {\n primary: '\"Noto Sans\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\n body: '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\n mono: 'SF Mono, Monaco, \"Cascadia Code\", \"Roboto Mono\", Consolas, \"Courier New\", monospace',\n },\n fontSize: {\n xs: \"12px\",\n sm: \"14px\",\n base: \"16px\",\n lg: \"18px\",\n xl: \"20px\",\n \"2xl\": \"24px\",\n \"3xl\": \"30px\",\n \"4xl\": \"36px\",\n },\n fontWeight: {\n normal: 400,\n medium: 500,\n semibold: 600,\n bold: 700,\n },\n },\n spacing: {\n xs: \"4px\",\n sm: \"8px\",\n md: \"16px\",\n lg: \"24px\",\n xl: \"32px\",\n \"2xl\": \"48px\",\n \"3xl\": \"64px\",\n },\n borderRadius: {\n none: \"0\",\n sm: \"4px\",\n md: \"8px\",\n lg: \"12px\",\n xl: \"16px\",\n \"2xl\": \"24px\",\n full: \"9999px\",\n },\n shadows: {\n sm: \"0 1px 2px 0 rgba(0, 0, 0, 0.05)\",\n md: \"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)\",\n lg: \"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)\",\n xl: \"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)\",\n glass: \"0 8px 32px rgba(0, 0, 0, 0.1)\",\n },\n glass: {\n backdrop: \"blur(20px)\",\n backdropLight: \"blur(10px)\",\n backdropHeavy: \"blur(40px)\",\n border: \"1px solid rgba(255, 255, 255, 0.2)\",\n borderLight: \"1px solid rgba(255, 255, 255, 0.1)\",\n },\n transitions: {\n fast: \"0.15s ease-in-out\",\n normal: \"0.2s ease-in-out\",\n slow: \"0.3s ease-in-out\",\n spring: \"0.4s cubic-bezier(0.4, 0, 0.2, 1)\",\n snappy: \"all 0.1s ease-out\",\n },\n zIndex: {\n base: 1,\n dropdown: 1000,\n sticky: 1020,\n fixed: 1030,\n modal: 1040,\n popover: 1050,\n tooltip: 1060,\n },\n};\n\n/**\n * Global CSS styles for the Convai widget\n * This should be injected once into the document head\n */\nexport const getGlobalStyles = (): string => `\n @keyframes convai-pulse {\n 0%, 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.5;\n }\n }\n\n @keyframes convai-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n\n @keyframes convai-bounce {\n 0%, 100% {\n transform: translateY(0);\n }\n 50% {\n transform: translateY(-10px);\n }\n }\n\n @keyframes convai-slide-up {\n from {\n transform: translateY(20px);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n }\n\n @keyframes convai-slide-down {\n from {\n transform: translateY(-20px);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n }\n\n @keyframes convai-fade-in {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n\n @keyframes convai-scale-in {\n from {\n transform: scale(0.8);\n opacity: 0;\n }\n to {\n transform: scale(1);\n opacity: 1;\n }\n }\n\n .convai-widget * {\n box-sizing: border-box;\n }\n\n .convai-widget {\n font-family: var(--convai-font, ${aeroTheme.typography.fontFamily.primary});\n color: var(--convai-panel-fg, ${aeroTheme.colors.text.primary});\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n\n .convai-widget button {\n font-family: inherit;\n cursor: pointer;\n border: none;\n outline: none;\n background: none;\n padding: 0;\n margin: 0;\n }\n\n .convai-widget input {\n font-family: inherit;\n border: none;\n outline: none;\n background: none;\n }\n\n .convai-widget::-webkit-scrollbar {\n width: 6px;\n }\n\n .convai-widget::-webkit-scrollbar-track {\n background: rgba(0, 0, 0, 0.05);\n border-radius: 3px;\n }\n\n .convai-widget::-webkit-scrollbar-thumb {\n background: rgba(0, 0, 0, 0.2);\n border-radius: 3px;\n }\n\n .convai-widget::-webkit-scrollbar-thumb:hover {\n background: rgba(0, 0, 0, 0.3);\n }\n`;\n\n/**\n * A document (the default) or a shadow root the widget is mounted inside.\n * `@keyframes` and global styles must be injected per-target because\n * shadow trees do not resolve rules defined in the document head.\n */\nexport type StyleTarget = Document | ShadowRoot;\n\n/** Ids of the injected <style> nodes. Public in effect: hosts and a second\n * copy of the SDK on the same page both key off them. */\nconst WIDGET_STYLES_ID = 'convai-widget-styles';\nconst WIDGET_KEYFRAMES_ID = 'convai-widget-keyframes';\n\n/** Targets that already hold the widget stylesheet. Per-target, so multiple\n * widget instances and shadow roots each get their own copy. */\nconst styledTargets = new WeakSet<StyleTarget>();\n\n/** Targets that already hold the widget's `@keyframes`. */\nconst keyframedTargets = new WeakSet<StyleTarget>();\n\n/** Where a <style> node should be appended for a given target. */\nconst styleHost = (target: StyleTarget): ShadowRoot | HTMLHeadElement =>\n target instanceof ShadowRoot ? target : target.head;\n\n/**\n * True when `target` already holds a <style> with this id.\n *\n * The WeakSets above dedup within one module instance. This is the\n * cross-bundle guard: two copies of the SDK on one page (an app bundling it\n * and an embed script loading its own) each get their own WeakSet, so without\n * an existence check they would both append a <style> carrying the same id.\n * Inert, but the pre-refactor inline code checked for this and it should not\n * regress.\n */\nconst hasStyleNode = (target: StyleTarget, id: string): boolean =>\n styleHost(target).querySelector(`#${id}`) !== null;\n\nconst WIDGET_KEYFRAMES = `\n @keyframes popIn {\n from { opacity: 0; transform: scale(0.95) translateY(-10px); }\n to { opacity: 1; transform: scale(1) translateY(0); }\n }\n\n /* Link-preview skeleton: one sweep across the placeholder while the media\n * decodes. Lives here rather than in getGlobalStyles() because that string is\n * pinned byte-for-byte by the inline-style parity fixture, and this is an\n * addition no existing element uses. */\n @keyframes convai-preview-shimmer {\n from { background-position: 200% 0; }\n to { background-position: -200% 0; }\n }\n\n /* Connecting overlay: logo spin + label pulse. Values match the React\n * widget's framer-motion transitions (ConvaiWidget.tsx:681-737) exactly --\n * a full turn every 2s linear, and opacity 0.5 -> 1 -> 0.5 every 2s\n * ease-in-out. React does not honour prefers-reduced-motion; vanilla does,\n * via the media query below, since a full-turn infinite spin plus a\n * pulsing label is exactly what that setting exists for. */\n @keyframes convaiConnectingSpin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n\n @keyframes convaiConnectingPulse {\n 0%, 100% { opacity: 0.5; }\n 50% { opacity: 1; }\n }\n\n /* Voice mode's avatar: two counter-rotating liquid-gradient layers behind\n * the character image. Matches the React overlay's framer-motion values\n * (VoiceModeOverlay.tsx) — 20s clockwise for the conic layer, 15s\n * anticlockwise for the radial one, both linear and infinite — and the\n * gentle scale breathing it applies while the character is speaking. */\n @keyframes convaiVoiceSpin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n\n @keyframes convaiVoiceSpinReverse {\n from { transform: rotate(360deg); }\n to { transform: rotate(0deg); }\n }\n\n @keyframes convaiVoiceBreathe {\n 0%, 100% { transform: scale(1); }\n 50% { transform: scale(1.05); }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .convai-connecting-spin {\n animation: none !important;\n }\n .convai-connecting-pulse {\n animation: none !important;\n }\n .convai-voice-gradient,\n .convai-voice-avatar {\n animation: none !important;\n }\n [data-convai-skeleton] {\n animation: none !important;\n }\n }\n`;\n\n/**\n * Inject the widget's global styles into a document or a shadow root.\n * Defaults to the document, so existing callers are unaffected.\n */\nexport const injectGlobalStyles = (target: StyleTarget = document): void => {\n if (styledTargets.has(target)) return;\n if (hasStyleNode(target, WIDGET_STYLES_ID)) {\n styledTargets.add(target);\n return;\n }\n\n const styleElement = document.createElement('style');\n styleElement.id = WIDGET_STYLES_ID;\n styleElement.textContent = getGlobalStyles();\n styleHost(target).appendChild(styleElement);\n\n styledTargets.add(target);\n};\n\n/**\n * Inject the widget's `@keyframes` (e.g. the settings tray's `popIn`)\n * into a document or a shadow root. `@keyframes` defined in the document\n * do not resolve for shadow content, so they must be injected into each\n * shadow root that uses them.\n */\nexport const injectKeyframes = (target: StyleTarget = document): void => {\n if (keyframedTargets.has(target)) return;\n if (hasStyleNode(target, WIDGET_KEYFRAMES_ID)) {\n keyframedTargets.add(target);\n return;\n }\n\n const style = document.createElement('style');\n style.id = WIDGET_KEYFRAMES_ID;\n style.textContent = WIDGET_KEYFRAMES;\n styleHost(target).appendChild(style);\n\n keyframedTargets.add(target);\n};\n\n/**\n * Helper to create inline styles object from theme\n */\nexport const createStyles = (styles: Record<string, any>): string => {\n return Object.entries(styles)\n .map(([key, value]) => {\n const cssKey = key.replace(/([A-Z])/g, '-$1').toLowerCase();\n return `${cssKey}: ${value}`;\n })\n .join('; ');\n};\n\n"]}
@@ -1,4 +1,5 @@
1
- import type { IConvaiClient, ChatMessage } from '../core/types.js';
1
+ import type { IConvaiClient, ChatMessage, PublishedChatConnectOptions } from '../core/types.js';
2
+ import type { PublishedChatDescriptor } from '../embed/publicationApi.js';
2
3
  /** Where the widget anchors itself. `inline` renders it in normal document flow. */
3
4
  export type WidgetPlacement = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'inline';
4
5
  /**
@@ -67,6 +68,12 @@ export interface VanillaWidgetOptions {
67
68
  * When true, the widget will open directly in voice mode with microphone enabled.
68
69
  */
69
70
  defaultVoiceMode?: boolean;
71
+ /** Mint a fresh single-use grant when a published-chat session is reopened. */
72
+ requestPublicationGrant?: () => Promise<string>;
73
+ /** Core endpoint override used with requestPublicationGrant. */
74
+ publishedChatConnectOptions?: PublishedChatConnectOptions;
75
+ /** Public descriptor used to label a credential-free published session. */
76
+ publishedChatDescriptor?: Pick<PublishedChatDescriptor, 'display_name' | 'image_url'>;
70
77
  /**
71
78
  * Where the widget's `<style>` and `@keyframes` nodes are injected.
72
79
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vanilla/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEhE,oFAAoF;AACpF,MAAM,MAAM,eAAe,GACvB,cAAc,GACd,aAAa,GACb,WAAW,GACX,UAAU,GACV,QAAQ,CAAC;AAEb;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,aAAa,GAAG;QAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,WAAW,EAAE,CAAC;QAC5B;;;;;;WAMG;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;KAChD,CAAC;IAEF,gHAAgH;IAChH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oGAAoG;IACpG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mEAAmE;IACnE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wEAAwE;IACxE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kGAAkG;IAClG,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE;QACjB,qFAAqF;QACrF,MA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AAqC;IACrC,OAAO,EAAE,WAAW,CAAC;IACrB,qCAAqC;IACrC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,iCAAiC;IACjC,MAAM,EAAE,aAAa,GAAG;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,WAAW,EAAE,CAAC;QAC5B,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;KAChD,CAAC;IACF,kDAAkD;IAClD,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;IAE1D;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;;;;;;OAOG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;;OAIG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,aAAa,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAC/E"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/vanilla/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IConvaiClient, ChatMessage } from '../core/types';\n\n/** Where the widget anchors itself. `inline` renders it in normal document flow. */\nexport type WidgetPlacement =\n | 'bottom-right'\n | 'bottom-left'\n | 'top-right'\n | 'top-left'\n | 'inline';\n\n/**\n * Options for creating a vanilla ConvaiWidget\n * \n * You can either:\n * 1. Pass an existing convaiClient instance, OR\n * 2. Pass connection config (apiKey, characterId, etc.) directly\n */\nexport interface VanillaWidgetOptions {\n /** \n * Option 1: Pass an existing Convai client instance.\n * Should be initialized with config: new ConvaiClient({ apiKey, characterId, ... })\n * The widget will auto-connect on first click.\n */\n convaiClient?: IConvaiClient & {\n activity?: string;\n chatMessages: ChatMessage[];\n /**\n * Present on the real `ConvaiClient` (it extends `EventEmitter`) and on\n * the test stubs; absent only if a caller hand-rolls a minimal\n * `IConvaiClient`. Optional so that case still type-checks -- the widget\n * calls it defensively (`client.emit?.(...)`) to surface mic-permission\n * failures on the same `error` channel `ConvaiClient` already uses.\n */\n emit?: (event: string, ...args: any[]) => void;\n };\n \n /** Option 2: Pass connection config directly (convenience shortcut). Either apiKey or authToken is required. */\n apiKey?: string;\n /** Auth token for realtime API (alternative to apiKey). See https://realtime-api.convai.com/docs */\n authToken?: string;\n characterId?: string;\n enableVideo?: boolean;\n startWithVideoOn?: boolean;\n /** Enable lipsync/facial animation blendshapes (default: false) */\n enableLipsync?: boolean;\n /** Enable emotion detection and bot-emotion updates (default: false) */\n enableEmotion?: boolean;\n /** Log incoming and outgoing decoded RTVI data messages to the browser console (default: true) */\n logRtviMessages?: boolean;\n /** Blendshape configuration for facial animation format */\n blendshapeConfig?: {\n /** Format of blendshapes: \"arkit\" or \"mha\" (Meta Human Animation, default: \"mha\") */\n format?: \"arkit\" | \"mha\";\n /** Custom mapper function to transform incoming blendshapes */\n customMapper?: (input: number[] | Float32Array) => Float32Array;\n /** Indexed NeuroSync ahead-delivery. Defaults to true; set false for the legacy paced path. */\n deliver_chunks_ahead?: boolean;\n /** Ahead-delivery timeline FPS override; ignored when deliver_chunks_ahead is false. */\n output_fps?: number;\n /** Seconds the server buffers blendshapes before releasing them. */\n frames_buffer_duration?: number;\n };\n \n /** \n * Show video toggle button in settings (default: true).\n * Only works if connection type is \"video\". If false, hides the video button.\n */\n showVideo?: boolean;\n /** \n * Show screen share toggle button in settings (default: true).\n * Only works if connection type is \"video\". If false, hides the screen share button.\n */\n showScreenShare?: boolean;\n /**\n * Start in voice mode by default when widget opens (default: true).\n * When true, the widget will open directly in voice mode with microphone enabled.\n */\n defaultVoiceMode?: boolean;\n \n /**\n * Where the widget's `<style>` and `@keyframes` nodes are injected.\n *\n * Omit it and the target is derived from `container.getRootNode()` at\n * construction time — correct only when the container is *already* inside\n * its final root. A custom element that builds its subtree first and appends\n * it to its shadow root afterwards (the usual pattern) constructs the widget\n * while the container is still detached, so the derivation sees the\n * document and the shadow root never receives the stylesheet or the `popIn`\n * keyframes — silently, with no error. Pass the shadow root here in that\n * case; when supplied it is used verbatim and no derivation happens.\n */\n styleTarget?: Document | ShadowRoot;\n\n /** Corner to anchor to, or `inline` for normal flow. Default `bottom-right`. */\n placement?: WidgetPlacement;\n\n /** Optional callbacks */\n onConnect?: () => void;\n onDisconnect?: () => void;\n onMessage?: (message: ChatMessage) => void;\n}\n\n/**\n * Vanilla ConvaiWidget instance with cleanup method\n */\nexport interface VanillaWidget {\n /** Root DOM element of the widget */\n element: HTMLElement;\n /** Cleanup and destroy the widget */\n destroy: () => void;\n /** The Convai client instance */\n client: IConvaiClient & {\n activity?: string;\n chatMessages: ChatMessage[];\n emit?: (event: string, ...args: any[]) => void;\n };\n /** Update widget state (for future extensions) */\n update?: (options: Partial<VanillaWidgetOptions>) => void;\n\n /**\n * Open the panel. Drives the same internal open path as the launcher\n * click (connect-on-first-open, then the morph to the panel). Idempotent:\n * calling `open()` while already open — or while a first open is still\n * waiting on `connect()` — is a no-op. It will not re-run the morph\n * animation, and it will not start a second connect.\n */\n open: () => void;\n /**\n * Close the panel. Drives the same internal path as the header's close\n * button. Idempotent: calling `close()` while already closed is a no-op.\n *\n * Called while a first open is still connecting, it *cancels* that open:\n * the connect completes (the client ends up connected) but the panel stays\n * collapsed rather than popping open once the promise resolves.\n */\n close: () => void;\n /**\n * Toggle the panel open or closed, per the current {@link isOpen} state.\n * Mid-connect this closes — i.e. a second click cancels the open in flight,\n * rather than queueing a second one.\n */\n toggle: () => void;\n /**\n * Whether the panel is open, or is opening. This is *requested* state, and\n * it updates synchronously: `widget.open(); widget.isOpen` is always `true`,\n * including on a cold client where the panel is only committed once\n * `connect()` resolves seconds later. Cancelling that open (via `close()`,\n * `toggle()`, or a second launcher click) returns it to `false`\n * immediately.\n *\n * The distinction matters only for the first open on a disconnected client;\n * every other transition is synchronous, so rendered and requested state\n * coincide. Consumers reconciling their own open/close events against this\n * flag get the answer that matches the user's last instruction, not the\n * animation frame.\n */\n readonly isOpen: boolean;\n /**\n * Insert a message into the transcript locally, without sending it to the\n * character. Use this for client-side lines — e.g. a greeting — that must\n * appear in the chat but must never reach the LLM and must never be billed\n * as a turn. This is not `sendUserTextMessage`: nothing is transmitted.\n */\n appendMessage: (message: { sender: \"user\" | \"bot\"; content: string }) => void;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/vanilla/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n IConvaiClient,\n ChatMessage,\n PublishedChatConnectOptions,\n} from '../core/types';\nimport type { PublishedChatDescriptor } from '../embed/publicationApi';\n\n/** Where the widget anchors itself. `inline` renders it in normal document flow. */\nexport type WidgetPlacement =\n | 'bottom-right'\n | 'bottom-left'\n | 'top-right'\n | 'top-left'\n | 'inline';\n\n/**\n * Options for creating a vanilla ConvaiWidget\n * \n * You can either:\n * 1. Pass an existing convaiClient instance, OR\n * 2. Pass connection config (apiKey, characterId, etc.) directly\n */\nexport interface VanillaWidgetOptions {\n /** \n * Option 1: Pass an existing Convai client instance.\n * Should be initialized with config: new ConvaiClient({ apiKey, characterId, ... })\n * The widget will auto-connect on first click.\n */\n convaiClient?: IConvaiClient & {\n activity?: string;\n chatMessages: ChatMessage[];\n /**\n * Present on the real `ConvaiClient` (it extends `EventEmitter`) and on\n * the test stubs; absent only if a caller hand-rolls a minimal\n * `IConvaiClient`. Optional so that case still type-checks -- the widget\n * calls it defensively (`client.emit?.(...)`) to surface mic-permission\n * failures on the same `error` channel `ConvaiClient` already uses.\n */\n emit?: (event: string, ...args: any[]) => void;\n };\n \n /** Option 2: Pass connection config directly (convenience shortcut). Either apiKey or authToken is required. */\n apiKey?: string;\n /** Auth token for realtime API (alternative to apiKey). See https://realtime-api.convai.com/docs */\n authToken?: string;\n characterId?: string;\n enableVideo?: boolean;\n startWithVideoOn?: boolean;\n /** Enable lipsync/facial animation blendshapes (default: false) */\n enableLipsync?: boolean;\n /** Enable emotion detection and bot-emotion updates (default: false) */\n enableEmotion?: boolean;\n /** Log incoming and outgoing decoded RTVI data messages to the browser console (default: true) */\n logRtviMessages?: boolean;\n /** Blendshape configuration for facial animation format */\n blendshapeConfig?: {\n /** Format of blendshapes: \"arkit\" or \"mha\" (Meta Human Animation, default: \"mha\") */\n format?: \"arkit\" | \"mha\";\n /** Custom mapper function to transform incoming blendshapes */\n customMapper?: (input: number[] | Float32Array) => Float32Array;\n /** Indexed NeuroSync ahead-delivery. Defaults to true; set false for the legacy paced path. */\n deliver_chunks_ahead?: boolean;\n /** Ahead-delivery timeline FPS override; ignored when deliver_chunks_ahead is false. */\n output_fps?: number;\n /** Seconds the server buffers blendshapes before releasing them. */\n frames_buffer_duration?: number;\n };\n \n /** \n * Show video toggle button in settings (default: true).\n * Only works if connection type is \"video\". If false, hides the video button.\n */\n showVideo?: boolean;\n /** \n * Show screen share toggle button in settings (default: true).\n * Only works if connection type is \"video\". If false, hides the screen share button.\n */\n showScreenShare?: boolean;\n /**\n * Start in voice mode by default when widget opens (default: true).\n * When true, the widget will open directly in voice mode with microphone enabled.\n */\n defaultVoiceMode?: boolean;\n /** Mint a fresh single-use grant when a published-chat session is reopened. */\n requestPublicationGrant?: () => Promise<string>;\n /** Core endpoint override used with requestPublicationGrant. */\n publishedChatConnectOptions?: PublishedChatConnectOptions;\n /** Public descriptor used to label a credential-free published session. */\n publishedChatDescriptor?: Pick<\n PublishedChatDescriptor,\n 'display_name' | 'image_url'\n >;\n \n /**\n * Where the widget's `<style>` and `@keyframes` nodes are injected.\n *\n * Omit it and the target is derived from `container.getRootNode()` at\n * construction time — correct only when the container is *already* inside\n * its final root. A custom element that builds its subtree first and appends\n * it to its shadow root afterwards (the usual pattern) constructs the widget\n * while the container is still detached, so the derivation sees the\n * document and the shadow root never receives the stylesheet or the `popIn`\n * keyframes — silently, with no error. Pass the shadow root here in that\n * case; when supplied it is used verbatim and no derivation happens.\n */\n styleTarget?: Document | ShadowRoot;\n\n /** Corner to anchor to, or `inline` for normal flow. Default `bottom-right`. */\n placement?: WidgetPlacement;\n\n /** Optional callbacks */\n onConnect?: () => void;\n onDisconnect?: () => void;\n onMessage?: (message: ChatMessage) => void;\n}\n\n/**\n * Vanilla ConvaiWidget instance with cleanup method\n */\nexport interface VanillaWidget {\n /** Root DOM element of the widget */\n element: HTMLElement;\n /** Cleanup and destroy the widget */\n destroy: () => void;\n /** The Convai client instance */\n client: IConvaiClient & {\n activity?: string;\n chatMessages: ChatMessage[];\n emit?: (event: string, ...args: any[]) => void;\n };\n /** Update widget state (for future extensions) */\n update?: (options: Partial<VanillaWidgetOptions>) => void;\n\n /**\n * Open the panel. Drives the same internal open path as the launcher\n * click (connect-on-first-open, then the morph to the panel). Idempotent:\n * calling `open()` while already open — or while a first open is still\n * waiting on `connect()` — is a no-op. It will not re-run the morph\n * animation, and it will not start a second connect.\n */\n open: () => void;\n /**\n * Close the panel. Drives the same internal path as the header's close\n * button. Idempotent: calling `close()` while already closed is a no-op.\n *\n * Called while a first open is still connecting, it *cancels* that open:\n * the connect completes (the client ends up connected) but the panel stays\n * collapsed rather than popping open once the promise resolves.\n */\n close: () => void;\n /**\n * Toggle the panel open or closed, per the current {@link isOpen} state.\n * Mid-connect this closes — i.e. a second click cancels the open in flight,\n * rather than queueing a second one.\n */\n toggle: () => void;\n /**\n * Whether the panel is open, or is opening. This is *requested* state, and\n * it updates synchronously: `widget.open(); widget.isOpen` is always `true`,\n * including on a cold client where the panel is only committed once\n * `connect()` resolves seconds later. Cancelling that open (via `close()`,\n * `toggle()`, or a second launcher click) returns it to `false`\n * immediately.\n *\n * The distinction matters only for the first open on a disconnected client;\n * every other transition is synchronous, so rendered and requested state\n * coincide. Consumers reconciling their own open/close events against this\n * flag get the answer that matches the user's last instruction, not the\n * animation frame.\n */\n readonly isOpen: boolean;\n /**\n * Insert a message into the transcript locally, without sending it to the\n * character. Use this for client-side lines — e.g. a greeting — that must\n * appear in the chat but must never reach the LLM and must never be billed\n * as a turn. This is not `sendUserTextMessage`: nothing is transmitted.\n */\n appendMessage: (message: { sender: \"user\" | \"bot\"; content: string }) => void;\n}\n"]}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "1.8.0-beta.6";
1
+ export declare const SDK_VERSION = "1.8.0-beta.8";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // GENERATED by scripts/sync-version.mjs — do not edit by hand.
2
2
  // Regenerated from package.json on every build.
3
- export const SDK_VERSION = "1.8.0-beta.6";
3
+ export const SDK_VERSION = "1.8.0-beta.8";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,gDAAgD;AAChD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC","sourcesContent":["// GENERATED by scripts/sync-version.mjs — do not edit by hand.\n// Regenerated from package.json on every build.\nexport const SDK_VERSION = \"1.8.0-beta.6\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,gDAAgD;AAChD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC","sourcesContent":["// GENERATED by scripts/sync-version.mjs — do not edit by hand.\n// Regenerated from package.json on every build.\nexport const SDK_VERSION = \"1.8.0-beta.8\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@convai/web-sdk",
3
- "version": "1.8.0-beta.6",
3
+ "version": "1.8.0-beta.8",
4
4
  "description": "Build web apps with lifelike AI characters. The Convai Web SDK gives you real-time voice, lipsync, emotions, and dynamic context — with first-class support for React and vanilla TypeScript.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -9,49 +9,78 @@
9
9
  "types": "dist/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
+ "types": "./dist/index.d.ts",
12
13
  "import": "./dist/index.js",
13
- "types": "./dist/index.d.ts"
14
+ "require": "./dist/index.js",
15
+ "default": "./dist/index.js"
14
16
  },
15
17
  "./core": {
18
+ "types": "./dist/core/index.d.ts",
16
19
  "import": "./dist/core/index.js",
17
- "types": "./dist/core/index.d.ts"
20
+ "require": "./dist/core/index.js",
21
+ "default": "./dist/core/index.js"
18
22
  },
19
23
  "./vanilla": {
24
+ "types": "./dist/vanilla/index.d.ts",
20
25
  "import": "./dist/vanilla/index.js",
21
- "types": "./dist/vanilla/index.d.ts"
26
+ "require": "./dist/vanilla/index.js",
27
+ "default": "./dist/vanilla/index.js"
22
28
  },
23
29
  "./vanilla/websocket": {
30
+ "types": "./dist/vanilla/websocket.d.ts",
24
31
  "import": "./dist/vanilla/websocket.js",
25
- "types": "./dist/vanilla/websocket.d.ts"
32
+ "require": "./dist/vanilla/websocket.js",
33
+ "default": "./dist/vanilla/websocket.js"
34
+ },
35
+ "./embed": {
36
+ "types": "./dist/embed/index.d.ts",
37
+ "import": "./dist/embed/index.js",
38
+ "require": "./dist/embed/index.js",
39
+ "default": "./dist/embed/index.js"
40
+ },
41
+ "./embed/browser": {
42
+ "types": "./dist/embed/browser.d.ts",
43
+ "import": "./dist/embed/chat-embed-v1.js",
44
+ "require": "./dist/embed/chat-embed-v1.js",
45
+ "default": "./dist/embed/chat-embed-v1.js"
26
46
  },
27
47
  "./react": {
48
+ "types": "./dist/react/index.d.ts",
28
49
  "import": "./dist/react/index.js",
29
- "types": "./dist/react/index.d.ts"
50
+ "require": "./dist/react/index.js",
51
+ "default": "./dist/react/index.js"
30
52
  },
31
53
  "./lipsync-helpers": {
54
+ "types": "./dist/lipsync-helpers/index.d.ts",
32
55
  "import": "./dist/lipsync-helpers/index.js",
33
- "types": "./dist/lipsync-helpers/index.d.ts"
56
+ "require": "./dist/lipsync-helpers/index.js",
57
+ "default": "./dist/lipsync-helpers/index.js"
34
58
  },
35
59
  "./package.json": "./package.json"
36
60
  },
37
61
  "sideEffects": [
62
+ "./dist/embed/browser.js",
63
+ "./dist/embed/chat-embed-v1.js",
38
64
  "./dist/vanilla/websocket.js",
65
+ "./src/embed/browser.ts",
39
66
  "./src/vanilla/websocket.ts"
40
67
  ],
41
68
  "publishConfig": {
42
69
  "access": "public"
43
70
  },
44
71
  "scripts": {
45
- "build": "node scripts/sync-version.mjs && tsc -p tsconfig.build.json && node scripts/fix-dist-extensions.mjs && pnpm typecheck:downstream",
46
- "build:fast": "node scripts/sync-version.mjs && tsc -p tsconfig.build.json && node scripts/fix-dist-extensions.mjs",
47
- "build:prod": "node scripts/sync-version.mjs && NODE_ENV=production tsc -p tsconfig.build.json && node scripts/fix-dist-extensions.mjs && pnpm typecheck:downstream",
72
+ "build": "node scripts/sync-version.mjs && tsc -p tsconfig.build.json && node scripts/fix-dist-extensions.mjs && pnpm build:embed && pnpm typecheck:downstream",
73
+ "build:fast": "node scripts/sync-version.mjs && tsc -p tsconfig.build.json && node scripts/fix-dist-extensions.mjs && pnpm build:embed",
74
+ "build:prod": "node scripts/sync-version.mjs && NODE_ENV=production tsc -p tsconfig.build.json && node scripts/fix-dist-extensions.mjs && pnpm build:embed && pnpm typecheck:downstream",
75
+ "build:embed": "esbuild src/embed/browser.ts --bundle --format=esm --platform=browser --target=es2020 --outfile=dist/embed/chat-embed-v1.js --minify --sourcemap",
48
76
  "dev": "tsc -p tsconfig.build.json --watch",
49
77
  "clean": "rimraf dist",
50
78
  "fix:ext": "node scripts/fix-dist-extensions.mjs",
51
79
  "typecheck": "tsc --noEmit",
80
+ "test": "vitest run",
81
+ "test:protocol": "tsc && node --test tests/modelOutput.test.mjs tests/actionResultAck.test.mjs tests/visionPromptMode.test.mjs",
52
82
  "typecheck:downstream": "pnpm -r --filter './examples/**' exec tsc -b --noEmit && pnpm -r --filter './doc-tests/**' exec tsc --noEmit",
53
83
  "typecheck:all": "pnpm typecheck && pnpm typecheck:downstream",
54
- "test": "vitest run",
55
84
  "test:watch": "vitest",
56
85
  "verify": "vitest run && tsc && tsc -p tsconfig.build.json && pnpm -r --filter './doc-tests/**' exec tsc --noEmit",
57
86
  "test:lipsync": "tsc && node scripts/test-neurosync-ahead.mjs",
@@ -129,10 +158,16 @@
129
158
  "happy-dom": "^15.11.7",
130
159
  "rimraf": "^5.0.0",
131
160
  "typescript": "^5.7.3",
132
- "vitest": "^2.1.9"
161
+ "vitest": "^3.2.4"
133
162
  },
134
163
  "files": [
135
164
  "dist",
136
165
  "README.md"
137
- ]
166
+ ],
167
+ "pnpm": {
168
+ "onlyBuiltDependencies": [
169
+ "esbuild"
170
+ ]
171
+ },
172
+ "packageManager": "pnpm@10.10.0"
138
173
  }