@intlayer/chokidar 8.0.4 → 8.0.5

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 (231) hide show
  1. package/dist/assets/installSkills/skills/angular.md +40 -0
  2. package/dist/assets/installSkills/skills/astro.md +13 -0
  3. package/dist/assets/installSkills/skills/config.md +5 -0
  4. package/dist/assets/installSkills/skills/content.md +127 -0
  5. package/dist/assets/installSkills/skills/extra_action.md +6 -0
  6. package/dist/assets/installSkills/skills/next_js.md +35 -0
  7. package/dist/assets/installSkills/skills/react.md +18 -0
  8. package/dist/assets/installSkills/skills/remote_content.md +6 -0
  9. package/dist/assets/installSkills/skills/setup.md +25 -0
  10. package/dist/assets/installSkills/skills/svelte.md +17 -0
  11. package/dist/assets/installSkills/skills/usage.md +103 -0
  12. package/dist/assets/installSkills/skills/vue.md +27 -0
  13. package/dist/cjs/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
  14. package/dist/cjs/_virtual/_utils_asset.cjs +1 -1
  15. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +2 -1
  16. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  17. package/dist/cjs/buildIntlayerDictionary/index.cjs +1 -0
  18. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +2 -1
  19. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
  20. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +2 -1
  21. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  22. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +2 -1
  23. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  24. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +2 -1
  25. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  26. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +2 -1
  27. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
  28. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +3 -2
  29. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
  30. package/dist/cjs/cleanOutputDir.cjs +2 -1
  31. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  32. package/dist/cjs/cleanRemovedContentDeclaration.cjs +3 -2
  33. package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
  34. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +2 -1
  35. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
  36. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +2 -1
  37. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
  38. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +3 -2
  39. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
  40. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +3 -2
  41. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
  42. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +3 -2
  43. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
  44. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +3 -2
  45. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
  46. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +3 -2
  47. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
  48. package/dist/cjs/createDictionaryEntryPoint/index.cjs +1 -0
  49. package/dist/cjs/createType/createModuleAugmentation.cjs +3 -2
  50. package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
  51. package/dist/cjs/createType/createType.cjs +2 -1
  52. package/dist/cjs/createType/createType.cjs.map +1 -1
  53. package/dist/cjs/createType/index.cjs +1 -0
  54. package/dist/cjs/fetchDistantDictionaries.cjs +2 -1
  55. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  56. package/dist/cjs/filterInvalidDictionaries.cjs +2 -1
  57. package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
  58. package/dist/cjs/formatDictionary.cjs +2 -1
  59. package/dist/cjs/formatDictionary.cjs.map +1 -1
  60. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +2 -1
  61. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  62. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +2 -1
  63. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
  64. package/dist/cjs/handleContentDeclarationFileChange.cjs +2 -1
  65. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  66. package/dist/cjs/handleContentDeclarationFileMoved.cjs +2 -1
  67. package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
  68. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +2 -1
  69. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
  70. package/dist/cjs/index.cjs +5 -0
  71. package/dist/cjs/init/index.cjs +75 -9
  72. package/dist/cjs/init/index.cjs.map +1 -1
  73. package/dist/cjs/init/utils/configManipulation.cjs +165 -0
  74. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -0
  75. package/dist/cjs/init/utils/fileSystem.cjs +2 -1
  76. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
  77. package/dist/cjs/init/utils/index.cjs +4 -0
  78. package/dist/cjs/init/utils/jsonParser.cjs +1 -0
  79. package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
  80. package/dist/cjs/init/utils/tsConfig.cjs +2 -1
  81. package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
  82. package/dist/cjs/initConfig/index.cjs +2 -1
  83. package/dist/cjs/initConfig/index.cjs.map +1 -1
  84. package/dist/cjs/installSkills/index.cjs +65 -0
  85. package/dist/cjs/installSkills/index.cjs.map +1 -0
  86. package/dist/cjs/listDictionariesPath.cjs +3 -2
  87. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  88. package/dist/cjs/listGitFiles.cjs +4 -3
  89. package/dist/cjs/listGitFiles.cjs.map +1 -1
  90. package/dist/cjs/listProjects.cjs +4 -3
  91. package/dist/cjs/listProjects.cjs.map +1 -1
  92. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +2 -1
  93. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
  94. package/dist/cjs/loadDictionaries/index.cjs +1 -0
  95. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +2 -1
  96. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
  97. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +2 -1
  98. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  99. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +2 -1
  100. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  101. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +2 -1
  102. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  103. package/dist/cjs/loadDictionaries/log.cjs +3 -2
  104. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  105. package/dist/cjs/prepareIntlayer.cjs +3 -2
  106. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  107. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +1 -0
  108. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
  109. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +2 -1
  110. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
  111. package/dist/cjs/transformFiles/extractDictionaryKey.cjs +2 -1
  112. package/dist/cjs/transformFiles/extractDictionaryKey.cjs.map +1 -1
  113. package/dist/cjs/transformFiles/index.cjs +1 -0
  114. package/dist/cjs/transformFiles/transformFiles.cjs +4 -3
  115. package/dist/cjs/transformFiles/transformFiles.cjs.map +1 -1
  116. package/dist/cjs/utils/autoDecorateContent.cjs +2 -1
  117. package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
  118. package/dist/cjs/utils/buildFilesList.cjs +3 -2
  119. package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
  120. package/dist/cjs/utils/chunkJSON.cjs +1 -0
  121. package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
  122. package/dist/cjs/utils/formatter.cjs +3 -2
  123. package/dist/cjs/utils/formatter.cjs.map +1 -1
  124. package/dist/cjs/utils/getChunk.cjs +1 -0
  125. package/dist/cjs/utils/getChunk.cjs.map +1 -1
  126. package/dist/cjs/utils/getComponentTransformPattern.cjs +6 -6
  127. package/dist/cjs/utils/getComponentTransformPattern.cjs.map +1 -1
  128. package/dist/cjs/utils/getFileHash.cjs +3 -2
  129. package/dist/cjs/utils/getFileHash.cjs.map +1 -1
  130. package/dist/cjs/utils/getFormatFromExtension.cjs +1 -0
  131. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
  132. package/dist/cjs/utils/pLimit.cjs +1 -0
  133. package/dist/cjs/utils/pLimit.cjs.map +1 -1
  134. package/dist/cjs/utils/parallelize.cjs +1 -0
  135. package/dist/cjs/utils/parallelize.cjs.map +1 -1
  136. package/dist/cjs/utils/parallelizeGlobal.cjs +1 -0
  137. package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
  138. package/dist/cjs/utils/reduceObjectFormat.cjs +1 -0
  139. package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
  140. package/dist/cjs/utils/resolveObjectPromises.cjs +1 -0
  141. package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
  142. package/dist/cjs/utils/runOnce.cjs +3 -2
  143. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  144. package/dist/cjs/utils/runParallel/bin.cjs +2 -1
  145. package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
  146. package/dist/cjs/utils/runParallel/bootstrap.cjs +1 -0
  147. package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
  148. package/dist/cjs/utils/runParallel/index.cjs +2 -1
  149. package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
  150. package/dist/cjs/utils/runParallel/pidTree.cjs +3 -2
  151. package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
  152. package/dist/cjs/utils/runParallel/ps.cjs +3 -2
  153. package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
  154. package/dist/cjs/utils/runParallel/runTask.cjs +2 -1
  155. package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
  156. package/dist/cjs/utils/runParallel/spawnPosix.cjs +2 -1
  157. package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
  158. package/dist/cjs/utils/runParallel/spawnWin32.cjs +2 -1
  159. package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
  160. package/dist/cjs/utils/runParallel/wmic.cjs +3 -2
  161. package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
  162. package/dist/cjs/utils/sortAlphabetically.cjs +1 -0
  163. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
  164. package/dist/cjs/utils/splitTextByLine.cjs +1 -0
  165. package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
  166. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +1 -0
  167. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
  168. package/dist/cjs/watcher.cjs +2 -1
  169. package/dist/cjs/watcher.cjs.map +1 -1
  170. package/dist/cjs/writeConfiguration/index.cjs +2 -1
  171. package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
  172. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +1 -0
  173. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  174. package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs +2 -1
  175. package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs.map +1 -1
  176. package/dist/cjs/writeContentDeclaration/index.cjs +1 -0
  177. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +2 -1
  178. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
  179. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +2 -1
  180. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
  181. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +2 -1
  182. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
  183. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +2 -1
  184. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  185. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +2 -1
  186. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  187. package/dist/cjs/writeFileIfChanged.cjs +2 -1
  188. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  189. package/dist/cjs/writeJsonIfChanged.cjs +1 -0
  190. package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
  191. package/dist/esm/_virtual/{rolldown_runtime.mjs → _rolldown/runtime.mjs} +1 -1
  192. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +1 -1
  193. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
  194. package/dist/esm/index.mjs +2 -1
  195. package/dist/esm/init/index.mjs +74 -9
  196. package/dist/esm/init/index.mjs.map +1 -1
  197. package/dist/esm/init/utils/configManipulation.mjs +162 -0
  198. package/dist/esm/init/utils/configManipulation.mjs.map +1 -0
  199. package/dist/esm/init/utils/index.mjs +2 -1
  200. package/dist/esm/installSkills/index.mjs +60 -0
  201. package/dist/esm/installSkills/index.mjs.map +1 -0
  202. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +1 -1
  203. package/dist/esm/transformFiles/transformFiles.mjs +1 -1
  204. package/dist/esm/utils/getComponentTransformPattern.mjs +4 -4
  205. package/dist/esm/utils/getComponentTransformPattern.mjs.map +1 -1
  206. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +2 -2
  207. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
  208. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
  209. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  210. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +3 -3
  211. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  212. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
  213. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
  214. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
  215. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
  216. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +2 -2
  217. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
  218. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
  219. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
  220. package/dist/types/index.d.ts +2 -1
  221. package/dist/types/init/index.d.ts.map +1 -1
  222. package/dist/types/init/utils/configManipulation.d.ts +18 -0
  223. package/dist/types/init/utils/configManipulation.d.ts.map +1 -0
  224. package/dist/types/init/utils/index.d.ts +2 -1
  225. package/dist/types/installSkills/index.d.ts +21 -0
  226. package/dist/types/installSkills/index.d.ts.map +1 -0
  227. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +2 -2
  228. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
  229. package/dist/types/watcher.d.ts +2 -2
  230. package/dist/types/watcher.d.ts.map +1 -1
  231. package/package.json +12 -12
@@ -0,0 +1,40 @@
1
+ # Intlayer Angular Usage
2
+
3
+ ## useIntlayer Composable
4
+
5
+ ```typescript
6
+ import { Component } from "@angular/core";
7
+ import { useIntlayer, ContentSelectorWrapperComponent } from "angular-intlayer";
8
+
9
+ @Component({
10
+ selector: "app-example",
11
+ standalone: true,
12
+ imports: [ContentSelectorWrapperComponent],
13
+ template: `
14
+ <div>
15
+ <h1>
16
+ <!-- Render the visual editor -->
17
+ <app-content-selector-wrapper
18
+ [dictionaryKey]="content().title.dictionaryKey"
19
+ [keyPath]="content().title.keyPath"
20
+ >
21
+ {{ content().title }}
22
+ </app-content-selector-wrapper>
23
+ </h1>
24
+ <h1>
25
+ <!-- Render as string -->
26
+ {{ content().title }}
27
+ </h1>
28
+ <img
29
+ [src]="content().image.src.value"
30
+ [alt]="content().image.alt.value"
31
+ />
32
+ </div>
33
+ `,
34
+ })
35
+ export class ExampleComponent {
36
+ content = useIntlayer("my-dictionary-key");
37
+ }
38
+ ```
39
+
40
+ [Angular Documentation](https://intlayer.org/doc/packages/angular-intlayer)
@@ -0,0 +1,13 @@
1
+ # Intlayer Astro Usage
2
+
3
+ ## Server-side (Astro Components)
4
+
5
+ ```astro
6
+ ---
7
+ import { getIntlayer } from "astro-intlayer";
8
+ const content = await getIntlayer("my-dictionary-key");
9
+ ---
10
+ <h1>{content.title}</h1>
11
+ ```
12
+
13
+ [Astro Documentation](https://intlayer.org/doc/packages/astro-intlayer)
@@ -0,0 +1,5 @@
1
+ # Intlayer Configuration
2
+
3
+ Understand how to configure Intlayer:
4
+
5
+ - [Configuration](https://intlayer.org/doc/concept/configuration.md)
@@ -0,0 +1,127 @@
1
+ # Intlayer Content Nodes
2
+
3
+ Intlayer provides various functions to define rich and dynamic content. Below is a reference for each node type.
4
+
5
+ ## Translation (`t`)
6
+
7
+ Define multilingual content mapped to locales.
8
+
9
+ [Doc](https://intlayer.org/doc/concept/content/translation.md)
10
+
11
+ ```typescript
12
+ import { t } from "intlayer";
13
+
14
+ const content = t({
15
+ en: "Hello",
16
+ fr: "Bonjour",
17
+ es: "Hola",
18
+ });
19
+ ```
20
+
21
+ ## Enumeration (`enu`)
22
+
23
+ Map content to specific keys, numbers, or ranges (useful for pluralization).
24
+
25
+ [Doc](https://intlayer.org/doc/concept/content/enumeration.md)
26
+
27
+ ```typescript
28
+ import { enu } from "intlayer";
29
+
30
+ const carCount = enu({
31
+ "0": "No cars",
32
+ "1": "One car",
33
+ ">1": "Multiple cars",
34
+ fallback: "Unknown amount",
35
+ });
36
+ ```
37
+
38
+ ## Condition (`cond`)
39
+
40
+ Define content based on a boolean condition.
41
+
42
+ [Doc](https://intlayer.org/doc/concept/content/condition.md)
43
+
44
+ ```typescript
45
+ import { cond } from "intlayer";
46
+
47
+ const isLoggedIn = cond({
48
+ true: "Welcome back!",
49
+ false: "Please log in",
50
+ fallback: "Status unknown", // Optional
51
+ });
52
+ ```
53
+
54
+ ## Markdown (`md`)
55
+
56
+ Define rich text using Markdown syntax.
57
+
58
+ [Doc](https://intlayer.org/doc/concept/content/markdown.md)
59
+
60
+ ```typescript
61
+ import { md } from "intlayer";
62
+
63
+ const article = md("# Title\n\nSome **bold** text.");
64
+ ```
65
+
66
+ ## HTML (`html`)
67
+
68
+ Define HTML content, optionally with custom components.
69
+
70
+ [Doc](https://intlayer.org/doc/concept/content/html.md)
71
+
72
+ ```typescript
73
+ import { html } from "intlayer";
74
+
75
+ const richText = html("<p>Hello <strong>World</strong></p>");
76
+ ```
77
+
78
+ ## Nesting (`nest`)
79
+
80
+ Reuse content from another dictionary.
81
+
82
+ [Doc](https://intlayer.org/doc/concept/content/nesting.md)
83
+
84
+ ```typescript
85
+ import { nest } from "intlayer";
86
+
87
+ // Reference entire dictionary
88
+ const fullRef = nest("other_dictionary_key");
89
+
90
+ // Reference specific path
91
+ const partialRef = nest("other_dictionary_key", "path.to.value");
92
+ ```
93
+
94
+ ## Function Fetching
95
+
96
+ Execute logic to generate content (synchronous or asynchronous).
97
+
98
+ [Doc](https://intlayer.org/doc/concept/content/function-fetching.md)
99
+
100
+ ```typescript
101
+ const computed = () => `Current time: ${new Date().toISOString()}`;
102
+
103
+ const fetched = async () => {
104
+ const data = await fetch("/api/data").then((res) => res.json());
105
+ return data.message;
106
+ };
107
+ ```
108
+
109
+ ## Gender (`gender`)
110
+
111
+ Define content based on gender ('male', 'female', etc.).
112
+
113
+ [Doc](https://intlayer.org/doc/concept/content/gender.md)
114
+
115
+ ```typescript
116
+ import { gender } from "intlayer";
117
+
118
+ const greeting = gender({
119
+ male: "Welcome sir",
120
+ female: "Welcome madam",
121
+ fallback: "Welcome",
122
+ });
123
+ ```
124
+
125
+ ---
126
+
127
+ [Content Overview](https://intlayer.org/doc/concept/content.md)
@@ -0,0 +1,6 @@
1
+ # Intlayer CLI & Extra Actions
2
+
3
+ For additional operations and CLI usage:
4
+
5
+ - [CLI Overview](https://intlayer.org/doc/concept/cli.md)
6
+ - [CLI Commands](https://intlayer.org/doc/packages/intlayer-cli.md)
@@ -0,0 +1,35 @@
1
+ # Intlayer Next.js Usage
2
+
3
+ ## Server Components
4
+
5
+ ```tsx
6
+ import { useIntlayer } from "next-intlayer/server";
7
+ const MyComponent = async () => {
8
+ const content = await useIntlayer("my-dictionary-key");
9
+ return (
10
+ <div>
11
+ <h1>{content.title}</h1>
12
+ <img src={content.image.src.value} alt={content.image.alt.value} />
13
+ </div>
14
+ );
15
+ };
16
+ ```
17
+
18
+ ## Client Components
19
+
20
+ ```tsx
21
+ "use client";
22
+ import { useIntlayer } from "next-intlayer";
23
+ const MyComponent = async () => {
24
+ const content = await useIntlayer("my-dictionary-key");
25
+ return (
26
+ <div>
27
+ <h1>{content.title}</h1>
28
+ <img src={content.image.src.value} alt={content.image.alt.value} />
29
+ </div>
30
+ );
31
+ };
32
+ ```
33
+
34
+ Use `useIntlayer` from `next-intlayer` exactly like in React.
35
+ [Next.js Documentation](https://intlayer.org/doc/packages/next-intlayer.md)
@@ -0,0 +1,18 @@
1
+ # Intlayer React Usage
2
+
3
+ ## useIntlayer Hook
4
+
5
+ ```tsx
6
+ import { useIntlayer } from "react-intlayer";
7
+ const MyComponent = () => {
8
+ const content = useIntlayer("my-dictionary-key");
9
+ return (
10
+ <div>
11
+ <h1>{content.title}</h1>
12
+ <img src={content.image.src.value} alt={content.image.alt.value} />
13
+ </div>
14
+ );
15
+ };
16
+ ```
17
+
18
+ [React Documentation](https://intlayer.org/doc/packages/react-intlayer)
@@ -0,0 +1,6 @@
1
+ # Intlayer Server Content & CMS
2
+
3
+ For managing server-side content and using the Intlayer CMS:
4
+
5
+ - [Intlayer CMS Documentation](https://intlayer.org/cms.md)
6
+ - [Fetching Content Functions](https://intlayer.org/doc/concept/content/function-fetching.md)
@@ -0,0 +1,25 @@
1
+ # Intlayer Setup
2
+
3
+ To set up Intlayer, please refer to the documentation specific to your framework:
4
+
5
+ - [Angular](https://intlayer.org/doc/environment/angular.md)
6
+ - [Astro](https://intlayer.org/doc/environment/astro.md)
7
+ - [Create React App](https://intlayer.org/doc/environment/create-react-app.md)
8
+ - [Express](https://intlayer.org/doc/environment/express.md)
9
+ - [Fastify](https://intlayer.org/doc/environment/fastify.md)
10
+ - [Lynx and React](https://intlayer.org/doc/environment/lynx-and-react.md)
11
+ - [Nest](https://intlayer.org/doc/environment/nest.md)
12
+ - [Next.js](https://intlayer.org/doc/environment/nextjs.md)
13
+ - [Next.js 14](https://intlayer.org/doc/environment/nextjs/14.md)
14
+ - [Next.js 15](https://intlayer.org/doc/environment/nextjs/15.md)
15
+ - [Next.js No Locale Path](https://intlayer.org/doc/environment/nextjs/no-locale-path.md)
16
+ - [Next.js with Page Router](https://intlayer.org/doc/environment/nextjs/next-with-page-router.md)
17
+ - [Nuxt and Vue](https://intlayer.org/doc/environment/nuxt-and-vue.md)
18
+ - [React Native and Expo](https://intlayer.org/doc/environment/react-native-and-expo.md)
19
+ - [Vite and React (React Router v7)](https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md)
20
+ - [SvelteKit](https://intlayer.org/doc/environment/sveltekit.md)
21
+ - [Vite and Preact](https://intlayer.org/doc/environment/vite-and-preact.md)
22
+ - [Vite and React](https://intlayer.org/doc/environment/vite-and-react.md)
23
+ - [Vite and Solid](https://intlayer.org/doc/environment/vite-and-solid.md)
24
+ - [Vite and Svelte](https://intlayer.org/doc/environment/vite-and-svelte.md)
25
+ - [Vite and Vue](https://intlayer.org/doc/environment/vite-and-vue.md)
@@ -0,0 +1,17 @@
1
+ # Intlayer Svelte Usage
2
+
3
+ ## useIntlayer Hook
4
+
5
+ ```svelte
6
+ <script>
7
+ import { useIntlayer } from "svelte-intlayer";
8
+ const content = useIntlayer("my-dictionary-key");
9
+ </script>
10
+ <div>
11
+ <h1>{$content.title}</h1>
12
+ <div aria-label={$content.title.value}></div>
13
+ <svelte:component this={$content.title} />
14
+ </div>
15
+ ```
16
+
17
+ [Svelte Documentation](https://intlayer.org/doc/intlayer_with_svelte_kit)
@@ -0,0 +1,103 @@
1
+ # Intlayer Usage
2
+
3
+ To use Intlayer effectively:
4
+
5
+ 1. **Retrieve Locales**: Check `intlayer.config.{ts,js,json,json5,jsonc,cjs,mjs}`, `.intlayerrc` to see the configured locales.
6
+
7
+ 2. **Declare Content**:
8
+ We recommend creating one content declaration file per component, located alongside the component file. This keeps translations close to the code.
9
+
10
+ **Example Directory Structure:**
11
+
12
+ ```
13
+ src/
14
+ ├── components/
15
+ │ ├── MyComponent/
16
+ │ │ ├── index.content.ts # Content declaration
17
+ │ │ └── index.tsx # Component
18
+ │ ├── MyOtherComponent.content.ts # Content declaration
19
+ │ └── MyOtherComponent.tsx # Component
20
+ ```
21
+
22
+ **Content Templates:**
23
+
24
+ _TypeScript (.content.ts)_
25
+
26
+ ```typescript
27
+ import { t, type Dictionary } from "intlayer";
28
+
29
+ const content = {
30
+ key: "my-component-key",
31
+ content: {
32
+ title: t({
33
+ en: "Hello World",
34
+ es: "Hola Mundo",
35
+ }),
36
+ description: "My description text",
37
+ },
38
+ } satisfies Dictionary;
39
+
40
+ export default content;
41
+ ```
42
+
43
+ _TypeScript with React (.content.tsx)_
44
+
45
+ ```tsx
46
+ import { t, type Dictionary } from "intlayer";
47
+ import { ReactNode } from "react";
48
+
49
+ const content = {
50
+ key: "my-component-key",
51
+ content: {
52
+ description: t<ReactNode>({
53
+ en: <>My description text</>,
54
+ es: <>Mi descripción de texto</>,
55
+ }),
56
+ },
57
+ } satisfies Dictionary;
58
+
59
+ export default content;
60
+ ```
61
+
62
+ ```json
63
+ {
64
+ "key": "my-component-key",
65
+ "content": {
66
+ "title": {
67
+ "en": "Hello World",
68
+ "fr": "Bonjour le monde"
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ ```javascript
75
+ import { t } from "intlayer";
76
+
77
+ export default {
78
+ key: "my-component-key",
79
+ content: {
80
+ title: t({
81
+ en: "Hello World",
82
+ fr: "Bonjour le monde",
83
+ }),
84
+ },
85
+ };
86
+ ```
87
+
88
+ - [Content Declaration Documentation](https://intlayer.org/doc/concept/content.md)
89
+ - [Content File Format](https://intlayer.org/doc/concept/content/file.md)
90
+
91
+ 3. **Consume Content**: Use the provided hooks and functions to access your content.
92
+ - [Intlayer Exports](https://intlayer.org/doc/packages/intlayer/exports.md)
93
+ - [React Intlayer Exports](https://intlayer.org/doc/packages/react-intlayer/exports.md)
94
+
95
+ **Common Packages:**
96
+ - `intlayer`: Core package for content declaration and utility functions.
97
+ - `react-intlayer`: React components and hooks (e.g., `useIntlayer`).
98
+ - `vite-intlayer`: Vite plugin for integration.
99
+
100
+ 4. **CLI Commands**:
101
+ Useful commands for managing your content:
102
+ - `npx intlayer build`: Build the dictionaries from your content declarations.
103
+ - `npx intlayer watch`: Watch for changes in content files and rebuild automatically.
@@ -0,0 +1,27 @@
1
+ # Intlayer Vue Usage
2
+
3
+ ## useIntlayer Composable
4
+
5
+ ```vue
6
+ <script setup>
7
+ import { useIntlayer } from "vue-intlayer";
8
+ const content = useIntlayer("my-dictionary-key");
9
+
10
+ console.log(content.title.raw); // Render as raw
11
+ </script>
12
+ <template>
13
+ <div>
14
+ <h1>
15
+ <!-- Render the visual editor -->
16
+ <content.title />
17
+ </h1>
18
+ <h1>
19
+ <!-- Render as string -->
20
+ {{ content.title }}
21
+ </h1>
22
+ <img :src="content.image.src" :alt="content.image.alt" />
23
+ </div>
24
+ </template>
25
+ ```
26
+
27
+ [Vue Documentation](https://intlayer.org/doc/packages/vue-intlayer)
@@ -1,4 +1,4 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,4 +1,4 @@
1
- const require_rolldown_runtime = require('./rolldown_runtime.cjs');
1
+ const require_runtime = require('./_rolldown/runtime.cjs');
2
2
  let node_fs = require("node:fs");
3
3
  let node_path = require("node:path");
4
4
  let node_url = require("node:url");
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  const require_buildIntlayerDictionary_writeDynamicDictionary = require('./writeDynamicDictionary.cjs');
3
4
  const require_buildIntlayerDictionary_writeFetchDictionary = require('./writeFetchDictionary.cjs');
4
5
  const require_buildIntlayerDictionary_writeMergedDictionary = require('./writeMergedDictionary.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"buildIntlayerDictionary.cjs","names":["DefaultValues","writeUnmergedDictionaries","writeMergedDictionaries","writeDynamicDictionary","writeFetchDictionary"],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { DefaultValues, getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n type LocalizedDictionaryOutput,\n writeDynamicDictionary,\n} from './writeDynamicDictionary';\nimport { writeFetchDictionary } from './writeFetchDictionary';\nimport { writeMergedDictionaries } from './writeMergedDictionary';\nimport { writeUnmergedDictionaries } from './writeUnmergedDictionary';\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const buildDictionary = async (\n localDictionariesEntries: Dictionary[],\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm'],\n importOtherDictionaries = true\n) => {\n const importMode =\n configuration.build.importMode ??\n configuration.dictionary?.importMode ??\n DefaultValues.Dictionary.IMPORT_MODE;\n\n const unmergedDictionariesToUpdate: Dictionary[] = [\n ...localDictionariesEntries,\n ];\n\n if (importOtherDictionaries) {\n const prevUnmergedDictionaries: Record<string, Dictionary[]> =\n getUnmergedDictionaries(configuration);\n\n // Reinsert other dictionaries with the same key to avoid merging errors\n for (const dictionaryToWrite of localDictionariesEntries) {\n const allPrebuiltUnmergedDictionaries =\n prevUnmergedDictionaries[dictionaryToWrite.key];\n\n if (allPrebuiltUnmergedDictionaries?.length > 0) {\n // Do not add the same dictionary again by filtering out the one with the same localId\n const otherUnmergedDictionaries =\n allPrebuiltUnmergedDictionaries.filter(\n (unmergedDictionary) =>\n unmergedDictionary.localId !== dictionaryToWrite.localId\n );\n\n unmergedDictionariesToUpdate.push(...otherUnmergedDictionaries);\n }\n }\n }\n\n const unmergedDictionaries = await writeUnmergedDictionaries(\n unmergedDictionariesToUpdate,\n configuration\n );\n\n const mergedDictionaries = await writeMergedDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n const dictionariesToBuildDynamic: typeof mergedDictionaries = {};\n const keysToBuildFetch = new Set<string>();\n\n for (const [key, mergedResult] of Object.entries(mergedDictionaries)) {\n const dictionary = mergedResult.dictionary;\n const mode = dictionary.importMode ?? importMode;\n\n if (mode === 'dynamic' || mode === 'fetch') {\n dictionariesToBuildDynamic[key] = mergedResult;\n }\n\n if (mode === 'fetch') {\n keysToBuildFetch.add(key);\n }\n }\n\n let dynamicDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (Object.keys(dictionariesToBuildDynamic).length > 0) {\n dynamicDictionaries = await writeDynamicDictionary(\n dictionariesToBuildDynamic,\n configuration,\n formats\n );\n }\n\n let fetchDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (dynamicDictionaries && keysToBuildFetch.size > 0) {\n const dictionariesToBuildFetch: LocalizedDictionaryOutput = {};\n\n for (const key of keysToBuildFetch) {\n if (dynamicDictionaries[key]) {\n dictionariesToBuildFetch[key] = dynamicDictionaries[key];\n }\n }\n\n if (Object.keys(dictionariesToBuildFetch).length > 0) {\n fetchDictionaries = await writeFetchDictionary(\n dictionariesToBuildFetch,\n configuration,\n formats\n );\n }\n }\n\n return {\n unmergedDictionaries,\n mergedDictionaries,\n dynamicDictionaries,\n fetchDictionaries,\n };\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,kBAAkB,OAC7B,0BACA,wDAAkC,EAClC,UAA6B,CAAC,OAAO,MAAM,EAC3C,0BAA0B,SACvB;CACH,MAAM,aACJ,cAAc,MAAM,cACpB,cAAc,YAAY,cAC1BA,+BAAc,WAAW;CAE3B,MAAM,+BAA6C,CACjD,GAAG,yBACJ;AAED,KAAI,yBAAyB;EAC3B,MAAM,8FACoB,cAAc;AAGxC,OAAK,MAAM,qBAAqB,0BAA0B;GACxD,MAAM,kCACJ,yBAAyB,kBAAkB;AAE7C,OAAI,iCAAiC,SAAS,GAAG;IAE/C,MAAM,4BACJ,gCAAgC,QAC7B,uBACC,mBAAmB,YAAY,kBAAkB,QACpD;AAEH,iCAA6B,KAAK,GAAG,0BAA0B;;;;CAKrE,MAAM,uBAAuB,MAAMC,kFACjC,8BACA,cACD;CAED,MAAM,qBAAqB,MAAMC,8EAC/B,sBACA,cACD;CAED,MAAM,6BAAwD,EAAE;CAChE,MAAM,mCAAmB,IAAI,KAAa;AAE1C,MAAK,MAAM,CAAC,KAAK,iBAAiB,OAAO,QAAQ,mBAAmB,EAAE;EAEpE,MAAM,OADa,aAAa,WACR,cAAc;AAEtC,MAAI,SAAS,aAAa,SAAS,QACjC,4BAA2B,OAAO;AAGpC,MAAI,SAAS,QACX,kBAAiB,IAAI,IAAI;;CAI7B,IAAI,sBAAwD;AAE5D,KAAI,OAAO,KAAK,2BAA2B,CAAC,SAAS,EACnD,uBAAsB,MAAMC,8EAC1B,4BACA,eACA,QACD;CAGH,IAAI,oBAAsD;AAE1D,KAAI,uBAAuB,iBAAiB,OAAO,GAAG;EACpD,MAAM,2BAAsD,EAAE;AAE9D,OAAK,MAAM,OAAO,iBAChB,KAAI,oBAAoB,KACtB,0BAAyB,OAAO,oBAAoB;AAIxD,MAAI,OAAO,KAAK,yBAAyB,CAAC,SAAS,EACjD,qBAAoB,MAAMC,0EACxB,0BACA,eACA,QACD;;AAIL,QAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"buildIntlayerDictionary.cjs","names":["DefaultValues","writeUnmergedDictionaries","writeMergedDictionaries","writeDynamicDictionary","writeFetchDictionary"],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { DefaultValues, getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n type LocalizedDictionaryOutput,\n writeDynamicDictionary,\n} from './writeDynamicDictionary';\nimport { writeFetchDictionary } from './writeFetchDictionary';\nimport { writeMergedDictionaries } from './writeMergedDictionary';\nimport { writeUnmergedDictionaries } from './writeUnmergedDictionary';\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const buildDictionary = async (\n localDictionariesEntries: Dictionary[],\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm'],\n importOtherDictionaries = true\n) => {\n const importMode =\n configuration.build.importMode ??\n configuration.dictionary?.importMode ??\n DefaultValues.Dictionary.IMPORT_MODE;\n\n const unmergedDictionariesToUpdate: Dictionary[] = [\n ...localDictionariesEntries,\n ];\n\n if (importOtherDictionaries) {\n const prevUnmergedDictionaries: Record<string, Dictionary[]> =\n getUnmergedDictionaries(configuration);\n\n // Reinsert other dictionaries with the same key to avoid merging errors\n for (const dictionaryToWrite of localDictionariesEntries) {\n const allPrebuiltUnmergedDictionaries =\n prevUnmergedDictionaries[dictionaryToWrite.key];\n\n if (allPrebuiltUnmergedDictionaries?.length > 0) {\n // Do not add the same dictionary again by filtering out the one with the same localId\n const otherUnmergedDictionaries =\n allPrebuiltUnmergedDictionaries.filter(\n (unmergedDictionary) =>\n unmergedDictionary.localId !== dictionaryToWrite.localId\n );\n\n unmergedDictionariesToUpdate.push(...otherUnmergedDictionaries);\n }\n }\n }\n\n const unmergedDictionaries = await writeUnmergedDictionaries(\n unmergedDictionariesToUpdate,\n configuration\n );\n\n const mergedDictionaries = await writeMergedDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n const dictionariesToBuildDynamic: typeof mergedDictionaries = {};\n const keysToBuildFetch = new Set<string>();\n\n for (const [key, mergedResult] of Object.entries(mergedDictionaries)) {\n const dictionary = mergedResult.dictionary;\n const mode = dictionary.importMode ?? importMode;\n\n if (mode === 'dynamic' || mode === 'fetch') {\n dictionariesToBuildDynamic[key] = mergedResult;\n }\n\n if (mode === 'fetch') {\n keysToBuildFetch.add(key);\n }\n }\n\n let dynamicDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (Object.keys(dictionariesToBuildDynamic).length > 0) {\n dynamicDictionaries = await writeDynamicDictionary(\n dictionariesToBuildDynamic,\n configuration,\n formats\n );\n }\n\n let fetchDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (dynamicDictionaries && keysToBuildFetch.size > 0) {\n const dictionariesToBuildFetch: LocalizedDictionaryOutput = {};\n\n for (const key of keysToBuildFetch) {\n if (dynamicDictionaries[key]) {\n dictionariesToBuildFetch[key] = dynamicDictionaries[key];\n }\n }\n\n if (Object.keys(dictionariesToBuildFetch).length > 0) {\n fetchDictionaries = await writeFetchDictionary(\n dictionariesToBuildFetch,\n configuration,\n formats\n );\n }\n }\n\n return {\n unmergedDictionaries,\n mergedDictionaries,\n dynamicDictionaries,\n fetchDictionaries,\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,kBAAkB,OAC7B,0BACA,wDAAkC,EAClC,UAA6B,CAAC,OAAO,MAAM,EAC3C,0BAA0B,SACvB;CACH,MAAM,aACJ,cAAc,MAAM,cACpB,cAAc,YAAY,cAC1BA,+BAAc,WAAW;CAE3B,MAAM,+BAA6C,CACjD,GAAG,yBACJ;AAED,KAAI,yBAAyB;EAC3B,MAAM,8FACoB,cAAc;AAGxC,OAAK,MAAM,qBAAqB,0BAA0B;GACxD,MAAM,kCACJ,yBAAyB,kBAAkB;AAE7C,OAAI,iCAAiC,SAAS,GAAG;IAE/C,MAAM,4BACJ,gCAAgC,QAC7B,uBACC,mBAAmB,YAAY,kBAAkB,QACpD;AAEH,iCAA6B,KAAK,GAAG,0BAA0B;;;;CAKrE,MAAM,uBAAuB,MAAMC,kFACjC,8BACA,cACD;CAED,MAAM,qBAAqB,MAAMC,8EAC/B,sBACA,cACD;CAED,MAAM,6BAAwD,EAAE;CAChE,MAAM,mCAAmB,IAAI,KAAa;AAE1C,MAAK,MAAM,CAAC,KAAK,iBAAiB,OAAO,QAAQ,mBAAmB,EAAE;EAEpE,MAAM,OADa,aAAa,WACR,cAAc;AAEtC,MAAI,SAAS,aAAa,SAAS,QACjC,4BAA2B,OAAO;AAGpC,MAAI,SAAS,QACX,kBAAiB,IAAI,IAAI;;CAI7B,IAAI,sBAAwD;AAE5D,KAAI,OAAO,KAAK,2BAA2B,CAAC,SAAS,EACnD,uBAAsB,MAAMC,8EAC1B,4BACA,eACA,QACD;CAGH,IAAI,oBAAsD;AAE1D,KAAI,uBAAuB,iBAAiB,OAAO,GAAG;EACpD,MAAM,2BAAsD,EAAE;AAE9D,OAAK,MAAM,OAAO,iBAChB,KAAI,oBAAoB,KACtB,0BAAyB,OAAO,oBAAoB;AAIxD,MAAI,OAAO,KAAK,yBAAyB,CAAC,SAAS,EACjD,qBAAoB,MAAMC,0EACxB,0BACA,eACA,QACD;;AAIL,QAAO;EACL;EACA;EACA;EACA;EACD"}
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
  const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary.cjs');
2
3
  const require_buildIntlayerDictionary_processContentDeclaration = require('./processContentDeclaration.cjs');
3
4
 
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  const require_utils_autoDecorateContent = require('../utils/autoDecorateContent.cjs');
3
4
  const require_utils_resolveObjectPromises = require('../utils/resolveObjectPromises.cjs');
4
5
  let _intlayer_config_client = require("@intlayer/config/client");
@@ -1 +1 @@
1
- {"version":3,"file":"processContentDeclaration.cjs","names":["resolveObjectPromises","autoDecorateContent"],"sources":["../../../src/buildIntlayerDictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { autoDecorateContent } from '../utils/autoDecorateContent';\nimport { resolveObjectPromises } from '../utils/resolveObjectPromises';\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary,\n configuration: IntlayerConfig\n): Promise<Dictionary | undefined> => {\n try {\n const resolvedContent = (await resolveObjectPromises(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n const isAutoDecorateContentEnabled =\n contentDeclaration.contentAutoTransformation ??\n configuration.dictionary?.contentAutoTransformation ??\n false;\n\n const decoratedContent = isAutoDecorateContentEnabled\n ? autoDecorateContent(resolvedContent, isAutoDecorateContentEnabled)\n : resolvedContent;\n\n return {\n ...contentDeclaration,\n content: decoratedContent,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,4BAA4B,OACvC,oBACA,kBACoC;AACpC,KAAI;EACF,MAAM,kBAAmB,MAAMA,0DAC7B,mBAAmB,QACpB;EAED,MAAM,+BACJ,mBAAmB,6BACnB,cAAc,YAAY,6BAC1B;EAEF,MAAM,mBAAmB,+BACrBC,sDAAoB,iBAAiB,6BAA6B,GAClE;AAEJ,SAAO;GACL,GAAG;GACH,SAAS;GACV;UACM,OAAO;AACd,sCAAO,OAAO,EACZ,OAAO,SACR,CAAC"}
1
+ {"version":3,"file":"processContentDeclaration.cjs","names":["resolveObjectPromises","autoDecorateContent"],"sources":["../../../src/buildIntlayerDictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { autoDecorateContent } from '../utils/autoDecorateContent';\nimport { resolveObjectPromises } from '../utils/resolveObjectPromises';\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary,\n configuration: IntlayerConfig\n): Promise<Dictionary | undefined> => {\n try {\n const resolvedContent = (await resolveObjectPromises(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n const isAutoDecorateContentEnabled =\n contentDeclaration.contentAutoTransformation ??\n configuration.dictionary?.contentAutoTransformation ??\n false;\n\n const decoratedContent = isAutoDecorateContentEnabled\n ? autoDecorateContent(resolvedContent, isAutoDecorateContentEnabled)\n : resolvedContent;\n\n return {\n ...contentDeclaration,\n content: decoratedContent,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,4BAA4B,OACvC,oBACA,kBACoC;AACpC,KAAI;EACF,MAAM,kBAAmB,MAAMA,0DAC7B,mBAAmB,QACpB;EAED,MAAM,+BACJ,mBAAmB,6BACnB,cAAc,YAAY,6BAC1B;EAEF,MAAM,mBAAmB,+BACrBC,sDAAoB,iBAAiB,6BAA6B,GAClE;AAEJ,SAAO;GACL,GAAG;GACH,SAAS;GACV;UACM,OAAO;AACd,sCAAO,OAAO,EACZ,OAAO,SACR,CAAC"}
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  const require_utils_parallelize = require('../utils/parallelize.cjs');
3
4
  const require_writeFileIfChanged = require('../writeFileIfChanged.cjs');
4
5
  const require_writeJsonIfChanged = require('../writeJsonIfChanged.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"writeDynamicDictionary.cjs","names":["parallelize","writeJsonIfChanged","writeFileIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport {\n colorizePath,\n getConfiguration,\n normalizePath,\n} from '@intlayer/config';\nimport { getPerLocaleDictionary } from '@intlayer/core';\nimport type { Dictionary, Locale } from '@intlayer/types';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { MergedDictionaryOutput } from './writeMergedDictionary';\n\nexport type DictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type LocalizedDictionaryResult = Partial<\n Record<Locale, DictionaryResult>\n>;\n\nexport type LocalizedDictionaryOutput = Record<\n string,\n LocalizedDictionaryResult\n>;\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { dynamicDictionariesDir } = configuration.system;\n\n let content = '';\n\n // Format Dictionary Map - map locales to functions\n const formattedDictionaryMap: string = Object.entries(\n localizedDictionariesPathsRecord\n )\n // The following filter/sort preserve determinism of the generated map\n // when files are built in parallel or across different Node versions.\n .filter((entry): entry is [string, DictionaryResult] => Boolean(entry[1]))\n .sort(([a], [b]) => String(a).localeCompare(String(b)))\n .map(([locale, dictionary]) => {\n const relativePath = normalizePath(\n relative(dynamicDictionariesDir, dictionary.dictionaryPath)\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)`;\n }\n\n return ` '${locale}': () => Promise.resolve(require('./${relativePath}'))`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dynamic_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeDynamicDictionary = async (\n mergedDictionaries: MergedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dynamicDictionariesDir), { recursive: true });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Merge dictionaries with the same key and write to dictionariesDir\n await parallelize(\n Object.entries(mergedDictionaries).sort(([a], [b]) =>\n String(a).localeCompare(String(b))\n ),\n async ([key, dictionaryEntry]) => {\n if (key === 'undefined') return;\n\n const localizedDictionariesPathsRecord: LocalizedDictionaryResult = {};\n\n await parallelize(locales, async (locale) => {\n const localizedDictionary = getPerLocaleDictionary(\n dictionaryEntry.dictionary,\n locale,\n defaultLocale\n );\n\n const outputFileName = `${key}.${locale}.json`;\n const resultFilePath = resolve(dynamicDictionariesDir, outputFileName);\n\n // Write the localized dictionary\n await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n (err) => {\n console.error(`Error creating localized ${outputFileName}:`, err);\n }\n );\n\n localizedDictionariesPathsRecord[locale] = {\n dictionaryPath: resultFilePath,\n dictionary: localizedDictionary,\n };\n });\n\n resultDictionariesPaths[key] = localizedDictionariesPathsRecord;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localizedDictionariesPathsRecord,\n format,\n configuration\n );\n\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;AA+BA,MAAa,gCACX,kCACA,SAAwB,OACxB,wDAAkC,KACvB;CACX,MAAM,EAAE,2BAA2B,cAAc;CAEjD,IAAI,UAAU;CAGd,MAAM,yBAAiC,OAAO,QAC5C,iCACD,CAGE,QAAQ,UAA+C,QAAQ,MAAM,GAAG,CAAC,CACzE,MAAM,CAAC,IAAI,CAAC,OAAO,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC,CACtD,KAAK,CAAC,QAAQ,gBAAgB;EAC7B,MAAM,2EACK,wBAAwB,WAAW,eAAe,CAC5D;AAED,MAAI,WAAW,MACb,QAAO,MAAM,OAAO,qBAAqB,aAAa;AAGxD,SAAO,MAAM,OAAO,sCAAsC,aAAa;GACvE,CACD,KAAK,MAAM;AAEd,YAAW,sBAAsB,uBAAuB;AAExD,KAAI,WAAW,MAAO,YAAW;AACjC,KAAI,WAAW,MAAO,YAAW;AAEjC,QAAO;;;;;;;;;;;;;;;;;;AAmBT,MAAa,yBAAyB,OACpC,oBACA,wDAAkC,EAClC,UAA6B,CAAC,OAAO,MAAM,KACJ;CACvC,MAAM,EAAE,SAAS,kBAAkB,cAAc;CACjD,MAAM,EAAE,2BAA2B,cAAc;AAGjD,0DAAoB,uBAAuB,EAAE,EAAE,WAAW,MAAM,CAAC;CAEjE,MAAM,0BAAqD,EAAE;AAG7D,OAAMA,sCACJ,OAAO,QAAQ,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,OAC7C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC,EACD,OAAO,CAAC,KAAK,qBAAqB;AAChC,MAAI,QAAQ,YAAa;EAEzB,MAAM,mCAA8D,EAAE;AAEtE,QAAMA,sCAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,iEACJ,gBAAgB,YAChB,QACA,cACD;GAED,MAAM,iBAAiB,GAAG,IAAI,GAAG,OAAO;GACxC,MAAM,wCAAyB,wBAAwB,eAAe;AAGtE,SAAMC,8CAAmB,gBAAgB,oBAAoB,CAAC,OAC3D,QAAQ;AACP,YAAQ,MAAM,4BAA4B,eAAe,IAAI,IAAI;KAEpE;AAED,oCAAiC,UAAU;IACzC,gBAAgB;IAChB,YAAY;IACb;IACD;AAEF,0BAAwB,OAAO;AAE/B,QAAMD,sCAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;GAC7C,MAAM,UAAU,6BACd,kCACA,QACA,cACD;AAED,SAAME,qEACI,wBAAwB,GAAG,IAAI,GAAG,YAAY,EACtD,QACD,CAAC,OAAO,QAAQ;AACf,YAAQ,MACN,oFAA+C,wBAAwB,GAAG,IAAI,GAAG,YAAY,CAAC,CAAC,IAC/F,IACD;KACD;IACF;GAEL;AAED,QAAO"}
1
+ {"version":3,"file":"writeDynamicDictionary.cjs","names":["parallelize","writeJsonIfChanged","writeFileIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport {\n colorizePath,\n getConfiguration,\n normalizePath,\n} from '@intlayer/config';\nimport { getPerLocaleDictionary } from '@intlayer/core';\nimport type { Dictionary, Locale } from '@intlayer/types';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { MergedDictionaryOutput } from './writeMergedDictionary';\n\nexport type DictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type LocalizedDictionaryResult = Partial<\n Record<Locale, DictionaryResult>\n>;\n\nexport type LocalizedDictionaryOutput = Record<\n string,\n LocalizedDictionaryResult\n>;\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { dynamicDictionariesDir } = configuration.system;\n\n let content = '';\n\n // Format Dictionary Map - map locales to functions\n const formattedDictionaryMap: string = Object.entries(\n localizedDictionariesPathsRecord\n )\n // The following filter/sort preserve determinism of the generated map\n // when files are built in parallel or across different Node versions.\n .filter((entry): entry is [string, DictionaryResult] => Boolean(entry[1]))\n .sort(([a], [b]) => String(a).localeCompare(String(b)))\n .map(([locale, dictionary]) => {\n const relativePath = normalizePath(\n relative(dynamicDictionariesDir, dictionary.dictionaryPath)\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)`;\n }\n\n return ` '${locale}': () => Promise.resolve(require('./${relativePath}'))`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dynamic_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeDynamicDictionary = async (\n mergedDictionaries: MergedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dynamicDictionariesDir), { recursive: true });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Merge dictionaries with the same key and write to dictionariesDir\n await parallelize(\n Object.entries(mergedDictionaries).sort(([a], [b]) =>\n String(a).localeCompare(String(b))\n ),\n async ([key, dictionaryEntry]) => {\n if (key === 'undefined') return;\n\n const localizedDictionariesPathsRecord: LocalizedDictionaryResult = {};\n\n await parallelize(locales, async (locale) => {\n const localizedDictionary = getPerLocaleDictionary(\n dictionaryEntry.dictionary,\n locale,\n defaultLocale\n );\n\n const outputFileName = `${key}.${locale}.json`;\n const resultFilePath = resolve(dynamicDictionariesDir, outputFileName);\n\n // Write the localized dictionary\n await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n (err) => {\n console.error(`Error creating localized ${outputFileName}:`, err);\n }\n );\n\n localizedDictionariesPathsRecord[locale] = {\n dictionaryPath: resultFilePath,\n dictionary: localizedDictionary,\n };\n });\n\n resultDictionariesPaths[key] = localizedDictionariesPathsRecord;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localizedDictionariesPathsRecord,\n format,\n configuration\n );\n\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;AA+BA,MAAa,gCACX,kCACA,SAAwB,OACxB,wDAAkC,KACvB;CACX,MAAM,EAAE,2BAA2B,cAAc;CAEjD,IAAI,UAAU;CAGd,MAAM,yBAAiC,OAAO,QAC5C,iCACD,CAGE,QAAQ,UAA+C,QAAQ,MAAM,GAAG,CAAC,CACzE,MAAM,CAAC,IAAI,CAAC,OAAO,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC,CACtD,KAAK,CAAC,QAAQ,gBAAgB;EAC7B,MAAM,2EACK,wBAAwB,WAAW,eAAe,CAC5D;AAED,MAAI,WAAW,MACb,QAAO,MAAM,OAAO,qBAAqB,aAAa;AAGxD,SAAO,MAAM,OAAO,sCAAsC,aAAa;GACvE,CACD,KAAK,MAAM;AAEd,YAAW,sBAAsB,uBAAuB;AAExD,KAAI,WAAW,MAAO,YAAW;AACjC,KAAI,WAAW,MAAO,YAAW;AAEjC,QAAO;;;;;;;;;;;;;;;;;;AAmBT,MAAa,yBAAyB,OACpC,oBACA,wDAAkC,EAClC,UAA6B,CAAC,OAAO,MAAM,KACJ;CACvC,MAAM,EAAE,SAAS,kBAAkB,cAAc;CACjD,MAAM,EAAE,2BAA2B,cAAc;AAGjD,0DAAoB,uBAAuB,EAAE,EAAE,WAAW,MAAM,CAAC;CAEjE,MAAM,0BAAqD,EAAE;AAG7D,OAAMA,sCACJ,OAAO,QAAQ,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,OAC7C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC,EACD,OAAO,CAAC,KAAK,qBAAqB;AAChC,MAAI,QAAQ,YAAa;EAEzB,MAAM,mCAA8D,EAAE;AAEtE,QAAMA,sCAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,iEACJ,gBAAgB,YAChB,QACA,cACD;GAED,MAAM,iBAAiB,GAAG,IAAI,GAAG,OAAO;GACxC,MAAM,wCAAyB,wBAAwB,eAAe;AAGtE,SAAMC,8CAAmB,gBAAgB,oBAAoB,CAAC,OAC3D,QAAQ;AACP,YAAQ,MAAM,4BAA4B,eAAe,IAAI,IAAI;KAEpE;AAED,oCAAiC,UAAU;IACzC,gBAAgB;IAChB,YAAY;IACb;IACD;AAEF,0BAAwB,OAAO;AAE/B,QAAMD,sCAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;GAC7C,MAAM,UAAU,6BACd,kCACA,QACA,cACD;AAED,SAAME,qEACI,wBAAwB,GAAG,IAAI,GAAG,YAAY,EACtD,QACD,CAAC,OAAO,QAAQ;AACf,YAAQ,MACN,oFAA+C,wBAAwB,GAAG,IAAI,GAAG,YAAY,CAAC,CAAC,IAC/F,IACD;KACD;IACF;GAEL;AAED,QAAO"}
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  const require_utils_parallelize = require('../utils/parallelize.cjs');
3
4
  const require_writeFileIfChanged = require('../writeFileIfChanged.cjs');
4
5
  let node_fs_promises = require("node:fs/promises");
@@ -1 +1 @@
1
- {"version":3,"file":"writeFetchDictionary.cjs","names":["parallelize","writeFileIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport {\n colorizePath,\n getConfiguration,\n normalizePath,\n} from '@intlayer/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type {\n LocalizedDictionaryOutput,\n LocalizedDictionaryResult,\n} from './writeDynamicDictionary';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { fetchDictionariesDir } = configuration.system;\n const { liveSyncURL } = configuration.editor;\n\n let content = '';\n\n const formattedDictionaryMap: string = Object.entries(\n localedDictionariesPathsRecord\n )\n .map(([locale, dictionary]) => {\n const relativePath = normalizePath(\n relative(fetchDictionariesDir, dictionary.dictionaryPath)\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return await import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)}})()`;\n }\n\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return Promise.resolve(require('./${relativePath}'))}})()`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(\n Object.entries(dynamicDictionaries),\n async ([key, localedDictionariesPathsRecord]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localedDictionariesPathsRecord,\n format,\n configuration\n );\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;AAiBA,MAAa,gCACX,gCACA,SAAwB,OACxB,wDAAkC,KACvB;CACX,MAAM,EAAE,yBAAyB,cAAc;CAC/C,MAAM,EAAE,gBAAgB,cAAc;CAEtC,IAAI,UAAU;CAEd,MAAM,yBAAiC,OAAO,QAC5C,+BACD,CACE,KAAK,CAAC,QAAQ,gBAAgB;EAC7B,MAAM,2EACK,sBAAsB,WAAW,eAAe,CAC1D;AAED,MAAI,WAAW,MACb,QAAO,MAAM,OAAO,mDAAmD,YAAY,gBAAgB,WAAW,WAAW,IAAI,GAAG,OAAO,qEAAqE,aAAa;AAG3N,SAAO,MAAM,OAAO,mDAAmD,YAAY,gBAAgB,WAAW,WAAW,IAAI,GAAG,OAAO,gFAAgF,aAAa;GACpO,CACD,KAAK,MAAM;AAEd,YAAW,sBAAsB,uBAAuB;AAExD,KAAI,WAAW,MAAO,YAAW;AACjC,KAAI,WAAW,MAAO,YAAW;AAEjC,QAAO;;;;;;;;;;;;;;;;;;AAmBT,MAAa,uBAAuB,OAClC,qBACA,wDAAkC,EAClC,UAA6B,CAAC,OAAO,MAAM,KACJ;CACvC,MAAM,EAAE,yBAAyB,cAAc;AAG/C,0DAAoB,qBAAqB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE/D,MAAM,0BAAqD,EAAE;AAG7D,OAAMA,sCACJ,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,oCAAoC;AAC/C,MAAI,QAAQ,YAAa;AAEzB,QAAMA,sCAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;GAC7C,MAAM,UAAU,6BACd,gCACA,QACA,cACD;AAED,SAAMC,qEACI,sBAAsB,GAAG,IAAI,GAAG,YAAY,EACpD,QACD,CAAC,OAAO,QAAQ;AACf,YAAQ,MACN,kFAA6C,sBAAsB,GAAG,IAAI,GAAG,YAAY,CAAC,CAAC,IAC3F,IACD;KACD;IACF;GAEL;AAED,QAAO"}
1
+ {"version":3,"file":"writeFetchDictionary.cjs","names":["parallelize","writeFileIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport {\n colorizePath,\n getConfiguration,\n normalizePath,\n} from '@intlayer/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type {\n LocalizedDictionaryOutput,\n LocalizedDictionaryResult,\n} from './writeDynamicDictionary';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { fetchDictionariesDir } = configuration.system;\n const { liveSyncURL } = configuration.editor;\n\n let content = '';\n\n const formattedDictionaryMap: string = Object.entries(\n localedDictionariesPathsRecord\n )\n .map(([locale, dictionary]) => {\n const relativePath = normalizePath(\n relative(fetchDictionariesDir, dictionary.dictionaryPath)\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return await import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)}})()`;\n }\n\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return Promise.resolve(require('./${relativePath}'))}})()`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(\n Object.entries(dynamicDictionaries),\n async ([key, localedDictionariesPathsRecord]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localedDictionariesPathsRecord,\n format,\n configuration\n );\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,gCACX,gCACA,SAAwB,OACxB,wDAAkC,KACvB;CACX,MAAM,EAAE,yBAAyB,cAAc;CAC/C,MAAM,EAAE,gBAAgB,cAAc;CAEtC,IAAI,UAAU;CAEd,MAAM,yBAAiC,OAAO,QAC5C,+BACD,CACE,KAAK,CAAC,QAAQ,gBAAgB;EAC7B,MAAM,2EACK,sBAAsB,WAAW,eAAe,CAC1D;AAED,MAAI,WAAW,MACb,QAAO,MAAM,OAAO,mDAAmD,YAAY,gBAAgB,WAAW,WAAW,IAAI,GAAG,OAAO,qEAAqE,aAAa;AAG3N,SAAO,MAAM,OAAO,mDAAmD,YAAY,gBAAgB,WAAW,WAAW,IAAI,GAAG,OAAO,gFAAgF,aAAa;GACpO,CACD,KAAK,MAAM;AAEd,YAAW,sBAAsB,uBAAuB;AAExD,KAAI,WAAW,MAAO,YAAW;AACjC,KAAI,WAAW,MAAO,YAAW;AAEjC,QAAO;;;;;;;;;;;;;;;;;;AAmBT,MAAa,uBAAuB,OAClC,qBACA,wDAAkC,EAClC,UAA6B,CAAC,OAAO,MAAM,KACJ;CACvC,MAAM,EAAE,yBAAyB,cAAc;AAG/C,0DAAoB,qBAAqB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE/D,MAAM,0BAAqD,EAAE;AAG7D,OAAMA,sCACJ,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,oCAAoC;AAC/C,MAAI,QAAQ,YAAa;AAEzB,QAAMA,sCAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;GAC7C,MAAM,UAAU,6BACd,gCACA,QACA,cACD;AAED,SAAMC,qEACI,sBAAsB,GAAG,IAAI,GAAG,YAAY,EACpD,QACD,CAAC,OAAO,QAAQ;AACf,YAAQ,MACN,kFAA6C,sBAAsB,GAAG,IAAI,GAAG,YAAY,CAAC,CAAC,IAC3F,IACD;KACD;IACF;GAEL;AAED,QAAO"}
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  const require_utils_parallelize = require('../utils/parallelize.cjs');
3
4
  const require_writeJsonIfChanged = require('../writeJsonIfChanged.cjs');
4
5
  let node_fs_promises = require("node:fs/promises");
@@ -1 +1 @@
1
- {"version":3,"file":"writeMergedDictionary.cjs","names":["parallelize","writeJsonIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, getConfiguration } from '@intlayer/config';\nimport { mergeDictionaries, normalizeDictionaries } from '@intlayer/core';\nimport type { Dictionary } from '@intlayer/types';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionary/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration = getConfiguration()\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const normalizedDictionaries = normalizeDictionaries(\n dictionariesEntry.dictionaries,\n configuration\n );\n\n const mergedDictionary = mergeDictionaries(normalizedDictionaries);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,0BAA0B,OACrC,qBACA,wDAAkC,KACE;CACpC,MAAM,EAAE,oBAAoB,cAAc;AAG1C,0DAAoB,gBAAgB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE1D,MAAM,UAAU,MAAMA,sCACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,uBAAuB;AAClC,MAAI,QAAQ,YACV;EAWF,MAAM,mGAJJ,kBAAkB,cAClB,cACD,CAEiE;EAGlE,MAAM,wCAAyB,iBADR,GAAG,IAAI,OACiC;AAG/D,QAAMC,8CAAmB,gBAAgB,iBAAiB,CAAC,OACxD,QAAQ;AACP,WAAQ,MACN,4DAAsC,eAAe,CAAC,IACtD,IACD;IAEJ;AAED,SAAO,CACL,KACA;GACE,gBAAgB;GAChB,YAAY;GACb,CACF;GAEJ;AAED,QAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CACxB"}
1
+ {"version":3,"file":"writeMergedDictionary.cjs","names":["parallelize","writeJsonIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, getConfiguration } from '@intlayer/config';\nimport { mergeDictionaries, normalizeDictionaries } from '@intlayer/core';\nimport type { Dictionary } from '@intlayer/types';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionary/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration = getConfiguration()\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const normalizedDictionaries = normalizeDictionaries(\n dictionariesEntry.dictionaries,\n configuration\n );\n\n const mergedDictionary = mergeDictionaries(normalizedDictionaries);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,0BAA0B,OACrC,qBACA,wDAAkC,KACE;CACpC,MAAM,EAAE,oBAAoB,cAAc;AAG1C,0DAAoB,gBAAgB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE1D,MAAM,UAAU,MAAMA,sCACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,uBAAuB;AAClC,MAAI,QAAQ,YACV;EAWF,MAAM,mGAJJ,kBAAkB,cAClB,cACD,CAEiE;EAGlE,MAAM,wCAAyB,iBADR,GAAG,IAAI,OACiC;AAG/D,QAAMC,8CAAmB,gBAAgB,iBAAiB,CAAC,OACxD,QAAQ;AACP,WAAQ,MACN,4DAAsC,eAAe,CAAC,IACtD,IACD;IAEJ;AAED,SAAO,CACL,KACA;GACE,gBAAgB;GAChB,YAAY;GACb,CACF;GAEJ;AAED,QAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CACxB"}
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  const require_utils_parallelize = require('../utils/parallelize.cjs');
3
4
  const require_writeJsonIfChanged = require('../writeJsonIfChanged.cjs');
4
5
  const require_filterInvalidDictionaries = require('../filterInvalidDictionaries.cjs');