@formatjs/cli-lib 6.3.6 → 6.3.8
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/package.json +5 -5
- package/src/extract.js +10 -2
- package/src/vue_extractor.js +13 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/cli-lib",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.8",
|
|
4
4
|
"description": "Lib for CLI for formatjs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"loud-rejection": "^2.2.0",
|
|
44
44
|
"tslib": "^2.4.0",
|
|
45
45
|
"typescript": "5",
|
|
46
|
-
"@formatjs/
|
|
47
|
-
"@formatjs/
|
|
46
|
+
"@formatjs/ts-transformer": "3.13.12",
|
|
47
|
+
"@formatjs/icu-messageformat-parser": "2.7.6"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@vue/compiler-core": "^3.
|
|
51
|
-
"vue": "^3.
|
|
50
|
+
"@vue/compiler-core": "^3.4.0",
|
|
51
|
+
"vue": "^3.4.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"vue": {
|
package/src/extract.js
CHANGED
|
@@ -23,13 +23,15 @@ function calculateLineColFromOffset(text, start) {
|
|
|
23
23
|
async function processFile(source, fn, { idInterpolationPattern, ...opts }) {
|
|
24
24
|
let messages = [];
|
|
25
25
|
let meta;
|
|
26
|
+
const onMsgExtracted = opts.onMsgExtracted;
|
|
27
|
+
const onMetaExtracted = opts.onMetaExtracted;
|
|
26
28
|
opts = {
|
|
27
29
|
...opts,
|
|
28
30
|
additionalComponentNames: [
|
|
29
31
|
'$formatMessage',
|
|
30
32
|
...(opts.additionalComponentNames || []),
|
|
31
33
|
],
|
|
32
|
-
onMsgExtracted(
|
|
34
|
+
onMsgExtracted(filePath, msgs) {
|
|
33
35
|
if (opts.extractSourceLocation) {
|
|
34
36
|
msgs = msgs.map(msg => ({
|
|
35
37
|
...msg,
|
|
@@ -37,9 +39,15 @@ async function processFile(source, fn, { idInterpolationPattern, ...opts }) {
|
|
|
37
39
|
}));
|
|
38
40
|
}
|
|
39
41
|
messages = messages.concat(msgs);
|
|
42
|
+
if (onMsgExtracted) {
|
|
43
|
+
onMsgExtracted(filePath, msgs);
|
|
44
|
+
}
|
|
40
45
|
},
|
|
41
|
-
onMetaExtracted(
|
|
46
|
+
onMetaExtracted(filePath, m) {
|
|
42
47
|
meta = m;
|
|
48
|
+
if (onMetaExtracted) {
|
|
49
|
+
onMetaExtracted(filePath, m);
|
|
50
|
+
}
|
|
43
51
|
},
|
|
44
52
|
};
|
|
45
53
|
if (!opts.overrideIdFn && idInterpolationPattern) {
|
package/src/vue_extractor.js
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseFile = void 0;
|
|
4
|
+
const compiler_core_1 = require("@vue/compiler-core");
|
|
4
5
|
const compiler_sfc_1 = require("vue/compiler-sfc");
|
|
5
|
-
// Duplicate `NodeTypes` here because they are defined as
|
|
6
|
-
// const enum, which does not work with swc transpilation: https://github.com/vuejs/core/issues/1228
|
|
7
|
-
const ELEMENT = 1;
|
|
8
|
-
const SIMPLE_EXPRESSION = 4;
|
|
9
|
-
const INTERPOLATION = 5;
|
|
10
|
-
const DIRECTIVE = 7;
|
|
11
|
-
const COMPOUND_EXPRESSION = 8;
|
|
12
6
|
function walk(node, visitor) {
|
|
13
|
-
if (typeof node !== 'object') {
|
|
7
|
+
if (typeof node !== 'object' || node == null) {
|
|
14
8
|
return;
|
|
15
9
|
}
|
|
16
|
-
if (node.type
|
|
17
|
-
node.
|
|
18
|
-
|
|
10
|
+
if (node.type === compiler_core_1.NodeTypes.ROOT) {
|
|
11
|
+
node.children.forEach(n => walk(n, visitor));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (node.type !== compiler_core_1.NodeTypes.ELEMENT &&
|
|
15
|
+
node.type !== compiler_core_1.NodeTypes.COMPOUND_EXPRESSION &&
|
|
16
|
+
node.type !== compiler_core_1.NodeTypes.INTERPOLATION) {
|
|
19
17
|
return;
|
|
20
18
|
}
|
|
21
19
|
visitor(node);
|
|
22
|
-
if (node.type === INTERPOLATION) {
|
|
20
|
+
if (node.type === compiler_core_1.NodeTypes.INTERPOLATION) {
|
|
23
21
|
visitor(node.content);
|
|
24
22
|
}
|
|
25
|
-
else if (node.type === ELEMENT) {
|
|
23
|
+
else if (node.type === compiler_core_1.NodeTypes.ELEMENT) {
|
|
26
24
|
node.children.forEach(n => walk(n, visitor));
|
|
27
25
|
node.props
|
|
28
|
-
.filter((prop) => prop.type === DIRECTIVE)
|
|
26
|
+
.filter((prop) => prop.type === compiler_core_1.NodeTypes.DIRECTIVE)
|
|
29
27
|
.filter(prop => !!prop.exp)
|
|
30
28
|
.forEach(prop => visitor(prop.exp));
|
|
31
29
|
}
|
|
@@ -38,7 +36,7 @@ function templateSimpleExpressionNodeVisitor(parseScriptFn) {
|
|
|
38
36
|
if (typeof n !== 'object') {
|
|
39
37
|
return;
|
|
40
38
|
}
|
|
41
|
-
if (n.type !== SIMPLE_EXPRESSION) {
|
|
39
|
+
if (n.type !== compiler_core_1.NodeTypes.SIMPLE_EXPRESSION) {
|
|
42
40
|
return;
|
|
43
41
|
}
|
|
44
42
|
const { content } = n;
|