intlayer-editor 8.12.2 → 8.12.3

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 (158) hide show
  1. package/client/dist/assets/{CodeBlockClient-b-yeqFuz.js → CodeBlockClient-BQMC5gqu.js} +3 -3
  2. package/client/dist/assets/{CodeBlockShiki-CKm7rixD.js → CodeBlockShiki-DB7ndrOR.js} +2 -2
  3. package/client/dist/assets/{MarkDownRender-EQEw6Grf.js → MarkDownRender-BQwPctN-.js} +3 -3
  4. package/client/dist/assets/{bundle-web-DofprJDj.js → bundle-web-C4HpQhJS.js} +1 -1
  5. package/client/dist/assets/{dist-BFhKwA67.js → dist-GH_AdANR.js} +1 -1
  6. package/client/dist/assets/index-DIJj_-IN.css +2 -0
  7. package/client/dist/assets/index-DJVEpj0g.js +189 -0
  8. package/client/dist/assets/purify.es-6-uFcs4-.js +3 -0
  9. package/client/dist/index.html +2 -2
  10. package/package.json +15 -15
  11. package/server/dist/@intlayer/chokidar/dist/types/build.d.ts +1 -0
  12. package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -0
  13. package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +2 -0
  14. package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +2 -0
  15. package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -0
  16. package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +2 -0
  17. package/server/dist/@intlayer/chokidar/dist/types/cleanOutputDir.d.ts +1 -0
  18. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +1 -0
  19. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +1 -0
  20. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +1 -0
  21. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +1 -0
  22. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +1 -0
  23. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +1 -0
  24. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +1 -0
  25. package/server/dist/@intlayer/chokidar/dist/types/createType/createModuleAugmentation.d.ts +1 -0
  26. package/server/dist/@intlayer/chokidar/dist/types/createType/createType.d.ts +2 -0
  27. package/server/dist/@intlayer/chokidar/dist/types/formatDictionary.d.ts +1 -0
  28. package/server/dist/@intlayer/chokidar/dist/types/intlayer/dist/types/index.d.ts +1 -0
  29. package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadContentDeclaration.d.ts +2 -0
  30. package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadDictionaries.d.ts +2 -0
  31. package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +2 -0
  32. package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +1 -0
  33. package/server/dist/@intlayer/chokidar/dist/types/prepareIntlayer.d.ts +1 -0
  34. package/server/dist/@intlayer/chokidar/dist/types/writeConfiguration/index.d.ts +1 -0
  35. package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +6 -0
  36. package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/transformJSFile.d.ts +1 -0
  37. package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +2 -0
  38. package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/writeJSFile.d.ts +2 -0
  39. package/server/dist/@intlayer/core/dist/types/messageFormat/ICU.d.ts +1 -0
  40. package/server/dist/@intlayer/core/dist/types/messageFormat/i18next.d.ts +1 -0
  41. package/server/dist/@intlayer/core/dist/types/messageFormat/index.d.ts +1 -0
  42. package/server/dist/@intlayer/core/dist/types/messageFormat/po.d.ts +1 -0
  43. package/server/dist/@intlayer/core/dist/types/messageFormat/vue-i18n.d.ts +1 -0
  44. package/server/dist/controllers/configuration.controller.cjs +1 -0
  45. package/server/dist/controllers/configuration.controller.cjs.map +1 -1
  46. package/server/dist/controllers/configuration.controller.mjs.map +1 -1
  47. package/server/dist/controllers/dictionary.controller.cjs +1 -0
  48. package/server/dist/controllers/dictionary.controller.cjs.map +1 -1
  49. package/server/dist/controllers/dictionary.controller.mjs.map +1 -1
  50. package/server/dist/index.cjs.map +1 -1
  51. package/server/dist/index.mjs.map +1 -1
  52. package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.cjs +32 -0
  53. package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.cjs.map +1 -0
  54. package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.mjs +31 -0
  55. package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.mjs.map +1 -0
  56. package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +82 -0
  57. package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -0
  58. package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +81 -0
  59. package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -0
  60. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.cjs +26 -0
  61. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.cjs.map +1 -0
  62. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.mjs +25 -0
  63. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.mjs.map +1 -0
  64. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.cjs +24 -0
  65. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.cjs.map +1 -0
  66. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs +23 -0
  67. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs.map +1 -0
  68. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.cjs +94 -0
  69. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -0
  70. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +92 -0
  71. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -0
  72. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.cjs +416 -0
  73. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.cjs.map +1 -0
  74. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.mjs +412 -0
  75. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -0
  76. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.cjs +127 -0
  77. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.cjs.map +1 -0
  78. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.mjs +125 -0
  79. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -0
  80. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.cjs +164 -0
  81. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -0
  82. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +163 -0
  83. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -0
  84. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.cjs +92 -0
  85. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.cjs.map +1 -0
  86. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.mjs +91 -0
  87. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -0
  88. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.cjs +65 -0
  89. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.cjs.map +1 -0
  90. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +64 -0
  91. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs.map +1 -0
  92. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.cjs +43 -0
  93. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.cjs.map +1 -0
  94. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.mjs +42 -0
  95. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.mjs.map +1 -0
  96. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.cjs +45 -0
  97. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -0
  98. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +43 -0
  99. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -0
  100. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.cjs +32 -0
  101. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.cjs.map +1 -0
  102. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +32 -0
  103. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -0
  104. package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.cjs +56 -0
  105. package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.cjs.map +1 -0
  106. package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.mjs +54 -0
  107. package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -0
  108. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.cjs +27 -0
  109. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.cjs.map +1 -0
  110. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.mjs +26 -0
  111. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.mjs.map +1 -0
  112. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.cjs +58 -0
  113. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.cjs.map +1 -0
  114. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.mjs +56 -0
  115. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -0
  116. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.cjs +160 -0
  117. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.cjs.map +1 -0
  118. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.mjs +158 -0
  119. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.mjs.map +1 -0
  120. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.cjs +71 -0
  121. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.cjs.map +1 -0
  122. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.mjs +70 -0
  123. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.mjs.map +1 -0
  124. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.cjs +38 -0
  125. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.cjs.map +1 -0
  126. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.mjs +37 -0
  127. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.mjs.map +1 -0
  128. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.cjs +22 -0
  129. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.cjs.map +1 -0
  130. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.mjs +21 -0
  131. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.mjs.map +1 -0
  132. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.cjs +87 -0
  133. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.cjs.map +1 -0
  134. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.mjs +86 -0
  135. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.mjs.map +1 -0
  136. package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.cjs +14 -0
  137. package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.cjs.map +1 -0
  138. package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.mjs +13 -0
  139. package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.mjs.map +1 -0
  140. package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.cjs +58 -0
  141. package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.cjs.map +1 -0
  142. package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.mjs +57 -0
  143. package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.mjs.map +1 -0
  144. package/server/dist/routes/config.routes.cjs +1 -0
  145. package/server/dist/routes/config.routes.cjs.map +1 -1
  146. package/server/dist/routes/config.routes.mjs.map +1 -1
  147. package/server/dist/routes/dictionary.routes.cjs +1 -0
  148. package/server/dist/routes/dictionary.routes.cjs.map +1 -1
  149. package/server/dist/routes/dictionary.routes.mjs.map +1 -1
  150. package/server/dist/utils/checkPortAvailability.cjs.map +1 -1
  151. package/server/dist/utils/checkPortAvailability.mjs.map +1 -1
  152. package/server/dist/utils/httpStatusCodes.cjs.map +1 -1
  153. package/server/dist/utils/httpStatusCodes.mjs.map +1 -1
  154. package/server/dist/utils/responseData.cjs.map +1 -1
  155. package/server/dist/utils/responseData.mjs.map +1 -1
  156. package/client/dist/assets/index-CTSrsWZb.css +0 -2
  157. package/client/dist/assets/index-bVSusa0N.js +0 -185
  158. package/client/dist/assets/purify.es-Dt2VzQ8a.js +0 -3
@@ -0,0 +1,125 @@
1
+ import * as recast from "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/recast@0.23.11/node_modules/recast/main.js";
2
+
3
+ //#region ../../@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.mjs
4
+ const b = recast.types.builders;
5
+ const n = recast.types.namedTypes;
6
+ /**
7
+ * Checks if a value is a plain object (and not null/array)
8
+ */
9
+ const isPlainObject = (value) => {
10
+ return typeof value === "object" && value !== null && !Array.isArray(value);
11
+ };
12
+ /**
13
+ * Checks if a recast AST node value matches the incoming primitive value.
14
+ */
15
+ const isPrimitiveEqual = (astNode, val) => {
16
+ if (val === null) return n.Literal.check(astNode) && astNode.value === null;
17
+ if (typeof val === "string" || typeof val === "number" || typeof val === "boolean") return (n.Literal.check(astNode) || n.StringLiteral.check(astNode) || n.NumericLiteral.check(astNode) || n.BooleanLiteral.check(astNode)) && astNode.value === val;
18
+ return false;
19
+ };
20
+ /**
21
+ * Robustly finds a property in a recast ObjectExpression.
22
+ * Handles quoted ("key") or unquoted (key) properties.
23
+ */
24
+ const getMatchingProperty = (node, key) => {
25
+ return node.properties.find((prop) => {
26
+ if (n.Property.check(prop) || n.ObjectProperty.check(prop)) {
27
+ if (n.Identifier.check(prop.key) && prop.key.name === key) return true;
28
+ if (n.StringLiteral.check(prop.key) && prop.key.value === key) return true;
29
+ if (n.Literal.check(prop.key) && prop.key.value === key) return true;
30
+ }
31
+ return false;
32
+ });
33
+ };
34
+ /**
35
+ * Recursively builds a clean recast AST node from a plain JS value.
36
+ * Because these nodes lack `loc` tracking, recast is forced to pretty-print them.
37
+ */
38
+ const buildASTNode = (val) => {
39
+ if (val === null) return b.literal(null);
40
+ if (typeof val === "string" || typeof val === "number" || typeof val === "boolean") return b.literal(val);
41
+ if (Array.isArray(val)) return b.arrayExpression(val.map((item) => buildASTNode(item)));
42
+ if (isPlainObject(val)) return b.objectExpression(Object.entries(val).filter(([, v]) => v !== void 0).map(([k, v]) => b.property("init", b.stringLiteral(k), buildASTNode(v))));
43
+ return b.literal(null);
44
+ };
45
+ /**
46
+ * Recursively updates the AST object literal with new data.
47
+ */
48
+ const updateObjectLiteral = (node, data) => {
49
+ for (const [key, val] of Object.entries(data)) {
50
+ if (val === void 0) continue;
51
+ const existingProp = getMatchingProperty(node, key);
52
+ if (existingProp?.comments) existingProp.comments.forEach((c) => {
53
+ if ((c.type === "Line" || c.type === "CommentLine") && c.trailing) {
54
+ c.type = c.type === "Line" ? "Block" : "CommentBlock";
55
+ c.value = `__INLINE_LINE__${c.value}`;
56
+ c.leading = false;
57
+ c.trailing = true;
58
+ }
59
+ });
60
+ if (isPlainObject(val)) if (existingProp && n.ObjectExpression.check(existingProp.value)) updateObjectLiteral(existingProp.value, val);
61
+ else if (existingProp) {
62
+ if (!(n.Literal.check(existingProp.value) && existingProp.value.value === val)) existingProp.value = buildASTNode(val);
63
+ } else node.properties.push(b.property("init", b.stringLiteral(key), buildASTNode(val)));
64
+ else if (existingProp) {
65
+ if (!isPrimitiveEqual(existingProp.value, val)) existingProp.value = buildASTNode(val);
66
+ } else node.properties.push(b.property("init", b.stringLiteral(key), buildASTNode(val)));
67
+ }
68
+ };
69
+ const transformJSONFile = (fileContent, dictionary, noMetadata) => {
70
+ const wrappedContent = `const _config = ${fileContent.trim() || "{}"};`;
71
+ let ast;
72
+ try {
73
+ ast = recast.parse(wrappedContent);
74
+ } catch {
75
+ return JSON.stringify(noMetadata ? dictionary.content : dictionary, null, 2);
76
+ }
77
+ const declaration = ast.program.body[0];
78
+ let objectLiteral;
79
+ if (n.VariableDeclaration.check(declaration) && declaration.declarations.length > 0 && n.VariableDeclarator.check(declaration.declarations[0]) && n.ObjectExpression.check(declaration.declarations[0].init)) objectLiteral = declaration.declarations[0].init;
80
+ if (noMetadata) {
81
+ const metadataProperties = [
82
+ "id",
83
+ "locale",
84
+ "filled",
85
+ "fill",
86
+ "title",
87
+ "description",
88
+ "tags",
89
+ "version",
90
+ "priority",
91
+ "contentAutoTransformation",
92
+ "$schema"
93
+ ];
94
+ for (let i = objectLiteral.properties.length - 1; i >= 0; i--) {
95
+ const prop = objectLiteral.properties[i];
96
+ if (n.Property.check(prop) || n.ObjectProperty.check(prop)) {
97
+ let propName = "";
98
+ if (n.Identifier.check(prop.key)) propName = prop.key.name;
99
+ else if (n.StringLiteral.check(prop.key)) propName = prop.key.value;
100
+ else if (n.Literal.check(prop.key)) propName = String(prop.key.value);
101
+ if ([
102
+ "key",
103
+ "content",
104
+ ...metadataProperties
105
+ ].includes(propName)) objectLiteral.properties.splice(i, 1);
106
+ }
107
+ }
108
+ }
109
+ updateObjectLiteral(objectLiteral, noMetadata ? dictionary.content : dictionary);
110
+ const printedCode = recast.print(ast, {
111
+ tabWidth: 2,
112
+ quote: "double",
113
+ trailingComma: false
114
+ }).code;
115
+ const startIndex = printedCode.indexOf("{");
116
+ const endIndex = printedCode.lastIndexOf("}");
117
+ let finalOutput = printedCode.substring(startIndex, endIndex + 1);
118
+ finalOutput = finalOutput.replace(/\s*\/\*__INLINE_LINE__(.*?)\*\/(\s*,?)/g, "$2 //$1");
119
+ finalOutput = finalOutput.replace(/\n[ \t]*\n/g, "\n");
120
+ return finalOutput;
121
+ };
122
+
123
+ //#endregion
124
+ export { transformJSONFile };
125
+ //# sourceMappingURL=transformJSONFile.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformJSONFile.mjs","names":[],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.mjs"],"sourcesContent":["import * as recast from \"recast\";\n\n//#region src/writeContentDeclaration/transformJSONFile.ts\nconst b = recast.types.builders;\nconst n = recast.types.namedTypes;\n/**\n* Checks if a value is a plain object (and not null/array)\n*/\nconst isPlainObject = (value) => {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n};\n/**\n* Checks if a recast AST node value matches the incoming primitive value.\n*/\nconst isPrimitiveEqual = (astNode, val) => {\n\tif (val === null) return n.Literal.check(astNode) && astNode.value === null;\n\tif (typeof val === \"string\" || typeof val === \"number\" || typeof val === \"boolean\") return (n.Literal.check(astNode) || n.StringLiteral.check(astNode) || n.NumericLiteral.check(astNode) || n.BooleanLiteral.check(astNode)) && astNode.value === val;\n\treturn false;\n};\n/**\n* Robustly finds a property in a recast ObjectExpression.\n* Handles quoted (\"key\") or unquoted (key) properties.\n*/\nconst getMatchingProperty = (node, key) => {\n\treturn node.properties.find((prop) => {\n\t\tif (n.Property.check(prop) || n.ObjectProperty.check(prop)) {\n\t\t\tif (n.Identifier.check(prop.key) && prop.key.name === key) return true;\n\t\t\tif (n.StringLiteral.check(prop.key) && prop.key.value === key) return true;\n\t\t\tif (n.Literal.check(prop.key) && prop.key.value === key) return true;\n\t\t}\n\t\treturn false;\n\t});\n};\n/**\n* Recursively builds a clean recast AST node from a plain JS value.\n* Because these nodes lack `loc` tracking, recast is forced to pretty-print them.\n*/\nconst buildASTNode = (val) => {\n\tif (val === null) return b.literal(null);\n\tif (typeof val === \"string\" || typeof val === \"number\" || typeof val === \"boolean\") return b.literal(val);\n\tif (Array.isArray(val)) return b.arrayExpression(val.map((item) => buildASTNode(item)));\n\tif (isPlainObject(val)) return b.objectExpression(Object.entries(val).filter(([, v]) => v !== void 0).map(([k, v]) => b.property(\"init\", b.stringLiteral(k), buildASTNode(v))));\n\treturn b.literal(null);\n};\n/**\n* Recursively updates the AST object literal with new data.\n*/\nconst updateObjectLiteral = (node, data) => {\n\tfor (const [key, val] of Object.entries(data)) {\n\t\tif (val === void 0) continue;\n\t\tconst existingProp = getMatchingProperty(node, key);\n\t\tif (existingProp?.comments) existingProp.comments.forEach((c) => {\n\t\t\tif ((c.type === \"Line\" || c.type === \"CommentLine\") && c.trailing) {\n\t\t\t\tc.type = c.type === \"Line\" ? \"Block\" : \"CommentBlock\";\n\t\t\t\tc.value = `__INLINE_LINE__${c.value}`;\n\t\t\t\tc.leading = false;\n\t\t\t\tc.trailing = true;\n\t\t\t}\n\t\t});\n\t\tif (isPlainObject(val)) if (existingProp && n.ObjectExpression.check(existingProp.value)) updateObjectLiteral(existingProp.value, val);\n\t\telse if (existingProp) {\n\t\t\tif (!(n.Literal.check(existingProp.value) && existingProp.value.value === val)) existingProp.value = buildASTNode(val);\n\t\t} else node.properties.push(b.property(\"init\", b.stringLiteral(key), buildASTNode(val)));\n\t\telse if (existingProp) {\n\t\t\tif (!isPrimitiveEqual(existingProp.value, val)) existingProp.value = buildASTNode(val);\n\t\t} else node.properties.push(b.property(\"init\", b.stringLiteral(key), buildASTNode(val)));\n\t}\n};\nconst transformJSONFile = (fileContent, dictionary, noMetadata) => {\n\tconst wrappedContent = `const _config = ${fileContent.trim() || \"{}\"};`;\n\tlet ast;\n\ttry {\n\t\tast = recast.parse(wrappedContent);\n\t} catch {\n\t\treturn JSON.stringify(noMetadata ? dictionary.content : dictionary, null, 2);\n\t}\n\tconst declaration = ast.program.body[0];\n\tlet objectLiteral;\n\tif (n.VariableDeclaration.check(declaration) && declaration.declarations.length > 0 && n.VariableDeclarator.check(declaration.declarations[0]) && n.ObjectExpression.check(declaration.declarations[0].init)) objectLiteral = declaration.declarations[0].init;\n\tif (noMetadata) {\n\t\tconst metadataProperties = [\n\t\t\t\"id\",\n\t\t\t\"locale\",\n\t\t\t\"filled\",\n\t\t\t\"fill\",\n\t\t\t\"title\",\n\t\t\t\"description\",\n\t\t\t\"tags\",\n\t\t\t\"version\",\n\t\t\t\"priority\",\n\t\t\t\"contentAutoTransformation\",\n\t\t\t\"$schema\"\n\t\t];\n\t\tfor (let i = objectLiteral.properties.length - 1; i >= 0; i--) {\n\t\t\tconst prop = objectLiteral.properties[i];\n\t\t\tif (n.Property.check(prop) || n.ObjectProperty.check(prop)) {\n\t\t\t\tlet propName = \"\";\n\t\t\t\tif (n.Identifier.check(prop.key)) propName = prop.key.name;\n\t\t\t\telse if (n.StringLiteral.check(prop.key)) propName = prop.key.value;\n\t\t\t\telse if (n.Literal.check(prop.key)) propName = String(prop.key.value);\n\t\t\t\tif ([\n\t\t\t\t\t\"key\",\n\t\t\t\t\t\"content\",\n\t\t\t\t\t...metadataProperties\n\t\t\t\t].includes(propName)) objectLiteral.properties.splice(i, 1);\n\t\t\t}\n\t\t}\n\t}\n\tupdateObjectLiteral(objectLiteral, noMetadata ? dictionary.content : dictionary);\n\tconst printedCode = recast.print(ast, {\n\t\ttabWidth: 2,\n\t\tquote: \"double\",\n\t\ttrailingComma: false\n\t}).code;\n\tconst startIndex = printedCode.indexOf(\"{\");\n\tconst endIndex = printedCode.lastIndexOf(\"}\");\n\tlet finalOutput = printedCode.substring(startIndex, endIndex + 1);\n\tfinalOutput = finalOutput.replace(/\\s*\\/\\*__INLINE_LINE__(.*?)\\*\\/(\\s*,?)/g, \"$2 //$1\");\n\tfinalOutput = finalOutput.replace(/\\n[ \\t]*\\n/g, \"\\n\");\n\treturn finalOutput;\n};\n\n//#endregion\nexport { transformJSONFile };\n//# sourceMappingURL=transformJSONFile.mjs.map"],"mappings":";;;AAGA,MAAM,IAAI,OAAO,MAAM;AACvB,MAAM,IAAI,OAAO,MAAM;;;;AAIvB,MAAM,iBAAiB,UAAU;AAChC,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;;;;AAK5E,MAAM,oBAAoB,SAAS,QAAQ;AAC1C,KAAI,QAAQ,KAAM,QAAO,EAAE,QAAQ,MAAM,QAAQ,IAAI,QAAQ,UAAU;AACvE,KAAI,OAAO,QAAQ,YAAY,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAAW,SAAQ,EAAE,QAAQ,MAAM,QAAQ,IAAI,EAAE,cAAc,MAAM,QAAQ,IAAI,EAAE,eAAe,MAAM,QAAQ,IAAI,EAAE,eAAe,MAAM,QAAQ,KAAK,QAAQ,UAAU;AACnP,QAAO;;;;;;AAMR,MAAM,uBAAuB,MAAM,QAAQ;AAC1C,QAAO,KAAK,WAAW,MAAM,SAAS;AACrC,MAAI,EAAE,SAAS,MAAM,KAAK,IAAI,EAAE,eAAe,MAAM,KAAK,EAAE;AAC3D,OAAI,EAAE,WAAW,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,SAAS,IAAK,QAAO;AAClE,OAAI,EAAE,cAAc,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,UAAU,IAAK,QAAO;AACtE,OAAI,EAAE,QAAQ,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,UAAU,IAAK,QAAO;;AAEjE,SAAO;GACN;;;;;;AAMH,MAAM,gBAAgB,QAAQ;AAC7B,KAAI,QAAQ,K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AAO,MAAM,KAAK;EACrC,UAAU;EACV,OAAO;EACP,eAAe;EACf,CAAC,CAAC;CACH,MAAM,aAAa,YAAY,QAAQ,IAAI;CAC3C,MAAM,WAAW,YAAY,YAAY,IAAI;CAC7C,IAAI,cAAc,YAAY,UAAU,YAAY,WAAW,EAAE;AACjE,eAAc,YAAY,QAAQ,2CAA2C,UAAU;AACvF,eAAc,YAAY,QAAQ,eAAe,KAAK;AACtD,QAAO"}
@@ -0,0 +1,164 @@
1
+ const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
2
+ const require_readDictionariesFromDisk = require('../utils/readDictionariesFromDisk.cjs');
3
+ const require_getFilteredLocalesContent = require('../../../../core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.cjs');
4
+ const require_getLocalizedContent = require('../../../../core/dist/esm/deepTransformPlugins/getLocalizedContent.cjs');
5
+ const require_getFormatFromExtension = require('../utils/getFormatFromExtension.cjs');
6
+ const require_detectFormatCommand = require('../detectFormatCommand.cjs');
7
+ const require_writeJSFile = require('./writeJSFile.cjs');
8
+ const require_processContentDeclarationContent = require('./processContentDeclarationContent.cjs');
9
+ const require_transformJSONFile = require('./transformJSONFile.cjs');
10
+ const require_writeMarkdownFile = require('./writeMarkdownFile.cjs');
11
+ const require_writeYamlFile = require('./writeYamlFile.cjs');
12
+ let node_path = require("node:path");
13
+ let node_fs_promises = require("node:fs/promises");
14
+ let node_fs = require("node:fs");
15
+ let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
16
+ let node_child_process = require("node:child_process");
17
+ let node_util = require("node:util");
18
+
19
+ //#region ../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs
20
+ const formatContentDeclaration = async (dictionary, configuration, localeList) => {
21
+ /**
22
+ * Clean Markdown, Insertion, File, etc. node metadata
23
+ */
24
+ const processedDictionary = await require_processContentDeclarationContent.processContentDeclarationContent(dictionary);
25
+ let content = processedDictionary.content;
26
+ /**
27
+ * Filter locales content
28
+ */
29
+ if (dictionary.locale) content = require_getLocalizedContent.getPerLocaleDictionary(processedDictionary, dictionary.locale).content;
30
+ else if (localeList) content = require_getFilteredLocalesContent.getFilteredLocalesDictionary(processedDictionary, localeList).content;
31
+ let pluginFormatResult = {
32
+ ...dictionary,
33
+ content
34
+ };
35
+ /**
36
+ * Format the dictionary with the plugins
37
+ */
38
+ for await (const plugin of configuration.plugins ?? []) if (plugin.formatOutput) {
39
+ const formattedResult = await plugin.formatOutput?.({
40
+ dictionary: pluginFormatResult,
41
+ configuration
42
+ });
43
+ if (formattedResult) pluginFormatResult = formattedResult;
44
+ }
45
+ if (!(pluginFormatResult.content && pluginFormatResult.key)) return pluginFormatResult;
46
+ const INTERNAL_FIELDS = new Set([
47
+ "$schema",
48
+ "filePath",
49
+ "localId",
50
+ "localIds",
51
+ "projectIds"
52
+ ]);
53
+ let result = {
54
+ ...Object.fromEntries(Object.entries(dictionary).filter(([k]) => !INTERNAL_FIELDS.has(k))),
55
+ content
56
+ };
57
+ if (require_getFormatFromExtension.getFormatFromExtension(dictionary.filePath ? (0, node_path.extname)(dictionary.filePath) : ".json") === "json" && pluginFormatResult.content && pluginFormatResult.key) result = {
58
+ $schema: "https://intlayer.org/schema.json",
59
+ ...result
60
+ };
61
+ return result;
62
+ };
63
+ const defaultOptions = { newDictionariesPath: "intlayer-dictionaries" };
64
+ const writeContentDeclaration = async (dictionary, configuration, options) => {
65
+ const { system, compiler } = configuration;
66
+ const { baseDir } = system;
67
+ const noMetadata = compiler?.noMetadata ?? _intlayer_config_defaultValues.COMPILER_NO_METADATA;
68
+ const { newDictionariesPath, localeList } = {
69
+ ...defaultOptions,
70
+ ...options
71
+ };
72
+ const newDictionaryLocationPath = (0, node_path.join)(baseDir, newDictionariesPath);
73
+ const existingDictionary = require_readDictionariesFromDisk.readDictionariesFromDisk(configuration.system.unmergedDictionariesDir)[dictionary.key]?.find((el) => el.localId === dictionary.localId);
74
+ const formattedContentDeclaration = await formatContentDeclaration(dictionary, configuration, localeList);
75
+ if (existingDictionary?.filePath) {
76
+ const isSameContent = (0, node_util.isDeepStrictEqual)(existingDictionary, dictionary);
77
+ const filePath = (0, node_path.resolve)(configuration.system.baseDir, existingDictionary.filePath);
78
+ if (isSameContent) return {
79
+ status: "up-to-date",
80
+ path: filePath
81
+ };
82
+ await writeFileWithDirectories(filePath, formattedContentDeclaration, configuration, noMetadata);
83
+ return {
84
+ status: "updated",
85
+ path: filePath
86
+ };
87
+ }
88
+ if (dictionary.filePath) {
89
+ const filePath = (0, node_path.resolve)(configuration.system.baseDir, dictionary.filePath);
90
+ await writeFileWithDirectories(filePath, formattedContentDeclaration, configuration, noMetadata);
91
+ return {
92
+ status: "created",
93
+ path: filePath
94
+ };
95
+ }
96
+ const contentDeclarationPath = (0, node_path.join)(newDictionaryLocationPath, `${dictionary.key}.content.json`);
97
+ await writeFileWithDirectories(contentDeclarationPath, formattedContentDeclaration, configuration, noMetadata);
98
+ return {
99
+ status: "imported",
100
+ path: contentDeclarationPath
101
+ };
102
+ };
103
+ const writeFileWithDirectories = async (absoluteFilePath, dictionary, configuration, noMetadata) => {
104
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(absoluteFilePath), { recursive: true });
105
+ const extension = (0, node_path.extname)(absoluteFilePath);
106
+ if (extension === ".md" || extension === ".mdx") {
107
+ await require_writeMarkdownFile.writeMarkdownFile(absoluteFilePath, dictionary, configuration);
108
+ return;
109
+ }
110
+ if (extension === ".yaml" || extension === ".yml") {
111
+ await require_writeYamlFile.writeYamlFile(absoluteFilePath, dictionary, configuration);
112
+ return;
113
+ }
114
+ if ([
115
+ ".json",
116
+ ".jsonc",
117
+ ".json5"
118
+ ].includes(extension)) {
119
+ let fileContent = "{}";
120
+ if ((0, node_fs.existsSync)(absoluteFilePath)) try {
121
+ fileContent = await (0, node_fs_promises.readFile)(absoluteFilePath, "utf-8");
122
+ } catch {}
123
+ const transformedContent = require_transformJSONFile.transformJSONFile(fileContent, dictionary, noMetadata);
124
+ const tempDir = configuration.system?.tempDir;
125
+ if (tempDir) await (0, node_fs_promises.mkdir)(tempDir, { recursive: true });
126
+ const tempFileName = `${(0, node_path.basename)(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
127
+ const tempPath = tempDir ? (0, node_path.join)(tempDir, tempFileName) : `${absoluteFilePath}.${tempFileName}`;
128
+ try {
129
+ await (0, node_fs_promises.writeFile)(tempPath, transformedContent, "utf-8");
130
+ await (0, node_fs_promises.rename)(tempPath, absoluteFilePath);
131
+ } catch (error) {
132
+ try {
133
+ await (0, node_fs_promises.rm)(tempPath, { force: true });
134
+ } catch {}
135
+ throw error;
136
+ }
137
+ const formatCommand = require_detectFormatCommand.detectFormatCommand(configuration);
138
+ if (formatCommand) try {
139
+ (0, node_child_process.execSync)(formatCommand.replace("{{file}}", absoluteFilePath), {
140
+ stdio: "inherit",
141
+ cwd: configuration.system.baseDir
142
+ });
143
+ } catch (error) {
144
+ console.error(error);
145
+ }
146
+ return;
147
+ }
148
+ if (!new Set([
149
+ ".ts",
150
+ ".tsx",
151
+ ".js",
152
+ ".jsx",
153
+ ".mjs",
154
+ ".cjs"
155
+ ]).has(extension)) return;
156
+ await require_writeJSFile.writeJSFile(absoluteFilePath, dictionary, configuration, noMetadata);
157
+ try {
158
+ await (0, node_fs_promises.rm)((0, node_path.join)(configuration.system.cacheDir, "intlayer-prepared.lock"), { recursive: true });
159
+ } catch {}
160
+ };
161
+
162
+ //#endregion
163
+ exports.writeContentDeclaration = writeContentDeclaration;
164
+ //# sourceMappingURL=writeContentDeclaration.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeContentDeclaration.cjs","names":["processContentDeclarationContent","getPerLocaleDictionary","getFilteredLocalesDictionary","getFormatFromExtension","COMPILER_NO_METADATA","readDictionariesFromDisk","writeMarkdownFile","writeYamlFile","transformJSONFile","detectFormatCommand","writeJSFile"],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs"],"sourcesContent":["import { readDictionariesFromDisk } from \"../utils/readDictionariesFromDisk.mjs\";\nimport { getFormatFromExtension } from \"../utils/getFormatFromExtension.mjs\";\nimport { detectFormatCommand } from \"../detectFormatCommand.mjs\";\nimport { processContentDeclarationContent } from \"./processContentDeclarationContent.mjs\";\nimport { transformJSONFile } from \"./transformJSONFile.mjs\";\nimport { writeJSFile } from \"./writeJSFile.mjs\";\nimport { writeMarkdownFile } from \"./writeMarkdownFile.mjs\";\nimport { writeYamlFile } from \"./writeYamlFile.mjs\";\nimport { mkdir, readFile, rename, rm, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, extname, join, resolve } from \"node:path\";\nimport { existsSync } from \"node:fs\";\nimport { COMPILER_NO_METADATA } from \"@intlayer/config/defaultValues\";\nimport { getFilteredLocalesDictionary, getPerLocaleDictionary } from \"@intlayer/core/plugins\";\nimport { execSync } from \"node:child_process\";\nimport { isDeepStrictEqual } from \"node:util\";\n\n//#region src/writeContentDeclaration/writeContentDeclaration.ts\nconst formatContentDeclaration = async (dictionary, configuration, localeList) => {\n\t/**\n\t* Clean Markdown, Insertion, File, etc. node metadata\n\t*/\n\tconst processedDictionary = await processContentDeclarationContent(dictionary);\n\tlet content = processedDictionary.content;\n\t/**\n\t* Filter locales content\n\t*/\n\tif (dictionary.locale) content = getPerLocaleDictionary(processedDictionary, dictionary.locale).content;\n\telse if (localeList) content = getFilteredLocalesDictionary(processedDictionary, localeList).content;\n\tlet pluginFormatResult = {\n\t\t...dictionary,\n\t\tcontent\n\t};\n\t/**\n\t* Format the dictionary with the plugins\n\t*/\n\tfor await (const plugin of configuration.plugins ?? []) if (plugin.formatOutput) {\n\t\tconst formattedResult = await plugin.formatOutput?.({\n\t\t\tdictionary: pluginFormatResult,\n\t\t\tconfiguration\n\t\t});\n\t\tif (formattedResult) pluginFormatResult = formattedResult;\n\t}\n\tif (!(pluginFormatResult.content && pluginFormatResult.key)) return pluginFormatResult;\n\tconst INTERNAL_FIELDS = new Set([\n\t\t\"$schema\",\n\t\t\"filePath\",\n\t\t\"localId\",\n\t\t\"localIds\",\n\t\t\"projectIds\"\n\t]);\n\tlet result = {\n\t\t...Object.fromEntries(Object.entries(dictionary).filter(([k]) => !INTERNAL_FIELDS.has(k))),\n\t\tcontent\n\t};\n\tif (getFormatFromExtension(dictionary.filePath ? extname(dictionary.filePath) : \".json\") === \"json\" && pluginFormatResult.content && pluginFormatResult.key) result = {\n\t\t$schema: \"https://intlayer.org/schema.json\",\n\t\t...result\n\t};\n\treturn result;\n};\nconst defaultOptions = { newDictionariesPath: \"intlayer-dictionaries\" };\nconst writeContentDeclaration = async (dictionary, configuration, options) => {\n\tconst { system, compiler } = configuration;\n\tconst { baseDir } = system;\n\tconst noMetadata = compiler?.noMetadata ?? COMPILER_NO_METADATA;\n\tconst { newDictionariesPath, localeList } = {\n\t\t...defaultOptions,\n\t\t...options\n\t};\n\tconst newDictionaryLocationPath = join(baseDir, newDictionariesPath);\n\tconst existingDictionary = readDictionariesFromDisk(configuration.system.unmergedDictionariesDir)[dictionary.key]?.find((el) => el.localId === dictionary.localId);\n\tconst formattedContentDeclaration = await formatContentDeclaration(dictionary, configuration, localeList);\n\tif (existingDictionary?.filePath) {\n\t\tconst isSameContent = isDeepStrictEqual(existingDictionary, dictionary);\n\t\tconst filePath = resolve(configuration.system.baseDir, existingDictionary.filePath);\n\t\tif (isSameContent) return {\n\t\t\tstatus: \"up-to-date\",\n\t\t\tpath: filePath\n\t\t};\n\t\tawait writeFileWithDirectories(filePath, formattedContentDeclaration, configuration, noMetadata);\n\t\treturn {\n\t\t\tstatus: \"updated\",\n\t\t\tpath: filePath\n\t\t};\n\t}\n\tif (dictionary.filePath) {\n\t\tconst filePath = resolve(configuration.system.baseDir, dictionary.filePath);\n\t\tawait writeFileWithDirectories(filePath, formattedContentDeclaration, configuration, noMetadata);\n\t\treturn {\n\t\t\tstatus: \"created\",\n\t\t\tpath: filePath\n\t\t};\n\t}\n\tconst contentDeclarationPath = join(newDictionaryLocationPath, `${dictionary.key}.content.json`);\n\tawait writeFileWithDirectories(contentDeclarationPath, formattedContentDeclaration, configuration, noMetadata);\n\treturn {\n\t\tstatus: \"imported\",\n\t\tpath: contentDeclarationPath\n\t};\n};\nconst writeFileWithDirectories = async (absoluteFilePath, dictionary, configuration, noMetadata) => {\n\tawait mkdir(dirname(absoluteFilePath), { recursive: true });\n\tconst extension = extname(absoluteFilePath);\n\tif (extension === \".md\" || extension === \".mdx\") {\n\t\tawait writeMarkdownFile(absoluteFilePath, dictionary, configuration);\n\t\treturn;\n\t}\n\tif (extension === \".yaml\" || extension === \".yml\") {\n\t\tawait writeYamlFile(absoluteFilePath, dictionary, configuration);\n\t\treturn;\n\t}\n\tif ([\n\t\t\".json\",\n\t\t\".jsonc\",\n\t\t\".json5\"\n\t].includes(extension)) {\n\t\tlet fileContent = \"{}\";\n\t\tif (existsSync(absoluteFilePath)) try {\n\t\t\tfileContent = await readFile(absoluteFilePath, \"utf-8\");\n\t\t} catch {}\n\t\tconst transformedContent = transformJSONFile(fileContent, dictionary, noMetadata);\n\t\tconst tempDir = configuration.system?.tempDir;\n\t\tif (tempDir) await mkdir(tempDir, { recursive: true });\n\t\tconst tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n\t\tconst tempPath = tempDir ? join(tempDir, tempFileName) : `${absoluteFilePath}.${tempFileName}`;\n\t\ttry {\n\t\t\tawait writeFile(tempPath, transformedContent, \"utf-8\");\n\t\t\tawait rename(tempPath, absoluteFilePath);\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\tawait rm(tempPath, { force: true });\n\t\t\t} catch {}\n\t\t\tthrow error;\n\t\t}\n\t\tconst formatCommand = detectFormatCommand(configuration);\n\t\tif (formatCommand) try {\n\t\t\texecSync(formatCommand.replace(\"{{file}}\", absoluteFilePath), {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t\tcwd: configuration.system.baseDir\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t\treturn;\n\t}\n\tif (!new Set([\n\t\t\".ts\",\n\t\t\".tsx\",\n\t\t\".js\",\n\t\t\".jsx\",\n\t\t\".mjs\",\n\t\t\".cjs\"\n\t]).has(extension)) return;\n\tawait writeJSFile(absoluteFilePath, dictionary, configuration, noMetadata);\n\ttry {\n\t\tawait rm(join(configuration.system.cacheDir, \"intlayer-prepared.lock\"), { recursive: true });\n\t} catch {}\n};\n\n//#endregion\nexport { writeContentDeclaration };\n//# sourceMappingURL=writeContentDeclaration.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA,MAAM,2BAA2B,OAAO,YAAY,eAAe,eAAe;;;;CAIjF,MAAM,sBAAsB,MAAMA,0EAAiC,WAAW;CAC9E,IAAI,UAAU,oBAAoB;;;;AAIlC,KAAI,WAAW,OAAQ,WAAUC,mDAAuB,qBAAqB,WAAW,OAAO,CAAC;UACvF,WAAY,WAAUC,+DAA6B,qBAAqB,WAAW,CAAC;CAC7F,IAAI,qBAAqB;EACxB,GAAG;EACH;EACA;;;;AAID,YAAW,MAAM,UAAU,cAAc,WAAW,EAAE,CAAE,KAAI,OAAO,cAAc;EAChF,MAAM,kBAAkB,MAAM,OAAO,eAAe;GACnD,YAAY;GACZ;GACA,CAAC;AACF,MAAI,gBAAiB,sBAAqB;;AAE3C,KAAI,EAAE,mBAAmB,WAAW,mBAAmB,KAAM,QAAO;CACpE,MAAM,kBAAkB,IAAI,IAAI;EAC/B;EACA;EACA;EACA;EACA;EACA,CAAC;CACF,IAAI,SAAS;EACZ,GAAG,OAAO,YAAY,OAAO,QAAQ,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;EAC1F;EACA;AACD,KAAIC,sDAAuB,WAAW,kCAAmB,WAAW,SAAS,GAAG,QAAQ,KAAK,UAAU,mBAAmB,WAAW,mBAAmB,IAAK,UAAS;EACrK,SAAS;EACT,GAAG;EACH;AACD,Q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,cAAc,WAAW,cAAc,QAAQ;AAClD,QAAMC,oCAAc,kBAAkB,YAAY,cAAc;AAChE;;AAED,KAAI;EACH;EACA;EACA;EACA,CAAC,SAAS,UAAU,EAAE;EACtB,IAAI,cAAc;AAClB,8BAAe,iBAAiB,CAAE,KAAI;AACrC,iBAAc,qCAAe,kBAAkB,QAAQ;UAChD;EACR,MAAM,qBAAqBC,4CAAkB,aAAa,YAAY,WAAW;EACjF,MAAM,UAAU,cAAc,QAAQ;AACtC,MAAI,QAAS,mCAAY,SAAS,EAAE,WAAW,MAAM,CAAC;EACtD,MAAM,eAAe,2BAAY,iBAAiB,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC;EACxG,MAAM,WAAW,8BAAe,SAAS,aAAa,GAAG,GAAG,iBAAiB,GAAG;AAChF,MAAI;AACH,yCAAgB,UAAU,oBAAoB,QAAQ;AACtD,sCAAa,UAAU,iBAAiB;WAChC,OAAO;AACf,OAAI;AACH,mCAAS,UAAU,EAAE,OAAO,MAAM,CAAC;WAC5B;AACR,SAAM;;EAEP,MAAM,gBAAgBC,gDAAoB,cAAc;AACxD,MAAI,cAAe,KAAI;AACtB,oCAAS,cAAc,QAAQ,YAAY,iBAAiB,EAAE;IAC7D,OAAO;IACP,KAAK,cAAc,OAAO;IAC1B,CAAC;WACM,OAAO;AACf,WAAQ,MAAM,MAAM;;AAErB;;AAED,KAAI,CAAC,IAAI,IAAI;EACZ;EACA;EACA;EACA;EACA;EACA;EACA,CAAC,CAAC,IAAI,UAAU,CAAE;AACnB,OAAMC,gCAAY,kBAAkB,YAAY,eAAe,WAAW;AAC1E,KAAI;AACH,qDAAc,cAAc,OAAO,UAAU,yBAAyB,EAAE,EAAE,WAAW,MAAM,CAAC;SACrF"}
@@ -0,0 +1,163 @@
1
+ import { readDictionariesFromDisk } from "../utils/readDictionariesFromDisk.mjs";
2
+ import { getFilteredLocalesDictionary } from "../../../../core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs";
3
+ import { getPerLocaleDictionary } from "../../../../core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs";
4
+ import { getFormatFromExtension } from "../utils/getFormatFromExtension.mjs";
5
+ import { detectFormatCommand } from "../detectFormatCommand.mjs";
6
+ import { writeJSFile } from "./writeJSFile.mjs";
7
+ import { processContentDeclarationContent } from "./processContentDeclarationContent.mjs";
8
+ import { transformJSONFile } from "./transformJSONFile.mjs";
9
+ import { writeMarkdownFile } from "./writeMarkdownFile.mjs";
10
+ import { writeYamlFile } from "./writeYamlFile.mjs";
11
+ import { basename, dirname, extname, join, resolve } from "node:path";
12
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
13
+ import { existsSync } from "node:fs";
14
+ import { COMPILER_NO_METADATA } from "@intlayer/config/defaultValues";
15
+ import { execSync } from "node:child_process";
16
+ import { isDeepStrictEqual } from "node:util";
17
+
18
+ //#region ../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs
19
+ const formatContentDeclaration = async (dictionary, configuration, localeList) => {
20
+ /**
21
+ * Clean Markdown, Insertion, File, etc. node metadata
22
+ */
23
+ const processedDictionary = await processContentDeclarationContent(dictionary);
24
+ let content = processedDictionary.content;
25
+ /**
26
+ * Filter locales content
27
+ */
28
+ if (dictionary.locale) content = getPerLocaleDictionary(processedDictionary, dictionary.locale).content;
29
+ else if (localeList) content = getFilteredLocalesDictionary(processedDictionary, localeList).content;
30
+ let pluginFormatResult = {
31
+ ...dictionary,
32
+ content
33
+ };
34
+ /**
35
+ * Format the dictionary with the plugins
36
+ */
37
+ for await (const plugin of configuration.plugins ?? []) if (plugin.formatOutput) {
38
+ const formattedResult = await plugin.formatOutput?.({
39
+ dictionary: pluginFormatResult,
40
+ configuration
41
+ });
42
+ if (formattedResult) pluginFormatResult = formattedResult;
43
+ }
44
+ if (!(pluginFormatResult.content && pluginFormatResult.key)) return pluginFormatResult;
45
+ const INTERNAL_FIELDS = new Set([
46
+ "$schema",
47
+ "filePath",
48
+ "localId",
49
+ "localIds",
50
+ "projectIds"
51
+ ]);
52
+ let result = {
53
+ ...Object.fromEntries(Object.entries(dictionary).filter(([k]) => !INTERNAL_FIELDS.has(k))),
54
+ content
55
+ };
56
+ if (getFormatFromExtension(dictionary.filePath ? extname(dictionary.filePath) : ".json") === "json" && pluginFormatResult.content && pluginFormatResult.key) result = {
57
+ $schema: "https://intlayer.org/schema.json",
58
+ ...result
59
+ };
60
+ return result;
61
+ };
62
+ const defaultOptions = { newDictionariesPath: "intlayer-dictionaries" };
63
+ const writeContentDeclaration = async (dictionary, configuration, options) => {
64
+ const { system, compiler } = configuration;
65
+ const { baseDir } = system;
66
+ const noMetadata = compiler?.noMetadata ?? COMPILER_NO_METADATA;
67
+ const { newDictionariesPath, localeList } = {
68
+ ...defaultOptions,
69
+ ...options
70
+ };
71
+ const newDictionaryLocationPath = join(baseDir, newDictionariesPath);
72
+ const existingDictionary = readDictionariesFromDisk(configuration.system.unmergedDictionariesDir)[dictionary.key]?.find((el) => el.localId === dictionary.localId);
73
+ const formattedContentDeclaration = await formatContentDeclaration(dictionary, configuration, localeList);
74
+ if (existingDictionary?.filePath) {
75
+ const isSameContent = isDeepStrictEqual(existingDictionary, dictionary);
76
+ const filePath = resolve(configuration.system.baseDir, existingDictionary.filePath);
77
+ if (isSameContent) return {
78
+ status: "up-to-date",
79
+ path: filePath
80
+ };
81
+ await writeFileWithDirectories(filePath, formattedContentDeclaration, configuration, noMetadata);
82
+ return {
83
+ status: "updated",
84
+ path: filePath
85
+ };
86
+ }
87
+ if (dictionary.filePath) {
88
+ const filePath = resolve(configuration.system.baseDir, dictionary.filePath);
89
+ await writeFileWithDirectories(filePath, formattedContentDeclaration, configuration, noMetadata);
90
+ return {
91
+ status: "created",
92
+ path: filePath
93
+ };
94
+ }
95
+ const contentDeclarationPath = join(newDictionaryLocationPath, `${dictionary.key}.content.json`);
96
+ await writeFileWithDirectories(contentDeclarationPath, formattedContentDeclaration, configuration, noMetadata);
97
+ return {
98
+ status: "imported",
99
+ path: contentDeclarationPath
100
+ };
101
+ };
102
+ const writeFileWithDirectories = async (absoluteFilePath, dictionary, configuration, noMetadata) => {
103
+ await mkdir(dirname(absoluteFilePath), { recursive: true });
104
+ const extension = extname(absoluteFilePath);
105
+ if (extension === ".md" || extension === ".mdx") {
106
+ await writeMarkdownFile(absoluteFilePath, dictionary, configuration);
107
+ return;
108
+ }
109
+ if (extension === ".yaml" || extension === ".yml") {
110
+ await writeYamlFile(absoluteFilePath, dictionary, configuration);
111
+ return;
112
+ }
113
+ if ([
114
+ ".json",
115
+ ".jsonc",
116
+ ".json5"
117
+ ].includes(extension)) {
118
+ let fileContent = "{}";
119
+ if (existsSync(absoluteFilePath)) try {
120
+ fileContent = await readFile(absoluteFilePath, "utf-8");
121
+ } catch {}
122
+ const transformedContent = transformJSONFile(fileContent, dictionary, noMetadata);
123
+ const tempDir = configuration.system?.tempDir;
124
+ if (tempDir) await mkdir(tempDir, { recursive: true });
125
+ const tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
126
+ const tempPath = tempDir ? join(tempDir, tempFileName) : `${absoluteFilePath}.${tempFileName}`;
127
+ try {
128
+ await writeFile(tempPath, transformedContent, "utf-8");
129
+ await rename(tempPath, absoluteFilePath);
130
+ } catch (error) {
131
+ try {
132
+ await rm(tempPath, { force: true });
133
+ } catch {}
134
+ throw error;
135
+ }
136
+ const formatCommand = detectFormatCommand(configuration);
137
+ if (formatCommand) try {
138
+ execSync(formatCommand.replace("{{file}}", absoluteFilePath), {
139
+ stdio: "inherit",
140
+ cwd: configuration.system.baseDir
141
+ });
142
+ } catch (error) {
143
+ console.error(error);
144
+ }
145
+ return;
146
+ }
147
+ if (!new Set([
148
+ ".ts",
149
+ ".tsx",
150
+ ".js",
151
+ ".jsx",
152
+ ".mjs",
153
+ ".cjs"
154
+ ]).has(extension)) return;
155
+ await writeJSFile(absoluteFilePath, dictionary, configuration, noMetadata);
156
+ try {
157
+ await rm(join(configuration.system.cacheDir, "intlayer-prepared.lock"), { recursive: true });
158
+ } catch {}
159
+ };
160
+
161
+ //#endregion
162
+ export { writeContentDeclaration };
163
+ //# sourceMappingURL=writeContentDeclaration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeContentDeclaration.mjs","names":[],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs"],"sourcesContent":["import { readDictionariesFromDisk } from \"../utils/readDictionariesFromDisk.mjs\";\nimport { getFormatFromExtension } from \"../utils/getFormatFromExtension.mjs\";\nimport { detectFormatCommand } from \"../detectFormatCommand.mjs\";\nimport { processContentDeclarationContent } from \"./processContentDeclarationContent.mjs\";\nimport { transformJSONFile } from \"./transformJSONFile.mjs\";\nimport { writeJSFile } from \"./writeJSFile.mjs\";\nimport { writeMarkdownFile } from \"./writeMarkdownFile.mjs\";\nimport { writeYamlFile } from \"./writeYamlFile.mjs\";\nimport { mkdir, readFile, rename, rm, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, extname, join, resolve } from \"node:path\";\nimport { existsSync } from \"node:fs\";\nimport { COMPILER_NO_METADATA } from \"@intlayer/config/defaultValues\";\nimport { getFilteredLocalesDictionary, getPerLocaleDictionary } from \"@intlayer/core/plugins\";\nimport { execSync } from \"node:child_process\";\nimport { isDeepStrictEqual } from \"node:util\";\n\n//#region src/writeContentDeclaration/writeContentDeclaration.ts\nconst formatContentDeclaration = async (dictionary, configuration, localeList) => {\n\t/**\n\t* Clean Markdown, Insertion, File, etc. node metadata\n\t*/\n\tconst processedDictionary = await processContentDeclarationContent(dictionary);\n\tlet content = processedDictionary.content;\n\t/**\n\t* Filter locales content\n\t*/\n\tif (dictionary.locale) content = getPerLocaleDictionary(processedDictionary, dictionary.locale).content;\n\telse if (localeList) content = getFilteredLocalesDictionary(processedDictionary, localeList).content;\n\tlet pluginFormatResult = {\n\t\t...dictionary,\n\t\tcontent\n\t};\n\t/**\n\t* Format the dictionary with the plugins\n\t*/\n\tfor await (const plugin of configuration.plugins ?? []) if (plugin.formatOutput) {\n\t\tconst formattedResult = await plugin.formatOutput?.({\n\t\t\tdictionary: pluginFormatResult,\n\t\t\tconfiguration\n\t\t});\n\t\tif (formattedResult) pluginFormatResult = formattedResult;\n\t}\n\tif (!(pluginFormatResult.content && pluginFormatResult.key)) return pluginFormatResult;\n\tconst INTERNAL_FIELDS = new Set([\n\t\t\"$schema\",\n\t\t\"filePath\",\n\t\t\"localId\",\n\t\t\"localIds\",\n\t\t\"projectIds\"\n\t]);\n\tlet result = {\n\t\t...Object.fromEntries(Object.entries(dictionary).filter(([k]) => !INTERNAL_FIELDS.has(k))),\n\t\tcontent\n\t};\n\tif (getFormatFromExtension(dictionary.filePath ? extname(dictionary.filePath) : \".json\") === \"json\" && pluginFormatResult.content && pluginFormatResult.key) result = {\n\t\t$schema: \"https://intlayer.org/schema.json\",\n\t\t...result\n\t};\n\treturn result;\n};\nconst defaultOptions = { newDictionariesPath: \"intlayer-dictionaries\" };\nconst writeContentDeclaration = async (dictionary, configuration, options) => {\n\tconst { system, compiler } = configuration;\n\tconst { baseDir } = system;\n\tconst noMetadata = compiler?.noMetadata ?? COMPILER_NO_METADATA;\n\tconst { newDictionariesPath, localeList } = {\n\t\t...defaultOptions,\n\t\t...options\n\t};\n\tconst newDictionaryLocationPath = join(baseDir, newDictionariesPath);\n\tconst existingDictionary = readDictionariesFromDisk(configuration.system.unmergedDictionariesDir)[dictionary.key]?.find((el) => el.localId === dictionary.localId);\n\tconst formattedContentDeclaration = await formatContentDeclaration(dictionary, configuration, localeList);\n\tif (existingDictionary?.filePath) {\n\t\tconst isSameContent = isDeepStrictEqual(existingDictionary, dictionary);\n\t\tconst filePath = resolve(configuration.system.baseDir, existingDictionary.filePath);\n\t\tif (isSameContent) return {\n\t\t\tstatus: \"up-to-date\",\n\t\t\tpath: filePath\n\t\t};\n\t\tawait writeFileWithDirectories(filePath, formattedContentDeclaration, configuration, noMetadata);\n\t\treturn {\n\t\t\tstatus: \"updated\",\n\t\t\tpath: filePath\n\t\t};\n\t}\n\tif (dictionary.filePath) {\n\t\tconst filePath = resolve(configuration.system.baseDir, dictionary.filePath);\n\t\tawait writeFileWithDirectories(filePath, formattedContentDeclaration, configuration, noMetadata);\n\t\treturn {\n\t\t\tstatus: \"created\",\n\t\t\tpath: filePath\n\t\t};\n\t}\n\tconst contentDeclarationPath = join(newDictionaryLocationPath, `${dictionary.key}.content.json`);\n\tawait writeFileWithDirectories(contentDeclarationPath, formattedContentDeclaration, configuration, noMetadata);\n\treturn {\n\t\tstatus: \"imported\",\n\t\tpath: contentDeclarationPath\n\t};\n};\nconst writeFileWithDirectories = async (absoluteFilePath, dictionary, configuration, noMetadata) => {\n\tawait mkdir(dirname(absoluteFilePath), { recursive: true });\n\tconst extension = extname(absoluteFilePath);\n\tif (extension === \".md\" || extension === \".mdx\") {\n\t\tawait writeMarkdownFile(absoluteFilePath, dictionary, configuration);\n\t\treturn;\n\t}\n\tif (extension === \".yaml\" || extension === \".yml\") {\n\t\tawait writeYamlFile(absoluteFilePath, dictionary, configuration);\n\t\treturn;\n\t}\n\tif ([\n\t\t\".json\",\n\t\t\".jsonc\",\n\t\t\".json5\"\n\t].includes(extension)) {\n\t\tlet fileContent = \"{}\";\n\t\tif (existsSync(absoluteFilePath)) try {\n\t\t\tfileContent = await readFile(absoluteFilePath, \"utf-8\");\n\t\t} catch {}\n\t\tconst transformedContent = transformJSONFile(fileContent, dictionary, noMetadata);\n\t\tconst tempDir = configuration.system?.tempDir;\n\t\tif (tempDir) await mkdir(tempDir, { recursive: true });\n\t\tconst tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n\t\tconst tempPath = tempDir ? join(tempDir, tempFileName) : `${absoluteFilePath}.${tempFileName}`;\n\t\ttry {\n\t\t\tawait writeFile(tempPath, transformedContent, \"utf-8\");\n\t\t\tawait rename(tempPath, absoluteFilePath);\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\tawait rm(tempPath, { force: true });\n\t\t\t} catch {}\n\t\t\tthrow error;\n\t\t}\n\t\tconst formatCommand = detectFormatCommand(configuration);\n\t\tif (formatCommand) try {\n\t\t\texecSync(formatCommand.replace(\"{{file}}\", absoluteFilePath), {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t\tcwd: configuration.system.baseDir\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t\treturn;\n\t}\n\tif (!new Set([\n\t\t\".ts\",\n\t\t\".tsx\",\n\t\t\".js\",\n\t\t\".jsx\",\n\t\t\".mjs\",\n\t\t\".cjs\"\n\t]).has(extension)) return;\n\tawait writeJSFile(absoluteFilePath, dictionary, configuration, noMetadata);\n\ttry {\n\t\tawait rm(join(configuration.system.cacheDir, \"intlayer-prepared.lock\"), { recursive: true });\n\t} catch {}\n};\n\n//#endregion\nexport { writeContentDeclaration };\n//# sourceMappingURL=writeContentDeclaration.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAM,2BAA2B,OAAO,YAAY,eAAe,eAAe;;;;CAIjF,MAAM,sBAAsB,MAAM,iCAAiC,WAAW;CAC9E,IAAI,UAAU,oBAAoB;;;;AAIlC,KAAI,WAAW,OAAQ,WAAU,uBAAuB,qBAAqB,WAAW,OAAO,CAAC;UACvF,WAAY,WAAU,6BAA6B,qBAAqB,WAAW,CAAC;CAC7F,IAAI,qBAAqB;EACxB,GAAG;EACH;EACA;;;;AAID,YAAW,MAAM,UAAU,cAAc,WAAW,EAAE,CAAE,KAAI,OAAO,cAAc;EAChF,MAAM,kBAAkB,MAAM,OAAO,eAAe;GACnD,YAAY;GACZ;GACA,CAAC;AACF,MAAI,gBAAiB,sBAAqB;;AAE3C,KAAI,EAAE,mBAAmB,WAAW,mBAAmB,KAAM,QAAO;CACpE,MAAM,kBAAkB,IAAI,IAAI;EAC/B;EACA;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,CAAC;WACM,OAAO;AACf,WAAQ,MAAM,MAAM;;AAErB;;AAED,KAAI,CAAC,IAAI,IAAI;EACZ;EACA;EACA;EACA;EACA;EACA;EACA,CAAC,CAAC,IAAI,UAAU,CAAE;AACnB,OAAM,YAAY,kBAAkB,YAAY,eAAe,WAAW;AAC1E,KAAI;AACH,QAAM,GAAG,KAAK,cAAc,OAAO,UAAU,yBAAyB,EAAE,EAAE,WAAW,MAAM,CAAC;SACrF"}
@@ -0,0 +1,92 @@
1
+ const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
2
+ const require_transformJSFile = require('./transformJSFile.cjs');
3
+ const require_getFormatFromExtension = require('../utils/getFormatFromExtension.cjs');
4
+ const require_detectFormatCommand = require('../detectFormatCommand.cjs');
5
+ const require_getContentDeclarationFileTemplate = require('../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs');
6
+ let node_path = require("node:path");
7
+ let node_fs_promises = require("node:fs/promises");
8
+ let node_fs = require("node:fs");
9
+ let _intlayer_config_logger = require("@intlayer/config/logger");
10
+ let node_child_process = require("node:child_process");
11
+
12
+ //#region ../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.mjs
13
+ /**
14
+ * Updates a JavaScript/TypeScript file based on the provided JSON instructions.
15
+ * It targets a specific dictionary object within the file (identified by its 'key' property)
16
+ * and updates its 'content' entries. Currently, it focuses on modifying arguments
17
+ * of 't' (translation) function calls.
18
+ */
19
+ const writeJSFile = async (filePath, dictionary, configuration, noMetadata) => {
20
+ const mergedDictionary = {
21
+ ...configuration.dictionary,
22
+ ...dictionary
23
+ };
24
+ const appLogger = (0, _intlayer_config_logger.getAppLogger)(configuration);
25
+ if (!(0, node_fs.existsSync)(filePath)) {
26
+ const format = require_getFormatFromExtension.getFormatFromExtension((0, node_path.extname)(filePath));
27
+ appLogger("File does not exist, creating it", { isVerbose: true });
28
+ const template = await require_getContentDeclarationFileTemplate.getContentDeclarationFileTemplate(mergedDictionary.key, format, Object.fromEntries(Object.entries({
29
+ id: noMetadata ? void 0 : mergedDictionary.id,
30
+ locale: noMetadata ? void 0 : mergedDictionary.locale,
31
+ filled: noMetadata ? void 0 : mergedDictionary.filled,
32
+ fill: noMetadata ? void 0 : mergedDictionary.fill,
33
+ description: noMetadata ? void 0 : mergedDictionary.description,
34
+ title: noMetadata ? void 0 : mergedDictionary.title,
35
+ tags: noMetadata ? void 0 : mergedDictionary.tags,
36
+ version: noMetadata ? void 0 : mergedDictionary.version,
37
+ priority: noMetadata ? void 0 : mergedDictionary.priority,
38
+ importMode: noMetadata ? void 0 : mergedDictionary.importMode
39
+ }).filter(([, value]) => value !== void 0)), noMetadata);
40
+ const tempDir = configuration.system?.tempDir;
41
+ if (tempDir) await (0, node_fs_promises.mkdir)(tempDir, { recursive: true });
42
+ const tempFileName = `${(0, node_path.basename)(filePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
43
+ const tempPath = tempDir ? (0, node_path.join)(tempDir, tempFileName) : `${filePath}.${tempFileName}`;
44
+ try {
45
+ await (0, node_fs_promises.writeFile)(tempPath, template, "utf-8");
46
+ await (0, node_fs_promises.rename)(tempPath, filePath);
47
+ } catch (error) {
48
+ try {
49
+ await (0, node_fs_promises.rm)(tempPath, { force: true });
50
+ } catch {}
51
+ throw error;
52
+ }
53
+ }
54
+ let fileContent = await (0, node_fs_promises.readFile)(filePath, "utf-8");
55
+ if (fileContent === "") {
56
+ const format = require_getFormatFromExtension.getFormatFromExtension((0, node_path.extname)(filePath));
57
+ fileContent = await require_getContentDeclarationFileTemplate.getContentDeclarationFileTemplate(mergedDictionary.key, format, {}, noMetadata);
58
+ }
59
+ const finalCode = await require_transformJSFile.transformJSFile(fileContent, dictionary, dictionary.locale, noMetadata);
60
+ const tempDir = configuration.system?.tempDir;
61
+ if (tempDir) await (0, node_fs_promises.mkdir)(tempDir, { recursive: true });
62
+ const tempFileName = `${(0, node_path.basename)(filePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
63
+ const tempPath = tempDir ? (0, node_path.join)(tempDir, tempFileName) : `${filePath}.${tempFileName}`;
64
+ try {
65
+ await (0, node_fs_promises.writeFile)(tempPath, finalCode, "utf-8");
66
+ await (0, node_fs_promises.rename)(tempPath, filePath);
67
+ (0, _intlayer_config_logger.logger)(`Successfully updated ${filePath}`, {
68
+ level: "info",
69
+ isVerbose: true
70
+ });
71
+ } catch (error) {
72
+ try {
73
+ await (0, node_fs_promises.rm)(tempPath, { force: true });
74
+ } catch {}
75
+ const err = error;
76
+ (0, _intlayer_config_logger.logger)(`Failed to write updated file: ${filePath}`, { level: "error" });
77
+ throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);
78
+ }
79
+ const formatCommand = require_detectFormatCommand.detectFormatCommand(configuration);
80
+ if (formatCommand) try {
81
+ (0, node_child_process.execSync)(formatCommand.replace("{{file}}", filePath), {
82
+ stdio: "inherit",
83
+ cwd: configuration.system.baseDir
84
+ });
85
+ } catch (error) {
86
+ console.error(error);
87
+ }
88
+ };
89
+
90
+ //#endregion
91
+ exports.writeJSFile = writeJSFile;
92
+ //# sourceMappingURL=writeJSFile.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeJSFile.cjs","names":["getFormatFromExtension","getContentDeclarationFileTemplate","transformJSFile","detectFormatCommand"],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.mjs"],"sourcesContent":["import { getFormatFromExtension } from \"../utils/getFormatFromExtension.mjs\";\nimport { transformJSFile } from \"./transformJSFile.mjs\";\nimport { detectFormatCommand } from \"../detectFormatCommand.mjs\";\nimport { getContentDeclarationFileTemplate } from \"../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs\";\nimport { mkdir, readFile, rename, rm, writeFile } from \"node:fs/promises\";\nimport { basename, extname, join } from \"node:path\";\nimport { getAppLogger, logger } from \"@intlayer/config/logger\";\nimport { existsSync } from \"node:fs\";\nimport { execSync } from \"node:child_process\";\n\n//#region src/writeContentDeclaration/writeJSFile.ts\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*/\nconst writeJSFile = async (filePath, dictionary, configuration, noMetadata) => {\n\tconst mergedDictionary = {\n\t\t...configuration.dictionary,\n\t\t...dictionary\n\t};\n\tconst appLogger = getAppLogger(configuration);\n\tif (!existsSync(filePath)) {\n\t\tconst format = getFormatFromExtension(extname(filePath));\n\t\tappLogger(\"File does not exist, creating it\", { isVerbose: true });\n\t\tconst template = await getContentDeclarationFileTemplate(mergedDictionary.key, format, Object.fromEntries(Object.entries({\n\t\t\tid: noMetadata ? void 0 : mergedDictionary.id,\n\t\t\tlocale: noMetadata ? void 0 : mergedDictionary.locale,\n\t\t\tfilled: noMetadata ? void 0 : mergedDictionary.filled,\n\t\t\tfill: noMetadata ? void 0 : mergedDictionary.fill,\n\t\t\tdescription: noMetadata ? void 0 : mergedDictionary.description,\n\t\t\ttitle: noMetadata ? void 0 : mergedDictionary.title,\n\t\t\ttags: noMetadata ? void 0 : mergedDictionary.tags,\n\t\t\tversion: noMetadata ? void 0 : mergedDictionary.version,\n\t\t\tpriority: noMetadata ? void 0 : mergedDictionary.priority,\n\t\t\timportMode: noMetadata ? void 0 : mergedDictionary.importMode\n\t\t}).filter(([, value]) => value !== void 0)), noMetadata);\n\t\tconst tempDir = configuration.system?.tempDir;\n\t\tif (tempDir) await mkdir(tempDir, { recursive: true });\n\t\tconst tempFileName = `${basename(filePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n\t\tconst tempPath = tempDir ? join(tempDir, tempFileName) : `${filePath}.${tempFileName}`;\n\t\ttry {\n\t\t\tawait writeFile(tempPath, template, \"utf-8\");\n\t\t\tawait rename(tempPath, filePath);\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\tawait rm(tempPath, { force: true });\n\t\t\t} catch {}\n\t\t\tthrow error;\n\t\t}\n\t}\n\tlet fileContent = await readFile(filePath, \"utf-8\");\n\tif (fileContent === \"\") {\n\t\tconst format = getFormatFromExtension(extname(filePath));\n\t\tfileContent = await getContentDeclarationFileTemplate(mergedDictionary.key, format, {}, noMetadata);\n\t}\n\tconst finalCode = await transformJSFile(fileContent, dictionary, dictionary.locale, noMetadata);\n\tconst tempDir = configuration.system?.tempDir;\n\tif (tempDir) await mkdir(tempDir, { recursive: true });\n\tconst tempFileName = `${basename(filePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n\tconst tempPath = tempDir ? join(tempDir, tempFileName) : `${filePath}.${tempFileName}`;\n\ttry {\n\t\tawait writeFile(tempPath, finalCode, \"utf-8\");\n\t\tawait rename(tempPath, filePath);\n\t\tlogger(`Successfully updated ${filePath}`, {\n\t\t\tlevel: \"info\",\n\t\t\tisVerbose: true\n\t\t});\n\t} catch (error) {\n\t\ttry {\n\t\t\tawait rm(tempPath, { force: true });\n\t\t} catch {}\n\t\tconst err = error;\n\t\tlogger(`Failed to write updated file: ${filePath}`, { level: \"error\" });\n\t\tthrow new Error(`Failed to write updated file ${filePath}: ${err.message}`);\n\t}\n\tconst formatCommand = detectFormatCommand(configuration);\n\tif (formatCommand) try {\n\t\texecSync(formatCommand.replace(\"{{file}}\", filePath), {\n\t\t\tstdio: \"inherit\",\n\t\t\tcwd: configuration.system.baseDir\n\t\t});\n\t} catch (error) {\n\t\tconsole.error(error);\n\t}\n};\n\n//#endregion\nexport { writeJSFile };\n//# sourceMappingURL=writeJSFile.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAM,cAAc,OAAO,UAAU,YAAY,eAAe,eAAe;CAC9E,MAAM,mBAAmB;EACxB,GAAG,cAAc;EACjB,GAAG;EACH;CACD,MAAM,sDAAyB,cAAc;AAC7C,KAAI,yBAAY,SAAS,EAAE;EAC1B,MAAM,SAASA,6EAA+B,SAAS,CAAC;AACxD,YAAU,oCAAoC,EAAE,WAAW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