@intlayer/config 8.4.3 → 8.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/cjs/built.cjs +7 -1
  3. package/dist/cjs/built.cjs.map +1 -1
  4. package/dist/cjs/client.cjs +16 -1
  5. package/dist/cjs/colors.cjs +33 -1
  6. package/dist/cjs/colors.cjs.map +1 -1
  7. package/dist/cjs/configFile/buildConfigurationFields.cjs +199 -1
  8. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  9. package/dist/cjs/configFile/configurationSchema.cjs +210 -1
  10. package/dist/cjs/configFile/configurationSchema.cjs.map +1 -1
  11. package/dist/cjs/configFile/getConfiguration.cjs +69 -1
  12. package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
  13. package/dist/cjs/configFile/index.cjs +28 -1
  14. package/dist/cjs/configFile/loadConfigurationFile.cjs +30 -1
  15. package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
  16. package/dist/cjs/configFile/searchConfigurationFile.cjs +53 -1
  17. package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
  18. package/dist/cjs/defaultValues/build.cjs +35 -1
  19. package/dist/cjs/defaultValues/build.cjs.map +1 -1
  20. package/dist/cjs/defaultValues/compiler.cjs +13 -1
  21. package/dist/cjs/defaultValues/compiler.cjs.map +1 -1
  22. package/dist/cjs/defaultValues/content.cjs +40 -1
  23. package/dist/cjs/defaultValues/content.cjs.map +1 -1
  24. package/dist/cjs/defaultValues/dictionary.cjs +13 -1
  25. package/dist/cjs/defaultValues/dictionary.cjs.map +1 -1
  26. package/dist/cjs/defaultValues/editor.cjs +23 -1
  27. package/dist/cjs/defaultValues/editor.cjs.map +1 -1
  28. package/dist/cjs/defaultValues/index.cjs +66 -1
  29. package/dist/cjs/defaultValues/internationalization.cjs +15 -1
  30. package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
  31. package/dist/cjs/defaultValues/log.cjs +10 -1
  32. package/dist/cjs/defaultValues/log.cjs.map +1 -1
  33. package/dist/cjs/defaultValues/routing.cjs +19 -1
  34. package/dist/cjs/defaultValues/routing.cjs.map +1 -1
  35. package/dist/cjs/defaultValues/system.cjs +29 -1
  36. package/dist/cjs/defaultValues/system.cjs.map +1 -1
  37. package/dist/cjs/loadEnvFile.cjs +31 -1
  38. package/dist/cjs/loadEnvFile.cjs.map +1 -1
  39. package/dist/cjs/loadExternalFile/bundleFile.cjs +71 -1
  40. package/dist/cjs/loadExternalFile/bundleFile.cjs.map +1 -1
  41. package/dist/cjs/loadExternalFile/bundleJSFile.cjs +33 -1
  42. package/dist/cjs/loadExternalFile/bundleJSFile.cjs.map +1 -1
  43. package/dist/cjs/loadExternalFile/index.cjs +17 -1
  44. package/dist/cjs/loadExternalFile/loadExternalFile.cjs +77 -1
  45. package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
  46. package/dist/cjs/loadExternalFile/parseFileContent.cjs +77 -1
  47. package/dist/cjs/loadExternalFile/parseFileContent.cjs.map +1 -1
  48. package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs +67 -1
  49. package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs.map +1 -1
  50. package/dist/cjs/logger.cjs +133 -1
  51. package/dist/cjs/logger.cjs.map +1 -1
  52. package/dist/cjs/node.cjs +28 -1
  53. package/dist/cjs/utils/ESMxCJSHelpers.cjs +27 -1
  54. package/dist/cjs/utils/ESMxCJSHelpers.cjs.map +1 -1
  55. package/dist/cjs/utils/alias.cjs +29 -1
  56. package/dist/cjs/utils/alias.cjs.map +1 -1
  57. package/dist/cjs/utils/cacheDisk.cjs +173 -1
  58. package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
  59. package/dist/cjs/utils/cacheMemory.cjs +269 -1
  60. package/dist/cjs/utils/cacheMemory.cjs.map +1 -1
  61. package/dist/cjs/utils/clearModuleCache.cjs +26 -1
  62. package/dist/cjs/utils/clearModuleCache.cjs.map +1 -1
  63. package/dist/cjs/utils/compareVersions.cjs +38 -1
  64. package/dist/cjs/utils/compareVersions.cjs.map +1 -1
  65. package/dist/cjs/utils/extractErrorMessage.cjs +95 -1
  66. package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
  67. package/dist/cjs/utils/getExtension.cjs +14 -1
  68. package/dist/cjs/utils/getExtension.cjs.map +1 -1
  69. package/dist/cjs/utils/getPackageJsonPath.cjs +33 -1
  70. package/dist/cjs/utils/getPackageJsonPath.cjs.map +1 -1
  71. package/dist/cjs/utils/index.cjs +45 -1
  72. package/dist/cjs/utils/logStack.cjs +17 -1
  73. package/dist/cjs/utils/logStack.cjs.map +1 -1
  74. package/dist/cjs/utils/normalizePath.cjs +17 -1
  75. package/dist/cjs/utils/normalizePath.cjs.map +1 -1
  76. package/dist/cjs/utils/parseFilePathPattern.cjs +24 -1
  77. package/dist/cjs/utils/parseFilePathPattern.cjs.map +1 -1
  78. package/dist/cjs/utils/retryManager.cjs +45 -1
  79. package/dist/cjs/utils/retryManager.cjs.map +1 -1
  80. package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs +13 -1
  81. package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs.map +1 -1
  82. package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs +16 -1
  83. package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs.map +1 -1
  84. package/dist/cjs/utils/stringFormatter/index.cjs +10 -1
  85. package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs +14 -1
  86. package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs.map +1 -1
  87. package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs +19 -1
  88. package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs.map +1 -1
  89. package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
  90. package/dist/esm/built.mjs +7 -1
  91. package/dist/esm/built.mjs.map +1 -1
  92. package/dist/esm/client.mjs +9 -1
  93. package/dist/esm/colors.mjs +18 -1
  94. package/dist/esm/colors.mjs.map +1 -1
  95. package/dist/esm/configFile/buildConfigurationFields.mjs +197 -1
  96. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  97. package/dist/esm/configFile/configurationSchema.mjs +191 -1
  98. package/dist/esm/configFile/configurationSchema.mjs.map +1 -1
  99. package/dist/esm/configFile/getConfiguration.mjs +66 -1
  100. package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
  101. package/dist/esm/configFile/index.mjs +6 -1
  102. package/dist/esm/configFile/loadConfigurationFile.mjs +29 -1
  103. package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
  104. package/dist/esm/configFile/searchConfigurationFile.mjs +50 -1
  105. package/dist/esm/configFile/searchConfigurationFile.mjs.map +1 -1
  106. package/dist/esm/defaultValues/build.mjs +28 -1
  107. package/dist/esm/defaultValues/build.mjs.map +1 -1
  108. package/dist/esm/defaultValues/compiler.mjs +8 -1
  109. package/dist/esm/defaultValues/compiler.mjs.map +1 -1
  110. package/dist/esm/defaultValues/content.mjs +32 -1
  111. package/dist/esm/defaultValues/content.mjs.map +1 -1
  112. package/dist/esm/defaultValues/dictionary.mjs +8 -1
  113. package/dist/esm/defaultValues/dictionary.mjs.map +1 -1
  114. package/dist/esm/defaultValues/editor.mjs +13 -1
  115. package/dist/esm/defaultValues/editor.mjs.map +1 -1
  116. package/dist/esm/defaultValues/index.mjs +11 -1
  117. package/dist/esm/defaultValues/internationalization.mjs +10 -1
  118. package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
  119. package/dist/esm/defaultValues/log.mjs +8 -1
  120. package/dist/esm/defaultValues/log.mjs.map +1 -1
  121. package/dist/esm/defaultValues/routing.mjs +11 -1
  122. package/dist/esm/defaultValues/routing.mjs.map +1 -1
  123. package/dist/esm/defaultValues/system.mjs +16 -1
  124. package/dist/esm/defaultValues/system.mjs.map +1 -1
  125. package/dist/esm/loadEnvFile.mjs +27 -1
  126. package/dist/esm/loadEnvFile.mjs.map +1 -1
  127. package/dist/esm/loadExternalFile/bundleFile.mjs +67 -1
  128. package/dist/esm/loadExternalFile/bundleFile.mjs.map +1 -1
  129. package/dist/esm/loadExternalFile/bundleJSFile.mjs +31 -1
  130. package/dist/esm/loadExternalFile/bundleJSFile.mjs.map +1 -1
  131. package/dist/esm/loadExternalFile/index.mjs +7 -1
  132. package/dist/esm/loadExternalFile/loadExternalFile.mjs +73 -1
  133. package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
  134. package/dist/esm/loadExternalFile/parseFileContent.mjs +73 -1
  135. package/dist/esm/loadExternalFile/parseFileContent.mjs.map +1 -1
  136. package/dist/esm/loadExternalFile/transpileTSToCJS.mjs +64 -1
  137. package/dist/esm/loadExternalFile/transpileTSToCJS.mjs.map +1 -1
  138. package/dist/esm/logger.mjs +118 -1
  139. package/dist/esm/logger.mjs.map +1 -1
  140. package/dist/esm/node.mjs +6 -1
  141. package/dist/esm/utils/ESMxCJSHelpers.mjs +25 -1
  142. package/dist/esm/utils/ESMxCJSHelpers.mjs.map +1 -0
  143. package/dist/esm/utils/alias.mjs +27 -1
  144. package/dist/esm/utils/alias.mjs.map +1 -1
  145. package/dist/esm/utils/cacheDisk.mjs +170 -1
  146. package/dist/esm/utils/cacheDisk.mjs.map +1 -1
  147. package/dist/esm/utils/cacheMemory.mjs +261 -1
  148. package/dist/esm/utils/cacheMemory.mjs.map +1 -1
  149. package/dist/esm/utils/clearModuleCache.mjs +25 -1
  150. package/dist/esm/utils/clearModuleCache.mjs.map +1 -1
  151. package/dist/esm/utils/compareVersions.mjs +36 -1
  152. package/dist/esm/utils/compareVersions.mjs.map +1 -1
  153. package/dist/esm/utils/extractErrorMessage.mjs +93 -1
  154. package/dist/esm/utils/extractErrorMessage.mjs.map +1 -1
  155. package/dist/esm/utils/getExtension.mjs +12 -1
  156. package/dist/esm/utils/getExtension.mjs.map +1 -1
  157. package/dist/esm/utils/getPackageJsonPath.mjs +31 -1
  158. package/dist/esm/utils/getPackageJsonPath.mjs.map +1 -1
  159. package/dist/esm/utils/index.mjs +19 -1
  160. package/dist/esm/utils/logStack.mjs +16 -1
  161. package/dist/esm/utils/logStack.mjs.map +1 -1
  162. package/dist/esm/utils/normalizePath.mjs +15 -1
  163. package/dist/esm/utils/normalizePath.mjs.map +1 -1
  164. package/dist/esm/utils/parseFilePathPattern.mjs +21 -1
  165. package/dist/esm/utils/parseFilePathPattern.mjs.map +1 -1
  166. package/dist/esm/utils/retryManager.mjs +44 -1
  167. package/dist/esm/utils/retryManager.mjs.map +1 -1
  168. package/dist/esm/utils/stringFormatter/camelCaseToKebabCase.mjs +11 -1
  169. package/dist/esm/utils/stringFormatter/camelCaseToKebabCase.mjs.map +1 -1
  170. package/dist/esm/utils/stringFormatter/camelCaseToSentence.mjs +14 -1
  171. package/dist/esm/utils/stringFormatter/camelCaseToSentence.mjs.map +1 -1
  172. package/dist/esm/utils/stringFormatter/index.mjs +6 -1
  173. package/dist/esm/utils/stringFormatter/kebabCaseToCamelCase.mjs +12 -1
  174. package/dist/esm/utils/stringFormatter/kebabCaseToCamelCase.mjs.map +1 -1
  175. package/dist/esm/utils/stringFormatter/toLowerCamelCase.mjs +17 -1
  176. package/dist/esm/utils/stringFormatter/toLowerCamelCase.mjs.map +1 -1
  177. package/dist/types/client.d.ts +4 -4
  178. package/dist/types/colors.d.ts +20 -2
  179. package/dist/types/colors.d.ts.map +1 -0
  180. package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
  181. package/dist/types/configFile/configurationSchema.d.ts +10 -10
  182. package/dist/types/configFile/getConfiguration.d.ts +2 -2
  183. package/dist/types/configFile/loadConfigurationFile.d.ts +1 -1
  184. package/dist/types/configFile/loadConfigurationFile.d.ts.map +1 -1
  185. package/dist/types/loadEnvFile.d.ts +10 -2
  186. package/dist/types/loadEnvFile.d.ts.map +1 -0
  187. package/dist/types/loadExternalFile/index.d.ts +3 -3
  188. package/dist/types/loadExternalFile/loadExternalFile.d.ts +25 -2
  189. package/dist/types/loadExternalFile/loadExternalFile.d.ts.map +1 -0
  190. package/dist/types/loadExternalFile/parseFileContent.d.ts +29 -2
  191. package/dist/types/loadExternalFile/parseFileContent.d.ts.map +1 -0
  192. package/dist/types/loadExternalFile/transpileTSToCJS.d.ts +19 -2
  193. package/dist/types/loadExternalFile/transpileTSToCJS.d.ts.map +1 -0
  194. package/dist/types/logger.d.ts +1 -1
  195. package/dist/types/utils/index.d.ts +4 -4
  196. package/dist/types/utils/stringFormatter/camelCaseToKebabCase.d.ts +9 -2
  197. package/dist/types/utils/stringFormatter/camelCaseToKebabCase.d.ts.map +1 -0
  198. package/dist/types/utils/stringFormatter/camelCaseToSentence.d.ts +9 -2
  199. package/dist/types/utils/stringFormatter/camelCaseToSentence.d.ts.map +1 -0
  200. package/dist/types/utils/stringFormatter/index.d.ts +4 -4
  201. package/dist/types/utils/stringFormatter/kebabCaseToCamelCase.d.ts +5 -2
  202. package/dist/types/utils/stringFormatter/kebabCaseToCamelCase.d.ts.map +1 -0
  203. package/dist/types/utils/stringFormatter/toLowerCamelCase.d.ts +10 -2
  204. package/dist/types/utils/stringFormatter/toLowerCamelCase.d.ts.map +1 -0
  205. package/package.json +2 -2
  206. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  207. package/dist/esm/ESMxCJSHelpers-BAuqwNXV.mjs +0 -2
  208. package/dist/esm/ESMxCJSHelpers-BAuqwNXV.mjs.map +0 -1
  209. package/dist/types/camelCaseToKebabCase-BV_lLJHR.d.ts +0 -9
  210. package/dist/types/camelCaseToKebabCase-BV_lLJHR.d.ts.map +0 -1
  211. package/dist/types/camelCaseToSentence-DAbbkwe6.d.ts +0 -9
  212. package/dist/types/camelCaseToSentence-DAbbkwe6.d.ts.map +0 -1
  213. package/dist/types/colors-BbZeGWYU.d.ts +0 -20
  214. package/dist/types/colors-BbZeGWYU.d.ts.map +0 -1
  215. package/dist/types/kebabCaseToCamelCase-h9PkNVuO.d.ts +0 -5
  216. package/dist/types/kebabCaseToCamelCase-h9PkNVuO.d.ts.map +0 -1
  217. package/dist/types/loadEnvFile-BiTBX4fe.d.ts +0 -10
  218. package/dist/types/loadEnvFile-BiTBX4fe.d.ts.map +0 -1
  219. package/dist/types/loadExternalFile-DmM_TGcA.d.ts +0 -25
  220. package/dist/types/loadExternalFile-DmM_TGcA.d.ts.map +0 -1
  221. package/dist/types/parseFileContent--o_QlW5j.d.ts +0 -29
  222. package/dist/types/parseFileContent--o_QlW5j.d.ts.map +0 -1
  223. package/dist/types/toLowerCamelCase-DUdT00I1.d.ts +0 -10
  224. package/dist/types/toLowerCamelCase-DUdT00I1.d.ts.map +0 -1
  225. package/dist/types/transpileTSToCJS-OifpV3zk.d.ts +0 -19
  226. package/dist/types/transpileTSToCJS-OifpV3zk.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"loadExternalFile.cjs","names":["JSON5","transpileTSToCJSSync","parseFileContent","transpileTSToCJS","colorizePath"],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport {\n type TranspileOptions,\n transpileTSToCJS,\n transpileTSToCJSSync,\n} from './transpileTSToCJS';\n\n// CJS MJS cross usage\nconst parseJSON5 = JSON5.parse || (JSON5 as any).default?.parse;\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: TranspileOptions;\n logError?: boolean;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return parseJSON5(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return parseJSON5(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n if (options?.logError ?? true) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n }\n};\n"],"mappings":"yTAiBA,MAAM,EAAaA,EAAAA,QAAM,OAAUA,EAAAA,QAAc,SAAS,MAa7C,GACX,EACA,IACoB,CACpB,IAAM,GAAA,EAAA,EAAA,SAAwB,EAAS,EAAI,QAE3C,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAGlB,OAAO,GAAA,EAAA,EAAA,cAAwB,EAAU,QAAQ,CAAC,CAMpD,IAAM,EAAyCC,EAAAA,sBAAAA,EAAAA,EAAAA,cAFrB,EAAU,QAAQ,CAI1C,EACA,GAAS,aACV,CAED,GAAI,CAAC,EAAoB,CACvB,EAAA,OAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAcC,EAAAA,iBAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAA,OAAO,oCAAoC,IAAW,CACtD,OAGF,OAAO,QACA,EAAO,CACd,EAAA,OACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF,GASQ,EAAmB,MAC9B,EACA,IAC6B,CAC7B,IAAM,GAAA,EAAA,EAAA,SAAwB,EAAS,CAEvC,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAIlB,OAAO,EADa,MAAA,EAAA,EAAA,UAAe,EAAU,QAAQ,CACvB,CAMhC,IAAM,EAAyC,MAAMC,EAAAA,iBAFxC,MAAA,EAAA,EAAA,UAAe,EAAU,QAAQ,CAI5C,EACA,GAAS,aACV,CAED,GAAI,CAAC,EAAoB,CACvB,EAAA,OAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAcD,EAAAA,iBAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAA,OAAO,oCAAoCE,EAAAA,aAAa,EAAS,GAAG,CACpE,OAGF,OAAO,QACA,EAAO,EACV,GAAS,UAAY,KACvB,EAAA,OACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF"}
1
+ {"version":3,"file":"loadExternalFile.cjs","names":["JSON5","transpileTSToCJSSync","parseFileContent","transpileTSToCJS","colorizePath"],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport {\n type TranspileOptions,\n transpileTSToCJS,\n transpileTSToCJSSync,\n} from './transpileTSToCJS';\n\n// CJS MJS cross usage\nconst parseJSON5 = JSON5.parse || (JSON5 as any).default?.parse;\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: TranspileOptions;\n logError?: boolean;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return parseJSON5(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return parseJSON5(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n if (options?.logError ?? true) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,aAAaA,cAAM,SAAUA,cAAc,SAAS;;;;;;AAa1D,MAAa,wBACX,UACA,YACoB;CACpB,MAAM,uCAAwB,SAAS,IAAI;AAE3C,KAAI;AACF,MACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,SAGlB,QAAO,qCAAwB,UAAU,QAAQ,CAAC;EAMpD,MAAM,qBAAyCC,yFAFrB,UAAU,QAAQ,EAI1C,UACA,SAAS,aACV;AAED,MAAI,CAAC,oBAAoB;AACvB,yBAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAGF,MAAM,cAAcC,2DAAiB,oBAAoB;GACvD,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC;AAEF,MAAI,OAAO,gBAAgB,aAAa;AACtC,yBAAO,oCAAoC,WAAW;AACtD;;AAGF,SAAO;UACA,OAAO;AACd,wBACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,EAAE,CAChD,EACD,EACE,OAAO,SACR,CACF;;;;;;;;AASL,MAAa,mBAAmB,OAC9B,UACA,YAC6B;CAC7B,MAAM,uCAAwB,SAAS;AAEvC,KAAI;AACF,MACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,SAIlB,QAAO,WADa,qCAAe,UAAU,QAAQ,CACvB;EAMhC,MAAM,qBAAyC,MAAMC,2DAFxC,qCAAe,UAAU,QAAQ,EAI5C,UACA,SAAS,aACV;AAED,MAAI,CAAC,oBAAoB;AACvB,yBAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAGF,MAAM,cAAcD,2DAAiB,oBAAoB;GACvD,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC;AAEF,MAAI,OAAO,gBAAgB,aAAa;AACtC,yBAAO,oCAAoCE,4BAAa,SAAS,GAAG;AACpE;;AAGF,SAAO;UACA,OAAO;AACd,MAAI,SAAS,YAAY,KACvB,uBACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,EAAE,CAChD,EACD,EACE,OAAO,SACR,CACF"}
@@ -1,2 +1,78 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Bmb41Sf3.cjs`),t=require(`../utils/ESMxCJSHelpers.cjs`),n=require(`../loadEnvFile.cjs`);let r=require(`node:vm`),i=require(`esbuild`);i=e.t(i);const a=e=>{let{envVarOptions:r,projectRequire:a,additionalEnvVars:o,mocks:s,aliases:c}=e??{},l={},u=typeof a==`function`?a:t.getProjectRequire(),d=(()=>{let e=Object.assign({esbuild:i},s),t=Object.assign({},c),n=function(n){let r=t?.[n]?t[n]:n;return e&&Object.hasOwn(e,r)?e[r]:r!==n&&e&&Object.hasOwn(e,n)?e[n]:u(r)};return n.resolve=u.resolve.bind(u),n.main=u.main,n.extensions=u.extensions,n.cache=u.cache,n})();try{l={React:u(`react`)}}catch{l={React:{createElement:(e,t,...n)=>({type:e,props:{...t,children:n.length<=1?n[0]:n}}),Fragment:Symbol.for(`react.fragment`)}}}let f={exports:{default:{}},module:{exports:{}},process:{...process,env:{...process.env,...n.loadEnvFile(r),...o}},console,require:d,...l};return Object.getOwnPropertyNames(globalThis).forEach(e=>{e in f||(f[e]=globalThis[e])}),f},o=(e,t)=>{let n=a(t);(0,r.runInNewContext)(`"use strict";\n${e}`,n);let i=[n.exports?.default,n.module?.exports?.defaults,n.module?.exports?.default,n.module?.exports];for(let e of i)if(e&&typeof e==`object`&&Object.keys(e).length>0)return e};exports.getSandBoxContext=a,exports.parseFileContent=o;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_utils_ESMxCJSHelpers = require('../utils/ESMxCJSHelpers.cjs');
4
+ const require_loadEnvFile = require('../loadEnvFile.cjs');
5
+ let node_vm = require("node:vm");
6
+ let esbuild = require("esbuild");
7
+ esbuild = require_runtime.__toESM(esbuild);
8
+
9
+ //#region src/loadExternalFile/parseFileContent.ts
10
+ const getSandBoxContext = (options) => {
11
+ const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } = options ?? {};
12
+ let additionalGlobalVar = {};
13
+ const baseRequire = typeof projectRequire === "function" ? projectRequire : require_utils_ESMxCJSHelpers.getProjectRequire();
14
+ const mockedRequire = (() => {
15
+ const mockTable = Object.assign({ esbuild }, mocks);
16
+ const aliasTable = Object.assign({}, aliases);
17
+ const wrappedRequire = function mockableRequire(id) {
18
+ const target = aliasTable?.[id] ? aliasTable[id] : id;
19
+ if (mockTable && Object.hasOwn(mockTable, target)) return mockTable[target];
20
+ if (target !== id && mockTable && Object.hasOwn(mockTable, id)) return mockTable[id];
21
+ return baseRequire(target);
22
+ };
23
+ wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);
24
+ wrappedRequire.main = baseRequire.main;
25
+ wrappedRequire.extensions = baseRequire.extensions;
26
+ wrappedRequire.cache = baseRequire.cache;
27
+ return wrappedRequire;
28
+ })();
29
+ try {
30
+ additionalGlobalVar = { React: baseRequire("react") };
31
+ } catch (_err) {
32
+ additionalGlobalVar = { React: {
33
+ createElement: (type, props, ...children) => ({
34
+ type,
35
+ props: {
36
+ ...props,
37
+ children: children.length <= 1 ? children[0] : children
38
+ }
39
+ }),
40
+ Fragment: Symbol.for("react.fragment")
41
+ } };
42
+ }
43
+ const sandboxContext = {
44
+ exports: { default: {} },
45
+ module: { exports: {} },
46
+ process: {
47
+ ...process,
48
+ env: {
49
+ ...process.env,
50
+ ...require_loadEnvFile.loadEnvFile(envVarOptions),
51
+ ...additionalEnvVars
52
+ }
53
+ },
54
+ console,
55
+ require: mockedRequire,
56
+ ...additionalGlobalVar
57
+ };
58
+ Object.getOwnPropertyNames(globalThis).forEach((key) => {
59
+ if (!(key in sandboxContext)) sandboxContext[key] = globalThis[key];
60
+ });
61
+ return sandboxContext;
62
+ };
63
+ const parseFileContent = (fileContentString, options) => {
64
+ const sandboxContext = getSandBoxContext(options);
65
+ (0, node_vm.runInNewContext)(`"use strict";\n${fileContentString}`, sandboxContext);
66
+ const candidates = [
67
+ sandboxContext.exports?.default,
68
+ sandboxContext.module?.exports?.defaults,
69
+ sandboxContext.module?.exports?.default,
70
+ sandboxContext.module?.exports
71
+ ];
72
+ for (const candidate of candidates) if (candidate && typeof candidate === "object" && Object.keys(candidate).length > 0) return candidate;
73
+ };
74
+
75
+ //#endregion
76
+ exports.getSandBoxContext = getSandBoxContext;
77
+ exports.parseFileContent = parseFileContent;
2
78
  //# sourceMappingURL=parseFileContent.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseFileContent.cjs","names":["getProjectRequire","loadEnvFile"],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we inject a dummy React object to capture JSX elements\n // This allows using JSX in content declarations even if React is not installed (e.g. in Solid.js or Vue projects)\n // because esbuild's tsx loader defaults to React.createElement.\n additionalGlobalVar = {\n React: {\n createElement: (type: any, props: any, ...children: any[]) => ({\n type,\n props: {\n ...props,\n children: children.length <= 1 ? children[0] : children,\n },\n }),\n Fragment: Symbol.for('react.fragment'),\n },\n };\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":"4OA0BA,MAAa,EAAqB,GAA6C,CAC7E,GAAM,CAAE,gBAAe,iBAAgB,oBAAmB,QAAO,WAC/D,GAAW,EAAE,CAEX,EAAsB,EAAE,CAEtB,EACJ,OAAO,GAAmB,WAAa,EAAiBA,EAAAA,mBAAmB,CAGvE,OAAuC,CAC3C,IAAM,EAAY,OAAO,OACvB,CACE,UACD,CACD,EACD,CACK,EAAa,OAAO,OAAO,EAAE,CAAE,EAAQ,CAEvC,EAAiB,SAAyB,EAAY,CAC1D,IAAM,EAAS,IAAa,GAAM,EAAW,GAAM,EAWnD,OATI,GAAa,OAAO,OAAO,EAAW,EAAO,CACxC,EAAU,GAIf,IAAW,GAAM,GAAa,OAAO,OAAO,EAAW,EAAG,CACrD,EAAU,GAGZ,EAAY,EAAO,EAS5B,MALA,GAAe,QAAU,EAAY,QAAQ,KAAK,EAAY,CAC9D,EAAe,KAAO,EAAY,KAClC,EAAe,WAAa,EAAY,WACxC,EAAe,MAAQ,EAAY,MAE5B,KACL,CAEJ,GAAI,CAEF,EAAsB,CACpB,MAAO,EAAY,QAAQ,CAC5B,MACY,CAIb,EAAsB,CACpB,MAAO,CACL,eAAgB,EAAW,EAAY,GAAG,KAAqB,CAC7D,OACA,MAAO,CACL,GAAG,EACH,SAAU,EAAS,QAAU,EAAI,EAAS,GAAK,EAChD,CACF,EACD,SAAU,OAAO,IAAI,iBAAiB,CACvC,CACF,CAGH,IAAM,EAA0B,CAC9B,QAAS,CACP,QAAS,EAAE,CACZ,CACD,OAAQ,CACN,QAAS,EAAE,CACZ,CACD,QAAS,CACP,GAAG,QACH,IAAK,CACH,GAAG,QAAQ,IACX,GAAGC,EAAAA,YAAY,EAAc,CAC7B,GAAG,EACJ,CACF,CACD,QACA,QAAS,EACT,GAAG,EACJ,CASD,OANA,OAAO,oBAAoB,WAAW,CAAC,QAAS,GAAQ,CAChD,KAAO,IACX,EAAe,GAAO,WAAW,KAEnC,CAEK,GAGI,GACX,EACA,IACkB,CAClB,IAAM,EAAiB,EAAkB,EAAQ,EAGjD,EAAA,EAAA,iBAAgB,kBAAkB,IAAqB,EAAe,CAEtE,IAAM,EAAwB,CAC5B,EAAe,SAAS,QACxB,EAAe,QAAQ,SAAS,SAChC,EAAe,QAAQ,SAAS,QAChC,EAAe,QAAQ,QACxB,CAED,IAAK,IAAM,KAAa,EACtB,GACE,GACA,OAAO,GAAc,UACrB,OAAO,KAAK,EAAoB,CAAC,OAAS,EAE1C,OAAO"}
1
+ {"version":3,"file":"parseFileContent.cjs","names":["getProjectRequire","loadEnvFile"],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we inject a dummy React object to capture JSX elements\n // This allows using JSX in content declarations even if React is not installed (e.g. in Solid.js or Vue projects)\n // because esbuild's tsx loader defaults to React.createElement.\n additionalGlobalVar = {\n React: {\n createElement: (type: any, props: any, ...children: any[]) => ({\n type,\n props: {\n ...props,\n children: children.length <= 1 ? children[0] : children,\n },\n }),\n Fragment: Symbol.for('react.fragment'),\n },\n };\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":";;;;;;;;;AA0BA,MAAa,qBAAqB,YAA6C;CAC7E,MAAM,EAAE,eAAe,gBAAgB,mBAAmB,OAAO,YAC/D,WAAW,EAAE;CAEf,IAAI,sBAAsB,EAAE;CAE5B,MAAM,cACJ,OAAO,mBAAmB,aAAa,iBAAiBA,gDAAmB;CAG7E,MAAM,uBAAuC;EAC3C,MAAM,YAAY,OAAO,OACvB,EACE,SACD,EACD,MACD;EACD,MAAM,aAAa,OAAO,OAAO,EAAE,EAAE,QAAQ;EAE7C,MAAM,iBAAiB,SAAS,gBAAgB,IAAY;GAC1D,MAAM,SAAS,aAAa,MAAM,WAAW,MAAM;AAEnD,OAAI,aAAa,OAAO,OAAO,WAAW,OAAO,CAC/C,QAAO,UAAU;AAInB,OAAI,WAAW,MAAM,aAAa,OAAO,OAAO,WAAW,GAAG,CAC5D,QAAO,UAAU;AAGnB,UAAO,YAAY,OAAO;;AAI5B,iBAAe,UAAU,YAAY,QAAQ,KAAK,YAAY;AAC9D,iBAAe,OAAO,YAAY;AAClC,iBAAe,aAAa,YAAY;AACxC,iBAAe,QAAQ,YAAY;AAEnC,SAAO;KACL;AAEJ,KAAI;AAEF,wBAAsB,EACpB,OAAO,YAAY,QAAQ,EAC5B;UACM,MAAM;AAIb,wBAAsB,EACpB,OAAO;GACL,gBAAgB,MAAW,OAAY,GAAG,cAAqB;IAC7D;IACA,OAAO;KACL,GAAG;KACH,UAAU,SAAS,UAAU,IAAI,SAAS,KAAK;KAChD;IACF;GACD,UAAU,OAAO,IAAI,iBAAiB;GACvC,EACF;;CAGH,MAAM,iBAA0B;EAC9B,SAAS,EACP,SAAS,EAAE,EACZ;EACD,QAAQ,EACN,SAAS,EAAE,EACZ;EACD,SAAS;GACP,GAAG;GACH,KAAK;IACH,GAAG,QAAQ;IACX,GAAGC,gCAAY,cAAc;IAC7B,GAAG;IACJ;GACF;EACD;EACA,SAAS;EACT,GAAG;EACJ;AAGD,QAAO,oBAAoB,WAAW,CAAC,SAAS,QAAQ;AACtD,MAAI,EAAE,OAAO,gBACX,gBAAe,OAAO,WAAW;GAEnC;AAEF,QAAO;;AAGT,MAAa,oBACX,mBACA,YACkB;CAClB,MAAM,iBAAiB,kBAAkB,QAAQ;AAGjD,8BAAgB,kBAAkB,qBAAqB,eAAe;CAEtE,MAAM,aAAwB;EAC5B,eAAe,SAAS;EACxB,eAAe,QAAQ,SAAS;EAChC,eAAe,QAAQ,SAAS;EAChC,eAAe,QAAQ;EACxB;AAED,MAAK,MAAM,aAAa,WACtB,KACE,aACA,OAAO,cAAc,YACrB,OAAO,KAAK,UAAoB,CAAC,SAAS,EAE1C,QAAO"}
@@ -1,2 +1,68 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../utils/getPackageJsonPath.cjs`),t=require(`./bundleFile.cjs`);let n=require(`node:fs`),r=require(`node:path`),i=require(`esbuild`),a=require(`node:url`);const o=t=>{let i=(0,r.join)(e.getPackageJsonPath((0,r.dirname)(t)).baseDir,`tsconfig.json`);return(0,n.existsSync)(i)?i:void 0},s=e=>({loader:{".js":`js`,".jsx":`jsx`,".mjs":`js`,".ts":`ts`,".tsx":`tsx`,".cjs":`js`,".json":`json`,".md":`text`,".mdx":`text`},format:`cjs`,target:`node20`,platform:`node`,write:!1,packages:`external`,bundle:!0,tsconfig:o(e),define:{"import.meta.url":JSON.stringify((0,a.pathToFileURL)(e).href)}}),c=(e,n,a)=>{let o=t.getLoader((0,r.extname)(n)),{esbuildInstance:c,...l}=a??{};return(c?.buildSync??i.buildSync)({stdin:{contents:e,loader:o,resolveDir:(0,r.dirname)(n),sourcefile:n},...s(n),...l}).outputFiles?.[0].text},l=async(e,n,a)=>{let o=t.getLoader((0,r.extname)(n)),{esbuildInstance:c,...l}=a??{};return(await(c?.build??i.build)({stdin:{contents:e,loader:o,resolveDir:(0,r.dirname)(n),sourcefile:n},...s(n),...l})).outputFiles?.[0].text};exports.transpileTSToCJS=l,exports.transpileTSToCJSSync=c;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_utils_getPackageJsonPath = require('../utils/getPackageJsonPath.cjs');
4
+ const require_loadExternalFile_bundleFile = require('./bundleFile.cjs');
5
+ let node_fs = require("node:fs");
6
+ let node_path = require("node:path");
7
+ let esbuild = require("esbuild");
8
+ let node_url = require("node:url");
9
+
10
+ //#region src/loadExternalFile/transpileTSToCJS.ts
11
+ const getTsConfigPath = (filePath) => {
12
+ const tsconfigPath = (0, node_path.join)(require_utils_getPackageJsonPath.getPackageJsonPath((0, node_path.dirname)(filePath)).baseDir, "tsconfig.json");
13
+ return (0, node_fs.existsSync)(tsconfigPath) ? tsconfigPath : void 0;
14
+ };
15
+ const getTransformationOptions = (filePath) => ({
16
+ loader: {
17
+ ".js": "js",
18
+ ".jsx": "jsx",
19
+ ".mjs": "js",
20
+ ".ts": "ts",
21
+ ".tsx": "tsx",
22
+ ".cjs": "js",
23
+ ".json": "json",
24
+ ".md": "text",
25
+ ".mdx": "text"
26
+ },
27
+ format: "cjs",
28
+ target: "node20",
29
+ platform: "node",
30
+ write: false,
31
+ packages: "external",
32
+ bundle: true,
33
+ tsconfig: getTsConfigPath(filePath),
34
+ define: { "import.meta.url": JSON.stringify((0, node_url.pathToFileURL)(filePath).href) }
35
+ });
36
+ const transpileTSToCJSSync = (code, filePath, options) => {
37
+ const loader = require_loadExternalFile_bundleFile.getLoader((0, node_path.extname)(filePath));
38
+ const { esbuildInstance, ...buildOptions } = options ?? {};
39
+ return (esbuildInstance?.buildSync ?? esbuild.buildSync)({
40
+ stdin: {
41
+ contents: code,
42
+ loader,
43
+ resolveDir: (0, node_path.dirname)(filePath),
44
+ sourcefile: filePath
45
+ },
46
+ ...getTransformationOptions(filePath),
47
+ ...buildOptions
48
+ }).outputFiles?.[0].text;
49
+ };
50
+ const transpileTSToCJS = async (code, filePath, options) => {
51
+ const loader = require_loadExternalFile_bundleFile.getLoader((0, node_path.extname)(filePath));
52
+ const { esbuildInstance, ...buildOptions } = options ?? {};
53
+ return (await (esbuildInstance?.build ?? esbuild.build)({
54
+ stdin: {
55
+ contents: code,
56
+ loader,
57
+ resolveDir: (0, node_path.dirname)(filePath),
58
+ sourcefile: filePath
59
+ },
60
+ ...getTransformationOptions(filePath),
61
+ ...buildOptions
62
+ })).outputFiles?.[0].text;
63
+ };
64
+
65
+ //#endregion
66
+ exports.transpileTSToCJS = transpileTSToCJS;
67
+ exports.transpileTSToCJSSync = transpileTSToCJSSync;
2
68
  //# sourceMappingURL=transpileTSToCJS.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"transpileTSToCJS.cjs","names":["getPackageJsonPath","getLoader","buildSync","build"],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { type BuildOptions, type BuildResult, build, buildSync } 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 },\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 const moduleResult: BuildResult = 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\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 const esbuildBuild = esbuildInstance?.build ?? build;\n\n const moduleResult: BuildResult = await esbuildBuild({\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\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":"gRAkBA,MAAM,EAAmB,GAAyC,CAChE,IAAM,GAAA,EAAA,EAAA,MACJA,EAAAA,oBAAAA,EAAAA,EAAAA,SAA2B,EAAS,CAAC,CAAC,QACtC,gBACD,CAGD,OAAA,EAAA,EAAA,YAAkB,EAAa,CAAG,EAAe,IAAA,IAG7C,EAA4B,IAAoC,CACpE,OAAQ,CACN,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,QAAS,OACT,MAAO,OACP,OAAQ,OACT,CACD,OAAQ,MACR,OAAQ,SACR,SAAU,OACV,MAAO,GACP,SAAU,WACV,OAAQ,GACR,SAAU,EAAgB,EAAS,CACnC,OAAQ,CACN,kBAAmB,KAAK,WAAA,EAAA,EAAA,eAAwB,EAAS,CAAC,KAAK,CAChE,CACF,EAEY,GACX,EACA,EACA,IACuB,CAEvB,IAAM,EAASC,EAAAA,WAAAA,EAAAA,EAAAA,SADW,EAAS,CACA,CAE7B,CAAE,kBAAiB,GAAG,GAAiB,GAAW,EAAE,CAgB1D,OAfyB,GAAiB,WAAaC,EAAAA,WAEJ,CACjD,MAAO,CACL,SAAU,EACV,SACA,YAAA,EAAA,EAAA,SAAoB,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,CAEsC,cAAc,GAAG,MAK9C,EAAmB,MAC9B,EACA,EACA,IACgC,CAEhC,IAAM,EAASD,EAAAA,WAAAA,EAAAA,EAAAA,SADW,EAAS,CACA,CAE7B,CAAE,kBAAiB,GAAG,GAAiB,GAAW,EAAE,CAgB1D,OAbkC,MAFb,GAAiB,OAASE,EAAAA,OAEM,CACnD,MAAO,CACL,SAAU,EACV,SACA,YAAA,EAAA,EAAA,SAAoB,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,EAEsC,cAAc,GAAG"}
1
+ {"version":3,"file":"transpileTSToCJS.cjs","names":["getPackageJsonPath","getLoader","buildSync","build"],"sources":["../../../src/loadExternalFile/transpileTSToCJS.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { type BuildOptions, type BuildResult, build, buildSync } 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 },\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 const moduleResult: BuildResult = 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\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 const esbuildBuild = esbuildInstance?.build ?? build;\n\n const moduleResult: BuildResult = await esbuildBuild({\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\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,mBAAmB,aAAyC;CAChE,MAAM,mCACJA,2EAA2B,SAAS,CAAC,CAAC,SACtC,gBACD;AAGD,gCAAkB,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,QAAQ;CACR,UAAU;CACV,OAAO;CACP,UAAU;CACV,QAAQ;CACR,UAAU,gBAAgB,SAAS;CACnC,QAAQ,EACN,mBAAmB,KAAK,sCAAwB,SAAS,CAAC,KAAK,EAChE;CACF;AAED,MAAa,wBACX,MACA,UACA,YACuB;CAEvB,MAAM,SAASC,qEADW,SAAS,CACA;CAEnC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,WAAW,EAAE;AAgB1D,SAfyB,iBAAiB,aAAaC,mBAEJ;EACjD,OAAO;GACL,UAAU;GACV;GACA,mCAAoB,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAAC,CAEsC,cAAc,GAAG;;AAK3D,MAAa,mBAAmB,OAC9B,MACA,UACA,YACgC;CAEhC,MAAM,SAASD,qEADW,SAAS,CACA;CAEnC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,WAAW,EAAE;AAgB1D,SAbkC,OAFb,iBAAiB,SAASE,eAEM;EACnD,OAAO;GACL,UAAU;GACV;GACA,mCAAoB,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAAC,EAEsC,cAAc,GAAG"}
@@ -1,2 +1,134 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./colors.cjs`);let t;const n=e=>{t=e},r=e=>t===void 0?e:t,i=(e,t)=>{let n=t?.isVerbose??!1,i=t?.config?.mode??`default`,a=t?.level??`info`,o=r(t?.config?.prefix),s=t?.config?.log??console.log,c=t?.config?.info??console.info,l=t?.config?.warn??console.warn,u=t?.config?.error??console.error,d=t?.config?.debug??console.debug;if(i===`disabled`||n&&i!==`verbose`)return;let f=o?[o,...[e].flat()]:[e].flat();if(a===`debug`)return d(...f);if(a===`info`)return c(...f);if(a===`warn`)return l(...f);if(a===`error`)return u(...f);s(...f)},a=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],o=(e,t)=>(n,r)=>i(n,{...r??{},config:{...e?.log,...t?.config,...r?.config??{}}}),s=(t,n,r)=>n?`${n}${t}${r?typeof r==`boolean`?e.RESET:r:e.RESET}`:t,c=(t,n=e.GREEN,r=e.RESET)=>[t].flat().map(e=>s(e,n,r)).join(`, `),l=(t,n=e.BEIGE,r=e.RESET)=>[t].flat().map(e=>s(e,n,r)).join(`, `),u=(t,n=e.GREY,r=e.RESET)=>[t].flat().map(e=>s(e,n,r)).join(`, `),d=(t,n={zero:e.BLUE,one:e.BLUE,two:e.BLUE,few:e.BLUE,many:e.BLUE,other:e.BLUE})=>{if(t===0){let e=n.zero??`\x1B[32m`;return s(t.toString(),e)}let r=n[new Intl.PluralRules(`en`).select(Number(t))];return s(t.toString(),r)},f=e=>e.replace(/\x1b\[[0-9;]*m/g,``),p=e=>{let t=0;return typeof e==`number`&&(t=e),typeof e==`string`&&(t=e.length),Array.isArray(e)&&e.every(e=>typeof e==`string`)&&(t=Math.max(...e.map(e=>e.length))),Array.isArray(e)&&e.every(e=>typeof e==`number`)&&(t=Math.max(...e)),Math.max(t,0)},m={colSize:0,minSize:0,maxSize:1/0,pad:`right`,padChar:`0`},h=(e,t)=>[e].flat().map(e=>{let{colSize:n,minSize:r,maxSize:i,pad:a}={...m,...t??{}},o=p(n),s=Math.max(r,Math.min(i,o-f(e).length));return a===`left`?`${` `.repeat(s)}${e}`:`${e}${` `.repeat(s)}`}).join(``),g=s(`✗`,e.RED),_=s(`✓`,e.GREEN),v=s(`⏲`,e.BLUE);exports.clock=v,exports.colon=h,exports.colorize=s,exports.colorizeKey=l,exports.colorizeLocales=c,exports.colorizeNumber=d,exports.colorizePath=u,exports.getAppLogger=o,exports.getPrefix=r,exports.logger=i,exports.removeColor=f,exports.setPrefix=n,exports.spinnerFrames=a,exports.v=_,exports.x=g;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_colors = require('./colors.cjs');
3
+
4
+ //#region src/logger.ts
5
+ let loggerPrefix;
6
+ const setPrefix = (prefix) => {
7
+ loggerPrefix = prefix;
8
+ };
9
+ const getPrefix = (configPrefix) => {
10
+ if (typeof loggerPrefix !== "undefined") return loggerPrefix;
11
+ return configPrefix;
12
+ };
13
+ const logger = (content, details) => {
14
+ const isVerbose = details?.isVerbose ?? false;
15
+ const mode = details?.config?.mode ?? "default";
16
+ const level = details?.level ?? "info";
17
+ const prefix = getPrefix(details?.config?.prefix);
18
+ const log = details?.config?.log ?? console.log;
19
+ const info = details?.config?.info ?? console.info;
20
+ const warn = details?.config?.warn ?? console.warn;
21
+ const error = details?.config?.error ?? console.error;
22
+ const debug = details?.config?.debug ?? console.debug;
23
+ if (mode === "disabled") return;
24
+ if (isVerbose && mode !== "verbose") return;
25
+ const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();
26
+ if (level === "debug") return debug(...flatContent);
27
+ if (level === "info") return info(...flatContent);
28
+ if (level === "warn") return warn(...flatContent);
29
+ if (level === "error") return error(...flatContent);
30
+ log(...flatContent);
31
+ };
32
+ const spinnerFrames = [
33
+ "⠋",
34
+ "⠙",
35
+ "⠹",
36
+ "⠸",
37
+ "⠼",
38
+ "⠴",
39
+ "⠦",
40
+ "⠧",
41
+ "⠇",
42
+ "⠏"
43
+ ];
44
+ /**
45
+ * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.
46
+ * It allows overriding the default configuration by passing a config object in the details parameter.
47
+ * The configuration is merged with the default configuration from the intlayer config file.
48
+ */
49
+ const getAppLogger = (configuration, globalDetails) => (content, details) => logger(content, {
50
+ ...details ?? {},
51
+ config: {
52
+ ...configuration?.log,
53
+ ...globalDetails?.config,
54
+ ...details?.config ?? {}
55
+ }
56
+ });
57
+ const colorize = (s, color, reset) => color ? `${color}${s}${reset ? typeof reset === "boolean" ? require_colors.RESET : reset : require_colors.RESET}` : s;
58
+ const colorizeLocales = (locales, color = require_colors.GREEN, reset = require_colors.RESET) => [locales].flat().map((locale) => colorize(locale, color, reset)).join(`, `);
59
+ const colorizeKey = (keyPath, color = require_colors.BEIGE, reset = require_colors.RESET) => [keyPath].flat().map((key) => colorize(key, color, reset)).join(`, `);
60
+ const colorizePath = (path, color = require_colors.GREY, reset = require_colors.RESET) => [path].flat().map((path) => colorize(path, color, reset)).join(`, `);
61
+ /**
62
+ * Colorize numeric value using Intl.NumberFormat and optional ANSI colors.
63
+ *
64
+ * Examples:
65
+ * colorizeNumber(2, [{ pluralRule: 'one' , color: ANSIColors.GREEN}, { pluralRule: 'other' , color: ANSIColors.RED}]) // "'\x1b[31m2\x1b[0m"
66
+ */
67
+ const colorizeNumber = (number, options = {
68
+ zero: require_colors.BLUE,
69
+ one: require_colors.BLUE,
70
+ two: require_colors.BLUE,
71
+ few: require_colors.BLUE,
72
+ many: require_colors.BLUE,
73
+ other: require_colors.BLUE
74
+ }) => {
75
+ if (number === 0) {
76
+ const color = options.zero ?? "\x1B[32m";
77
+ return colorize(number.toString(), color);
78
+ }
79
+ const color = options[new Intl.PluralRules("en").select(Number(number))];
80
+ return colorize(number.toString(), color);
81
+ };
82
+ const removeColor = (text) => text.replace(/\x1b\[[0-9;]*m/g, "");
83
+ const getLength = (length) => {
84
+ let value = 0;
85
+ if (typeof length === "number") value = length;
86
+ if (typeof length === "string") value = length.length;
87
+ if (Array.isArray(length) && length.every((l) => typeof l === "string")) value = Math.max(...length.map((str) => str.length));
88
+ if (Array.isArray(length) && length.every((l) => typeof l === "number")) value = Math.max(...length);
89
+ return Math.max(value, 0);
90
+ };
91
+ const defaultColonOptions = {
92
+ colSize: 0,
93
+ minSize: 0,
94
+ maxSize: Infinity,
95
+ pad: "right",
96
+ padChar: "0"
97
+ };
98
+ /**
99
+ * Create a string of spaces of a given length.
100
+ *
101
+ * @param colSize - The length of the string to create.
102
+ * @returns A string of spaces.
103
+ */
104
+ const colon = (text, options) => [text].flat().map((text) => {
105
+ const { colSize, minSize, maxSize, pad } = {
106
+ ...defaultColonOptions,
107
+ ...options ?? {}
108
+ };
109
+ const length = getLength(colSize);
110
+ const spacesLength = Math.max(minSize, Math.min(maxSize, length - removeColor(text).length));
111
+ if (pad === "left") return `${" ".repeat(spacesLength)}${text}`;
112
+ return `${text}${" ".repeat(spacesLength)}`;
113
+ }).join("");
114
+ const x = colorize("✗", require_colors.RED);
115
+ const v = colorize("✓", require_colors.GREEN);
116
+ const clock = colorize("⏲", require_colors.BLUE);
117
+
118
+ //#endregion
119
+ exports.clock = clock;
120
+ exports.colon = colon;
121
+ exports.colorize = colorize;
122
+ exports.colorizeKey = colorizeKey;
123
+ exports.colorizeLocales = colorizeLocales;
124
+ exports.colorizeNumber = colorizeNumber;
125
+ exports.colorizePath = colorizePath;
126
+ exports.getAppLogger = getAppLogger;
127
+ exports.getPrefix = getPrefix;
128
+ exports.logger = logger;
129
+ exports.removeColor = removeColor;
130
+ exports.setPrefix = setPrefix;
131
+ exports.spinnerFrames = spinnerFrames;
132
+ exports.v = v;
133
+ exports.x = x;
2
134
  //# sourceMappingURL=logger.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.cjs","names":[],"sources":["../../src/logger.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { CustomIntlayerConfig } from '@intlayer/types/config';\nimport * as ANSIColors from './colors';\n\nexport type ANSIColorsType = (typeof ANSIColors)[keyof typeof ANSIColors];\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 isVerbose = details?.isVerbose ?? false;\n const mode = details?.config?.mode ?? 'default';\n const level = details?.level ?? 'info';\n const prefix = getPrefix(details?.config?.prefix);\n const log = details?.config?.log ?? console.log;\n const info = details?.config?.info ?? console.info;\n const warn = details?.config?.warn ?? console.warn;\n const error = details?.config?.error ?? console.error;\n const debug = details?.config?.debug ?? console.debug;\n\n if (mode === 'disabled') return;\n\n if (isVerbose && mode !== 'verbose') return;\n\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n\n if (level === 'debug') {\n return debug(...flatContent);\n }\n\n if (level === 'info') {\n return info(...flatContent);\n }\n\n if (level === 'warn') {\n return warn(...flatContent);\n }\n\n if (level === 'error') {\n return error(...flatContent);\n }\n\n log(...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?: CustomIntlayerConfig, 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 s: string,\n color?: ANSIColorsType,\n reset?: boolean | ANSIColorsType\n): string =>\n color\n ? `${color}${s}${reset ? (typeof reset === 'boolean' ? ANSIColors.RESET : reset) : ANSIColors.RESET}`\n : s;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color = ANSIColors.GREEN,\n reset: boolean | ANSIColorsType = ANSIColors.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 = ANSIColors.BEIGE,\n reset: boolean | ANSIColorsType = ANSIColors.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 = ANSIColors.GREY,\n reset: boolean | ANSIColorsType = ANSIColors.RESET\n) =>\n [path]\n .flat()\n .map((path) => colorize(path, color, reset))\n .join(`, `);\n\n/**\n * Colorize numeric value using Intl.NumberFormat and optional ANSI colors.\n *\n * Examples:\n * colorizeNumber(2, [{ pluralRule: 'one' , color: ANSIColors.GREEN}, { pluralRule: 'other' , color: ANSIColors.RED}]) // \"'\\x1b[31m2\\x1b[0m\"\n */\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColorsType>> = {\n zero: ANSIColors.BLUE,\n one: ANSIColors.BLUE,\n two: ANSIColors.BLUE,\n few: ANSIColors.BLUE,\n many: ANSIColors.BLUE,\n other: ANSIColors.BLUE,\n }\n): string => {\n if (number === 0) {\n const color = options.zero ?? ANSIColors.GREEN;\n return colorize(number.toString(), color);\n }\n\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 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 (Array.isArray(length) && length.every((l) => typeof l === 'string')) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (Array.isArray(length) && length.every((l) => typeof l === 'number')) {\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('✗', ANSIColors.RED);\nexport const v = colorize('✓', ANSIColors.GREEN);\nexport const clock = colorize('⏲', ANSIColors.BLUE);\n"],"mappings":"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"}
1
+ {"version":3,"file":"logger.cjs","names":[],"sources":["../../src/logger.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { CustomIntlayerConfig } from '@intlayer/types/config';\nimport * as ANSIColors from './colors';\n\nexport type ANSIColorsType = (typeof ANSIColors)[keyof typeof ANSIColors];\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 isVerbose = details?.isVerbose ?? false;\n const mode = details?.config?.mode ?? 'default';\n const level = details?.level ?? 'info';\n const prefix = getPrefix(details?.config?.prefix);\n const log = details?.config?.log ?? console.log;\n const info = details?.config?.info ?? console.info;\n const warn = details?.config?.warn ?? console.warn;\n const error = details?.config?.error ?? console.error;\n const debug = details?.config?.debug ?? console.debug;\n\n if (mode === 'disabled') return;\n\n if (isVerbose && mode !== 'verbose') return;\n\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n\n if (level === 'debug') {\n return debug(...flatContent);\n }\n\n if (level === 'info') {\n return info(...flatContent);\n }\n\n if (level === 'warn') {\n return warn(...flatContent);\n }\n\n if (level === 'error') {\n return error(...flatContent);\n }\n\n log(...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?: CustomIntlayerConfig, 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 s: string,\n color?: ANSIColorsType,\n reset?: boolean | ANSIColorsType\n): string =>\n color\n ? `${color}${s}${reset ? (typeof reset === 'boolean' ? ANSIColors.RESET : reset) : ANSIColors.RESET}`\n : s;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color = ANSIColors.GREEN,\n reset: boolean | ANSIColorsType = ANSIColors.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 = ANSIColors.BEIGE,\n reset: boolean | ANSIColorsType = ANSIColors.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 = ANSIColors.GREY,\n reset: boolean | ANSIColorsType = ANSIColors.RESET\n) =>\n [path]\n .flat()\n .map((path) => colorize(path, color, reset))\n .join(`, `);\n\n/**\n * Colorize numeric value using Intl.NumberFormat and optional ANSI colors.\n *\n * Examples:\n * colorizeNumber(2, [{ pluralRule: 'one' , color: ANSIColors.GREEN}, { pluralRule: 'other' , color: ANSIColors.RED}]) // \"'\\x1b[31m2\\x1b[0m\"\n */\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColorsType>> = {\n zero: ANSIColors.BLUE,\n one: ANSIColors.BLUE,\n two: ANSIColors.BLUE,\n few: ANSIColors.BLUE,\n many: ANSIColors.BLUE,\n other: ANSIColors.BLUE,\n }\n): string => {\n if (number === 0) {\n const color = options.zero ?? ANSIColors.GREEN;\n return colorize(number.toString(), color);\n }\n\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 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 (Array.isArray(length) && length.every((l) => typeof l === 'string')) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (Array.isArray(length) && length.every((l) => typeof l === 'number')) {\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('✗', ANSIColors.RED);\nexport const v = colorize('✓', ANSIColors.GREEN);\nexport const clock = colorize('⏲', ANSIColors.BLUE);\n"],"mappings":"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"}
package/dist/cjs/node.cjs CHANGED
@@ -1 +1,28 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./configFile/buildConfigurationFields.cjs`),t=require(`./configFile/configurationSchema.cjs`),n=require(`./configFile/searchConfigurationFile.cjs`),r=require(`./configFile/getConfiguration.cjs`);exports.aiSchema=t.aiSchema,exports.buildConfigurationFields=e.buildConfigurationFields,exports.buildSchema=t.buildSchema,exports.compilerSchema=t.compilerSchema,exports.configurationFilesCandidates=n.configurationFilesCandidates,exports.contentSchema=t.contentSchema,exports.cookiesAttributesSchema=t.cookiesAttributesSchema,exports.dictionarySchema=t.dictionarySchema,exports.editorSchema=t.editorSchema,exports.getConfiguration=r.getConfiguration,exports.getConfigurationAndFilePath=r.getConfigurationAndFilePath,exports.internationalizationSchema=t.internationalizationSchema,exports.intlayerConfigSchema=t.intlayerConfigSchema,exports.logSchema=t.logSchema,exports.rewriteObjectSchema=t.rewriteObjectSchema,exports.rewriteRuleSchema=t.rewriteRuleSchema,exports.rewriteRulesSchema=t.rewriteRulesSchema,exports.routingSchema=t.routingSchema,exports.searchConfigurationFile=n.searchConfigurationFile,exports.storageAttributesSchema=t.storageAttributesSchema,exports.storageSchema=t.storageSchema,exports.systemSchema=t.systemSchema;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_configFile_configurationSchema = require('./configFile/configurationSchema.cjs');
3
+ const require_configFile_buildConfigurationFields = require('./configFile/buildConfigurationFields.cjs');
4
+ const require_configFile_searchConfigurationFile = require('./configFile/searchConfigurationFile.cjs');
5
+ const require_configFile_getConfiguration = require('./configFile/getConfiguration.cjs');
6
+
7
+ exports.aiSchema = require_configFile_configurationSchema.aiSchema;
8
+ exports.buildConfigurationFields = require_configFile_buildConfigurationFields.buildConfigurationFields;
9
+ exports.buildSchema = require_configFile_configurationSchema.buildSchema;
10
+ exports.compilerSchema = require_configFile_configurationSchema.compilerSchema;
11
+ exports.configurationFilesCandidates = require_configFile_searchConfigurationFile.configurationFilesCandidates;
12
+ exports.contentSchema = require_configFile_configurationSchema.contentSchema;
13
+ exports.cookiesAttributesSchema = require_configFile_configurationSchema.cookiesAttributesSchema;
14
+ exports.dictionarySchema = require_configFile_configurationSchema.dictionarySchema;
15
+ exports.editorSchema = require_configFile_configurationSchema.editorSchema;
16
+ exports.getConfiguration = require_configFile_getConfiguration.getConfiguration;
17
+ exports.getConfigurationAndFilePath = require_configFile_getConfiguration.getConfigurationAndFilePath;
18
+ exports.internationalizationSchema = require_configFile_configurationSchema.internationalizationSchema;
19
+ exports.intlayerConfigSchema = require_configFile_configurationSchema.intlayerConfigSchema;
20
+ exports.logSchema = require_configFile_configurationSchema.logSchema;
21
+ exports.rewriteObjectSchema = require_configFile_configurationSchema.rewriteObjectSchema;
22
+ exports.rewriteRuleSchema = require_configFile_configurationSchema.rewriteRuleSchema;
23
+ exports.rewriteRulesSchema = require_configFile_configurationSchema.rewriteRulesSchema;
24
+ exports.routingSchema = require_configFile_configurationSchema.routingSchema;
25
+ exports.searchConfigurationFile = require_configFile_searchConfigurationFile.searchConfigurationFile;
26
+ exports.storageAttributesSchema = require_configFile_configurationSchema.storageAttributesSchema;
27
+ exports.storageSchema = require_configFile_configurationSchema.storageSchema;
28
+ exports.systemSchema = require_configFile_configurationSchema.systemSchema;
@@ -1,2 +1,28 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`./getPackageJsonPath.cjs`);let t=require(`node:module`);const n=typeof require(`url`).pathToFileURL(__filename).href==`string`,r=n=>{let{packageJsonPath:r}=e.getPackageJsonPath(n);return(0,t.createRequire)(r)},i=n?(0,t.createRequire)(require(`url`).pathToFileURL(__filename).href):require;exports.configESMxCJSRequire=i,exports.getProjectRequire=r,exports.isESModule=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_utils_getPackageJsonPath = require('./getPackageJsonPath.cjs');
4
+ let node_module = require("node:module");
5
+
6
+ //#region src/utils/ESMxCJSHelpers.ts
7
+ const isESModule = typeof require("url").pathToFileURL(__filename).href === "string";
8
+ /**
9
+ * Require relative to the user project
10
+ *
11
+ * Note: Can resolve package that are installed in the user project, ex `'intlayer'`
12
+ */
13
+ const getProjectRequire = (startDir) => {
14
+ const { packageJsonPath } = require_utils_getPackageJsonPath.getPackageJsonPath(startDir);
15
+ return (0, node_module.createRequire)(packageJsonPath);
16
+ };
17
+ /**
18
+ * Require relative to the @intlayer/config package
19
+ *
20
+ * Note: Can resolve package that are installed in the config package, ex `'@intlayer/types'`
21
+ */
22
+ const configESMxCJSRequire = isESModule ? (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href) : require;
23
+
24
+ //#endregion
25
+ exports.configESMxCJSRequire = configESMxCJSRequire;
26
+ exports.getProjectRequire = getProjectRequire;
27
+ exports.isESModule = isESModule;
2
28
  //# sourceMappingURL=ESMxCJSHelpers.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ESMxCJSHelpers.cjs","names":["getPackageJsonPath"],"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":"6KAGA,MAAa,EAAa,OAAA,QAAA,MAAA,CAAA,cAAA,WAAA,CAAA,MAA2B,SAOxC,EAAqB,GAAsC,CAEtE,GAAM,CAAE,mBAAoBA,EAAAA,mBAAmB,EAAS,CAExD,OAAA,EAAA,EAAA,eAAqB,EAAgB,EAQ1B,EAAuC,GAAA,EAAA,EAAA,eAAA,QAAA,MAAA,CAAA,cAAA,WAAA,CAAA,KAClB,CAC9B"}
1
+ {"version":3,"file":"ESMxCJSHelpers.cjs","names":["getPackageJsonPath"],"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,yDAA2B;;;;;;AAOrD,MAAa,qBAAqB,aAAsC;CAEtE,MAAM,EAAE,oBAAoBA,oDAAmB,SAAS;AAExD,uCAAqB,gBAAgB;;;;;;;AAQvC,MAAa,uBAAuC,0FAClB,GAC9B"}
@@ -1,2 +1,30 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`./getExtension.cjs`),t=require(`./normalizePath.cjs`);let n=require(`node:path`);const r=({configuration:r,format:i,formatter:a=e=>e})=>{let o=e.getExtension(r,i??r.build.outputFormat[0]??`esm`),{baseDir:s}=r.system,{mainDir:c,configDir:l}=r.system,u=a(t.normalizePath((0,n.relative)(s,(0,n.join)(c,`dictionaries.${o}`)))),d=a(t.normalizePath((0,n.relative)(s,(0,n.join)(c,`unmerged_dictionaries.${o}`)))),f=a(t.normalizePath((0,n.relative)(s,(0,n.join)(c,`remote_dictionaries.${o}`)))),p=a(t.normalizePath((0,n.relative)(s,(0,n.join)(c,`dynamic_dictionaries.${o}`)))),m=a(t.normalizePath((0,n.relative)(s,(0,n.join)(c,`fetch_dictionaries.${o}`)))),h=a(t.normalizePath((0,n.relative)(s,(0,n.join)(l,`configuration.json`))));return{"@intlayer/dictionaries-entry":u,"@intlayer/unmerged-dictionaries-entry":d,"@intlayer/remote-dictionaries-entry":f,"@intlayer/dynamic-dictionaries-entry":p,"@intlayer/fetch-dictionaries-entry":m,"@intlayer/config/built":h}};exports.getAlias=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_utils_getExtension = require('./getExtension.cjs');
4
+ const require_utils_normalizePath = require('./normalizePath.cjs');
5
+ let node_path = require("node:path");
6
+
7
+ //#region src/utils/alias.ts
8
+ const getAlias = ({ configuration, format, formatter = (value) => value }) => {
9
+ const extension = require_utils_getExtension.getExtension(configuration, format ?? configuration.build.outputFormat[0] ?? "esm");
10
+ const { baseDir } = configuration.system;
11
+ const { mainDir, configDir } = configuration.system;
12
+ const fixedDictionariesPath = formatter(require_utils_normalizePath.normalizePath((0, node_path.relative)(baseDir, (0, node_path.join)(mainDir, `dictionaries.${extension}`))));
13
+ const fixedUnmergedDictionariesPath = formatter(require_utils_normalizePath.normalizePath((0, node_path.relative)(baseDir, (0, node_path.join)(mainDir, `unmerged_dictionaries.${extension}`))));
14
+ const fixedRemoteDictionariesPath = formatter(require_utils_normalizePath.normalizePath((0, node_path.relative)(baseDir, (0, node_path.join)(mainDir, `remote_dictionaries.${extension}`))));
15
+ const fixedDynamicDictionariesPath = formatter(require_utils_normalizePath.normalizePath((0, node_path.relative)(baseDir, (0, node_path.join)(mainDir, `dynamic_dictionaries.${extension}`))));
16
+ const fixedFetchDictionariesPath = formatter(require_utils_normalizePath.normalizePath((0, node_path.relative)(baseDir, (0, node_path.join)(mainDir, `fetch_dictionaries.${extension}`))));
17
+ const fixedConfigurationPath = formatter(require_utils_normalizePath.normalizePath((0, node_path.relative)(baseDir, (0, node_path.join)(configDir, `configuration.json`))));
18
+ return {
19
+ "@intlayer/dictionaries-entry": fixedDictionariesPath,
20
+ "@intlayer/unmerged-dictionaries-entry": fixedUnmergedDictionariesPath,
21
+ "@intlayer/remote-dictionaries-entry": fixedRemoteDictionariesPath,
22
+ "@intlayer/dynamic-dictionaries-entry": fixedDynamicDictionariesPath,
23
+ "@intlayer/fetch-dictionaries-entry": fixedFetchDictionariesPath,
24
+ "@intlayer/config/built": fixedConfigurationPath
25
+ };
26
+ };
27
+
28
+ //#endregion
29
+ exports.getAlias = getAlias;
2
30
  //# sourceMappingURL=alias.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"alias.cjs","names":["getExtension","normalizePath"],"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.json`);\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":"sMAWA,MAAa,GAAY,CACvB,gBACA,SACA,YAAa,GAAkB,KACV,CACrB,IAAM,EAAYA,EAAAA,aAChB,EACA,GAAU,EAAc,MAAM,aAAa,IAAM,MAClD,CAEK,CAAE,WAAY,EAAc,OAC5B,CAAE,UAAS,aAAc,EAAc,OAOvC,EAAwB,EAC5BC,EAAAA,eAAAA,EAAAA,EAAAA,UAFwC,GAAA,EAAA,EAAA,MADZ,EAAS,gBAAgB,IAAY,CACC,CAE3B,CACxC,CAaK,EAAgC,EACpCA,EAAAA,eAAAA,EAAAA,EAAAA,UAJA,GAAA,EAAA,EAAA,MAJA,EACA,yBAAyB,IAC1B,CAIA,CAEgD,CAChD,CAaK,EAA8B,EAClCA,EAAAA,eAAAA,EAAAA,EAAAA,UAJA,GAAA,EAAA,EAAA,MAJA,EACA,uBAAuB,IACxB,CAIA,CAE8C,CAC9C,CAaK,EAA+B,EACnCA,EAAAA,eAAAA,EAAAA,EAAAA,UAJA,GAAA,EAAA,EAAA,MAJA,EACA,wBAAwB,IACzB,CAIA,CAE+C,CAC/C,CAaK,EAA6B,EACjCA,EAAAA,eAAAA,EAAAA,EAAAA,UAJA,GAAA,EAAA,EAAA,MAJA,EACA,sBAAsB,IACvB,CAIA,CAE6C,CAC7C,CAOK,EAAyB,EAC7BA,EAAAA,eAAAA,EAAAA,EAAAA,UAFyC,GAAA,EAAA,EAAA,MADZ,EAAW,qBAAqB,CACO,CAE5B,CACzC,CAED,MAAO,CACL,+BAAgC,EAChC,wCAAyC,EACzC,sCAAuC,EACvC,uCAAwC,EACxC,qCAAsC,EACtC,yBAA0B,EAC3B"}
1
+ {"version":3,"file":"alias.cjs","names":["getExtension","normalizePath"],"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.json`);\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,YAAYA,wCAChB,eACA,UAAU,cAAc,MAAM,aAAa,MAAM,MAClD;CAED,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,SAAS,cAAc,cAAc;CAO7C,MAAM,wBAAwB,UAC5BC,kEAFwC,6BADZ,SAAS,gBAAgB,YAAY,CACC,CAE3B,CACxC;CAaD,MAAM,gCAAgC,UACpCA,kEAJA,6BAJA,SACA,yBAAyB,YAC1B,CAIA,CAEgD,CAChD;CAaD,MAAM,8BAA8B,UAClCA,kEAJA,6BAJA,SACA,uBAAuB,YACxB,CAIA,CAE8C,CAC9C;CAaD,MAAM,+BAA+B,UACnCA,kEAJA,6BAJA,SACA,wBAAwB,YACzB,CAIA,CAE+C,CAC/C;CAaD,MAAM,6BAA6B,UACjCA,kEAJA,6BAJA,SACA,sBAAsB,YACvB,CAIA,CAE6C,CAC7C;CAOD,MAAM,yBAAyB,UAC7BA,kEAFyC,6BADZ,WAAW,qBAAqB,CACO,CAE5B,CACzC;AAED,QAAO;EACL,gCAAgC;EAChC,yCAAyC;EACzC,uCAAuC;EACvC,wCAAwC;EACxC,sCAAsC;EACtC,0BAA0B;EAC3B"}