intlayer-editor 8.12.1 → 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-DPTR7zkl.js → CodeBlockClient-BQMC5gqu.js} +3 -3
  2. package/client/dist/assets/{CodeBlockShiki-D1gLOqNZ.js → CodeBlockShiki-DB7ndrOR.js} +2 -2
  3. package/client/dist/assets/{MarkDownRender-Dieny2mT.js → MarkDownRender-BQwPctN-.js} +3 -3
  4. package/client/dist/assets/{bundle-web-C6qOstkL.js → bundle-web-C4HpQhJS.js} +1 -1
  5. package/client/dist/assets/{dist-Uia0doeb.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 +18 -18
  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-sNIxTlYK.js +0 -185
  158. package/client/dist/assets/purify.es-Dt2VzQ8a.js +0 -3
@@ -0,0 +1,91 @@
1
+ import { transformJSFile } from "./transformJSFile.mjs";
2
+ import { getFormatFromExtension } from "../utils/getFormatFromExtension.mjs";
3
+ import { detectFormatCommand } from "../detectFormatCommand.mjs";
4
+ import { getContentDeclarationFileTemplate } from "../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";
5
+ import { basename, extname, join } from "node:path";
6
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
7
+ import { existsSync } from "node:fs";
8
+ import { getAppLogger, logger } from "@intlayer/config/logger";
9
+ import { execSync } from "node:child_process";
10
+
11
+ //#region ../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.mjs
12
+ /**
13
+ * Updates a JavaScript/TypeScript file based on the provided JSON instructions.
14
+ * It targets a specific dictionary object within the file (identified by its 'key' property)
15
+ * and updates its 'content' entries. Currently, it focuses on modifying arguments
16
+ * of 't' (translation) function calls.
17
+ */
18
+ const writeJSFile = async (filePath, dictionary, configuration, noMetadata) => {
19
+ const mergedDictionary = {
20
+ ...configuration.dictionary,
21
+ ...dictionary
22
+ };
23
+ const appLogger = getAppLogger(configuration);
24
+ if (!existsSync(filePath)) {
25
+ const format = getFormatFromExtension(extname(filePath));
26
+ appLogger("File does not exist, creating it", { isVerbose: true });
27
+ const template = await getContentDeclarationFileTemplate(mergedDictionary.key, format, Object.fromEntries(Object.entries({
28
+ id: noMetadata ? void 0 : mergedDictionary.id,
29
+ locale: noMetadata ? void 0 : mergedDictionary.locale,
30
+ filled: noMetadata ? void 0 : mergedDictionary.filled,
31
+ fill: noMetadata ? void 0 : mergedDictionary.fill,
32
+ description: noMetadata ? void 0 : mergedDictionary.description,
33
+ title: noMetadata ? void 0 : mergedDictionary.title,
34
+ tags: noMetadata ? void 0 : mergedDictionary.tags,
35
+ version: noMetadata ? void 0 : mergedDictionary.version,
36
+ priority: noMetadata ? void 0 : mergedDictionary.priority,
37
+ importMode: noMetadata ? void 0 : mergedDictionary.importMode
38
+ }).filter(([, value]) => value !== void 0)), noMetadata);
39
+ const tempDir = configuration.system?.tempDir;
40
+ if (tempDir) await mkdir(tempDir, { recursive: true });
41
+ const tempFileName = `${basename(filePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
42
+ const tempPath = tempDir ? join(tempDir, tempFileName) : `${filePath}.${tempFileName}`;
43
+ try {
44
+ await writeFile(tempPath, template, "utf-8");
45
+ await rename(tempPath, filePath);
46
+ } catch (error) {
47
+ try {
48
+ await rm(tempPath, { force: true });
49
+ } catch {}
50
+ throw error;
51
+ }
52
+ }
53
+ let fileContent = await readFile(filePath, "utf-8");
54
+ if (fileContent === "") {
55
+ const format = getFormatFromExtension(extname(filePath));
56
+ fileContent = await getContentDeclarationFileTemplate(mergedDictionary.key, format, {}, noMetadata);
57
+ }
58
+ const finalCode = await transformJSFile(fileContent, dictionary, dictionary.locale, noMetadata);
59
+ const tempDir = configuration.system?.tempDir;
60
+ if (tempDir) await mkdir(tempDir, { recursive: true });
61
+ const tempFileName = `${basename(filePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
62
+ const tempPath = tempDir ? join(tempDir, tempFileName) : `${filePath}.${tempFileName}`;
63
+ try {
64
+ await writeFile(tempPath, finalCode, "utf-8");
65
+ await rename(tempPath, filePath);
66
+ logger(`Successfully updated ${filePath}`, {
67
+ level: "info",
68
+ isVerbose: true
69
+ });
70
+ } catch (error) {
71
+ try {
72
+ await rm(tempPath, { force: true });
73
+ } catch {}
74
+ const err = error;
75
+ logger(`Failed to write updated file: ${filePath}`, { level: "error" });
76
+ throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);
77
+ }
78
+ const formatCommand = detectFormatCommand(configuration);
79
+ if (formatCommand) try {
80
+ execSync(formatCommand.replace("{{file}}", filePath), {
81
+ stdio: "inherit",
82
+ cwd: configuration.system.baseDir
83
+ });
84
+ } catch (error) {
85
+ console.error(error);
86
+ }
87
+ };
88
+
89
+ //#endregion
90
+ export { writeJSFile };
91
+ //# sourceMappingURL=writeJSFile.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeJSFile.mjs","names":[],"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,YAAY,aAAa,cAAc;AAC7C,KAAI,CAAC,WAAW,SAAS,EAAE;EAC1B,MAAM,SAAS,uBAAuB,QAAQ,SAAS,CAAC;AACxD,YAAU,oCAAoC,EAAE,WAAW,MAAM,CAAC;EAClE,MAAM,WAAW,MAAM,kCAAkC,iBAAiB,KAAK,QAAQ,OAAO,YAAY,OAAO,QAAQ;GACxH,IAAI,aAAa,KAAK,IAAI,iBAAiB;GAC3C,QAAQ,aAAa,KAAK,IAAI,iBAAiB;GAC/C,QAAQ,aAAa,KAAK,IAAI,iBAAiB;GAC/C,MAAM,aAAa,KAAK,IAAI,iBAAiB;GAC7C,aAAa,aAAa,KAAK,IAAI,iBAAiB;GACpD,OAAO,aAAa,KAAK,IAAI,iBAAiB;GAC9C,MAAM,aAAa,KAAK,IAAI,iBAAiB;GAC7C,SAAS,aAAa,KAAK,IAAI,iBAAiB;GAChD,UAAU,aAAa,KAAK,IAAI,iBAAiB;GACjD,YAAY,aAAa,KAAK,IAAI,iBAAiB;GACnD,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAK,EAAE,CAAC,EAAE,WAAW;EACxD,MAAM,UAAU,cAAc,QAAQ;AACtC,MAAI,QAAS,OAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;EACtD,MAAM,eAAe,GAAG,SAAS,SAAS,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC;EAChG,MAAM,WAAW,UAAU,KAAK,SAAS,aAAa,GAAG,GAAG,SAAS,GAAG;AACxE,MAAI;AACH,SAAM,UAAU,UAAU,UAAU,QAAQ;AAC5C,SAAM,OAAO,UAAU,SAAS;WACxB,OAAO;AACf,OAAI;AACH,UAAM,GAAG,UAAU,EAAE,OAAO,MAAM,CAAC;WAC5B;AACR,SAAM;;;CAGR,IAAI,cAAc,MAAM,SAAS,UAAU,QAAQ;AACnD,KAAI,gBAAgB,IAAI;EACvB,MAAM,SAAS,uBAAuB,QAAQ,SAAS,CAAC;AACxD,gBAAc,MAAM,kCAAkC,iBAAiB,KAAK,QAAQ,EAAE,EAAE,WAAW;;CAEpG,MAAM,YAAY,MAAM,gBAAgB,aAAa,YAAY,WAAW,QAAQ,WAAW;CAC/F,MAAM,UAAU,cAAc,QAAQ;AACtC,KAAI,QAAS,OAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;CACtD,MAAM,eAAe,GAAG,SAAS,SAAS,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC;CAChG,MAAM,WAAW,UAAU,KAAK,SAAS,aAAa,GAAG,GAAG,SAAS,GAAG;AACxE,KAAI;AACH,QAAM,UAAU,UAAU,WAAW,QAAQ;AAC7C,QAAM,OAAO,UAAU,SAAS;AAChC,SAAO,wBAAwB,YAAY;GAC1C,OAAO;GACP,WAAW;GACX,CAAC;UACM,OAAO;AACf,MAAI;AACH,SAAM,GAAG,UAAU,EAAE,OAAO,MAAM,CAAC;UAC5B;EACR,MAAM,MAAM;AACZ,SAAO,iCAAiC,YAAY,EAAE,OAAO,SAAS,CAAC;AACvE,QAAM,IAAI,MAAM,gCAAgC,SAAS,IAAI,IAAI,UAAU;;CAE5E,MAAM,gBAAgB,oBAAoB,cAAc;AACxD,KAAI,cAAe,KAAI;AACtB,WAAS,cAAc,QAAQ,YAAY,SAAS,EAAE;GACrD,OAAO;GACP,KAAK,cAAc,OAAO;GAC1B,CAAC;UACM,OAAO;AACf,UAAQ,MAAM,MAAM"}
@@ -0,0 +1,65 @@
1
+ const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
2
+ const require_detectFormatCommand = require('../detectFormatCommand.cjs');
3
+ let node_path = require("node:path");
4
+ let node_fs_promises = require("node:fs/promises");
5
+ let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
6
+ let node_child_process = require("node:child_process");
7
+
8
+ //#region ../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs
9
+ const stringifyYamlFrontmatter = (fields) => Object.entries(fields).filter(([, value]) => value !== void 0 && value !== null).map(([key, value]) => {
10
+ if (Array.isArray(value)) return `${key}:\n${value.map((item) => ` - ${JSON.stringify(item)}`).join("\n")}`;
11
+ if (typeof value === "string" && (value.includes(":") || value.includes("\n") || value.includes("#"))) return `${key}: ${JSON.stringify(value)}`;
12
+ return `${key}: ${value}`;
13
+ }).join("\n");
14
+ const getMarkdownBody = (content) => {
15
+ const lines = content.split(/\r?\n/);
16
+ const firstNonEmptyIndex = lines.findIndex((line) => line.trim() !== "");
17
+ if (firstNonEmptyIndex === -1 || lines[firstNonEmptyIndex].trim() !== "---") return content;
18
+ let endIndex = -1;
19
+ for (let i = firstNonEmptyIndex + 1; i < lines.length; i++) if (lines[i].trim() === "---") {
20
+ endIndex = i;
21
+ break;
22
+ }
23
+ if (endIndex === -1) return content;
24
+ return lines.slice(endIndex + 1).join("\n").trimStart();
25
+ };
26
+ const EXCLUDED_FRONTMATTER_KEYS = new Set([
27
+ "content",
28
+ "$schema",
29
+ "filePath",
30
+ "localId",
31
+ "localIds",
32
+ "projectIds"
33
+ ]);
34
+ const writeMarkdownFile = async (absoluteFilePath, dictionary, configuration) => {
35
+ const content = dictionary.content;
36
+ const markdownBody = getMarkdownBody(typeof content === "object" && content?.nodeType === _intlayer_types_nodeType.MARKDOWN ? content[_intlayer_types_nodeType.MARKDOWN] ?? "" : "");
37
+ const fileContent = `---\n${stringifyYamlFrontmatter(Object.fromEntries(Object.entries(dictionary).filter(([k, v]) => !EXCLUDED_FRONTMATTER_KEYS.has(k) && v !== void 0)))}\n---\n\n${markdownBody}`;
38
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(absoluteFilePath), { recursive: true });
39
+ const tempDir = configuration.system?.tempDir;
40
+ if (tempDir) await (0, node_fs_promises.mkdir)(tempDir, { recursive: true });
41
+ const tempFileName = `${(0, node_path.basename)(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
42
+ const tempPath = tempDir ? (0, node_path.join)(tempDir, tempFileName) : `${absoluteFilePath}.${tempFileName}`;
43
+ try {
44
+ await (0, node_fs_promises.writeFile)(tempPath, fileContent, "utf-8");
45
+ await (0, node_fs_promises.rename)(tempPath, absoluteFilePath);
46
+ } catch (error) {
47
+ try {
48
+ await (0, node_fs_promises.rm)(tempPath, { force: true });
49
+ } catch {}
50
+ throw error;
51
+ }
52
+ const formatCommand = require_detectFormatCommand.detectFormatCommand(configuration);
53
+ if (formatCommand) try {
54
+ (0, node_child_process.execSync)(formatCommand.replace("{{file}}", absoluteFilePath), {
55
+ stdio: "inherit",
56
+ cwd: configuration.system.baseDir
57
+ });
58
+ } catch (error) {
59
+ console.error(error);
60
+ }
61
+ };
62
+
63
+ //#endregion
64
+ exports.writeMarkdownFile = writeMarkdownFile;
65
+ //# sourceMappingURL=writeMarkdownFile.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeMarkdownFile.cjs","names":["MARKDOWN","detectFormatCommand"],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs"],"sourcesContent":["import { detectFormatCommand } from \"../detectFormatCommand.mjs\";\nimport { mkdir, rename, rm, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, join } from \"node:path\";\nimport { MARKDOWN } from \"@intlayer/types/nodeType\";\nimport { execSync } from \"node:child_process\";\n\n//#region src/writeContentDeclaration/writeMarkdownFile.ts\nconst stringifyYamlFrontmatter = (fields) => Object.entries(fields).filter(([, value]) => value !== void 0 && value !== null).map(([key, value]) => {\n\tif (Array.isArray(value)) return `${key}:\\n${value.map((item) => ` - ${JSON.stringify(item)}`).join(\"\\n\")}`;\n\tif (typeof value === \"string\" && (value.includes(\":\") || value.includes(\"\\n\") || value.includes(\"#\"))) return `${key}: ${JSON.stringify(value)}`;\n\treturn `${key}: ${value}`;\n}).join(\"\\n\");\nconst getMarkdownBody = (content) => {\n\tconst lines = content.split(/\\r?\\n/);\n\tconst firstNonEmptyIndex = lines.findIndex((line) => line.trim() !== \"\");\n\tif (firstNonEmptyIndex === -1 || lines[firstNonEmptyIndex].trim() !== \"---\") return content;\n\tlet endIndex = -1;\n\tfor (let i = firstNonEmptyIndex + 1; i < lines.length; i++) if (lines[i].trim() === \"---\") {\n\t\tendIndex = i;\n\t\tbreak;\n\t}\n\tif (endIndex === -1) return content;\n\treturn lines.slice(endIndex + 1).join(\"\\n\").trimStart();\n};\nconst EXCLUDED_FRONTMATTER_KEYS = new Set([\n\t\"content\",\n\t\"$schema\",\n\t\"filePath\",\n\t\"localId\",\n\t\"localIds\",\n\t\"projectIds\"\n]);\nconst writeMarkdownFile = async (absoluteFilePath, dictionary, configuration) => {\n\tconst content = dictionary.content;\n\tconst markdownBody = getMarkdownBody(typeof content === \"object\" && content?.nodeType === MARKDOWN ? content[MARKDOWN] ?? \"\" : \"\");\n\tconst fileContent = `---\\n${stringifyYamlFrontmatter(Object.fromEntries(Object.entries(dictionary).filter(([k, v]) => !EXCLUDED_FRONTMATTER_KEYS.has(k) && v !== void 0)))}\\n---\\n\\n${markdownBody}`;\n\tawait mkdir(dirname(absoluteFilePath), { recursive: true });\n\tconst tempDir = configuration.system?.tempDir;\n\tif (tempDir) await mkdir(tempDir, { recursive: true });\n\tconst tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n\tconst tempPath = tempDir ? join(tempDir, tempFileName) : `${absoluteFilePath}.${tempFileName}`;\n\ttry {\n\t\tawait writeFile(tempPath, fileContent, \"utf-8\");\n\t\tawait rename(tempPath, absoluteFilePath);\n\t} catch (error) {\n\t\ttry {\n\t\t\tawait rm(tempPath, { force: true });\n\t\t} catch {}\n\t\tthrow error;\n\t}\n\tconst formatCommand = detectFormatCommand(configuration);\n\tif (formatCommand) try {\n\t\texecSync(formatCommand.replace(\"{{file}}\", absoluteFilePath), {\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 { writeMarkdownFile };\n//# sourceMappingURL=writeMarkdownFile.mjs.map"],"mappings":";;;;;;;;AAOA,MAAM,4BAA4B,WAAW,OAAO,QAAQ,OAAO,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAK,KAAK,UAAU,KAAK,CAAC,KAAK,CAAC,KAAK,WAAW;AACnJ,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,GAAG,IAAI,KAAK,MAAM,KAAK,SAAS,OAAO,KAAK,UAAU,KAAK,GAAG,CAAC,KAAK,KAAK;AAC1G,KAAI,OAAO,UAAU,aAAa,MAAM,SAAS,IAAI,IAAI,MAAM,SAAS,KAAK,IAAI,MAAM,SAAS,IAAI,EAAG,QAAO,GAAG,IAAI,IAAI,KAAK,UAAU,MAAM;AAC9I,QAAO,GAAG,IAAI,IAAI;EACjB,CAAC,KAAK,KAAK;AACb,MAAM,mBAAmB,YAAY;CACpC,MAAM,QAAQ,QAAQ,MAAM,QAAQ;CACpC,MAAM,qBAAqB,MAAM,WAAW,SAAS,KAAK,MAAM,KAAK,GAAG;AACxE,KAAI,uBAAuB,MAAM,MAAM,oBAAoB,MAAM,KAAK,MAAO,QAAO;CACpF,IAAI,WAAW;AACf,MAAK,IAAI,IAAI,qBAAqB,GAAG,IAAI,MAAM,QAAQ,IAAK,KAAI,MAAM,GAAG,MAAM,KAAK,OAAO;AAC1F,aAAW;AACX;;AAED,KAAI,aAAa,GAAI,QAAO;AAC5B,QAAO,MAAM,MAAM,WAAW,EAAE,CAAC,KAAK,KAAK,CAAC,WAAW;;AAExD,MAAM,4BAA4B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;CACA,CAAC;AACF,MAAM,oBAAoB,OAAO,kBAAkB,YAAY,kBAAkB;CAChF,MAAM,UAAU,WAAW;CAC3B,MAAM,eAAe,gBAAgB,OAAO,YAAY,YAAY,SAAS,aAAaA,oCAAW,QAAQA,sCAAa,KAAK,GAAG;CAClI,MAAM,cAAc,QAAQ,yBAAyB,OAAO,YAAY,OAAO,QAAQ,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,0BAA0B,IAAI,EAAE,IAAI,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,WAAW;AACtL,0DAAoB,iBAAiB,EAAE,EAAE,WAAW,MAAM,CAAC;CAC3D,MAAM,UAAU,cAAc,QAAQ;AACtC,KAAI,QAAS,mCAAY,SAAS,EAAE,WAAW,MAAM,CAAC;CACtD,MAAM,eAAe,2BAAY,iBAAiB,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC;CACxG,MAAM,WAAW,8BAAe,SAAS,aAAa,GAAG,GAAG,iBAAiB,GAAG;AAChF,KAAI;AACH,wCAAgB,UAAU,aAAa,QAAQ;AAC/C,qCAAa,UAAU,iBAAiB;UAChC,OAAO;AACf,MAAI;AACH,kCAAS,UAAU,EAAE,OAAO,MAAM,CAAC;UAC5B;AACR,QAAM;;CAEP,MAAM,gBAAgBC,gDAAoB,cAAc;AACxD,KAAI,cAAe,KAAI;AACtB,mCAAS,cAAc,QAAQ,YAAY,iBAAiB,EAAE;GAC7D,OAAO;GACP,KAAK,cAAc,OAAO;GAC1B,CAAC;UACM,OAAO;AACf,UAAQ,MAAM,MAAM"}
@@ -0,0 +1,64 @@
1
+ import { detectFormatCommand } from "../detectFormatCommand.mjs";
2
+ import { basename, dirname, join } from "node:path";
3
+ import { mkdir, rename, rm, writeFile } from "node:fs/promises";
4
+ import { MARKDOWN } from "@intlayer/types/nodeType";
5
+ import { execSync } from "node:child_process";
6
+
7
+ //#region ../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs
8
+ const stringifyYamlFrontmatter = (fields) => Object.entries(fields).filter(([, value]) => value !== void 0 && value !== null).map(([key, value]) => {
9
+ if (Array.isArray(value)) return `${key}:\n${value.map((item) => ` - ${JSON.stringify(item)}`).join("\n")}`;
10
+ if (typeof value === "string" && (value.includes(":") || value.includes("\n") || value.includes("#"))) return `${key}: ${JSON.stringify(value)}`;
11
+ return `${key}: ${value}`;
12
+ }).join("\n");
13
+ const getMarkdownBody = (content) => {
14
+ const lines = content.split(/\r?\n/);
15
+ const firstNonEmptyIndex = lines.findIndex((line) => line.trim() !== "");
16
+ if (firstNonEmptyIndex === -1 || lines[firstNonEmptyIndex].trim() !== "---") return content;
17
+ let endIndex = -1;
18
+ for (let i = firstNonEmptyIndex + 1; i < lines.length; i++) if (lines[i].trim() === "---") {
19
+ endIndex = i;
20
+ break;
21
+ }
22
+ if (endIndex === -1) return content;
23
+ return lines.slice(endIndex + 1).join("\n").trimStart();
24
+ };
25
+ const EXCLUDED_FRONTMATTER_KEYS = new Set([
26
+ "content",
27
+ "$schema",
28
+ "filePath",
29
+ "localId",
30
+ "localIds",
31
+ "projectIds"
32
+ ]);
33
+ const writeMarkdownFile = async (absoluteFilePath, dictionary, configuration) => {
34
+ const content = dictionary.content;
35
+ const markdownBody = getMarkdownBody(typeof content === "object" && content?.nodeType === MARKDOWN ? content[MARKDOWN] ?? "" : "");
36
+ const fileContent = `---\n${stringifyYamlFrontmatter(Object.fromEntries(Object.entries(dictionary).filter(([k, v]) => !EXCLUDED_FRONTMATTER_KEYS.has(k) && v !== void 0)))}\n---\n\n${markdownBody}`;
37
+ await mkdir(dirname(absoluteFilePath), { recursive: true });
38
+ const tempDir = configuration.system?.tempDir;
39
+ if (tempDir) await mkdir(tempDir, { recursive: true });
40
+ const tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
41
+ const tempPath = tempDir ? join(tempDir, tempFileName) : `${absoluteFilePath}.${tempFileName}`;
42
+ try {
43
+ await writeFile(tempPath, fileContent, "utf-8");
44
+ await rename(tempPath, absoluteFilePath);
45
+ } catch (error) {
46
+ try {
47
+ await rm(tempPath, { force: true });
48
+ } catch {}
49
+ throw error;
50
+ }
51
+ const formatCommand = detectFormatCommand(configuration);
52
+ if (formatCommand) try {
53
+ execSync(formatCommand.replace("{{file}}", absoluteFilePath), {
54
+ stdio: "inherit",
55
+ cwd: configuration.system.baseDir
56
+ });
57
+ } catch (error) {
58
+ console.error(error);
59
+ }
60
+ };
61
+
62
+ //#endregion
63
+ export { writeMarkdownFile };
64
+ //# sourceMappingURL=writeMarkdownFile.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeMarkdownFile.mjs","names":[],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs"],"sourcesContent":["import { detectFormatCommand } from \"../detectFormatCommand.mjs\";\nimport { mkdir, rename, rm, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, join } from \"node:path\";\nimport { MARKDOWN } from \"@intlayer/types/nodeType\";\nimport { execSync } from \"node:child_process\";\n\n//#region src/writeContentDeclaration/writeMarkdownFile.ts\nconst stringifyYamlFrontmatter = (fields) => Object.entries(fields).filter(([, value]) => value !== void 0 && value !== null).map(([key, value]) => {\n\tif (Array.isArray(value)) return `${key}:\\n${value.map((item) => ` - ${JSON.stringify(item)}`).join(\"\\n\")}`;\n\tif (typeof value === \"string\" && (value.includes(\":\") || value.includes(\"\\n\") || value.includes(\"#\"))) return `${key}: ${JSON.stringify(value)}`;\n\treturn `${key}: ${value}`;\n}).join(\"\\n\");\nconst getMarkdownBody = (content) => {\n\tconst lines = content.split(/\\r?\\n/);\n\tconst firstNonEmptyIndex = lines.findIndex((line) => line.trim() !== \"\");\n\tif (firstNonEmptyIndex === -1 || lines[firstNonEmptyIndex].trim() !== \"---\") return content;\n\tlet endIndex = -1;\n\tfor (let i = firstNonEmptyIndex + 1; i < lines.length; i++) if (lines[i].trim() === \"---\") {\n\t\tendIndex = i;\n\t\tbreak;\n\t}\n\tif (endIndex === -1) return content;\n\treturn lines.slice(endIndex + 1).join(\"\\n\").trimStart();\n};\nconst EXCLUDED_FRONTMATTER_KEYS = new Set([\n\t\"content\",\n\t\"$schema\",\n\t\"filePath\",\n\t\"localId\",\n\t\"localIds\",\n\t\"projectIds\"\n]);\nconst writeMarkdownFile = async (absoluteFilePath, dictionary, configuration) => {\n\tconst content = dictionary.content;\n\tconst markdownBody = getMarkdownBody(typeof content === \"object\" && content?.nodeType === MARKDOWN ? content[MARKDOWN] ?? \"\" : \"\");\n\tconst fileContent = `---\\n${stringifyYamlFrontmatter(Object.fromEntries(Object.entries(dictionary).filter(([k, v]) => !EXCLUDED_FRONTMATTER_KEYS.has(k) && v !== void 0)))}\\n---\\n\\n${markdownBody}`;\n\tawait mkdir(dirname(absoluteFilePath), { recursive: true });\n\tconst tempDir = configuration.system?.tempDir;\n\tif (tempDir) await mkdir(tempDir, { recursive: true });\n\tconst tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n\tconst tempPath = tempDir ? join(tempDir, tempFileName) : `${absoluteFilePath}.${tempFileName}`;\n\ttry {\n\t\tawait writeFile(tempPath, fileContent, \"utf-8\");\n\t\tawait rename(tempPath, absoluteFilePath);\n\t} catch (error) {\n\t\ttry {\n\t\t\tawait rm(tempPath, { force: true });\n\t\t} catch {}\n\t\tthrow error;\n\t}\n\tconst formatCommand = detectFormatCommand(configuration);\n\tif (formatCommand) try {\n\t\texecSync(formatCommand.replace(\"{{file}}\", absoluteFilePath), {\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 { writeMarkdownFile };\n//# sourceMappingURL=writeMarkdownFile.mjs.map"],"mappings":";;;;;;;AAOA,MAAM,4BAA4B,WAAW,OAAO,QAAQ,OAAO,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAK,KAAK,UAAU,KAAK,CAAC,KAAK,CAAC,KAAK,WAAW;AACnJ,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,GAAG,IAAI,KAAK,MAAM,KAAK,SAAS,OAAO,KAAK,UAAU,KAAK,GAAG,CAAC,KAAK,KAAK;AAC1G,KAAI,OAAO,UAAU,aAAa,MAAM,SAAS,IAAI,IAAI,MAAM,SAAS,KAAK,IAAI,MAAM,SAAS,IAAI,EAAG,QAAO,GAAG,IAAI,IAAI,KAAK,UAAU,MAAM;AAC9I,QAAO,GAAG,IAAI,IAAI;EACjB,CAAC,KAAK,KAAK;AACb,MAAM,mBAAmB,YAAY;CACpC,MAAM,QAAQ,QAAQ,MAAM,QAAQ;CACpC,MAAM,qBAAqB,MAAM,WAAW,SAAS,KAAK,MAAM,KAAK,GAAG;AACxE,KAAI,uBAAuB,MAAM,MAAM,oBAAoB,MAAM,KAAK,MAAO,QAAO;CACpF,IAAI,WAAW;AACf,MAAK,IAAI,IAAI,qBAAqB,GAAG,IAAI,MAAM,QAAQ,IAAK,KAAI,MAAM,GAAG,MAAM,KAAK,OAAO;AAC1F,aAAW;AACX;;AAED,KAAI,aAAa,GAAI,QAAO;AAC5B,QAAO,MAAM,MAAM,WAAW,EAAE,CAAC,KAAK,KAAK,CAAC,WAAW;;AAExD,MAAM,4BAA4B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;CACA,CAAC;AACF,MAAM,oBAAoB,OAAO,kBAAkB,YAAY,kBAAkB;CAChF,MAAM,UAAU,WAAW;CAC3B,MAAM,eAAe,gBAAgB,OAAO,YAAY,YAAY,SAAS,aAAa,WAAW,QAAQ,aAAa,KAAK,GAAG;CAClI,MAAM,cAAc,QAAQ,yBAAyB,OAAO,YAAY,OAAO,QAAQ,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,0BAA0B,IAAI,EAAE,IAAI,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,WAAW;AACtL,OAAM,MAAM,QAAQ,iBAAiB,EAAE,EAAE,WAAW,MAAM,CAAC;CAC3D,MAAM,UAAU,cAAc,QAAQ;AACtC,KAAI,QAAS,OAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;CACtD,MAAM,eAAe,GAAG,SAAS,iBAAiB,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC;CACxG,MAAM,WAAW,UAAU,KAAK,SAAS,aAAa,GAAG,GAAG,iBAAiB,GAAG;AAChF,KAAI;AACH,QAAM,UAAU,UAAU,aAAa,QAAQ;AAC/C,QAAM,OAAO,UAAU,iBAAiB;UAChC,OAAO;AACf,MAAI;AACH,SAAM,GAAG,UAAU,EAAE,OAAO,MAAM,CAAC;UAC5B;AACR,QAAM;;CAEP,MAAM,gBAAgB,oBAAoB,cAAc;AACxD,KAAI,cAAe,KAAI;AACtB,WAAS,cAAc,QAAQ,YAAY,iBAAiB,EAAE;GAC7D,OAAO;GACP,KAAK,cAAc,OAAO;GAC1B,CAAC;UACM,OAAO;AACf,UAAQ,MAAM,MAAM"}
@@ -0,0 +1,43 @@
1
+ const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
2
+ const require_stringifyYaml = require('../../../../core/dist/esm/utils/stringifyYaml.cjs');
3
+ const require_detectFormatCommand = require('../detectFormatCommand.cjs');
4
+ let node_path = require("node:path");
5
+ let node_fs_promises = require("node:fs/promises");
6
+ let node_child_process = require("node:child_process");
7
+
8
+ //#region ../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.mjs
9
+ const EXCLUDED_YAML_KEYS = new Set([
10
+ "$schema",
11
+ "id",
12
+ "filePath"
13
+ ]);
14
+ const writeYamlFile = async (absoluteFilePath, dictionary, configuration) => {
15
+ const fileContent = require_stringifyYaml.stringifyYaml(Object.fromEntries(Object.entries(dictionary).filter(([k, v]) => !EXCLUDED_YAML_KEYS.has(k) && v !== void 0)));
16
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(absoluteFilePath), { recursive: true });
17
+ const tempDir = configuration.system?.tempDir;
18
+ if (tempDir) await (0, node_fs_promises.mkdir)(tempDir, { recursive: true });
19
+ const tempFileName = `${(0, node_path.basename)(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
20
+ const tempPath = tempDir ? (0, node_path.join)(tempDir, tempFileName) : `${absoluteFilePath}.${tempFileName}`;
21
+ try {
22
+ await (0, node_fs_promises.writeFile)(tempPath, fileContent, "utf-8");
23
+ await (0, node_fs_promises.rename)(tempPath, absoluteFilePath);
24
+ } catch (error) {
25
+ try {
26
+ await (0, node_fs_promises.rm)(tempPath, { force: true });
27
+ } catch {}
28
+ throw error;
29
+ }
30
+ const formatCommand = require_detectFormatCommand.detectFormatCommand(configuration);
31
+ if (formatCommand) try {
32
+ (0, node_child_process.execSync)(formatCommand.replace("{{file}}", absoluteFilePath), {
33
+ stdio: "inherit",
34
+ cwd: configuration.system.baseDir
35
+ });
36
+ } catch (error) {
37
+ console.error(error);
38
+ }
39
+ };
40
+
41
+ //#endregion
42
+ exports.writeYamlFile = writeYamlFile;
43
+ //# sourceMappingURL=writeYamlFile.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeYamlFile.cjs","names":["stringifyYaml","detectFormatCommand"],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.mjs"],"sourcesContent":["import { detectFormatCommand } from \"../detectFormatCommand.mjs\";\nimport { mkdir, rename, rm, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, join } from \"node:path\";\nimport { execSync } from \"node:child_process\";\nimport { stringifyYaml } from \"@intlayer/core/utils\";\n\n//#region src/writeContentDeclaration/writeYamlFile.ts\nconst EXCLUDED_YAML_KEYS = new Set([\n\t\"$schema\",\n\t\"id\",\n\t\"filePath\"\n]);\nconst writeYamlFile = async (absoluteFilePath, dictionary, configuration) => {\n\tconst fileContent = stringifyYaml(Object.fromEntries(Object.entries(dictionary).filter(([k, v]) => !EXCLUDED_YAML_KEYS.has(k) && v !== void 0)));\n\tawait mkdir(dirname(absoluteFilePath), { recursive: true });\n\tconst tempDir = configuration.system?.tempDir;\n\tif (tempDir) await mkdir(tempDir, { recursive: true });\n\tconst tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n\tconst tempPath = tempDir ? join(tempDir, tempFileName) : `${absoluteFilePath}.${tempFileName}`;\n\ttry {\n\t\tawait writeFile(tempPath, fileContent, \"utf-8\");\n\t\tawait rename(tempPath, absoluteFilePath);\n\t} catch (error) {\n\t\ttry {\n\t\t\tawait rm(tempPath, { force: true });\n\t\t} catch {}\n\t\tthrow error;\n\t}\n\tconst formatCommand = detectFormatCommand(configuration);\n\tif (formatCommand) try {\n\t\texecSync(formatCommand.replace(\"{{file}}\", absoluteFilePath), {\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 { writeYamlFile };\n//# sourceMappingURL=writeYamlFile.mjs.map"],"mappings":";;;;;;;;AAOA,MAAM,qBAAqB,IAAI,IAAI;CAClC;CACA;CACA;CACA,CAAC;AACF,MAAM,gBAAgB,OAAO,kBAAkB,YAAY,kBAAkB;CAC5E,MAAM,cAAcA,oCAAc,OAAO,YAAY,OAAO,QAAQ,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,mBAAmB,IAAI,EAAE,IAAI,MAAM,KAAK,EAAE,CAAC,CAAC;AAChJ,0DAAoB,iBAAiB,EAAE,EAAE,WAAW,MAAM,CAAC;CAC3D,MAAM,UAAU,cAAc,QAAQ;AACtC,KAAI,QAAS,mCAAY,SAAS,EAAE,WAAW,MAAM,CAAC;CACtD,MAAM,eAAe,2BAAY,iBAAiB,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC;CACxG,MAAM,WAAW,8BAAe,SAAS,aAAa,GAAG,GAAG,iBAAiB,GAAG;AAChF,KAAI;AACH,wCAAgB,UAAU,aAAa,QAAQ;AAC/C,qCAAa,UAAU,iBAAiB;UAChC,OAAO;AACf,MAAI;AACH,kCAAS,UAAU,EAAE,OAAO,MAAM,CAAC;UAC5B;AACR,QAAM;;CAEP,MAAM,gBAAgBC,gDAAoB,cAAc;AACxD,KAAI,cAAe,KAAI;AACtB,mCAAS,cAAc,QAAQ,YAAY,iBAAiB,EAAE;GAC7D,OAAO;GACP,KAAK,cAAc,OAAO;GAC1B,CAAC;UACM,OAAO;AACf,UAAQ,MAAM,MAAM"}
@@ -0,0 +1,42 @@
1
+ import { stringifyYaml } from "../../../../core/dist/esm/utils/stringifyYaml.mjs";
2
+ import { detectFormatCommand } from "../detectFormatCommand.mjs";
3
+ import { basename, dirname, join } from "node:path";
4
+ import { mkdir, rename, rm, writeFile } from "node:fs/promises";
5
+ import { execSync } from "node:child_process";
6
+
7
+ //#region ../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.mjs
8
+ const EXCLUDED_YAML_KEYS = new Set([
9
+ "$schema",
10
+ "id",
11
+ "filePath"
12
+ ]);
13
+ const writeYamlFile = async (absoluteFilePath, dictionary, configuration) => {
14
+ const fileContent = stringifyYaml(Object.fromEntries(Object.entries(dictionary).filter(([k, v]) => !EXCLUDED_YAML_KEYS.has(k) && v !== void 0)));
15
+ await mkdir(dirname(absoluteFilePath), { recursive: true });
16
+ const tempDir = configuration.system?.tempDir;
17
+ if (tempDir) await mkdir(tempDir, { recursive: true });
18
+ const tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
19
+ const tempPath = tempDir ? join(tempDir, tempFileName) : `${absoluteFilePath}.${tempFileName}`;
20
+ try {
21
+ await writeFile(tempPath, fileContent, "utf-8");
22
+ await rename(tempPath, absoluteFilePath);
23
+ } catch (error) {
24
+ try {
25
+ await rm(tempPath, { force: true });
26
+ } catch {}
27
+ throw error;
28
+ }
29
+ const formatCommand = detectFormatCommand(configuration);
30
+ if (formatCommand) try {
31
+ execSync(formatCommand.replace("{{file}}", absoluteFilePath), {
32
+ stdio: "inherit",
33
+ cwd: configuration.system.baseDir
34
+ });
35
+ } catch (error) {
36
+ console.error(error);
37
+ }
38
+ };
39
+
40
+ //#endregion
41
+ export { writeYamlFile };
42
+ //# sourceMappingURL=writeYamlFile.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeYamlFile.mjs","names":[],"sources":["../../../../../../../../../@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.mjs"],"sourcesContent":["import { detectFormatCommand } from \"../detectFormatCommand.mjs\";\nimport { mkdir, rename, rm, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, join } from \"node:path\";\nimport { execSync } from \"node:child_process\";\nimport { stringifyYaml } from \"@intlayer/core/utils\";\n\n//#region src/writeContentDeclaration/writeYamlFile.ts\nconst EXCLUDED_YAML_KEYS = new Set([\n\t\"$schema\",\n\t\"id\",\n\t\"filePath\"\n]);\nconst writeYamlFile = async (absoluteFilePath, dictionary, configuration) => {\n\tconst fileContent = stringifyYaml(Object.fromEntries(Object.entries(dictionary).filter(([k, v]) => !EXCLUDED_YAML_KEYS.has(k) && v !== void 0)));\n\tawait mkdir(dirname(absoluteFilePath), { recursive: true });\n\tconst tempDir = configuration.system?.tempDir;\n\tif (tempDir) await mkdir(tempDir, { recursive: true });\n\tconst tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n\tconst tempPath = tempDir ? join(tempDir, tempFileName) : `${absoluteFilePath}.${tempFileName}`;\n\ttry {\n\t\tawait writeFile(tempPath, fileContent, \"utf-8\");\n\t\tawait rename(tempPath, absoluteFilePath);\n\t} catch (error) {\n\t\ttry {\n\t\t\tawait rm(tempPath, { force: true });\n\t\t} catch {}\n\t\tthrow error;\n\t}\n\tconst formatCommand = detectFormatCommand(configuration);\n\tif (formatCommand) try {\n\t\texecSync(formatCommand.replace(\"{{file}}\", absoluteFilePath), {\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 { writeYamlFile };\n//# sourceMappingURL=writeYamlFile.mjs.map"],"mappings":";;;;;;;AAOA,MAAM,qBAAqB,IAAI,IAAI;CAClC;CACA;CACA;CACA,CAAC;AACF,MAAM,gBAAgB,OAAO,kBAAkB,YAAY,kBAAkB;CAC5E,MAAM,cAAc,cAAc,OAAO,YAAY,OAAO,QAAQ,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,mBAAmB,IAAI,EAAE,IAAI,MAAM,KAAK,EAAE,CAAC,CAAC;AAChJ,OAAM,MAAM,QAAQ,iBAAiB,EAAE,EAAE,WAAW,MAAM,CAAC;CAC3D,MAAM,UAAU,cAAc,QAAQ;AACtC,KAAI,QAAS,OAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;CACtD,MAAM,eAAe,GAAG,SAAS,iBAAiB,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC;CACxG,MAAM,WAAW,UAAU,KAAK,SAAS,aAAa,GAAG,GAAG,iBAAiB,GAAG;AAChF,KAAI;AACH,QAAM,UAAU,UAAU,aAAa,QAAQ;AAC/C,QAAM,OAAO,UAAU,iBAAiB;UAChC,OAAO;AACf,MAAI;AACH,SAAM,GAAG,UAAU,EAAE,OAAO,MAAM,CAAC;UAC5B;AACR,QAAM;;CAEP,MAAM,gBAAgB,oBAAoB,cAAc;AACxD,KAAI,cAAe,KAAI;AACtB,WAAS,cAAc,QAAQ,YAAY,iBAAiB,EAAE;GAC7D,OAAO;GACP,KAAK,cAAc,OAAO;GAC1B,CAAC;UACM,OAAO;AACf,UAAQ,MAAM,MAAM"}
@@ -0,0 +1,45 @@
1
+ const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
2
+ const require_deepTransform = require('../interpreter/getContent/deepTransform.cjs');
3
+ let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
4
+ _intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType, 1);
5
+
6
+ //#region ../../@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs
7
+ const filterTranslationsPlugin = (locales) => ({
8
+ id: "filter-translations-plugin",
9
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.TRANSLATION,
10
+ transform: (node, props, deepTransformNode) => {
11
+ const translationMap = node[_intlayer_types_nodeType.TRANSLATION];
12
+ const filteredTranslationMap = Object.fromEntries(Object.entries(translationMap).filter(([key]) => locales.includes(key)));
13
+ return {
14
+ ...node,
15
+ [_intlayer_types_nodeType.TRANSLATION]: deepTransformNode(filteredTranslationMap, {
16
+ ...props,
17
+ keyPath: [...props.keyPath, {
18
+ type: _intlayer_types_nodeType.OBJECT,
19
+ key: _intlayer_types_nodeType.TRANSLATION
20
+ }]
21
+ })
22
+ };
23
+ }
24
+ });
25
+ const getFilteredLocalesContent = (node, locales, nodeProps) => {
26
+ const plugins = [filterTranslationsPlugin(Array.isArray(locales) ? locales : [locales]), ...nodeProps.plugins ?? []];
27
+ return require_deepTransform.deepTransformNode(node, {
28
+ ...nodeProps,
29
+ plugins
30
+ });
31
+ };
32
+ const getFilteredLocalesDictionary = (dictionary, locale) => {
33
+ const localesArray = Array.isArray(locale) ? locale : [locale];
34
+ return {
35
+ ...dictionary,
36
+ content: getFilteredLocalesContent(dictionary.content, localesArray, {
37
+ dictionaryKey: dictionary.key,
38
+ keyPath: []
39
+ })
40
+ };
41
+ };
42
+
43
+ //#endregion
44
+ exports.getFilteredLocalesDictionary = getFilteredLocalesDictionary;
45
+ //# sourceMappingURL=getFilteredLocalesContent.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFilteredLocalesContent.cjs","names":["NodeTypes","deepTransformNode"],"sources":["../../../../../../../../../@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs"],"sourcesContent":["import { deepTransformNode } from \"../interpreter/getContent/deepTransform.mjs\";\nimport * as NodeTypes from \"@intlayer/types/nodeType\";\n\n//#region src/deepTransformPlugins/getFilteredLocalesContent.ts\nconst filterTranslationsPlugin = (locales) => ({\n\tid: \"filter-translations-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.TRANSLATION,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst translationMap = node[NodeTypes.TRANSLATION];\n\t\tconst filteredTranslationMap = Object.fromEntries(Object.entries(translationMap).filter(([key]) => locales.includes(key)));\n\t\treturn {\n\t\t\t...node,\n\t\t\t[NodeTypes.TRANSLATION]: deepTransformNode(filteredTranslationMap, {\n\t\t\t\t...props,\n\t\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\t\ttype: NodeTypes.OBJECT,\n\t\t\t\t\tkey: NodeTypes.TRANSLATION\n\t\t\t\t}]\n\t\t\t})\n\t\t};\n\t}\n});\nconst getFilteredLocalesContent = (node, locales, nodeProps) => {\n\tconst plugins = [filterTranslationsPlugin(Array.isArray(locales) ? locales : [locales]), ...nodeProps.plugins ?? []];\n\treturn deepTransformNode(node, {\n\t\t...nodeProps,\n\t\tplugins\n\t});\n};\nconst getFilteredLocalesDictionary = (dictionary, locale) => {\n\tconst localesArray = Array.isArray(locale) ? locale : [locale];\n\treturn {\n\t\t...dictionary,\n\t\tcontent: getFilteredLocalesContent(dictionary.content, localesArray, {\n\t\t\tdictionaryKey: dictionary.key,\n\t\t\tkeyPath: []\n\t\t})\n\t};\n};\n\n//#endregion\nexport { getFilteredLocalesContent, getFilteredLocalesDictionary };\n//# sourceMappingURL=getFilteredLocalesContent.mjs.map"],"mappings":";;;;;;AAIA,MAAM,4BAA4B,aAAa;CAC9C,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAaA,yBAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;EAC9C,MAAM,iBAAiB,KAAKA,yBAAU;EACtC,MAAM,yBAAyB,OAAO,YAAY,OAAO,QAAQ,eAAe,CAAC,QAAQ,CAAC,SAAS,QAAQ,SAAS,IAAI,CAAC,CAAC;AAC1H,SAAO;GACN,GAAG;IACFA,yBAAU,cAAc,kBAAkB,wBAAwB;IAClE,GAAG;IACH,SAAS,CAAC,GAAG,MAAM,SAAS;KAC3B,MAAMA,yBAAU;KAChB,KAAKA,yBAAU;KACf,CAAC;IACF,CAAC;GACF;;CAEF;AACD,MAAM,6BAA6B,MAAM,SAAS,cAAc;CAC/D,MAAM,UAAU,CAAC,yBAAyB,MAAM,QAAQ,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,EAAE,GAAG,UAAU,WAAW,EAAE,CAAC;AACpH,QAAOC,wCAAkB,MAAM;EAC9B,GAAG;EACH;EACA,CAAC;;AAEH,MAAM,gCAAgC,YAAY,WAAW;CAC5D,MAAM,eAAe,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;AAC9D,QAAO;EACN,GAAG;EACH,SAAS,0BAA0B,WAAW,SAAS,cAAc;GACpE,eAAe,WAAW;GAC1B,SAAS,EAAE;GACX,CAAC;EACF"}
@@ -0,0 +1,43 @@
1
+ import { deepTransformNode } from "../interpreter/getContent/deepTransform.mjs";
2
+ import * as NodeTypes from "@intlayer/types/nodeType";
3
+
4
+ //#region ../../@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs
5
+ const filterTranslationsPlugin = (locales) => ({
6
+ id: "filter-translations-plugin",
7
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.TRANSLATION,
8
+ transform: (node, props, deepTransformNode) => {
9
+ const translationMap = node[NodeTypes.TRANSLATION];
10
+ const filteredTranslationMap = Object.fromEntries(Object.entries(translationMap).filter(([key]) => locales.includes(key)));
11
+ return {
12
+ ...node,
13
+ [NodeTypes.TRANSLATION]: deepTransformNode(filteredTranslationMap, {
14
+ ...props,
15
+ keyPath: [...props.keyPath, {
16
+ type: NodeTypes.OBJECT,
17
+ key: NodeTypes.TRANSLATION
18
+ }]
19
+ })
20
+ };
21
+ }
22
+ });
23
+ const getFilteredLocalesContent = (node, locales, nodeProps) => {
24
+ const plugins = [filterTranslationsPlugin(Array.isArray(locales) ? locales : [locales]), ...nodeProps.plugins ?? []];
25
+ return deepTransformNode(node, {
26
+ ...nodeProps,
27
+ plugins
28
+ });
29
+ };
30
+ const getFilteredLocalesDictionary = (dictionary, locale) => {
31
+ const localesArray = Array.isArray(locale) ? locale : [locale];
32
+ return {
33
+ ...dictionary,
34
+ content: getFilteredLocalesContent(dictionary.content, localesArray, {
35
+ dictionaryKey: dictionary.key,
36
+ keyPath: []
37
+ })
38
+ };
39
+ };
40
+
41
+ //#endregion
42
+ export { getFilteredLocalesDictionary };
43
+ //# sourceMappingURL=getFilteredLocalesContent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFilteredLocalesContent.mjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs"],"sourcesContent":["import { deepTransformNode } from \"../interpreter/getContent/deepTransform.mjs\";\nimport * as NodeTypes from \"@intlayer/types/nodeType\";\n\n//#region src/deepTransformPlugins/getFilteredLocalesContent.ts\nconst filterTranslationsPlugin = (locales) => ({\n\tid: \"filter-translations-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.TRANSLATION,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst translationMap = node[NodeTypes.TRANSLATION];\n\t\tconst filteredTranslationMap = Object.fromEntries(Object.entries(translationMap).filter(([key]) => locales.includes(key)));\n\t\treturn {\n\t\t\t...node,\n\t\t\t[NodeTypes.TRANSLATION]: deepTransformNode(filteredTranslationMap, {\n\t\t\t\t...props,\n\t\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\t\ttype: NodeTypes.OBJECT,\n\t\t\t\t\tkey: NodeTypes.TRANSLATION\n\t\t\t\t}]\n\t\t\t})\n\t\t};\n\t}\n});\nconst getFilteredLocalesContent = (node, locales, nodeProps) => {\n\tconst plugins = [filterTranslationsPlugin(Array.isArray(locales) ? locales : [locales]), ...nodeProps.plugins ?? []];\n\treturn deepTransformNode(node, {\n\t\t...nodeProps,\n\t\tplugins\n\t});\n};\nconst getFilteredLocalesDictionary = (dictionary, locale) => {\n\tconst localesArray = Array.isArray(locale) ? locale : [locale];\n\treturn {\n\t\t...dictionary,\n\t\tcontent: getFilteredLocalesContent(dictionary.content, localesArray, {\n\t\t\tdictionaryKey: dictionary.key,\n\t\t\tkeyPath: []\n\t\t})\n\t};\n};\n\n//#endregion\nexport { getFilteredLocalesContent, getFilteredLocalesDictionary };\n//# sourceMappingURL=getFilteredLocalesContent.mjs.map"],"mappings":";;;;AAIA,MAAM,4BAA4B,aAAa;CAC9C,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;EAC9C,MAAM,iBAAiB,KAAK,UAAU;EACtC,MAAM,yBAAyB,OAAO,YAAY,OAAO,QAAQ,eAAe,CAAC,QAAQ,CAAC,SAAS,QAAQ,SAAS,IAAI,CAAC,CAAC;AAC1H,SAAO;GACN,GAAG;IACF,UAAU,cAAc,kBAAkB,wBAAwB;IAClE,GAAG;IACH,SAAS,CAAC,GAAG,MAAM,SAAS;KAC3B,MAAM,UAAU;KAChB,KAAK,UAAU;KACf,CAAC;IACF,CAAC;GACF;;CAEF;AACD,MAAM,6BAA6B,MAAM,SAAS,cAAc;CAC/D,MAAM,UAAU,CAAC,yBAAyB,MAAM,QAAQ,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,EAAE,GAAG,UAAU,WAAW,EAAE,CAAC;AACpH,QAAO,kBAAkB,MAAM;EAC9B,GAAG;EACH;EACA,CAAC;;AAEH,MAAM,gCAAgC,YAAY,WAAW;CAC5D,MAAM,eAAe,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;AAC9D,QAAO;EACN,GAAG;EACH,SAAS,0BAA0B,WAAW,SAAS,cAAc;GACpE,eAAe,WAAW;GAC1B,SAAS,EAAE;GACX,CAAC;EACF"}
@@ -0,0 +1,32 @@
1
+ const require_deepTransform = require('../interpreter/getContent/deepTransform.cjs');
2
+ const require_plugins = require('../interpreter/getContent/plugins.cjs');
3
+
4
+ //#region ../../@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs
5
+ /**
6
+ * Transforms a node in a single pass, applying each plugin as needed.
7
+ * In comparison to `getContent`, this function will only apply the translation plugin.
8
+ * It will not transform enumerations, insertions, or other content types.
9
+ *
10
+ * @param node The node to transform.
11
+ * @param locale The locale to use if your transformers need it (e.g. for translations).
12
+ */
13
+ const getLocalizedContent = (node, locale, nodeProps, fallback) => {
14
+ const plugins = [require_plugins.translationPlugin(locale, fallback), ...nodeProps.plugins ?? []];
15
+ return require_deepTransform.deepTransformNode(node, {
16
+ ...nodeProps,
17
+ plugins
18
+ });
19
+ };
20
+ const getPerLocaleDictionary = (dictionary, locale, fallback) => ({
21
+ ...dictionary,
22
+ locale,
23
+ content: getLocalizedContent(dictionary.content, locale, {
24
+ dictionaryKey: dictionary.key,
25
+ keyPath: [],
26
+ plugins: []
27
+ }, fallback)
28
+ });
29
+
30
+ //#endregion
31
+ exports.getPerLocaleDictionary = getPerLocaleDictionary;
32
+ //# sourceMappingURL=getLocalizedContent.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLocalizedContent.cjs","names":["translationPlugin","deepTransformNode"],"sources":["../../../../../../../../../@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs"],"sourcesContent":["import { deepTransformNode } from \"../interpreter/getContent/deepTransform.mjs\";\nimport { translationPlugin } from \"../interpreter/getContent/plugins.mjs\";\n\n//#region src/deepTransformPlugins/getLocalizedContent.ts\n/**\n* Transforms a node in a single pass, applying each plugin as needed.\n* In comparison to `getContent`, this function will only apply the translation plugin.\n* It will not transform enumerations, insertions, or other content types.\n*\n* @param node The node to transform.\n* @param locale The locale to use if your transformers need it (e.g. for translations).\n*/\nconst getLocalizedContent = (node, locale, nodeProps, fallback) => {\n\tconst plugins = [translationPlugin(locale, fallback), ...nodeProps.plugins ?? []];\n\treturn deepTransformNode(node, {\n\t\t...nodeProps,\n\t\tplugins\n\t});\n};\nconst getPerLocaleDictionary = (dictionary, locale, fallback) => ({\n\t...dictionary,\n\tlocale,\n\tcontent: getLocalizedContent(dictionary.content, locale, {\n\t\tdictionaryKey: dictionary.key,\n\t\tkeyPath: [],\n\t\tplugins: []\n\t}, fallback)\n});\n\n//#endregion\nexport { getLocalizedContent, getPerLocaleDictionary };\n//# sourceMappingURL=getLocalizedContent.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,MAAM,uBAAuB,MAAM,QAAQ,WAAW,aAAa;CAClE,MAAM,UAAU,CAACA,kCAAkB,QAAQ,SAAS,EAAE,GAAG,UAAU,WAAW,EAAE,CAAC;AACjF,QAAOC,wCAAkB,MAAM;EAC9B,GAAG;EACH;EACA,CAAC;;AAEH,MAAM,0BAA0B,YAAY,QAAQ,cAAc;CACjE,GAAG;CACH;CACA,SAAS,oBAAoB,WAAW,SAAS,QAAQ;EACxD,eAAe,WAAW;EAC1B,SAAS,EAAE;EACX,SAAS,EAAE;EACX,EAAE,SAAS;CACZ"}
@@ -0,0 +1,32 @@
1
+ import { deepTransformNode } from "../interpreter/getContent/deepTransform.mjs";
2
+ import { translationPlugin } from "../interpreter/getContent/plugins.mjs";
3
+
4
+ //#region ../../@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs
5
+ /**
6
+ * Transforms a node in a single pass, applying each plugin as needed.
7
+ * In comparison to `getContent`, this function will only apply the translation plugin.
8
+ * It will not transform enumerations, insertions, or other content types.
9
+ *
10
+ * @param node The node to transform.
11
+ * @param locale The locale to use if your transformers need it (e.g. for translations).
12
+ */
13
+ const getLocalizedContent = (node, locale, nodeProps, fallback) => {
14
+ const plugins = [translationPlugin(locale, fallback), ...nodeProps.plugins ?? []];
15
+ return deepTransformNode(node, {
16
+ ...nodeProps,
17
+ plugins
18
+ });
19
+ };
20
+ const getPerLocaleDictionary = (dictionary, locale, fallback) => ({
21
+ ...dictionary,
22
+ locale,
23
+ content: getLocalizedContent(dictionary.content, locale, {
24
+ dictionaryKey: dictionary.key,
25
+ keyPath: [],
26
+ plugins: []
27
+ }, fallback)
28
+ });
29
+
30
+ //#endregion
31
+ export { getPerLocaleDictionary };
32
+ //# sourceMappingURL=getLocalizedContent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLocalizedContent.mjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs"],"sourcesContent":["import { deepTransformNode } from \"../interpreter/getContent/deepTransform.mjs\";\nimport { translationPlugin } from \"../interpreter/getContent/plugins.mjs\";\n\n//#region src/deepTransformPlugins/getLocalizedContent.ts\n/**\n* Transforms a node in a single pass, applying each plugin as needed.\n* In comparison to `getContent`, this function will only apply the translation plugin.\n* It will not transform enumerations, insertions, or other content types.\n*\n* @param node The node to transform.\n* @param locale The locale to use if your transformers need it (e.g. for translations).\n*/\nconst getLocalizedContent = (node, locale, nodeProps, fallback) => {\n\tconst plugins = [translationPlugin(locale, fallback), ...nodeProps.plugins ?? []];\n\treturn deepTransformNode(node, {\n\t\t...nodeProps,\n\t\tplugins\n\t});\n};\nconst getPerLocaleDictionary = (dictionary, locale, fallback) => ({\n\t...dictionary,\n\tlocale,\n\tcontent: getLocalizedContent(dictionary.content, locale, {\n\t\tdictionaryKey: dictionary.key,\n\t\tkeyPath: [],\n\t\tplugins: []\n\t}, fallback)\n});\n\n//#endregion\nexport { getLocalizedContent, getPerLocaleDictionary };\n//# sourceMappingURL=getLocalizedContent.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,MAAM,uBAAuB,MAAM,QAAQ,WAAW,aAAa;CAClE,MAAM,UAAU,CAAC,kBAAkB,QAAQ,SAAS,EAAE,GAAG,UAAU,WAAW,EAAE,CAAC;AACjF,QAAO,kBAAkB,MAAM;EAC9B,GAAG;EACH;EACA,CAAC;;AAEH,MAAM,0BAA0B,YAAY,QAAQ,cAAc;CACjE,GAAG;CACH;CACA,SAAS,oBAAoB,WAAW,SAAS,QAAQ;EACxD,eAAe,WAAW;EAC1B,SAAS,EAAE;EACX,SAAS,EAAE;EACX,EAAE,SAAS;CACZ"}
@@ -0,0 +1,56 @@
1
+ const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
2
+ const require_isValidReactElement = require('../utils/isValidReactElement.cjs');
3
+ let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
4
+ _intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType, 1);
5
+
6
+ //#region ../../@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.mjs
7
+ /**
8
+ * Type guard to check if content is a TypedNode
9
+ */
10
+ const isTypedNode = (content) => {
11
+ return typeof content === "object" && content !== null && "nodeType" in content && typeof content.nodeType === "string";
12
+ };
13
+ /**
14
+ * Type guard to check if content is a valid NodeType
15
+ */
16
+ const isValidNodeType = (nodeType) => {
17
+ return [
18
+ _intlayer_types_nodeType.TRANSLATION,
19
+ _intlayer_types_nodeType.ENUMERATION,
20
+ _intlayer_types_nodeType.PLURAL,
21
+ _intlayer_types_nodeType.CONDITION,
22
+ _intlayer_types_nodeType.INSERTION,
23
+ _intlayer_types_nodeType.FILE,
24
+ _intlayer_types_nodeType.OBJECT,
25
+ _intlayer_types_nodeType.ARRAY,
26
+ _intlayer_types_nodeType.NESTED,
27
+ _intlayer_types_nodeType.REACT_NODE,
28
+ _intlayer_types_nodeType.MARKDOWN,
29
+ _intlayer_types_nodeType.HTML,
30
+ _intlayer_types_nodeType.TEXT,
31
+ _intlayer_types_nodeType.NUMBER,
32
+ _intlayer_types_nodeType.BOOLEAN,
33
+ _intlayer_types_nodeType.GENDER,
34
+ _intlayer_types_nodeType.NULL,
35
+ _intlayer_types_nodeType.UNKNOWN
36
+ ].includes(nodeType);
37
+ };
38
+ const getNodeType = (content) => {
39
+ if (typeof content === "string") return _intlayer_types_nodeType.TEXT;
40
+ if (isTypedNode(content)) {
41
+ const nodeType = content.nodeType;
42
+ if (isValidNodeType(nodeType)) return nodeType;
43
+ return _intlayer_types_nodeType.UNKNOWN;
44
+ }
45
+ if (Array.isArray(content)) return _intlayer_types_nodeType.ARRAY;
46
+ if (require_isValidReactElement.isValidElement(content)) return _intlayer_types_nodeType.REACT_NODE;
47
+ if (typeof content === "number") return _intlayer_types_nodeType.NUMBER;
48
+ if (typeof content === "boolean") return _intlayer_types_nodeType.BOOLEAN;
49
+ if (content && typeof content === "object") return _intlayer_types_nodeType.OBJECT;
50
+ if (content === null) return _intlayer_types_nodeType.NULL;
51
+ return _intlayer_types_nodeType.UNKNOWN;
52
+ };
53
+
54
+ //#endregion
55
+ exports.getNodeType = getNodeType;
56
+ //# sourceMappingURL=getNodeType.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNodeType.cjs","names":["NodeTypes","isValidElement"],"sources":["../../../../../../../../../@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.mjs"],"sourcesContent":["import { isValidElement } from \"../utils/isValidReactElement.mjs\";\nimport * as NodeTypes from \"@intlayer/types/nodeType\";\n\n//#region src/dictionaryManipulator/getNodeType.ts\n/**\n* Type guard to check if content is a TypedNode\n*/\nconst isTypedNode = (content) => {\n\treturn typeof content === \"object\" && content !== null && \"nodeType\" in content && typeof content.nodeType === \"string\";\n};\n/**\n* Type guard to check if content is a valid NodeType\n*/\nconst isValidNodeType = (nodeType) => {\n\treturn [\n\t\tNodeTypes.TRANSLATION,\n\t\tNodeTypes.ENUMERATION,\n\t\tNodeTypes.PLURAL,\n\t\tNodeTypes.CONDITION,\n\t\tNodeTypes.INSERTION,\n\t\tNodeTypes.FILE,\n\t\tNodeTypes.OBJECT,\n\t\tNodeTypes.ARRAY,\n\t\tNodeTypes.NESTED,\n\t\tNodeTypes.REACT_NODE,\n\t\tNodeTypes.MARKDOWN,\n\t\tNodeTypes.HTML,\n\t\tNodeTypes.TEXT,\n\t\tNodeTypes.NUMBER,\n\t\tNodeTypes.BOOLEAN,\n\t\tNodeTypes.GENDER,\n\t\tNodeTypes.NULL,\n\t\tNodeTypes.UNKNOWN\n\t].includes(nodeType);\n};\nconst getNodeType = (content) => {\n\tif (typeof content === \"string\") return NodeTypes.TEXT;\n\tif (isTypedNode(content)) {\n\t\tconst nodeType = content.nodeType;\n\t\tif (isValidNodeType(nodeType)) return nodeType;\n\t\treturn NodeTypes.UNKNOWN;\n\t}\n\tif (Array.isArray(content)) return NodeTypes.ARRAY;\n\tif (isValidElement(content)) return NodeTypes.REACT_NODE;\n\tif (typeof content === \"number\") return NodeTypes.NUMBER;\n\tif (typeof content === \"boolean\") return NodeTypes.BOOLEAN;\n\tif (content && typeof content === \"object\") return NodeTypes.OBJECT;\n\tif (content === null) return NodeTypes.NULL;\n\treturn NodeTypes.UNKNOWN;\n};\n\n//#endregion\nexport { getNodeType };\n//# sourceMappingURL=getNodeType.mjs.map"],"mappings":";;;;;;;;;AAOA,MAAM,eAAe,YAAY;AAChC,QAAO,OAAO,YAAY,YAAY,YAAY,QAAQ,cAAc,WAAW,OAAO,QAAQ,aAAa;;;;;AAKhH,MAAM,mBAAmB,aAAa;AACrC,QAAO;EACNA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACV,CAAC,SAAS,SAAS;;AAErB,MAAM,eAAe,YAAY;AAChC,KAAI,OAAO,YAAY,SAAU,QAAOA,yBAAU;AAClD,KAAI,YAAY,QAAQ,EAAE;EACzB,MAAM,WAAW,QAAQ;AACzB,MAAI,gBAAgB,SAAS,CAAE,QAAO;AACtC,SAAOA,yBAAU;;AAElB,KAAI,MAAM,QAAQ,QAAQ,CAAE,QAAOA,yBAAU;AAC7C,KAAIC,2CAAe,QAAQ,CAAE,QAAOD,yBAAU;AAC9C,KAAI,OAAO,YAAY,SAAU,QAAOA,yBAAU;AAClD,KAAI,OAAO,YAAY,UAAW,QAAOA,yBAAU;AACnD,KAAI,WAAW,OAAO,YAAY,SAAU,QAAOA,yBAAU;AAC7D,KAAI,YAAY,KAAM,QAAOA,yBAAU;AACvC,QAAOA,yBAAU"}