ztxkutils 2.10.66-15 → 2.10.66-16

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 (79) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/{request-ba8abf99.js → request-588c90ec.js} +92 -18
  3. package/dist/{request-0cc024b1.js → request-dc69f021.js} +68 -13
  4. package/dist/request.js +1 -1
  5. package/package.json +1 -1
  6. package/zti18n-cli/bin/index.js +3 -3
  7. package/zti18n-cli/index.js +23 -23
  8. package/zti18n-cli/src/command/convert.js +17 -17
  9. package/zti18n-cli/src/command/convert2.js +35 -35
  10. package/zti18n-cli/src/command/initFileConf.js +133 -133
  11. package/zti18n-cli/src/command/publish.js +24 -24
  12. package/zti18n-cli/src/conf/BaseConf.js +21 -21
  13. package/zti18n-cli/src/conf/FileConf.js +116 -116
  14. package/zti18n-cli/src/index.js +75 -75
  15. package/zti18n-cli/src/translate/google.js +6 -6
  16. package/zti18n-cli/src/utils/isChinese.js +3 -3
  17. package/zti18n-cli/src/utils/log.js +8 -8
  18. package/zti18n-cli/src/utils/mergeOptions.js +45 -45
  19. package/zti18n-cli/src/utils/reactOptions.js +73 -73
  20. package/zti18n-cli/src/utils/vueOptions.js +69 -69
  21. package/zti18n-core/index.js +1 -1
  22. package/zti18n-core/src/index.js +5 -5
  23. package/zti18n-core/src/plugin/reactIntlToReactIntlUniversal.js +224 -224
  24. package/zti18n-core/src/plugin/reactIntlUniversalToDi18n.js +64 -64
  25. package/zti18n-core/src/transform/defaultPkMap.js +79 -79
  26. package/zti18n-core/src/transform/transformHtml.js +271 -271
  27. package/zti18n-core/src/transform/transformPug.js +272 -272
  28. package/zti18n-core/src/transform/transformReactIntlToReactIntlUniversal.js +96 -96
  29. package/zti18n-core/src/transform/transformReactIntlUniveralToDi18n.js +90 -90
  30. package/zti18n-core/src/transform/transformToDi18n.js +22 -22
  31. package/zti18n-core/src/transform/transformTs.js +41 -41
  32. package/zti18n-core/src/transform/transformVue.js +126 -126
  33. package/zti18n-core/src/translate/google.js +6 -6
  34. package/zti18n-core/src/utils/constants.js +3 -3
  35. package/zti18n-core/src/utils/getIgnoreLines.js +14 -14
  36. package/zti18n-core/src/utils/isChinese.js +3 -3
  37. package/zti18n-core/src/utils/log.js +8 -8
  38. package/dist/authority-e6bde99f.js +0 -423
  39. package/dist/reqUrl-3792afcd.js +0 -82
  40. package/dist/reqUrl-787dd9e5.js +0 -82
  41. package/dist/request-ef290b9a.js +0 -2838
  42. package/dist/tools-09a4d620.js +0 -2445
  43. package/dist/tools-0ca888cd.js +0 -2473
  44. package/dist/validate-6e735536.js +0 -79
  45. package/dist/zti18n-cli/bin/index.d.ts +0 -2
  46. package/dist/zti18n-cli/index.d.ts +0 -1
  47. package/dist/zti18n-cli/src/command/collect.d.ts +0 -2
  48. package/dist/zti18n-cli/src/command/convert.d.ts +0 -2
  49. package/dist/zti18n-cli/src/command/convert2.d.ts +0 -2
  50. package/dist/zti18n-cli/src/command/initFileConf.d.ts +0 -2
  51. package/dist/zti18n-cli/src/command/publish.d.ts +0 -2
  52. package/dist/zti18n-cli/src/conf/BaseConf.d.ts +0 -8
  53. package/dist/zti18n-cli/src/conf/FileConf.d.ts +0 -6
  54. package/dist/zti18n-cli/src/index.d.ts +0 -1
  55. package/dist/zti18n-cli/src/translate/google.d.ts +0 -2
  56. package/dist/zti18n-cli/src/utils/isChinese.d.ts +0 -2
  57. package/dist/zti18n-cli/src/utils/log.d.ts +0 -4
  58. package/dist/zti18n-cli/src/utils/mergeOptions.d.ts +0 -24
  59. package/dist/zti18n-cli/src/utils/reactOptions.d.ts +0 -21
  60. package/dist/zti18n-cli/src/utils/vueOptions.d.ts +0 -17
  61. package/dist/zti18n-core/index.d.ts +0 -2
  62. package/dist/zti18n-core/src/index.d.ts +0 -8
  63. package/dist/zti18n-core/src/plugin/reactIntlToReactIntlUniversal.d.ts +0 -19
  64. package/dist/zti18n-core/src/plugin/reactIntlUniversalToDi18n.d.ts +0 -9
  65. package/dist/zti18n-core/src/transform/defaultPkMap.d.ts +0 -75
  66. package/dist/zti18n-core/src/transform/transformHtml.d.ts +0 -5
  67. package/dist/zti18n-core/src/transform/transformJs.d.ts +0 -5
  68. package/dist/zti18n-core/src/transform/transformPug.d.ts +0 -5
  69. package/dist/zti18n-core/src/transform/transformReactIntlToReactIntlUniversal.d.ts +0 -2
  70. package/dist/zti18n-core/src/transform/transformReactIntlUniveralToDi18n.d.ts +0 -2
  71. package/dist/zti18n-core/src/transform/transformToDi18n.d.ts +0 -5
  72. package/dist/zti18n-core/src/transform/transformTs.d.ts +0 -5
  73. package/dist/zti18n-core/src/transform/transformVue.d.ts +0 -5
  74. package/dist/zti18n-core/src/transform/transformZeroToDi18n.d.ts +0 -2
  75. package/dist/zti18n-core/src/translate/google.d.ts +0 -2
  76. package/dist/zti18n-core/src/utils/constants.d.ts +0 -3
  77. package/dist/zti18n-core/src/utils/getIgnoreLines.d.ts +0 -2
  78. package/dist/zti18n-core/src/utils/isChinese.d.ts +0 -2
  79. package/dist/zti18n-core/src/utils/log.d.ts +0 -4
@@ -1,126 +1,126 @@
1
- const compiler = require('vue-template-compiler');
2
- const transformJs = require('./transformJs');
3
- const transformPug = require('./transformPug');
4
- const transformHtml = require('./transformHtml');
5
-
6
- function openTag(sfcBlock) {
7
- const { type, lang, src, scoped, module, attrs } = sfcBlock;
8
-
9
- let tag = `<${type}`;
10
- if (lang) tag += ` lang="${lang}"`;
11
- if (src) tag += ` src="${src}"`;
12
- if (scoped) tag += ' scoped';
13
- if (module) {
14
- if (typeof module === 'string') tag += ` module="${module}"`;
15
- else tag += ' module';
16
- }
17
- for (let k in attrs) {
18
- if (!['type', 'lang', 'src', 'scoped', 'module'].includes(k)) {
19
- tag += ` ${k}="${attrs[k]}"`;
20
- }
21
- }
22
- tag += '>';
23
-
24
- return tag;
25
- }
26
-
27
- function closeTag(sfcBlock) {
28
- return '</' + sfcBlock.type + '>';
29
- }
30
-
31
- function combineVue(template, script, sytles, customBlocks) {
32
- return [template, script, ...sytles, ...customBlocks]
33
- .map((sfc) =>
34
- sfc ? `${openTag(sfc)}\n${sfc.content.trim()}\n${closeTag(sfc)}\n` : ''
35
- )
36
- .join('\n');
37
- }
38
-
39
- module.exports = function transformVue(source, localeInfo = {}, options = {}) {
40
- const { allTranslated = {}, allUpdated = {}, allUsedKeys = [] } = localeInfo;
41
-
42
- const {
43
- primaryRegx = /[\u4e00-\u9fa5]/,
44
- i18nObject = 'intl',
45
- i18nMethod = '$t',
46
- importCode = "import { intl } from 'di18n-vue';",
47
- babelPresets = [],
48
- babelPlugins = [],
49
- ignoreComponents = [],
50
- ignoreMethods = [],
51
- pkMap = {},
52
- } = options;
53
-
54
- const sfc = compiler.parseComponent(source, {
55
- pad: 'space',
56
- deindent: false,
57
- });
58
-
59
- const { template, script, styles, customBlocks } = sfc;
60
- let hasTouch = false;
61
-
62
- if (template) {
63
- const templateType = (template.lang || 'html').toLowerCase();
64
-
65
- // transform template
66
- if (['html', 'pug'].includes(templateType)) {
67
- const transform = templateType === 'html' ? transformHtml : transformPug;
68
-
69
- const ret = transform(
70
- template.content,
71
- {
72
- allTranslated,
73
- allUpdated,
74
- allUsedKeys,
75
- },
76
- {
77
- primaryRegx,
78
- i18nObject: '',
79
- i18nMethod,
80
- importCode: '',
81
- babelPresets,
82
- babelPlugins,
83
- ignoreComponents,
84
- ignoreMethods,
85
- pkMap,
86
- }
87
- );
88
-
89
- template.content = ret.source;
90
- hasTouch = ret.hasTouch;
91
- } else {
92
- console.warn(
93
- `Unsupport type: ${templateType}, so the template is ignored`
94
- );
95
- }
96
- }
97
-
98
- // transform script
99
- if (script) {
100
- const ret = transformJs(
101
- script.content,
102
- {
103
- allTranslated,
104
- allUpdated,
105
- allUsedKeys,
106
- },
107
- {
108
- primaryRegx,
109
- i18nObject,
110
- i18nMethod,
111
- importCode,
112
- babelPresets,
113
- babelPlugins,
114
- ignoreComponents,
115
- ignoreMethods,
116
- }
117
- );
118
-
119
- script.content = ret.source;
120
- hasTouch = hasTouch || ret.hasTouch;
121
- }
122
-
123
- const code = combineVue(template, script, styles, customBlocks);
124
-
125
- return { source: code, hasTouch };
126
- };
1
+ const compiler = require('vue-template-compiler');
2
+ const transformJs = require('./transformJs');
3
+ const transformPug = require('./transformPug');
4
+ const transformHtml = require('./transformHtml');
5
+
6
+ function openTag(sfcBlock) {
7
+ const { type, lang, src, scoped, module, attrs } = sfcBlock;
8
+
9
+ let tag = `<${type}`;
10
+ if (lang) tag += ` lang="${lang}"`;
11
+ if (src) tag += ` src="${src}"`;
12
+ if (scoped) tag += ' scoped';
13
+ if (module) {
14
+ if (typeof module === 'string') tag += ` module="${module}"`;
15
+ else tag += ' module';
16
+ }
17
+ for (let k in attrs) {
18
+ if (!['type', 'lang', 'src', 'scoped', 'module'].includes(k)) {
19
+ tag += ` ${k}="${attrs[k]}"`;
20
+ }
21
+ }
22
+ tag += '>';
23
+
24
+ return tag;
25
+ }
26
+
27
+ function closeTag(sfcBlock) {
28
+ return '</' + sfcBlock.type + '>';
29
+ }
30
+
31
+ function combineVue(template, script, sytles, customBlocks) {
32
+ return [template, script, ...sytles, ...customBlocks]
33
+ .map((sfc) =>
34
+ sfc ? `${openTag(sfc)}\n${sfc.content.trim()}\n${closeTag(sfc)}\n` : ''
35
+ )
36
+ .join('\n');
37
+ }
38
+
39
+ module.exports = function transformVue(source, localeInfo = {}, options = {}) {
40
+ const { allTranslated = {}, allUpdated = {}, allUsedKeys = [] } = localeInfo;
41
+
42
+ const {
43
+ primaryRegx = /[\u4e00-\u9fa5]/,
44
+ i18nObject = 'intl',
45
+ i18nMethod = '$t',
46
+ importCode = "import { intl } from 'di18n-vue';",
47
+ babelPresets = [],
48
+ babelPlugins = [],
49
+ ignoreComponents = [],
50
+ ignoreMethods = [],
51
+ pkMap = {},
52
+ } = options;
53
+
54
+ const sfc = compiler.parseComponent(source, {
55
+ pad: 'space',
56
+ deindent: false,
57
+ });
58
+
59
+ const { template, script, styles, customBlocks } = sfc;
60
+ let hasTouch = false;
61
+
62
+ if (template) {
63
+ const templateType = (template.lang || 'html').toLowerCase();
64
+
65
+ // transform template
66
+ if (['html', 'pug'].includes(templateType)) {
67
+ const transform = templateType === 'html' ? transformHtml : transformPug;
68
+
69
+ const ret = transform(
70
+ template.content,
71
+ {
72
+ allTranslated,
73
+ allUpdated,
74
+ allUsedKeys,
75
+ },
76
+ {
77
+ primaryRegx,
78
+ i18nObject: '',
79
+ i18nMethod,
80
+ importCode: '',
81
+ babelPresets,
82
+ babelPlugins,
83
+ ignoreComponents,
84
+ ignoreMethods,
85
+ pkMap,
86
+ }
87
+ );
88
+
89
+ template.content = ret.source;
90
+ hasTouch = ret.hasTouch;
91
+ } else {
92
+ console.warn(
93
+ `Unsupport type: ${templateType}, so the template is ignored`
94
+ );
95
+ }
96
+ }
97
+
98
+ // transform script
99
+ if (script) {
100
+ const ret = transformJs(
101
+ script.content,
102
+ {
103
+ allTranslated,
104
+ allUpdated,
105
+ allUsedKeys,
106
+ },
107
+ {
108
+ primaryRegx,
109
+ i18nObject,
110
+ i18nMethod,
111
+ importCode,
112
+ babelPresets,
113
+ babelPlugins,
114
+ ignoreComponents,
115
+ ignoreMethods,
116
+ }
117
+ );
118
+
119
+ script.content = ret.source;
120
+ hasTouch = hasTouch || ret.hasTouch;
121
+ }
122
+
123
+ const code = combineVue(template, script, styles, customBlocks);
124
+
125
+ return { source: code, hasTouch };
126
+ };
@@ -1,6 +1,6 @@
1
- // https://github.com/matheuss/google-translate-api/issues/79#issuecomment-427841889
2
- const googleTranslate = require('@vitalets/google-translate-api');
3
-
4
- module.exports = function translateByGoogle(text, targetLang) {
5
- return googleTranslate(text, { client: 'gtx', to: targetLang });
6
- };
1
+ // https://github.com/matheuss/google-translate-api/issues/79#issuecomment-427841889
2
+ const googleTranslate = require('@vitalets/google-translate-api');
3
+
4
+ module.exports = function translateByGoogle(text, targetLang) {
5
+ return googleTranslate(text, { client: 'gtx', to: targetLang });
6
+ };
@@ -1,3 +1,3 @@
1
- exports.REACT_JS = 'js';
2
- exports.REACT_TS = 'ts';
3
- exports.VUE = 'vue';
1
+ exports.REACT_JS = 'js';
2
+ exports.REACT_TS = 'ts';
3
+ exports.VUE = 'vue';
@@ -1,14 +1,14 @@
1
- module.exports = function getIgnoreLines(tpl) {
2
- // 仅支持 // di18n-disable 和 // di18n-enable 注释指令
3
- const ignores = [];
4
- let ignoring = false;
5
-
6
- const lines = tpl.split(/\n|\r\n/g);
7
- for (let i = 0; i < lines.length; i++) {
8
- if (lines[i].includes('di18n-disable')) ignoring = true;
9
- if (lines[i].includes('di18n-enable')) ignoring = false;
10
- if (ignoring) ignores.push(i + 1);
11
- }
12
-
13
- return ignores;
14
- };
1
+ module.exports = function getIgnoreLines(tpl) {
2
+ // 仅支持 // di18n-disable 和 // di18n-enable 注释指令
3
+ const ignores = [];
4
+ let ignoring = false;
5
+
6
+ const lines = tpl.split(/\n|\r\n/g);
7
+ for (let i = 0; i < lines.length; i++) {
8
+ if (lines[i].includes('di18n-disable')) ignoring = true;
9
+ if (lines[i].includes('di18n-enable')) ignoring = false;
10
+ if (ignoring) ignores.push(i + 1);
11
+ }
12
+
13
+ return ignores;
14
+ };
@@ -1,3 +1,3 @@
1
- module.exports = function isChinese(text) {
2
- return /[\u4e00-\u9fa5]/.test(text);
3
- };
1
+ module.exports = function isChinese(text) {
2
+ return /[\u4e00-\u9fa5]/.test(text);
3
+ };
@@ -1,8 +1,8 @@
1
- const chalk = require('chalk');
2
-
3
- module.exports = {
4
- info: (msg) => console.log(chalk.cyan(msg)),
5
- warning: (msg) => console.log(chalk.yellow(msg)),
6
- success: (msg) => console.log(chalk.green(msg)),
7
- error: (msg) => console.log(chalk.red(msg)),
8
- };
1
+ const chalk = require('chalk');
2
+
3
+ module.exports = {
4
+ info: (msg) => console.log(chalk.cyan(msg)),
5
+ warning: (msg) => console.log(chalk.yellow(msg)),
6
+ success: (msg) => console.log(chalk.green(msg)),
7
+ error: (msg) => console.log(chalk.red(msg)),
8
+ };