@intlayer/config 9.0.0-canary.9 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/dist/cjs/built.cjs +2 -0
  2. package/dist/cjs/built.cjs.map +1 -1
  3. package/dist/cjs/bundle/index.cjs.map +1 -1
  4. package/dist/cjs/bundle/logBundle.cjs.map +1 -1
  5. package/dist/cjs/callers/base.cjs +42 -0
  6. package/dist/cjs/callers/base.cjs.map +1 -0
  7. package/dist/cjs/callers/compat/i18next.cjs +27 -0
  8. package/dist/cjs/callers/compat/i18next.cjs.map +1 -0
  9. package/dist/cjs/callers/compat/lingui.cjs +82 -0
  10. package/dist/cjs/callers/compat/lingui.cjs.map +1 -0
  11. package/dist/cjs/callers/compat/nextIntl.cjs +44 -0
  12. package/dist/cjs/callers/compat/nextIntl.cjs.map +1 -0
  13. package/dist/cjs/callers/compat/reactI18next.cjs +50 -0
  14. package/dist/cjs/callers/compat/reactI18next.cjs.map +1 -0
  15. package/dist/cjs/callers/compat/reactIntl.cjs +31 -0
  16. package/dist/cjs/callers/compat/reactIntl.cjs.map +1 -0
  17. package/dist/cjs/callers/compat/useIntl.cjs +46 -0
  18. package/dist/cjs/callers/compat/useIntl.cjs.map +1 -0
  19. package/dist/cjs/callers/compat/vueI18n.cjs +26 -0
  20. package/dist/cjs/callers/compat/vueI18n.cjs.map +1 -0
  21. package/dist/cjs/callers/index.cjs +87 -0
  22. package/dist/cjs/callers/index.cjs.map +1 -0
  23. package/dist/cjs/callers/transform.cjs +46 -0
  24. package/dist/cjs/callers/transform.cjs.map +1 -0
  25. package/dist/cjs/callers/types.cjs +0 -0
  26. package/dist/cjs/client.cjs +1 -0
  27. package/dist/cjs/configFile/buildBrowserConfiguration.cjs +47 -3
  28. package/dist/cjs/configFile/buildBrowserConfiguration.cjs.map +1 -1
  29. package/dist/cjs/configFile/buildConfigurationFields.cjs +9 -3
  30. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  31. package/dist/cjs/configFile/configurationSchema.cjs +7 -0
  32. package/dist/cjs/configFile/configurationSchema.cjs.map +1 -1
  33. package/dist/cjs/configFile/getConfiguration.cjs +10 -3
  34. package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
  35. package/dist/cjs/configFile/index.cjs +2 -0
  36. package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
  37. package/dist/cjs/configFile/searchConfigurationFile.cjs +0 -1
  38. package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
  39. package/dist/cjs/defaultValues/analytics.cjs +16 -0
  40. package/dist/cjs/defaultValues/analytics.cjs.map +1 -0
  41. package/dist/cjs/defaultValues/build.cjs.map +1 -1
  42. package/dist/cjs/defaultValues/content.cjs.map +1 -1
  43. package/dist/cjs/defaultValues/index.cjs +4 -0
  44. package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
  45. package/dist/cjs/defaultValues/routing.cjs.map +1 -1
  46. package/dist/cjs/envVars/envVars.cjs +2 -1
  47. package/dist/cjs/envVars/envVars.cjs.map +1 -1
  48. package/dist/cjs/loadEnvFile.cjs +44 -7
  49. package/dist/cjs/loadEnvFile.cjs.map +1 -1
  50. package/dist/cjs/loadExternalFile/bundleFile.cjs +4 -3
  51. package/dist/cjs/loadExternalFile/bundleFile.cjs.map +1 -1
  52. package/dist/cjs/loadExternalFile/bundleJSFile.cjs +0 -1
  53. package/dist/cjs/loadExternalFile/bundleJSFile.cjs.map +1 -1
  54. package/dist/cjs/loadExternalFile/index.cjs +1 -0
  55. package/dist/cjs/loadExternalFile/loadExternalFile.cjs +11 -6
  56. package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
  57. package/dist/cjs/loadExternalFile/parseFileContent.cjs +52 -17
  58. package/dist/cjs/loadExternalFile/parseFileContent.cjs.map +1 -1
  59. package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs +99 -10
  60. package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs.map +1 -1
  61. package/dist/cjs/logger.cjs +2 -1
  62. package/dist/cjs/logger.cjs.map +1 -1
  63. package/dist/cjs/node.cjs +2 -0
  64. package/dist/cjs/utils/ESMxCJSHelpers.cjs +0 -1
  65. package/dist/cjs/utils/ESMxCJSHelpers.cjs.map +1 -1
  66. package/dist/cjs/utils/alias.cjs +0 -1
  67. package/dist/cjs/utils/alias.cjs.map +1 -1
  68. package/dist/cjs/utils/builtConfigKeys.cjs +38 -0
  69. package/dist/cjs/utils/builtConfigKeys.cjs.map +1 -0
  70. package/dist/cjs/utils/cacheDisk.cjs +2 -1
  71. package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
  72. package/dist/cjs/utils/cacheMemory.cjs +0 -1
  73. package/dist/cjs/utils/cacheMemory.cjs.map +1 -1
  74. package/dist/cjs/utils/clearModuleCache.cjs.map +1 -1
  75. package/dist/cjs/utils/compareVersions.cjs.map +1 -1
  76. package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
  77. package/dist/cjs/utils/getDictionarySelectorUsage.cjs.map +1 -1
  78. package/dist/cjs/utils/getExtension.cjs.map +1 -1
  79. package/dist/cjs/utils/getPackageJsonPath.cjs +0 -1
  80. package/dist/cjs/utils/getPackageJsonPath.cjs.map +1 -1
  81. package/dist/cjs/utils/getStorageAttributes.cjs +2 -1
  82. package/dist/cjs/utils/getStorageAttributes.cjs.map +1 -1
  83. package/dist/cjs/utils/getUsedNodeTypes.cjs +0 -1
  84. package/dist/cjs/utils/getUsedNodeTypes.cjs.map +1 -1
  85. package/dist/cjs/utils/index.cjs +2 -0
  86. package/dist/cjs/utils/logStack.cjs.map +1 -1
  87. package/dist/cjs/utils/normalizePath.cjs.map +1 -1
  88. package/dist/cjs/utils/parseFilePathPattern.cjs.map +1 -1
  89. package/dist/cjs/utils/pathSecurity.cjs +0 -1
  90. package/dist/cjs/utils/pathSecurity.cjs.map +1 -1
  91. package/dist/cjs/utils/retryManager.cjs.map +1 -1
  92. package/dist/cjs/utils/setIntlayerIdentifier.cjs.map +1 -1
  93. package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs.map +1 -1
  94. package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs.map +1 -1
  95. package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs.map +1 -1
  96. package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs.map +1 -1
  97. package/dist/esm/built.mjs +2 -1
  98. package/dist/esm/built.mjs.map +1 -1
  99. package/dist/esm/bundle/index.mjs +3 -3
  100. package/dist/esm/bundle/index.mjs.map +1 -1
  101. package/dist/esm/bundle/logBundle.mjs.map +1 -1
  102. package/dist/esm/callers/base.mjs +40 -0
  103. package/dist/esm/callers/base.mjs.map +1 -0
  104. package/dist/esm/callers/compat/i18next.mjs +25 -0
  105. package/dist/esm/callers/compat/i18next.mjs.map +1 -0
  106. package/dist/esm/callers/compat/lingui.mjs +80 -0
  107. package/dist/esm/callers/compat/lingui.mjs.map +1 -0
  108. package/dist/esm/callers/compat/nextIntl.mjs +42 -0
  109. package/dist/esm/callers/compat/nextIntl.mjs.map +1 -0
  110. package/dist/esm/callers/compat/reactI18next.mjs +48 -0
  111. package/dist/esm/callers/compat/reactI18next.mjs.map +1 -0
  112. package/dist/esm/callers/compat/reactIntl.mjs +29 -0
  113. package/dist/esm/callers/compat/reactIntl.mjs.map +1 -0
  114. package/dist/esm/callers/compat/useIntl.mjs +44 -0
  115. package/dist/esm/callers/compat/useIntl.mjs.map +1 -0
  116. package/dist/esm/callers/compat/vueI18n.mjs +24 -0
  117. package/dist/esm/callers/compat/vueI18n.mjs.map +1 -0
  118. package/dist/esm/callers/index.mjs +72 -0
  119. package/dist/esm/callers/index.mjs.map +1 -0
  120. package/dist/esm/callers/transform.mjs +43 -0
  121. package/dist/esm/callers/transform.mjs.map +1 -0
  122. package/dist/esm/callers/types.mjs +0 -0
  123. package/dist/esm/client.mjs +2 -2
  124. package/dist/esm/configFile/buildBrowserConfiguration.mjs +47 -4
  125. package/dist/esm/configFile/buildBrowserConfiguration.mjs.map +1 -1
  126. package/dist/esm/configFile/buildConfigurationFields.mjs +10 -4
  127. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  128. package/dist/esm/configFile/configurationSchema.mjs +7 -1
  129. package/dist/esm/configFile/configurationSchema.mjs.map +1 -1
  130. package/dist/esm/configFile/getConfiguration.mjs +10 -2
  131. package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
  132. package/dist/esm/configFile/index.mjs +3 -3
  133. package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
  134. package/dist/esm/configFile/searchConfigurationFile.mjs.map +1 -1
  135. package/dist/esm/defaultValues/analytics.mjs +12 -0
  136. package/dist/esm/defaultValues/analytics.mjs.map +1 -0
  137. package/dist/esm/defaultValues/build.mjs.map +1 -1
  138. package/dist/esm/defaultValues/content.mjs.map +1 -1
  139. package/dist/esm/defaultValues/index.mjs +2 -1
  140. package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
  141. package/dist/esm/defaultValues/routing.mjs.map +1 -1
  142. package/dist/esm/envVars/envVars.mjs +2 -1
  143. package/dist/esm/envVars/envVars.mjs.map +1 -1
  144. package/dist/esm/loadEnvFile.mjs +45 -8
  145. package/dist/esm/loadEnvFile.mjs.map +1 -1
  146. package/dist/esm/loadExternalFile/bundleFile.mjs +4 -2
  147. package/dist/esm/loadExternalFile/bundleFile.mjs.map +1 -1
  148. package/dist/esm/loadExternalFile/bundleJSFile.mjs.map +1 -1
  149. package/dist/esm/loadExternalFile/index.mjs +2 -2
  150. package/dist/esm/loadExternalFile/loadExternalFile.mjs +11 -6
  151. package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
  152. package/dist/esm/loadExternalFile/parseFileContent.mjs +52 -17
  153. package/dist/esm/loadExternalFile/parseFileContent.mjs.map +1 -1
  154. package/dist/esm/loadExternalFile/transpileTSToCJS.mjs +102 -13
  155. package/dist/esm/loadExternalFile/transpileTSToCJS.mjs.map +1 -1
  156. package/dist/esm/logger.mjs +2 -1
  157. package/dist/esm/logger.mjs.map +1 -1
  158. package/dist/esm/node.mjs +3 -3
  159. package/dist/esm/utils/ESMxCJSHelpers.mjs.map +1 -1
  160. package/dist/esm/utils/alias.mjs.map +1 -1
  161. package/dist/esm/utils/builtConfigKeys.mjs +36 -0
  162. package/dist/esm/utils/builtConfigKeys.mjs.map +1 -0
  163. package/dist/esm/utils/cacheDisk.mjs +6 -5
  164. package/dist/esm/utils/cacheDisk.mjs.map +1 -1
  165. package/dist/esm/utils/cacheMemory.mjs.map +1 -1
  166. package/dist/esm/utils/clearModuleCache.mjs.map +1 -1
  167. package/dist/esm/utils/compareVersions.mjs.map +1 -1
  168. package/dist/esm/utils/extractErrorMessage.mjs.map +1 -1
  169. package/dist/esm/utils/getDictionarySelectorUsage.mjs.map +1 -1
  170. package/dist/esm/utils/getExtension.mjs.map +1 -1
  171. package/dist/esm/utils/getPackageJsonPath.mjs.map +1 -1
  172. package/dist/esm/utils/getStorageAttributes.mjs +2 -1
  173. package/dist/esm/utils/getStorageAttributes.mjs.map +1 -1
  174. package/dist/esm/utils/getUsedNodeTypes.mjs.map +1 -1
  175. package/dist/esm/utils/index.mjs +2 -1
  176. package/dist/esm/utils/logStack.mjs.map +1 -1
  177. package/dist/esm/utils/normalizePath.mjs.map +1 -1
  178. package/dist/esm/utils/parseFilePathPattern.mjs.map +1 -1
  179. package/dist/esm/utils/pathSecurity.mjs.map +1 -1
  180. package/dist/esm/utils/retryManager.mjs.map +1 -1
  181. package/dist/esm/utils/setIntlayerIdentifier.mjs.map +1 -1
  182. package/dist/esm/utils/stringFormatter/camelCaseToKebabCase.mjs.map +1 -1
  183. package/dist/esm/utils/stringFormatter/camelCaseToSentence.mjs.map +1 -1
  184. package/dist/esm/utils/stringFormatter/kebabCaseToCamelCase.mjs.map +1 -1
  185. package/dist/esm/utils/stringFormatter/toLowerCamelCase.mjs.map +1 -1
  186. package/dist/types/built.d.ts +2 -1
  187. package/dist/types/built.d.ts.map +1 -1
  188. package/dist/types/bundle/index.d.ts +2 -4
  189. package/dist/types/bundle/index.d.ts.map +1 -1
  190. package/dist/types/bundle/logBundle.d.ts +0 -1
  191. package/dist/types/bundle/logBundle.d.ts.map +1 -1
  192. package/dist/types/callers/base.d.ts +13 -0
  193. package/dist/types/callers/base.d.ts.map +1 -0
  194. package/dist/types/callers/compat/i18next.d.ts +11 -0
  195. package/dist/types/callers/compat/i18next.d.ts.map +1 -0
  196. package/dist/types/callers/compat/lingui.d.ts +6 -0
  197. package/dist/types/callers/compat/lingui.d.ts.map +1 -0
  198. package/dist/types/callers/compat/nextIntl.d.ts +12 -0
  199. package/dist/types/callers/compat/nextIntl.d.ts.map +1 -0
  200. package/dist/types/callers/compat/reactI18next.d.ts +14 -0
  201. package/dist/types/callers/compat/reactI18next.d.ts.map +1 -0
  202. package/dist/types/callers/compat/reactIntl.d.ts +15 -0
  203. package/dist/types/callers/compat/reactIntl.d.ts.map +1 -0
  204. package/dist/types/callers/compat/useIntl.d.ts +11 -0
  205. package/dist/types/callers/compat/useIntl.d.ts.map +1 -0
  206. package/dist/types/callers/compat/vueI18n.d.ts +11 -0
  207. package/dist/types/callers/compat/vueI18n.d.ts.map +1 -0
  208. package/dist/types/callers/index.d.ts +48 -0
  209. package/dist/types/callers/index.d.ts.map +1 -0
  210. package/dist/types/callers/transform.d.ts +60 -0
  211. package/dist/types/callers/transform.d.ts.map +1 -0
  212. package/dist/types/callers/types.d.ts +160 -0
  213. package/dist/types/callers/types.d.ts.map +1 -0
  214. package/dist/types/client.d.ts +2 -2
  215. package/dist/types/colors.d.ts +14 -14
  216. package/dist/types/colors.d.ts.map +1 -1
  217. package/dist/types/configFile/buildBrowserConfiguration.d.ts +24 -4
  218. package/dist/types/configFile/buildBrowserConfiguration.d.ts.map +1 -1
  219. package/dist/types/configFile/buildConfigurationFields.d.ts +8 -4
  220. package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
  221. package/dist/types/configFile/configurationSchema.d.ts +43 -34
  222. package/dist/types/configFile/configurationSchema.d.ts.map +1 -1
  223. package/dist/types/configFile/getConfiguration.d.ts +0 -1
  224. package/dist/types/configFile/getConfiguration.d.ts.map +1 -1
  225. package/dist/types/configFile/index.d.ts +3 -3
  226. package/dist/types/configFile/loadConfigurationFile.d.ts +1 -2
  227. package/dist/types/configFile/loadConfigurationFile.d.ts.map +1 -1
  228. package/dist/types/configFile/searchConfigurationFile.d.ts +1 -1
  229. package/dist/types/configFile/searchConfigurationFile.d.ts.map +1 -1
  230. package/dist/types/defaultValues/analytics.d.ts +11 -0
  231. package/dist/types/defaultValues/analytics.d.ts.map +1 -0
  232. package/dist/types/defaultValues/build.d.ts.map +1 -1
  233. package/dist/types/defaultValues/compiler.d.ts.map +1 -1
  234. package/dist/types/defaultValues/content.d.ts.map +1 -1
  235. package/dist/types/defaultValues/dictionary.d.ts +0 -1
  236. package/dist/types/defaultValues/dictionary.d.ts.map +1 -1
  237. package/dist/types/defaultValues/editor.d.ts.map +1 -1
  238. package/dist/types/defaultValues/index.d.ts +2 -1
  239. package/dist/types/defaultValues/internationalization.d.ts +0 -1
  240. package/dist/types/defaultValues/internationalization.d.ts.map +1 -1
  241. package/dist/types/defaultValues/log.d.ts.map +1 -1
  242. package/dist/types/defaultValues/routing.d.ts +0 -1
  243. package/dist/types/defaultValues/routing.d.ts.map +1 -1
  244. package/dist/types/defaultValues/system.d.ts.map +1 -1
  245. package/dist/types/envVars/envVars.d.ts +0 -1
  246. package/dist/types/envVars/envVars.d.ts.map +1 -1
  247. package/dist/types/loadEnvFile.d.ts +1 -1
  248. package/dist/types/loadEnvFile.d.ts.map +1 -1
  249. package/dist/types/loadExternalFile/bundleFile.d.ts +0 -1
  250. package/dist/types/loadExternalFile/bundleFile.d.ts.map +1 -1
  251. package/dist/types/loadExternalFile/bundleJSFile.d.ts +57 -59
  252. package/dist/types/loadExternalFile/bundleJSFile.d.ts.map +1 -1
  253. package/dist/types/loadExternalFile/index.d.ts +2 -2
  254. package/dist/types/loadExternalFile/loadExternalFile.d.ts +0 -1
  255. package/dist/types/loadExternalFile/loadExternalFile.d.ts.map +1 -1
  256. package/dist/types/loadExternalFile/parseFileContent.d.ts +9 -1
  257. package/dist/types/loadExternalFile/parseFileContent.d.ts.map +1 -1
  258. package/dist/types/loadExternalFile/transpileTSToCJS.d.ts +4 -4
  259. package/dist/types/loadExternalFile/transpileTSToCJS.d.ts.map +1 -1
  260. package/dist/types/logger.d.ts +2 -3
  261. package/dist/types/logger.d.ts.map +1 -1
  262. package/dist/types/node.d.ts +3 -3
  263. package/dist/types/utils/ESMxCJSHelpers.d.ts.map +1 -1
  264. package/dist/types/utils/alias.d.ts +1 -6
  265. package/dist/types/utils/alias.d.ts.map +1 -1
  266. package/dist/types/utils/builtConfigKeys.d.ts +25 -0
  267. package/dist/types/utils/builtConfigKeys.d.ts.map +1 -0
  268. package/dist/types/utils/cacheDisk.d.ts +22 -11
  269. package/dist/types/utils/cacheDisk.d.ts.map +1 -1
  270. package/dist/types/utils/cacheMemory.d.ts +3 -3
  271. package/dist/types/utils/cacheMemory.d.ts.map +1 -1
  272. package/dist/types/utils/clearModuleCache.d.ts.map +1 -1
  273. package/dist/types/utils/compareVersions.d.ts +1 -1
  274. package/dist/types/utils/compareVersions.d.ts.map +1 -1
  275. package/dist/types/utils/extractErrorMessage.d.ts.map +1 -1
  276. package/dist/types/utils/getDictionarySelectorUsage.d.ts +0 -1
  277. package/dist/types/utils/getDictionarySelectorUsage.d.ts.map +1 -1
  278. package/dist/types/utils/getExtension.d.ts +1 -2
  279. package/dist/types/utils/getExtension.d.ts.map +1 -1
  280. package/dist/types/utils/getPackageJsonPath.d.ts.map +1 -1
  281. package/dist/types/utils/getStorageAttributes.d.ts +0 -1
  282. package/dist/types/utils/getStorageAttributes.d.ts.map +1 -1
  283. package/dist/types/utils/getUsedNodeTypes.d.ts +0 -1
  284. package/dist/types/utils/getUsedNodeTypes.d.ts.map +1 -1
  285. package/dist/types/utils/index.d.ts +2 -1
  286. package/dist/types/utils/logStack.d.ts.map +1 -1
  287. package/dist/types/utils/normalizePath.d.ts.map +1 -1
  288. package/dist/types/utils/parseFilePathPattern.d.ts +0 -1
  289. package/dist/types/utils/parseFilePathPattern.d.ts.map +1 -1
  290. package/dist/types/utils/pathSecurity.d.ts.map +1 -1
  291. package/dist/types/utils/retryManager.d.ts +8 -9
  292. package/dist/types/utils/retryManager.d.ts.map +1 -1
  293. package/dist/types/utils/setIntlayerIdentifier.d.ts.map +1 -1
  294. package/dist/types/utils/stringFormatter/camelCaseToKebabCase.d.ts.map +1 -1
  295. package/dist/types/utils/stringFormatter/camelCaseToSentence.d.ts.map +1 -1
  296. package/dist/types/utils/stringFormatter/kebabCaseToCamelCase.d.ts.map +1 -1
  297. package/dist/types/utils/stringFormatter/toLowerCamelCase.d.ts.map +1 -1
  298. package/package.json +11 -7
  299. package/dist/cjs/built.browser.cjs +0 -46
  300. package/dist/cjs/built.browser.cjs.map +0 -1
  301. package/dist/esm/built.browser.mjs +0 -32
  302. package/dist/esm/built.browser.mjs.map +0 -1
  303. package/dist/types/built.browser.d.ts +0 -27
  304. package/dist/types/built.browser.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"transpileTSToCJS.mjs","names":[],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n buildSync,\n context,\n} from 'esbuild';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { getLoader } from './bundleFile';\n\nexport type TranspileOptions = BuildOptions & {\n /**\n * Optional custom esbuild instance to use for transpilation.\n * Useful in environments (e.g. VS Code extensions) where the bundled\n * esbuild binary may not match the host platform.\n * When provided, its `buildSync`/`build` methods are used instead of\n * the ones imported from the `esbuild` package.\n */\n esbuildInstance?: typeof import('esbuild');\n};\n\nconst getTsConfigPath = (filePath: string): string | undefined => {\n const tsconfigPath = join(\n getPackageJsonPath(dirname(filePath)).baseDir,\n 'tsconfig.json'\n );\n\n // Only return the tsconfig path if it exists\n return existsSync(tsconfigPath) ? tsconfigPath : undefined;\n};\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs',\n target: 'node20',\n platform: 'node',\n write: false,\n packages: 'external',\n bundle: true,\n tsconfig: getTsConfigPath(filePath),\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n 'import.meta.env': 'process.env',\n },\n});\n\nexport const transpileTSToCJSSync = (\n code: string,\n filePath: string,\n options?: TranspileOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const { esbuildInstance, ...buildOptions } = options ?? {};\n const esbuildBuildSync = esbuildInstance?.buildSync ?? buildSync;\n\n // esbuild's worker thread service calls `new Worker(__filename, …)` on first use.\n // In Vite's SSR module runner the SSR-optimised chunk is ESM and __filename is\n // never declared (confirmed: accessing it throws ReferenceError, not undefined).\n // Because there is no local declaration the bare `__filename` lookup falls\n // through to globalThis, so we set it there to esbuild's own CJS entry-point –\n // the exact path esbuild would use if it were loaded in a normal CJS context.\n //\n // IMPORTANT: We save/restore the globals so this temporary shim does not leak\n // to other Vite plugins (e.g. `@vitejs/plugin-react-swc`) that check\n // `typeof __dirname !== \"undefined\"` to locate their own assets.\n const g = globalThis as Record<string, unknown>;\n const hadFilename = typeof g.__filename === 'string';\n const prevFilename = g.__filename;\n const prevDirname = g.__dirname;\n\n if (!hadFilename) {\n try {\n const _require = createRequire(import.meta.url);\n const esbuildEntry = _require.resolve('esbuild');\n g.__filename = esbuildEntry;\n g.__dirname = dirname(esbuildEntry);\n } catch {\n // Best-effort: if esbuild can't be resolved the caller's catch handles it\n }\n }\n\n let moduleResult: BuildResult;\n try {\n moduleResult = esbuildBuildSync({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...buildOptions,\n });\n } finally {\n // Always restore the previous values so the globals don't linger.\n if (!hadFilename) {\n if (prevFilename === undefined) {\n delete g.__filename;\n } else {\n g.__filename = prevFilename;\n }\n if (prevDirname === undefined) {\n delete g.__dirname;\n } else {\n g.__dirname = prevDirname;\n }\n }\n }\n\n const moduleResultString = moduleResult!.outputFiles?.[0]?.text;\n\n return moduleResultString;\n};\n\nexport const transpileTSToCJS = async (\n code: string,\n filePath: string,\n options?: TranspileOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const { esbuildInstance, ...buildOptions } = options ?? {};\n // Use context() + rebuild() + dispose() so esbuild deterministically releases\n // Go-subprocess resources for each one-shot transpilation, preventing them\n // from accumulating between rapid HMR-driven file changes.\n const esbuildContext = esbuildInstance?.context ?? context;\n\n const ctx = await esbuildContext({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath),\n sourcefile: filePath,\n },\n ...getTransformationOptions(filePath),\n ...buildOptions,\n });\n\n try {\n const moduleResult = await ctx.rebuild();\n return moduleResult.outputFiles?.[0].text;\n } finally {\n await ctx.dispose();\n }\n};\n"],"mappings":";;;;;;;;;AAwBA,MAAM,mBAAmB,aAAyC;CAChE,MAAM,eAAe,KACnB,mBAAmB,QAAQ,SAAS,CAAC,CAAC,SACtC,gBACD;AAGD,QAAO,WAAW,aAAa,GAAG,eAAe;;AAGnD,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACD,QAAQ;CACR,QAA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AAI;AAEF,UAAO,MADoB,IAAI,SAAS,EACpB,cAAc,GAAG;WAC7B;AACR,QAAM,IAAI,SAAS"}
1
+ {"version":3,"file":"transpileTSToCJS.mjs","names":[],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync, statSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, extname, isAbsolute, join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n build,\n buildSync,\n type Metafile,\n} from 'esbuild';\nimport { computeKeyId } from '../utils/cacheMemory';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { getLoader } from './bundleFile';\n\nexport type TranspileOptions = BuildOptions & {\n /**\n * Optional custom esbuild instance to use for transpilation.\n * Useful in environments (e.g. VS Code extensions) where the bundled\n * esbuild binary may not match the host platform.\n * When provided, its `buildSync`/`build` methods are used instead of\n * the ones imported from the `esbuild` package.\n */\n esbuildInstance?: typeof import('esbuild');\n};\n\n/**\n * Cache of resolved tsconfig paths keyed by the file's directory.\n * Avoids re-walking to package.json + existsSync on every transpilation.\n */\nconst tsConfigPathCache = new Map<string, string | undefined>();\n\nconst getTsConfigPath = (filePath: string): string | undefined => {\n const fileDirectory = dirname(filePath);\n\n if (tsConfigPathCache.has(fileDirectory)) {\n return tsConfigPathCache.get(fileDirectory);\n }\n\n let resolvedPath: string | undefined;\n try {\n const tsconfigPath = join(\n getPackageJsonPath(fileDirectory).baseDir,\n 'tsconfig.json'\n );\n\n // Only return the tsconfig path if it exists\n resolvedPath = existsSync(tsconfigPath) ? tsconfigPath : undefined;\n } catch {\n // No package.json found up the tree — transpile without a tsconfig\n resolvedPath = undefined;\n }\n\n tsConfigPathCache.set(fileDirectory, resolvedPath);\n\n return resolvedPath;\n};\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs',\n target: 'node20',\n platform: 'node',\n write: false,\n packages: 'external',\n bundle: true,\n // The metafile lists every bundled input, which the transpile cache uses to\n // invalidate when an imported file changes (the entry itself is keyed by hash).\n metafile: true,\n tsconfig: getTsConfigPath(filePath),\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n 'import.meta.env': 'process.env',\n },\n});\n\n/** Fingerprint of a bundled input file, used to detect changes without re-reading it. */\ntype TranspileCacheInput = {\n path: string;\n mtimeMs: number;\n size: number;\n};\n\ntype TranspileCacheEntry = {\n /** Hash of the entry file's source code. */\n codeHash: string;\n /** Hash of the build options, so different option sets don't collide. */\n optionsKey: string;\n /** The transpiled CJS output. */\n output: string;\n /** Fingerprints of every non-entry input bundled into the output. */\n inputs: TranspileCacheInput[];\n};\n\n/**\n * In-memory cache of transpiled outputs keyed by entry file path (one entry\n * per file, so re-transpilations replace rather than accumulate).\n * The entry file is validated by content hash; bundled relative imports are\n * validated by mtime + size so an edited dependency invalidates the cache.\n */\nconst transpileCache = new Map<string, TranspileCacheEntry>();\n\nconst isInputUnchanged = (input: TranspileCacheInput): boolean => {\n try {\n const stats = statSync(input.path);\n return stats.mtimeMs === input.mtimeMs && stats.size === input.size;\n } catch {\n // File removed or unreadable — treat as changed\n return false;\n }\n};\n\nconst getCachedTranspilation = (\n filePath: string,\n codeHash: string,\n optionsKey: string\n): string | undefined => {\n const cacheEntry = transpileCache.get(filePath);\n\n if (!cacheEntry) return undefined;\n if (cacheEntry.codeHash !== codeHash) return undefined;\n if (cacheEntry.optionsKey !== optionsKey) return undefined;\n if (!cacheEntry.inputs.every(isInputUnchanged)) return undefined;\n\n return cacheEntry.output;\n};\n\n/**\n * Extracts the fingerprints of every bundled input from the esbuild metafile.\n * Returns `undefined` when an input cannot be fingerprinted (the result should\n * then not be cached, as invalidation would be unreliable).\n */\nconst getInputFingerprints = (\n metafile: Metafile | undefined,\n entryFilePath: string\n): TranspileCacheInput[] | undefined => {\n if (!metafile) return undefined;\n\n const resolvedEntryFilePath = resolve(entryFilePath);\n const inputs: TranspileCacheInput[] = [];\n\n for (const inputPath of Object.keys(metafile.inputs)) {\n // The entry itself is provided via stdin and validated by content hash.\n // esbuild labels it \"<stdin>\", or with the sourcefile path when set.\n if (inputPath === '<stdin>') continue;\n // Virtual modules from plugins (e.g. \"plugin:...\") cannot be fingerprinted\n if (inputPath.includes(':') && !isAbsolute(inputPath)) return undefined;\n\n const absoluteInputPath = isAbsolute(inputPath)\n ? inputPath\n : resolve(process.cwd(), inputPath);\n\n if (absoluteInputPath === resolvedEntryFilePath) continue;\n\n try {\n const stats = statSync(absoluteInputPath);\n inputs.push({\n path: absoluteInputPath,\n mtimeMs: stats.mtimeMs,\n size: stats.size,\n });\n } catch {\n return undefined;\n }\n }\n\n return inputs;\n};\n\nconst setCachedTranspilation = (\n filePath: string,\n codeHash: string,\n optionsKey: string,\n moduleResult: BuildResult,\n output: string\n): void => {\n const inputs = getInputFingerprints(moduleResult.metafile, filePath);\n\n // Without a usable metafile the cache cannot be invalidated reliably — skip\n if (!inputs) return;\n\n transpileCache.set(filePath, { codeHash, optionsKey, output, inputs });\n};\n\n/** Clears the in-memory transpilation cache (mainly for tests). */\nexport const clearTranspileCache = (): void => {\n transpileCache.clear();\n tsConfigPathCache.clear();\n};\n\nexport const transpileTSToCJSSync = (\n code: string,\n filePath: string,\n options?: TranspileOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const { esbuildInstance, ...buildOptions } = options ?? {};\n\n const codeHash = computeKeyId([code]);\n const optionsKey = computeKeyId([buildOptions]);\n\n const cachedOutput = getCachedTranspilation(filePath, codeHash, optionsKey);\n if (typeof cachedOutput === 'string') return cachedOutput;\n\n const esbuildBuildSync = esbuildInstance?.buildSync ?? buildSync;\n\n // esbuild's worker thread service calls `new Worker(__filename, …)` on first use.\n // In Vite's SSR module runner the SSR-optimised chunk is ESM and __filename is\n // never declared (confirmed: accessing it throws ReferenceError, not undefined).\n // Because there is no local declaration the bare `__filename` lookup falls\n // through to globalThis, so we set it there to esbuild's own CJS entry-point –\n // the exact path esbuild would use if it were loaded in a normal CJS context.\n //\n // IMPORTANT: We save/restore the globals so this temporary shim does not leak\n // to other Vite plugins (e.g. `@vitejs/plugin-react-swc`) that check\n // `typeof __dirname !== \"undefined\"` to locate their own assets.\n const g = globalThis as Record<string, unknown>;\n const hadFilename = typeof g.__filename === 'string';\n const prevFilename = g.__filename;\n const prevDirname = g.__dirname;\n\n if (!hadFilename) {\n try {\n const _require = createRequire(import.meta.url);\n const esbuildEntry = _require.resolve('esbuild');\n g.__filename = esbuildEntry;\n g.__dirname = dirname(esbuildEntry);\n } catch {\n // Best-effort: if esbuild can't be resolved the caller's catch handles it\n }\n }\n\n let moduleResult: BuildResult;\n try {\n moduleResult = esbuildBuildSync({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...buildOptions,\n });\n } finally {\n // Always restore the previous values so the globals don't linger.\n if (!hadFilename) {\n if (prevFilename === undefined) {\n // biome-ignore lint/performance/noDelete: the global must be truly absent — assigning undefined would leave the key present and break `typeof __filename` checks in other tools\n delete g.__filename;\n } else {\n g.__filename = prevFilename;\n }\n if (prevDirname === undefined) {\n // biome-ignore lint/performance/noDelete: same as __filename above\n delete g.__dirname;\n } else {\n g.__dirname = prevDirname;\n }\n }\n }\n\n const moduleResultString = moduleResult!.outputFiles?.[0]?.text;\n\n if (typeof moduleResultString === 'string') {\n setCachedTranspilation(\n filePath,\n codeHash,\n optionsKey,\n moduleResult!,\n moduleResultString\n );\n }\n\n return moduleResultString;\n};\n\nexport const transpileTSToCJS = async (\n code: string,\n filePath: string,\n options?: TranspileOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const { esbuildInstance, ...buildOptions } = options ?? {};\n\n const codeHash = computeKeyId([code]);\n const optionsKey = computeKeyId([buildOptions]);\n\n const cachedOutput = getCachedTranspilation(filePath, codeHash, optionsKey);\n if (typeof cachedOutput === 'string') return cachedOutput;\n\n // A one-shot build() releases its Go-side resources on completion and costs a\n // single service round-trip (context()+rebuild()+dispose() costs three).\n const esbuildBuild = esbuildInstance?.build ?? build;\n\n const moduleResult = await esbuildBuild({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath),\n sourcefile: filePath,\n },\n ...getTransformationOptions(filePath),\n ...buildOptions,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0]?.text;\n\n if (typeof moduleResultString === 'string') {\n setCachedTranspilation(\n filePath,\n codeHash,\n optionsKey,\n moduleResult,\n moduleResultString\n );\n }\n\n return moduleResultString;\n};\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,oCAAoB,IAAI,IAAgC;AAE9D,MAAM,mBAAmB,aAAyC;CAChE,MAAM,gBAAgB,QAAQ,QAAQ;CAEtC,IAAI,kBAAkB,IAAI,aAAa,GACrC,OAAO,kBAAkB,IAAI,aAAa;CAG5C,IAAI;CACJ,IAAI;EACF,MAAM,eAAe,KACnB,mBAAmB,aAAa,CAAC,CAAC,SAClC,eACF;EAGA,eAAe,WAAW,YAAY,IAAI,eAAe;CAC3D,QAAQ;EAEN,eAAe;CACjB;CAEA,kBAAkB,IAAI,eAAe,YAAY;CAEjD,OAAO;AACT;AAEA,MAAM,4BAA4B,cAAoC;CACpE,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;CACV;CACA,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,QAAQ;CAGR,UAAU;CACV,UAAU,gBAAgB,QAAQ;CAClC,QAAQ;EACN,mBAAmB,KAAK,UAAU,cAAc,QA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E,iBAAiB,GAAG,iBAAiB,WAAW,CAAC;CAEzD,MAAM,WAAW,aAAa,CAAC,IAAI,CAAC;CACpC,MAAM,aAAa,aAAa,CAAC,YAAY,CAAC;CAE9C,MAAM,eAAe,uBAAuB,UAAU,UAAU,UAAU;CAC1E,IAAI,OAAO,iBAAiB,UAAU,OAAO;CAM7C,MAAM,eAAe,OAFA,iBAAiB,SAAS,MAER,CAAC;EACtC,OAAO;GACL,UAAU;GACV;GACA,YAAY,QAAQ,QAAQ;GAC5B,YAAY;EACd;EACA,GAAG,yBAAyB,QAAQ;EACpC,GAAG;CACL,CAAC;CAED,MAAM,qBAAqB,aAAa,cAAc,EAAE,EAAE;CAE1D,IAAI,OAAO,uBAAuB,UAChC,uBACE,UACA,UACA,YACA,cACA,kBACF;CAGF,OAAO;AACT"}
@@ -93,7 +93,8 @@ const colorizeObject = (obj, indentLevel = 0, indentSize = 2, key) => {
93
93
  return `{\n${keys.map((key) => {
94
94
  const coloredKey = colorize(`"${key}"`, GREY_LIGHT);
95
95
  const value = obj[key];
96
- return `${nextIndent}${coloredKey}: ${colorizeObject(value, indentLevel + 1, indentSize, key)}`;
96
+ const coloredValue = colorizeObject(value, indentLevel + 1, indentSize, key);
97
+ return `${nextIndent}${coloredKey}: ${coloredValue}`;
97
98
  }).join(",\n")}\n${indent}}`;
98
99
  }
99
100
  return colorize(String(obj), GREY);
@@ -1 +1 @@
1
- {"version":3,"file":"logger.mjs","names":[],"sources":["../../src/logger.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport type * as ANSIColorsTypes from './colors';\nimport {\n BEIGE,\n BLUE,\n GREEN,\n GREY,\n GREY_DARK,\n GREY_LIGHT,\n RED,\n RESET,\n WHITE,\n} from './colors';\n\nexport type ANSIColorsType =\n (typeof ANSIColorsTypes)[keyof typeof ANSIColorsTypes];\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nlet loggerPrefix: string | undefined;\n\nexport const setPrefix = (prefix: string | undefined) => {\n loggerPrefix = prefix;\n};\n\nexport const getPrefix = (configPrefix?: string): string | undefined => {\n if (typeof loggerPrefix !== 'undefined') {\n return loggerPrefix;\n }\n\n return configPrefix;\n};\n\nexport const logger: Logger = (content, details) => {\n const config = details?.config ?? {};\n const mode = config.mode ?? 'default';\n\n if (mode === 'disabled' || (details?.isVerbose && mode !== 'verbose')) return;\n\n const prefix = getPrefix(config.prefix);\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n const level = details?.level ?? 'info';\n\n const logMethod =\n config[level] ?? console[level] ?? config.log ?? console.log;\n\n logMethod(...flatContent);\n};\n\nexport const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n/**\n * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.\n * It allows overriding the default configuration by passing a config object in the details parameter.\n * The configuration is merged with the default configuration from the intlayer config file.\n */\nexport const getAppLogger =\n (configuration?: Pick<IntlayerConfig, 'log'>, globalDetails?: Details) =>\n (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: {\n ...configuration?.log,\n ...globalDetails?.config,\n ...(details?.config ?? {}),\n },\n });\n\nexport const colorize = (\n string: string,\n color?: ANSIColorsType,\n reset?: boolean | ANSIColorsType\n): string =>\n color && typeof window === 'undefined'\n ? `${color}${string}${reset ? (typeof reset === 'boolean' ? RESET : reset) : RESET}`\n : string;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color: ANSIColorsType = GREEN,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color, reset))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color: ANSIColorsType = BEIGE,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color, reset))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color: ANSIColorsType = GREY,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [path]\n .flat()\n .map((path) => colorize(path, color, reset))\n .join(`, `);\n\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColorsType>> = {\n zero: BLUE,\n one: BLUE,\n two: BLUE,\n few: BLUE,\n many: BLUE,\n other: BLUE,\n }\n): string => {\n if (number === 0 || number === '0') {\n const color = options.zero ?? GREEN;\n return colorize(number.toString(), color);\n }\n\n // Kept inside the function. Top-level instantiation of classes/APIs\n // is treated as a side-effect and prevents tree-shaking if the function is unused.\n const rule = new Intl.PluralRules('en').select(Number(number));\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const colorizeObject = (\n obj: any,\n indentLevel = 0,\n indentSize = 2,\n key?: string\n): string => {\n const indent = ' '.repeat(indentLevel * indentSize);\n const nextIndent = ' '.repeat((indentLevel + 1) * indentSize);\n\n if (obj === null) {\n return colorize('null', BLUE);\n }\n\n if (typeof obj === 'boolean') {\n return colorize(obj.toString(), BLUE);\n }\n\n if (typeof obj === 'number') {\n return colorize(obj.toString(), BLUE);\n }\n\n if (typeof obj === 'string') {\n const isDateString = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}/.test(obj);\n const isUrl = obj.startsWith('http://') || obj.startsWith('https://');\n const isGlob = obj.includes('*') || obj.includes('?') || obj.includes('{');\n const isPath =\n obj.startsWith('/') ||\n obj.startsWith('./') ||\n obj.startsWith('../') ||\n /\\.[a-zA-Z0-9]{2,5}$/.test(obj);\n const isSecret =\n /^[0-9a-fA-F]{24,}$/.test(obj) || (obj.length >= 40 && !/\\s/.test(obj));\n const hasSpaces = /\\s/.test(obj);\n\n if (isDateString) return colorize(`\"${obj}\"`, BEIGE);\n if (isUrl) return colorize(`\"${obj}\"`, GREY_DARK);\n if (isGlob) return colorize(`\"${obj}\"`, GREY);\n if (isPath) return colorize(`\"${obj}\"`, GREY_DARK);\n if (isSecret) return colorize(`\"${obj}\"`, GREY);\n if (hasSpaces) return colorize(`\"${obj}\"`, WHITE);\n return colorize(`\"${obj}\"`, BLUE);\n }\n\n if (Array.isArray(obj)) {\n if (obj.length === 0) {\n return '[]';\n }\n const items = obj\n .map(\n (item) =>\n `${nextIndent}${colorizeObject(item, indentLevel + 1, indentSize, key)}`\n )\n .join(',\\n');\n return `[\\n${items}\\n${indent}]`;\n }\n\n if (typeof obj === 'object') {\n const keys = Object.keys(obj);\n\n if (keys.length === 0) {\n return '{}';\n }\n\n const fields = keys\n .map((key) => {\n const coloredKey = colorize(`\"${key}\"`, GREY_LIGHT);\n const value = obj[key];\n const coloredValue = colorizeObject(\n value,\n indentLevel + 1,\n indentSize,\n key\n );\n return `${nextIndent}${coloredKey}: ${coloredValue}`;\n })\n .join(',\\n');\n return `{\\n${fields}\\n${indent}}`;\n }\n\n return colorize(String(obj), GREY);\n};\n\nexport const removeColor = (text: string) =>\n // biome-ignore lint/suspicious/noControlCharactersInRegex: we need to remove the color codes\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'string')\n ) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'number')\n ) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad } = {\n ...defaultColonOptions,\n ...(options ?? {}),\n };\n\n const length = getLength(colSize);\n const spacesLength = Math.max(\n minSize!,\n Math.min(maxSize!, length - removeColor(text).length)\n );\n\n if (pad === 'left') {\n return `${' '.repeat(spacesLength)}${text}`;\n }\n\n return `${text}${' '.repeat(spacesLength)}`;\n })\n .join('');\n\nexport const x = colorize('✗', RED);\nexport const v = colorize('✓', GREEN);\nexport const clock = colorize('⏲', BLUE);\n"],"mappings":";;;AA6BA,IAAI;AAEJ,MAAa,aAAa,WAA+B;AACvD,gBAAe;;AAGjB,MAAa,aAAa,iBAA8C;AACtE,KAAI,OAAO,iBAAiB,YAC1B,QAAO;AAGT,QAAO;;AAGT,MAAa,UAAkB,SAAS,YAAY;CAClD,MAAM,SAAS,SAAS,UAAU,EAAE;CACpC,MAAM,OAAO,OAAO,QAAQ;AAE5B,KAAI,SAAS,cAAe,SAAS,aAAa,SAAS,UAAY;CAEvE,MAAM,SAAS,UAAU,OAAO,OAAO;CACvC,MAAM,cAAc,SAAS,CAAC,QAAQ,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM;CAC7E,MAAM,QAAQ,SAAS,SAAS;AAKhC,EAFE,OAAO,UAAU,QAAQ,UAAU,OAAO,OAAO,QAAQ,KAEjD,GAAG,YAAY;;AAG3B,MAAa,gBAAgB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAI;;;;;;AAO/E,MAAa,gBACV,eAA6C,mBAC7C,SAAc,YACb,OAAO,SAAS;CACd,GAAI,WAAW,EAAE;CACjB,QAAQ;EACN,GAAG,eAAe;EAClB,GAAG,eAAe;EAClB,GAAI,SAAS,UAAU,EAAE;EAC1B;CACF,CAAC;AAEN,MAAa,YACX,QACA,OACA,UAEA,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["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport type * as ANSIColorsTypes from './colors';\nimport {\n BEIGE,\n BLUE,\n GREEN,\n GREY,\n GREY_DARK,\n GREY_LIGHT,\n RED,\n RESET,\n WHITE,\n} from './colors';\n\nexport type ANSIColorsType =\n (typeof ANSIColorsTypes)[keyof typeof ANSIColorsTypes];\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nlet loggerPrefix: string | undefined;\n\nexport const setPrefix = (prefix: string | undefined) => {\n loggerPrefix = prefix;\n};\n\nexport const getPrefix = (configPrefix?: string): string | undefined => {\n if (typeof loggerPrefix !== 'undefined') {\n return loggerPrefix;\n }\n\n return configPrefix;\n};\n\nexport const logger: Logger = (content, details) => {\n const config = details?.config ?? {};\n const mode = config.mode ?? 'default';\n\n if (mode === 'disabled' || (details?.isVerbose && mode !== 'verbose')) return;\n\n const prefix = getPrefix(config.prefix);\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n const level = details?.level ?? 'info';\n\n const logMethod =\n config[level] ?? console[level] ?? config.log ?? console.log;\n\n logMethod(...flatContent);\n};\n\nexport const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n/**\n * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.\n * It allows overriding the default configuration by passing a config object in the details parameter.\n * The configuration is merged with the default configuration from the intlayer config file.\n */\nexport const getAppLogger =\n (configuration?: Pick<IntlayerConfig, 'log'>, globalDetails?: Details) =>\n (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: {\n ...configuration?.log,\n ...globalDetails?.config,\n ...(details?.config ?? {}),\n },\n });\n\nexport const colorize = (\n string: string,\n color?: ANSIColorsType,\n reset?: boolean | ANSIColorsType\n): string =>\n color && typeof window === 'undefined'\n ? `${color}${string}${reset ? (typeof reset === 'boolean' ? RESET : reset) : RESET}`\n : string;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color: ANSIColorsType = GREEN,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color, reset))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color: ANSIColorsType = BEIGE,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color, reset))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color: ANSIColorsType = GREY,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [path]\n .flat()\n .map((path) => colorize(path, color, reset))\n .join(`, `);\n\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColorsType>> = {\n zero: BLUE,\n one: BLUE,\n two: BLUE,\n few: BLUE,\n many: BLUE,\n other: BLUE,\n }\n): string => {\n if (number === 0 || number === '0') {\n const color = options.zero ?? GREEN;\n return colorize(number.toString(), color);\n }\n\n // Kept inside the function. Top-level instantiation of classes/APIs\n // is treated as a side-effect and prevents tree-shaking if the function is unused.\n const rule = new Intl.PluralRules('en').select(Number(number));\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const colorizeObject = (\n obj: any,\n indentLevel = 0,\n indentSize = 2,\n key?: string\n): string => {\n const indent = ' '.repeat(indentLevel * indentSize);\n const nextIndent = ' '.repeat((indentLevel + 1) * indentSize);\n\n if (obj === null) {\n return colorize('null', BLUE);\n }\n\n if (typeof obj === 'boolean') {\n return colorize(obj.toString(), BLUE);\n }\n\n if (typeof obj === 'number') {\n return colorize(obj.toString(), BLUE);\n }\n\n if (typeof obj === 'string') {\n const isDateString = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}/.test(obj);\n const isUrl = obj.startsWith('http://') || obj.startsWith('https://');\n const isGlob = obj.includes('*') || obj.includes('?') || obj.includes('{');\n const isPath =\n obj.startsWith('/') ||\n obj.startsWith('./') ||\n obj.startsWith('../') ||\n /\\.[a-zA-Z0-9]{2,5}$/.test(obj);\n const isSecret =\n /^[0-9a-fA-F]{24,}$/.test(obj) || (obj.length >= 40 && !/\\s/.test(obj));\n const hasSpaces = /\\s/.test(obj);\n\n if (isDateString) return colorize(`\"${obj}\"`, BEIGE);\n if (isUrl) return colorize(`\"${obj}\"`, GREY_DARK);\n if (isGlob) return colorize(`\"${obj}\"`, GREY);\n if (isPath) return colorize(`\"${obj}\"`, GREY_DARK);\n if (isSecret) return colorize(`\"${obj}\"`, GREY);\n if (hasSpaces) return colorize(`\"${obj}\"`, WHITE);\n return colorize(`\"${obj}\"`, BLUE);\n }\n\n if (Array.isArray(obj)) {\n if (obj.length === 0) {\n return '[]';\n }\n const items = obj\n .map(\n (item) =>\n `${nextIndent}${colorizeObject(item, indentLevel + 1, indentSize, key)}`\n )\n .join(',\\n');\n return `[\\n${items}\\n${indent}]`;\n }\n\n if (typeof obj === 'object') {\n const keys = Object.keys(obj);\n\n if (keys.length === 0) {\n return '{}';\n }\n\n const fields = keys\n .map((key) => {\n const coloredKey = colorize(`\"${key}\"`, GREY_LIGHT);\n const value = obj[key];\n const coloredValue = colorizeObject(\n value,\n indentLevel + 1,\n indentSize,\n key\n );\n return `${nextIndent}${coloredKey}: ${coloredValue}`;\n })\n .join(',\\n');\n return `{\\n${fields}\\n${indent}}`;\n }\n\n return colorize(String(obj), GREY);\n};\n\nexport const removeColor = (text: string) =>\n // biome-ignore lint/suspicious/noControlCharactersInRegex: we need to remove the color codes\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'string')\n ) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'number')\n ) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad } = {\n ...defaultColonOptions,\n ...(options ?? {}),\n };\n\n const length = getLength(colSize);\n const spacesLength = Math.max(\n minSize!,\n Math.min(maxSize!, length - removeColor(text).length)\n );\n\n if (pad === 'left') {\n return `${' '.repeat(spacesLength)}${text}`;\n }\n\n return `${text}${' '.repeat(spacesLength)}`;\n })\n .join('');\n\nexport const x = colorize('✗', RED);\nexport const v = colorize('✓', GREEN);\nexport const clock = colorize('⏲', BLUE);\n"],"mappings":";;;AA6BA,IAAI;AAEJ,MAAa,aAAa,WAA+B;CACvD,eAAe;AACjB;AAEA,MAAa,aAAa,iBAA8C;CACtE,IAAI,OAAO,iBAAiB,aAC1B,OAAO;CAGT,OAAO;AACT;AAEA,MAAa,UAAkB,SAAS,YAAY;CAClD,MAAM,SAAS,SAAS,UAAU,CAAC;CACnC,MAAM,OAAO,OAAO,QAAQ;CAE5B,IAAI,SAAS,cAAe,SAAS,aAAa,SAAS,WAAY;CAEvE,MAAM,SAAS,UAAU,OAAO,MAAM;CACtC,MAAM,cAAc,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK;CAC5E,MAAM,QAAQ,SAAS,SAAS;CAKhC,CAFE,OAAO,UAAU,QAAQ,UAAU,OAAO,OAAO,QAAQ,IAElD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Q;EACzC,GAAG;EACH,GAAI,WAAW,CAAC;CAClB;CAEA,MAAM,SAAS,UAAU,OAAO;CAChC,MAAM,eAAe,KAAK,IACxB,SACA,KAAK,IAAI,SAAU,SAAS,YAAY,IAAI,CAAC,CAAC,MAAM,CACtD;CAEA,IAAI,QAAQ,QACV,OAAO,GAAG,IAAI,OAAO,YAAY,IAAI;CAGvC,OAAO,GAAG,OAAO,IAAI,OAAO,YAAY;AAC1C,CAAC,CAAC,CACD,KAAK,EAAE;AAEZ,MAAa,IAAI,SAAS,KAAK,GAAG;AAClC,MAAa,IAAI,SAAS,KAAK,KAAK;AACpC,MAAa,QAAQ,SAAS,KAAK,IAAI"}
package/dist/esm/node.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./configFile/buildBrowserConfiguration.mjs";
2
- import { aiSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema } from "./configFile/configurationSchema.mjs";
1
+ import { buildAnalyticsFields, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./configFile/buildBrowserConfiguration.mjs";
2
+ import { aiSchema, analyticsSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema } from "./configFile/configurationSchema.mjs";
3
3
  import { buildConfigurationFields } from "./configFile/buildConfigurationFields.mjs";
4
4
  import { configurationFilesCandidates, searchConfigurationFile } from "./configFile/searchConfigurationFile.mjs";
5
5
  import { getConfiguration, getConfigurationAndFilePath } from "./configFile/getConfiguration.mjs";
6
6
 
7
- export { aiSchema, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
7
+ export { aiSchema, analyticsSchema, buildAnalyticsFields, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
@@ -1 +1 @@
1
- {"version":3,"file":"ESMxCJSHelpers.mjs","names":[],"sources":["../../../src/utils/ESMxCJSHelpers.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { getPackageJsonPath } from './getPackageJsonPath';\n\nexport const isESModule = typeof import.meta.url === 'string';\n\n/**\n * Require relative to the user project\n *\n * Note: Can resolve package that are installed in the user project, ex `'intlayer'`\n */\nexport const getProjectRequire = (startDir?: string): NodeJS.Require => {\n // Can fail on VSCode extensions\n const { packageJsonPath } = getPackageJsonPath(startDir);\n\n return createRequire(packageJsonPath);\n};\n\n/**\n * Require relative to the @intlayer/config package\n *\n * Note: Can resolve package that are installed in the config package, ex `'@intlayer/types'`\n */\nexport const configESMxCJSRequire: NodeJS.Require = isESModule\n ? createRequire(import.meta.url)\n : require;\n"],"mappings":";;;;;AAGA,MAAa,aAAa,OAAO,OAAO,KAAK,QAAQ;;;;;;AAOrD,MAAa,qBAAqB,aAAsC;CAEtE,MAAM,EAAE,oBAAoB,mBAAmB,SAAS;AAExD,QAAO,cAAc,gBAAgB;;;;;;;AAQvC,MAAa,uBAAuC,aAChD,cAAc,OAAO,KAAK,IAAI"}
1
+ {"version":3,"file":"ESMxCJSHelpers.mjs","names":[],"sources":["../../../src/utils/ESMxCJSHelpers.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { getPackageJsonPath } from './getPackageJsonPath';\n\nexport const isESModule = typeof import.meta.url === 'string';\n\n/**\n * Require relative to the user project\n *\n * Note: Can resolve package that are installed in the user project, ex `'intlayer'`\n */\nexport const getProjectRequire = (startDir?: string): NodeJS.Require => {\n // Can fail on VSCode extensions\n const { packageJsonPath } = getPackageJsonPath(startDir);\n\n return createRequire(packageJsonPath);\n};\n\n/**\n * Require relative to the @intlayer/config package\n *\n * Note: Can resolve package that are installed in the config package, ex `'@intlayer/types'`\n */\nexport const configESMxCJSRequire: NodeJS.Require = isESModule\n ? createRequire(import.meta.url)\n : require;\n"],"mappings":";;;;;AAGA,MAAa,aAAa,OAAO,OAAO,KAAK,QAAQ;;;;;;AAOrD,MAAa,qBAAqB,aAAsC;CAEtE,MAAM,EAAE,oBAAoB,mBAAmB,QAAQ;CAEvD,OAAO,cAAc,eAAe;AACtC;;;;;;AAOA,MAAa,uBAAuC,aAChD,cAAc,OAAO,KAAK,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"alias.mjs","names":[],"sources":["../../../src/utils/alias.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getExtension } from './getExtension';\nimport { normalizePath } from './normalizePath';\n\nexport type GetAliasOptions = {\n configuration: IntlayerConfig;\n format?: 'esm' | 'cjs';\n formatter?: (value: string) => string;\n};\n\nexport const getAlias = ({\n configuration,\n format,\n formatter = (value: string) => value,\n}: GetAliasOptions) => {\n const extension = getExtension(\n configuration,\n format ?? configuration.build.outputFormat[0] ?? 'esm'\n );\n\n const { baseDir } = configuration.system;\n const { mainDir, configDir } = configuration.system;\n\n /**\n * Dictionaries\n */\n const dictionariesPath = join(mainDir, `dictionaries.${extension}`);\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n const fixedDictionariesPath = formatter(\n normalizePath(relativeDictionariesPath)\n );\n\n /**\n * Unmerged dictionaries\n */\n const unmergedDictionariesPath = join(\n mainDir,\n `unmerged_dictionaries.${extension}`\n );\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n const fixedUnmergedDictionariesPath = formatter(\n normalizePath(relativeUnmergedDictionariesPath)\n );\n\n /**\n * Remote dictionaries\n */\n const remoteDictionariesPath = join(\n mainDir,\n `remote_dictionaries.${extension}`\n );\n const relativeRemoteDictionariesPath = relative(\n baseDir,\n remoteDictionariesPath\n );\n const fixedRemoteDictionariesPath = formatter(\n normalizePath(relativeRemoteDictionariesPath)\n );\n\n /**\n * Dynamic dictionaries\n */\n const dynamicDictionariesPath = join(\n mainDir,\n `dynamic_dictionaries.${extension}`\n );\n const relativeDynamicDictionariesPath = relative(\n baseDir,\n dynamicDictionariesPath\n );\n const fixedDynamicDictionariesPath = formatter(\n normalizePath(relativeDynamicDictionariesPath)\n );\n\n /**\n * Fetch dictionaries\n */\n const fetchDictionariesPath = join(\n mainDir,\n `fetch_dictionaries.${extension}`\n );\n const relativeFetchDictionariesPath = relative(\n baseDir,\n fetchDictionariesPath\n );\n const fixedFetchDictionariesPath = formatter(\n normalizePath(relativeFetchDictionariesPath)\n );\n\n /**\n * Configuration\n */\n const configurationPath = join(configDir, `configuration.${extension}`);\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n const fixedConfigurationPath = formatter(\n normalizePath(relativeConfigurationPath)\n );\n\n return {\n '@intlayer/dictionaries-entry': fixedDictionariesPath,\n '@intlayer/unmerged-dictionaries-entry': fixedUnmergedDictionariesPath,\n '@intlayer/remote-dictionaries-entry': fixedRemoteDictionariesPath,\n '@intlayer/dynamic-dictionaries-entry': fixedDynamicDictionariesPath,\n '@intlayer/fetch-dictionaries-entry': fixedFetchDictionariesPath,\n '@intlayer/config/built': fixedConfigurationPath,\n } as const;\n};\n"],"mappings":";;;;;AAWA,MAAa,YAAY,EACvB,eACA,QACA,aAAa,UAAkB,YACV;CACrB,MAAM,YAAY,aAChB,eACA,UAAU,cAAc,MAAM,aAAa,MAAM,MAClD;CAED,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,SAAS,cAAc,cAAc;AAgF7C,QAAO;EACL,gCA1E4B,UAC5B,cAF+B,SAAS,SADjB,KAAK,SAAS,gBAAgB,YACY,CAE3B,CAAC,CAyEc;EACrD,yCA5DoC,UACpC,cALuC,SACvC,SAL+B,KAC/B,SACA,yBAAyB,YAID,CAGsB,CAAC,CA2DuB;EACtE,uCA9CkC,UAClC,cALqC,SACrC,SAL6B,KAC7B,SACA,uBAAuB,YAID,CAGsB,CAAC,CA6CqB;EAClE,wCAhCmC,UACnC,cALsC,SACtC,SAL8B,KAC9B,SACA,wBAAwB,YAID,CAGsB,CAAC,CA+BsB;EACpE,sCAlBiC,UACjC,cALoC,SACpC,SAL4B,KAC5B,SACA,sBAAsB,YAID,CAGsB,CAAC,CAiBoB;EAChE,0BAV6B,UAC7B,cAFgC,SAAS,SADjB,KAAK,WAAW,iBAAiB,YACU,CAE5B,CAAC,CASQ;EACjD"}
1
+ {"version":3,"file":"alias.mjs","names":[],"sources":["../../../src/utils/alias.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getExtension } from './getExtension';\nimport { normalizePath } from './normalizePath';\n\nexport type GetAliasOptions = {\n configuration: IntlayerConfig;\n format?: 'esm' | 'cjs';\n formatter?: (value: string) => string;\n};\n\nexport const getAlias = ({\n configuration,\n format,\n formatter = (value: string) => value,\n}: GetAliasOptions) => {\n const extension = getExtension(\n configuration,\n format ?? configuration.build.outputFormat[0] ?? 'esm'\n );\n\n const { baseDir } = configuration.system;\n const { mainDir, configDir } = configuration.system;\n\n /**\n * Dictionaries\n */\n const dictionariesPath = join(mainDir, `dictionaries.${extension}`);\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n const fixedDictionariesPath = formatter(\n normalizePath(relativeDictionariesPath)\n );\n\n /**\n * Unmerged dictionaries\n */\n const unmergedDictionariesPath = join(\n mainDir,\n `unmerged_dictionaries.${extension}`\n );\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n const fixedUnmergedDictionariesPath = formatter(\n normalizePath(relativeUnmergedDictionariesPath)\n );\n\n /**\n * Remote dictionaries\n */\n const remoteDictionariesPath = join(\n mainDir,\n `remote_dictionaries.${extension}`\n );\n const relativeRemoteDictionariesPath = relative(\n baseDir,\n remoteDictionariesPath\n );\n const fixedRemoteDictionariesPath = formatter(\n normalizePath(relativeRemoteDictionariesPath)\n );\n\n /**\n * Dynamic dictionaries\n */\n const dynamicDictionariesPath = join(\n mainDir,\n `dynamic_dictionaries.${extension}`\n );\n const relativeDynamicDictionariesPath = relative(\n baseDir,\n dynamicDictionariesPath\n );\n const fixedDynamicDictionariesPath = formatter(\n normalizePath(relativeDynamicDictionariesPath)\n );\n\n /**\n * Fetch dictionaries\n */\n const fetchDictionariesPath = join(\n mainDir,\n `fetch_dictionaries.${extension}`\n );\n const relativeFetchDictionariesPath = relative(\n baseDir,\n fetchDictionariesPath\n );\n const fixedFetchDictionariesPath = formatter(\n normalizePath(relativeFetchDictionariesPath)\n );\n\n /**\n * Configuration\n */\n const configurationPath = join(configDir, `configuration.${extension}`);\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n const fixedConfigurationPath = formatter(\n normalizePath(relativeConfigurationPath)\n );\n\n return {\n '@intlayer/dictionaries-entry': fixedDictionariesPath,\n '@intlayer/unmerged-dictionaries-entry': fixedUnmergedDictionariesPath,\n '@intlayer/remote-dictionaries-entry': fixedRemoteDictionariesPath,\n '@intlayer/dynamic-dictionaries-entry': fixedDynamicDictionariesPath,\n '@intlayer/fetch-dictionaries-entry': fixedFetchDictionariesPath,\n '@intlayer/config/built': fixedConfigurationPath,\n } as const;\n};\n"],"mappings":";;;;;AAWA,MAAa,YAAY,EACvB,eACA,QACA,aAAa,UAAkB,YACV;CACrB,MAAM,YAAY,aAChB,eACA,UAAU,cAAc,MAAM,aAAa,MAAM,KACnD;CAEA,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,SAAS,cAAc,cAAc;CAgF7C,OAAO;EACL,gCA1E4B,UAC5B,cAF+B,SAAS,SADjB,KAAK,SAAS,gBAAgB,WACW,CAE3B,CAAC,CAyEc;EACpD,yCA5DoC,UACpC,cALuC,SACvC,SAL+B,KAC/B,SACA,yBAAyB,WAIF,CAGsB,CAAC,CA2DuB;EACrE,uCA9CkC,UAClC,cALqC,SACrC,SAL6B,KAC7B,SACA,uBAAuB,WAIF,CAGsB,CAAC,CA6CqB;EACjE,wCAhCmC,UACnC,cALsC,SACtC,SAL8B,KAC9B,SACA,wBAAwB,WAIF,CAGsB,CAAC,CA+BsB;EACnE,sCAlBiC,UACjC,cALoC,SACpC,SAL4B,KAC5B,SACA,sBAAsB,WAIF,CAGsB,CAAC,CAiBoB;EAC/D,0BAV6B,UAC7B,cAFgC,SAAS,SADjB,KAAK,WAAW,iBAAiB,WACS,CAE5B,CAAC,CASQ;CACjD;AACF"}
@@ -0,0 +1,36 @@
1
+ //#region src/utils/builtConfigKeys.ts
2
+ /**
3
+ * Canonical list of configuration sections exposed as named exports by
4
+ * `@intlayer/config/built`.
5
+ *
6
+ * At build time, bundler integrations (Vite, webpack, …) alias
7
+ * `@intlayer/config/built` to the generated `.intlayer/config/configuration.mjs`
8
+ * file (see {@link getAlias} and `generateConfigurationContent`). For that alias
9
+ * to be transparent, the generated file MUST expose exactly the same named
10
+ * exports as `built.ts`; otherwise a consumer importing one of them (e.g.
11
+ * `import { analytics } from '@intlayer/config/built'`) triggers a
12
+ * `MISSING_EXPORT` bundler error.
13
+ *
14
+ * Deriving both `built.ts` and the generator from this single array guarantees
15
+ * they can never drift: adding a section here is the only change required to
16
+ * expose it in every build target.
17
+ */
18
+ const BUILT_CONFIG_KEYS = [
19
+ "internationalization",
20
+ "dictionary",
21
+ "routing",
22
+ "content",
23
+ "system",
24
+ "editor",
25
+ "analytics",
26
+ "log",
27
+ "ai",
28
+ "build",
29
+ "compiler",
30
+ "schemas",
31
+ "plugins"
32
+ ];
33
+
34
+ //#endregion
35
+ export { BUILT_CONFIG_KEYS };
36
+ //# sourceMappingURL=builtConfigKeys.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtConfigKeys.mjs","names":[],"sources":["../../../src/utils/builtConfigKeys.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Canonical list of configuration sections exposed as named exports by\n * `@intlayer/config/built`.\n *\n * At build time, bundler integrations (Vite, webpack, …) alias\n * `@intlayer/config/built` to the generated `.intlayer/config/configuration.mjs`\n * file (see {@link getAlias} and `generateConfigurationContent`). For that alias\n * to be transparent, the generated file MUST expose exactly the same named\n * exports as `built.ts`; otherwise a consumer importing one of them (e.g.\n * `import { analytics } from '@intlayer/config/built'`) triggers a\n * `MISSING_EXPORT` bundler error.\n *\n * Deriving both `built.ts` and the generator from this single array guarantees\n * they can never drift: adding a section here is the only change required to\n * expose it in every build target.\n */\nexport const BUILT_CONFIG_KEYS = [\n 'internationalization',\n 'dictionary',\n 'routing',\n 'content',\n 'system',\n 'editor',\n 'analytics',\n 'log',\n 'ai',\n 'build',\n 'compiler',\n 'schemas',\n 'plugins',\n] as const satisfies readonly (keyof IntlayerConfig)[];\n\n/**\n * Union of the configuration section names exposed by `@intlayer/config/built`.\n */\nexport type BuiltConfigKey = (typeof BUILT_CONFIG_KEYS)[number];\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -3,7 +3,7 @@ import { basename, dirname, join } from "node:path";
3
3
  import { mkdir, readFile, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
4
4
  import { deserialize, serialize } from "node:v8";
5
5
  import { gunzipSync, gzipSync } from "node:zlib";
6
- import packageJSON from "@intlayer/types/package.json" with { type: "json" };
6
+ import configPackageJson from "@intlayer/types/package.json" with { type: "json" };
7
7
 
8
8
  //#region src/utils/cacheDisk.ts
9
9
  const DEFAULTS = { compress: true };
@@ -60,7 +60,7 @@ const cacheDisk = (intlayerConfig, keys, options) => {
60
60
  const maybeObj = deserialized;
61
61
  if (!!maybeObj && typeof maybeObj === "object" && typeof maybeObj.version === "string" && typeof maybeObj.timestamp === "number" && Object.hasOwn(maybeObj, "data")) {
62
62
  const entry = maybeObj;
63
- if (entry.version !== packageJSON.version) {
63
+ if (entry.version !== configPackageJson.version) {
64
64
  try {
65
65
  await unlink(filePath);
66
66
  } catch {}
@@ -96,13 +96,14 @@ const cacheDisk = (intlayerConfig, keys, options) => {
96
96
  try {
97
97
  await ensureDir(dirname(filePath));
98
98
  const envelope = {
99
- version: packageJSON.version,
99
+ version: configPackageJson.version,
100
100
  timestamp: Date.now(),
101
101
  data: value
102
102
  };
103
103
  const payload = Buffer.from(serialize(envelope));
104
104
  const gz = shouldUseCompression(payload, compress) ? gzipSync(payload) : payload;
105
- await atomicWriteFile(filePath, Buffer.concat([Buffer.from([gz === payload ? 0 : 1]), gz]), tempDir);
105
+ const buf = Buffer.concat([Buffer.from([gz === payload ? 0 : 1]), gz]);
106
+ await atomicWriteFile(filePath, buf, tempDir);
106
107
  } catch {}
107
108
  };
108
109
  return {
@@ -156,7 +157,7 @@ const cacheDisk = (intlayerConfig, keys, options) => {
156
157
  const maybeObj = deserialize(flag === 1 ? gunzipSync(raw) : raw);
157
158
  if (!!maybeObj && typeof maybeObj === "object" && typeof maybeObj.version === "string" && typeof maybeObj.timestamp === "number" && Object.hasOwn(maybeObj, "data")) {
158
159
  const entry = maybeObj;
159
- if (entry.version !== packageJSON.version) return false;
160
+ if (entry.version !== configPackageJson.version) return false;
160
161
  if (typeof maxTimeMs === "number" && maxTimeMs > 0) {
161
162
  if (Date.now() - entry.timestamp > maxTimeMs) return false;
162
163
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cacheDisk.mjs","names":["configPackageJson"],"sources":["../../../src/utils/cacheDisk.ts"],"sourcesContent":["import {\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { basename, dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport configPackageJson from '@intlayer/types/package.json' with {\n type: 'json',\n};\nimport { type CacheKey, clearAllCache, computeKeyId } from './cacheMemory';\n\n/** ------------------------- Persistence layer ------------------------- **/\n\n/** Cache envelope structure stored on disk */\ntype CacheEnvelope = {\n /** Version of the config package (for cache invalidation) */\n version: string;\n /** Timestamp when the cache entry was created (in milliseconds) */\n timestamp: number;\n /** Data payload (the actual cached value) */\n data: unknown;\n};\n\ntype LocalCacheOptions = {\n /** Preferred new option name */\n persistent?: boolean;\n /** Time-to-live in ms; if expired, disk entry is ignored. */\n ttlMs?: number;\n /** Max age in ms based on stored creation timestamp; invalidates on exceed. */\n maxTimeMs?: number;\n /** Optional namespace to separate different logical caches. */\n namespace?: string;\n /** Gzip values on disk (on by default for blobs > 1KB). */\n compress?: boolean;\n};\n\nconst DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>> = {\n compress: true,\n};\n\nconst ensureDir = async (dir: string) => {\n await mkdir(dir, { recursive: true });\n};\n\nconst atomicWriteFile = async (\n file: string,\n data: Buffer,\n tempDir?: string\n) => {\n if (tempDir) {\n try {\n await ensureDir(tempDir);\n } catch {}\n }\n\n const tempFileName = `${basename(file)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n const tmp = tempDir\n ? join(tempDir, tempFileName)\n : `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n try {\n await writeFile(tmp, data);\n await rename(tmp, file);\n } catch (error) {\n try {\n await rm(tmp, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\n};\n\nconst shouldUseCompression = (buf: Buffer, force?: boolean) =>\n force === true || (force !== false && buf.byteLength > 1024);\n\n/** Derive on-disk path from config dir + namespace + key id. */\nconst cachePath = (cacheDir: string, id: string, ns?: string) =>\n join(cacheDir, ns ? join(ns, id) : id);\n\n/** ------------------------- Local cache facade ------------------------- **/\n\nconst cacheMap = new Map<string, any>();\n\n/** Clears the in-memory portion of the disk cache without touching disk files. */\nexport const clearDiskCacheMemory = (): void => {\n cacheMap.clear();\n};\n\nexport const cacheDisk = (\n intlayerConfig: IntlayerConfig,\n keys: CacheKey[],\n options?: LocalCacheOptions\n) => {\n const { cacheDir, tempDir } = intlayerConfig.system;\n const buildCacheEnabled = intlayerConfig.build.cache ?? true;\n const persistent =\n options?.persistent === true ||\n (typeof options?.persistent === 'undefined' && buildCacheEnabled);\n\n const { compress, ttlMs, maxTimeMs, namespace } = {\n ...DEFAULTS,\n ...options,\n };\n\n // single stable id for this key tuple (works for both memory & disk)\n const id = computeKeyId(keys);\n const filePath = cachePath(cacheDir, id, namespace);\n\n const readFromDisk = async (): Promise<unknown | undefined> => {\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n\n if (!statValue) return undefined;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return undefined;\n }\n let raw = await readFile(filePath);\n // header: 1 byte flag (0x00 raw, 0x01 gzip)\n const flag = raw[0];\n\n raw = raw.subarray(1);\n\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n let value: unknown;\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof (maybeObj as any).version === 'string' &&\n typeof (maybeObj as any).timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n\n if (entry.version !== configPackageJson.version) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n\n value = entry.data;\n } else {\n // Backward compatibility: old entries had raw serialized value.\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n value = deserialized;\n }\n\n // hydrate memory cache as well\n cacheMap.set(id, value);\n return value;\n } catch {\n return undefined;\n }\n };\n\n const writeToDisk = async (value: unknown) => {\n try {\n await ensureDir(dirname(filePath));\n const envelope: CacheEnvelope = {\n version: configPackageJson.version,\n timestamp: Date.now(),\n data: value,\n };\n const payload = Buffer.from(serialize(envelope));\n\n const gz = shouldUseCompression(payload, compress)\n ? gzipSync(payload)\n : payload;\n\n // prepend a 1-byte header indicating compression\n const buf = Buffer.concat([\n Buffer.from([gz === payload ? 0x00 : 0x01]),\n gz,\n ]);\n\n await atomicWriteFile(filePath, buf, tempDir);\n } catch {\n // swallow disk errors for cache writes\n }\n };\n\n return {\n /** In-memory first, then disk (if enabled), otherwise undefined. */\n get: async <T>(): Promise<T | undefined> => {\n const mem = cacheMap.get(id);\n\n if (mem !== undefined) return mem as T;\n\n if (persistent && buildCacheEnabled) {\n return (await readFromDisk()) as T | undefined;\n }\n return undefined;\n },\n /** Sets in-memory (always) and persists to disk if enabled. */\n set: async (value: unknown): Promise<void> => {\n cacheMap.set(id, value);\n\n if (persistent && buildCacheEnabled) {\n await writeToDisk(value);\n }\n },\n /** Clears only this entry from memory and disk. */\n clear: async (): Promise<void> => {\n cacheMap.delete(id);\n\n try {\n await unlink(filePath);\n } catch {}\n },\n /** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */\n clearAll: async (): Promise<void> => {\n clearAllCache();\n if (persistent && buildCacheEnabled) {\n // remove only the current namespace (if provided), else the root dir\n const base = namespace ? join(cacheDir, namespace) : cacheDir;\n\n try {\n await rm(base, { recursive: true, force: true });\n } catch {}\n\n try {\n await mkdir(base, { recursive: true });\n } catch {}\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n isValid: async (): Promise<boolean> => {\n const cachedValue = cacheMap.get(id);\n if (cachedValue !== undefined) return true;\n\n // If persistence is disabled or build cache disabled, only memory can be valid\n if (!persistent || !buildCacheEnabled) return false;\n\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n if (!statValue) return false;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return false;\n }\n\n let raw = await readFile(filePath);\n const flag = raw[0];\n raw = raw.subarray(1);\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof maybeObj.version === 'string' &&\n typeof maybeObj.timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n if (entry.version !== configPackageJson.version) return false;\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) return false;\n }\n return true;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) return false;\n }\n return true;\n } catch {\n return false;\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n id,\n /** Expose the absolute file path for debugging. */\n filePath,\n };\n};\n"],"mappings":";;;;;;;;AA2CA,MAAM,WAA0D,EAC9D,UAAU,MAC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B,OAAO,OAAO,UAAU,OAAO,EAEjB;KACd,MAAM,QAAQ;AACd,SAAI,MAAM,YAAYA,YAAkB,QAAS,QAAO;AAExD,SAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;UADY,KAAK,KAAK,GAAG,MAAM,YACrB,UAAW,QAAO;;AAE9B,YAAO;;AAGT,QAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,UAAW,QAAO;;AAE9B,WAAO;WACD;AACN,WAAO;;;;EAIX;;EAEA;EACD"}
1
+ {"version":3,"file":"cacheDisk.mjs","names":[],"sources":["../../../src/utils/cacheDisk.ts"],"sourcesContent":["import {\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { basename, dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport configPackageJson from '@intlayer/types/package.json' with {\n type: 'json',\n};\nimport { type CacheKey, clearAllCache, computeKeyId } from './cacheMemory';\n\n/** ------------------------- Persistence layer ------------------------- **/\n\n/** Cache envelope structure stored on disk */\ntype CacheEnvelope = {\n /** Version of the config package (for cache invalidation) */\n version: string;\n /** Timestamp when the cache entry was created (in milliseconds) */\n timestamp: number;\n /** Data payload (the actual cached value) */\n data: unknown;\n};\n\ntype LocalCacheOptions = {\n /** Preferred new option name */\n persistent?: boolean;\n /** Time-to-live in ms; if expired, disk entry is ignored. */\n ttlMs?: number;\n /** Max age in ms based on stored creation timestamp; invalidates on exceed. */\n maxTimeMs?: number;\n /** Optional namespace to separate different logical caches. */\n namespace?: string;\n /** Gzip values on disk (on by default for blobs > 1KB). */\n compress?: boolean;\n};\n\nconst DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>> = {\n compress: true,\n};\n\nconst ensureDir = async (dir: string) => {\n await mkdir(dir, { recursive: true });\n};\n\nconst atomicWriteFile = async (\n file: string,\n data: Buffer,\n tempDir?: string\n) => {\n if (tempDir) {\n try {\n await ensureDir(tempDir);\n } catch {}\n }\n\n const tempFileName = `${basename(file)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n const tmp = tempDir\n ? join(tempDir, tempFileName)\n : `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n try {\n await writeFile(tmp, data);\n await rename(tmp, file);\n } catch (error) {\n try {\n await rm(tmp, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\n};\n\nconst shouldUseCompression = (buf: Buffer, force?: boolean) =>\n force === true || (force !== false && buf.byteLength > 1024);\n\n/** Derive on-disk path from config dir + namespace + key id. */\nconst cachePath = (cacheDir: string, id: string, ns?: string) =>\n join(cacheDir, ns ? join(ns, id) : id);\n\n/** ------------------------- Local cache facade ------------------------- **/\n\nconst cacheMap = new Map<string, any>();\n\n/** Clears the in-memory portion of the disk cache without touching disk files. */\nexport const clearDiskCacheMemory = (): void => {\n cacheMap.clear();\n};\n\nexport const cacheDisk = (\n intlayerConfig: IntlayerConfig,\n keys: CacheKey[],\n options?: LocalCacheOptions\n) => {\n const { cacheDir, tempDir } = intlayerConfig.system;\n const buildCacheEnabled = intlayerConfig.build.cache ?? true;\n const persistent =\n options?.persistent === true ||\n (typeof options?.persistent === 'undefined' && buildCacheEnabled);\n\n const { compress, ttlMs, maxTimeMs, namespace } = {\n ...DEFAULTS,\n ...options,\n };\n\n // single stable id for this key tuple (works for both memory & disk)\n const id = computeKeyId(keys);\n const filePath = cachePath(cacheDir, id, namespace);\n\n const readFromDisk = async (): Promise<unknown | undefined> => {\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n\n if (!statValue) return undefined;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return undefined;\n }\n let raw = await readFile(filePath);\n // header: 1 byte flag (0x00 raw, 0x01 gzip)\n const flag = raw[0];\n\n raw = raw.subarray(1);\n\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n let value: unknown;\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof (maybeObj as any).version === 'string' &&\n typeof (maybeObj as any).timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n\n if (entry.version !== configPackageJson.version) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n\n value = entry.data;\n } else {\n // Backward compatibility: old entries had raw serialized value.\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n value = deserialized;\n }\n\n // hydrate memory cache as well\n cacheMap.set(id, value);\n return value;\n } catch {\n return undefined;\n }\n };\n\n const writeToDisk = async (value: unknown) => {\n try {\n await ensureDir(dirname(filePath));\n const envelope: CacheEnvelope = {\n version: configPackageJson.version,\n timestamp: Date.now(),\n data: value,\n };\n const payload = Buffer.from(serialize(envelope));\n\n const gz = shouldUseCompression(payload, compress)\n ? gzipSync(payload)\n : payload;\n\n // prepend a 1-byte header indicating compression\n const buf = Buffer.concat([\n Buffer.from([gz === payload ? 0x00 : 0x01]),\n gz,\n ]);\n\n await atomicWriteFile(filePath, buf, tempDir);\n } catch {\n // swallow disk errors for cache writes\n }\n };\n\n return {\n /** In-memory first, then disk (if enabled), otherwise undefined. */\n get: async <T>(): Promise<T | undefined> => {\n const mem = cacheMap.get(id);\n\n if (mem !== undefined) return mem as T;\n\n if (persistent && buildCacheEnabled) {\n return (await readFromDisk()) as T | undefined;\n }\n return undefined;\n },\n /** Sets in-memory (always) and persists to disk if enabled. */\n set: async (value: unknown): Promise<void> => {\n cacheMap.set(id, value);\n\n if (persistent && buildCacheEnabled) {\n await writeToDisk(value);\n }\n },\n /** Clears only this entry from memory and disk. */\n clear: async (): Promise<void> => {\n cacheMap.delete(id);\n\n try {\n await unlink(filePath);\n } catch {}\n },\n /** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */\n clearAll: async (): Promise<void> => {\n clearAllCache();\n if (persistent && buildCacheEnabled) {\n // remove only the current namespace (if provided), else the root dir\n const base = namespace ? join(cacheDir, namespace) : cacheDir;\n\n try {\n await rm(base, { recursive: true, force: true });\n } catch {}\n\n try {\n await mkdir(base, { recursive: true });\n } catch {}\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n isValid: async (): Promise<boolean> => {\n const cachedValue = cacheMap.get(id);\n if (cachedValue !== undefined) return true;\n\n // If persistence is disabled or build cache disabled, only memory can be valid\n if (!persistent || !buildCacheEnabled) return false;\n\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n if (!statValue) return false;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return false;\n }\n\n let raw = await readFile(filePath);\n const flag = raw[0];\n raw = raw.subarray(1);\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof maybeObj.version === 'string' &&\n typeof maybeObj.timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n if (entry.version !== configPackageJson.version) return false;\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) return false;\n }\n return true;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) return false;\n }\n return true;\n } catch {\n return false;\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n id,\n /** Expose the absolute file path for debugging. */\n filePath,\n };\n};\n"],"mappings":";;;;;;;;AA2CA,MAAM,WAA0D,EAC9D,UAAU,KACZ;AAEA,MAAM,YAAY,OAAO,QAAgB;CACvC,MAAM,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AACtC;AAEA,MAAM,kBAAkB,OACtB,MACA,MACA,YACG;CACH,IAAI,SACF,IAAI;EACF,MAAM,UAAU,OAAO;CACzB,QAAQ,CAAC;CAGX,MAAM,eAAe,GAAG,SAAS,IAAI,EAAE,OAAO,QAAQ,IAAI,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;CAC/F,MAAM,MAAM,UACR,KAAK,SAAS,YAAY,IAC1B,GAAG,KAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;CACpE,IAAI;EACF,MAAM,UAAU,KAAK,IAAI;EACzB,MAAM,OAAO,KAAK,IAAI;CACxB,SAAS,OAAO;EACd,IAAI;GACF,MAAM,GAAG,KAAK,EAAE,OAAO,KAAK,CAAC;EAC/B,QAAQ,CAER;EACA,MAAM;CACR;AACF;AAEA,MAAM,wBAAwB,KAAa,UACzC,UAAU,QAAS,UAAU,SAAS,IAAI,aAAa;;AAGzD,MAAM,aAAa,UAAkB,IAAY,OAC/C,KAAK,UAAU,KAAK,KAAK,IAAI,EAAE,IAAI,EAAE;;AAIvC,MAAM,2BAAW,IAAI,IAAiB;;AAGtC,MAAa,6BAAmC;CAC9C,SAAS,MAAM;AACjB;AAEA,MAAa,aACX,gBACA,MACA,YACG;CACH,MAAM,EAAE,UAAU,YAAY,eAAe;CAC7C,MAAM,oBAAoB,eAAe,MAAM,SAAS;CACxD,MAAM,aACJ,SAAS,eAAe,QACvB,OAAO,SAA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AAI;IACF,MAAM,YAAY,MAAM,KAAK,QAAQ,CAAC,CAAC,YAAY,MAAS;IAC5D,IAAI,CAAC,WAAW,OAAO;IAEvB,IAAI,OAAO,UAAU,YAAY,QAAQ,GAEvC;SADY,KAAK,IAAI,IAAI,UAAU,UACzB,OAAO,OAAO;IAAK;IAG/B,IAAI,MAAM,MAAM,SAAS,QAAQ;IACjC,MAAM,OAAO,IAAI;IACjB,MAAM,IAAI,SAAS,CAAC;IAIpB,MAAM,WAFe,YADL,SAAS,IAAO,WAAW,GAAG,IAAI,GAGtB;IAQ5B,IANE,CAAC,CAAC,YACF,OAAO,aAAa,YACpB,OAAO,SAAS,YAAY,YAC5B,OAAO,SAAS,cAAc,YAC9B,OAAO,OAAO,UAAU,MAAM,GAEhB;KACd,MAAM,QAAQ;KACd,IAAI,MAAM,YAAY,kBAAkB,SAAS,OAAO;KAExD,IAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;UADY,KAAK,IAAI,IAAI,MAAM,YACrB,WAAW,OAAO;KAAK;KAEnC,OAAO;IACT;IAEA,IAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;SADY,KAAK,IAAI,IAAI,UAAU,UACzB,WAAW,OAAO;IAAK;IAEnC,OAAO;GACT,QAAQ;IACN,OAAO;GACT;EACF;;EAEA;;EAEA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"cacheMemory.mjs","names":[],"sources":["../../../src/utils/cacheMemory.ts"],"sourcesContent":["import { createHash, type Hash } from 'node:crypto';\n\n/** ------------------------- Utilities ------------------------- **/\n\n/** Prefer a fast non-crypto hash if available, then fast crypto, then sha256. */\nconst pickHashAlgorithm = (): string => {\n try {\n // Node 20+ supports xxhash64 (very fast). We feature-detect at module load.\n createHash('xxhash64').update('test').digest();\n return 'xxhash64';\n } catch {}\n try {\n // sha1 is faster than sha256 and sufficient for cache keys.\n createHash('sha1').update('test').digest();\n return 'sha1';\n } catch {}\n\n return 'sha256';\n};\nconst HASH_ALGORITHM = pickHashAlgorithm();\n\n/** Base64url without padding for compact, file-system-safe ids. */\nconst toBase64Url = (buffer: Buffer): string =>\n buffer\n .toString('base64')\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/g, '');\n\n/** Token helpers to minimize collisions while streaming to the hasher. */\nconst token = {\n start: (hasher: Hash, tag: string) => hasher.update(`<${tag}>`),\n sep: (hasher: Hash) => hasher.update('|'),\n end: (hasher: Hash, tag: string) => hasher.update(`</${tag}>`),\n str: (hasher: Hash, stringValue: string) => {\n // length prefix to avoid ambiguity: len#value\n hasher.update(`${stringValue.length}#`);\n hasher.update(stringValue);\n },\n num: (hasher: Hash, numberValue: number) =>\n hasher.update(\n Number.isNaN(numberValue)\n ? 'NaN'\n : numberValue === Infinity\n ? 'Inf'\n : numberValue === -Infinity\n ? '-Inf'\n : String(numberValue)\n ),\n big: (hasher: Hash, bigintValue: bigint) =>\n hasher.update(bigintValue.toString(10)),\n bool: (hasher: Hash, booleanValue: boolean) =>\n hasher.update(booleanValue ? '1' : '0'),\n};\n\n/** ------------------- Canonical, streaming hasher ------------------- **/\n\ntype Seen = WeakSet<object>;\n\n/**\n * Streams a canonical representation of `value` into `hasher` without\n * constructing large intermediate strings. Objects/Maps/Sets are normalized.\n */\nconst stableHashValue = (hasher: Hash, value: unknown, seen: Seen): void => {\n const valueType = typeof value;\n\n if (value === null) {\n token.start(hasher, 'null');\n token.end(hasher, 'null');\n return;\n }\n\n if (valueType === 'undefined') {\n token.start(hasher, 'undef');\n token.end(hasher, 'undef');\n return;\n }\n\n if (valueType === 'number') {\n token.start(hasher, 'num');\n token.num(hasher, value as number);\n token.end(hasher, 'num');\n return;\n }\n\n if (valueType === 'bigint') {\n token.start(hasher, 'big');\n token.big(hasher, value as bigint);\n token.end(hasher, 'big');\n return;\n }\n\n if (valueType === 'boolean') {\n token.start(hasher, 'bool');\n token.bool(hasher, value as boolean);\n token.end(hasher, 'bool');\n return;\n }\n\n if (valueType === 'string') {\n token.start(hasher, 'str');\n token.str(hasher, value as string);\n token.end(hasher, 'str');\n return;\n }\n\n if (valueType === 'symbol') {\n token.start(hasher, 'sym');\n token.str(hasher, String(value));\n token.end(hasher, 'sym');\n return;\n }\n\n if (valueType === 'function') {\n // Stable-ish fingerprint: name and arity (avoid source text).\n const functionValue = value as Function;\n token.start(hasher, 'fn');\n token.str(hasher, functionValue.name ?? '');\n token.sep(hasher);\n token.num(hasher, functionValue.length);\n token.end(hasher, 'fn');\n return;\n }\n\n // Arrays and typed arrays\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n token.start(hasher, 'arr');\n token.str(hasher, 'Circular');\n token.end(hasher, 'arr');\n return;\n }\n seen.add(value);\n token.start(hasher, 'arr');\n for (let i = 0; i < value.length; i++) {\n token.sep(hasher);\n stableHashValue(hasher, value[i], seen);\n }\n token.end(hasher, 'arr');\n seen.delete(value);\n return;\n }\n\n // Node/Builtins\n if (value instanceof Date) {\n token.start(hasher, 'date');\n token.str(hasher, (value as Date).toISOString());\n token.end(hasher, 'date');\n return;\n }\n\n if (value instanceof RegExp) {\n const regex = value as RegExp;\n token.start(hasher, 're');\n token.str(hasher, regex.source);\n token.sep(hasher);\n token.str(hasher, regex.flags);\n token.end(hasher, 're');\n return;\n }\n\n if (value instanceof Set) {\n const setValue = value as Set<unknown>;\n if (seen.has(setValue)) {\n token.start(hasher, 'set');\n token.str(hasher, 'Circular');\n token.end(hasher, 'set');\n return;\n }\n seen.add(setValue);\n // Normalize by item fingerprints (strings) to sort deterministically.\n const items: string[] = [];\n for (const v of setValue) items.push(stableStringify(v)); // small, bounded use of stringify\n items.sort();\n token.start(hasher, 'set');\n for (const item of items) {\n token.sep(hasher);\n token.str(hasher, item);\n }\n token.end(hasher, 'set');\n seen.delete(setValue);\n return;\n }\n\n if (value instanceof Map) {\n const mapObject = value as Map<unknown, unknown>;\n if (seen.has(mapObject)) {\n token.start(hasher, 'map');\n token.str(hasher, 'Circular');\n token.end(hasher, 'map');\n return;\n }\n seen.add(mapObject);\n // Normalize by sorted key fingerprints.\n const entries: Array<[string, unknown]> = [];\n for (const [k, v] of mapObject.entries())\n entries.push([stableStringify(k), v]);\n entries.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));\n token.start(hasher, 'map');\n for (const [keyFingerprint, entryValue] of entries) {\n token.sep(hasher);\n token.str(hasher, keyFingerprint);\n token.sep(hasher);\n stableHashValue(hasher, entryValue, seen);\n }\n token.end(hasher, 'map');\n seen.delete(mapObject);\n return;\n }\n\n // ArrayBuffer & typed arrays\n if (ArrayBuffer.isView(value)) {\n const view = value as ArrayBufferView;\n token.start(hasher, 'typed');\n token.str(hasher, Object.getPrototypeOf(view).constructor.name);\n token.sep(hasher);\n hasher.update(Buffer.from(view.buffer, view.byteOffset, view.byteLength));\n token.end(hasher, 'typed');\n return;\n }\n if (value instanceof ArrayBuffer) {\n const buffer = Buffer.from(value as ArrayBuffer);\n token.start(hasher, 'ab');\n hasher.update(buffer);\n token.end(hasher, 'ab');\n return;\n }\n\n // URL\n if (typeof URL !== 'undefined' && value instanceof URL) {\n token.start(hasher, 'url');\n token.str(hasher, (value as URL).toString());\n token.end(hasher, 'url');\n return;\n }\n\n // Errors\n if (value instanceof Error) {\n const errorValue = value as Error;\n token.start(hasher, 'err');\n token.str(hasher, errorValue.name || '');\n token.sep(hasher);\n token.str(hasher, errorValue.message || '');\n token.sep(hasher);\n token.str(hasher, errorValue.stack || '');\n token.end(hasher, 'err');\n return;\n }\n\n // Generic objects\n if (valueType === 'object') {\n const objectValue = value as Record<string, unknown>;\n if (seen.has(objectValue)) {\n token.start(hasher, 'obj');\n token.str(hasher, 'Circular');\n token.end(hasher, 'obj');\n return;\n }\n seen.add(objectValue);\n\n const keys = Object.keys(objectValue).sort();\n token.start(hasher, 'obj');\n for (const key of keys) {\n token.sep(hasher);\n token.str(hasher, key);\n token.sep(hasher);\n stableHashValue(hasher, (objectValue as any)[key], seen);\n }\n token.end(hasher, 'obj');\n\n seen.delete(objectValue);\n return;\n }\n\n // Fallback\n token.start(hasher, 'other');\n token.str(hasher, String(value));\n token.end(hasher, 'other');\n};\n\n/** Public stringify kept for convenience / debugging (now faster & broader). */\nexport const stableStringify = (\n value: unknown,\n _stack = new WeakSet<object>()\n): string => {\n const hasher = createHash(HASH_ALGORITHM);\n stableHashValue(hasher, value, _stack);\n return toBase64Url(hasher.digest());\n};\n\n/** Compute a compact, stable id for arbitrary key tuples. */\nexport const computeKeyId = (keyParts: unknown[]): string => {\n const h = createHash(HASH_ALGORITHM);\n token.start(h, 'keys');\n for (let i = 0; i < keyParts.length; i++) {\n token.sep(h);\n stableHashValue(h, keyParts[i], new WeakSet());\n }\n token.end(h, 'keys');\n return toBase64Url(h.digest());\n};\n\n/** ------------------------- In-memory cache ------------------------- **/\n\nexport type CacheKey = unknown;\nconst cacheMap = new Map<string, any>();\n\nexport const getCache = <T>(...key: CacheKey[]): T | undefined => {\n return cacheMap.get(computeKeyId(key));\n};\n\ntype CacheSetArgs<T> = [...keys: CacheKey[], value: T];\n\nexport const setCache = <T>(...args: CacheSetArgs<T>): void => {\n const value = args[args.length - 1] as T;\n const key = args.slice(0, -1) as CacheKey[];\n cacheMap.set(computeKeyId(key), value);\n};\n\nexport const clearCache = (idOrKey: string): void => {\n // Accept either our computed id or a legacy string id the caller already computed.\n cacheMap.delete(idOrKey);\n};\n\nexport const clearAllCache = (): void => {\n cacheMap.clear();\n};\n\nexport const cacheMemory = {\n get: getCache,\n set: setCache,\n clear: clearCache,\n};\n"],"mappings":";;;;;AAKA,MAAM,0BAAkC;AACtC,KAAI;AAEF,aAAW,WAAW,CAAC,OAAO,OAAO,CAAC,QAAQ;AAC9C,SAAO;SACD;AACR,KAAI;AAEF,aAAW,OAAO,CAAC,OAAO,OAAO,CAAC,QAAQ;AAC1C,SAAO;SACD;AAER,QAAO;;AAET,MAAM,iBAAiB,mBAAmB;;AAG1C,MAAM,eAAe,WACnB,OACG,SAAS,SAAS,CAClB,QAAQ,OAAO,IAAI,C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n\n/** ------------------------- Utilities ------------------------- **/\n\n/** Prefer a fast non-crypto hash if available, then fast crypto, then sha256. */\nconst pickHashAlgorithm = (): string => {\n try {\n // Node 20+ supports xxhash64 (very fast). We feature-detect at module load.\n createHash('xxhash64').update('test').digest();\n return 'xxhash64';\n } catch {}\n try {\n // sha1 is faster than sha256 and sufficient for cache keys.\n createHash('sha1').update('test').digest();\n return 'sha1';\n } catch {}\n\n return 'sha256';\n};\nconst HASH_ALGORITHM = pickHashAlgorithm();\n\n/** Base64url without padding for compact, file-system-safe ids. */\nconst toBase64Url = (buffer: Buffer): string =>\n buffer\n .toString('base64')\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/g, '');\n\n/** Token helpers to minimize collisions while streaming to the hasher. */\nconst token = {\n start: (hasher: Hash, tag: string) => hasher.update(`<${tag}>`),\n sep: (hasher: Hash) => hasher.update('|'),\n end: (hasher: Hash, tag: string) => hasher.update(`</${tag}>`),\n str: (hasher: Hash, stringValue: string) => {\n // length prefix to avoid ambiguity: len#value\n hasher.update(`${stringValue.length}#`);\n hasher.update(stringValue);\n },\n num: (hasher: Hash, numberValue: number) =>\n hasher.update(\n Number.isNaN(numberValue)\n ? 'NaN'\n : numberValue === Infinity\n ? 'Inf'\n : numberValue === -Infinity\n ? '-Inf'\n : String(numberValue)\n ),\n big: (hasher: Hash, bigintValue: bigint) =>\n hasher.update(bigintValue.toString(10)),\n bool: (hasher: Hash, booleanValue: boolean) =>\n hasher.update(booleanValue ? '1' : '0'),\n};\n\n/** ------------------- Canonical, streaming hasher ------------------- **/\n\ntype Seen = WeakSet<object>;\n\n/**\n * Streams a canonical representation of `value` into `hasher` without\n * constructing large intermediate strings. Objects/Maps/Sets are normalized.\n */\nconst stableHashValue = (hasher: Hash, value: unknown, seen: Seen): void => {\n const valueType = typeof value;\n\n if (value === null) {\n token.start(hasher, 'null');\n token.end(hasher, 'null');\n return;\n }\n\n if (valueType === 'undefined') {\n token.start(hasher, 'undef');\n token.end(hasher, 'undef');\n return;\n }\n\n if (valueType === 'number') {\n token.start(hasher, 'num');\n token.num(hasher, value as number);\n token.end(hasher, 'num');\n return;\n }\n\n if (valueType === 'bigint') {\n token.start(hasher, 'big');\n token.big(hasher, value as bigint);\n token.end(hasher, 'big');\n return;\n }\n\n if (valueType === 'boolean') {\n token.start(hasher, 'bool');\n token.bool(hasher, value as boolean);\n token.end(hasher, 'bool');\n return;\n }\n\n if (valueType === 'string') {\n token.start(hasher, 'str');\n token.str(hasher, value as string);\n token.end(hasher, 'str');\n return;\n }\n\n if (valueType === 'symbol') {\n token.start(hasher, 'sym');\n token.str(hasher, String(value));\n token.end(hasher, 'sym');\n return;\n }\n\n if (valueType === 'function') {\n // Stable-ish fingerprint: name and arity (avoid source text).\n const functionValue = value as Function;\n token.start(hasher, 'fn');\n token.str(hasher, functionValue.name ?? '');\n token.sep(hasher);\n token.num(hasher, functionValue.length);\n token.end(hasher, 'fn');\n return;\n }\n\n // Arrays and typed arrays\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n token.start(hasher, 'arr');\n token.str(hasher, 'Circular');\n token.end(hasher, 'arr');\n return;\n }\n seen.add(value);\n token.start(hasher, 'arr');\n for (let i = 0; i < value.length; i++) {\n token.sep(hasher);\n stableHashValue(hasher, value[i], seen);\n }\n token.end(hasher, 'arr');\n seen.delete(value);\n return;\n }\n\n // Node/Builtins\n if (value instanceof Date) {\n token.start(hasher, 'date');\n token.str(hasher, (value as Date).toISOString());\n token.end(hasher, 'date');\n return;\n }\n\n if (value instanceof RegExp) {\n const regex = value as RegExp;\n token.start(hasher, 're');\n token.str(hasher, regex.source);\n token.sep(hasher);\n token.str(hasher, regex.flags);\n token.end(hasher, 're');\n return;\n }\n\n if (value instanceof Set) {\n const setValue = value as Set<unknown>;\n if (seen.has(setValue)) {\n token.start(hasher, 'set');\n token.str(hasher, 'Circular');\n token.end(hasher, 'set');\n return;\n }\n seen.add(setValue);\n // Normalize by item fingerprints (strings) to sort deterministically.\n const items: string[] = [];\n for (const v of setValue) items.push(stableStringify(v)); // small, bounded use of stringify\n items.sort();\n token.start(hasher, 'set');\n for (const item of items) {\n token.sep(hasher);\n token.str(hasher, item);\n }\n token.end(hasher, 'set');\n seen.delete(setValue);\n return;\n }\n\n if (value instanceof Map) {\n const mapObject = value as Map<unknown, unknown>;\n if (seen.has(mapObject)) {\n token.start(hasher, 'map');\n token.str(hasher, 'Circular');\n token.end(hasher, 'map');\n return;\n }\n seen.add(mapObject);\n // Normalize by sorted key fingerprints.\n const entries: Array<[string, unknown]> = [];\n for (const [k, v] of mapObject.entries())\n entries.push([stableStringify(k), v]);\n entries.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));\n token.start(hasher, 'map');\n for (const [keyFingerprint, entryValue] of entries) {\n token.sep(hasher);\n token.str(hasher, keyFingerprint);\n token.sep(hasher);\n stableHashValue(hasher, entryValue, seen);\n }\n token.end(hasher, 'map');\n seen.delete(mapObject);\n return;\n }\n\n // ArrayBuffer & typed arrays\n if (ArrayBuffer.isView(value)) {\n const view = value as ArrayBufferView;\n token.start(hasher, 'typed');\n token.str(hasher, Object.getPrototypeOf(view).constructor.name);\n token.sep(hasher);\n hasher.update(Buffer.from(view.buffer, view.byteOffset, view.byteLength));\n token.end(hasher, 'typed');\n return;\n }\n if (value instanceof ArrayBuffer) {\n const buffer = Buffer.from(value as ArrayBuffer);\n token.start(hasher, 'ab');\n hasher.update(buffer);\n token.end(hasher, 'ab');\n return;\n }\n\n // URL\n if (typeof URL !== 'undefined' && value instanceof URL) {\n token.start(hasher, 'url');\n token.str(hasher, (value as URL).toString());\n token.end(hasher, 'url');\n return;\n }\n\n // Errors\n if (value instanceof Error) {\n const errorValue = value as Error;\n token.start(hasher, 'err');\n token.str(hasher, errorValue.name || '');\n token.sep(hasher);\n token.str(hasher, errorValue.message || '');\n token.sep(hasher);\n token.str(hasher, errorValue.stack || '');\n token.end(hasher, 'err');\n return;\n }\n\n // Generic objects\n if (valueType === 'object') {\n const objectValue = value as Record<string, unknown>;\n if (seen.has(objectValue)) {\n token.start(hasher, 'obj');\n token.str(hasher, 'Circular');\n token.end(hasher, 'obj');\n return;\n }\n seen.add(objectValue);\n\n const keys = Object.keys(objectValue).sort();\n token.start(hasher, 'obj');\n for (const key of keys) {\n token.sep(hasher);\n token.str(hasher, key);\n token.sep(hasher);\n stableHashValue(hasher, (objectValue as any)[key], seen);\n }\n token.end(hasher, 'obj');\n\n seen.delete(objectValue);\n return;\n }\n\n // Fallback\n token.start(hasher, 'other');\n token.str(hasher, String(value));\n token.end(hasher, 'other');\n};\n\n/** Public stringify kept for convenience / debugging (now faster & broader). */\nexport const stableStringify = (\n value: unknown,\n _stack = new WeakSet<object>()\n): string => {\n const hasher = createHash(HASH_ALGORITHM);\n stableHashValue(hasher, value, _stack);\n return toBase64Url(hasher.digest());\n};\n\n/** Compute a compact, stable id for arbitrary key tuples. */\nexport const computeKeyId = (keyParts: unknown[]): string => {\n const h = createHash(HASH_ALGORITHM);\n token.start(h, 'keys');\n for (let i = 0; i < keyParts.length; i++) {\n token.sep(h);\n stableHashValue(h, keyParts[i], new WeakSet());\n }\n token.end(h, 'keys');\n return toBase64Url(h.digest());\n};\n\n/** ------------------------- In-memory cache ------------------------- **/\n\nexport type CacheKey = unknown;\nconst cacheMap = new Map<string, any>();\n\nexport const getCache = <T>(...key: CacheKey[]): T | undefined => {\n return cacheMap.get(computeKeyId(key));\n};\n\ntype CacheSetArgs<T> = [...keys: CacheKey[], value: T];\n\nexport const setCache = <T>(...args: CacheSetArgs<T>): void => {\n const value = args[args.length - 1] as T;\n const key = args.slice(0, -1) as CacheKey[];\n cacheMap.set(computeKeyId(key), value);\n};\n\nexport const clearCache = (idOrKey: string): void => {\n // Accept either our computed id or a legacy string id the caller already computed.\n cacheMap.delete(idOrKey);\n};\n\nexport const clearAllCache = (): void => {\n cacheMap.clear();\n};\n\nexport const cacheMemory = {\n get: getCache,\n set: setCache,\n clear: clearCache,\n};\n"],"mapp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AmC;CAChE,OAAO,SAAS,IAAI,aAAa,GAAG,CAAC;AACvC;AAIA,MAAa,YAAe,GAAG,SAAgC;CAC7D,MAAM,QAAQ,KAAK,KAAK,SAAS;CACjC,MAAM,MAAM,KAAK,MAAM,GAAG,EAAE;CAC5B,SAAS,IAAI,aAAa,GAAG,GAAG,KAAK;AACvC;AAEA,MAAa,cAAc,YAA0B;CAEnD,SAAS,OAAO,OAAO;AACzB;AAEA,MAAa,sBAA4B;CACvC,SAAS,MAAM;AACjB;AAEA,MAAa,cAAc;CACzB,KAAK;CACL,KAAK;CACL,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"clearModuleCache.mjs","names":[],"sources":["../../../src/utils/clearModuleCache.ts"],"sourcesContent":["import { configESMxCJSRequire } from './ESMxCJSHelpers';\n\n/**\n * Recursively clears the require cache for a module and all its dependencies\n */\nexport const clearModuleCache = (\n modulePath: string,\n visited = new Set<string>()\n) => {\n // Avoid infinite loops\n if (visited.has(modulePath)) {\n return;\n }\n visited.add(modulePath);\n\n try {\n const resolvedPath = configESMxCJSRequire.resolve(modulePath);\n\n // Get the cached module\n const cachedModule = configESMxCJSRequire.cache[resolvedPath];\n\n if (cachedModule) {\n // Clear cache for all children (dependencies) first\n if (cachedModule.children) {\n cachedModule.children.forEach((child) => {\n clearModuleCache(child.filename, visited);\n });\n }\n\n // Clear the cache for this module\n delete configESMxCJSRequire.cache[resolvedPath];\n }\n } catch (error) {\n // Module might not exist or be resolvable, skip it\n console.warn(`Could not clear cache for module: ${modulePath}`, error);\n }\n};\n"],"mappings":";;;;;;AAKA,MAAa,oBACX,YACA,0BAAU,IAAI,KAAa,KACxB;AAEH,KAAI,QAAQ,IAAI,WAAW,CACzB;AAEF,SAAQ,IAAI,WAAW;AAEvB,KAAI;EACF,MAAM,eAAe,qBAAqB,QAAQ,WAAW;EAG7D,MAAM,eAAe,qBAAqB,MAAM;AAEhD,MAAI,cAAc;AAEhB,OAAI,aAAa,SACf,cAAa,SAAS,SAAS,UAAU;AACvC,qBAAiB,MAAM,UAAU,QAAQ;KACzC;AAIJ,UAAO,qBAAqB,MAAM;;UAE7B,OAAO;AAEd,UAAQ,KAAK,qCAAqC,cAAc,MAAM"}
1
+ {"version":3,"file":"clearModuleCache.mjs","names":[],"sources":["../../../src/utils/clearModuleCache.ts"],"sourcesContent":["import { configESMxCJSRequire } from './ESMxCJSHelpers';\n\n/**\n * Recursively clears the require cache for a module and all its dependencies\n */\nexport const clearModuleCache = (\n modulePath: string,\n visited = new Set<string>()\n) => {\n // Avoid infinite loops\n if (visited.has(modulePath)) {\n return;\n }\n visited.add(modulePath);\n\n try {\n const resolvedPath = configESMxCJSRequire.resolve(modulePath);\n\n // Get the cached module\n const cachedModule = configESMxCJSRequire.cache[resolvedPath];\n\n if (cachedModule) {\n // Clear cache for all children (dependencies) first\n if (cachedModule.children) {\n cachedModule.children.forEach((child) => {\n clearModuleCache(child.filename, visited);\n });\n }\n\n // Clear the cache for this module\n delete configESMxCJSRequire.cache[resolvedPath];\n }\n } catch (error) {\n // Module might not exist or be resolvable, skip it\n console.warn(`Could not clear cache for module: ${modulePath}`, error);\n }\n};\n"],"mappings":";;;;;;AAKA,MAAa,oBACX,YACA,0BAAU,IAAI,IAAY,MACvB;CAEH,IAAI,QAAQ,IAAI,UAAU,GACxB;CAEF,QAAQ,IAAI,UAAU;CAEtB,IAAI;EACF,MAAM,eAAe,qBAAqB,QAAQ,UAAU;EAG5D,MAAM,eAAe,qBAAqB,MAAM;EAEhD,IAAI,cAAc;GAEhB,IAAI,aAAa,UACf,aAAa,SAAS,SAAS,UAAU;IACvC,iBAAiB,MAAM,UAAU,OAAO;GAC1C,CAAC;GAIH,OAAO,qBAAqB,MAAM;EACpC;CACF,SAAS,OAAO;EAEd,QAAQ,KAAK,qCAAqC,cAAc,KAAK;CACvE;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"compareVersions.mjs","names":[],"sources":["../../../src/utils/compareVersions.ts"],"sourcesContent":["/**\n * Compare two semver-like version strings (e.g. \"15.10.4\" vs \"15.3.5\").\n *\n * @param version1 - first version string\n * @param version2 - second version string\n * @param comparison - type of comparison: 'gt', 'lt', 'eq', 'gte', 'lte'\n * @returns boolean indicating if version1 meets the specified comparison condition vs version2\n */\nexport const compareVersions = (\n version1: string,\n comparison: '>' | '<' | '=' | '≥' | '≤',\n version2: string\n): boolean => {\n const v1Parts = version1.split('.').map(Number);\n const v2Parts = version2.split('.').map(Number);\n const maxLen = Math.max(v1Parts.length, v2Parts.length);\n\n // Compute a basic -1, 0, or 1 comparison\n let result = 0;\n for (let i = 0; i < maxLen; i++) {\n const part1 = v1Parts[i] || 0;\n const part2 = v2Parts[i] || 0;\n if (part1 > part2) {\n result = 1;\n break;\n } else if (part1 < part2) {\n result = -1;\n break;\n }\n }\n\n switch (comparison) {\n case '>':\n return result === 1;\n case '<':\n return result === -1;\n case '=':\n return result === 0;\n case '≥':\n return result === 0 || result === 1;\n case '≤':\n return result === 0 || result === -1;\n }\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,mBACX,UACA,YACA,aACY;CACZ,MAAM,UAAU,SAAS,MAAM,IAAI,CAAC,IAAI,OAAO;CAC/C,MAAM,UAAU,SAAS,MAAM,IAAI,CAAC,IAAI,OAAO;CAC/C,MAAM,SAAS,KAAK,IAAI,QAAQ,QAAQ,QAAQ,OAAO;CAGvD,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,KAAK;EAC/B,MAAM,QAAQ,QAAQ,MAAM;EAC5B,MAAM,QAAQ,QAAQ,MAAM;AAC5B,MAAI,QAAQ,OAAO;AACjB,YAAS;AACT;aACS,QAAQ,OAAO;AACxB,YAAS;AACT;;;AAIJ,SAAQ,YAAR;EACE,KAAK,IACH,QAAO,WAAW;EACpB,KAAK,IACH,QAAO,WAAW;EACpB,KAAK,IACH,QAAO,WAAW;EACpB,KAAK,IACH,QAAO,WAAW,KAAK,WAAW;EACpC,KAAK,IACH,QAAO,WAAW,KAAK,WAAW"}
1
+ {"version":3,"file":"compareVersions.mjs","names":[],"sources":["../../../src/utils/compareVersions.ts"],"sourcesContent":["/**\n * Compare two semver-like version strings (e.g. \"15.10.4\" vs \"15.3.5\").\n *\n * @param version1 - first version string\n * @param version2 - second version string\n * @param comparison - type of comparison: 'gt', 'lt', 'eq', 'gte', 'lte'\n * @returns boolean indicating if version1 meets the specified comparison condition vs version2\n */\nexport const compareVersions = (\n version1: string,\n comparison: '>' | '<' | '=' | '≥' | '≤',\n version2: string\n): boolean => {\n const v1Parts = version1.split('.').map(Number);\n const v2Parts = version2.split('.').map(Number);\n const maxLen = Math.max(v1Parts.length, v2Parts.length);\n\n // Compute a basic -1, 0, or 1 comparison\n let result = 0;\n for (let i = 0; i < maxLen; i++) {\n const part1 = v1Parts[i] || 0;\n const part2 = v2Parts[i] || 0;\n if (part1 > part2) {\n result = 1;\n break;\n } else if (part1 < part2) {\n result = -1;\n break;\n }\n }\n\n switch (comparison) {\n case '>':\n return result === 1;\n case '<':\n return result === -1;\n case '=':\n return result === 0;\n case '≥':\n return result === 0 || result === 1;\n case '≤':\n return result === 0 || result === -1;\n }\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,mBACX,UACA,YACA,aACY;CACZ,MAAM,UAAU,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CAC9C,MAAM,UAAU,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CAC9C,MAAM,SAAS,KAAK,IAAI,QAAQ,QAAQ,QAAQ,MAAM;CAGtD,IAAI,SAAS;CACb,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,KAAK;EAC/B,MAAM,QAAQ,QAAQ,MAAM;EAC5B,MAAM,QAAQ,QAAQ,MAAM;EAC5B,IAAI,QAAQ,OAAO;GACjB,SAAS;GACT;EACF,OAAO,IAAI,QAAQ,OAAO;GACxB,SAAS;GACT;EACF;CACF;CAEA,QAAQ,YAAR;EACE,KAAK,KACH,OAAO,WAAW;EACpB,KAAK,KACH,OAAO,WAAW;EACpB,KAAK,KACH,OAAO,WAAW;EACpB,KAAK,KACH,OAAO,WAAW,KAAK,WAAW;EACpC,KAAK,KACH,OAAO,WAAW,KAAK,WAAW;CACtC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"extractErrorMessage.mjs","names":[],"sources":["../../../src/utils/extractErrorMessage.ts"],"sourcesContent":["export const extractErrorMessage = (error: unknown): string => {\n const trimToSingleLine = (text: string): string =>\n text\n .split(/\\r?\\n/)\n .map((stringValue) => stringValue.trim())\n .filter(Boolean)[0] ?? text.trim();\n\n const looksLikeJson = (value: string): boolean => {\n const stringValue = value.trim();\n\n if (!stringValue) return false;\n const first = stringValue[0];\n return first === '{' || first === '[' || first === '\"';\n };\n\n const sanitizeUnexpectedTokenMessage = (text: string): string => {\n // If the text mentions an invalid JSON parse, try to extract the meaningful part\n const t = text.trim();\n\n if (/Unexpected token/i.test(t) && /not valid JSON/i.test(t)) {\n const quoted = t.match(/\"([^\"]+)\"/);\n\n if (quoted?.[1]) return quoted[1];\n // Fallback: drop the leading parser error description\n const afterColon = t.split(':').slice(1).join(':').trim();\n\n if (afterColon) return afterColon;\n }\n return t;\n };\n\n const pickFieldsFromObject = (\n value: unknown,\n seen: Set<unknown>\n ): string | undefined => {\n if (!value || typeof value !== 'object') return undefined;\n\n if (seen.has(value)) return undefined;\n\n seen.add(value);\n\n // If the value itself is an array (e.g. ZodError.issues), iterate its items\n\n if (Array.isArray(value)) {\n for (const item of value) {\n const fromItem = pickFieldsFromObject(item, seen);\n\n if (fromItem) return fromItem;\n\n if (typeof (item as any)?.message === 'string')\n return (item as any).message;\n }\n return undefined;\n }\n\n const obj = value as Record<string, unknown>;\n\n // Check for message first (highest priority)\n\n if (typeof obj.message === 'string' && obj.message.trim()) {\n return obj.message;\n }\n\n // Check for error_description\n\n if (\n typeof obj.error_description === 'string' &&\n obj.error_description.trim()\n ) {\n return obj.error_description;\n }\n\n // Check for error\n\n if (typeof obj.error === 'string' && obj.error.trim()) {\n return obj.error;\n }\n\n // Handle title and code combination\n const title = typeof obj.title === 'string' ? obj.title.trim() : '';\n const code = typeof obj.code === 'string' ? obj.code.trim() : '';\n\n if (title && code) {\n return `${title} (${code})`;\n }\n\n if (title) {\n return title;\n }\n\n if (code) {\n return code;\n }\n\n // Check for statusText\n\n if (typeof obj.statusText === 'string' && obj.statusText.trim()) {\n return obj.statusText;\n }\n\n // Common nested structures (Axios/Fetch-like)\n const response = obj.response as Record<string, unknown> | undefined;\n\n if (response && typeof response === 'object') {\n const data = response.data as unknown;\n const fromData = pickFieldsFromObject(data, seen);\n\n if (fromData) return fromData;\n }\n\n const data = obj.data as unknown;\n const fromData = pickFieldsFromObject(data, seen);\n\n if (fromData) return fromData;\n\n // Nested cause chain\n const cause = (obj as { cause?: unknown }).cause;\n const fromCause =\n pickFieldsFromObject(cause, seen) ??\n (typeof (cause as any)?.message === 'string'\n ? (cause as any).message\n : undefined);\n\n if (fromCause) return fromCause;\n\n // Arrays of errors\n const errors = obj.errors as unknown;\n\n if (Array.isArray(errors)) {\n for (const item of errors) {\n const fromItem = pickFieldsFromObject(item, seen);\n\n if (fromItem) return fromItem;\n\n if (typeof (item as any)?.message === 'string')\n return (item as any).message;\n }\n }\n\n return undefined;\n };\n\n const tryParseJsonString = (maybeJson: string): string | undefined => {\n if (!looksLikeJson(maybeJson)) return undefined;\n try {\n const parsed = JSON.parse(maybeJson);\n const picked = pickFieldsFromObject(parsed, new Set());\n\n if (picked) return picked;\n\n if (typeof parsed === 'string') return parsed;\n return undefined;\n } catch {\n return undefined;\n }\n };\n\n if (typeof error === 'string') {\n const cleaned = sanitizeUnexpectedTokenMessage(error);\n return tryParseJsonString(cleaned) ?? trimToSingleLine(cleaned);\n }\n\n if (error && typeof error === 'object') {\n // Native Error instance\n\n if (error instanceof Error) {\n const cleaned = sanitizeUnexpectedTokenMessage(error.message);\n const fromMessage = tryParseJsonString(cleaned);\n\n if (fromMessage) return trimToSingleLine(fromMessage);\n // Dive into cause when present\n const fromCause = extractErrorMessage(error.cause as unknown);\n\n if (fromCause && fromCause !== 'An unknown error occurred')\n return trimToSingleLine(fromCause);\n return trimToSingleLine(cleaned);\n }\n\n // Generic object\n const seen = new Set<unknown>();\n const fromObject = pickFieldsFromObject(error, seen);\n\n if (fromObject) {\n const cleaned = sanitizeUnexpectedTokenMessage(fromObject);\n return tryParseJsonString(cleaned) ?? trimToSingleLine(cleaned);\n }\n\n try {\n const serialized = JSON.stringify(error);\n return trimToSingleLine(serialized);\n } catch {\n return trimToSingleLine(String(error));\n }\n }\n\n return 'An unknown error occurred';\n};\n"],"mappings":";AAAA,MAAa,uBAAuB,UAA2B;CAC7D,MAAM,oBAAoB,SACxB,KACG,MAAM,QAAQ,CACd,KAAK,gBAAgB,YAAY,MAAM,CAAC,CACxC,OAAO,QAAQ,CAAC,MAAM,KAAK,MAAM;CAEtC,MAAM,iBAAiB,UAA2B;EAChD,MAAM,cAAc,MAAM,MAAM;AAEhC,MAAI,CAAC,YAAa,QAAO;EACzB,MAAM,QAAQ,YAAY;AAC1B,SAAO,UAAU,OAAO,UAAU,OAAO,UAAU;;CAGrD,MAAM,kCAAkC,SAAyB;EAE/D,MAAM,IAAI,KAAK,MAAM;AAErB,MAAI,oBAAoB,KAAK,EAAE,IAAI,kBAAkB,KAAK,EAAE,EAAE;GAC5D,MAAM,SAAS,EAAE,MAAM,YAAY;AAEnC,OAAI,SAAS,GAAI,QAAO,OAAO;GAE/B,MAAM,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC,MAAM;AAEzD,OAAI,WAAY,QAAO;;AAEzB,SAAO;;CAGT,MAAM,wBACJ,OACA,SACuB;AACvB,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAEhD,MAAI,KAAK,IAAI,MAAM,CAAE,QAAO;AAE5B,OAAK,IAAI,MAAM;AAIf,MAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,QAAK,MAAM,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,MAAc,YAAY,SACpC,QAAQ,KAAa;;;CAO7B,MAAM,sBAAsB,cAA0C;AACpE,MAAI,CAAC,cAAc,UAAU,CAAE,QAAO;AACtC,MAAI;GACF,MAAM,SAAS,KAAK,MAAM,UAAU;GACpC,MAAM,SAAS,qBAAqB,wBAAQ,IAAI,KAAK,CAAC;AAEtD,OAAI,OAAQ,QAAO;AAEnB,OAAI,OAAO,WAAW,SAAU,QAAO;AACvC;UACM;AACN;;;AAIJ,KAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,UAAU,+BAA+B,MAAM;AACrD,SAAO,mBAAmB,QAAQ,IAAI,iBAAiB,QAAQ;;AAGjE,KAAI,SAAS,OAAO,UAAU,UAAU;AAGtC,MAAI,iBAAiB,OAAO;GAC1B,MAAM,UAAU,+BAA+B,MAAM,QAAQ;GAC7D,MAAM,cAAc,mBAAmB,QAAQ;AAE/C,OAAI,YAAa,QAAO,iBAAiB,YAAY;GAErD,MAAM,YAAY,oBAAoB,MAAM,MAAiB;AAE7D,OAAI,aAAa,cAAc,4BAC7B,QAAO,iBAAiB,UAAU;AACpC,UAAO,iBAAiB,QAAQ;;EAKlC,MAAM,aAAa,qBAAqB,uBAAO,IAD9B,KACkC,CAAC;AAEpD,MAAI,YAAY;GACd,MAAM,UAAU,+BAA+B,WAAW;AAC1D,UAAO,mBAAmB,QAAQ,IAAI,iBAAiB,QAAQ;;AAGjE,MAAI;AAEF,UAAO,iBADY,KAAK,UAAU,MACA,CAAC;UAC7B;AACN,UAAO,iBAAiB,OAAO,MAAM,CAAC;;;AAI1C,QAAO"}
1
+ {"version":3,"file":"extractErrorMessage.mjs","names":[],"sources":["../../../src/utils/extractErrorMessage.ts"],"sourcesContent":["export const extractErrorMessage = (error: unknown): string => {\n const trimToSingleLine = (text: string): string =>\n text\n .split(/\\r?\\n/)\n .map((stringValue) => stringValue.trim())\n .filter(Boolean)[0] ?? text.trim();\n\n const looksLikeJson = (value: string): boolean => {\n const stringValue = value.trim();\n\n if (!stringValue) return false;\n const first = stringValue[0];\n return first === '{' || first === '[' || first === '\"';\n };\n\n const sanitizeUnexpectedTokenMessage = (text: string): string => {\n // If the text mentions an invalid JSON parse, try to extract the meaningful part\n const t = text.trim();\n\n if (/Unexpected token/i.test(t) && /not valid JSON/i.test(t)) {\n const quoted = t.match(/\"([^\"]+)\"/);\n\n if (quoted?.[1]) return quoted[1];\n // Fallback: drop the leading parser error description\n const afterColon = t.split(':').slice(1).join(':').trim();\n\n if (afterColon) return afterColon;\n }\n return t;\n };\n\n const pickFieldsFromObject = (\n value: unknown,\n seen: Set<unknown>\n ): string | undefined => {\n if (!value || typeof value !== 'object') return undefined;\n\n if (seen.has(value)) return undefined;\n\n seen.add(value);\n\n // If the value itself is an array (e.g. ZodError.issues), iterate its items\n\n if (Array.isArray(value)) {\n for (const item of value) {\n const fromItem = pickFieldsFromObject(item, seen);\n\n if (fromItem) return fromItem;\n\n if (typeof (item as any)?.message === 'string')\n return (item as any).message;\n }\n return undefined;\n }\n\n const obj = value as Record<string, unknown>;\n\n // Check for message first (highest priority)\n\n if (typeof obj.message === 'string' && obj.message.trim()) {\n return obj.message;\n }\n\n // Check for error_description\n\n if (\n typeof obj.error_description === 'string' &&\n obj.error_description.trim()\n ) {\n return obj.error_description;\n }\n\n // Check for error\n\n if (typeof obj.error === 'string' && obj.error.trim()) {\n return obj.error;\n }\n\n // Handle title and code combination\n const title = typeof obj.title === 'string' ? obj.title.trim() : '';\n const code = typeof obj.code === 'string' ? obj.code.trim() : '';\n\n if (title && code) {\n return `${title} (${code})`;\n }\n\n if (title) {\n return title;\n }\n\n if (code) {\n return code;\n }\n\n // Check for statusText\n\n if (typeof obj.statusText === 'string' && obj.statusText.trim()) {\n return obj.statusText;\n }\n\n // Common nested structures (Axios/Fetch-like)\n const response = obj.response as Record<string, unknown> | undefined;\n\n if (response && typeof response === 'object') {\n const data = response.data as unknown;\n const fromData = pickFieldsFromObject(data, seen);\n\n if (fromData) return fromData;\n }\n\n const data = obj.data as unknown;\n const fromData = pickFieldsFromObject(data, seen);\n\n if (fromData) return fromData;\n\n // Nested cause chain\n const cause = (obj as { cause?: unknown }).cause;\n const fromCause =\n pickFieldsFromObject(cause, seen) ??\n (typeof (cause as any)?.message === 'string'\n ? (cause as any).message\n : undefined);\n\n if (fromCause) return fromCause;\n\n // Arrays of errors\n const errors = obj.errors as unknown;\n\n if (Array.isArray(errors)) {\n for (const item of errors) {\n const fromItem = pickFieldsFromObject(item, seen);\n\n if (fromItem) return fromItem;\n\n if (typeof (item as any)?.message === 'string')\n return (item as any).message;\n }\n }\n\n return undefined;\n };\n\n const tryParseJsonString = (maybeJson: string): string | undefined => {\n if (!looksLikeJson(maybeJson)) return undefined;\n try {\n const parsed = JSON.parse(maybeJson);\n const picked = pickFieldsFromObject(parsed, new Set());\n\n if (picked) return picked;\n\n if (typeof parsed === 'string') return parsed;\n return undefined;\n } catch {\n return undefined;\n }\n };\n\n if (typeof error === 'string') {\n const cleaned = sanitizeUnexpectedTokenMessage(error);\n return tryParseJsonString(cleaned) ?? trimToSingleLine(cleaned);\n }\n\n if (error && typeof error === 'object') {\n // Native Error instance\n\n if (error instanceof Error) {\n const cleaned = sanitizeUnexpectedTokenMessage(error.message);\n const fromMessage = tryParseJsonString(cleaned);\n\n if (fromMessage) return trimToSingleLine(fromMessage);\n // Dive into cause when present\n const fromCause = extractErrorMessage(error.cause as unknown);\n\n if (fromCause && fromCause !== 'An unknown error occurred')\n return trimToSingleLine(fromCause);\n return trimToSingleLine(cleaned);\n }\n\n // Generic object\n const seen = new Set<unknown>();\n const fromObject = pickFieldsFromObject(error, seen);\n\n if (fromObject) {\n const cleaned = sanitizeUnexpectedTokenMessage(fromObject);\n return tryParseJsonString(cleaned) ?? trimToSingleLine(cleaned);\n }\n\n try {\n const serialized = JSON.stringify(error);\n return trimToSingleLine(serialized);\n } catch {\n return trimToSingleLine(String(error));\n }\n }\n\n return 'An unknown error occurred';\n};\n"],"mappings":";AAAA,MAAa,uBAAuB,UAA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A+B,KAAK;EACpD,OAAO,mBAAmB,OAAO,KAAK,iBAAiB,OAAO;CAChE;CAEA,IAAI,SAAS,OAAO,UAAU,UAAU;EAGtC,IAAI,iBAAiB,OAAO;GAC1B,MAAM,UAAU,+BAA+B,MAAM,OAAO;GAC5D,MAAM,cAAc,mBAAmB,OAAO;GAE9C,IAAI,aAAa,OAAO,iBAAiB,WAAW;GAEpD,MAAM,YAAY,oBAAoB,MAAM,KAAgB;GAE5D,IAAI,aAAa,cAAc,6BAC7B,OAAO,iBAAiB,SAAS;GACnC,OAAO,iBAAiB,OAAO;EACjC;EAIA,MAAM,aAAa,qBAAqB,uBAAO,IAD9B,IACiC,CAAC;EAEnD,IAAI,YAAY;GACd,MAAM,UAAU,+BAA+B,UAAU;GACzD,OAAO,mBAAmB,OAAO,KAAK,iBAAiB,OAAO;EAChE;EAEA,IAAI;GAEF,OAAO,iBADY,KAAK,UAAU,KACD,CAAC;EACpC,QAAQ;GACN,OAAO,iBAAiB,OAAO,KAAK,CAAC;EACvC;CACF;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionarySelectorUsage.mjs","names":[],"sources":["../../../src/utils/getDictionarySelectorUsage.ts"],"sourcesContent":["import type {\n Dictionary,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\n\ntype DictionaryOrGroup = Dictionary | QualifiedDictionaryGroup;\n\n/**\n * Detects whether any built dictionary declares qualifier dimensions\n * (collections or variants).\n *\n * The merge step emits a {@link QualifiedDictionaryGroup} — carrying a\n * non-empty `qualifierTypes` array — for every key whose declarations use a\n * selector. When no group is present, the selector-object resolution path in\n * `getIntlayer` / `useIntlayer` is dead code, and bundlers can eliminate it via\n * the `INTLAYER_DICTIONARY_SELECTOR` env var.\n *\n * @example\n * getHasDictionarySelector(getDictionaries(config));\n * // true → at least one collection / variant / meta dictionary\n * // false → only plain dictionaries (selector logic can be stripped)\n */\nexport const getHasDictionarySelector = (\n dictionaries: Record<string, DictionaryOrGroup> | DictionaryOrGroup[]\n): boolean => {\n const dictionariesArray = Array.isArray(dictionaries)\n ? dictionaries\n : Object.values(dictionaries);\n\n return dictionariesArray.some((dictionary) => {\n const { qualifierTypes } = dictionary as QualifiedDictionaryGroup;\n\n return Array.isArray(qualifierTypes) && qualifierTypes.length > 0;\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,MAAa,4BACX,iBACY;AAKZ,SAJ0B,MAAM,QAAQ,aAAa,GACjD,eACA,OAAO,OAAO,aAAa,EAEN,MAAM,eAAe;EAC5C,MAAM,EAAE,mBAAmB;AAE3B,SAAO,MAAM,QAAQ,eAAe,IAAI,eAAe,SAAS;GAChE"}
1
+ {"version":3,"file":"getDictionarySelectorUsage.mjs","names":[],"sources":["../../../src/utils/getDictionarySelectorUsage.ts"],"sourcesContent":["import type {\n Dictionary,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\n\ntype DictionaryOrGroup = Dictionary | QualifiedDictionaryGroup;\n\n/**\n * Detects whether any built dictionary declares qualifier dimensions\n * (collections or variants).\n *\n * The merge step emits a {@link QualifiedDictionaryGroup} — carrying a\n * non-empty `qualifierTypes` array — for every key whose declarations use a\n * selector. When no group is present, the selector-object resolution path in\n * `getIntlayer` / `useIntlayer` is dead code, and bundlers can eliminate it via\n * the `INTLAYER_DICTIONARY_SELECTOR` env var.\n *\n * @example\n * getHasDictionarySelector(getDictionaries(config));\n * // true → at least one collection / variant / meta dictionary\n * // false → only plain dictionaries (selector logic can be stripped)\n */\nexport const getHasDictionarySelector = (\n dictionaries: Record<string, DictionaryOrGroup> | DictionaryOrGroup[]\n): boolean => {\n const dictionariesArray = Array.isArray(dictionaries)\n ? dictionaries\n : Object.values(dictionaries);\n\n return dictionariesArray.some((dictionary) => {\n const { qualifierTypes } = dictionary as QualifiedDictionaryGroup;\n\n return Array.isArray(qualifierTypes) && qualifierTypes.length > 0;\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,MAAa,4BACX,iBACY;CAKZ,QAJ0B,MAAM,QAAQ,YAAY,IAChD,eACA,OAAO,OAAO,YAAY,EAEN,CAAC,MAAM,eAAe;EAC5C,MAAM,EAAE,mBAAmB;EAE3B,OAAO,MAAM,QAAQ,cAAc,KAAK,eAAe,SAAS;CAClE,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"getExtension.mjs","names":[],"sources":["../../../src/utils/getExtension.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\nexport const getExtension = (\n configuration: IntlayerConfig,\n format?: 'esm' | 'cjs' | undefined\n) => {\n const outputFormats = configuration.build.outputFormat;\n\n if (format === 'cjs') return 'cjs';\n if (format === 'esm') return 'mjs';\n\n if (outputFormats.includes('cjs')) return 'cjs';\n if (outputFormats.includes('esm')) return 'mjs';\n\n return 'cjs';\n};\n"],"mappings":";AAEA,MAAa,gBACX,eACA,WACG;CACH,MAAM,gBAAgB,cAAc,MAAM;AAE1C,KAAI,WAAW,MAAO,QAAO;AAC7B,KAAI,WAAW,MAAO,QAAO;AAE7B,KAAI,cAAc,SAAS,MAAM,CAAE,QAAO;AAC1C,KAAI,cAAc,SAAS,MAAM,CAAE,QAAO;AAE1C,QAAO"}
1
+ {"version":3,"file":"getExtension.mjs","names":[],"sources":["../../../src/utils/getExtension.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\nexport const getExtension = (\n configuration: IntlayerConfig,\n format?: 'esm' | 'cjs' | undefined\n) => {\n const outputFormats = configuration.build.outputFormat;\n\n if (format === 'cjs') return 'cjs';\n if (format === 'esm') return 'mjs';\n\n if (outputFormats.includes('cjs')) return 'cjs';\n if (outputFormats.includes('esm')) return 'mjs';\n\n return 'cjs';\n};\n"],"mappings":";AAEA,MAAa,gBACX,eACA,WACG;CACH,MAAM,gBAAgB,cAAc,MAAM;CAE1C,IAAI,WAAW,OAAO,OAAO;CAC7B,IAAI,WAAW,OAAO,OAAO;CAE7B,IAAI,cAAc,SAAS,KAAK,GAAG,OAAO;CAC1C,IAAI,cAAc,SAAS,KAAK,GAAG,OAAO;CAE1C,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPackageJsonPath.mjs","names":[],"sources":["../../../src/utils/getPackageJsonPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { cacheMemory } from './cacheMemory';\n\nconst MAX_LEVELS = 15;\n\ntype PackageJsonPathCache = {\n packageJsonPath: string;\n baseDir: string;\n};\n\nexport const getPackageJsonPath = (\n startDir: string = process.cwd()\n): PackageJsonPathCache => {\n const checkedCache = cacheMemory.get<PackageJsonPathCache>(\n 'packageJsonPath',\n startDir\n );\n\n if (checkedCache) return checkedCache;\n\n let currentDir = startDir;\n\n for (let level = 0; level < MAX_LEVELS; level++) {\n const packageJsonPath = join(currentDir, 'package.json');\n\n if (existsSync(packageJsonPath)) {\n cacheMemory.set('packageJsonPath', startDir, {\n packageJsonPath,\n baseDir: currentDir,\n });\n\n return { packageJsonPath, baseDir: currentDir };\n }\n\n const parentDir = dirname(currentDir);\n\n // If we've reached the root directory, stop\n if (parentDir === currentDir) {\n break;\n }\n\n currentDir = parentDir;\n }\n\n throw new Error(\n `Could not find package.json in current directory or any of the ${MAX_LEVELS} parent directories. Searched from: ${startDir}`\n );\n};\n"],"mappings":";;;;;AAIA,MAAM,aAAa;AAOnB,MAAa,sBACX,WAAmB,QAAQ,KAAK,KACP;CACzB,MAAM,eAAe,YAAY,IAC/B,mBACA,SACD;AAED,KAAI,aAAc,QAAO;CAEzB,IAAI,aAAa;AAEjB,MAAK,IAAI,QAAQ,GAAG,QAAQ,YAAY,SAAS;EAC/C,MAAM,kBAAkB,KAAK,YAAY,eAAe;AAExD,MAAI,WAAW,gBAAgB,EAAE;AAC/B,eAAY,IAAI,mBAAmB,UAAU;IAC3C;IACA,SAAS;IACV,CAAC;AAEF,UAAO;IAAE;IAAiB,SAAS;IAAY;;EAGjD,MAAM,YAAY,QAAQ,WAAW;AAGrC,MAAI,cAAc,WAChB;AAGF,eAAa;;AAGf,OAAM,IAAI,MACR,kEAAkE,WAAW,sCAAsC,WACpH"}
1
+ {"version":3,"file":"getPackageJsonPath.mjs","names":[],"sources":["../../../src/utils/getPackageJsonPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { cacheMemory } from './cacheMemory';\n\nconst MAX_LEVELS = 15;\n\ntype PackageJsonPathCache = {\n packageJsonPath: string;\n baseDir: string;\n};\n\nexport const getPackageJsonPath = (\n startDir: string = process.cwd()\n): PackageJsonPathCache => {\n const checkedCache = cacheMemory.get<PackageJsonPathCache>(\n 'packageJsonPath',\n startDir\n );\n\n if (checkedCache) return checkedCache;\n\n let currentDir = startDir;\n\n for (let level = 0; level < MAX_LEVELS; level++) {\n const packageJsonPath = join(currentDir, 'package.json');\n\n if (existsSync(packageJsonPath)) {\n cacheMemory.set('packageJsonPath', startDir, {\n packageJsonPath,\n baseDir: currentDir,\n });\n\n return { packageJsonPath, baseDir: currentDir };\n }\n\n const parentDir = dirname(currentDir);\n\n // If we've reached the root directory, stop\n if (parentDir === currentDir) {\n break;\n }\n\n currentDir = parentDir;\n }\n\n throw new Error(\n `Could not find package.json in current directory or any of the ${MAX_LEVELS} parent directories. Searched from: ${startDir}`\n );\n};\n"],"mappings":";;;;;AAIA,MAAM,aAAa;AAOnB,MAAa,sBACX,WAAmB,QAAQ,IAAI,MACN;CACzB,MAAM,eAAe,YAAY,IAC/B,mBACA,QACF;CAEA,IAAI,cAAc,OAAO;CAEzB,IAAI,aAAa;CAEjB,KAAK,IAAI,QAAQ,GAAG,QAAQ,YAAY,SAAS;EAC/C,MAAM,kBAAkB,KAAK,YAAY,cAAc;EAEvD,IAAI,WAAW,eAAe,GAAG;GAC/B,YAAY,IAAI,mBAAmB,UAAU;IAC3C;IACA,SAAS;GACX,CAAC;GAED,OAAO;IAAE;IAAiB,SAAS;GAAW;EAChD;EAEA,MAAM,YAAY,QAAQ,UAAU;EAGpC,IAAI,cAAc,YAChB;EAGF,aAAa;CACf;CAEA,MAAM,IAAI,MACR,kEAAkE,WAAW,sCAAsC,UACrH;AACF"}
@@ -97,7 +97,8 @@ const getStorageAttributes = (options) => {
97
97
  };
98
98
  if (options === false || options === void 0) return {};
99
99
  const result = Array.isArray(options) ? options.reduce((acc, entry) => {
100
- return mergeStorageAttributes(acc, processStorageEntry(entry));
100
+ const partial = processStorageEntry(entry);
101
+ return mergeStorageAttributes(acc, partial);
101
102
  }, emptyResult) : mergeStorageAttributes(emptyResult, processStorageEntry(options));
102
103
  const cleanedResult = {};
103
104
  if (result.cookies && result.cookies.length > 0) cleanedResult.cookies = result.cookies;