@esgettext/tools 1.0.0 → 1.2.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.
Files changed (113) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +197 -22
  3. package/dist/command.js +2 -0
  4. package/dist/commands/convert.js +286 -0
  5. package/dist/commands/install.js +257 -0
  6. package/dist/commands/msgfmt-all.js +219 -0
  7. package/dist/commands/msgmerge-all.js +230 -0
  8. package/dist/commands/xgettext/file-resolver.js +20 -0
  9. package/dist/commands/xgettext/files-collector.js +39 -0
  10. package/dist/commands/xgettext.js +534 -0
  11. package/dist/configuration.js +277 -0
  12. package/dist/esgettext-package-json.js +2 -0
  13. package/dist/index.js +135 -0
  14. package/dist/package.js +10 -12
  15. package/dist/parser/javascript.js +9 -28
  16. package/dist/parser/parser.js +176 -148
  17. package/dist/parser/po.js +144 -128
  18. package/dist/parser/typescript.js +10 -28
  19. package/dist/pot/catalog.js +134 -83
  20. package/dist/pot/entry.js +173 -115
  21. package/dist/pot/keyword.js +66 -92
  22. package/package.json +38 -25
  23. package/bin/esgettext-install.js +0 -5
  24. package/bin/esgettext-mo2json.js +0 -5
  25. package/bin/esgettext-msgfmt-all.js +0 -5
  26. package/bin/esgettext-msgmerge-all.js +0 -5
  27. package/bin/esgettext-xgettext.js +0 -5
  28. package/dist/cli/getopt.d.ts +0 -34
  29. package/dist/cli/getopt.js +0 -150
  30. package/dist/cli/getopt.js.map +0 -1
  31. package/dist/cli/getopt.spec.d.ts +0 -1
  32. package/dist/cli/getopt.spec.js +0 -164
  33. package/dist/cli/getopt.spec.js.map +0 -1
  34. package/dist/cli/install.d.ts +0 -1
  35. package/dist/cli/install.js +0 -91
  36. package/dist/cli/install.js.map +0 -1
  37. package/dist/cli/mo2json-cli.d.ts +0 -1
  38. package/dist/cli/mo2json-cli.js +0 -48
  39. package/dist/cli/mo2json-cli.js.map +0 -1
  40. package/dist/cli/msgfmt-all.d.ts +0 -1
  41. package/dist/cli/msgfmt-all.js +0 -99
  42. package/dist/cli/msgfmt-all.js.map +0 -1
  43. package/dist/cli/msgmerge-all.d.ts +0 -1
  44. package/dist/cli/msgmerge-all.js +0 -85
  45. package/dist/cli/msgmerge-all.js.map +0 -1
  46. package/dist/cli/xgettext-cli.d.ts +0 -1
  47. package/dist/cli/xgettext-cli.js +0 -303
  48. package/dist/cli/xgettext-cli.js.map +0 -1
  49. package/dist/install/install.d.ts +0 -10
  50. package/dist/install/install.js +0 -157
  51. package/dist/install/install.js.map +0 -1
  52. package/dist/msgfmt-all/msgfmt-all.d.ts +0 -8
  53. package/dist/msgfmt-all/msgfmt-all.js +0 -142
  54. package/dist/msgfmt-all/msgfmt-all.js.map +0 -1
  55. package/dist/msgmerge-all/msgmerge-all.d.ts +0 -9
  56. package/dist/msgmerge-all/msgmerge-all.js +0 -157
  57. package/dist/msgmerge-all/msgmerge-all.js.map +0 -1
  58. package/dist/package.d.ts +0 -4
  59. package/dist/package.js.map +0 -1
  60. package/dist/parser/__snapshots__/javascript.spec.js.snap +0 -56
  61. package/dist/parser/__snapshots__/po.spec.js.snap +0 -176
  62. package/dist/parser/javascript.d.ts +0 -4
  63. package/dist/parser/javascript.js.map +0 -1
  64. package/dist/parser/javascript.spec.d.ts +0 -1
  65. package/dist/parser/javascript.spec.js +0 -436
  66. package/dist/parser/javascript.spec.js.map +0 -1
  67. package/dist/parser/parser.d.ts +0 -45
  68. package/dist/parser/parser.js.map +0 -1
  69. package/dist/parser/po.d.ts +0 -22
  70. package/dist/parser/po.js.map +0 -1
  71. package/dist/parser/po.spec.d.ts +0 -1
  72. package/dist/parser/po.spec.js +0 -296
  73. package/dist/parser/po.spec.js.map +0 -1
  74. package/dist/parser/typescript.d.ts +0 -4
  75. package/dist/parser/typescript.js.map +0 -1
  76. package/dist/parser/typescript.spec.d.ts +0 -1
  77. package/dist/parser/typescript.spec.js +0 -106
  78. package/dist/parser/typescript.spec.js.map +0 -1
  79. package/dist/pot/__snapshots__/catalog.spec.js.snap +0 -591
  80. package/dist/pot/catalog.d.ts +0 -26
  81. package/dist/pot/catalog.js.map +0 -1
  82. package/dist/pot/catalog.spec.d.ts +0 -1
  83. package/dist/pot/catalog.spec.js +0 -240
  84. package/dist/pot/catalog.spec.js.map +0 -1
  85. package/dist/pot/entry.d.ts +0 -35
  86. package/dist/pot/entry.js.map +0 -1
  87. package/dist/pot/entry.spec.d.ts +0 -1
  88. package/dist/pot/entry.spec.js +0 -317
  89. package/dist/pot/entry.spec.js.map +0 -1
  90. package/dist/pot/keyword.d.ts +0 -17
  91. package/dist/pot/keyword.js.map +0 -1
  92. package/dist/pot/keyword.spec.d.ts +0 -1
  93. package/dist/pot/keyword.spec.js +0 -54
  94. package/dist/pot/keyword.spec.js.map +0 -1
  95. package/dist/xgettext/__snapshots__/xgettext.spec.js.snap +0 -462
  96. package/dist/xgettext/file-resolver.d.ts +0 -5
  97. package/dist/xgettext/file-resolver.js +0 -23
  98. package/dist/xgettext/file-resolver.js.map +0 -1
  99. package/dist/xgettext/file-resolver.spec.d.ts +0 -1
  100. package/dist/xgettext/file-resolver.spec.js +0 -22
  101. package/dist/xgettext/file-resolver.spec.js.map +0 -1
  102. package/dist/xgettext/files-collector.d.ts +0 -5
  103. package/dist/xgettext/files-collector.js +0 -41
  104. package/dist/xgettext/files-collector.js.map +0 -1
  105. package/dist/xgettext/files-collector.spec.d.ts +0 -1
  106. package/dist/xgettext/files-collector.spec.js +0 -78
  107. package/dist/xgettext/files-collector.spec.js.map +0 -1
  108. package/dist/xgettext/xgettext.d.ts +0 -16
  109. package/dist/xgettext/xgettext.js +0 -335
  110. package/dist/xgettext/xgettext.js.map +0 -1
  111. package/dist/xgettext/xgettext.spec.d.ts +0 -1
  112. package/dist/xgettext/xgettext.spec.js +0 -743
  113. package/dist/xgettext/xgettext.spec.js.map +0 -1
package/dist/parser/po.js CHANGED
@@ -1,41 +1,41 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.PoParser = void 0;
19
- var iconv_lite_1 = require("iconv-lite");
20
- var runtime_1 = require("@esgettext/runtime");
21
- var entry_1 = require("../pot/entry");
22
- var parser_1 = require("./parser");
23
- var gtx = runtime_1.Textdomain.getInstance('tools');
24
- var PoParser = (function (_super) {
25
- __extends(PoParser, _super);
26
- function PoParser() {
27
- var _this = _super !== null && _super.apply(this, arguments) || this;
28
- _this.msgType = null;
29
- return _this;
4
+ const iconv_lite_1 = require("iconv-lite");
5
+ const runtime_1 = require("@esgettext/runtime");
6
+ const entry_1 = require("../pot/entry");
7
+ const parser_1 = require("./parser");
8
+ const gtx = runtime_1.Textdomain.getInstance('tools');
9
+ class PoParser extends parser_1.Parser {
10
+ constructor() {
11
+ super(...arguments);
12
+ // All those get reset on each call to parse().
13
+ this.entry = undefined;
14
+ this.loc = undefined;
15
+ this.entryLoc = undefined;
16
+ this.msgType = undefined;
17
+ this.seen = {};
30
18
  }
31
- PoParser.prototype.parse = function (buf, filename, encoding) {
19
+ /**
20
+ * Parse a po file into a catalog. This parser is very forgiving and
21
+ * accepts input that actually does not follow the standard in certain
22
+ * areas.
23
+ *
24
+ * The encoding will always be read from the PO header if present.
25
+ *
26
+ * @param input - the content of the po file
27
+ * @param filename - the filename
28
+ * @param encoding - an optional encoding
29
+ */
30
+ parse(buf, filename, encoding) {
32
31
  if (typeof encoding !== 'undefined') {
33
32
  if (!(0, iconv_lite_1.encodingExists)(encoding)) {
34
- console.error(gtx._x('unsupported encoding "{encoding}"', { encoding: encoding }));
33
+ console.error(gtx._x('unsupported encoding "{encoding}"', { encoding }));
35
34
  return false;
36
35
  }
37
36
  }
38
- var input = typeof encoding === 'undefined' ? buf.toString() : (0, iconv_lite_1.decode)(buf, encoding);
37
+ const input = typeof encoding === 'undefined' ? buf.toString() : (0, iconv_lite_1.decode)(buf, encoding);
38
+ // Reset parser.
39
39
  this.entry = undefined;
40
40
  this.filename = filename;
41
41
  this.loc = {
@@ -44,16 +44,22 @@ var PoParser = (function (_super) {
44
44
  column: 1,
45
45
  index: 0,
46
46
  },
47
- end: null,
48
- filename: filename,
47
+ end: {
48
+ line: 0,
49
+ column: 0,
50
+ index: 0,
51
+ },
52
+ filename,
49
53
  identifierName: '',
50
54
  };
51
- this.msgType = null;
55
+ this.msgType = undefined;
52
56
  this.seen = {};
53
57
  this.errors = 0;
54
- var lines = input.split('\n');
55
- for (var i = 0; i < lines.length; ++i) {
56
- var line = lines[i];
58
+ // We cannot use forEach here because we may have to return from
59
+ // inside the loop.
60
+ const lines = input.split('\n');
61
+ for (let i = 0; i < lines.length; ++i) {
62
+ const line = lines[i];
57
63
  this.loc.start.column = 1;
58
64
  ++this.loc.start.line;
59
65
  if (line === '') {
@@ -61,17 +67,20 @@ var PoParser = (function (_super) {
61
67
  this.entry.properties.msgid === '' &&
62
68
  typeof this.entry.properties.msgctxt === 'undefined' &&
63
69
  this.entry.properties.msgstr) {
64
- var charset = this.extractCharset(this.entry.properties.msgstr);
70
+ const charset = this.extractCharset(this.entry.properties.msgstr);
65
71
  if (charset &&
66
72
  (typeof encoding === 'undefined' ||
67
73
  charset.toLowerCase() !== encoding.toLowerCase())) {
74
+ // FIXME! This must only happen, if the header is the first
75
+ // entry that has been added. Otherwise, we'll add the entries
76
+ // before this, twice.
68
77
  return this.parse(buf, filename, charset);
69
78
  }
70
79
  }
71
80
  this.flushEntry();
72
81
  }
73
82
  else {
74
- var first = line[0];
83
+ const first = line[0];
75
84
  switch (first) {
76
85
  case '#':
77
86
  if (line.length > 1 && line[1] === '~') {
@@ -112,10 +121,13 @@ var PoParser = (function (_super) {
112
121
  this.entry.properties.msgid === '' &&
113
122
  typeof this.entry.properties.msgctxt === 'undefined' &&
114
123
  this.entry.properties.msgstr) {
115
- var charset = this.extractCharset(this.entry.properties.msgstr);
124
+ const charset = this.extractCharset(this.entry.properties.msgstr);
116
125
  if (charset &&
117
126
  (typeof encoding === 'undefined' ||
118
127
  charset.toLowerCase() !== encoding.toLowerCase())) {
128
+ // FIXME! This must only happen, if the header is the first
129
+ // entry that has been added. Otherwise, we'll add the entries
130
+ // before this, twice.
119
131
  return this.parse(buf, filename, charset);
120
132
  }
121
133
  }
@@ -123,50 +135,53 @@ var PoParser = (function (_super) {
123
135
  if (this.errors) {
124
136
  return false;
125
137
  }
138
+ // FIXME! This must go into the caller!
126
139
  this.catalog.makePOT();
127
140
  return true;
128
- };
129
- PoParser.prototype.doParse = function (_input, _filename) {
141
+ }
142
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
143
+ doParse(_input, _filename) {
130
144
  throw new Error('not implemented');
131
- };
132
- PoParser.prototype.extractCharset = function (header) {
133
- var headers = {};
145
+ }
146
+ extractCharset(header) {
147
+ const headers = {};
134
148
  header
135
149
  .split('\n')
136
- .map(function (line) { return line.split(':'); })
137
- .map(function (chunks) { return ({
150
+ .map(line => line.split(':'))
151
+ .map(chunks => ({
138
152
  name: chunks[0].toLowerCase(),
139
153
  value: chunks.slice(1).join(':').trim(),
140
- }); })
141
- .filter(function (header) { return header.name !== ''; })
142
- .forEach(function (header) { return (headers[header.name] = header.value); });
143
- var contentType = headers['content-type'];
154
+ }))
155
+ .filter(header => header.name !== '')
156
+ .forEach(header => (headers[header.name] = header.value));
157
+ const contentType = headers['content-type'];
144
158
  if (typeof contentType === 'undefined') {
145
159
  return null;
146
160
  }
147
- var tokens = contentType.split('=').map(function (token) { return token.trim(); });
161
+ const tokens = contentType.split('=').map(token => token.trim());
148
162
  if (tokens.length <= 1) {
149
163
  return null;
150
164
  }
151
- var charset = tokens[tokens.length - 1];
165
+ const charset = tokens[tokens.length - 1];
152
166
  if (!(0, iconv_lite_1.encodingExists)(charset)) {
153
167
  this.warn(gtx._x('the charset "{charset}" is not a portable encoding name.', {
154
- charset: charset,
168
+ charset,
155
169
  }), this.loc);
156
170
  this.warn(gtx._('message conversion to the users charset might not work.'), this.loc);
157
171
  return null;
158
172
  }
159
173
  return charset;
160
- };
161
- PoParser.prototype.flushEntry = function () {
174
+ }
175
+ flushEntry() {
162
176
  if (this.errors) {
163
177
  this.entry = undefined;
164
178
  return;
165
179
  }
166
180
  if (this.entry) {
167
- var msgctxt = this.entry.properties.msgctxt;
168
- var msgid = this.entry.properties.msgid;
181
+ const msgctxt = this.entry.properties.msgctxt;
182
+ const msgid = this.entry.properties.msgid;
169
183
  if (typeof msgid === 'undefined') {
184
+ // TRANSLATORS: Do not translate "msgid".
170
185
  this.error(gtx._('missing "msgid" section'), this.loc);
171
186
  return;
172
187
  }
@@ -182,9 +197,9 @@ var PoParser = (function (_super) {
182
197
  this.catalog.addEntry(this.entry);
183
198
  }
184
199
  this.entry = undefined;
185
- };
186
- PoParser.prototype.parseCommentLine = function (line) {
187
- var marker = line[1];
200
+ }
201
+ parseCommentLine(line) {
202
+ const marker = line[1];
188
203
  switch (marker) {
189
204
  case ',':
190
205
  this.parseFlags(line);
@@ -202,44 +217,43 @@ var PoParser = (function (_super) {
202
217
  this.entry.addTranslatorCommentLine(line.substr(1));
203
218
  break;
204
219
  }
205
- };
206
- PoParser.prototype.parseKeywordLine = function (line) {
207
- var _this = this;
208
- var errorsBefore = this.errors;
209
- var remainder = line.replace(/^[_A-Za-z0-9[\]]+/, function (keyword) {
220
+ }
221
+ parseKeywordLine(line) {
222
+ const errorsBefore = this.errors;
223
+ let remainder = line.replace(/^[_A-Za-z0-9[\]]+/, keyword => {
210
224
  switch (keyword) {
211
225
  case 'msgid':
212
- _this.entryLoc = _this.copyLocation(_this.loc);
213
- _this.msgType = keyword;
214
- if (typeof _this.entry.properties.msgid !== 'undefined') {
215
- _this.error(gtx._x('duplicate "{keyword}" section', { keyword: keyword }), _this.loc);
226
+ this.entryLoc = this.copyLocation(this.loc);
227
+ this.msgType = keyword;
228
+ if (typeof this.entry.properties.msgid !== 'undefined') {
229
+ this.error(gtx._x('duplicate "{keyword}" section', { keyword }), this.loc);
216
230
  }
217
231
  break;
218
232
  case 'msgstr':
219
- _this.msgType = keyword;
220
- if (typeof _this.entry.properties.msgstr !== 'undefined') {
221
- _this.error(gtx._x('duplicate "{keyword}" section', { keyword: keyword }), _this.loc);
233
+ this.msgType = keyword;
234
+ if (typeof this.entry.properties.msgstr !== 'undefined') {
235
+ this.error(gtx._x('duplicate "{keyword}" section', { keyword }), this.loc);
222
236
  }
223
237
  break;
224
238
  case 'msgid_plural':
225
- _this.msgType = keyword;
226
- if (typeof _this.entry.properties.msgidPlural !== 'undefined') {
227
- _this.error(gtx._x('duplicate "{keyword}" section', { keyword: keyword }), _this.loc);
239
+ this.msgType = keyword;
240
+ if (typeof this.entry.properties.msgidPlural !== 'undefined') {
241
+ this.error(gtx._x('duplicate "{keyword}" section', { keyword }), this.loc);
228
242
  }
229
243
  break;
230
244
  case 'msgctxt':
231
- _this.msgType = keyword;
232
- if (typeof _this.entry.properties.msgctxt !== 'undefined') {
233
- _this.error(gtx._x('duplicate "{keyword}" section', { keyword: keyword }), _this.loc);
245
+ this.msgType = keyword;
246
+ if (typeof this.entry.properties.msgctxt !== 'undefined') {
247
+ this.error(gtx._x('duplicate "{keyword}" section', { keyword }), this.loc);
234
248
  }
235
249
  break;
236
250
  default:
237
251
  if (!/^msgstr\[[0-9]+\]/.exec(keyword)) {
238
- _this.error(gtx._x('keyword "{keyword}" unknown', { keyword: keyword }), _this.loc);
252
+ this.error(gtx._x('keyword "{keyword}" unknown', { keyword }), this.loc);
239
253
  }
240
- _this.msgType = keyword;
254
+ this.msgType = keyword;
241
255
  }
242
- _this.loc.start.column += keyword.length;
256
+ this.loc.start.column += keyword.length;
243
257
  return '';
244
258
  });
245
259
  if (errorsBefore !== this.errors) {
@@ -252,21 +266,20 @@ var PoParser = (function (_super) {
252
266
  else {
253
267
  this.syntaxError();
254
268
  }
255
- };
256
- PoParser.prototype.parseQuotedString = function (line) {
257
- var _this = this;
269
+ }
270
+ parseQuotedString(line) {
258
271
  if (!line.endsWith('"')) {
259
272
  this.loc.start.column += line.length;
260
273
  this.error(gtx._('end-of-line within string'), this.loc);
261
274
  return;
262
275
  }
263
- var raw = line.substr(1, line.length - 2);
276
+ const raw = line.substr(1, line.length - 2);
264
277
  if (raw.length && raw.endsWith('\\')) {
265
278
  this.error(gtx._('end-of-line within string'), this.loc);
266
279
  return;
267
280
  }
268
- var msg = raw.replace(/\\./g, function (match, offset) {
269
- var retval;
281
+ const msg = raw.replace(/\\./g, (match, offset) => {
282
+ let retval;
270
283
  switch (match[1]) {
271
284
  case '\\':
272
285
  case '"':
@@ -294,8 +307,9 @@ var PoParser = (function (_super) {
294
307
  retval = '\r';
295
308
  break;
296
309
  default:
297
- _this.loc.start.column += offset + 1;
298
- _this.error(gtx._('invalid control sequence'), _this.loc);
310
+ // We have to take the leading quote into account.
311
+ this.loc.start.column += offset + 1;
312
+ this.error(gtx._('invalid control sequence'), this.loc);
299
313
  retval = '';
300
314
  }
301
315
  return retval;
@@ -317,78 +331,80 @@ var PoParser = (function (_super) {
317
331
  this.entry.addToMsgctxt(msg);
318
332
  break;
319
333
  default:
334
+ // Ignore plural translations.
320
335
  break;
321
336
  }
322
- };
323
- PoParser.prototype.parseFlags = function (line) {
324
- var _this = this;
325
- var flags = line.substr(2).split(',');
326
- flags.forEach(function (flag, i) {
337
+ }
338
+ parseFlags(line) {
339
+ const flags = line.substr(2).split(',');
340
+ flags.forEach((flag, i) => {
327
341
  if (i) {
328
- ++_this.loc.start.column;
342
+ ++this.loc.start.column;
329
343
  }
330
- var rspace = _this.rspace(flag);
331
- flag = _this.trim(flag);
344
+ const rspace = this.rspace(flag);
345
+ flag = this.trim(flag);
332
346
  if (!flag.length) {
333
- _this.warn(gtx._('ignoring empty flag'), _this.loc);
347
+ this.warn(gtx._('ignoring empty flag'), this.loc);
334
348
  }
335
349
  else {
336
- _this.entry.addFlag(flag);
350
+ this.entry.addFlag(flag);
337
351
  }
338
- _this.loc.start.column += rspace + flag.length;
352
+ this.loc.start.column += rspace + flag.length;
339
353
  });
340
- };
341
- PoParser.prototype.parseReferences = function (line) {
342
- var _this = this;
354
+ }
355
+ parseReferences(line) {
343
356
  this.loc.start.column += 2;
344
- var refs = line.substr(2).split(' ');
345
- refs.forEach(function (reference, i) {
357
+ const refs = line.substr(2).split(' ');
358
+ refs.forEach((reference, i) => {
346
359
  if (i) {
347
- ++_this.loc.start.column;
360
+ ++this.loc.start.column;
348
361
  }
349
- reference = _this.trim(reference);
362
+ reference = this.trim(reference);
350
363
  if (/.+:[1-9][0-9]*$/.exec(reference)) {
351
- _this.entry.addReference(reference);
364
+ this.entry.addReference(reference);
352
365
  }
353
366
  else if (reference !== '') {
354
- _this.warn(gtx._x('ignoring mal-formed reference "{reference}"', {
355
- reference: reference,
356
- }), _this.loc);
367
+ this.warn(gtx._x('ignoring mal-formed reference "{reference}"', {
368
+ reference,
369
+ }), this.loc);
357
370
  }
358
- _this.loc.start.column += reference.length;
371
+ this.loc.start.column += reference.length;
359
372
  });
360
- };
361
- PoParser.prototype.syntaxError = function () {
373
+ }
374
+ syntaxError() {
362
375
  this.error(gtx._('syntax error'), this.loc);
363
- };
364
- PoParser.prototype.trim = function (str) {
365
- var _this = this;
376
+ }
377
+ trim(str) {
366
378
  return str
367
- .replace(/^[\s\uFEFF\xA0]+/, function (match) {
368
- _this.loc.start.column += match.length;
379
+ .replace(/^[\s\uFEFF\xA0]+/, match => {
380
+ this.loc.start.column += match.length;
369
381
  return '';
370
382
  })
371
383
  .trim();
372
- };
373
- PoParser.prototype.rspace = function (str) {
374
- var space = /[\s\uFEFF\xA0]+$/.exec(str);
384
+ }
385
+ rspace(str) {
386
+ const space = /[\s\uFEFF\xA0]+$/.exec(str);
375
387
  if (space) {
376
388
  return space[0].length;
377
389
  }
378
390
  else {
379
391
  return 0;
380
392
  }
381
- };
382
- PoParser.prototype.copyLocation = function (loc) {
393
+ }
394
+ copyLocation(loc) {
383
395
  return {
384
396
  start: {
385
397
  line: loc.start.line,
386
398
  column: loc.start.column,
387
399
  },
388
- end: null,
400
+ end: {
401
+ line: 0,
402
+ column: 0,
403
+ index: 0,
404
+ },
405
+ filename: '',
406
+ identifierName: null,
389
407
  };
390
- };
391
- return PoParser;
392
- }(parser_1.Parser));
408
+ }
409
+ }
393
410
  exports.PoParser = PoParser;
394
- //# sourceMappingURL=po.js.map
@@ -1,35 +1,18 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.TypeScriptParser = void 0;
19
- var parser_1 = require("@babel/parser");
20
- var parser_2 = require("./parser");
21
- var TypeScriptParser = (function (_super) {
22
- __extends(TypeScriptParser, _super);
23
- function TypeScriptParser() {
24
- return _super !== null && _super.apply(this, arguments) || this;
25
- }
26
- TypeScriptParser.prototype.doParse = function (input, filename) {
27
- var ast = (0, parser_1.parse)(input, {
4
+ const parser_1 = require("@babel/parser");
5
+ const parser_2 = require("./parser");
6
+ class TypeScriptParser extends parser_2.Parser {
7
+ doParse(input, filename) {
8
+ const ast = (0, parser_1.parse)(input, {
28
9
  allowAwaitOutsideFunction: true,
29
10
  allowImportExportEverywhere: true,
30
11
  allowReturnOutsideFunction: true,
31
12
  allowSuperOutsideMethod: true,
32
13
  allowUndeclaredExports: true,
14
+ // Documented but not supported. FIXME! Maybe only missing in types.
15
+ // errorRecovery: true,
33
16
  sourceFilename: filename,
34
17
  plugins: [
35
18
  'typescript',
@@ -37,11 +20,10 @@ var TypeScriptParser = (function (_super) {
37
20
  'classProperties',
38
21
  'classPrivateMethods',
39
22
  'classPrivateProperties',
23
+ 'decorators',
40
24
  ],
41
25
  });
42
26
  return this.extract(filename, ast);
43
- };
44
- return TypeScriptParser;
45
- }(parser_2.Parser));
27
+ }
28
+ }
46
29
  exports.TypeScriptParser = TypeScriptParser;
47
- //# sourceMappingURL=typescript.js.map