@sefinek/google-tts-api 2.1.5 → 2.1.7

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,5 +1,5 @@
1
- # 📢 @sefinek/google-tts-api
2
- Google TTS (Text-To-Speech) for [Node.js](https://nodejs.org) without any vulnerabilities.
1
+ # 📢 Google TTS API
2
+ Google TTS (Text-To-Speech) for [Node.js](https://nodejs.org) without any vulnerabilities. For free without any API keys!
3
3
 
4
4
  ![@sefinek/google-tts-api.png](https://img.shields.io/npm/dt/@sefinek/google-tts-api?maxAge=3600)
5
5
  ![@sefinek/google-tts-api.png](https://img.shields.io/github/last-commit/sefinek24/google-tts-api)
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var assertInputTypes = function (text, lang, slow, host) {
3
+ const assertInputTypes = (text, lang, slow, host) => {
4
4
  if (typeof text !== 'string' || text.length === 0) {
5
5
  throw new TypeError('text should be a string');
6
6
  }
@@ -15,4 +15,3 @@ var assertInputTypes = function (text, lang, slow, host) {
15
15
  }
16
16
  };
17
17
  exports.default = assertInputTypes;
18
- //# sourceMappingURL=assertInputTypes.js.map
@@ -4,38 +4,10 @@ interface Option {
4
4
  host?: string;
5
5
  timeout?: number;
6
6
  }
7
- /**
8
- * Get "Google TTS" audio base64 text
9
- *
10
- * @param {string} text length should be less than 200 characters
11
- * @param {object?} option
12
- * @param {string?} option.lang default is "en"
13
- * @param {boolean?} option.slow default is false
14
- * @param {string?} option.host default is "https://translate.google.com"
15
- * @param {number?} option.timeout default is 10000 (ms)
16
- * @returns {Promise<string>} url
17
- */
18
7
  export declare const getAudioBase64: (text: string, { lang, slow, host, timeout }?: Option) => Promise<string>;
19
8
  interface LongTextOption extends Option {
20
9
  splitPunct?: string;
21
10
  }
22
- /**
23
- * @typedef {object} Result
24
- * @property {string} shortText
25
- * @property {string} base64
26
- */
27
- /**
28
- * Split the long text into multiple short text and generate audio base64 list
29
- *
30
- * @param {string} text
31
- * @param {object?} option
32
- * @param {string?} option.lang default is "en"
33
- * @param {boolean?} option.slow default is false
34
- * @param {string?} option.host default is "https://translate.google.com"
35
- * @param {string?} option.splitPunct split punctuation
36
- * @param {number?} option.timeout default is 10000 (ms)
37
- * @return {Result[]} the list with short text and audio base64
38
- */
39
11
  export declare const getAllAudioBase64: (text: string, { lang, slow, host, splitPunct, timeout, }?: LongTextOption) => Promise<{
40
12
  shortText: string;
41
13
  base64: string;
@@ -1 +1 @@
1
- {"version":3,"file":"getAudioBase64.d.ts","sourceRoot":"","sources":["../src/getAudioBase64.ts"],"names":[],"mappings":"AAIA,UAAU,MAAM;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,SACjB,MAAM,kCAC2E,MAAM,KAC9F,QAAQ,MAAM,CAgDhB,CAAC;AAEF,UAAU,cAAe,SAAQ,MAAM;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,SACpB,MAAM,+CAOT,cAAc,KAClB,QAAQ;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,CAyBjD,CAAC"}
1
+ {"version":3,"file":"getAudioBase64.d.ts","sourceRoot":"","sources":["../src/getAudioBase64.ts"],"names":[],"mappings":"AAIA,UAAU,MAAM;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAaD,eAAO,MAAM,cAAc,SACjB,MAAM,kCAC2E,MAAM,KAC9F,OAAO,CAAC,MAAM,CAgDhB,CAAC;AAEF,UAAU,cAAe,SAAQ,MAAM;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAoBD,eAAO,MAAM,iBAAiB,SACpB,MAAM,+CAOT,cAAc,KAClB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,CAyBjD,CAAC"}
@@ -8,163 +8,67 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
- if (ar || !(i in from)) {
41
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
- ar[i] = from[i];
43
- }
44
- }
45
- return to.concat(ar || Array.prototype.slice.call(from));
46
- };
47
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
48
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
49
13
  };
50
14
  Object.defineProperty(exports, "__esModule", { value: true });
51
15
  exports.getAllAudioBase64 = exports.getAudioBase64 = void 0;
52
- var assertInputTypes_1 = __importDefault(require("./assertInputTypes"));
53
- var axios_1 = __importDefault(require("axios"));
54
- var splitLongText_1 = __importDefault(require("./splitLongText"));
55
- /**
56
- * Get "Google TTS" audio base64 text
57
- *
58
- * @param {string} text length should be less than 200 characters
59
- * @param {object?} option
60
- * @param {string?} option.lang default is "en"
61
- * @param {boolean?} option.slow default is false
62
- * @param {string?} option.host default is "https://translate.google.com"
63
- * @param {number?} option.timeout default is 10000 (ms)
64
- * @returns {Promise<string>} url
65
- */
66
- var getAudioBase64 = function (text_1) {
67
- var args_1 = [];
68
- for (var _i = 1; _i < arguments.length; _i++) {
69
- args_1[_i - 1] = arguments[_i];
16
+ const assertInputTypes_1 = __importDefault(require("./assertInputTypes"));
17
+ const axios_1 = __importDefault(require("axios"));
18
+ const splitLongText_1 = __importDefault(require("./splitLongText"));
19
+ const getAudioBase64 = (text_1, ...args_1) => __awaiter(void 0, [text_1, ...args_1], void 0, function* (text, { lang = 'en', slow = false, host = 'https://translate.google.com', timeout = 10000 } = {}) {
20
+ (0, assertInputTypes_1.default)(text, lang, slow, host);
21
+ if (typeof timeout !== 'number' || timeout <= 0) {
22
+ throw new TypeError('timeout should be a positive number');
70
23
  }
71
- return __awaiter(void 0, __spreadArray([text_1], args_1, true), void 0, function (text, _a) {
72
- var res, result;
73
- var _b = _a === void 0 ? {} : _a, _c = _b.lang, lang = _c === void 0 ? 'en' : _c, _d = _b.slow, slow = _d === void 0 ? false : _d, _e = _b.host, host = _e === void 0 ? 'https://translate.google.com' : _e, _f = _b.timeout, timeout = _f === void 0 ? 10000 : _f;
74
- return __generator(this, function (_g) {
75
- switch (_g.label) {
76
- case 0:
77
- (0, assertInputTypes_1.default)(text, lang, slow, host);
78
- if (typeof timeout !== 'number' || timeout <= 0) {
79
- throw new TypeError('timeout should be a positive number');
80
- }
81
- if (text.length > 200) {
82
- throw new RangeError("text length (".concat(text.length, ") should be less than 200 characters. Try \"getAllAudioBase64(text, [option])\" for long text."));
83
- }
84
- return [4 /*yield*/, (0, axios_1.default)({
85
- method: 'post',
86
- baseURL: host,
87
- url: '/_/TranslateWebserverUi/data/batchexecute',
88
- timeout: timeout,
89
- data: 'f.req=' +
90
- encodeURIComponent(JSON.stringify([
91
- [['jQ1olc', JSON.stringify([text, lang, slow ? true : null, 'null']), null, 'generic']],
92
- ])),
93
- })];
94
- case 1:
95
- res = _g.sent();
96
- try {
97
- result = eval(res.data.slice(5))[0][2];
98
- }
99
- catch (e) {
100
- throw new Error("parse response failed:\n".concat(res.data));
101
- }
102
- // Check the result. The result will be null if given the lang doesn't exist
103
- if (!result) {
104
- throw new Error("lang \"".concat(lang, "\" might not exist"));
105
- }
106
- // 2. continue to parse audio base64 string
107
- try {
108
- result = eval(result)[0];
109
- }
110
- catch (e) {
111
- throw new Error("parse response failed:\n".concat(res.data));
112
- }
113
- return [2 /*return*/, result];
114
- }
115
- });
24
+ if (text.length > 200) {
25
+ throw new RangeError(`text length (${text.length}) should be less than 200 characters. Try "getAllAudioBase64(text, [option])" for long text.`);
26
+ }
27
+ const res = yield (0, axios_1.default)({
28
+ method: 'post',
29
+ baseURL: host,
30
+ url: '/_/TranslateWebserverUi/data/batchexecute',
31
+ timeout,
32
+ data: 'f.req=' +
33
+ encodeURIComponent(JSON.stringify([
34
+ [['jQ1olc', JSON.stringify([text, lang, slow ? true : null, 'null']), null, 'generic']],
35
+ ])),
116
36
  });
117
- };
37
+ let result;
38
+ try {
39
+ result = eval(res.data.slice(5))[0][2];
40
+ }
41
+ catch (e) {
42
+ throw new Error(`parse response failed:\n${res.data}`);
43
+ }
44
+ if (!result) {
45
+ throw new Error(`lang "${lang}" might not exist`);
46
+ }
47
+ try {
48
+ result = eval(result)[0];
49
+ }
50
+ catch (e) {
51
+ throw new Error(`parse response failed:\n${res.data}`);
52
+ }
53
+ return result;
54
+ });
118
55
  exports.getAudioBase64 = getAudioBase64;
119
- /**
120
- * @typedef {object} Result
121
- * @property {string} shortText
122
- * @property {string} base64
123
- */
124
- /**
125
- * Split the long text into multiple short text and generate audio base64 list
126
- *
127
- * @param {string} text
128
- * @param {object?} option
129
- * @param {string?} option.lang default is "en"
130
- * @param {boolean?} option.slow default is false
131
- * @param {string?} option.host default is "https://translate.google.com"
132
- * @param {string?} option.splitPunct split punctuation
133
- * @param {number?} option.timeout default is 10000 (ms)
134
- * @return {Result[]} the list with short text and audio base64
135
- */
136
- var getAllAudioBase64 = function (text_1) {
137
- var args_1 = [];
138
- for (var _i = 1; _i < arguments.length; _i++) {
139
- args_1[_i - 1] = arguments[_i];
56
+ const getAllAudioBase64 = (text_1, ...args_1) => __awaiter(void 0, [text_1, ...args_1], void 0, function* (text, { lang = 'en', slow = false, host = 'https://translate.google.com', splitPunct = '', timeout = 10000, } = {}) {
57
+ (0, assertInputTypes_1.default)(text, lang, slow, host);
58
+ if (typeof splitPunct !== 'string') {
59
+ throw new TypeError('splitPunct should be a string');
140
60
  }
141
- return __awaiter(void 0, __spreadArray([text_1], args_1, true), void 0, function (text, _a) {
142
- var shortTextList, base64List, result, i, shortText, base64;
143
- var _b = _a === void 0 ? {} : _a, _c = _b.lang, lang = _c === void 0 ? 'en' : _c, _d = _b.slow, slow = _d === void 0 ? false : _d, _e = _b.host, host = _e === void 0 ? 'https://translate.google.com' : _e, _f = _b.splitPunct, splitPunct = _f === void 0 ? '' : _f, _g = _b.timeout, timeout = _g === void 0 ? 10000 : _g;
144
- return __generator(this, function (_h) {
145
- switch (_h.label) {
146
- case 0:
147
- (0, assertInputTypes_1.default)(text, lang, slow, host);
148
- if (typeof splitPunct !== 'string') {
149
- throw new TypeError('splitPunct should be a string');
150
- }
151
- if (typeof timeout !== 'number' || timeout <= 0) {
152
- throw new TypeError('timeout should be a positive number');
153
- }
154
- shortTextList = (0, splitLongText_1.default)(text, { splitPunct: splitPunct });
155
- return [4 /*yield*/, Promise.all(shortTextList.map(function (shortText) { return (0, exports.getAudioBase64)(shortText, { lang: lang, slow: slow, host: host, timeout: timeout }); }))];
156
- case 1:
157
- base64List = _h.sent();
158
- result = [];
159
- for (i = 0; i < shortTextList.length; i++) {
160
- shortText = shortTextList[i];
161
- base64 = base64List[i];
162
- result.push({ shortText: shortText, base64: base64 });
163
- }
164
- return [2 /*return*/, result];
165
- }
166
- });
167
- });
168
- };
61
+ if (typeof timeout !== 'number' || timeout <= 0) {
62
+ throw new TypeError('timeout should be a positive number');
63
+ }
64
+ const shortTextList = (0, splitLongText_1.default)(text, { splitPunct });
65
+ const base64List = yield Promise.all(shortTextList.map((shortText) => (0, exports.getAudioBase64)(shortText, { lang, slow, host, timeout })));
66
+ const result = [];
67
+ for (let i = 0; i < shortTextList.length; i++) {
68
+ const shortText = shortTextList[i];
69
+ const base64 = base64List[i];
70
+ result.push({ shortText, base64 });
71
+ }
72
+ return result;
73
+ });
169
74
  exports.getAllAudioBase64 = getAllAudioBase64;
170
- //# sourceMappingURL=getAudioBase64.js.map
@@ -1,40 +1,12 @@
1
- /// <reference types="node" />
2
- import url from 'url';
3
1
  interface Option {
4
2
  lang?: string;
5
3
  slow?: boolean;
6
4
  host?: string;
7
5
  }
8
- /**
9
- * Generate "Google TTS" audio URL
10
- *
11
- * @param {string} text length should be less than 200 characters
12
- * @param {object?} option
13
- * @param {string?} option.lang default is "en"
14
- * @param {boolean?} option.slow default is false
15
- * @param {string?} option.host default is "https://translate.google.com"
16
- * @return {string} url
17
- */
18
6
  export declare const getAudioUrl: (text: string, { lang, slow, host }?: Option) => string;
19
7
  interface LongTextOption extends Option {
20
8
  splitPunct?: string;
21
9
  }
22
- /**
23
- * @typedef {object} Result
24
- * @property {string} shortText
25
- * @property {string} url
26
- */
27
- /**
28
- * Split the long text into multiple short text and generate audio URL list
29
- *
30
- * @param {string} text
31
- * @param {object?} option
32
- * @param {string?} option.lang default is "en"
33
- * @param {boolean?} option.slow default is false
34
- * @param {string?} option.host default is "https://translate.google.com"
35
- * @param {string?} option.splitPunct split punctuation
36
- * @return {Result[]} the list with short text and audio url
37
- */
38
10
  export declare const getAllAudioUrls: (text: string, { lang, slow, host, splitPunct, }?: LongTextOption) => {
39
11
  shortText: string;
40
12
  url: string;
@@ -1 +1 @@
1
- {"version":3,"file":"getAudioUrl.d.ts","sourceRoot":"","sources":["../src/getAudioUrl.ts"],"names":[],"mappings":";AAEA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,UAAU,MAAM;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,SACd,MAAM,yBAC0D,MAAM,KAC7E,MA0BF,CAAC;AAEF,UAAU,cAAe,SAAQ,MAAM;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,SAClB,MAAM,sCAMT,cAAc,KAClB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,MAAM,CAAA;CAAE,EAWpC,CAAC"}
1
+ {"version":3,"file":"getAudioUrl.d.ts","sourceRoot":"","sources":["../src/getAudioUrl.ts"],"names":[],"mappings":"AAIA,UAAU,MAAM;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAYD,eAAO,MAAM,WAAW,SACd,MAAM,yBAC0D,MAAM,KAC7E,MA0BF,CAAC;AAEF,UAAU,cAAe,SAAQ,MAAM;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAmBD,eAAO,MAAM,eAAe,SAClB,MAAM,sCAMT,cAAc,KAClB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAWpC,CAAC"}
@@ -4,24 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getAllAudioUrls = exports.getAudioUrl = void 0;
7
- var assertInputTypes_1 = __importDefault(require("./assertInputTypes"));
8
- var splitLongText_1 = __importDefault(require("./splitLongText"));
9
- var url_1 = __importDefault(require("url"));
10
- /**
11
- * Generate "Google TTS" audio URL
12
- *
13
- * @param {string} text length should be less than 200 characters
14
- * @param {object?} option
15
- * @param {string?} option.lang default is "en"
16
- * @param {boolean?} option.slow default is false
17
- * @param {string?} option.host default is "https://translate.google.com"
18
- * @return {string} url
19
- */
20
- var getAudioUrl = function (text, _a) {
21
- var _b = _a === void 0 ? {} : _a, _c = _b.lang, lang = _c === void 0 ? 'en' : _c, _d = _b.slow, slow = _d === void 0 ? false : _d, _e = _b.host, host = _e === void 0 ? 'https://translate.google.com' : _e;
7
+ const assertInputTypes_1 = __importDefault(require("./assertInputTypes"));
8
+ const splitLongText_1 = __importDefault(require("./splitLongText"));
9
+ const url_1 = __importDefault(require("url"));
10
+ const getAudioUrl = (text, { lang = 'en', slow = false, host = 'https://translate.google.com' } = {}) => {
22
11
  (0, assertInputTypes_1.default)(text, lang, slow, host);
23
12
  if (text.length > 200) {
24
- throw new RangeError("text length (".concat(text.length, ") should be less than 200 characters. Try \"getAllAudioUrls(text, [option])\" for long text."));
13
+ throw new RangeError(`text length (${text.length}) should be less than 200 characters. Try "getAllAudioUrls(text, [option])" for long text.`);
25
14
  }
26
15
  return (host +
27
16
  '/translate_tts' +
@@ -40,32 +29,14 @@ var getAudioUrl = function (text, _a) {
40
29
  }));
41
30
  };
42
31
  exports.getAudioUrl = getAudioUrl;
43
- /**
44
- * @typedef {object} Result
45
- * @property {string} shortText
46
- * @property {string} url
47
- */
48
- /**
49
- * Split the long text into multiple short text and generate audio URL list
50
- *
51
- * @param {string} text
52
- * @param {object?} option
53
- * @param {string?} option.lang default is "en"
54
- * @param {boolean?} option.slow default is false
55
- * @param {string?} option.host default is "https://translate.google.com"
56
- * @param {string?} option.splitPunct split punctuation
57
- * @return {Result[]} the list with short text and audio url
58
- */
59
- var getAllAudioUrls = function (text, _a) {
60
- var _b = _a === void 0 ? {} : _a, _c = _b.lang, lang = _c === void 0 ? 'en' : _c, _d = _b.slow, slow = _d === void 0 ? false : _d, _e = _b.host, host = _e === void 0 ? 'https://translate.google.com' : _e, _f = _b.splitPunct, splitPunct = _f === void 0 ? '' : _f;
32
+ const getAllAudioUrls = (text, { lang = 'en', slow = false, host = 'https://translate.google.com', splitPunct = '', } = {}) => {
61
33
  (0, assertInputTypes_1.default)(text, lang, slow, host);
62
34
  if (typeof splitPunct !== 'string') {
63
35
  throw new TypeError('splitPunct should be a string');
64
36
  }
65
- return (0, splitLongText_1.default)(text, { splitPunct: splitPunct }).map(function (shortText) { return ({
66
- shortText: shortText,
67
- url: (0, exports.getAudioUrl)(shortText, { lang: lang, slow: slow, host: host }),
68
- }); });
37
+ return (0, splitLongText_1.default)(text, { splitPunct }).map((shortText) => ({
38
+ shortText,
39
+ url: (0, exports.getAudioUrl)(shortText, { lang, slow, host }),
40
+ }));
69
41
  };
70
42
  exports.getAllAudioUrls = getAllAudioUrls;
71
- //# sourceMappingURL=getAudioUrl.js.map
package/dist/index.js CHANGED
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAllAudioBase64 = exports.getAudioBase64 = exports.getAllAudioUrls = exports.getAudioUrl = void 0;
4
- var getAudioUrl_1 = require("./getAudioUrl");
4
+ const getAudioUrl_1 = require("./getAudioUrl");
5
5
  Object.defineProperty(exports, "getAudioUrl", { enumerable: true, get: function () { return getAudioUrl_1.getAudioUrl; } });
6
6
  Object.defineProperty(exports, "getAllAudioUrls", { enumerable: true, get: function () { return getAudioUrl_1.getAllAudioUrls; } });
7
- var getAudioBase64_1 = require("./getAudioBase64");
7
+ const getAudioBase64_1 = require("./getAudioBase64");
8
8
  Object.defineProperty(exports, "getAudioBase64", { enumerable: true, get: function () { return getAudioBase64_1.getAudioBase64; } });
9
9
  Object.defineProperty(exports, "getAllAudioBase64", { enumerable: true, get: function () { return getAudioBase64_1.getAllAudioBase64; } });
10
- //# sourceMappingURL=index.js.map
@@ -2,16 +2,6 @@ interface Option {
2
2
  maxLength?: number;
3
3
  splitPunct?: string;
4
4
  }
5
- /**
6
- * split the long text to short texts
7
- * Time Complexity: O(n)
8
- *
9
- * @param {string} text
10
- * @param {object?} option
11
- * @param {number?} option.maxLength default is 200
12
- * @param {string?} option.splitPunct default is ''
13
- * @returns {string[]} short text list
14
- */
15
5
  declare const splitLongText: (text: string, { maxLength, splitPunct }?: Option) => string[];
16
6
  export default splitLongText;
17
7
  //# sourceMappingURL=splitLongText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"splitLongText.d.ts","sourceRoot":"","sources":["../src/splitLongText.ts"],"names":[],"mappings":"AAMA,UAAU,MAAM;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;GASG;AACH,QAAA,MAAM,aAAa,SACT,MAAM,8BAC0B,MAAM,KAC7C,MAAM,EAmDR,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"splitLongText.d.ts","sourceRoot":"","sources":["../src/splitLongText.ts"],"names":[],"mappings":"AAMA,UAAU,MAAM;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAYD,QAAA,MAAM,aAAa,SACT,MAAM,8BAC0B,MAAM,KAC7C,MAAM,EAmDR,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,63 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim
4
- var SPACE_REGEX = '\\s\\uFEFF\\xA0';
5
- // https://remarkablemark.org/blog/2019/09/28/javascript-remove-punctuation
6
- var DEFAULT_PUNCTUATION_REGEX = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~';
7
- /**
8
- * split the long text to short texts
9
- * Time Complexity: O(n)
10
- *
11
- * @param {string} text
12
- * @param {object?} option
13
- * @param {number?} option.maxLength default is 200
14
- * @param {string?} option.splitPunct default is ''
15
- * @returns {string[]} short text list
16
- */
17
- var splitLongText = function (text, _a) {
18
- var _b = _a === void 0 ? {} : _a, _c = _b.maxLength, maxLength = _c === void 0 ? 200 : _c, _d = _b.splitPunct, splitPunct = _d === void 0 ? '' : _d;
19
- var isSpaceOrPunct = function (s, i) {
20
- var regex = new RegExp('[' + SPACE_REGEX + DEFAULT_PUNCTUATION_REGEX + splitPunct + ']');
3
+ const SPACE_REGEX = '\\s\\uFEFF\\xA0';
4
+ const DEFAULT_PUNCTUATION_REGEX = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~';
5
+ const splitLongText = (text, { maxLength = 200, splitPunct = '' } = {}) => {
6
+ const isSpaceOrPunct = (s, i) => {
7
+ const regex = new RegExp('[' + SPACE_REGEX + DEFAULT_PUNCTUATION_REGEX + splitPunct + ']');
21
8
  return regex.test(s.charAt(i));
22
9
  };
23
- var lastIndexOfSpaceOrPunct = function (s, left, right) {
24
- for (var i = right; i >= left; i--) {
10
+ const lastIndexOfSpaceOrPunct = (s, left, right) => {
11
+ for (let i = right; i >= left; i--) {
25
12
  if (isSpaceOrPunct(s, i))
26
13
  return i;
27
14
  }
28
- return -1; // not found
15
+ return -1;
29
16
  };
30
- var result = [];
31
- var addResult = function (text, start, end) {
17
+ const result = [];
18
+ const addResult = (text, start, end) => {
32
19
  result.push(text.slice(start, end + 1));
33
20
  };
34
- var start = 0;
21
+ let start = 0;
35
22
  for (;;) {
36
- // check text's length
37
23
  if (text.length - start <= maxLength) {
38
24
  addResult(text, start, text.length - 1);
39
- break; // end of text
25
+ break;
40
26
  }
41
- // check whether the word is cut in the middle.
42
- var end = start + maxLength - 1;
27
+ let end = start + maxLength - 1;
43
28
  if (isSpaceOrPunct(text, end) || isSpaceOrPunct(text, end + 1)) {
44
29
  addResult(text, start, end);
45
30
  start = end + 1;
46
31
  continue;
47
32
  }
48
- // find last index of space
49
33
  end = lastIndexOfSpaceOrPunct(text, start, end);
50
34
  if (end === -1) {
51
- var str = text.slice(start, start + maxLength);
35
+ const str = text.slice(start, start + maxLength);
52
36
  throw new Error('The word is too long to split into a short text:' +
53
- "\n".concat(str, " ...") +
37
+ `\n${str} ...` +
54
38
  '\n\nTry the option "splitPunct" to split the text by punctuation.');
55
39
  }
56
- // add result
57
40
  addResult(text, start, end);
58
41
  start = end + 1;
59
42
  }
60
43
  return result;
61
44
  };
62
45
  exports.default = splitLongText;
63
- //# sourceMappingURL=splitLongText.js.map
@@ -0,0 +1,56 @@
1
+ import js from '@eslint/js';
2
+ import globals from 'globals';
3
+
4
+ // noinspection JSUnusedGlobalSymbols
5
+ export default [
6
+ js.configs.recommended,
7
+ {
8
+ languageOptions: {
9
+ ecmaVersion: 2024,
10
+ globals: {
11
+ ...globals.node,
12
+ ...globals.es2024
13
+ }
14
+ },
15
+ rules: {
16
+ 'arrow-spacing': ['warn', { before: true, after: true }],
17
+ 'comma-dangle': ['error'],
18
+ 'comma-spacing': 'error',
19
+ 'comma-style': 'error',
20
+ 'curly': ['error', 'multi-line', 'consistent'],
21
+ 'dot-location': ['error', 'property'],
22
+ 'handle-callback-err': 'off',
23
+ 'indent': ['warn', 'tab'],
24
+ 'keyword-spacing': 'warn',
25
+ 'max-nested-callbacks': ['error', { max: 4 }],
26
+ 'max-statements-per-line': ['error', { max: 2 }],
27
+ 'no-console': 'off',
28
+ 'no-empty': 'warn',
29
+ 'no-empty-function': 'error',
30
+ 'no-floating-decimal': 'error',
31
+ 'no-lonely-if': 'error',
32
+ 'no-multi-spaces': 'warn',
33
+ 'no-multiple-empty-lines': ['warn', { max: 4, maxEOF: 1, maxBOF: 0 }],
34
+ 'no-shadow': ['error', { allow: ['err', 'resolve', 'reject'] }],
35
+ 'no-trailing-spaces': ['warn'],
36
+ 'no-unreachable': 'warn',
37
+ 'no-unused-vars': 'warn',
38
+ 'no-use-before-define': ['error', { functions: false, classes: true }],
39
+ 'no-var': 'error',
40
+ 'object-curly-spacing': ['error', 'always'],
41
+ 'prefer-const': 'error',
42
+ 'quotes': ['warn', 'single'],
43
+ 'semi': ['warn', 'always'],
44
+ 'sort-vars': 'warn',
45
+ 'space-before-blocks': 'error',
46
+ 'space-before-function-paren': ['error', { anonymous: 'never', named: 'never', asyncArrow: 'always' }],
47
+ 'space-in-parens': 'error',
48
+ 'space-infix-ops': 'error',
49
+ 'space-unary-ops': 'error',
50
+ 'spaced-comment': 'warn',
51
+ 'wrap-regex': 'error',
52
+ 'yoda': 'error'
53
+ },
54
+ ignores: ['node_modules']
55
+ }
56
+ ];
@@ -1,17 +1,17 @@
1
1
  const fs = require('fs');
2
2
  const googleTTS = require('../dist/index');
3
3
 
4
- // 1. get audio URL
4
+ // 1. Get audio URL
5
5
  const url = googleTTS.getAudioUrl('Hello World', { lang: 'en-GB' });
6
6
  console.log({ url }); // https://translate.google.com/translate_tts?...
7
7
 
8
- // 2. get base64 text
8
+ // 2. Get base64 text
9
9
  googleTTS
10
10
  .getAudioBase64('Hello World', { lang: 'en-GB' })
11
11
  .then((base64) => {
12
12
  console.log({ base64 });
13
13
 
14
- // save the audio file
14
+ // Save the audio file
15
15
  const buffer = Buffer.from(base64, 'base64');
16
16
  fs.writeFileSync('hello-world-british.mp3', buffer, { encoding: 'base64' });
17
17
  })
@@ -1,17 +1,17 @@
1
1
  const fs = require('fs');
2
2
  const googleTTS = require('../dist/index');
3
3
 
4
- // 1. get audio URL
4
+ // 1. Get audio URL
5
5
  const url = googleTTS.getAudioUrl('你好世界', { lang: 'zh-TW' });
6
6
  console.log({ url }); // https://translate.google.com/translate_tts?...
7
7
 
8
- // 2. get base64 text
8
+ // 2. Get base64 text
9
9
  googleTTS
10
10
  .getAudioBase64('你好世界', { lang: 'zh-TW' })
11
11
  .then((base64) => {
12
12
  console.log({ base64 });
13
13
 
14
- // save the audio file
14
+ // Save the audio file
15
15
  const buffer = Buffer.from(base64, 'base64');
16
16
  fs.writeFileSync('hello-world-chinese.mp3', buffer, { encoding: 'base64' });
17
17
  })
@@ -13,13 +13,13 @@ function downloadFile(url, dest) {
13
13
  host: info.host,
14
14
  path: info.path,
15
15
  headers: {
16
- 'user-agent': 'WHAT_EVER',
17
- },
16
+ 'user-agent': 'WHAT_EVER'
17
+ }
18
18
  };
19
19
 
20
20
  httpClient
21
21
  .get(options, (res) => {
22
- // check status code
22
+ // Check status code
23
23
  if (res.statusCode !== 200) {
24
24
  const msg = `request to ${url} failed, status code = ${res.statusCode} (${res.statusMessage})`;
25
25
  reject(new Error(msg));
@@ -48,7 +48,7 @@ function downloadFile(url, dest) {
48
48
  const url = googleTTS.getAudioUrl('hello');
49
49
  console.log(url); // https://translate.google.com/translate_tts?...
50
50
 
51
- const dest = path.resolve(__dirname, 'hello.mp3'); // file destination
51
+ const dest = path.resolve(__dirname, 'hello.mp3'); // File destination
52
52
  console.log('Download to ' + dest + ' ...');
53
53
  downloadFile(url, dest);
54
54
  console.log('Download success');
@@ -1,17 +1,17 @@
1
1
  const fs = require('fs');
2
2
  const googleTTS = require('../dist/index');
3
3
 
4
- // 1. get audio URL
4
+ // 1. Get audio URL
5
5
  const url = googleTTS.getAudioUrl('Hello World', { lang: 'en', slow: false });
6
6
  console.log({ url }); // https://translate.google.com/translate_tts?...
7
7
 
8
- // 2. get base64 text
8
+ // 2. Get base64 text
9
9
  googleTTS
10
10
  .getAudioBase64('Hello World', { lang: 'en', slow: false })
11
11
  .then((base64) => {
12
12
  console.log({ base64 });
13
13
 
14
- // save the audio file
14
+ // Save the audio file
15
15
  const buffer = Buffer.from(base64, 'base64');
16
16
  fs.writeFileSync('hello-world-english.mp3', buffer, { encoding: 'base64' });
17
17
  })
@@ -1,4 +1,3 @@
1
- const fs = require('fs');
2
1
  const googleTTS = require('../dist/index');
3
2
 
4
3
  const article =
@@ -30,15 +29,15 @@ const article =
30
29
 
31
30
  const option = { lang: 'zh', splitPunct: ',、。' };
32
31
 
33
- // 1. all audio URLs
32
+ // 1. All audio URLs
34
33
  const results = googleTTS.getAllAudioUrls(article, option);
35
34
  results.forEach((item, i) => {
36
35
  console.log(`${i + 1}. ${item.shortText.length} characters`, item, '\n');
37
36
  });
38
37
 
39
- // 2. all audio base64 texts
40
- googleTTS.getAllAudioBase64(article, option).then((results) => {
41
- results.forEach((item, i) => {
38
+ // 2. All audio base64 texts
39
+ googleTTS.getAllAudioBase64(article, option).then(data => {
40
+ data.forEach((item, i) => {
42
41
  console.log(`${i + 1}. ${item.shortText.length} characters`, item, '\n');
43
42
  });
44
43
  });
@@ -39,15 +39,15 @@ It was such people who began to flock to the cities seeking employment and who f
39
39
 
40
40
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`;
41
41
 
42
- // 1. all audio URLs
42
+ // 1. All audio URLs
43
43
  const results = googleTTS.getAllAudioUrls(article);
44
44
  results.forEach((item, i) => {
45
45
  console.log(`${i + 1}. ${item.shortText.length} characters`, item, '\n');
46
46
  });
47
47
 
48
- // 2. all audio base64 texts
49
- googleTTS.getAllAudioBase64(article).then((results) => {
50
- results.forEach((item, i) => {
48
+ // 2. All audio base64 texts
49
+ googleTTS.getAllAudioBase64(article).then(data => {
50
+ data.forEach((item, i) => {
51
51
  console.log(`${i + 1}. ${item.shortText.length} characters`, item, '\n');
52
52
  });
53
53
  });
package/package.json CHANGED
@@ -1,13 +1,20 @@
1
1
  {
2
2
  "name": "@sefinek/google-tts-api",
3
- "version": "2.1.5",
4
- "description": "Google TTS (Text-To-Speech) for Node.js.",
3
+ "version": "2.1.7",
4
+ "description": "Google TTS (Text-To-Speech) for Node.js without any vulnerabilities. For free without any API keys!",
5
5
  "keywords": [
6
- "tts",
6
+ "cloud",
7
+ "google api client",
8
+ "google api",
9
+ "google apis client",
10
+ "google apis",
11
+ "google cloud platform",
12
+ "google cloud",
13
+ "google texttospeech",
7
14
  "google",
8
- "google-tts",
9
- "text-to-speech",
10
- "google-text-to-speech"
15
+ "google-api",
16
+ "text-to-speech api",
17
+ "texttospeech"
11
18
  ],
12
19
  "homepage": "https://github.com/sefinek24/google-tts-api#readme",
13
20
  "bugs": {
@@ -35,11 +42,13 @@
35
42
  "testEnvironment": "node"
36
43
  },
37
44
  "dependencies": {
38
- "axios": "^1.6.7"
45
+ "axios": "^1.7.7"
39
46
  },
40
47
  "devDependencies": {
48
+ "@eslint/js": "^9.10.0",
49
+ "globals": "^15.9.0",
41
50
  "is-base64": "^1.1.0",
42
51
  "jest": "^29.7.0",
43
- "typescript": "^5.4.2"
52
+ "typescript": "^5.6.2"
44
53
  }
45
54
  }
@@ -7,11 +7,11 @@ const TestCases = [
7
7
  ['Hello'],
8
8
  ['hello world', { lang: 'en' }],
9
9
  ['hello world', { slow: false }],
10
- ['hello world', { host: 'https://translate.google.com.cn/' }],
10
+ ['hello world', { host: 'https://translate.google.pl' }],
11
11
  ['你好', { lang: 'zh' }],
12
12
  ['你好世界', { lang: 'zh' }],
13
13
  ['123', { lang: 'en', slow: true }],
14
- ['123', { lang: 'zh', slow: true }],
14
+ ['123', { lang: 'zh', slow: true }]
15
15
  ];
16
16
 
17
17
  test('get TTS URL', async () => {
@@ -10,7 +10,7 @@ const TestCases = [
10
10
  ['test', { slow: null }, 'slow should be a boolean'],
11
11
  ['test', { slow: 123 }, 'slow should be a boolean'],
12
12
  ['test', { host: null }, 'host should be a string'],
13
- ['test', { host: '' }, 'host should be a string'],
13
+ ['test', { host: '' }, 'host should be a string']
14
14
  ];
15
15
 
16
16
  test('test paramater for TTS URL', async () => {
@@ -33,7 +33,7 @@ test('test paramater for TTS base64', async () => {
33
33
  ['test', { timeout: null }, 'timeout should be a positive number'],
34
34
  ['test', { timeout: -10 }, 'timeout should be a positive number'],
35
35
  ['test', { timeout: 10 }, 'timeout of 10ms exceeded'],
36
- ['test', { lang: 'DOG-LANG' }, 'lang "DOG-LANG" might not exist'],
36
+ ['test', { lang: 'DOG-LANG' }, 'lang "DOG-LANG" might not exist']
37
37
  ];
38
38
 
39
39
  for (const [text, option, errorMessage] of Base64TestCases) {
@@ -59,7 +59,7 @@ describe('Split long text', () => {
59
59
 
60
60
  it('the single word is too long to split into short text', () => {
61
61
  expect(() => splitLongText(text200, { maxLength: 100 })).toThrow(
62
- 'The word is too long to split into a short text:',
62
+ 'The word is too long to split into a short text:'
63
63
  );
64
64
  });
65
65
 
@@ -73,7 +73,7 @@ describe('Split long text', () => {
73
73
 
74
74
  // no additional split punctuation
75
75
  expect(() => splitLongText(longChineseText)).toThrow(
76
- 'The word is too long to split into a short text:',
76
+ 'The word is too long to split into a short text:'
77
77
  );
78
78
 
79
79
  // add additional split punctuation
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertInputTypes.js","sourceRoot":"","sources":["../src/assertInputTypes.ts"],"names":[],"mappings":";;AAAA,IAAM,gBAAgB,GAAG,UAAC,IAAY,EAAE,IAAY,EAAE,IAAa,EAAE,IAAY;IAC/E,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC,CAAC;IACjD,CAAC;AACH,CAAC,CAAC;AAEF,kBAAe,gBAAgB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getAudioBase64.js","sourceRoot":"","sources":["../src/getAudioBase64.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wEAAkD;AAClD,gDAA0B;AAC1B,kEAA4C;AAS5C;;;;;;;;;;GAUG;AACI,IAAM,cAAc,GAAG;;;;;sFAC1B,IAAY,EACZ,EAAkG;;YAAlG,qBAAgG,EAAE,KAAA,EAAhG,YAAW,EAAX,IAAI,mBAAG,IAAI,KAAA,EAAE,YAAY,EAAZ,IAAI,mBAAG,KAAK,KAAA,EAAE,YAAqC,EAArC,IAAI,mBAAG,8BAA8B,KAAA,EAAE,eAAe,EAAf,OAAO,mBAAG,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","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAA6D;AAGpD,4FAHA,yBAAW,OAGA;AAAE,gGAHA,6BAAe,OAGA;AAFrC,mDAAqE;AAE9B,+FAF9B,+BAAc,OAE8B;AAAE,kGAF9B,kCAAiB,OAE8B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"splitLongText.js","sourceRoot":"","sources":["../src/splitLongText.ts"],"names":[],"mappings":";;AAAA,+FAA+F;AAC/F,IAAM,WAAW,GAAG,iBAAiB,CAAC;AAEtC,2EAA2E;AAC3E,IAAM,yBAAyB,GAAG,oCAAoC,CAAC;AAOvE;;;;;;;;;GASG;AACH,IAAM,aAAa,GAAG,UAClB,IAAY,EACZ,EAAiD;QAAjD,qBAA+C,EAAE,KAAA,EAA/C,iBAAe,EAAf,SAAS,mBAAG,GAAG,KAAA,EAAE,kBAAe,EAAf,UAAU,mBAAG,EAAE,KAAA;IAEpC,IAAM,cAAc,GAAG,UAAC,CAAS,EAAE,CAAS;QAC1C,IAAM,KAAK,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,WAAW,GAAG,yBAAyB,GAAG,UAAU,GAAG,GAAG,CAAC,CAAC;QAC3F,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC;IAEF,IAAM,uBAAuB,GAAG,UAAC,CAAS,EAAE,IAAY,EAAE,KAAa;QACrE,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,IAAI,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;gBAAE,OAAO,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,CAAC,CAAC,CAAC,CAAC,YAAY;IACzB,CAAC,CAAC;IAEF,IAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAM,SAAS,GAAG,UAAC,IAAY,EAAE,KAAa,EAAE,GAAW;QACzD,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+0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
-
5
- /* Basic Options */
6
- // "incremental": true, /* Enable incremental compilation */
7
- "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
8
- "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9
- // "lib": [], /* Specify library files to be included in the compilation. */
10
- // "allowJs": true, /* Allow javascript files to be compiled. */
11
- // "checkJs": true, /* Report errors in .js files. */
12
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
13
- "declaration": true, /* Generates corresponding '.d.ts' file. */
14
- "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15
- "sourceMap": true, /* Generates corresponding '.map' file. */
16
- // "outFile": "./", /* Concatenate and emit output to single file. */
17
- "outDir": "./dist", /* Redirect output structure to the directory. */
18
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19
- // "composite": true, /* Enable project compilation */
20
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
21
- // "removeComments": true, /* Do not emit comments to output. */
22
- // "noEmit": true, /* Do not emit outputs. */
23
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
24
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
26
-
27
- /* Strict Type-Checking Options */
28
- "strict": true, /* Enable all strict type-checking options. */
29
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
30
- // "strictNullChecks": true, /* Enable strict null checks. */
31
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
32
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
33
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
34
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
35
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
36
-
37
- /* Additional Checks */
38
- // "noUnusedLocals": true, /* Report errors on unused locals. */
39
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
40
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
41
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
42
- // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
43
-
44
- /* Module Resolution Options */
45
- // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
46
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
47
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
48
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
49
- // "typeRoots": [], /* List of folders to include type definitions from. */
50
- // "types": [], /* Type declaration files to be included in compilation. */
51
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
52
- "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
53
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
54
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
55
-
56
- /* Source Map Options */
57
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
58
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
59
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
60
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
61
-
62
- /* Experimental Options */
63
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
64
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
65
-
66
- /* Advanced Options */
67
- "skipLibCheck": true, /* Skip type checking of declaration files. */
68
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
69
- },
70
- "include": [
71
- "src"
72
- ]
73
- }