uneeq-js 2.43.0 → 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,5 +1,6 @@
1
1
  export interface PersonaStartRequest {
2
2
  enableTransparentBackground?: boolean;
3
+ resumeSession?: boolean;
3
4
  backgroundImageUrl?: string;
4
5
  nameTagImageUrl?: string;
5
6
  }
@@ -0,0 +1,4 @@
1
+ export interface ResumeSessionCheckResponse {
2
+ resumeSession: boolean;
3
+ resumeSessionId?: string;
4
+ }
@@ -53,6 +53,10 @@ 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;
56
60
  /**
57
61
  * This option specifies the URL of the background image to be used when the digital human is rendered.
58
62
  */
@@ -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;
@@ -5831,9 +5833,23 @@ class Uneeq {
5831
5833
  return __awaiter(this, void 0, void 0, function* () {
5832
5834
  this.startSessionTime = Date.now();
5833
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
+ }
5834
5840
  this.startSessionData.tokenId = tokenId;
5835
5841
  this.session = yield this.api.startSessionWithToken(this.startSessionData);
5836
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);
5837
5853
  this.session.sourceApp = SourceApp_1.SourceApp[this.session.sourceApp ? this.session.sourceApp : ''] ?
5838
5854
  this.session.sourceApp : SourceApp_1.SourceApp.UNKNOWN;
5839
5855
  this.initialize();
@@ -6079,7 +6095,7 @@ class Uneeq {
6079
6095
  sessionLiveHandler() {
6080
6096
  // Send the SessionLive message and play welcome (optional)
6081
6097
  if (!this.sessionStarted) {
6082
- 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));
6083
6099
  if (this.options.playWelcome) {
6084
6100
  this.api.avatarWelcome();
6085
6101
  }
@@ -6136,8 +6152,12 @@ class Uneeq {
6136
6152
  this.messages.next(new MessageTypes_1.AvatarAvailableMessage());
6137
6153
  this.api.avatarStart({
6138
6154
  enableTransparentBackground: this.options.enableTransparentBackground,
6155
+ resumeSession: this.sessionWasResumed,
6139
6156
  backgroundImageUrl: this.options.backgroundImageUrl,
6140
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');
6141
6161
  });
6142
6162
  }
6143
6163
  else {
@@ -18116,7 +18136,7 @@ function zipAll(project) {
18116
18136
  /* 224 */
18117
18137
  /***/ (function(module) {
18118
18138
 
18119
- module.exports = JSON.parse("{\"name\":\"uneeq-js\",\"version\":\"2.43.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\"}}");
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\"}}");
18120
18140
 
18121
18141
  /***/ }),
18122
18142
  /* 225 */
@@ -32729,8 +32749,9 @@ exports.WarningMessage = WarningMessage;
32729
32749
  * Session is Live, avatar video is active
32730
32750
  */
32731
32751
  class SessionLiveMessage {
32732
- constructor(showLogo) {
32752
+ constructor(showLogo, sessionResumed) {
32733
32753
  this.showLogo = showLogo;
32754
+ this.sessionResumed = sessionResumed;
32734
32755
  this.uneeqMessageType = UneeqMessageType.SessionLive;
32735
32756
  }
32736
32757
  }
@@ -53309,6 +53330,51 @@ exports.OnlineStatusService = OnlineStatusService;
53309
53330
 
53310
53331
  "use strict";
53311
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
+
53312
53378
  Object.defineProperty(exports, "__esModule", { value: true });
53313
53379
  exports.StreamManager = void 0;
53314
53380
  class StreamManager {
@@ -53423,7 +53489,7 @@ StreamManager.audioData = 'data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTG
53423
53489
 
53424
53490
 
53425
53491
  /***/ }),
53426
- /* 306 */
53492
+ /* 307 */
53427
53493
  /***/ (function(module, exports, __webpack_require__) {
53428
53494
 
53429
53495
  "use strict";
@@ -53431,9 +53497,9 @@ StreamManager.audioData = 'data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTG
53431
53497
  Object.defineProperty(exports, "__esModule", { value: true });
53432
53498
  exports.VoiceInputManager = void 0;
53433
53499
  const operators_1 = __webpack_require__(126);
53434
- const soundmeter_1 = __webpack_require__(307);
53500
+ const soundmeter_1 = __webpack_require__(308);
53435
53501
  const MessageTypes_1 = __webpack_require__(267);
53436
- const VoiceInputMode_1 = __webpack_require__(308);
53502
+ const VoiceInputMode_1 = __webpack_require__(309);
53437
53503
  const logger_1 = __webpack_require__(233);
53438
53504
  class VoiceInputManager {
53439
53505
  constructor(options, api, messages, enableMicrophone) {
@@ -53606,7 +53672,7 @@ exports.VoiceInputManager = VoiceInputManager;
53606
53672
 
53607
53673
 
53608
53674
  /***/ }),
53609
- /* 307 */
53675
+ /* 308 */
53610
53676
  /***/ (function(module, exports, __webpack_require__) {
53611
53677
 
53612
53678
  "use strict";
@@ -53685,7 +53751,7 @@ exports.SoundMeter = SoundMeter;
53685
53751
 
53686
53752
 
53687
53753
  /***/ }),
53688
- /* 308 */
53754
+ /* 309 */
53689
53755
  /***/ (function(module, exports, __webpack_require__) {
53690
53756
 
53691
53757
  "use strict";
@@ -53700,7 +53766,7 @@ var VoiceInputMode;
53700
53766
 
53701
53767
 
53702
53768
  /***/ }),
53703
- /* 309 */
53769
+ /* 310 */
53704
53770
  /***/ (function(module, exports, __webpack_require__) {
53705
53771
 
53706
53772
  "use strict";
@@ -53714,7 +53780,7 @@ var SessionType;
53714
53780
 
53715
53781
 
53716
53782
  /***/ }),
53717
- /* 310 */
53783
+ /* 311 */
53718
53784
  /***/ (function(module, exports, __webpack_require__) {
53719
53785
 
53720
53786
  "use strict";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uneeq-js",
3
- "version": "2.43.0",
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,9 @@ 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
+
11
14
  #### 2.43.0
12
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.
13
16