uneeq-js 2.42.3 → 2.44.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.
@@ -0,0 +1,6 @@
1
+ import { ResumeSessionCheckResponse } from '../types/ResumeSessionCheckResponse';
2
+ import { UneeqOptions } from '../types/UneeqOptions';
3
+ export declare class ResumeSessionCheck {
4
+ static validate(options: UneeqOptions): ResumeSessionCheckResponse;
5
+ static browserTabIsActive(): boolean;
6
+ }
@@ -290,8 +290,9 @@ export declare class WarningMessage implements UneeqMessage {
290
290
  */
291
291
  export declare class SessionLiveMessage implements UneeqMessage {
292
292
  readonly showLogo: boolean;
293
+ readonly sessionResumed: boolean;
293
294
  uneeqMessageType: UneeqMessageType;
294
- constructor(showLogo: boolean);
295
+ constructor(showLogo: boolean, sessionResumed: boolean);
295
296
  }
296
297
  /**
297
298
  * WebRTC data channel message
@@ -6,6 +6,7 @@ export interface NewSessionRequest {
6
6
  tokenId?: string;
7
7
  clientWidth?: number;
8
8
  clientHeight?: number;
9
+ resumeSessionId?: string;
9
10
  }
10
11
  interface NewSessionCustomData {
11
12
  additionalProp1: string;
@@ -1,3 +1,6 @@
1
1
  export interface PersonaStartRequest {
2
2
  enableTransparentBackground?: boolean;
3
+ resumeSession?: boolean;
4
+ backgroundImageUrl?: string;
5
+ nameTagImageUrl?: string;
3
6
  }
@@ -0,0 +1,4 @@
1
+ export interface ResumeSessionCheckResponse {
2
+ resumeSession: boolean;
3
+ resumeSessionId?: string;
4
+ }
@@ -53,4 +53,16 @@ export interface UneeqOptions {
53
53
  * This option specifies what the default voice input mode will be.
54
54
  */
55
55
  voiceInputMode: VoiceInputMode | string;
56
+ /**
57
+ * Resume user session if available.
58
+ */
59
+ resumeSession?: boolean;
60
+ /**
61
+ * This option specifies the URL of the background image to be used when the digital human is rendered.
62
+ */
63
+ backgroundImageUrl?: string;
64
+ /**
65
+ * This option specifies the URL of the name tag image to be used when the digital human is rendered.
66
+ */
67
+ nameTagImageUrl?: string;
56
68
  }
@@ -26,6 +26,7 @@ export declare class Uneeq {
26
26
  private startSessionTime;
27
27
  private availableResponseTime;
28
28
  private streamManager;
29
+ private sessionWasResumed;
29
30
  constructor(options: UneeqOptions);
30
31
  setLoggerEnabled(enabled: boolean): void;
31
32
  /**
package/dist/umd/index.js CHANGED
@@ -5761,13 +5761,14 @@ const messaging_1 = __webpack_require__(280);
5761
5761
  const metrics_service_1 = __webpack_require__(302);
5762
5762
  const online_status_service_1 = __webpack_require__(304);
5763
5763
  const prom_1 = __webpack_require__(269);
5764
- const stream_manager_1 = __webpack_require__(305);
5765
- const voice_input_manager_1 = __webpack_require__(306);
5764
+ const resume_session_check_1 = __webpack_require__(305);
5765
+ const stream_manager_1 = __webpack_require__(306);
5766
+ const voice_input_manager_1 = __webpack_require__(307);
5766
5767
  const MessageTypes_1 = __webpack_require__(267);
5767
- const NewSessionRequest_1 = __webpack_require__(309);
5768
+ const NewSessionRequest_1 = __webpack_require__(310);
5768
5769
  const PublishSubscribeState_1 = __webpack_require__(231);
5769
- const SourceApp_1 = __webpack_require__(310);
5770
- const VoiceInputMode_1 = __webpack_require__(308);
5770
+ const SourceApp_1 = __webpack_require__(311);
5771
+ const VoiceInputMode_1 = __webpack_require__(309);
5771
5772
  class Uneeq {
5772
5773
  constructor(options) {
5773
5774
  this.ready = new rxjs_1.BehaviorSubject(false);
@@ -5777,6 +5778,7 @@ class Uneeq {
5777
5778
  this.sessionPaused = false;
5778
5779
  this.sessionStarted = false; /* Whether the user is live in a session with an avatar (different from sessionPaused) */
5779
5780
  this.unavailableAvatarMsgSent = false;
5781
+ this.sessionWasResumed = false;
5780
5782
  logger_1.logger.enabled = options.logging || false;
5781
5783
  this.options = options;
5782
5784
  this.options.diagnostics = options.diagnostics || false;
@@ -5785,6 +5787,8 @@ class Uneeq {
5785
5787
  this.options.sendLocalAudio = options.sendLocalAudio === undefined ? true : options.sendLocalAudio;
5786
5788
  this.options.enableClientPerformanceMessage = options.enableClientPerformanceMessage || false;
5787
5789
  this.options.enableTransparentBackground = options.enableTransparentBackground || false;
5790
+ this.options.backgroundImageUrl = options.backgroundImageUrl || '';
5791
+ this.options.nameTagImageUrl = options.nameTagImageUrl || '';
5788
5792
  // TODO update default mode to VOICE_ACTIVITY once we are confident in the solution.
5789
5793
  this.options.voiceInputMode = options.voiceInputMode || VoiceInputMode_1.VoiceInputMode.PUSH_TO_TALK;
5790
5794
  this.api = new api_1.API(this.options.url, this.options.apiKey);
@@ -5829,9 +5833,23 @@ class Uneeq {
5829
5833
  return __awaiter(this, void 0, void 0, function* () {
5830
5834
  this.startSessionTime = Date.now();
5831
5835
  try {
5836
+ const resumeSessionCheck = resume_session_check_1.ResumeSessionCheck.validate(this.options);
5837
+ if (resumeSessionCheck.resumeSession === true) {
5838
+ this.startSessionData.resumeSessionId = resumeSessionCheck.resumeSessionId;
5839
+ }
5832
5840
  this.startSessionData.tokenId = tokenId;
5833
5841
  this.session = yield this.api.startSessionWithToken(this.startSessionData);
5834
5842
  console.log('UneeQ Session ID: ' + this.session.id);
5843
+ if (this.session.id === this.startSessionData.resumeSessionId) {
5844
+ logger_1.logger.log('UneeQ: Session was resumed.');
5845
+ this.sessionWasResumed = true;
5846
+ }
5847
+ else {
5848
+ logger_1.logger.log('UneeQ: Session was not resumed.');
5849
+ }
5850
+ // put the session id and persona id into local storage so it can be resumed
5851
+ localStorage.setItem('uneeqResumeSessionId', this.session.id);
5852
+ localStorage.setItem('uneeqResumeSessionPersonaId', this.options.conversationId);
5835
5853
  this.session.sourceApp = SourceApp_1.SourceApp[this.session.sourceApp ? this.session.sourceApp : ''] ?
5836
5854
  this.session.sourceApp : SourceApp_1.SourceApp.UNKNOWN;
5837
5855
  this.initialize();
@@ -6077,7 +6095,7 @@ class Uneeq {
6077
6095
  sessionLiveHandler() {
6078
6096
  // Send the SessionLive message and play welcome (optional)
6079
6097
  if (!this.sessionStarted) {
6080
- this.messages.next(new MessageTypes_1.SessionLiveMessage(this.session.showUneeqLogo || false));
6098
+ this.messages.next(new MessageTypes_1.SessionLiveMessage(this.session.showUneeqLogo || false, this.sessionWasResumed));
6081
6099
  if (this.options.playWelcome) {
6082
6100
  this.api.avatarWelcome();
6083
6101
  }
@@ -6132,7 +6150,15 @@ class Uneeq {
6132
6150
  };
6133
6151
  this.internalMessages$.next({ faceMeMessageType: 'prom', promMsg: availabilityChkMetric });
6134
6152
  this.messages.next(new MessageTypes_1.AvatarAvailableMessage());
6135
- this.api.avatarStart({ enableTransparentBackground: this.options.enableTransparentBackground });
6153
+ this.api.avatarStart({
6154
+ enableTransparentBackground: this.options.enableTransparentBackground,
6155
+ resumeSession: this.sessionWasResumed,
6156
+ backgroundImageUrl: this.options.backgroundImageUrl,
6157
+ nameTagImageUrl: this.options.nameTagImageUrl
6158
+ }).catch((err) => {
6159
+ console.error('UneeQ: Digital human could not be started. Clearing resumeSession token and ending process.', err);
6160
+ localStorage.removeItem('uneeqResumeSessionId');
6161
+ });
6136
6162
  }
6137
6163
  else {
6138
6164
  if (!this.unavailableAvatarMsgSent) {
@@ -18110,7 +18136,7 @@ function zipAll(project) {
18110
18136
  /* 224 */
18111
18137
  /***/ (function(module) {
18112
18138
 
18113
- module.exports = JSON.parse("{\"name\":\"uneeq-js\",\"version\":\"2.42.3\",\"description\":\"\",\"main\":\"dist/index.js\",\"types\":\"dist/src/index.d.ts\",\"scripts\":{\"start\":\"npx webpack -w\",\"test-local\":\"./node_modules/karma/bin/karma start karma.conf.js -logLevel=DEBUG\",\"test\":\"./node_modules/karma/bin/karma start --browsers ChromeHeadless --single-run\",\"test:windows\":\"karma start karma.conf.js\",\"build\":\"webpack --config webpack.config.prod.js && webpack --config webpack.config.umd.js\",\"lint\":\"./node_modules/tslint/bin/tslint -p tsconfig.json --fix\",\"docs\":\"./node_modules/typedoc/bin/typedoc --options\"},\"files\":[\"dist\",\"!dist/test\"],\"author\":\"\",\"license\":\"ISC\",\"dependencies\":{\"@stomp/stompjs\":\"^6.0.0\",\"@uehreka/seriously\":\"^1.0.1\",\"fast-text-encoding\":\"^1.0.0\",\"intrinsic-scale\":\"^3.0.4\",\"promjs\":\"^0.4.1\",\"rxjs\":\"^6.2.2\",\"rxjs-compat\":\"^6.3.2\",\"simple-peer\":\"9.11.0\",\"webrtc-adapter\":\"8.1.0\"},\"devDependencies\":{\"@types/jasmine\":\"^2.8.8\",\"@types/node\":\"^10.9.4\",\"fetch-mock\":\"7.7.3\",\"ignore-styles\":\"^5.0.1\",\"jasmine\":\"^3.2.0\",\"jasmine-class-mock\":\"^1.0.1\",\"jasmine-core\":\"^3.3.0\",\"karma\":\"^5.0.0\",\"karma-chrome-launcher\":\"^2.2.0\",\"karma-firefox-launcher\":\"^1.1.0\",\"karma-jasmine\":\"^2.0.1\",\"karma-jasmine-html-reporter\":\"^1.4.0\",\"karma-requirejs\":\"^1.1.0\",\"karma-safari-launcher\":\"^1.0.0\",\"karma-typescript\":\"^5.0.0\",\"karma-typescript-es6-transform\":\"^5.0.0\",\"nock\":\"^9.6.1\",\"requirejs\":\"^2.3.6\",\"ts-loader\":\"^5.0.0\",\"ts-node\":\"^7.0.1\",\"tslint\":\"^5.11.0\",\"tslint-no-focused-test\":\"^0.5.0\",\"typedoc\":\"^0.18.0\",\"typescript\":\"^3.9.7\",\"webpack\":\"^4.17.1\",\"webpack-cli\":\"^3.1.0\"}}");
18139
+ module.exports = JSON.parse("{\"name\":\"uneeq-js\",\"version\":\"2.44.0\",\"description\":\"\",\"main\":\"dist/index.js\",\"types\":\"dist/src/index.d.ts\",\"scripts\":{\"start\":\"npx webpack -w\",\"test-local\":\"./node_modules/karma/bin/karma start karma.conf.js -logLevel=DEBUG\",\"test\":\"./node_modules/karma/bin/karma start --browsers ChromeHeadless --single-run\",\"test:windows\":\"karma start karma.conf.js\",\"build\":\"webpack --config webpack.config.prod.js && webpack --config webpack.config.umd.js\",\"lint\":\"./node_modules/tslint/bin/tslint -p tsconfig.json --fix\",\"docs\":\"./node_modules/typedoc/bin/typedoc --options\"},\"files\":[\"dist\",\"!dist/test\"],\"author\":\"\",\"license\":\"ISC\",\"dependencies\":{\"@stomp/stompjs\":\"^6.0.0\",\"@uehreka/seriously\":\"^1.0.1\",\"fast-text-encoding\":\"^1.0.0\",\"intrinsic-scale\":\"^3.0.4\",\"promjs\":\"^0.4.1\",\"rxjs\":\"^6.2.2\",\"rxjs-compat\":\"^6.3.2\",\"simple-peer\":\"9.11.0\",\"webrtc-adapter\":\"8.1.0\"},\"devDependencies\":{\"@types/jasmine\":\"^2.8.8\",\"@types/node\":\"^10.9.4\",\"fetch-mock\":\"7.7.3\",\"ignore-styles\":\"^5.0.1\",\"jasmine\":\"^3.2.0\",\"jasmine-class-mock\":\"^1.0.1\",\"jasmine-core\":\"^3.3.0\",\"karma\":\"^5.0.0\",\"karma-chrome-launcher\":\"^2.2.0\",\"karma-firefox-launcher\":\"^1.1.0\",\"karma-jasmine\":\"^2.0.1\",\"karma-jasmine-html-reporter\":\"^1.4.0\",\"karma-requirejs\":\"^1.1.0\",\"karma-safari-launcher\":\"^1.0.0\",\"karma-typescript\":\"^5.0.0\",\"karma-typescript-es6-transform\":\"^5.0.0\",\"nock\":\"^9.6.1\",\"requirejs\":\"^2.3.6\",\"ts-loader\":\"^5.0.0\",\"ts-node\":\"^7.0.1\",\"tslint\":\"^5.11.0\",\"tslint-no-focused-test\":\"^0.5.0\",\"typedoc\":\"^0.18.0\",\"typescript\":\"^3.9.7\",\"webpack\":\"^4.17.1\",\"webpack-cli\":\"^3.1.0\"}}");
18114
18140
 
18115
18141
  /***/ }),
18116
18142
  /* 225 */
@@ -32723,8 +32749,9 @@ exports.WarningMessage = WarningMessage;
32723
32749
  * Session is Live, avatar video is active
32724
32750
  */
32725
32751
  class SessionLiveMessage {
32726
- constructor(showLogo) {
32752
+ constructor(showLogo, sessionResumed) {
32727
32753
  this.showLogo = showLogo;
32754
+ this.sessionResumed = sessionResumed;
32728
32755
  this.uneeqMessageType = UneeqMessageType.SessionLive;
32729
32756
  }
32730
32757
  }
@@ -53303,6 +53330,51 @@ exports.OnlineStatusService = OnlineStatusService;
53303
53330
 
53304
53331
  "use strict";
53305
53332
 
53333
+ Object.defineProperty(exports, "__esModule", { value: true });
53334
+ exports.ResumeSessionCheck = void 0;
53335
+ const logger_1 = __webpack_require__(233);
53336
+ class ResumeSessionCheck {
53337
+ static validate(options) {
53338
+ let resumeSession = options.resumeSession !== undefined ? options.resumeSession : false;
53339
+ const resumeSessionPersonaId = localStorage.getItem('uneeqResumeSessionPersonaId');
53340
+ const resumingSamePersona = resumeSessionPersonaId === options.conversationId;
53341
+ if (!resumingSamePersona) {
53342
+ logger_1.logger.log('UneeQ: Persona Id\'s do not match, unable to resume session.');
53343
+ resumeSession = false;
53344
+ }
53345
+ const tabIsActive = ResumeSessionCheck.browserTabIsActive();
53346
+ if (resumeSession && !tabIsActive) {
53347
+ logger_1.logger.log('UneeQ: Browser tab is not active so unable to resume');
53348
+ resumeSession = false;
53349
+ }
53350
+ if (resumeSession) {
53351
+ const resumeSessionId = localStorage.getItem('uneeqResumeSessionId');
53352
+ if (resumeSessionId !== null) {
53353
+ return {
53354
+ resumeSession: true,
53355
+ resumeSessionId: resumeSessionId
53356
+ };
53357
+ }
53358
+ }
53359
+ return {
53360
+ resumeSession: false
53361
+ };
53362
+ }
53363
+ // Set this up as a method to make the class more testable.
53364
+ // You cannot easily mock document.hidden as it is readonly.
53365
+ static browserTabIsActive() {
53366
+ return !document.hidden;
53367
+ }
53368
+ }
53369
+ exports.ResumeSessionCheck = ResumeSessionCheck;
53370
+
53371
+
53372
+ /***/ }),
53373
+ /* 306 */
53374
+ /***/ (function(module, exports, __webpack_require__) {
53375
+
53376
+ "use strict";
53377
+
53306
53378
  Object.defineProperty(exports, "__esModule", { value: true });
53307
53379
  exports.StreamManager = void 0;
53308
53380
  class StreamManager {
@@ -53417,7 +53489,7 @@ StreamManager.audioData = 'data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTG
53417
53489
 
53418
53490
 
53419
53491
  /***/ }),
53420
- /* 306 */
53492
+ /* 307 */
53421
53493
  /***/ (function(module, exports, __webpack_require__) {
53422
53494
 
53423
53495
  "use strict";
@@ -53425,9 +53497,9 @@ StreamManager.audioData = 'data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTG
53425
53497
  Object.defineProperty(exports, "__esModule", { value: true });
53426
53498
  exports.VoiceInputManager = void 0;
53427
53499
  const operators_1 = __webpack_require__(126);
53428
- const soundmeter_1 = __webpack_require__(307);
53500
+ const soundmeter_1 = __webpack_require__(308);
53429
53501
  const MessageTypes_1 = __webpack_require__(267);
53430
- const VoiceInputMode_1 = __webpack_require__(308);
53502
+ const VoiceInputMode_1 = __webpack_require__(309);
53431
53503
  const logger_1 = __webpack_require__(233);
53432
53504
  class VoiceInputManager {
53433
53505
  constructor(options, api, messages, enableMicrophone) {
@@ -53600,7 +53672,7 @@ exports.VoiceInputManager = VoiceInputManager;
53600
53672
 
53601
53673
 
53602
53674
  /***/ }),
53603
- /* 307 */
53675
+ /* 308 */
53604
53676
  /***/ (function(module, exports, __webpack_require__) {
53605
53677
 
53606
53678
  "use strict";
@@ -53679,7 +53751,7 @@ exports.SoundMeter = SoundMeter;
53679
53751
 
53680
53752
 
53681
53753
  /***/ }),
53682
- /* 308 */
53754
+ /* 309 */
53683
53755
  /***/ (function(module, exports, __webpack_require__) {
53684
53756
 
53685
53757
  "use strict";
@@ -53694,7 +53766,7 @@ var VoiceInputMode;
53694
53766
 
53695
53767
 
53696
53768
  /***/ }),
53697
- /* 309 */
53769
+ /* 310 */
53698
53770
  /***/ (function(module, exports, __webpack_require__) {
53699
53771
 
53700
53772
  "use strict";
@@ -53708,7 +53780,7 @@ var SessionType;
53708
53780
 
53709
53781
 
53710
53782
  /***/ }),
53711
- /* 310 */
53783
+ /* 311 */
53712
53784
  /***/ (function(module, exports, __webpack_require__) {
53713
53785
 
53714
53786
  "use strict";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uneeq-js",
3
- "version": "2.42.3",
3
+ "version": "2.44.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/src/index.d.ts",
package/readme.md CHANGED
@@ -8,6 +8,12 @@ https://docs.uneeq.io/build-your-own-experience
8
8
  To use uneeq-js with a typescript version < 3.8, 'skipLibCheck' must be set to true.
9
9
 
10
10
  ## Release Notes
11
+ #### 2.44.0
12
+ * Added beta support for session resume.
13
+
14
+ #### 2.43.0
15
+ * Adding support for setting a background image and name tag image when starting a session using new fields in UneeqOptions. Url restrictions apply, please reach out to the Customer Service team.
16
+
11
17
  #### 2.42.3
12
18
  * Fixed issue that caused voiceActivity input not to work when using autoStart
13
19