@kaltura-sdk/avatars 1.15.0 → 1.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1,47 @@
1
- # Unisphere Genie - Package Avatars
1
+ # @kaltura-sdk/avatars
2
+
3
+ Core implementation of `AvatarClientManager` — the state machine-driven client for Kaltura's conversational avatar. Runs on `xstate` + `@unisphere/core` reactive stores; owns the whole connection lifecycle (RTC session, chat, captions, screen share, tap-to-talk, client tools, Kaltura context).
4
+
5
+ For a framework-free, CDN-loadable build, use [`@kaltura-sdk/avatars-esm`](../avatars-esm) — it re-exports this package.
6
+
7
+ ## Usage
8
+
9
+ ```ts
10
+ import { AvatarClientManager } from '@kaltura-sdk/avatars';
11
+
12
+ const manager = new AvatarClientManager({
13
+ actions: { showNotification }, // optional, defaults to a noop
14
+ debugMode: true, // optional, default false
15
+ logger, // optional — UnisphereLoggerType, defaults to an internal 'avatar-client' logger
16
+ runtimeSettings, // AvatarRuntimeSettings
17
+ kalturaAnalyticsService, // optional, no-ops if omitted
18
+ pubSubService, // optional, no-ops if omitted
19
+ registerDeveloperTools: (actor) => {}, // optional, e.g. xstate inspector
20
+ videoContainerId: 'avatar-video', // optional — auto-joins STV once castMode is "webrtc"
21
+ });
22
+
23
+ manager.connectionStatus.onChanges((status) => console.log(status));
24
+ manager.connect({ dynamicVariables, kickOffPhrase });
25
+ manager.disconnect();
26
+ manager.stop(); // full teardown, unsubscribes everything
27
+ ```
28
+
29
+ `connect()`/`disconnect()` are sync (fire-and-forget) — read outcomes off the reactive stores (`connectionStatus`, `castMode`, `disconnectData`, etc).
30
+
31
+ ## API surface
32
+
33
+ - **Lifecycle**: `connect()`, `disconnect()`, `reconnect()`, `stop()`, `connectionStatus`, `playerUrl`, `sessionId`, `castMode`, `turnServerURL`, `disconnectData`
34
+ - **Pause/resume**: `pause()`, `resume()`, `pauseAfterSpeaking()`, `isPaused`
35
+ - **Chat & content**: `askViaText()`, `chatLog`, `content`, `setLocalContent()`, `clearContent()`, `agentData`
36
+ - **Screen share**: `startScreenShare()`, `stopScreenShare()`, `screenShareInfo`
37
+ - **Tap-to-talk**: `tapToTalkStart()`, `tapToTalkEnd()`, `toggleTapToTalkMode()`, `tapToTalkInfo`
38
+ - **Captions**: `captions` (state + `toggle`/`setReplacements`/`setFilter`)
39
+ - **Kaltura context**: `kalturaContext`, `toggleKalturaContext()`, `updateDynamicVariables()`
40
+ - **Client tools**: `registerClientTools()`, `unregisterClientTools()`, `registeredClientTools`, `clientToolCallLog`
41
+ - **Session metadata**: `threadId`, `setExternalThreadId()`, `isPreviewMode`, `contextSelectorVisible`, `features`, `agentPreviewUrl`, `agentPreviewImageUrl`, `serverUrl`
42
+ - **RTC/device passthrough**: `audioState`, `audioVolumeLevel`, `devicesList`, `joinSTV()`, `leaveSTV()`, `changeDevice()`, `toggleMuteAudio()`
43
+ - **Player events**: `onPlayerReady()`, `onPlayerError()`
44
+
45
+ All getters return `@unisphere/core` reactive stores (`.consumer`, subscribe via `.onChanges`).
46
+
47
+ `connection` is a deprecated back-compat facade kept only for consumers not yet migrated to the manager's own getters/methods.
package/index.esm.js CHANGED
@@ -23630,6 +23630,11 @@ const noopPubSubService = {
23630
23630
  // noop
23631
23631
  }
23632
23632
  };
23633
+ const noopAvatarClientManagerActions = {
23634
+ showNotification: () => {
23635
+ // noop
23636
+ }
23637
+ };
23633
23638
  /**
23634
23639
  * Avatar-domain manager on top of the generic `ActorManager` engine: owns
23635
23640
  * the `avatarConnectionMachine` actor and exposes it as reactive stores +
@@ -23640,6 +23645,7 @@ const noopPubSubService = {
23640
23645
  */
23641
23646
  class AvatarClientManager extends ActorManager {
23642
23647
  constructor(_config) {
23648
+ var _a;
23643
23649
  super();
23644
23650
  this._config = _config;
23645
23651
  // keep separate from other subscriptions since we don't want to stop when disconnect only when stop called
@@ -23790,7 +23796,7 @@ class AvatarClientManager extends ActorManager {
23790
23796
  this._contextSelectorVisible = new TinyDataStore({
23791
23797
  initialValue: true
23792
23798
  });
23793
- this._logger = this._config.logger;
23799
+ this._logger = (_a = this._config.logger) !== null && _a !== void 0 ? _a : avatarClientLoggerFactory.getOrCreateLogger('service', 'avatar-client');
23794
23800
  if (this._config.runtimeSettings.features) {
23795
23801
  this._features.setData(() => this._config.runtimeSettings.features);
23796
23802
  }
@@ -24002,7 +24008,7 @@ class AvatarClientManager extends ActorManager {
24002
24008
  return this._agentData.consumer;
24003
24009
  }
24004
24010
  connect(options) {
24005
- var _a, _b, _c, _d, _e;
24011
+ var _a, _b, _c, _d, _e, _f, _g;
24006
24012
  this._lastConnectOptions = options;
24007
24013
  this._onThreadIdChange = options === null || options === void 0 ? void 0 : options.onThreadIdChange;
24008
24014
  if (this._connection.getData()) {
@@ -24020,11 +24026,11 @@ class AvatarClientManager extends ActorManager {
24020
24026
  input: Object.assign({
24021
24027
  connectionId,
24022
24028
  logger: this._logger,
24023
- debugMode: this._config.debugMode,
24024
- kalturaAnalyticsService: (_a = this._config.kalturaAnalyticsService) !== null && _a !== void 0 ? _a : noopKalturaAnalyticsService,
24025
- pubSubService: (_b = this._config.pubSubService) !== null && _b !== void 0 ? _b : noopPubSubService,
24029
+ debugMode: (_a = this._config.debugMode) !== null && _a !== void 0 ? _a : false,
24030
+ kalturaAnalyticsService: (_b = this._config.kalturaAnalyticsService) !== null && _b !== void 0 ? _b : noopKalturaAnalyticsService,
24031
+ pubSubService: (_c = this._config.pubSubService) !== null && _c !== void 0 ? _c : noopPubSubService,
24026
24032
  externalActions: {
24027
- showNotification: this._config.actions.showNotification
24033
+ showNotification: ((_d = this._config.actions) !== null && _d !== void 0 ? _d : noopAvatarClientManagerActions).showNotification
24028
24034
  },
24029
24035
  runtimeSettings: this._config.runtimeSettings,
24030
24036
  videoContainerId: this._config.videoContainerId,
@@ -24033,14 +24039,14 @@ class AvatarClientManager extends ActorManager {
24033
24039
  kickOffPhrase: options === null || options === void 0 ? void 0 : options.kickOffPhrase,
24034
24040
  clientToolsRegistry: this._clientToolsRegistry,
24035
24041
  getClientToolHandler: this._getClientToolHandler
24036
- }, ((_c = options === null || options === void 0 ? void 0 : options.context) === null || _c === void 0 ? void 0 : _c.type) === 'thread' && {
24042
+ }, ((_e = options === null || options === void 0 ? void 0 : options.context) === null || _e === void 0 ? void 0 : _e.type) === 'thread' && {
24037
24043
  threadId: options.context.threadId,
24038
24044
  messageId: options.context.messageId
24039
24045
  })
24040
24046
  });
24041
24047
  this._logsInitialized = false;
24042
24048
  this._setupActorSync(actor);
24043
- (_e = (_d = this._config).registerDeveloperTools) === null || _e === void 0 ? void 0 : _e.call(_d, actor);
24049
+ (_g = (_f = this._config).registerDeveloperTools) === null || _g === void 0 ? void 0 : _g.call(_f, actor);
24044
24050
  actor.start();
24045
24051
  }
24046
24052
  disconnect() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaltura-sdk/avatars",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "author": "kaltura",
5
5
  "license": "AGPL-3.0",
6
6
  "repository": {
@@ -58,9 +58,9 @@ export declare class AvatarClientManager extends ActorManager<AvatarConnectionAc
58
58
  private readonly _isPreviewMode;
59
59
  private readonly _contextSelectorVisible;
60
60
  constructor(_config: {
61
- actions: AvatarClientManagerActions;
62
- debugMode: boolean;
63
- logger: UnisphereLoggerType;
61
+ actions?: AvatarClientManagerActions;
62
+ debugMode?: boolean;
63
+ logger?: UnisphereLoggerType;
64
64
  kalturaAnalyticsService?: KalturaAnalyticsServiceType;
65
65
  pubSubService?: PubSubServiceType;
66
66
  runtimeSettings: AvatarRuntimeSettings;