@intlayer/chokidar 5.4.2 → 5.5.0-canary.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 (132) hide show
  1. package/dist/cjs/chokidar/watcher.cjs +3 -3
  2. package/dist/cjs/chokidar/watcher.cjs.map +1 -1
  3. package/dist/cjs/cleanOutputDir.cjs +7 -9
  4. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  5. package/dist/cjs/fetchDistantDictionaries.cjs +4 -3
  6. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  7. package/dist/cjs/filterDictionaryLocales.cjs +58 -0
  8. package/dist/cjs/filterDictionaryLocales.cjs.map +1 -0
  9. package/dist/cjs/getBuiltUnmergedDictionariesPath.cjs +51 -0
  10. package/dist/cjs/getBuiltUnmergedDictionariesPath.cjs.map +1 -0
  11. package/dist/cjs/getContentDeclarationFileTemplate/cjsTemplate.md +9 -0
  12. package/dist/cjs/getContentDeclarationFileTemplate/esmTemplate.md +9 -0
  13. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +62 -0
  14. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -0
  15. package/dist/cjs/getContentDeclarationFileTemplate/tsTemplate.md +8 -0
  16. package/dist/cjs/index.cjs +21 -6
  17. package/dist/cjs/index.cjs.map +1 -1
  18. package/dist/cjs/listGitFiles.cjs +98 -0
  19. package/dist/cjs/listGitFiles.cjs.map +1 -0
  20. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +1 -23
  21. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  22. package/dist/cjs/loadDictionaries/loadDistantDictionaries.cjs +7 -1
  23. package/dist/cjs/loadDictionaries/loadDistantDictionaries.cjs.map +1 -1
  24. package/dist/cjs/mergeDictionaries.cjs +43 -23
  25. package/dist/cjs/mergeDictionaries.cjs.map +1 -1
  26. package/dist/cjs/prepareIntlayer.cjs +1 -1
  27. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  28. package/dist/cjs/processPerLocaleDictionary.cjs +49 -0
  29. package/dist/cjs/processPerLocaleDictionary.cjs.map +1 -0
  30. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +50 -0
  31. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -0
  32. package/dist/cjs/reduceDictionaryContent/buildMask.cjs +49 -0
  33. package/dist/cjs/reduceDictionaryContent/buildMask.cjs.map +1 -0
  34. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +35 -0
  35. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -0
  36. package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.cjs +4 -4
  37. package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.cjs.map +1 -1
  38. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs +56 -8
  39. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs.map +1 -1
  40. package/dist/cjs/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.cjs +4 -4
  41. package/dist/cjs/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.cjs.map +1 -1
  42. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs +21 -1
  43. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +1 -1
  44. package/dist/cjs/writeContentDeclaration/formatCode.cjs +61 -0
  45. package/dist/cjs/writeContentDeclaration/formatCode.cjs.map +1 -0
  46. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +36 -37
  47. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  48. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +377 -0
  49. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -0
  50. package/dist/esm/chokidar/watcher.mjs +5 -5
  51. package/dist/esm/chokidar/watcher.mjs.map +1 -1
  52. package/dist/esm/cleanOutputDir.mjs +7 -9
  53. package/dist/esm/cleanOutputDir.mjs.map +1 -1
  54. package/dist/esm/fetchDistantDictionaries.mjs +5 -4
  55. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  56. package/dist/esm/filterDictionaryLocales.mjs +37 -0
  57. package/dist/esm/filterDictionaryLocales.mjs.map +1 -0
  58. package/dist/esm/getBuiltUnmergedDictionariesPath.mjs +17 -0
  59. package/dist/esm/getBuiltUnmergedDictionariesPath.mjs.map +1 -0
  60. package/dist/esm/getContentDeclarationFileTemplate/cjsTemplate.md +9 -0
  61. package/dist/esm/getContentDeclarationFileTemplate/esmTemplate.md +9 -0
  62. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +37 -0
  63. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -0
  64. package/dist/esm/getContentDeclarationFileTemplate/tsTemplate.md +8 -0
  65. package/dist/esm/index.mjs +21 -9
  66. package/dist/esm/index.mjs.map +1 -1
  67. package/dist/esm/listGitFiles.mjs +64 -0
  68. package/dist/esm/listGitFiles.mjs.map +1 -0
  69. package/dist/esm/loadDictionaries/loadDictionaries.mjs +1 -13
  70. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  71. package/dist/esm/loadDictionaries/loadDistantDictionaries.mjs +7 -1
  72. package/dist/esm/loadDictionaries/loadDistantDictionaries.mjs.map +1 -1
  73. package/dist/esm/mergeDictionaries.mjs +42 -22
  74. package/dist/esm/mergeDictionaries.mjs.map +1 -1
  75. package/dist/esm/prepareIntlayer.mjs +3 -3
  76. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  77. package/dist/esm/processPerLocaleDictionary.mjs +25 -0
  78. package/dist/esm/processPerLocaleDictionary.mjs.map +1 -0
  79. package/dist/esm/reduceDictionaryContent/applyMask.mjs +26 -0
  80. package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -0
  81. package/dist/esm/reduceDictionaryContent/buildMask.mjs +24 -0
  82. package/dist/esm/reduceDictionaryContent/buildMask.mjs.map +1 -0
  83. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +11 -0
  84. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -0
  85. package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs +4 -4
  86. package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs.map +1 -1
  87. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs +54 -8
  88. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs.map +1 -1
  89. package/dist/esm/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.mjs +4 -4
  90. package/dist/esm/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.mjs.map +1 -1
  91. package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs +21 -1
  92. package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +1 -1
  93. package/dist/esm/writeContentDeclaration/formatCode.mjs +37 -0
  94. package/dist/esm/writeContentDeclaration/formatCode.mjs.map +1 -0
  95. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +35 -36
  96. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  97. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +345 -0
  98. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -0
  99. package/dist/types/chokidar/watcher.d.ts.map +1 -1
  100. package/dist/types/cleanOutputDir.d.ts.map +1 -1
  101. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  102. package/dist/types/filterDictionaryLocales.d.ts +4 -0
  103. package/dist/types/filterDictionaryLocales.d.ts.map +1 -0
  104. package/dist/types/getBuiltUnmergedDictionariesPath.d.ts +5 -0
  105. package/dist/types/getBuiltUnmergedDictionariesPath.d.ts.map +1 -0
  106. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +2 -0
  107. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -0
  108. package/dist/types/index.d.ts +12 -7
  109. package/dist/types/index.d.ts.map +1 -1
  110. package/dist/types/listGitFiles.d.ts +9 -0
  111. package/dist/types/listGitFiles.d.ts.map +1 -0
  112. package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
  113. package/dist/types/loadDictionaries/loadDistantDictionaries.d.ts.map +1 -1
  114. package/dist/types/mergeDictionaries.d.ts +2 -4
  115. package/dist/types/mergeDictionaries.d.ts.map +1 -1
  116. package/dist/types/processPerLocaleDictionary.d.ts +32 -0
  117. package/dist/types/processPerLocaleDictionary.d.ts.map +1 -0
  118. package/dist/types/reduceDictionaryContent/applyMask.d.ts +3 -0
  119. package/dist/types/reduceDictionaryContent/applyMask.d.ts.map +1 -0
  120. package/dist/types/reduceDictionaryContent/buildMask.d.ts +5 -0
  121. package/dist/types/reduceDictionaryContent/buildMask.d.ts.map +1 -0
  122. package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts +3 -0
  123. package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts.map +1 -0
  124. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.d.ts +38 -0
  125. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.d.ts.map +1 -1
  126. package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts.map +1 -1
  127. package/dist/types/writeContentDeclaration/formatCode.d.ts +2 -0
  128. package/dist/types/writeContentDeclaration/formatCode.d.ts.map +1 -0
  129. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
  130. package/dist/types/writeContentDeclaration/writeJSFile.d.ts +9 -0
  131. package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -0
  132. package/package.json +21 -13
@@ -0,0 +1,345 @@
1
+ import generator from "@babel/generator";
2
+ import * as babelParser from "@babel/parser";
3
+ import traverse from "@babel/traverse";
4
+ import * as t from "@babel/types";
5
+ import { appLogger, logger } from "@intlayer/config";
6
+ import {
7
+ NodeType
8
+ } from "@intlayer/core";
9
+ import { existsSync } from "fs";
10
+ import { readFile, writeFile } from "fs/promises";
11
+ import { extname } from "path";
12
+ import { getContentDeclarationFileTemplate } from "../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";
13
+ import { formatCode } from "./formatCode.mjs";
14
+ const writeJSFile = async (filePath, dictionary) => {
15
+ const {
16
+ key: dictionaryIdentifierKey,
17
+ content: updatesToApply,
18
+ locale,
19
+ autoFilled
20
+ } = dictionary;
21
+ const isPerLocaleDeclarationFile = typeof locale === "string";
22
+ if (!existsSync(filePath)) {
23
+ const fileExtension = extname(filePath);
24
+ let format = "ts";
25
+ if (fileExtension === ".ts" || fileExtension === ".tsx") {
26
+ format = "ts";
27
+ } else if (fileExtension === ".cjs" || fileExtension === ".cjsx") {
28
+ format = "cjs";
29
+ } else {
30
+ format = "esm";
31
+ }
32
+ appLogger("File does not exist, creating it", {
33
+ isVerbose: true
34
+ });
35
+ const template = await getContentDeclarationFileTemplate(
36
+ dictionaryIdentifierKey,
37
+ format,
38
+ { locale, autoFilled }
39
+ );
40
+ await writeFile(filePath, template, "utf-8");
41
+ }
42
+ let sourceCode;
43
+ try {
44
+ sourceCode = await readFile(filePath, "utf-8");
45
+ } catch (error) {
46
+ const err = error;
47
+ appLogger(`Failed to read file: ${filePath}`, {
48
+ level: "error"
49
+ });
50
+ throw new Error(`Failed to read file ${filePath}: ${err.message}`);
51
+ }
52
+ const ast = babelParser.parse(sourceCode, {
53
+ sourceType: "module",
54
+ plugins: ["typescript", "jsx"],
55
+ tokens: true
56
+ });
57
+ let dictionaryObjectPath = null;
58
+ let dictionaryIdentifier = null;
59
+ traverse(ast, {
60
+ ObjectExpression(path) {
61
+ if (dictionaryObjectPath) return;
62
+ const keyProp = path.node.properties.find((prop) => {
63
+ if (!t.isObjectProperty(prop)) return false;
64
+ if (!t.isIdentifier(prop.key) && !t.isStringLiteral(prop.key))
65
+ return false;
66
+ const keyName = t.isIdentifier(prop.key) ? prop.key.name : prop.key.value;
67
+ if (keyName !== "key" || !t.isStringLiteral(prop.value)) return false;
68
+ const propValue = prop.value.value;
69
+ return propValue === dictionaryIdentifierKey;
70
+ });
71
+ if (keyProp) {
72
+ dictionaryObjectPath = path;
73
+ path.stop();
74
+ }
75
+ }
76
+ });
77
+ if (!dictionaryObjectPath) {
78
+ appLogger(`Looking for variable declarations`, {
79
+ isVerbose: true
80
+ });
81
+ const candidateVars = [];
82
+ traverse(ast, {
83
+ VariableDeclarator(path) {
84
+ const { node } = path;
85
+ if (!t.isIdentifier(node.id)) return;
86
+ let objPath = null;
87
+ if (node.init && t.isObjectExpression(node.init)) {
88
+ objPath = path.get("init");
89
+ } else if (node.init && (t.isTSAsExpression(node.init) || t.isTSTypeAssertion(node.init)) && t.isObjectExpression(node.init.expression)) {
90
+ objPath = path.get("init.expression");
91
+ }
92
+ if (objPath) {
93
+ candidateVars.push({ id: node.id.name, path: objPath });
94
+ }
95
+ }
96
+ });
97
+ appLogger(`Found ${candidateVars.length} candidate variables`, {
98
+ isVerbose: true
99
+ });
100
+ for (const { id, path } of candidateVars) {
101
+ const keyProp = path.node.properties.find((prop) => {
102
+ if (!t.isObjectProperty(prop)) return false;
103
+ if (!t.isIdentifier(prop.key) && !t.isStringLiteral(prop.key))
104
+ return false;
105
+ const keyName = t.isIdentifier(prop.key) ? prop.key.name : prop.key.value;
106
+ return keyName === "key" && t.isStringLiteral(prop.value) && prop.value.value === dictionaryIdentifierKey;
107
+ });
108
+ if (keyProp) {
109
+ appLogger(`Found match in variable: ${id}`);
110
+ dictionaryObjectPath = path;
111
+ dictionaryIdentifier = id;
112
+ break;
113
+ }
114
+ }
115
+ if (!dictionaryObjectPath) {
116
+ appLogger("Could not find dictionary object. Dumping all objects:", {
117
+ isVerbose: true
118
+ });
119
+ traverse(ast, {
120
+ ObjectExpression(path) {
121
+ const props = path.node.properties.map((prop) => {
122
+ if (!t.isObjectProperty(prop)) return "non-object-property";
123
+ if (!t.isIdentifier(prop.key) && !t.isStringLiteral(prop.key))
124
+ return "complex-key";
125
+ const keyName = t.isIdentifier(prop.key) ? prop.key.name : prop.key.value;
126
+ let valueDesc = "unknown-value";
127
+ if (t.isStringLiteral(prop.value)) {
128
+ valueDesc = `"${prop.value.value}"`;
129
+ }
130
+ return `${keyName}: ${valueDesc}`;
131
+ }).join(", ");
132
+ appLogger(`Object: { ${props} }`);
133
+ }
134
+ });
135
+ }
136
+ }
137
+ if (!dictionaryObjectPath) {
138
+ throw new Error(
139
+ `Could not find dictionary object with key '${dictionaryIdentifierKey}' in ${filePath}`
140
+ );
141
+ }
142
+ const contentPropertyPath = dictionaryObjectPath.get("properties").find((propPath) => {
143
+ if (!propPath.isObjectProperty()) return false;
144
+ const propNode = propPath.node;
145
+ const keyName = t.isIdentifier(propNode.key) ? propNode.key.name : t.isStringLiteral(propNode.key) ? propNode.key.value : null;
146
+ return keyName === "content";
147
+ });
148
+ if (!contentPropertyPath || !contentPropertyPath.isObjectProperty() || !contentPropertyPath.get("value").isObjectExpression()) {
149
+ throw new Error(
150
+ `Could not find 'content' object property, or it's not an object, in dictionary in ${filePath}`
151
+ );
152
+ }
153
+ const contentObjectPath = contentPropertyPath.get(
154
+ "value"
155
+ );
156
+ for (const [entryKeyToUpdate, newEntryData] of Object.entries(
157
+ updatesToApply
158
+ )) {
159
+ const targetPropertyPath = contentObjectPath.get("properties").find((propPath) => {
160
+ if (!propPath.isObjectProperty()) return false;
161
+ const propNode = propPath.node;
162
+ const keyName = t.isIdentifier(propNode.key) ? propNode.key.name : t.isStringLiteral(propNode.key) ? propNode.key.value : null;
163
+ return keyName === entryKeyToUpdate;
164
+ });
165
+ if (!targetPropertyPath || !targetPropertyPath.isObjectProperty()) {
166
+ appLogger(
167
+ `Key '${entryKeyToUpdate}' not found in content object of ${filePath}. Adding the missing key.`,
168
+ {
169
+ level: "info",
170
+ isVerbose: true
171
+ }
172
+ );
173
+ let valueNode;
174
+ if (newEntryData?.nodeType === NodeType.Translation) {
175
+ const translationContent = newEntryData;
176
+ if (isPerLocaleDeclarationFile && typeof locale === "string" && translationContent?.[NodeType.Translation]?.[locale]) {
177
+ valueNode = t.stringLiteral(
178
+ String(translationContent[NodeType.Translation][locale])
179
+ );
180
+ } else {
181
+ const translationsObj = t.objectExpression(
182
+ Object.entries(translationContent?.[NodeType.Translation]).map(
183
+ ([langKey, langValue]) => {
184
+ const keyNode2 = t.isValidIdentifier(langKey) ? t.identifier(langKey) : t.stringLiteral(langKey);
185
+ return t.objectProperty(
186
+ keyNode2,
187
+ t.stringLiteral(String(langValue))
188
+ );
189
+ }
190
+ )
191
+ );
192
+ valueNode = t.callExpression(t.identifier("t"), [translationsObj]);
193
+ }
194
+ } else if (typeof newEntryData === "string") {
195
+ valueNode = t.stringLiteral(newEntryData);
196
+ } else {
197
+ appLogger(
198
+ `Unsupported data type for new key '${entryKeyToUpdate}'. Using empty string.`,
199
+ { level: "warn", isVerbose: true }
200
+ );
201
+ valueNode = t.stringLiteral("");
202
+ }
203
+ const keyNode = t.isValidIdentifier(entryKeyToUpdate) ? t.identifier(entryKeyToUpdate) : t.stringLiteral(entryKeyToUpdate);
204
+ const newProperty = t.objectProperty(keyNode, valueNode);
205
+ contentObjectPath.node.properties.push(newProperty);
206
+ continue;
207
+ }
208
+ const callExpressionPath = targetPropertyPath.get("value");
209
+ if (callExpressionPath.isCallExpression()) {
210
+ const calleeNode = callExpressionPath.node.callee;
211
+ const calleeName = t.isIdentifier(calleeNode) ? calleeNode.name : null;
212
+ if (newEntryData?.nodeType === "translation" && calleeName === "t") {
213
+ const args = callExpressionPath.node.arguments;
214
+ if (args.length === 0 || !t.isObjectExpression(args[0])) {
215
+ appLogger(
216
+ `'t' call for '${entryKeyToUpdate}' in ${filePath} does not have an object literal as its first argument. Skipping.`,
217
+ {
218
+ level: "warn",
219
+ isVerbose: true
220
+ }
221
+ );
222
+ continue;
223
+ }
224
+ if (isPerLocaleDeclarationFile && typeof locale === "string") {
225
+ const translations = newEntryData?.[NodeType.Translation];
226
+ if (translations[locale]) {
227
+ targetPropertyPath.get("value").replaceWith(t.stringLiteral(String(translations[locale])));
228
+ } else {
229
+ appLogger(
230
+ `Missing translation for locale '${locale}' in '${entryKeyToUpdate}'. Using first available translation.`,
231
+ { level: "warn", isVerbose: true }
232
+ );
233
+ const firstValue = Object.values(translations)[0];
234
+ if (firstValue) {
235
+ targetPropertyPath.get("value").replaceWith(t.stringLiteral(String(firstValue)));
236
+ }
237
+ }
238
+ continue;
239
+ }
240
+ const translationsObjectAstNode = args[0];
241
+ const processedLangKeysInJsonUpdate = /* @__PURE__ */ new Set();
242
+ translationsObjectAstNode.properties.forEach((prop) => {
243
+ if (t.isObjectProperty(prop)) {
244
+ const langKeyNode = prop.key;
245
+ const astLangKeyName = t.isIdentifier(langKeyNode) ? langKeyNode.name : t.isStringLiteral(langKeyNode) ? langKeyNode.value : null;
246
+ if (astLangKeyName && newEntryData?.[NodeType.Translation].hasOwnProperty(astLangKeyName)) {
247
+ prop.value = t.stringLiteral(
248
+ String(
249
+ newEntryData?.[NodeType.Translation]?.[astLangKeyName]
250
+ )
251
+ );
252
+ processedLangKeysInJsonUpdate.add(astLangKeyName);
253
+ }
254
+ }
255
+ });
256
+ for (const [jsonLangKey, jsonLangValue] of Object.entries(
257
+ newEntryData?.[NodeType.Translation]
258
+ )) {
259
+ if (!processedLangKeysInJsonUpdate.has(jsonLangKey)) {
260
+ const newKeyNode = t.isValidIdentifier(jsonLangKey) ? t.identifier(jsonLangKey) : t.stringLiteral(jsonLangKey);
261
+ translationsObjectAstNode.properties.push(
262
+ t.objectProperty(
263
+ newKeyNode,
264
+ t.stringLiteral(String(jsonLangValue))
265
+ )
266
+ );
267
+ }
268
+ }
269
+ } else {
270
+ appLogger(
271
+ `Unhandled callee '${calleeName || "unknown"}' for key '${entryKeyToUpdate}' in ${filePath}.`,
272
+ { level: "warn", isVerbose: true }
273
+ );
274
+ }
275
+ } else if (callExpressionPath.isStringLiteral()) {
276
+ if (typeof newEntryData === "string") {
277
+ targetPropertyPath.get("value").replaceWith(t.stringLiteral(newEntryData));
278
+ } else if (newEntryData?.[NodeType.Translation]) {
279
+ const translations = newEntryData[NodeType.Translation];
280
+ const firstValue = Object.values(translations)[0];
281
+ if (firstValue) {
282
+ targetPropertyPath.get("value").replaceWith(t.stringLiteral(String(firstValue)));
283
+ }
284
+ } else {
285
+ appLogger(
286
+ `Unhandled data structure for string replacement at '${entryKeyToUpdate}' in ${filePath}.`,
287
+ { level: "warn", isVerbose: true }
288
+ );
289
+ }
290
+ } else {
291
+ const valueType = callExpressionPath.node.type;
292
+ appLogger(
293
+ `Updating value of type ${valueType} for '${entryKeyToUpdate}' in ${filePath}`,
294
+ { level: "info", isVerbose: true }
295
+ );
296
+ if (typeof newEntryData === "string") {
297
+ targetPropertyPath.get("value").replaceWith(t.stringLiteral(newEntryData));
298
+ } else if (newEntryData?.[NodeType.Translation]) {
299
+ const translations = newEntryData[NodeType.Translation];
300
+ const localeMatch = filePath.match(/\.([a-z]{2})\.content\.(ts|js)$/i);
301
+ const locale2 = localeMatch ? localeMatch[1] : Object.keys(translations)[0];
302
+ if (translations[locale2]) {
303
+ targetPropertyPath.get("value").replaceWith(t.stringLiteral(String(translations[locale2])));
304
+ } else {
305
+ const firstValue = Object.values(translations)[0];
306
+ if (firstValue) {
307
+ targetPropertyPath.get("value").replaceWith(t.stringLiteral(String(firstValue)));
308
+ }
309
+ }
310
+ } else {
311
+ appLogger(
312
+ `Cannot update value of type ${valueType} for '${entryKeyToUpdate}' in ${filePath}. Unsupported data structure.`,
313
+ { level: "warn", isVerbose: true }
314
+ );
315
+ }
316
+ }
317
+ }
318
+ const generatedCode = generator(ast, {
319
+ retainLines: true,
320
+ comments: true,
321
+ jsescOption: {
322
+ minimal: true
323
+ // This ensures Unicode characters are not escaped
324
+ }
325
+ }).code;
326
+ let finalCode = generatedCode;
327
+ finalCode = await formatCode(filePath, finalCode);
328
+ try {
329
+ await writeFile(filePath, finalCode, "utf-8");
330
+ logger(`Successfully updated ${filePath}`, {
331
+ level: "info",
332
+ isVerbose: true
333
+ });
334
+ } catch (error) {
335
+ const err = error;
336
+ logger(`Failed to write updated file: ${filePath}`, {
337
+ level: "error"
338
+ });
339
+ throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);
340
+ }
341
+ };
342
+ export {
343
+ writeJSFile
344
+ };
345
+ //# sourceMappingURL=writeJSFile.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import generator from '@babel/generator';\nimport * as babelParser from '@babel/parser';\nimport traverse, { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { appLogger, logger } from '@intlayer/config';\nimport {\n Dictionary,\n NodeType,\n TranslationContent,\n TypedNode,\n} from '@intlayer/core';\nimport { existsSync } from 'fs';\nimport { readFile, writeFile } from 'fs/promises';\nimport { extname } from 'path';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport { formatCode } from './formatCode';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary\n): Promise<void> => {\n const {\n key: dictionaryIdentifierKey,\n content: updatesToApply,\n locale,\n autoFilled,\n } = dictionary;\n const isPerLocaleDeclarationFile = typeof locale === 'string';\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath);\n\n let format = 'ts' as 'ts' | 'cjs' | 'esm';\n\n if (fileExtension === '.ts' || fileExtension === '.tsx') {\n format = 'ts';\n } else if (fileExtension === '.cjs' || fileExtension === '.cjsx') {\n format = 'cjs';\n } else {\n format = 'esm';\n }\n\n appLogger('File does not exist, creating it', {\n isVerbose: true,\n });\n const template = await getContentDeclarationFileTemplate(\n dictionaryIdentifierKey,\n format,\n { locale, autoFilled }\n );\n\n await writeFile(filePath, template, 'utf-8');\n }\n\n let sourceCode: string;\n try {\n sourceCode = await readFile(filePath, 'utf-8');\n } catch (error) {\n const err = error as Error;\n appLogger(`Failed to read file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to read file ${filePath}: ${err.message}`);\n }\n\n const ast = babelParser.parse(sourceCode, {\n sourceType: 'module',\n plugins: ['typescript', 'jsx'],\n tokens: true,\n });\n\n let dictionaryObjectPath: NodePath<t.ObjectExpression> | null = null;\n let dictionaryIdentifier: string | null = null;\n\n // First look for direct objects with the right key, regardless of variable assignments\n traverse(ast, {\n ObjectExpression(path) {\n if (dictionaryObjectPath) return; // Already found\n\n // Check if this object has a key property with the right value\n const keyProp = path.node.properties.find((prop) => {\n if (!t.isObjectProperty(prop)) return false;\n if (!t.isIdentifier(prop.key) && !t.isStringLiteral(prop.key))\n return false;\n\n const keyName = t.isIdentifier(prop.key)\n ? prop.key.name\n : prop.key.value;\n\n if (keyName !== 'key' || !t.isStringLiteral(prop.value)) return false;\n\n // Unescape the value for comparison\n const propValue = prop.value.value;\n // Compare actual string content, not just raw representation\n return propValue === dictionaryIdentifierKey;\n });\n\n if (keyProp) {\n dictionaryObjectPath = path;\n path.stop();\n }\n },\n });\n\n // If not found directly, look for variable declarations and exports\n if (!dictionaryObjectPath) {\n appLogger(`Looking for variable declarations`, {\n isVerbose: true,\n });\n\n // Collect all variable declarations with objects\n const candidateVars: { id: string; path: NodePath<t.ObjectExpression> }[] =\n [];\n\n traverse(ast, {\n VariableDeclarator(path) {\n const { node } = path;\n if (!t.isIdentifier(node.id)) return;\n\n let objPath: NodePath<t.ObjectExpression> | null = null;\n\n // Direct object assignment\n if (node.init && t.isObjectExpression(node.init)) {\n objPath = path.get('init') as NodePath<t.ObjectExpression>;\n }\n // Object with TS type assertion (satisfies/as)\n else if (\n node.init &&\n (t.isTSAsExpression(node.init) || t.isTSTypeAssertion(node.init)) &&\n t.isObjectExpression(node.init.expression)\n ) {\n objPath = path.get('init.expression') as NodePath<t.ObjectExpression>;\n }\n\n if (objPath) {\n candidateVars.push({ id: node.id.name, path: objPath });\n }\n },\n });\n\n appLogger(`Found ${candidateVars.length} candidate variables`, {\n isVerbose: true,\n });\n\n // Check each candidate for the key property\n for (const { id, path } of candidateVars) {\n const keyProp = path.node.properties.find((prop) => {\n if (!t.isObjectProperty(prop)) return false;\n if (!t.isIdentifier(prop.key) && !t.isStringLiteral(prop.key))\n return false;\n\n const keyName = t.isIdentifier(prop.key)\n ? prop.key.name\n : prop.key.value;\n return (\n keyName === 'key' &&\n t.isStringLiteral(prop.value) &&\n prop.value.value === dictionaryIdentifierKey\n );\n });\n\n if (keyProp) {\n appLogger(`Found match in variable: ${id}`);\n dictionaryObjectPath = path;\n dictionaryIdentifier = id;\n break;\n }\n }\n\n // If still not found, dump all object expressions for debugging\n if (!dictionaryObjectPath) {\n appLogger('Could not find dictionary object. Dumping all objects:', {\n isVerbose: true,\n });\n traverse(ast, {\n ObjectExpression(path) {\n const props = path.node.properties\n .map((prop) => {\n if (!t.isObjectProperty(prop)) return 'non-object-property';\n if (!t.isIdentifier(prop.key) && !t.isStringLiteral(prop.key))\n return 'complex-key';\n\n const keyName = t.isIdentifier(prop.key)\n ? prop.key.name\n : prop.key.value;\n let valueDesc = 'unknown-value';\n\n if (t.isStringLiteral(prop.value)) {\n valueDesc = `\"${prop.value.value}\"`;\n }\n\n return `${keyName}: ${valueDesc}`;\n })\n .join(', ');\n\n appLogger(`Object: { ${props} }`);\n },\n });\n }\n }\n\n if (!dictionaryObjectPath) {\n throw new Error(\n `Could not find dictionary object with key '${dictionaryIdentifierKey}' in ${filePath}`\n );\n }\n\n // Find the 'content' property within the identified dictionary object\n const contentPropertyPath = (\n (dictionaryObjectPath as any).get('properties') as NodePath<\n t.ObjectProperty | t.SpreadElement | t.ObjectMethod\n >[]\n ).find((propPath) => {\n if (!propPath.isObjectProperty()) return false;\n const propNode = propPath.node;\n const keyName = t.isIdentifier(propNode.key)\n ? propNode.key.name\n : t.isStringLiteral(propNode.key)\n ? propNode.key.value\n : null;\n return keyName === 'content';\n });\n\n if (\n !contentPropertyPath ||\n !contentPropertyPath.isObjectProperty() ||\n !(contentPropertyPath.get('value') as NodePath).isObjectExpression()\n ) {\n throw new Error(\n `Could not find 'content' object property, or it's not an object, in dictionary in ${filePath}`\n );\n }\n\n const contentObjectPath = contentPropertyPath.get(\n 'value'\n ) as NodePath<t.ObjectExpression>;\n\n // Apply updates to each entry specified in the JSON\n for (const [entryKeyToUpdate, newEntryData] of Object.entries(\n updatesToApply\n )) {\n const targetPropertyPath = (\n contentObjectPath.get('properties') as NodePath<\n t.ObjectProperty | t.SpreadElement | t.ObjectMethod\n >[]\n ).find((propPath) => {\n if (!propPath.isObjectProperty()) return false;\n const propNode = propPath.node;\n const keyName = t.isIdentifier(propNode.key)\n ? propNode.key.name\n : t.isStringLiteral(propNode.key)\n ? propNode.key.value\n : null;\n return keyName === entryKeyToUpdate;\n });\n\n if (!targetPropertyPath || !targetPropertyPath.isObjectProperty()) {\n appLogger(\n `Key '${entryKeyToUpdate}' not found in content object of ${filePath}. Adding the missing key.`,\n {\n level: 'info',\n isVerbose: true,\n }\n );\n\n // Create a new property for the missing key\n let valueNode: t.Expression;\n\n if ((newEntryData as TypedNode)?.nodeType === NodeType.Translation) {\n // Create a new t() call with the translations\n const translationContent = newEntryData as TranslationContent;\n\n if (\n isPerLocaleDeclarationFile &&\n typeof locale === 'string' &&\n translationContent?.[NodeType.Translation]?.[locale]\n ) {\n // For per-locale files, use the string value directly\n valueNode = t.stringLiteral(\n String(translationContent[NodeType.Translation][locale])\n );\n } else {\n // Otherwise create a t() call with translations object\n const translationsObj = t.objectExpression(\n Object.entries(translationContent?.[NodeType.Translation]).map(\n ([langKey, langValue]) => {\n const keyNode = t.isValidIdentifier(langKey)\n ? t.identifier(langKey)\n : t.stringLiteral(langKey);\n return t.objectProperty(\n keyNode,\n t.stringLiteral(String(langValue))\n );\n }\n )\n );\n valueNode = t.callExpression(t.identifier('t'), [translationsObj]);\n }\n } else if (typeof newEntryData === 'string') {\n // Create a string literal for string values\n valueNode = t.stringLiteral(newEntryData);\n } else {\n // Fallback to empty string if we don't know how to handle this type\n appLogger(\n `Unsupported data type for new key '${entryKeyToUpdate}'. Using empty string.`,\n { level: 'warn', isVerbose: true }\n );\n valueNode = t.stringLiteral('');\n }\n\n // Add the new property to the content object\n const keyNode = t.isValidIdentifier(entryKeyToUpdate)\n ? t.identifier(entryKeyToUpdate)\n : t.stringLiteral(entryKeyToUpdate);\n const newProperty = t.objectProperty(keyNode, valueNode);\n contentObjectPath.node.properties.push(newProperty);\n\n continue;\n }\n\n const callExpressionPath = targetPropertyPath.get('value') as NodePath; // Path to the value, e.g., t(...)\n\n // Handle different types of values\n if (callExpressionPath.isCallExpression()) {\n const calleeNode = (callExpressionPath.node as t.CallExpression).callee;\n const calleeName = t.isIdentifier(calleeNode) ? calleeNode.name : null;\n\n // Handle 't' function calls\n if (\n (newEntryData as TypedNode)?.nodeType === 'translation' &&\n calleeName === 't'\n ) {\n const args = (callExpressionPath.node as t.CallExpression).arguments;\n if (args.length === 0 || !t.isObjectExpression(args[0])) {\n appLogger(\n `'t' call for '${entryKeyToUpdate}' in ${filePath} does not have an object literal as its first argument. Skipping.`,\n {\n level: 'warn',\n isVerbose: true,\n }\n );\n continue;\n }\n\n if (isPerLocaleDeclarationFile && typeof locale === 'string') {\n // For per-locale files, replace t() call with direct string\n const translations = (newEntryData as TranslationContent)?.[\n NodeType.Translation\n ];\n\n if (translations[locale]) {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(String(translations[locale])));\n } else {\n appLogger(\n `Missing translation for locale '${locale}' in '${entryKeyToUpdate}'. Using first available translation.`,\n { level: 'warn', isVerbose: true }\n );\n const firstValue = Object.values(translations)[0];\n if (firstValue) {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(String(firstValue)));\n }\n }\n continue;\n }\n\n const translationsObjectAstNode = args[0] as t.ObjectExpression;\n const processedLangKeysInJsonUpdate = new Set<string>();\n\n // Update existing language properties in the AST node\n translationsObjectAstNode.properties.forEach((prop: any) => {\n if (t.isObjectProperty(prop)) {\n const langKeyNode = prop.key;\n const astLangKeyName = t.isIdentifier(langKeyNode)\n ? langKeyNode.name\n : t.isStringLiteral(langKeyNode)\n ? langKeyNode.value\n : null;\n\n if (\n astLangKeyName &&\n (newEntryData as TranslationContent)?.[\n NodeType.Translation\n ].hasOwnProperty(astLangKeyName)\n ) {\n prop.value = t.stringLiteral(\n String(\n (newEntryData as TranslationContent)?.[\n NodeType.Translation\n ]?.[astLangKeyName]\n )\n );\n processedLangKeysInJsonUpdate.add(astLangKeyName);\n }\n }\n });\n\n // Add new language properties from the JSON update that were not originally in the AST node\n for (const [jsonLangKey, jsonLangValue] of Object.entries(\n (newEntryData as TranslationContent)?.[NodeType.Translation]\n )) {\n if (!processedLangKeysInJsonUpdate.has(jsonLangKey)) {\n const newKeyNode = t.isValidIdentifier(jsonLangKey)\n ? t.identifier(jsonLangKey)\n : t.stringLiteral(jsonLangKey);\n translationsObjectAstNode.properties.push(\n t.objectProperty(\n newKeyNode,\n t.stringLiteral(String(jsonLangValue))\n )\n );\n }\n }\n }\n // Handle other function calls in the future\n else {\n appLogger(\n `Unhandled callee '${calleeName || 'unknown'}' for key '${entryKeyToUpdate}' in ${filePath}.`,\n { level: 'warn', isVerbose: true }\n );\n }\n }\n // Handle direct string literals\n else if (callExpressionPath.isStringLiteral()) {\n // For string literals, directly replace with the new value\n if (typeof newEntryData === 'string') {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(newEntryData));\n } else if ((newEntryData as any)?.[NodeType.Translation]) {\n // Handle translation content (use first available translation)\n const translations = (newEntryData as TranslationContent)[\n NodeType.Translation\n ];\n const firstValue = Object.values(translations)[0];\n if (firstValue) {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(String(firstValue)));\n }\n } else {\n appLogger(\n `Unhandled data structure for string replacement at '${entryKeyToUpdate}' in ${filePath}.`,\n { level: 'warn', isVerbose: true }\n );\n }\n }\n // Handle other value types (objects, arrays, etc.)\n else {\n const valueType = callExpressionPath.node.type;\n appLogger(\n `Updating value of type ${valueType} for '${entryKeyToUpdate}' in ${filePath}`,\n { level: 'info', isVerbose: true }\n );\n\n // For simple values like strings, use direct replacement\n if (typeof newEntryData === 'string') {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(newEntryData));\n }\n // For translation content, use a smart approach\n else if ((newEntryData as any)?.[NodeType.Translation]) {\n // Extract just the value relevant to this file's locale\n const translations = (newEntryData as TranslationContent)[\n NodeType.Translation\n ];\n\n // Try to determine locale from file path (assuming a pattern like .fr.content.ts)\n const localeMatch = filePath.match(/\\.([a-z]{2})\\.content\\.(ts|js)$/i);\n const locale = localeMatch\n ? localeMatch[1]\n : Object.keys(translations)[0];\n\n if (translations[locale]) {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(String(translations[locale])));\n } else {\n // Fallback to first translation\n const firstValue = Object.values(translations)[0];\n if (firstValue) {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(String(firstValue)));\n }\n }\n } else {\n appLogger(\n `Cannot update value of type ${valueType} for '${entryKeyToUpdate}' in ${filePath}. Unsupported data structure.`,\n { level: 'warn', isVerbose: true }\n );\n }\n }\n }\n\n // Generate JavaScript/TypeScript code from the modified AST\n const generatedCode = generator(ast, {\n retainLines: true,\n comments: true,\n jsescOption: {\n minimal: true, // This ensures Unicode characters are not escaped\n },\n }).code;\n\n let finalCode = generatedCode;\n\n finalCode = await formatCode(filePath, finalCode);\n\n // Write the modified code back to the file\n try {\n await writeFile(filePath, finalCode, 'utf-8');\n logger(`Successfully updated ${filePath}`, {\n level: 'info',\n isVerbose: true,\n });\n } catch (error) {\n const err = error as Error;\n logger(`Failed to write updated file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);\n }\n};\n"],"mappings":"AAAA,OAAO,eAAe;AACtB,YAAY,iBAAiB;AAC7B,OAAO,cAA4B;AACnC,YAAY,OAAO;AACnB,SAAS,WAAW,cAAc;AAClC;AAAA,EAEE;AAAA,OAGK;AACP,SAAS,kBAAkB;AAC3B,SAAS,UAAU,iBAAiB;AACpC,SAAS,eAAe;AACxB,SAAS,yCAAyC;AAClD,SAAS,kBAAkB;AAQpB,MAAM,cAAc,OACzB,UACA,eACkB;AAClB,QAAM;AAAA,IACJ,KAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,6BAA6B,OAAO,WAAW;AAGrD,MAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,UAAM,gBAAgB,QAAQ,QAAQ;AAEtC,QAAI,SAAS;AAEb,QAAI,kBAAkB,SAAS,kBAAkB,QAAQ;AACvD,eAAS;AAAA,IACX,WAAW,kBAAkB,UAAU,kBAAkB,SAAS;AAChE,eAAS;AAAA,IACX,OAAO;AACL,eAAS;AAAA,IACX;AAEA,cAAU,oCAAoC;AAAA,MAC5C,WAAW;AAAA,IACb,CAAC;AACD,UAAM,WAAW,MAAM;AAAA,MACrB;AAAA,MACA;AAAA,MACA,EAAE,QAAQ,WAAW;AAAA,IACvB;AAEA,UAAM,UAAU,UAAU,UAAU,OAAO;AAAA,EAC7C;AAEA,MAAI;AACJ,MAAI;AACF,iBAAa,MAAM,SAAS,UAAU,OAAO;AAAA,EAC/C,SAAS,OAAO;AACd,UAAM,MAAM;AACZ,cAAU,wBAAwB,QAAQ,IAAI;AAAA,MAC5C,OAAO;AAAA,IAC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AAAA,EACH,SAAS,OAAO;AACd,UAAM,MAAM;AACZ,WAAO,iCAAiC,QAAQ,IAAI;AAAA,MAClD,OAAO;AAAA,IACT,CAAC;AACD,UAAM,IAAI,MAAM,gCAAgC,QAAQ,KAAK,IAAI,OAAO,EAAE;AAAA,EAC5E;AACF;","names":["keyNode","locale"]}
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../../src/chokidar/watcher.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,kBAAkB,CAAC;AAC1B,2FAA2F;AAC3F,OAAO,EAAE,KAAK,eAAe,EAA0B,MAAM,UAAU,CAAC;AAcxE,eAAO,MAAM,sCAAsC,GACjD,UAAU,MAAM,EAChB,gBAAgB,cAAc,kBAiC/B,CAAC;AAEF,eAAO,MAAM,mCAAmC,GAC9C,UAAU,MAAM,EAChB,gBAAgB,cAAc,kBAgC/B,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAC7C,UAAU,MAAM,EAChB,gBAAgB,cAAc,kBAmC/B,CAAC;AAEF,KAAK,YAAY,GAAG,eAAe,GAAG;IACpC,aAAa,CAAC,EAAE,cAAc,CAAC;CAChC,CAAC;AAGF,eAAO,MAAM,KAAK,GAAI,UAAU,YAAY,QAkD3C,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAU,UAAU,YAAY,kBASjE,CAAC"}
1
+ {"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../../src/chokidar/watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,kBAAkB,CAAC;AAE1B,2FAA2F;AAC3F,OAAO,EAAE,KAAK,eAAe,EAA0B,MAAM,UAAU,CAAC;AAcxE,eAAO,MAAM,sCAAsC,GACjD,UAAU,MAAM,EAChB,gBAAgB,cAAc,kBAiC/B,CAAC;AAEF,eAAO,MAAM,mCAAmC,GAC9C,UAAU,MAAM,EAChB,gBAAgB,cAAc,kBAgC/B,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAC7C,UAAU,MAAM,EAChB,gBAAgB,cAAc,kBAmC/B,CAAC;AAEF,KAAK,YAAY,GAAG,eAAe,GAAG;IACpC,aAAa,CAAC,EAAE,cAAc,CAAC;CAChC,CAAC;AAGF,eAAO,MAAM,KAAK,GAAI,UAAU,YAAY,QAkD3C,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAU,UAAU,YAAY,kBASjE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cleanOutputDir.d.ts","sourceRoot":"","sources":["../../src/cleanOutputDir.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,GAAI,yDAAkC,SAgBhE,CAAC"}
1
+ {"version":3,"file":"cleanOutputDir.d.ts","sourceRoot":"","sources":["../../src/cleanOutputDir.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,GAAI,yDAAkC,SAchE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionaries.d.ts","sourceRoot":"","sources":["../../src/fetchDistantDictionaries.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKvD,KAAK,+BAA+B,GAAG;IACrC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,+BAA+B,KACvC,OAAO,CAAC,aAAa,EAAE,CA8FzB,CAAC"}
1
+ {"version":3,"file":"fetchDistantDictionaries.d.ts","sourceRoot":"","sources":["../../src/fetchDistantDictionaries.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKvD,KAAK,+BAA+B,GAAG;IACrC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,+BAA+B,KACvC,OAAO,CAAC,aAAa,EAAE,CA+FzB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Locales } from '@intlayer/config/client';
2
+ import { Dictionary } from '@intlayer/core';
3
+ export declare const filterDictionaryLocales: (dictionary: Dictionary, locales: Locales[]) => any;
4
+ //# sourceMappingURL=filterDictionaryLocales.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterDictionaryLocales.d.ts","sourceRoot":"","sources":["../../src/filterDictionaryLocales.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAEL,UAAU,EAGX,MAAM,gBAAgB,CAAC;AA4BxB,eAAO,MAAM,uBAAuB,GAClC,YAAY,UAAU,EACtB,SAAS,OAAO,EAAE,QAOnB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This function generates a list of dictionaries in the main directory
3
+ */
4
+ export declare const getBuiltUnmergedDictionariesPath: (configuration?: import("@intlayer/config").IntlayerConfig) => string[];
5
+ //# sourceMappingURL=getBuiltUnmergedDictionariesPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBuiltUnmergedDictionariesPath.d.ts","sourceRoot":"","sources":["../../src/getBuiltUnmergedDictionariesPath.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,gCAAgC,GAC3C,yDAAkC,aAcnC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const getContentDeclarationFileTemplate: (key: string, format: "ts" | "cjs" | "esm", fileParams?: Record<string, any>) => Promise<string>;
2
+ //# sourceMappingURL=getContentDeclarationFileTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getContentDeclarationFileTemplate.d.ts","sourceRoot":"","sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iCAAiC,GAC5C,KAAK,MAAM,EACX,QAAQ,IAAI,GAAG,KAAK,GAAG,KAAK,EAC5B,aAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,oBAwCrC,CAAC"}
@@ -1,13 +1,18 @@
1
- export { watch, handleAdditionalContentDeclarationFile, handleContentDeclarationFileChange, buildAndWatchIntlayer, } from './chokidar/watcher';
2
- export { prepareIntlayer } from './prepareIntlayer';
3
- export { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';
4
- export { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';
5
- export { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';
1
+ export { checkDictionaryChanges } from './checkDictionaryChanges';
2
+ export { buildAndWatchIntlayer, handleAdditionalContentDeclarationFile, handleContentDeclarationFileChange, watch, } from './chokidar/watcher';
6
3
  export { fetchDistantDictionaries } from './fetchDistantDictionaries';
7
4
  export { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';
8
- export { loadDistantDictionaries, loadDictionaries, loadLocalDictionaries, } from './loadDictionaries/index';
9
- export { checkDictionaryChanges } from './checkDictionaryChanges';
5
+ export { filterDictionaryLocales } from './filterDictionaryLocales';
10
6
  export { listDictionaries } from './listDictionariesPath';
7
+ export { listGitFiles, type DiffMode, type ListGitFilesOptions, } from './listGitFiles';
8
+ export { loadDictionaries, loadDistantDictionaries, loadLocalDictionaries, } from './loadDictionaries/index';
9
+ export { mergeDictionaries } from './mergeDictionaries';
11
10
  export { prepareContentDeclaration } from './prepareContentDeclaration';
11
+ export { prepareIntlayer } from './prepareIntlayer';
12
+ export { processPerLocaleDictionary } from './processPerLocaleDictionary';
13
+ export { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';
14
+ export { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';
15
+ export { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';
16
+ export { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';
12
17
  export { writeContentDeclaration, type DictionaryStatus, } from './writeContentDeclaration';
13
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,sCAAsC,EACtC,kCAAkC,EAClC,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,4DAA4D,CAAC;AACxG,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,GACtB,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,qBAAqB,EACrB,sCAAsC,EACtC,kCAAkC,EAClC,KAAK,GACN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,4DAA4D,CAAC;AACxG,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAC;AACpG,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,GACtB,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,9 @@
1
+ export type DiffMode = 'gitDiff' | 'uncommitted' | 'unpushed' | 'untracked';
2
+ export type ListGitFilesOptions = {
3
+ mode: DiffMode[];
4
+ baseRef?: string;
5
+ currentRef?: string;
6
+ absolute?: boolean;
7
+ };
8
+ export declare const listGitFiles: ({ mode, baseRef, currentRef, absolute, }: ListGitFilesOptions) => Promise<string[]>;
9
+ //# sourceMappingURL=listGitFiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listGitFiles.d.ts","sourceRoot":"","sources":["../../src/listGitFiles.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,WAAW,CAAC;AAe5E,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,YAAY,GAAU,0CAKhC,mBAAmB,sBAuDrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"loadDictionaries.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AASjD,eAAO,MAAM,gBAAgB,GAC3B,0BAA0B,MAAM,EAAE,GAAG,MAAM,EAC3C,yDAAkC,EAClC,+BAA+B,KAC9B,OAAO,CAAC,UAAU,EAAE,CA6EtB,CAAC"}
1
+ {"version":3,"file":"loadDictionaries.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAOjD,eAAO,MAAM,gBAAgB,GAC3B,0BAA0B,MAAM,EAAE,GAAG,MAAM,EAC3C,yDAAkC,EAClC,+BAA+B,KAC9B,OAAO,CAAC,UAAU,EAAE,CAiEtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"loadDistantDictionaries.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadDistantDictionaries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,KAAK,8BAA8B,GAAG;IACpC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,SAAS,8BAA8B,KACtC,OAAO,CAAC,aAAa,EAAE,CASzB,CAAC"}
1
+ {"version":3,"file":"loadDistantDictionaries.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadDistantDictionaries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,KAAK,8BAA8B,GAAG;IACpC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AASF,eAAO,MAAM,uBAAuB,GAClC,SAAS,8BAA8B,KACtC,OAAO,CAAC,aAAa,EAAE,CASzB,CAAC"}
@@ -1,5 +1,3 @@
1
- import { type Options } from 'deepmerge';
2
- export declare const mergeByKey: <T extends {
3
- key: string;
4
- }>(key: keyof T) => (target: T[], source: T[], options?: Options) => T[];
1
+ import type { Dictionary } from '@intlayer/core';
2
+ export declare const mergeDictionaries: (dictionaries: Dictionary[]) => Dictionary;
5
3
  //# sourceMappingURL=mergeDictionaries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeDictionaries.d.ts","sourceRoot":"","sources":["../../src/mergeDictionaries.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAGhD,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,MAAM,CAAC,MACxD,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,UAAU,OAAO,KAAG,CAAC,EA6BxD,CAAC"}
1
+ {"version":3,"file":"mergeDictionaries.d.ts","sourceRoot":"","sources":["../../src/mergeDictionaries.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAgCjD,eAAO,MAAM,iBAAiB,GAAI,cAAc,UAAU,EAAE,KAAG,UA0B9D,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { type Dictionary } from '@intlayer/core';
2
+ /**
3
+ *
4
+ * Should transform per locale dictionaries to multi-locale dictionaries
5
+ *
6
+ * Example:
7
+ *
8
+ * ```json5
9
+ * // .intlayer/dictionaries/home.fr.json
10
+ * { 'key': 'home', 'locale': 'fr', 'content': { 'example': "value", ... } },
11
+ * ```
12
+ *
13
+ * Result:
14
+ *
15
+ * ```json5
16
+ * // .intlayer/dictionaries/home.json
17
+ * {
18
+ * 'key': 'home',
19
+ * 'content': {
20
+ * 'example': {
21
+ * 'nodeType': 'translation',
22
+ * 'translation': {
23
+ * 'fr': 'valeur',
24
+ * }
25
+ * }, ... } },
26
+ * ```
27
+ *
28
+ * @param dictionary
29
+ * @returns
30
+ */
31
+ export declare const processPerLocaleDictionary: (dictionary: Dictionary) => Dictionary;
32
+ //# sourceMappingURL=processPerLocaleDictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processPerLocaleDictionary.d.ts","sourceRoot":"","sources":["../../src/processPerLocaleDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,0BAA0B,GAAI,YAAY,UAAU,eAuBhE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Dictionary } from '@intlayer/core';
2
+ export declare const applyMask: (full: Dictionary, mask: any) => Dictionary;
3
+ //# sourceMappingURL=applyMask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyMask.d.ts","sourceRoot":"","sources":["../../../src/reduceDictionaryContent/applyMask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,SAAS,GAAI,MAAM,UAAU,EAAE,MAAM,GAAG,KAAG,UA8BvD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Dictionary, type Plugins } from '@intlayer/core';
2
+ /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
3
+ export declare const buildMaskPlugin: Plugins;
4
+ export declare const buildMask: (source: Dictionary) => any;
5
+ //# sourceMappingURL=buildMask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildMask.d.ts","sourceRoot":"","sources":["../../../src/reduceDictionaryContent/buildMask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAU7E,wFAAwF;AACxF,eAAO,MAAM,eAAe,EAAE,OAI7B,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,QAAQ,UAAU,KAAG,GAO7C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Dictionary } from '@intlayer/core';
2
+ export declare const reduceDictionaryContent: (fullDictionary: Dictionary, partialDictionary: Dictionary) => Dictionary;
3
+ //# sourceMappingURL=reduceDictionaryContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reduceDictionaryContent.d.ts","sourceRoot":"","sources":["../../../src/reduceDictionaryContent/reduceDictionaryContent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD,eAAO,MAAM,uBAAuB,GAClC,gBAAgB,UAAU,EAC1B,mBAAmB,UAAU,eAM9B,CAAC"}
@@ -1,3 +1,41 @@
1
1
  import type { Dictionary } from '@intlayer/core';
2
+ /**
3
+ * Write the unmerged dictionaries to the unmergedDictionariesDir
4
+ * @param dictionaries - The dictionaries to write
5
+ * @param configuration - The configuration
6
+ * @returns The grouped dictionaries
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
11
+ * console.log(unmergedDictionaries);
12
+ *
13
+ * // .intlayer/unmerged_dictionaries/home.json
14
+ * // {
15
+ * // [
16
+ * // { key: 'home', content: { ... } },
17
+ * // { key: 'home', content: { ... } },
18
+ * // ],
19
+ * // }
20
+ * ```
21
+ */
22
+ export declare const writeUnmergedDictionaries: (dictionaries: Dictionary[], configuration?: import("@intlayer/config").IntlayerConfig) => Promise<Record<string, Dictionary[]>>;
23
+ /**
24
+ * Write the final dictionaries to the dictionariesDir
25
+ * @param groupedDictionaries - The grouped dictionaries
26
+ * @param configuration - The configuration
27
+ * @returns The final dictionaries
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
32
+ * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
33
+ * console.log(finalDictionaries);
34
+ *
35
+ * // .intlayer/dictionaries/home.json
36
+ * // { key: 'home', content: { ... } },
37
+ * ```
38
+ */
39
+ export declare const writeFinalDictionaries: (groupedDictionaries: Record<string, Dictionary[]>, configuration?: import("@intlayer/config").IntlayerConfig) => Promise<string[]>;
2
40
  export declare const writeDictionary: (dictionaries: Dictionary[], configuration?: import("@intlayer/config").IntlayerConfig) => Promise<string[]>;
3
41
  //# sourceMappingURL=writeDictionary.d.ts.map