@lobehub/ui 1.110.0 → 1.111.2

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,27 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ export var getHeadersAndData = function getHeadersAndData(data) {
6
+ var headers = {};
7
+ var _iterator = _createForOfIteratorHelper(data.slice(0, data.indexOf('\r\n\r\n')).split('\r\n')),
8
+ _step;
9
+ try {
10
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
11
+ var line = _step.value;
12
+ var _line$split = line.split(':', 2),
13
+ _line$split2 = _slicedToArray(_line$split, 2),
14
+ _key = _line$split2[0],
15
+ value = _line$split2[1];
16
+ headers[_key] = value;
17
+ }
18
+ } catch (err) {
19
+ _iterator.e(err);
20
+ } finally {
21
+ _iterator.f();
22
+ }
23
+ return {
24
+ data: data.slice(data.indexOf('\r\n\r\n') + 4),
25
+ headers: headers
26
+ };
27
+ };
@@ -1,11 +1,18 @@
1
1
  interface Voice {
2
- localName?: string;
2
+ localeName?: string;
3
3
  name: string;
4
4
  }
5
+ interface VoiceOptions {
6
+ [key: string]: string;
7
+ }
5
8
  export interface VoiceList {
6
9
  [locale: string]: Voice[];
7
10
  }
8
- export declare const genSpeechSynthesVoiceList: () => VoiceList;
9
- export declare const getSpeechSynthesVoiceList: (locale?: string) => Voice[];
10
- export declare const getAzureVoiceList: (locale?: string) => Voice[];
11
+ export interface VoiceListLite {
12
+ [locale: string]: string[];
13
+ }
14
+ export declare const genSpeechSynthesVoiceList: () => VoiceListLite;
15
+ export declare const getSpeechSynthesVoiceList: (locale?: string) => string[];
16
+ export declare const getAzureVoiceList: (locale?: string) => VoiceOptions;
17
+ export declare const getEdgeVoiceList: (locale?: string) => VoiceOptions;
11
18
  export {};
@@ -3,6 +3,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
3
3
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
4
  import { flatten } from 'lodash-es';
5
5
  import azureVoiceList from "../data/azureVoiceListLite.json";
6
+ import edgeVoiceList from "../data/edgeVoiceList.json";
7
+ import speechSynthesVoiceListFallback from "../data/speechSynthesVoiceList.json";
6
8
  export var genSpeechSynthesVoiceList = function genSpeechSynthesVoiceList() {
7
9
  var data = speechSynthesis.getVoices();
8
10
  var list = {};
@@ -12,24 +14,38 @@ export var genSpeechSynthesVoiceList = function genSpeechSynthesVoiceList() {
12
14
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
13
15
  var voice = _step.value;
14
16
  if (!list[voice.lang]) list[voice.lang] = [];
15
- list[voice.lang].push({
16
- localName: voice.name,
17
- name: voice.voiceURI
18
- });
17
+ list[voice.lang].push(voice.name);
19
18
  }
20
19
  } catch (err) {
21
20
  _iterator.e(err);
22
21
  } finally {
23
22
  _iterator.f();
24
23
  }
25
- return list;
24
+ return Object.keys(list).length > 0 ? list : speechSynthesVoiceListFallback;
26
25
  };
27
26
  export var getSpeechSynthesVoiceList = function getSpeechSynthesVoiceList(locale) {
28
27
  var speechSynthesVoiceList = genSpeechSynthesVoiceList();
29
- if (locale) return (speechSynthesVoiceList === null || speechSynthesVoiceList === void 0 ? void 0 : speechSynthesVoiceList[locale]) || [];
30
- return flatten(Object.values(speechSynthesVoiceList));
28
+ var data = [];
29
+ data = locale && speechSynthesVoiceList !== null && speechSynthesVoiceList !== void 0 && speechSynthesVoiceList[locale] ? (speechSynthesVoiceList === null || speechSynthesVoiceList === void 0 ? void 0 : speechSynthesVoiceList[locale]) || [] : flatten(Object.values(speechSynthesVoiceList));
30
+ return data;
31
31
  };
32
32
  export var getAzureVoiceList = function getAzureVoiceList(locale) {
33
- if (locale) return azureVoiceList[locale] || [];
34
- return flatten(Object.values(azureVoiceList));
33
+ var options = {};
34
+ var data = [];
35
+ data = locale && azureVoiceList[locale] ? azureVoiceList[locale] || [] : flatten(Object.values(azureVoiceList));
36
+ data.forEach(function (voice) {
37
+ options[voice.localeName || voice.name] = voice.name;
38
+ });
39
+ return options;
40
+ };
41
+ export var getEdgeVoiceList = function getEdgeVoiceList(locale) {
42
+ var options = {};
43
+ var list = flatten(Object.values(edgeVoiceList));
44
+ var data = [];
45
+ data = locale && azureVoiceList[locale] ? azureVoiceList[locale] || [] : flatten(Object.values(azureVoiceList));
46
+ data.forEach(function (voice) {
47
+ if (!list.includes(voice.name)) return;
48
+ options[voice.localeName || voice.name] = voice.name;
49
+ });
50
+ return options;
35
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.110.0",
3
+ "version": "1.111.2",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -93,8 +93,10 @@
93
93
  "lodash-es": "^4",
94
94
  "lucide-react": "latest",
95
95
  "microsoft-cognitiveservices-speech-sdk": "^1",
96
+ "msedge-tts": "^1",
96
97
  "polished": "^4",
97
98
  "prism-react-renderer": "^2",
99
+ "query-string": "^8",
98
100
  "rc-footer": "^0",
99
101
  "re-resizable": "^6",
100
102
  "react-error-boundary": "^4",
@@ -123,6 +125,7 @@
123
125
  "@types/chroma-js": "^2",
124
126
  "@types/lodash-es": "^4",
125
127
  "@types/pangu": "^4",
128
+ "@types/query-string": "^6",
126
129
  "@types/react": "^18",
127
130
  "@types/react-dom": "^18",
128
131
  "@types/three": "^0.157",