@formatjs/cli-lib 5.0.4 → 5.0.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.
Files changed (80) hide show
  1. package/BUILD +118 -0
  2. package/CHANGELOG.md +1097 -0
  3. package/LICENSE.md +0 -0
  4. package/README.md +0 -0
  5. package/index.ts +7 -0
  6. package/main.ts +5 -0
  7. package/package.json +61 -61
  8. package/src/cli.ts +240 -0
  9. package/src/compile.ts +141 -0
  10. package/src/compile_folder.ts +15 -0
  11. package/src/console_utils.ts +78 -0
  12. package/src/extract.ts +273 -0
  13. package/src/formatters/crowdin.ts +34 -0
  14. package/src/formatters/default.ts +19 -0
  15. package/src/formatters/index.ts +46 -0
  16. package/src/formatters/lokalise.ts +33 -0
  17. package/src/formatters/simple.ts +12 -0
  18. package/src/formatters/smartling.ts +73 -0
  19. package/src/formatters/transifex.ts +33 -0
  20. package/src/parse_script.ts +49 -0
  21. package/src/pseudo_locale.ts +113 -0
  22. package/src/vue_extractor.ts +96 -0
  23. package/tests/unit/__snapshots__/unit.test.ts.snap +42 -0
  24. package/tests/unit/__snapshots__/vue_extractor.test.ts.snap +36 -0
  25. package/tests/unit/fixtures/bind.vue +46 -0
  26. package/tests/unit/fixtures/comp.vue +17 -0
  27. package/tests/unit/unit.test.ts +44 -0
  28. package/tests/unit/vue_extractor.test.ts +38 -0
  29. package/tsconfig.json +5 -0
  30. package/index.d.ts +0 -8
  31. package/index.d.ts.map +0 -1
  32. package/index.js +0 -12
  33. package/main.d.ts +0 -2
  34. package/main.d.ts.map +0 -1
  35. package/main.js +0 -3
  36. package/src/cli.d.ts +0 -3
  37. package/src/cli.d.ts.map +0 -1
  38. package/src/cli.js +0 -142
  39. package/src/compile.d.ts +0 -48
  40. package/src/compile.d.ts.map +0 -1
  41. package/src/compile.js +0 -122
  42. package/src/compile_folder.d.ts +0 -3
  43. package/src/compile_folder.d.ts.map +0 -1
  44. package/src/compile_folder.js +0 -22
  45. package/src/console_utils.d.ts +0 -9
  46. package/src/console_utils.d.ts.map +0 -1
  47. package/src/console_utils.js +0 -141
  48. package/src/extract.d.ts +0 -75
  49. package/src/extract.d.ts.map +0 -1
  50. package/src/extract.js +0 -220
  51. package/src/formatters/crowdin.d.ts +0 -8
  52. package/src/formatters/crowdin.d.ts.map +0 -1
  53. package/src/formatters/crowdin.js +0 -29
  54. package/src/formatters/default.d.ts +0 -6
  55. package/src/formatters/default.d.ts.map +0 -1
  56. package/src/formatters/default.js +0 -13
  57. package/src/formatters/index.d.ts +0 -9
  58. package/src/formatters/index.d.ts.map +0 -1
  59. package/src/formatters/index.js +0 -45
  60. package/src/formatters/lokalise.d.ts +0 -10
  61. package/src/formatters/lokalise.d.ts.map +0 -1
  62. package/src/formatters/lokalise.js +0 -26
  63. package/src/formatters/simple.d.ts +0 -5
  64. package/src/formatters/simple.d.ts.map +0 -1
  65. package/src/formatters/simple.js +0 -12
  66. package/src/formatters/smartling.d.ts +0 -24
  67. package/src/formatters/smartling.d.ts.map +0 -1
  68. package/src/formatters/smartling.js +0 -52
  69. package/src/formatters/transifex.d.ts +0 -10
  70. package/src/formatters/transifex.d.ts.map +0 -1
  71. package/src/formatters/transifex.js +0 -26
  72. package/src/parse_script.d.ts +0 -8
  73. package/src/parse_script.d.ts.map +0 -1
  74. package/src/parse_script.js +0 -50
  75. package/src/pseudo_locale.d.ts +0 -7
  76. package/src/pseudo_locale.d.ts.map +0 -1
  77. package/src/pseudo_locale.js +0 -104
  78. package/src/vue_extractor.d.ts +0 -3
  79. package/src/vue_extractor.d.ts.map +0 -1
  80. package/src/vue_extractor.js +0 -62
@@ -1 +0,0 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli-lib/src/formatters/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAA;AAE1D,oBAAY,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,IAAI,CAC5D,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,KACpC,CAAC,CAAA;AAEN,oBAAY,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,IAAI,CAC7D,IAAI,EAAE,CAAC,KACJ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE3B,eAAO,MAAM,MAAM,EAAE,QAAuB,CAAA;AAE5C,eAAO,MAAM,OAAO,EAAE,SAMrB,CAAA"}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compile = exports.format = void 0;
4
- var format = function (msgs) { return msgs; };
5
- exports.format = format;
6
- var compile = function (msgs) {
7
- var results = {};
8
- for (var k in msgs) {
9
- results[k] = msgs[k].defaultMessage;
10
- }
11
- return results;
12
- };
13
- exports.compile = compile;
@@ -1,9 +0,0 @@
1
- import { FormatFn, CompileFn } from './default';
2
- import { Comparator } from 'json-stable-stringify';
3
- export interface Formatter {
4
- format: FormatFn;
5
- compile: CompileFn;
6
- compareMessages?: Comparator;
7
- }
8
- export declare function resolveBuiltinFormatter(format?: string | Formatter): Promise<any>;
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli-lib/src/formatters/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,WAAW,CAAA;AAM7C,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAA;AAGhD,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,QAAQ,CAAA;IAChB,OAAO,EAAE,SAAS,CAAA;IAClB,eAAe,CAAC,EAAE,UAAU,CAAA;CAC7B;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,GAC1B,OAAO,CAAC,GAAG,CAAC,CA0Bd"}
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveBuiltinFormatter = void 0;
4
- var tslib_1 = require("tslib");
5
- var defaultFormatter = (0, tslib_1.__importStar)(require("./default"));
6
- var transifex = (0, tslib_1.__importStar)(require("./transifex"));
7
- var smartling = (0, tslib_1.__importStar)(require("./smartling"));
8
- var simple = (0, tslib_1.__importStar)(require("./simple"));
9
- var lokalise = (0, tslib_1.__importStar)(require("./lokalise"));
10
- var crowdin = (0, tslib_1.__importStar)(require("./crowdin"));
11
- var path_1 = require("path");
12
- function resolveBuiltinFormatter(format) {
13
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
14
- return (0, tslib_1.__generator)(this, function (_a) {
15
- if (!format) {
16
- return [2 /*return*/, defaultFormatter];
17
- }
18
- if (typeof format !== 'string') {
19
- return [2 /*return*/, format];
20
- }
21
- switch (format) {
22
- case 'transifex':
23
- return [2 /*return*/, transifex];
24
- case 'smartling':
25
- return [2 /*return*/, smartling];
26
- case 'simple':
27
- return [2 /*return*/, simple];
28
- case 'lokalise':
29
- return [2 /*return*/, lokalise];
30
- case 'crowdin':
31
- return [2 /*return*/, crowdin];
32
- }
33
- try {
34
- // eslint-disable-next-line import/dynamic-import-chunkname
35
- return [2 /*return*/, Promise.resolve().then(function () { return (0, tslib_1.__importStar)(require((0, path_1.resolve)(process.cwd(), format))); })];
36
- }
37
- catch (e) {
38
- console.error("Cannot resolve formatter ".concat(format));
39
- throw e;
40
- }
41
- return [2 /*return*/];
42
- });
43
- });
44
- }
45
- exports.resolveBuiltinFormatter = resolveBuiltinFormatter;
@@ -1,10 +0,0 @@
1
- import { CompileFn, FormatFn } from './default';
2
- export declare type StructuredJson = Record<string, {
3
- translation: string;
4
- notes?: string;
5
- context?: string;
6
- limit?: string;
7
- }>;
8
- export declare const format: FormatFn<StructuredJson>;
9
- export declare const compile: CompileFn<StructuredJson>;
10
- //# sourceMappingURL=lokalise.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lokalise.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli-lib/src/formatters/lokalise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAE7C,oBAAY,cAAc,GAAG,MAAM,CACjC,MAAM,EACN;IACE,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CACF,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,cAAc,CAY3C,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,cAAc,CAM7C,CAAA"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compile = exports.format = void 0;
4
- var format = function (msgs) {
5
- var results = {};
6
- for (var _i = 0, _a = Object.entries(msgs); _i < _a.length; _i++) {
7
- var _b = _a[_i], id = _b[0], msg = _b[1];
8
- results[id] = {
9
- translation: msg.defaultMessage,
10
- notes: typeof msg.description === 'string'
11
- ? msg.description
12
- : JSON.stringify(msg.description),
13
- };
14
- }
15
- return results;
16
- };
17
- exports.format = format;
18
- var compile = function (msgs) {
19
- var results = {};
20
- for (var _i = 0, _a = Object.entries(msgs); _i < _a.length; _i++) {
21
- var _b = _a[_i], id = _b[0], msg = _b[1];
22
- results[id] = msg.translation;
23
- }
24
- return results;
25
- };
26
- exports.compile = compile;
@@ -1,5 +0,0 @@
1
- import { CompileFn, FormatFn } from './default';
2
- export declare type PhraseJson = Record<string, string>;
3
- export declare const format: FormatFn<PhraseJson>;
4
- export declare const compile: CompileFn<PhraseJson>;
5
- //# sourceMappingURL=simple.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"simple.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli-lib/src/formatters/simple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAE7C,oBAAY,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE/C,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,UAAU,CAKvC,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CAAgB,CAAA"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compile = exports.format = void 0;
4
- var format = function (msgs) {
5
- return Object.keys(msgs).reduce(function (all, k) {
6
- all[k] = msgs[k].defaultMessage;
7
- return all;
8
- }, {});
9
- };
10
- exports.format = format;
11
- var compile = function (msgs) { return msgs; };
12
- exports.compile = compile;
@@ -1,24 +0,0 @@
1
- import { Comparator } from 'json-stable-stringify';
2
- import { CompileFn, FormatFn } from './default';
3
- export interface SmartlingDirectives {
4
- translate_paths: [
5
- {
6
- path: string;
7
- key: string;
8
- instruction: string;
9
- }
10
- ];
11
- variants_enabled: boolean;
12
- string_format: string;
13
- [k: string]: any;
14
- }
15
- export declare type SmartlingJson = {
16
- smartling: SmartlingDirectives;
17
- } & Record<string, {
18
- message: string;
19
- description?: string;
20
- }>;
21
- export declare const format: FormatFn<SmartlingJson>;
22
- export declare const compareMessages: Comparator;
23
- export declare const compile: CompileFn<SmartlingJson>;
24
- //# sourceMappingURL=smartling.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smartling.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli-lib/src/formatters/smartling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAE7C,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE;QACf;YACE,IAAI,EAAE,MAAM,CAAA;YACZ,GAAG,EAAE,MAAM,CAAA;YACX,WAAW,EAAE,MAAM,CAAA;SACpB;KACF,CAAA;IACD,gBAAgB,EAAE,OAAO,CAAA;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAED,oBAAY,aAAa,GAAG;IAC1B,SAAS,EAAE,mBAAmB,CAAA;CAC/B,GAAG,MAAM,CACR,MAAM,EACN;IACE,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CACF,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,aAAa,CAwB1C,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,UAS7B,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CAS5C,CAAA"}
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compile = exports.compareMessages = exports.format = void 0;
4
- var format = function (msgs) {
5
- var results = {
6
- smartling: {
7
- translate_paths: [
8
- {
9
- path: '*/message',
10
- key: '{*}/message',
11
- instruction: '*/description',
12
- },
13
- ],
14
- variants_enabled: true,
15
- string_format: 'icu',
16
- },
17
- };
18
- for (var _i = 0, _a = Object.entries(msgs); _i < _a.length; _i++) {
19
- var _b = _a[_i], id = _b[0], msg = _b[1];
20
- results[id] = {
21
- message: msg.defaultMessage,
22
- description: typeof msg.description === 'string'
23
- ? msg.description
24
- : JSON.stringify(msg.description),
25
- };
26
- }
27
- return results;
28
- };
29
- exports.format = format;
30
- var compareMessages = function (el1, el2) {
31
- // `smartling` has to be the 1st key
32
- if (el1.key === 'smartling') {
33
- return -1;
34
- }
35
- if (el2.key === 'smartling') {
36
- return 1;
37
- }
38
- return el1.key < el2.key ? -1 : el1.key === el2.key ? 0 : 1;
39
- };
40
- exports.compareMessages = compareMessages;
41
- var compile = function (msgs) {
42
- var results = {};
43
- for (var _i = 0, _a = Object.entries(msgs); _i < _a.length; _i++) {
44
- var _b = _a[_i], id = _b[0], msg = _b[1];
45
- if (id === 'smartling') {
46
- continue;
47
- }
48
- results[id] = msg.message;
49
- }
50
- return results;
51
- };
52
- exports.compile = compile;
@@ -1,10 +0,0 @@
1
- import { CompileFn, FormatFn } from './default';
2
- export declare type StructuredJson = Record<string, {
3
- string: string;
4
- developer_comment?: string;
5
- context?: string;
6
- character_limit?: string;
7
- }>;
8
- export declare const format: FormatFn<StructuredJson>;
9
- export declare const compile: CompileFn<StructuredJson>;
10
- //# sourceMappingURL=transifex.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transifex.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli-lib/src/formatters/transifex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAE7C,oBAAY,cAAc,GAAG,MAAM,CACjC,MAAM,EACN;IACE,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB,CACF,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,cAAc,CAY3C,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,cAAc,CAM7C,CAAA"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compile = exports.format = void 0;
4
- var format = function (msgs) {
5
- var results = {};
6
- for (var _i = 0, _a = Object.entries(msgs); _i < _a.length; _i++) {
7
- var _b = _a[_i], id = _b[0], msg = _b[1];
8
- results[id] = {
9
- string: msg.defaultMessage,
10
- developer_comment: typeof msg.description === 'string'
11
- ? msg.description
12
- : JSON.stringify(msg.description),
13
- };
14
- }
15
- return results;
16
- };
17
- exports.format = format;
18
- var compile = function (msgs) {
19
- var results = {};
20
- for (var _i = 0, _a = Object.entries(msgs); _i < _a.length; _i++) {
21
- var _b = _a[_i], id = _b[0], msg = _b[1];
22
- results[id] = msg.string;
23
- }
24
- return results;
25
- };
26
- exports.compile = compile;
@@ -1,8 +0,0 @@
1
- import { Opts } from '@formatjs/ts-transformer';
2
- /**
3
- * Invoid TypeScript module transpilation with our TS transformer
4
- * @param opts Formatjs TS Transformer opt
5
- * @param fn filename
6
- */
7
- export declare function parseScript(opts: Opts, fn?: string): (source: string) => void;
8
- //# sourceMappingURL=parse_script.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse_script.d.ts","sourceRoot":"","sources":["../../../../../../packages/cli-lib/src/parse_script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAkB,MAAM,0BAA0B,CAAA;AAG9D;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,MAAM,YACjC,MAAM,UAuCvB"}
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseScript = void 0;
4
- var tslib_1 = require("tslib");
5
- var ts_transformer_1 = require("@formatjs/ts-transformer");
6
- var typescript_1 = (0, tslib_1.__importDefault)(require("typescript"));
7
- var console_utils_1 = require("./console_utils");
8
- /**
9
- * Invoid TypeScript module transpilation with our TS transformer
10
- * @param opts Formatjs TS Transformer opt
11
- * @param fn filename
12
- */
13
- function parseScript(opts, fn) {
14
- return function (source) {
15
- var output;
16
- try {
17
- (0, console_utils_1.debug)('Using TS compiler to process file', fn);
18
- output = typescript_1.default.transpileModule(source, {
19
- compilerOptions: {
20
- allowJs: true,
21
- target: typescript_1.default.ScriptTarget.ESNext,
22
- noEmit: true,
23
- experimentalDecorators: true,
24
- },
25
- reportDiagnostics: true,
26
- fileName: fn,
27
- transformers: {
28
- before: [(0, ts_transformer_1.transformWithTs)(typescript_1.default, opts)],
29
- },
30
- });
31
- }
32
- catch (e) {
33
- if (e instanceof Error) {
34
- e.message = "Error processing file ".concat(fn, " \n").concat(e.message || '');
35
- }
36
- throw e;
37
- }
38
- if (output.diagnostics) {
39
- var errs = output.diagnostics.filter(function (d) { return d.category === typescript_1.default.DiagnosticCategory.Error; });
40
- if (errs.length) {
41
- throw new Error(typescript_1.default.formatDiagnosticsWithColorAndContext(errs, {
42
- getCanonicalFileName: function (fileName) { return fileName; },
43
- getCurrentDirectory: function () { return process.cwd(); },
44
- getNewLine: function () { return typescript_1.default.sys.newLine; },
45
- }));
46
- }
47
- }
48
- };
49
- }
50
- exports.parseScript = parseScript;
@@ -1,7 +0,0 @@
1
- import { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
2
- export declare function generateXXLS(msg: string | MessageFormatElement[]): MessageFormatElement[];
3
- export declare function generateXXAC(msg: string | MessageFormatElement[]): MessageFormatElement[];
4
- export declare function generateXXHA(msg: string | MessageFormatElement[]): MessageFormatElement[];
5
- export declare function generateENXA(msg: string | MessageFormatElement[]): MessageFormatElement[];
6
- export declare function generateENXB(msg: string | MessageFormatElement[]): MessageFormatElement[];
7
- //# sourceMappingURL=pseudo_locale.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pseudo_locale.d.ts","sourceRoot":"","sources":["../../../../../../packages/cli-lib/src/pseudo_locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EAMrB,MAAM,oCAAoC,CAAA;AAE3C,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,GAAG,oBAAoB,EAAE,GACnC,oBAAoB,EAAE,CAQxB;AAED,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,GAAG,oBAAoB,EAAE,GACnC,oBAAoB,EAAE,CAcxB;AAED,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,GAAG,oBAAoB,EAAE,GACnC,oBAAoB,EAAE,CAQxB;AAKD,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,GAAG,oBAAoB,EAAE,GACnC,oBAAoB,EAAE,CAuBxB;AAED,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,GAAG,oBAAoB,EAAE,GACnC,oBAAoB,EAAE,CA4BxB"}
@@ -1,104 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateENXB = exports.generateENXA = exports.generateXXHA = exports.generateXXAC = exports.generateXXLS = void 0;
4
- var tslib_1 = require("tslib");
5
- var icu_messageformat_parser_1 = require("@formatjs/icu-messageformat-parser");
6
- function generateXXLS(msg) {
7
- var ast = typeof msg === 'string' ? (0, icu_messageformat_parser_1.parse)(msg) : msg;
8
- var lastChunk = ast.pop();
9
- if (lastChunk && (0, icu_messageformat_parser_1.isLiteralElement)(lastChunk)) {
10
- lastChunk.value += 'SSSSSSSSSSSSSSSSSSSSSSSSS';
11
- return (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], ast, true), [lastChunk], false);
12
- }
13
- return (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], ast, true), [{ type: icu_messageformat_parser_1.TYPE.literal, value: 'SSSSSSSSSSSSSSSSSSSSSSSSS' }], false);
14
- }
15
- exports.generateXXLS = generateXXLS;
16
- function generateXXAC(msg) {
17
- var ast = typeof msg === 'string' ? (0, icu_messageformat_parser_1.parse)(msg) : msg;
18
- ast.forEach(function (el) {
19
- if ((0, icu_messageformat_parser_1.isLiteralElement)(el)) {
20
- el.value = el.value.toUpperCase();
21
- }
22
- else if ((0, icu_messageformat_parser_1.isPluralElement)(el) || (0, icu_messageformat_parser_1.isSelectElement)(el)) {
23
- for (var _i = 0, _a = Object.values(el.options); _i < _a.length; _i++) {
24
- var opt = _a[_i];
25
- generateXXAC(opt.value);
26
- }
27
- }
28
- else if ((0, icu_messageformat_parser_1.isTagElement)(el)) {
29
- generateXXAC(el.children);
30
- }
31
- });
32
- return ast;
33
- }
34
- exports.generateXXAC = generateXXAC;
35
- function generateXXHA(msg) {
36
- var ast = typeof msg === 'string' ? (0, icu_messageformat_parser_1.parse)(msg) : msg;
37
- var firstChunk = ast.shift();
38
- if (firstChunk && (0, icu_messageformat_parser_1.isLiteralElement)(firstChunk)) {
39
- firstChunk.value = '[javascript]' + firstChunk.value;
40
- return (0, tslib_1.__spreadArray)([firstChunk], ast, true);
41
- }
42
- return (0, tslib_1.__spreadArray)([{ type: icu_messageformat_parser_1.TYPE.literal, value: '[javascript]' }], ast, true);
43
- }
44
- exports.generateXXHA = generateXXHA;
45
- var ASCII = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
46
- var ACCENTED_ASCII = 'âḃćḋèḟĝḫíĵǩĺṁńŏṗɋŕśṭůṿẘẋẏẓḀḂḈḊḔḞḠḢḬĴḴĻḾŊÕṔɊŔṠṮŨṼẄẌŸƵ';
47
- function generateENXA(msg) {
48
- var ast = typeof msg === 'string' ? (0, icu_messageformat_parser_1.parse)(msg) : msg;
49
- ast.forEach(function (el) {
50
- if ((0, icu_messageformat_parser_1.isLiteralElement)(el)) {
51
- el.value = el.value
52
- .split('')
53
- .map(function (c) {
54
- var i = ASCII.indexOf(c);
55
- if (i < 0) {
56
- return c;
57
- }
58
- return ACCENTED_ASCII[i];
59
- })
60
- .join('');
61
- }
62
- else if ((0, icu_messageformat_parser_1.isPluralElement)(el) || (0, icu_messageformat_parser_1.isSelectElement)(el)) {
63
- for (var _i = 0, _a = Object.values(el.options); _i < _a.length; _i++) {
64
- var opt = _a[_i];
65
- generateENXA(opt.value);
66
- }
67
- }
68
- else if ((0, icu_messageformat_parser_1.isTagElement)(el)) {
69
- generateENXA(el.children);
70
- }
71
- });
72
- return ast;
73
- }
74
- exports.generateENXA = generateENXA;
75
- function generateENXB(msg) {
76
- var ast = typeof msg === 'string' ? (0, icu_messageformat_parser_1.parse)(msg) : msg;
77
- ast.forEach(function (el) {
78
- if ((0, icu_messageformat_parser_1.isLiteralElement)(el)) {
79
- var pseudoString = el.value
80
- .split('')
81
- .map(function (c, index) {
82
- var i = ASCII.indexOf(c);
83
- var canPad = (index + 1) % 3 === 0;
84
- if (i < 0) {
85
- return c;
86
- }
87
- return canPad ? ACCENTED_ASCII[i].repeat(3) : ACCENTED_ASCII[i];
88
- })
89
- .join('');
90
- el.value = "[!! ".concat(pseudoString, " !!]");
91
- }
92
- else if ((0, icu_messageformat_parser_1.isPluralElement)(el) || (0, icu_messageformat_parser_1.isSelectElement)(el)) {
93
- for (var _i = 0, _a = Object.values(el.options); _i < _a.length; _i++) {
94
- var opt = _a[_i];
95
- generateENXB(opt.value);
96
- }
97
- }
98
- else if ((0, icu_messageformat_parser_1.isTagElement)(el)) {
99
- generateENXB(el.children);
100
- }
101
- });
102
- return ast;
103
- }
104
- exports.generateENXB = generateENXB;
@@ -1,3 +0,0 @@
1
- export declare type ScriptParseFn = (source: string) => void;
2
- export declare function parseFile(source: string, filename: string, parseScriptFn: ScriptParseFn): any;
3
- //# sourceMappingURL=vue_extractor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vue_extractor.d.ts","sourceRoot":"","sources":["../../../../../../packages/cli-lib/src/vue_extractor.ts"],"names":[],"mappings":"AAWA,oBAAY,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;AA4DpD,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,aAAa,GAC3B,GAAG,CAoBL"}
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseFile = void 0;
4
- var compiler_sfc_1 = require("@vue/compiler-sfc");
5
- function walk(node, visitor) {
6
- if (typeof node !== 'object') {
7
- return;
8
- }
9
- if (node.type !== 1 /* ELEMENT */ &&
10
- node.type !== 8 /* COMPOUND_EXPRESSION */ &&
11
- node.type !== 5 /* INTERPOLATION */) {
12
- return;
13
- }
14
- visitor(node);
15
- if (node.type === 5 /* INTERPOLATION */) {
16
- visitor(node.content);
17
- }
18
- else if (node.type === 1 /* ELEMENT */) {
19
- node.children.forEach(function (n) { return walk(n, visitor); });
20
- node.props
21
- .filter(function (prop) { return prop.type === 7 /* DIRECTIVE */; })
22
- .filter(function (prop) { return !!prop.exp; })
23
- .forEach(function (prop) { return visitor(prop.exp); });
24
- }
25
- else {
26
- node.children.forEach(function (n) { return walk(n, visitor); });
27
- }
28
- }
29
- function templateSimpleExpressionNodeVisitor(parseScriptFn) {
30
- return function (n) {
31
- if (typeof n !== 'object') {
32
- return;
33
- }
34
- if (n.type !== 4 /* SIMPLE_EXPRESSION */) {
35
- return;
36
- }
37
- var content = n.content;
38
- // Wrap this in () since a vue comp node attribute can just be
39
- // an object literal which, by itself is invalid TS
40
- // but with () it becomes an ExpressionStatement
41
- parseScriptFn("(".concat(content, ")"));
42
- };
43
- }
44
- function parseFile(source, filename, parseScriptFn) {
45
- var _a = (0, compiler_sfc_1.parse)(source, {
46
- filename: filename,
47
- }), descriptor = _a.descriptor, errors = _a.errors;
48
- if (errors.length) {
49
- throw errors[0];
50
- }
51
- var script = descriptor.script, scriptSetup = descriptor.scriptSetup, template = descriptor.template;
52
- if (template) {
53
- walk(template.ast, templateSimpleExpressionNodeVisitor(parseScriptFn));
54
- }
55
- if (script) {
56
- parseScriptFn(script.content);
57
- }
58
- if (scriptSetup) {
59
- parseScriptFn(scriptSetup.content);
60
- }
61
- }
62
- exports.parseFile = parseFile;