uneeq-js 2.46.2 → 2.46.4

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.
@@ -9,6 +9,6 @@ export declare class LocaleDetector {
9
9
  */
10
10
  static validateOrDetectSpeechLocales(options: UneeqOptions): string;
11
11
  private static defaultLocale;
12
- private static localesRegEx;
13
12
  private static localeMappings;
13
+ private static sttSupportedLocales;
14
14
  }
package/dist/umd/index.js CHANGED
@@ -5763,8 +5763,8 @@ const metrics_service_1 = __webpack_require__(303);
5763
5763
  const online_status_service_1 = __webpack_require__(305);
5764
5764
  const prom_1 = __webpack_require__(270);
5765
5765
  const resume_session_check_1 = __webpack_require__(306);
5766
- const stream_manager_1 = __webpack_require__(307);
5767
- const uneeq_local_storage_1 = __webpack_require__(308);
5766
+ const stream_manager_1 = __webpack_require__(308);
5767
+ const uneeq_local_storage_1 = __webpack_require__(307);
5768
5768
  const voice_input_manager_1 = __webpack_require__(309);
5769
5769
  const MessageTypes_1 = __webpack_require__(267);
5770
5770
  const NewSessionRequest_1 = __webpack_require__(312);
@@ -18173,7 +18173,7 @@ function zipAll(project) {
18173
18173
  /* 224 */
18174
18174
  /***/ (function(module) {
18175
18175
 
18176
- module.exports = JSON.parse("{\"name\":\"uneeq-js\",\"version\":\"2.46.2\",\"description\":\"\",\"main\":\"dist/index.js\",\"types\":\"dist/src/index.d.ts\",\"scripts\":{\"start\":\"npx webpack -w\",\"test-local\":\"npx karma start karma.conf.js -logLevel=DEBUG\",\"test\":\"npx 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\":\"npx tslint -p tsconfig.json --fix\",\"docs\":\"npx 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\"}}");
18176
+ module.exports = JSON.parse("{\"name\":\"uneeq-js\",\"version\":\"2.46.4\",\"description\":\"\",\"main\":\"dist/index.js\",\"types\":\"dist/src/index.d.ts\",\"scripts\":{\"start\":\"npx webpack -w\",\"test-local\":\"npx karma start karma.conf.js -logLevel=DEBUG\",\"test\":\"npx 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\":\"npx tslint -p tsconfig.json --fix\",\"docs\":\"npx 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\"}}");
18177
18177
 
18178
18178
  /***/ }),
18179
18179
  /* 225 */
@@ -32957,11 +32957,15 @@ class LocaleDetector {
32957
32957
  */
32958
32958
  static validateOrDetectSpeechLocales(options) {
32959
32959
  let speechToTextLocales = options.speechToTextLocales;
32960
- // validate config language locales match regex and are not null or undefined
32960
+ // validate config language locales match supported list and are not null or undefined
32961
32961
  if (speechToTextLocales && speechToTextLocales.length > 0) {
32962
- if (!speechToTextLocales.match(this.localesRegEx)) {
32963
- console.error(`UneeQ: Likely invalid value for speechToTextLocales: ${speechToTextLocales}. Please use a BCP-47 language tag with multiple locales separated by colon .e.g 'en-US:ja-JP`);
32964
- }
32962
+ let arrayOfLocales = speechToTextLocales.split(':');
32963
+ arrayOfLocales.forEach((locale) => {
32964
+ if (!this.sttSupportedLocales[locale]) {
32965
+ console.error(`UneeQ: Speech to text not supported for: ${locale}. Defaulting to en-US`);
32966
+ speechToTextLocales = this.defaultLocale;
32967
+ }
32968
+ });
32965
32969
  if (speechToTextLocales === 'undefined' || speechToTextLocales === 'null') {
32966
32970
  speechToTextLocales = this.defaultLocale;
32967
32971
  }
@@ -32969,27 +32973,37 @@ class LocaleDetector {
32969
32973
  // Get the user's language preferences from the browser
32970
32974
  const userLanguages = window.navigator.languages || [window.navigator.language];
32971
32975
  // Map two-letter language locales to four-letter language locales
32976
+ // Chinese is unusual for our STT so requires special manipulation
32972
32977
  const filteredUserLanguages = userLanguages.map((lang) => {
32973
- if (lang.length < 5) {
32974
- return this.localeMappings[lang] || null;
32978
+ if (lang.length < 5 || lang === 'zh-CN') {
32979
+ lang = this.localeMappings[lang] || null;
32980
+ }
32981
+ if (lang && !this.sttSupportedLocales[lang]) {
32982
+ console.warn(`UneeQ: Speech to text not supported for one of the detected languages: ${lang}. Replacing with en-US.`);
32983
+ lang = this.defaultLocale;
32975
32984
  }
32976
32985
  return lang;
32977
32986
  });
32978
32987
  // Truncate the array to a maximum of 4 elements
32979
- const truncatedUserLanguages = filteredUserLanguages.slice(0, 4);
32988
+ const truncatedUserLanguages = filteredUserLanguages.slice(0, 4).filter(notEmpty).filter((v, i, a) => a.indexOf(v) === i);
32980
32989
  // Join the filtered and truncated user's language preferences into a string separated by colons
32981
- let userLanguageLocales = truncatedUserLanguages.join(':');
32990
+ let userLanguageLocales = truncatedUserLanguages.join(':').replace(/:\s*$/, "");
32982
32991
  if (!userLanguageLocales || userLanguageLocales.length === 0) {
32983
32992
  // If the user's language preferences are empty, default to en-US
32984
32993
  userLanguageLocales = this.defaultLocale;
32985
32994
  }
32995
+ if (speechToTextLocales && speechToTextLocales.length > 0) {
32996
+ console.debug(`UneeQ: Configured speech to text languages: ${speechToTextLocales}`);
32997
+ }
32998
+ else {
32999
+ console.warn(`UneeQ: Detected speechToText languages from browser: ${userLanguageLocales}`);
33000
+ }
32986
33001
  // Return the concatenated language locales string if config has not supplied any
32987
33002
  return speechToTextLocales || userLanguageLocales;
32988
33003
  }
32989
33004
  }
32990
33005
  exports.LocaleDetector = LocaleDetector;
32991
33006
  LocaleDetector.defaultLocale = 'en-US';
32992
- LocaleDetector.localesRegEx = /^([a-z]{2}(-[A-Z]{2}))(:[a-z]{2}(-[A-Z]{2})?)*$/;
32993
33007
  // Map two-letter language locales to four-letter language locales
32994
33008
  LocaleDetector.localeMappings = {
32995
33009
  en: 'en-US',
@@ -32998,7 +33012,7 @@ LocaleDetector.localeMappings = {
32998
33012
  ja: 'ja-JP',
32999
33013
  de: 'de-DE',
33000
33014
  ko: 'ko-KR',
33001
- zh: 'zh-CN',
33015
+ zh: 'cmn-Hans-CN',
33002
33016
  it: 'it-IT',
33003
33017
  pt: 'pt-PT',
33004
33018
  nl: 'nl-NL',
@@ -33019,7 +33033,158 @@ LocaleDetector.localeMappings = {
33019
33033
  vi: 'vi-VN',
33020
33034
  uk: 'uk-UA',
33021
33035
  hi: 'hi-IN',
33036
+ 'zh-CN': 'cmn-Hans-CN',
33022
33037
  };
33038
+ LocaleDetector.sttSupportedLocales = {
33039
+ "af-ZA": true,
33040
+ "sq-AL": true,
33041
+ "am-ET": true,
33042
+ "ar-DZ": true,
33043
+ "ar-BH": true,
33044
+ "ar-EG": true,
33045
+ "ar-IQ": true,
33046
+ "ar-IL": true,
33047
+ "ar-JO": true,
33048
+ "ar-KW": true,
33049
+ "ar-LB": true,
33050
+ "ar-MR": true,
33051
+ "ar-MA": true,
33052
+ "ar-OM": true,
33053
+ "ar-QA": true,
33054
+ "ar-SA": true,
33055
+ "ar-PS": true,
33056
+ "ar-TN": true,
33057
+ "ar-AE": true,
33058
+ "ar-YE": true,
33059
+ "hy-AM": true,
33060
+ "az-AZ": true,
33061
+ "eu-ES": true,
33062
+ "bn-BD": true,
33063
+ "bn-IN": true,
33064
+ "bs-BA": true,
33065
+ "bg-BG": true,
33066
+ "my-MM": true,
33067
+ "ca-ES": true,
33068
+ "yue-Hant-HK": true,
33069
+ "cmn-Hans-CN": true,
33070
+ "cmn-Hant-TW": true,
33071
+ "hr-HR": true,
33072
+ "cs-CZ": true,
33073
+ "da-DK": true,
33074
+ "nl-BE": true,
33075
+ "nl-NL": true,
33076
+ "en-AU": true,
33077
+ "en-CA": true,
33078
+ "en-GH": true,
33079
+ "en-HK": true,
33080
+ "en-IN": true,
33081
+ "en-IE": true,
33082
+ "en-KE": true,
33083
+ "en-NZ": true,
33084
+ "en-NG": true,
33085
+ "en-PK": true,
33086
+ "en-PH": true,
33087
+ "en-SG": true,
33088
+ "en-ZA": true,
33089
+ "en-TZ": true,
33090
+ "en-GB": true,
33091
+ "en-US": true,
33092
+ "et-EE": true,
33093
+ "fil-PH": true,
33094
+ "fi-FI": true,
33095
+ "fr-BE": true,
33096
+ "fr-CA": true,
33097
+ "fr-FR": true,
33098
+ "fr-CH": true,
33099
+ "gl-ES": true,
33100
+ "ka-GE": true,
33101
+ "de-AT": true,
33102
+ "de-DE": true,
33103
+ "de-CH": true,
33104
+ "el-GR": true,
33105
+ "gu-IN": true,
33106
+ "iw-IL": true,
33107
+ "hi-IN": true,
33108
+ "hu-HU": true,
33109
+ "is-IS": true,
33110
+ "id-ID": true,
33111
+ "it-IT": true,
33112
+ "it-CH": true,
33113
+ "ja-JP": true,
33114
+ "jv-ID": true,
33115
+ "kn-IN": true,
33116
+ "kk-KZ": true,
33117
+ "km-KH": true,
33118
+ "ko-KR": true,
33119
+ "lo-LA": true,
33120
+ "lv-LV": true,
33121
+ "lt-LT": true,
33122
+ "mk-MK": true,
33123
+ "ms-MY": true,
33124
+ "ml-IN": true,
33125
+ "mr-IN": true,
33126
+ "mn-MN": true,
33127
+ "ne-NP": true,
33128
+ "no-NO": true,
33129
+ "fa-IR": true,
33130
+ "pl-PL": true,
33131
+ "pt-BR": true,
33132
+ "pt-PT": true,
33133
+ "pa-Guru-IN": true,
33134
+ "ro-RO": true,
33135
+ "ru-RU": true,
33136
+ "rw-RW": true,
33137
+ "sr-RS": true,
33138
+ "si-LK": true,
33139
+ "sk-SK": true,
33140
+ "sl-SI": true,
33141
+ "ss-latn-za": true,
33142
+ "st-ZA": true,
33143
+ "es-AR": true,
33144
+ "es-BO": true,
33145
+ "es-CL": true,
33146
+ "es-CO": true,
33147
+ "es-CR": true,
33148
+ "es-DO": true,
33149
+ "es-EC": true,
33150
+ "es-SV": true,
33151
+ "es-GT": true,
33152
+ "es-HN": true,
33153
+ "es-MX": true,
33154
+ "es-NI": true,
33155
+ "es-PA": true,
33156
+ "es-PY": true,
33157
+ "es-PE": true,
33158
+ "es-PR": true,
33159
+ "es-ES": true,
33160
+ "es-US": true,
33161
+ "es-UY": true,
33162
+ "es-VE": true,
33163
+ "su-ID": true,
33164
+ "sw-KE": true,
33165
+ "sw-TZ": true,
33166
+ "sv-SE": true,
33167
+ "ta-IN": true,
33168
+ "ta-MY": true,
33169
+ "ta-SG": true,
33170
+ "ta-LK": true,
33171
+ "te-IN": true,
33172
+ "th-TH": true,
33173
+ "tn-latn-za": true,
33174
+ "tr-TR": true,
33175
+ "ts-ZA": true,
33176
+ "uk-UA": true,
33177
+ "ur-IN": true,
33178
+ "ur-PK": true,
33179
+ "uz-UZ": true,
33180
+ "ve-ZA": true,
33181
+ "vi-VN": true,
33182
+ "xh-ZA": true,
33183
+ "zu-ZA": true,
33184
+ };
33185
+ function notEmpty(value) {
33186
+ return value !== null && value !== undefined;
33187
+ }
33023
33188
 
33024
33189
 
33025
33190
  /***/ }),
@@ -53465,10 +53630,12 @@ exports.OnlineStatusService = OnlineStatusService;
53465
53630
  Object.defineProperty(exports, "__esModule", { value: true });
53466
53631
  exports.ResumeSessionCheck = void 0;
53467
53632
  const logger_1 = __webpack_require__(233);
53633
+ const uneeq_local_storage_1 = __webpack_require__(307);
53468
53634
  class ResumeSessionCheck {
53469
53635
  static validate(options) {
53636
+ const uneeqLocalStorage = new uneeq_local_storage_1.UneeqLocalStorage();
53470
53637
  let resumeSession = options.resumeSession !== undefined ? options.resumeSession : false;
53471
- const resumeSessionPersonaId = localStorage.getItem('uneeqResumeSessionPersonaId');
53638
+ const resumeSessionPersonaId = uneeqLocalStorage.getItemSafely('uneeqResumeSessionPersonaId');
53472
53639
  const resumingSamePersona = resumeSessionPersonaId === options.conversationId;
53473
53640
  if (!resumingSamePersona) {
53474
53641
  logger_1.logger.log('UneeQ: Persona Id\'s do not match, unable to resume session.');
@@ -53480,7 +53647,7 @@ class ResumeSessionCheck {
53480
53647
  resumeSession = false;
53481
53648
  }
53482
53649
  if (resumeSession) {
53483
- const resumeSessionId = localStorage.getItem('uneeqResumeSessionId');
53650
+ const resumeSessionId = uneeqLocalStorage.getItemSafely('uneeqResumeSessionId');
53484
53651
  if (resumeSessionId !== null) {
53485
53652
  return {
53486
53653
  resumeSession: true,
@@ -53507,6 +53674,63 @@ exports.ResumeSessionCheck = ResumeSessionCheck;
53507
53674
 
53508
53675
  "use strict";
53509
53676
 
53677
+ Object.defineProperty(exports, "__esModule", { value: true });
53678
+ exports.UneeqLocalStorage = void 0;
53679
+ const logger_1 = __webpack_require__(233);
53680
+ class UneeqLocalStorage {
53681
+ constructor() { }
53682
+ get available() {
53683
+ if (this.localStorageAvailable === undefined) {
53684
+ this.localStorageAvailable = this.checkIfLocalStorageAvailable();
53685
+ }
53686
+ return this.localStorageAvailable;
53687
+ }
53688
+ setItemSafely(key, value) {
53689
+ if (this.available) {
53690
+ localStorage.setItem(key, value);
53691
+ }
53692
+ else {
53693
+ logger_1.logger.log('UneeQ: unable to access localStorage because it is not available.');
53694
+ }
53695
+ }
53696
+ getItemSafely(key) {
53697
+ if (this.available) {
53698
+ return localStorage.getItem(key);
53699
+ }
53700
+ else {
53701
+ logger_1.logger.log('UneeQ: unable to access localStorage because it is not available.');
53702
+ return undefined;
53703
+ }
53704
+ }
53705
+ removeItemSafely(key) {
53706
+ if (this.available) {
53707
+ localStorage.removeItem(key);
53708
+ }
53709
+ else {
53710
+ logger_1.logger.log('UneeQ: unable to access localStorage because it is not available.');
53711
+ }
53712
+ }
53713
+ checkIfLocalStorageAvailable() {
53714
+ const uneeqLocalStoreCheck = 'UneeqLocalStoreCheck';
53715
+ try {
53716
+ localStorage.setItem(uneeqLocalStoreCheck, uneeqLocalStoreCheck);
53717
+ localStorage.removeItem(uneeqLocalStoreCheck);
53718
+ return true;
53719
+ }
53720
+ catch (e) {
53721
+ return false;
53722
+ }
53723
+ }
53724
+ }
53725
+ exports.UneeqLocalStorage = UneeqLocalStorage;
53726
+
53727
+
53728
+ /***/ }),
53729
+ /* 308 */
53730
+ /***/ (function(module, exports, __webpack_require__) {
53731
+
53732
+ "use strict";
53733
+
53510
53734
  Object.defineProperty(exports, "__esModule", { value: true });
53511
53735
  exports.StreamManager = void 0;
53512
53736
  class StreamManager {
@@ -53566,64 +53790,6 @@ class StreamManager {
53566
53790
  exports.StreamManager = StreamManager;
53567
53791
 
53568
53792
 
53569
- /***/ }),
53570
- /* 308 */
53571
- /***/ (function(module, exports, __webpack_require__) {
53572
-
53573
- "use strict";
53574
-
53575
- Object.defineProperty(exports, "__esModule", { value: true });
53576
- exports.UneeqLocalStorage = void 0;
53577
- const logger_1 = __webpack_require__(233);
53578
- class UneeqLocalStorage {
53579
- constructor() { }
53580
- get available() {
53581
- if (this.localStorageAvailable === undefined) {
53582
- this.localStorageAvailable = this.checkIfLocalStorageAvailable();
53583
- }
53584
- return this.localStorageAvailable;
53585
- }
53586
- setItemSafely(key, value) {
53587
- if (this.available) {
53588
- localStorage.setItem(key, value);
53589
- }
53590
- else {
53591
- logger_1.logger.log('UneeQ: unable to access localStorage because it is not available.');
53592
- }
53593
- }
53594
- getItemSafely(key) {
53595
- if (this.available) {
53596
- return localStorage.getItem(key);
53597
- }
53598
- else {
53599
- logger_1.logger.log('UneeQ: unable to access localStorage because it is not available.');
53600
- return undefined;
53601
- }
53602
- }
53603
- removeItemSafely(key) {
53604
- if (this.available) {
53605
- localStorage.removeItem(key);
53606
- }
53607
- else {
53608
- logger_1.logger.log('UneeQ: unable to access localStorage because it is not available.');
53609
- }
53610
- }
53611
- checkIfLocalStorageAvailable() {
53612
- const uneeqLocalStoreCheck = 'UneeqLocalStoreCheck';
53613
- try {
53614
- localStorage.setItem(uneeqLocalStoreCheck, uneeqLocalStoreCheck);
53615
- localStorage.removeItem(uneeqLocalStoreCheck);
53616
- return true;
53617
- }
53618
- catch (e) {
53619
- console.warn('UneeQ: Local storage is not available. Reason: ', e);
53620
- return false;
53621
- }
53622
- }
53623
- }
53624
- exports.UneeqLocalStorage = UneeqLocalStorage;
53625
-
53626
-
53627
53793
  /***/ }),
53628
53794
  /* 309 */
53629
53795
  /***/ (function(module, exports, __webpack_require__) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uneeq-js",
3
- "version": "2.46.2",
3
+ "version": "2.46.4",
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.46.4
12
+ * Improve locale detection to ensure we fall back to supported speech to text languages
13
+
14
+ #### 2.46.3
15
+ * Fix for sessions to start without localStorage availability.
16
+
11
17
  #### 2.46.2
12
18
  * Fix for session starting in incognito browser windows.
13
19