@intlayer/config 9.0.0-canary.16 → 9.0.0-canary.18

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 (232) hide show
  1. package/dist/cjs/built.cjs.map +1 -1
  2. package/dist/cjs/bundle/index.cjs.map +1 -1
  3. package/dist/cjs/bundle/logBundle.cjs.map +1 -1
  4. package/dist/cjs/callers/base.cjs.map +1 -1
  5. package/dist/cjs/callers/compat/i18next.cjs.map +1 -1
  6. package/dist/cjs/callers/compat/lingui.cjs.map +1 -1
  7. package/dist/cjs/callers/compat/nextIntl.cjs.map +1 -1
  8. package/dist/cjs/callers/compat/reactI18next.cjs.map +1 -1
  9. package/dist/cjs/callers/compat/reactIntl.cjs.map +1 -1
  10. package/dist/cjs/callers/compat/useIntl.cjs.map +1 -1
  11. package/dist/cjs/callers/compat/vueI18n.cjs.map +1 -1
  12. package/dist/cjs/callers/index.cjs.map +1 -1
  13. package/dist/cjs/callers/transform.cjs.map +1 -1
  14. package/dist/cjs/configFile/buildBrowserConfiguration.cjs.map +1 -1
  15. package/dist/cjs/configFile/buildConfigurationFields.cjs +0 -1
  16. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  17. package/dist/cjs/configFile/configurationSchema.cjs.map +1 -1
  18. package/dist/cjs/configFile/getConfiguration.cjs +0 -1
  19. package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
  20. package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
  21. package/dist/cjs/configFile/searchConfigurationFile.cjs +0 -1
  22. package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
  23. package/dist/cjs/defaultValues/build.cjs.map +1 -1
  24. package/dist/cjs/defaultValues/content.cjs.map +1 -1
  25. package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
  26. package/dist/cjs/defaultValues/routing.cjs.map +1 -1
  27. package/dist/cjs/envVars/envVars.cjs.map +1 -1
  28. package/dist/cjs/loadEnvFile.cjs.map +1 -1
  29. package/dist/cjs/loadExternalFile/bundleFile.cjs +4 -3
  30. package/dist/cjs/loadExternalFile/bundleFile.cjs.map +1 -1
  31. package/dist/cjs/loadExternalFile/bundleJSFile.cjs +0 -1
  32. package/dist/cjs/loadExternalFile/bundleJSFile.cjs.map +1 -1
  33. package/dist/cjs/loadExternalFile/loadExternalFile.cjs +4 -1
  34. package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
  35. package/dist/cjs/loadExternalFile/parseFileContent.cjs.map +1 -1
  36. package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs +0 -1
  37. package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs.map +1 -1
  38. package/dist/cjs/logger.cjs +2 -1
  39. package/dist/cjs/logger.cjs.map +1 -1
  40. package/dist/cjs/utils/ESMxCJSHelpers.cjs +0 -1
  41. package/dist/cjs/utils/ESMxCJSHelpers.cjs.map +1 -1
  42. package/dist/cjs/utils/alias.cjs +0 -1
  43. package/dist/cjs/utils/alias.cjs.map +1 -1
  44. package/dist/cjs/utils/cacheDisk.cjs +2 -1
  45. package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
  46. package/dist/cjs/utils/cacheMemory.cjs +0 -1
  47. package/dist/cjs/utils/cacheMemory.cjs.map +1 -1
  48. package/dist/cjs/utils/clearModuleCache.cjs.map +1 -1
  49. package/dist/cjs/utils/compareVersions.cjs.map +1 -1
  50. package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
  51. package/dist/cjs/utils/getDictionarySelectorUsage.cjs.map +1 -1
  52. package/dist/cjs/utils/getExtension.cjs.map +1 -1
  53. package/dist/cjs/utils/getPackageJsonPath.cjs +0 -1
  54. package/dist/cjs/utils/getPackageJsonPath.cjs.map +1 -1
  55. package/dist/cjs/utils/getStorageAttributes.cjs +2 -1
  56. package/dist/cjs/utils/getStorageAttributes.cjs.map +1 -1
  57. package/dist/cjs/utils/getUsedNodeTypes.cjs +0 -1
  58. package/dist/cjs/utils/getUsedNodeTypes.cjs.map +1 -1
  59. package/dist/cjs/utils/logStack.cjs.map +1 -1
  60. package/dist/cjs/utils/normalizePath.cjs.map +1 -1
  61. package/dist/cjs/utils/parseFilePathPattern.cjs.map +1 -1
  62. package/dist/cjs/utils/pathSecurity.cjs +0 -1
  63. package/dist/cjs/utils/pathSecurity.cjs.map +1 -1
  64. package/dist/cjs/utils/retryManager.cjs.map +1 -1
  65. package/dist/cjs/utils/setIntlayerIdentifier.cjs.map +1 -1
  66. package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs.map +1 -1
  67. package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs.map +1 -1
  68. package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs.map +1 -1
  69. package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs.map +1 -1
  70. package/dist/esm/built.mjs.map +1 -1
  71. package/dist/esm/bundle/index.mjs +3 -3
  72. package/dist/esm/bundle/index.mjs.map +1 -1
  73. package/dist/esm/bundle/logBundle.mjs.map +1 -1
  74. package/dist/esm/callers/base.mjs.map +1 -1
  75. package/dist/esm/callers/compat/i18next.mjs.map +1 -1
  76. package/dist/esm/callers/compat/lingui.mjs.map +1 -1
  77. package/dist/esm/callers/compat/nextIntl.mjs.map +1 -1
  78. package/dist/esm/callers/compat/reactI18next.mjs.map +1 -1
  79. package/dist/esm/callers/compat/reactIntl.mjs.map +1 -1
  80. package/dist/esm/callers/compat/useIntl.mjs.map +1 -1
  81. package/dist/esm/callers/compat/vueI18n.mjs.map +1 -1
  82. package/dist/esm/callers/index.mjs.map +1 -1
  83. package/dist/esm/callers/transform.mjs.map +1 -1
  84. package/dist/esm/configFile/buildBrowserConfiguration.mjs.map +1 -1
  85. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  86. package/dist/esm/configFile/configurationSchema.mjs.map +1 -1
  87. package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
  88. package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
  89. package/dist/esm/configFile/searchConfigurationFile.mjs.map +1 -1
  90. package/dist/esm/defaultValues/build.mjs.map +1 -1
  91. package/dist/esm/defaultValues/content.mjs.map +1 -1
  92. package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
  93. package/dist/esm/defaultValues/routing.mjs.map +1 -1
  94. package/dist/esm/envVars/envVars.mjs.map +1 -1
  95. package/dist/esm/loadEnvFile.mjs.map +1 -1
  96. package/dist/esm/loadExternalFile/bundleFile.mjs +4 -2
  97. package/dist/esm/loadExternalFile/bundleFile.mjs.map +1 -1
  98. package/dist/esm/loadExternalFile/bundleJSFile.mjs.map +1 -1
  99. package/dist/esm/loadExternalFile/loadExternalFile.mjs +4 -1
  100. package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
  101. package/dist/esm/loadExternalFile/parseFileContent.mjs.map +1 -1
  102. package/dist/esm/loadExternalFile/transpileTSToCJS.mjs.map +1 -1
  103. package/dist/esm/logger.mjs +2 -1
  104. package/dist/esm/logger.mjs.map +1 -1
  105. package/dist/esm/utils/ESMxCJSHelpers.mjs.map +1 -1
  106. package/dist/esm/utils/alias.mjs.map +1 -1
  107. package/dist/esm/utils/cacheDisk.mjs +6 -5
  108. package/dist/esm/utils/cacheDisk.mjs.map +1 -1
  109. package/dist/esm/utils/cacheMemory.mjs.map +1 -1
  110. package/dist/esm/utils/clearModuleCache.mjs.map +1 -1
  111. package/dist/esm/utils/compareVersions.mjs.map +1 -1
  112. package/dist/esm/utils/extractErrorMessage.mjs.map +1 -1
  113. package/dist/esm/utils/getDictionarySelectorUsage.mjs.map +1 -1
  114. package/dist/esm/utils/getExtension.mjs.map +1 -1
  115. package/dist/esm/utils/getPackageJsonPath.mjs.map +1 -1
  116. package/dist/esm/utils/getStorageAttributes.mjs +2 -1
  117. package/dist/esm/utils/getStorageAttributes.mjs.map +1 -1
  118. package/dist/esm/utils/getUsedNodeTypes.mjs.map +1 -1
  119. package/dist/esm/utils/logStack.mjs.map +1 -1
  120. package/dist/esm/utils/normalizePath.mjs.map +1 -1
  121. package/dist/esm/utils/parseFilePathPattern.mjs.map +1 -1
  122. package/dist/esm/utils/pathSecurity.mjs.map +1 -1
  123. package/dist/esm/utils/retryManager.mjs.map +1 -1
  124. package/dist/esm/utils/setIntlayerIdentifier.mjs.map +1 -1
  125. package/dist/esm/utils/stringFormatter/camelCaseToKebabCase.mjs.map +1 -1
  126. package/dist/esm/utils/stringFormatter/camelCaseToSentence.mjs.map +1 -1
  127. package/dist/esm/utils/stringFormatter/kebabCaseToCamelCase.mjs.map +1 -1
  128. package/dist/esm/utils/stringFormatter/toLowerCamelCase.mjs.map +1 -1
  129. package/dist/types/built.d.ts.map +1 -1
  130. package/dist/types/bundle/index.d.ts +2 -4
  131. package/dist/types/bundle/index.d.ts.map +1 -1
  132. package/dist/types/bundle/logBundle.d.ts +0 -1
  133. package/dist/types/bundle/logBundle.d.ts.map +1 -1
  134. package/dist/types/callers/base.d.ts +0 -1
  135. package/dist/types/callers/base.d.ts.map +1 -1
  136. package/dist/types/callers/compat/i18next.d.ts +0 -1
  137. package/dist/types/callers/compat/i18next.d.ts.map +1 -1
  138. package/dist/types/callers/compat/lingui.d.ts +0 -1
  139. package/dist/types/callers/compat/lingui.d.ts.map +1 -1
  140. package/dist/types/callers/compat/nextIntl.d.ts +0 -1
  141. package/dist/types/callers/compat/nextIntl.d.ts.map +1 -1
  142. package/dist/types/callers/compat/reactI18next.d.ts +0 -1
  143. package/dist/types/callers/compat/reactI18next.d.ts.map +1 -1
  144. package/dist/types/callers/compat/reactIntl.d.ts +0 -1
  145. package/dist/types/callers/compat/reactIntl.d.ts.map +1 -1
  146. package/dist/types/callers/compat/useIntl.d.ts +0 -1
  147. package/dist/types/callers/compat/useIntl.d.ts.map +1 -1
  148. package/dist/types/callers/compat/vueI18n.d.ts +0 -1
  149. package/dist/types/callers/compat/vueI18n.d.ts.map +1 -1
  150. package/dist/types/callers/index.d.ts +0 -1
  151. package/dist/types/callers/index.d.ts.map +1 -1
  152. package/dist/types/callers/transform.d.ts +7 -4
  153. package/dist/types/callers/transform.d.ts.map +1 -1
  154. package/dist/types/callers/types.d.ts +17 -9
  155. package/dist/types/callers/types.d.ts.map +1 -1
  156. package/dist/types/colors.d.ts +14 -14
  157. package/dist/types/colors.d.ts.map +1 -1
  158. package/dist/types/configFile/buildBrowserConfiguration.d.ts +0 -1
  159. package/dist/types/configFile/buildBrowserConfiguration.d.ts.map +1 -1
  160. package/dist/types/configFile/buildConfigurationFields.d.ts +0 -1
  161. package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
  162. package/dist/types/configFile/configurationSchema.d.ts +32 -33
  163. package/dist/types/configFile/configurationSchema.d.ts.map +1 -1
  164. package/dist/types/configFile/getConfiguration.d.ts +0 -1
  165. package/dist/types/configFile/getConfiguration.d.ts.map +1 -1
  166. package/dist/types/configFile/index.d.ts +1 -1
  167. package/dist/types/configFile/loadConfigurationFile.d.ts +1 -2
  168. package/dist/types/configFile/loadConfigurationFile.d.ts.map +1 -1
  169. package/dist/types/configFile/searchConfigurationFile.d.ts +1 -1
  170. package/dist/types/configFile/searchConfigurationFile.d.ts.map +1 -1
  171. package/dist/types/defaultValues/analytics.d.ts.map +1 -1
  172. package/dist/types/defaultValues/build.d.ts.map +1 -1
  173. package/dist/types/defaultValues/compiler.d.ts.map +1 -1
  174. package/dist/types/defaultValues/content.d.ts.map +1 -1
  175. package/dist/types/defaultValues/dictionary.d.ts +0 -1
  176. package/dist/types/defaultValues/dictionary.d.ts.map +1 -1
  177. package/dist/types/defaultValues/editor.d.ts.map +1 -1
  178. package/dist/types/defaultValues/internationalization.d.ts +0 -1
  179. package/dist/types/defaultValues/internationalization.d.ts.map +1 -1
  180. package/dist/types/defaultValues/log.d.ts.map +1 -1
  181. package/dist/types/defaultValues/routing.d.ts +0 -1
  182. package/dist/types/defaultValues/routing.d.ts.map +1 -1
  183. package/dist/types/defaultValues/system.d.ts.map +1 -1
  184. package/dist/types/envVars/envVars.d.ts +0 -1
  185. package/dist/types/envVars/envVars.d.ts.map +1 -1
  186. package/dist/types/loadEnvFile.d.ts.map +1 -1
  187. package/dist/types/loadExternalFile/bundleFile.d.ts +0 -1
  188. package/dist/types/loadExternalFile/bundleFile.d.ts.map +1 -1
  189. package/dist/types/loadExternalFile/bundleJSFile.d.ts +57 -59
  190. package/dist/types/loadExternalFile/bundleJSFile.d.ts.map +1 -1
  191. package/dist/types/loadExternalFile/loadExternalFile.d.ts +0 -1
  192. package/dist/types/loadExternalFile/loadExternalFile.d.ts.map +1 -1
  193. package/dist/types/loadExternalFile/parseFileContent.d.ts +0 -1
  194. package/dist/types/loadExternalFile/parseFileContent.d.ts.map +1 -1
  195. package/dist/types/loadExternalFile/transpileTSToCJS.d.ts +1 -3
  196. package/dist/types/loadExternalFile/transpileTSToCJS.d.ts.map +1 -1
  197. package/dist/types/logger.d.ts +2 -3
  198. package/dist/types/logger.d.ts.map +1 -1
  199. package/dist/types/node.d.ts +1 -1
  200. package/dist/types/utils/ESMxCJSHelpers.d.ts.map +1 -1
  201. package/dist/types/utils/alias.d.ts +1 -6
  202. package/dist/types/utils/alias.d.ts.map +1 -1
  203. package/dist/types/utils/cacheDisk.d.ts +22 -11
  204. package/dist/types/utils/cacheDisk.d.ts.map +1 -1
  205. package/dist/types/utils/cacheMemory.d.ts +3 -3
  206. package/dist/types/utils/cacheMemory.d.ts.map +1 -1
  207. package/dist/types/utils/clearModuleCache.d.ts.map +1 -1
  208. package/dist/types/utils/compareVersions.d.ts +1 -1
  209. package/dist/types/utils/compareVersions.d.ts.map +1 -1
  210. package/dist/types/utils/extractErrorMessage.d.ts.map +1 -1
  211. package/dist/types/utils/getDictionarySelectorUsage.d.ts +0 -1
  212. package/dist/types/utils/getDictionarySelectorUsage.d.ts.map +1 -1
  213. package/dist/types/utils/getExtension.d.ts +1 -2
  214. package/dist/types/utils/getExtension.d.ts.map +1 -1
  215. package/dist/types/utils/getPackageJsonPath.d.ts.map +1 -1
  216. package/dist/types/utils/getStorageAttributes.d.ts +0 -1
  217. package/dist/types/utils/getStorageAttributes.d.ts.map +1 -1
  218. package/dist/types/utils/getUsedNodeTypes.d.ts +0 -1
  219. package/dist/types/utils/getUsedNodeTypes.d.ts.map +1 -1
  220. package/dist/types/utils/logStack.d.ts.map +1 -1
  221. package/dist/types/utils/normalizePath.d.ts.map +1 -1
  222. package/dist/types/utils/parseFilePathPattern.d.ts +0 -1
  223. package/dist/types/utils/parseFilePathPattern.d.ts.map +1 -1
  224. package/dist/types/utils/pathSecurity.d.ts.map +1 -1
  225. package/dist/types/utils/retryManager.d.ts +8 -9
  226. package/dist/types/utils/retryManager.d.ts.map +1 -1
  227. package/dist/types/utils/setIntlayerIdentifier.d.ts.map +1 -1
  228. package/dist/types/utils/stringFormatter/camelCaseToKebabCase.d.ts.map +1 -1
  229. package/dist/types/utils/stringFormatter/camelCaseToSentence.d.ts.map +1 -1
  230. package/dist/types/utils/stringFormatter/kebabCaseToCamelCase.d.ts.map +1 -1
  231. package/dist/types/utils/stringFormatter/toLowerCamelCase.d.ts.map +1 -1
  232. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"configurationSchema.cjs","names":["z","AiProviders"],"sources":["../../../src/configFile/configurationSchema.ts"],"sourcesContent":["import { AiProviders } from '@intlayer/types/config';\nimport z from 'zod';\n\nexport const internationalizationSchema = z.object({\n locales: z.array(z.string()).min(1),\n requiredLocales: z.array(z.string()).optional(),\n strictMode: z.enum(['strict', 'inclusive', 'loose']).optional(),\n defaultLocale: z.string().optional(),\n});\n\n/**\n * Cross-realm-safe `Date` check.\n *\n * Configuration files are executed inside a `node:vm` sandbox, so a `Date`\n * created there is an instance of the sandbox realm's `Date`, not the host\n * realm's. `instanceof Date` (used by `z.date()`) therefore returns `false`\n * for those values, which would reject a perfectly valid `Date`.\n */\nconst isDateLike = (value: unknown): value is Date =>\n value instanceof Date ||\n Object.prototype.toString.call(value) === '[object Date]';\n\n/**\n * Cookie expiry: a number of days, an absolute `Date`, or an ISO date string\n * (the form a `Date` takes once the configuration is serialized).\n */\nconst cookieExpiresSchema = z.union([\n z.custom<Date>(isDateLike, { message: 'Expected a Date' }),\n z.number(),\n z.string().refine((value) => !Number.isNaN(Date.parse(value)), {\n message: 'Expected a valid date string',\n }),\n]);\n\nexport const cookiesAttributesSchema = z.object({\n type: z.literal('cookie'),\n name: z.string().optional(),\n domain: z.string().optional(),\n path: z.string().optional(),\n secure: z.boolean().optional(),\n httpOnly: z.boolean().optional(),\n sameSite: z.enum(['strict', 'lax', 'none']).optional(),\n expires: cookieExpiresSchema.optional(),\n maxAge: z.number().optional(),\n});\n\nexport const storageAttributesSchema = z.object({\n type: z.enum(['localStorage', 'sessionStorage', 'header']),\n name: z.string().optional(),\n});\n\nexport const storageSchema = z.union([\n z.literal(false),\n z.enum(['cookie', 'localStorage', 'sessionStorage', 'header']),\n cookiesAttributesSchema,\n storageAttributesSchema,\n z.array(\n z.union([\n z.enum(['cookie', 'localStorage', 'sessionStorage', 'header']),\n cookiesAttributesSchema,\n storageAttributesSchema,\n ])\n ),\n]);\n\nexport const rewriteRuleSchema = z.object({\n canonical: z.string(),\n localized: z.record(z.string(), z.string()),\n});\n\nexport const rewriteRulesSchema = z.object({\n rules: z.array(rewriteRuleSchema),\n});\n\nexport const rewriteObjectSchema = z.object({\n url: rewriteRulesSchema,\n nextjs: rewriteRulesSchema.optional(),\n vite: rewriteRulesSchema.optional(),\n});\n\nexport const routingSchema = z.object({\n rewrite: z\n .union([\n z.record(z.string(), z.record(z.string(), z.string())),\n rewriteObjectSchema,\n ])\n .optional(),\n mode: z\n .enum(['prefix-no-default', 'prefix-all', 'no-prefix', 'search-params'])\n .optional(),\n enableProxy: z.boolean().optional(),\n storage: storageSchema.optional(),\n basePath: z.string().optional(),\n domains: z.record(z.string(), z.string()).optional(),\n});\n\nexport const systemSchema = z.object({\n baseDir: z.string().optional(),\n moduleAugmentationDir: z.string().optional(),\n unmergedDictionariesDir: z.string().optional(),\n remoteDictionariesDir: z.string().optional(),\n dictionariesDir: z.string().optional(),\n dynamicDictionariesDir: z.string().optional(),\n fetchDictionariesDir: z.string().optional(),\n typesDir: z.string().optional(),\n mainDir: z.string().optional(),\n configDir: z.string().optional(),\n cacheDir: z.string().optional(),\n tempDir: z.string().optional(),\n});\n\nexport const contentSchema = z.object({\n fileExtensions: z.array(z.string()).optional(),\n contentDir: z.array(z.string()).optional(),\n codeDir: z.array(z.string()).optional(),\n excludedPath: z.array(z.string()).optional(),\n watch: z.boolean().optional(),\n formatCommand: z.string().optional(),\n});\n\nexport const editorSchema = z.object({\n applicationURL: z.union([z.url(), z.literal('')]).optional(),\n editorURL: z.union([z.url(), z.literal('')]).optional(),\n cmsURL: z.union([z.url(), z.literal('')]).optional(),\n backendURL: z.union([z.url(), z.literal('')]).optional(),\n port: z.number().int().positive().max(65535).optional(),\n enabled: z.boolean().optional(),\n clientId: z.string().optional(),\n clientSecret: z.string().optional(),\n dictionaryPriorityStrategy: z\n .enum(['local_first', 'distant_first'])\n .optional(),\n liveSync: z.boolean().optional(),\n liveSyncPort: z.number().int().positive().max(65535).optional(),\n liveSyncURL: z.union([z.url(), z.literal('')]).optional(),\n});\n\nexport const analyticsSchema = z.object({\n enabled: z.boolean().optional(),\n flushInterval: z.number().int().positive().optional(),\n sampleRate: z.number().min(0).max(1).optional(),\n});\n\nexport const logSchema = z.object({\n mode: z.enum(['default', 'verbose', 'disabled']).optional(),\n prefix: z.string().optional(),\n error: z.function().optional(),\n log: z.function().optional(),\n info: z.function().optional(),\n warn: z.function().optional(),\n});\n\nexport const aiSchema = z.object({\n provider: z.enum(AiProviders).optional(),\n apiKey: z.string().optional(),\n model: z.string().optional(),\n temperature: z.number().min(0).max(2).optional(),\n applicationContext: z.string().optional(),\n baseURL: z.url().optional(),\n dataSerialization: z.enum(['json', 'toon']).optional(),\n});\n\nexport const buildSchema = z.object({\n mode: z.enum(['auto', 'manual']).optional(),\n optimize: z.boolean().optional(),\n importMode: z.enum(['static', 'dynamic', 'fetch']).optional(),\n traversePattern: z.array(z.string()).optional(),\n outputFormat: z.array(z.enum(['cjs', 'esm'])).optional(),\n cache: z.boolean().optional(),\n require: z.unknown().optional(),\n checkTypes: z.boolean().optional(),\n});\n\nexport const compilerSchema = z.object({\n enabled: z.union([z.boolean(), z.literal('build-only')]).optional(),\n dictionaryKeyPrefix: z.string().optional(),\n transformPattern: z.union([z.string(), z.array(z.string())]).optional(),\n excludePattern: z.union([z.string(), z.array(z.string())]).optional(),\n output: z.unknown().optional(),\n noMetadata: z.boolean().optional(),\n saveComponents: z.boolean().optional(),\n});\n\nexport const dictionarySchema = z.object({\n fill: z.unknown().optional(),\n contentAutoTransformation: z\n .union([\n z.boolean(),\n z.object({\n markdown: z.boolean().optional(),\n html: z.boolean().optional(),\n insertion: z.boolean().optional(),\n }),\n ])\n .optional(),\n location: z.string().optional(),\n locale: z.string().optional(),\n title: z.string().optional(),\n});\n\nexport const intlayerConfigSchema = z.object({\n internationalization: internationalizationSchema.optional(),\n routing: routingSchema.optional(),\n content: contentSchema.optional(),\n system: systemSchema.optional(),\n editor: editorSchema.optional(),\n analytics: analyticsSchema.optional(),\n log: logSchema.optional(),\n ai: aiSchema.optional(),\n build: buildSchema.optional(),\n compiler: compilerSchema.optional(),\n dictionary: dictionarySchema.optional(),\n plugins: z.array(z.unknown()).optional(),\n schemas: z.record(z.string(), z.unknown()).optional(),\n metadata: z\n .object({\n name: z.string().optional(),\n version: z.string().optional(),\n doc: z.string().optional(),\n })\n .optional(),\n});\n"],"mappings":";;;;;;;AAGA,MAAa,6BAA6BA,YAAE,OAAO;CACjD,SAASA,YAAE,MAAMA,YAAE,QAAQ,CAAC,CAAC,IAAI,EAAE;CACnC,iBAAiBA,YAAE,MAAMA,YAAE,QAAQ,CAAC,CAAC,UAAU;CAC/C,YAAYA,YAAE,KAAK;EAAC;EAAU;EAAa;EAAQ,CAAC,CAAC,UAAU;CAC/D,eAAeA,YAAE,QAAQ,CAAC,UAAU;CACrC,CAAC;;;;;;;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AC/B,WAAW,gBAAgB,UAAU;CACrC,KAAK,UAAU,UAAU;CACzB,IAAI,SAAS,UAAU;CACvB,OAAO,YAAY,UAAU;CAC7B,UAAU,eAAe,UAAU;CACnC,YAAY,iBAAiB,UAAU;CACvC,SAASA,YAAE,MAAMA,YAAE,SAAS,CAAC,CAAC,UAAU;CACxC,SAASA,YAAE,OAAOA,YAAE,QAAQ,EAAEA,YAAE,SAAS,CAAC,CAAC,UAAU;CACrD,UAAUA,YACP,OAAO;EACN,MAAMA,YAAE,QAAQ,CAAC,UAAU;EAC3B,SAASA,YAAE,QAAQ,CAAC,UAAU;EAC9B,KAAKA,YAAE,QAAQ,CAAC,UAAU;EAC3B,CAAC,CACD,UAAU;CACd,CAAC"}
1
+ {"version":3,"file":"configurationSchema.cjs","names":["z","AiProviders"],"sources":["../../../src/configFile/configurationSchema.ts"],"sourcesContent":["import { AiProviders } from '@intlayer/types/config';\nimport z from 'zod';\n\nexport const internationalizationSchema = z.object({\n locales: z.array(z.string()).min(1),\n requiredLocales: z.array(z.string()).optional(),\n strictMode: z.enum(['strict', 'inclusive', 'loose']).optional(),\n defaultLocale: z.string().optional(),\n});\n\n/**\n * Cross-realm-safe `Date` check.\n *\n * Configuration files are executed inside a `node:vm` sandbox, so a `Date`\n * created there is an instance of the sandbox realm's `Date`, not the host\n * realm's. `instanceof Date` (used by `z.date()`) therefore returns `false`\n * for those values, which would reject a perfectly valid `Date`.\n */\nconst isDateLike = (value: unknown): value is Date =>\n value instanceof Date ||\n Object.prototype.toString.call(value) === '[object Date]';\n\n/**\n * Cookie expiry: a number of days, an absolute `Date`, or an ISO date string\n * (the form a `Date` takes once the configuration is serialized).\n */\nconst cookieExpiresSchema = z.union([\n z.custom<Date>(isDateLike, { message: 'Expected a Date' }),\n z.number(),\n z.string().refine((value) => !Number.isNaN(Date.parse(value)), {\n message: 'Expected a valid date string',\n }),\n]);\n\nexport const cookiesAttributesSchema = z.object({\n type: z.literal('cookie'),\n name: z.string().optional(),\n domain: z.string().optional(),\n path: z.string().optional(),\n secure: z.boolean().optional(),\n httpOnly: z.boolean().optional(),\n sameSite: z.enum(['strict', 'lax', 'none']).optional(),\n expires: cookieExpiresSchema.optional(),\n maxAge: z.number().optional(),\n});\n\nexport const storageAttributesSchema = z.object({\n type: z.enum(['localStorage', 'sessionStorage', 'header']),\n name: z.string().optional(),\n});\n\nexport const storageSchema = z.union([\n z.literal(false),\n z.enum(['cookie', 'localStorage', 'sessionStorage', 'header']),\n cookiesAttributesSchema,\n storageAttributesSchema,\n z.array(\n z.union([\n z.enum(['cookie', 'localStorage', 'sessionStorage', 'header']),\n cookiesAttributesSchema,\n storageAttributesSchema,\n ])\n ),\n]);\n\nexport const rewriteRuleSchema = z.object({\n canonical: z.string(),\n localized: z.record(z.string(), z.string()),\n});\n\nexport const rewriteRulesSchema = z.object({\n rules: z.array(rewriteRuleSchema),\n});\n\nexport const rewriteObjectSchema = z.object({\n url: rewriteRulesSchema,\n nextjs: rewriteRulesSchema.optional(),\n vite: rewriteRulesSchema.optional(),\n});\n\nexport const routingSchema = z.object({\n rewrite: z\n .union([\n z.record(z.string(), z.record(z.string(), z.string())),\n rewriteObjectSchema,\n ])\n .optional(),\n mode: z\n .enum(['prefix-no-default', 'prefix-all', 'no-prefix', 'search-params'])\n .optional(),\n enableProxy: z.boolean().optional(),\n storage: storageSchema.optional(),\n basePath: z.string().optional(),\n domains: z.record(z.string(), z.string()).optional(),\n});\n\nexport const systemSchema = z.object({\n baseDir: z.string().optional(),\n moduleAugmentationDir: z.string().optional(),\n unmergedDictionariesDir: z.string().optional(),\n remoteDictionariesDir: z.string().optional(),\n dictionariesDir: z.string().optional(),\n dynamicDictionariesDir: z.string().optional(),\n fetchDictionariesDir: z.string().optional(),\n typesDir: z.string().optional(),\n mainDir: z.string().optional(),\n configDir: z.string().optional(),\n cacheDir: z.string().optional(),\n tempDir: z.string().optional(),\n});\n\nexport const contentSchema = z.object({\n fileExtensions: z.array(z.string()).optional(),\n contentDir: z.array(z.string()).optional(),\n codeDir: z.array(z.string()).optional(),\n excludedPath: z.array(z.string()).optional(),\n watch: z.boolean().optional(),\n formatCommand: z.string().optional(),\n});\n\nexport const editorSchema = z.object({\n applicationURL: z.union([z.url(), z.literal('')]).optional(),\n editorURL: z.union([z.url(), z.literal('')]).optional(),\n cmsURL: z.union([z.url(), z.literal('')]).optional(),\n backendURL: z.union([z.url(), z.literal('')]).optional(),\n port: z.number().int().positive().max(65535).optional(),\n enabled: z.boolean().optional(),\n clientId: z.string().optional(),\n clientSecret: z.string().optional(),\n dictionaryPriorityStrategy: z\n .enum(['local_first', 'distant_first'])\n .optional(),\n liveSync: z.boolean().optional(),\n liveSyncPort: z.number().int().positive().max(65535).optional(),\n liveSyncURL: z.union([z.url(), z.literal('')]).optional(),\n});\n\nexport const analyticsSchema = z.object({\n enabled: z.boolean().optional(),\n flushInterval: z.number().int().positive().optional(),\n sampleRate: z.number().min(0).max(1).optional(),\n});\n\nexport const logSchema = z.object({\n mode: z.enum(['default', 'verbose', 'disabled']).optional(),\n prefix: z.string().optional(),\n error: z.function().optional(),\n log: z.function().optional(),\n info: z.function().optional(),\n warn: z.function().optional(),\n});\n\nexport const aiSchema = z.object({\n provider: z.enum(AiProviders).optional(),\n apiKey: z.string().optional(),\n model: z.string().optional(),\n temperature: z.number().min(0).max(2).optional(),\n applicationContext: z.string().optional(),\n baseURL: z.url().optional(),\n dataSerialization: z.enum(['json', 'toon']).optional(),\n});\n\nexport const buildSchema = z.object({\n mode: z.enum(['auto', 'manual']).optional(),\n optimize: z.boolean().optional(),\n importMode: z.enum(['static', 'dynamic', 'fetch']).optional(),\n traversePattern: z.array(z.string()).optional(),\n outputFormat: z.array(z.enum(['cjs', 'esm'])).optional(),\n cache: z.boolean().optional(),\n require: z.unknown().optional(),\n checkTypes: z.boolean().optional(),\n});\n\nexport const compilerSchema = z.object({\n enabled: z.union([z.boolean(), z.literal('build-only')]).optional(),\n dictionaryKeyPrefix: z.string().optional(),\n transformPattern: z.union([z.string(), z.array(z.string())]).optional(),\n excludePattern: z.union([z.string(), z.array(z.string())]).optional(),\n output: z.unknown().optional(),\n noMetadata: z.boolean().optional(),\n saveComponents: z.boolean().optional(),\n});\n\nexport const dictionarySchema = z.object({\n fill: z.unknown().optional(),\n contentAutoTransformation: z\n .union([\n z.boolean(),\n z.object({\n markdown: z.boolean().optional(),\n html: z.boolean().optional(),\n insertion: z.boolean().optional(),\n }),\n ])\n .optional(),\n location: z.string().optional(),\n locale: z.string().optional(),\n title: z.string().optional(),\n});\n\nexport const intlayerConfigSchema = z.object({\n internationalization: internationalizationSchema.optional(),\n routing: routingSchema.optional(),\n content: contentSchema.optional(),\n system: systemSchema.optional(),\n editor: editorSchema.optional(),\n analytics: analyticsSchema.optional(),\n log: logSchema.optional(),\n ai: aiSchema.optional(),\n build: buildSchema.optional(),\n compiler: compilerSchema.optional(),\n dictionary: dictionarySchema.optional(),\n plugins: z.array(z.unknown()).optional(),\n schemas: z.record(z.string(), z.unknown()).optional(),\n metadata: z\n .object({\n name: z.string().optional(),\n version: z.string().optional(),\n doc: z.string().optional(),\n })\n .optional(),\n});\n"],"mappings":";;;;;;;AAGA,MAAa,6BAA6BA,YAAE,OAAO;CACjD,SAASA,YAAE,MAAMA,YAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;CAClC,iBAAiBA,YAAE,MAAMA,YAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CAC9C,YAAYA,YAAE,KAAK;EAAC;EAAU;EAAa;CAAO,CAAC,CAAC,CAAC,SAAS;CAC9D,eAAeA,YAAE,OAAO,CAAC,CAAC,SAAS;AACrC,CAAC;;;;;;;;;AAUD,MAAM,cAAc,UAClB,iBAAiB,QACjB,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM;;;;;AAM5C,MAAM,sBAAsBA,YAAE,MAAM;CAClCA,YAAE,OAAa,YAAY,EAAE,SAAS,kBAAkB,CAAC;CACzDA,YAAE,OAAO;CACTA,YAAE,OAAO,CAAC,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,UAAUA,YAAE,OAAO,CAAC,CAAC,SAAS;CAC9B,QAAQA,YAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,OAAOA,YAAE,OAAO,CAAC,CAAC,SAAS;AAC7B,CAAC;AAED,MAAa,uBAAuBA,YAAE,OAAO;CAC3C,sBAAsB,2BAA2B,SAAS;CAC1D,SAAS,cAAc,SAAS;CAChC,SAAS,cAAc,SAAS;CAChC,QAAQ,aAAa,SAAS;CAC9B,QAAQ,aAAa,SAAS;CAC9B,WAAW,gBAAgB,SAAS;CACpC,KAAK,UAAU,SAAS;CACxB,IAAI,SAAS,SAAS;CACtB,OAAO,YAAY,SAAS;CAC5B,UAAU,eAAe,SAAS;CAClC,YAAY,iBAAiB,SAAS;CACtC,SAASA,YAAE,MAAMA,YAAE,QAAQ,CAAC,CAAC,CAAC,SAAS;CACvC,SAASA,YAAE,OAAOA,YAAE,OAAO,GAAGA,YAAE,QAAQ,CAAC,CAAC,CAAC,SAAS;CACpD,UAAUA,YACP,OAAO;EACN,MAAMA,YAAE,OAAO,CAAC,CAAC,SAAS;EAC1B,SAASA,YAAE,OAAO,CAAC,CAAC,SAAS;EAC7B,KAAKA,YAAE,OAAO,CAAC,CAAC,SAAS;CAC3B,CAAC,CAAC,CACD,SAAS;AACd,CAAC"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_utils_cacheMemory = require('../utils/cacheMemory.cjs');
4
3
  const require_utils_getPackageJsonPath = require('../utils/getPackageJsonPath.cjs');
5
4
  const require_configFile_buildConfigurationFields = require('./buildConfigurationFields.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"getConfiguration.cjs","names":["getPackageJsonPath","buildConfigurationFields","cacheMemory","searchConfigurationFile","loadEnvFile","loadConfigurationFile"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types/config';\nimport { defu } from 'defu';\nimport { loadEnvFile } from '../loadEnvFile';\nimport type { LoadExternalFileOptions } from '../loadExternalFile/loadExternalFile';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { cacheMemory } from '../utils/cacheMemory';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n // Dotenv options\n env?: string;\n envFile?: string;\n // Log functions\n logFunctions?: LogFunctions;\n // Require function\n require?: NodeJS.Require;\n // cache\n cache?: boolean;\n // Build options for TypeScript transpilation (e.g. custom esbuild instance)\n buildOptions?: LoadExternalFileOptions['buildOptions'];\n} & Omit<SandBoxContextOptions, 'projectRequire'>;\n\nexport type GetConfigurationAndFilePathResult = {\n configuration: IntlayerConfig;\n customConfiguration: CustomIntlayerConfig | undefined;\n numCustomConfiguration: number;\n configurationFilePath: string | undefined;\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfigurationAndFilePath = (\n options?: GetConfigurationOptions\n): GetConfigurationAndFilePathResult => {\n let baseDir: string | undefined;\n\n try {\n // Can fail in some environments (e.g. MCP server, VScode extension)\n baseDir = options?.baseDir ?? getPackageJsonPath().baseDir;\n } catch (_err) {\n // Return default config if the package.json is not found\n return {\n configuration: buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions\n ),\n customConfiguration: undefined,\n numCustomConfiguration: 0,\n configurationFilePath: undefined,\n };\n }\n\n const cachedConfiguration =\n cacheMemory.get<GetConfigurationAndFilePathResult>(options);\n\n if (cachedConfiguration) return cachedConfiguration;\n\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n // Merge the variables from the resolved env file (e.g. the CLI `--env-file`)\n // on top of `process.env` without mutating the real environment. This lets\n // credential fallbacks (`INTLAYER_CLIENT_ID` / `INTLAYER_CLIENT_SECRET`) be\n // resolved from the env file even when the configuration file does not wire\n // `process.env` into `editor.clientId` / `editor.clientSecret` itself.\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n ...loadEnvFile({ env: options?.env, envFile: options?.envFile }),\n };\n\n let storedConfiguration: IntlayerConfig;\n let customConfiguration: CustomIntlayerConfig | undefined;\n\n if (configurationFilePath) {\n // Load the custom configuration\n customConfiguration = loadConfigurationFile(configurationFilePath, {\n projectRequire: options?.require,\n // Dotenv options\n envVarOptions: {\n env: options?.env,\n envFile: options?.envFile,\n },\n // Sandbox context additional variables\n additionalEnvVars: options?.additionalEnvVars,\n aliases: options?.aliases,\n // Build options for TypeScript transpilation (e.g. custom esbuild instance)\n buildOptions: options?.buildOptions,\n });\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n customConfiguration,\n options?.baseDir,\n options?.logFunctions,\n env\n );\n } else {\n // No configuration file found, use default configuration\n storedConfiguration = buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions,\n env\n );\n }\n\n // Log warning if multiple configuration files are found\n const projectRequireConfig: CustomIntlayerConfig = options?.require\n ? {\n build: {\n require: options?.require,\n cache: options?.cache,\n },\n }\n : {};\n\n const configWithProjectRequire = defu(\n projectRequireConfig,\n storedConfiguration\n ) as IntlayerConfig;\n\n const configuration = defu(\n options?.override ?? {},\n configWithProjectRequire\n ) as IntlayerConfig;\n\n cacheMemory.set(options, {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n });\n\n return {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n };\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfiguration = (\n options?: GetConfigurationOptions\n): IntlayerConfig => getConfigurationAndFilePath(options).configuration;\n"],"mappings":";;;;;;;;;;;;;;AAyCA,MAAa,+BACX,YACsC;CACtC,IAAI;AAEJ,KAAI;AAEF,YAAU,SAAS,WAAWA,qDAAoB,CAAC;UAC5C,MAAM;AAEb,SAAO;GACL,eAAeC,qEACb,EAAE,EACF,SAAS,SACT,SAAS,aACV;GACD,qBAAqB;GACrB,wBAAwB;GACxB,uBAAuB;GACxB;;CAGH,MAAM,sBACJC,sCAAY,IAAuC,QAAQ;AAE7D,KAAI,oBAAqB,QAAO;CAGhC,MAAM,EAAE,uBAAuB,2BAC7BC,mEAAwB,QAAQ;CAOlC,MAAM,MAAyB;EAC7B,GAAG,QAAQ;EACX,GAAGC,gCAAY;GAAE,KAAK,SAAS;GAAK,SAAS,SAAS;GAAS,CAAC;EACjE;CAED,IAAI;CACJ,IAAI;AAEJ,KAAI,uBAAuB;AAEzB,wBAAsBC,+DAAsB,uBAAuB;GACjE,gBAAgB,SAAS;GAEzB,eAAe;IACb,KAAK,SAAS;IACd,SAAS,SAAS;IACnB;GAED,mBAAmB,SAAS;GAC5B,SAAS,SAAS;GAElB,cAAc,SAAS;GACxB,CAAC;AAGF,wBAAsBJ,qEACpB,qBACA,SAAS,SACT,SAAS,cACT,IACD;OAGD,uBAAsBA,qEACpB,EAAE,EACF,SAAS,SACT,SAAS,cACT,IACD;CAaH,MAAM,0CAT6C,SAAS,UACxD,EACE,OAAO;EACL,SAAS,SAAS;EAClB,OAAO,SAAS;EACjB,EACF,GACD,EAAE,EAIJ,oBACD;CAED,MAAM,+BACJ,SAAS,YAAY,EAAE,EACvB,yBACD;AAED,uCAAY,IAAI,SAAS;EACvB;EACA;EACA;EACA;EACD,CAAC;AAEF,QAAO;EACL;EACA;EACA;EACA;EACD;;;;;AAMH,MAAa,oBACX,YACmB,4BAA4B,QAAQ,CAAC"}
1
+ {"version":3,"file":"getConfiguration.cjs","names":["getPackageJsonPath","buildConfigurationFields","cacheMemory","searchConfigurationFile","loadEnvFile","loadConfigurationFile"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types/config';\nimport { defu } from 'defu';\nimport { loadEnvFile } from '../loadEnvFile';\nimport type { LoadExternalFileOptions } from '../loadExternalFile/loadExternalFile';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { cacheMemory } from '../utils/cacheMemory';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n // Dotenv options\n env?: string;\n envFile?: string;\n // Log functions\n logFunctions?: LogFunctions;\n // Require function\n require?: NodeJS.Require;\n // cache\n cache?: boolean;\n // Build options for TypeScript transpilation (e.g. custom esbuild instance)\n buildOptions?: LoadExternalFileOptions['buildOptions'];\n} & Omit<SandBoxContextOptions, 'projectRequire'>;\n\nexport type GetConfigurationAndFilePathResult = {\n configuration: IntlayerConfig;\n customConfiguration: CustomIntlayerConfig | undefined;\n numCustomConfiguration: number;\n configurationFilePath: string | undefined;\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfigurationAndFilePath = (\n options?: GetConfigurationOptions\n): GetConfigurationAndFilePathResult => {\n let baseDir: string | undefined;\n\n try {\n // Can fail in some environments (e.g. MCP server, VScode extension)\n baseDir = options?.baseDir ?? getPackageJsonPath().baseDir;\n } catch (_err) {\n // Return default config if the package.json is not found\n return {\n configuration: buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions\n ),\n customConfiguration: undefined,\n numCustomConfiguration: 0,\n configurationFilePath: undefined,\n };\n }\n\n const cachedConfiguration =\n cacheMemory.get<GetConfigurationAndFilePathResult>(options);\n\n if (cachedConfiguration) return cachedConfiguration;\n\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n // Merge the variables from the resolved env file (e.g. the CLI `--env-file`)\n // on top of `process.env` without mutating the real environment. This lets\n // credential fallbacks (`INTLAYER_CLIENT_ID` / `INTLAYER_CLIENT_SECRET`) be\n // resolved from the env file even when the configuration file does not wire\n // `process.env` into `editor.clientId` / `editor.clientSecret` itself.\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n ...loadEnvFile({ env: options?.env, envFile: options?.envFile }),\n };\n\n let storedConfiguration: IntlayerConfig;\n let customConfiguration: CustomIntlayerConfig | undefined;\n\n if (configurationFilePath) {\n // Load the custom configuration\n customConfiguration = loadConfigurationFile(configurationFilePath, {\n projectRequire: options?.require,\n // Dotenv options\n envVarOptions: {\n env: options?.env,\n envFile: options?.envFile,\n },\n // Sandbox context additional variables\n additionalEnvVars: options?.additionalEnvVars,\n aliases: options?.aliases,\n // Build options for TypeScript transpilation (e.g. custom esbuild instance)\n buildOptions: options?.buildOptions,\n });\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n customConfiguration,\n options?.baseDir,\n options?.logFunctions,\n env\n );\n } else {\n // No configuration file found, use default configuration\n storedConfiguration = buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions,\n env\n );\n }\n\n // Log warning if multiple configuration files are found\n const projectRequireConfig: CustomIntlayerConfig = options?.require\n ? {\n build: {\n require: options?.require,\n cache: options?.cache,\n },\n }\n : {};\n\n const configWithProjectRequire = defu(\n projectRequireConfig,\n storedConfiguration\n ) as IntlayerConfig;\n\n const configuration = defu(\n options?.override ?? {},\n configWithProjectRequire\n ) as IntlayerConfig;\n\n cacheMemory.set(options, {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n });\n\n return {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n };\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfiguration = (\n options?: GetConfigurationOptions\n): IntlayerConfig => getConfigurationAndFilePath(options).configuration;\n"],"mappings":";;;;;;;;;;;;;AAyCA,MAAa,+BACX,YACsC;CACtC,IAAI;CAEJ,IAAI;EAEF,UAAU,SAAS,WAAWA,oDAAmB,CAAC,CAAC;CACrD,SAAS,MAAM;EAEb,OAAO;GACL,eAAeC,qEACb,CAAC,GACD,SAAS,SACT,SAAS,YACX;GACA,qBAAqB;GACrB,wBAAwB;GACxB,uBAAuB;EACzB;CACF;CAEA,MAAM,sBACJC,sCAAY,IAAuC,OAAO;CAE5D,IAAI,qBAAqB,OAAO;CAGhC,MAAM,EAAE,uBAAuB,2BAC7BC,mEAAwB,OAAO;CAOjC,MAAM,MAAyB;EAC7B,GAAG,QAAQ;EACX,GAAGC,gCAAY;GAAE,KAAK,SAAS;GAAK,SAAS,SAAS;EAAQ,CAAC;CACjE;CAEA,IAAI;CACJ,IAAI;CAEJ,IAAI,uBAAuB;EAEzB,sBAAsBC,+DAAsB,uBAAuB;GACjE,gBAAgB,SAAS;GAEzB,eAAe;IACb,KAAK,SAAS;IACd,SAAS,SAAS;GACpB;GAEA,mBAAmB,SAAS;GAC5B,SAAS,SAAS;GAElB,cAAc,SAAS;EACzB,CAAC;EAGD,sBAAsBJ,qEACpB,qBACA,SAAS,SACT,SAAS,cACT,GACF;CACF,OAEE,sBAAsBA,qEACpB,CAAC,GACD,SAAS,SACT,SAAS,cACT,GACF;CAaF,MAAM,0CAT6C,SAAS,UACxD,EACE,OAAO;EACL,SAAS,SAAS;EAClB,OAAO,SAAS;CAClB,EACF,IACA,CAAC,GAIH,mBACF;CAEA,MAAM,+BACJ,SAAS,YAAY,CAAC,GACtB,wBACF;CAEA,sCAAY,IAAI,SAAS;EACvB;EACA;EACA;EACA;CACF,CAAC;CAED,OAAO;EACL;EACA;EACA;EACA;CACF;AACF;;;;AAKA,MAAa,oBACX,YACmB,4BAA4B,OAAO,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"loadConfigurationFile.cjs","names":["configESMxCJSRequire","loadExternalFileSync"],"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import type { CustomIntlayerConfig } from '@intlayer/types/config';\nimport {\n type LoadExternalFileOptions,\n loadExternalFileSync,\n} from '../loadExternalFile/loadExternalFile';\nimport { configESMxCJSRequire } from '../utils/ESMxCJSHelpers';\n\nconst getAliases = (\n options?: Omit<LoadExternalFileOptions, 'configuration'>\n) => {\n // Can fail if CJS hot removed from the module (e.g. in Tanstack Start + Nitro)\n try {\n return {\n ...options?.aliases,\n // Replace intlayer with @intlayer/types to avoid circular dependency intlayer -> @intlayer/config -> intlayer\n intlayer: configESMxCJSRequire.resolve('@intlayer/types'),\n };\n } catch {\n return options?.aliases;\n }\n};\n\n/**\n * Load the configuration file from the given path\n * Example of configuration file: intlayer.config.js\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadConfigurationFile = (\n configFilePath: string,\n options?: Omit<LoadExternalFileOptions, 'configuration'>\n): CustomIntlayerConfig | undefined => {\n const fileContent = loadExternalFileSync(configFilePath, {\n ...options,\n aliases: getAliases(options),\n });\n\n return fileContent;\n};\n"],"mappings":";;;;;AAOA,MAAM,cACJ,YACG;AAEH,KAAI;AACF,SAAO;GACL,GAAG,SAAS;GAEZ,UAAUA,kDAAqB,QAAQ,kBAAkB;GAC1D;SACK;AACN,SAAO,SAAS;;;;;;;;;AAUpB,MAAa,yBACX,gBACA,YACqC;AAMrC,QALoBC,+DAAqB,gBAAgB;EACvD,GAAG;EACH,SAAS,WAAW,QAAQ;EAC7B,CAEiB"}
1
+ {"version":3,"file":"loadConfigurationFile.cjs","names":["configESMxCJSRequire","loadExternalFileSync"],"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import type { CustomIntlayerConfig } from '@intlayer/types/config';\nimport {\n type LoadExternalFileOptions,\n loadExternalFileSync,\n} from '../loadExternalFile/loadExternalFile';\nimport { configESMxCJSRequire } from '../utils/ESMxCJSHelpers';\n\nconst getAliases = (\n options?: Omit<LoadExternalFileOptions, 'configuration'>\n) => {\n // Can fail if CJS hot removed from the module (e.g. in Tanstack Start + Nitro)\n try {\n return {\n ...options?.aliases,\n // Replace intlayer with @intlayer/types to avoid circular dependency intlayer -> @intlayer/config -> intlayer\n intlayer: configESMxCJSRequire.resolve('@intlayer/types'),\n };\n } catch {\n return options?.aliases;\n }\n};\n\n/**\n * Load the configuration file from the given path\n * Example of configuration file: intlayer.config.js\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadConfigurationFile = (\n configFilePath: string,\n options?: Omit<LoadExternalFileOptions, 'configuration'>\n): CustomIntlayerConfig | undefined => {\n const fileContent = loadExternalFileSync(configFilePath, {\n ...options,\n aliases: getAliases(options),\n });\n\n return fileContent;\n};\n"],"mappings":";;;;;AAOA,MAAM,cACJ,YACG;CAEH,IAAI;EACF,OAAO;GACL,GAAG,SAAS;GAEZ,UAAUA,kDAAqB,QAAQ,iBAAiB;EAC1D;CACF,QAAQ;EACN,OAAO,SAAS;CAClB;AACF;;;;;;;AAQA,MAAa,yBACX,gBACA,YACqC;CAMrC,OALoBC,+DAAqB,gBAAgB;EACvD,GAAG;EACH,SAAS,WAAW,OAAO;CAC7B,CAEiB;AACnB"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_utils_getPackageJsonPath = require('../utils/getPackageJsonPath.cjs');
4
3
  const require_logger = require('../logger.cjs');
5
4
  let node_fs = require("node:fs");
@@ -1 +1 @@
1
- {"version":3,"file":"searchConfigurationFile.cjs","names":["getPackageJsonPath"],"sources":["../../../src/configFile/searchConfigurationFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { logger } from '../logger';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\n\nexport const configurationFilesCandidates = [\n 'intlayer.config.ts',\n 'intlayer.config.js',\n 'intlayer.config.json',\n 'intlayer.config.json5',\n 'intlayer.config.jsonc',\n 'intlayer.config.cjs',\n 'intlayer.config.mjs',\n '.intlayerrc',\n] as const;\n\ntype SearchConfigurationFileResult = {\n configurationFilePath?: string;\n numCustomConfiguration: number;\n};\n\n// CACHE: Store results to avoid re-walking the file system for the same path\nconst rootPathCache = new Map<string, SearchConfigurationFileResult>();\n\n/**\n * Search for the configuration file in the given path\n *\n * List of detected configuration files:\n * - intlayer.config.ts\n * - intlayer.config.js\n * - intlayer.config.json\n * - intlayer.config.cjs\n * - intlayer.config.mjs\n * - .intlayerrc\n */\nexport const searchConfigurationFile = (\n startDir: string\n): SearchConfigurationFileResult => {\n let configurationFilePath: string | undefined;\n let numCustomConfiguration = 0;\n\n // OPTIMIZATION: Return cached result immediately\n if (rootPathCache.has(startDir)) {\n return rootPathCache.get(startDir) as SearchConfigurationFileResult;\n }\n\n const { baseDir } = getPackageJsonPath(startDir);\n\n for (const fileName of configurationFilesCandidates) {\n try {\n const filePath = resolve(baseDir, fileName);\n\n // Check if the file exists\n if (!existsSync(filePath)) {\n } else {\n numCustomConfiguration += 1;\n\n if (!configurationFilePath) {\n configurationFilePath = filePath;\n }\n }\n } catch (error) {\n // Return \"Cannot use import statement outside a module\"\n logger(`${fileName}: ${error as string}`, { level: 'error' });\n }\n }\n\n return { configurationFilePath, numCustomConfiguration };\n};\n"],"mappings":";;;;;;;;AAKA,MAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAQD,MAAM,gCAAgB,IAAI,KAA4C;;;;;;;;;;;;AAatE,MAAa,2BACX,aACkC;CAClC,IAAI;CACJ,IAAI,yBAAyB;AAG7B,KAAI,cAAc,IAAI,SAAS,CAC7B,QAAO,cAAc,IAAI,SAAS;CAGpC,MAAM,EAAE,YAAYA,oDAAmB,SAAS;AAEhD,MAAK,MAAM,YAAY,6BACrB,KAAI;EACF,MAAM,kCAAmB,SAAS,SAAS;AAG3C,MAAI,yBAAY,SAAS,EAAE,QACpB;AACL,6BAA0B;AAE1B,OAAI,CAAC,sBACH,yBAAwB;;UAGrB,OAAO;AAEd,wBAAO,GAAG,SAAS,IAAI,SAAmB,EAAE,OAAO,SAAS,CAAC;;AAIjE,QAAO;EAAE;EAAuB;EAAwB"}
1
+ {"version":3,"file":"searchConfigurationFile.cjs","names":["getPackageJsonPath"],"sources":["../../../src/configFile/searchConfigurationFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { logger } from '../logger';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\n\nexport const configurationFilesCandidates = [\n 'intlayer.config.ts',\n 'intlayer.config.js',\n 'intlayer.config.json',\n 'intlayer.config.json5',\n 'intlayer.config.jsonc',\n 'intlayer.config.cjs',\n 'intlayer.config.mjs',\n '.intlayerrc',\n] as const;\n\ntype SearchConfigurationFileResult = {\n configurationFilePath?: string;\n numCustomConfiguration: number;\n};\n\n// CACHE: Store results to avoid re-walking the file system for the same path\nconst rootPathCache = new Map<string, SearchConfigurationFileResult>();\n\n/**\n * Search for the configuration file in the given path\n *\n * List of detected configuration files:\n * - intlayer.config.ts\n * - intlayer.config.js\n * - intlayer.config.json\n * - intlayer.config.cjs\n * - intlayer.config.mjs\n * - .intlayerrc\n */\nexport const searchConfigurationFile = (\n startDir: string\n): SearchConfigurationFileResult => {\n let configurationFilePath: string | undefined;\n let numCustomConfiguration = 0;\n\n // OPTIMIZATION: Return cached result immediately\n if (rootPathCache.has(startDir)) {\n return rootPathCache.get(startDir) as SearchConfigurationFileResult;\n }\n\n const { baseDir } = getPackageJsonPath(startDir);\n\n for (const fileName of configurationFilesCandidates) {\n try {\n const filePath = resolve(baseDir, fileName);\n\n // Check if the file exists\n if (!existsSync(filePath)) {\n } else {\n numCustomConfiguration += 1;\n\n if (!configurationFilePath) {\n configurationFilePath = filePath;\n }\n }\n } catch (error) {\n // Return \"Cannot use import statement outside a module\"\n logger(`${fileName}: ${error as string}`, { level: 'error' });\n }\n }\n\n return { configurationFilePath, numCustomConfiguration };\n};\n"],"mappings":";;;;;;;AAKA,MAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAQA,MAAM,gCAAgB,IAAI,IAA2C;;;;;;;;;;;;AAarE,MAAa,2BACX,aACkC;CAClC,IAAI;CACJ,IAAI,yBAAyB;CAG7B,IAAI,cAAc,IAAI,QAAQ,GAC5B,OAAO,cAAc,IAAI,QAAQ;CAGnC,MAAM,EAAE,YAAYA,oDAAmB,QAAQ;CAE/C,KAAK,MAAM,YAAY,8BACrB,IAAI;EACF,MAAM,kCAAmB,SAAS,QAAQ;EAG1C,IAAI,yBAAY,QAAQ,GAAG,CAC3B,OAAO;GACL,0BAA0B;GAE1B,IAAI,CAAC,uBACH,wBAAwB;EAE5B;CACF,SAAS,OAAO;EAEd,sBAAO,GAAG,SAAS,IAAI,SAAmB,EAAE,OAAO,QAAQ,CAAC;CAC9D;CAGF,OAAO;EAAE;EAAuB;CAAuB;AACzD"}
@@ -1 +1 @@
1
- {"version":3,"file":"build.cjs","names":[],"sources":["../../../src/defaultValues/build.ts"],"sourcesContent":["export const BUILD_MODE = 'auto';\n\nexport const OPTIMIZE = undefined;\n\nexport const TRAVERSE_PATTERN = [\n // Included files to parse\n '**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,astro}',\n\n // Excluded paths\n '!**/node_modules/**',\n '!**/dist/**',\n '!**/build/**',\n '!**/.intlayer/**',\n '!**/.next/**',\n '!**/.nuxt/**',\n '!**/.expo/**',\n '!**/.vercel/**',\n '!**/.turbo/**',\n '!**/.tanstack/**',\n '!**/.output/**',\n '!**/.svelte-kit/**',\n '!**/*.config.*',\n '!**/*.test.*',\n '!**/*.spec.*',\n '!**/*.stories.*',\n '!**/*.d.ts',\n '!**/*.d.ts.map',\n '!**/*.map',\n];\n\nexport const OUTPUT_FORMAT: ('cjs' | 'esm')[] = ['esm', 'cjs'];\n\nexport const CACHE = true;\n\nexport const TYPE_CHECKING = false;\n\nexport const MINIFY = false;\n\nexport const PURGE = false;\n"],"mappings":";;;AAAA,MAAa,aAAa;AAE1B,MAAa,WAAW;AAExB,MAAa,mBAAmB;CAE9B;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,gBAAmC,CAAC,OAAO,MAAM;AAE9D,MAAa,QAAQ;AAErB,MAAa,gBAAgB;AAE7B,MAAa,SAAS;AAEtB,MAAa,QAAQ"}
1
+ {"version":3,"file":"build.cjs","names":[],"sources":["../../../src/defaultValues/build.ts"],"sourcesContent":["export const BUILD_MODE = 'auto';\n\nexport const OPTIMIZE = undefined;\n\nexport const TRAVERSE_PATTERN = [\n // Included files to parse\n '**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,astro}',\n\n // Excluded paths\n '!**/node_modules/**',\n '!**/dist/**',\n '!**/build/**',\n '!**/.intlayer/**',\n '!**/.next/**',\n '!**/.nuxt/**',\n '!**/.expo/**',\n '!**/.vercel/**',\n '!**/.turbo/**',\n '!**/.tanstack/**',\n '!**/.output/**',\n '!**/.svelte-kit/**',\n '!**/*.config.*',\n '!**/*.test.*',\n '!**/*.spec.*',\n '!**/*.stories.*',\n '!**/*.d.ts',\n '!**/*.d.ts.map',\n '!**/*.map',\n];\n\nexport const OUTPUT_FORMAT: ('cjs' | 'esm')[] = ['esm', 'cjs'];\n\nexport const CACHE = true;\n\nexport const TYPE_CHECKING = false;\n\nexport const MINIFY = false;\n\nexport const PURGE = false;\n"],"mappings":";;;AAAA,MAAa,aAAa;AAE1B,MAAa,WAAW;AAExB,MAAa,mBAAmB;CAE9B;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,gBAAmC,CAAC,OAAO,KAAK;AAE7D,MAAa,QAAQ;AAErB,MAAa,gBAAgB;AAE7B,MAAa,SAAS;AAEtB,MAAa,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"content.cjs","names":[],"sources":["../../../src/defaultValues/content.ts"],"sourcesContent":["export const FILE_EXTENSIONS = [\n '.content.ts',\n '.content.js',\n '.content.cjs',\n '.content.mjs',\n '.content.json',\n '.content.json5',\n '.content.jsonc',\n '.content.tsx',\n '.content.jsx',\n '.content.md',\n '.content.mdx',\n '.content.yaml',\n '.content.yml',\n];\n\nexport const EXCLUDED_PATHS = [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n '**/.next/**',\n '**/.nuxt/**',\n '**/.expo/**',\n '**/.vercel/**',\n '**/.turbo/**',\n '**/.tanstack/**',\n '**/.output/**',\n '**/.svelte-kit/**',\n];\n\nexport const CONTENT_DIR = ['.'];\n\nexport const CODE_DIR = ['.'];\n\nexport const I18NEXT_DICTIONARIES_DIR = 'i18next_resources';\n\nexport const REACT_INTL_MESSAGES_DIR = 'intl_messages';\n\nexport const WATCH = true;\n"],"mappings":";;;AAAA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,cAAc,CAAC,IAAI;AAEhC,MAAa,WAAW,CAAC,IAAI;AAE7B,MAAa,2BAA2B;AAExC,MAAa,0BAA0B;AAEvC,MAAa,QAAQ"}
1
+ {"version":3,"file":"content.cjs","names":[],"sources":["../../../src/defaultValues/content.ts"],"sourcesContent":["export const FILE_EXTENSIONS = [\n '.content.ts',\n '.content.js',\n '.content.cjs',\n '.content.mjs',\n '.content.json',\n '.content.json5',\n '.content.jsonc',\n '.content.tsx',\n '.content.jsx',\n '.content.md',\n '.content.mdx',\n '.content.yaml',\n '.content.yml',\n];\n\nexport const EXCLUDED_PATHS = [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n '**/.next/**',\n '**/.nuxt/**',\n '**/.expo/**',\n '**/.vercel/**',\n '**/.turbo/**',\n '**/.tanstack/**',\n '**/.output/**',\n '**/.svelte-kit/**',\n];\n\nexport const CONTENT_DIR = ['.'];\n\nexport const CODE_DIR = ['.'];\n\nexport const I18NEXT_DICTIONARIES_DIR = 'i18next_resources';\n\nexport const REACT_INTL_MESSAGES_DIR = 'intl_messages';\n\nexport const WATCH = true;\n"],"mappings":";;;AAAA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,cAAc,CAAC,GAAG;AAE/B,MAAa,WAAW,CAAC,GAAG;AAE5B,MAAa,2BAA2B;AAExC,MAAa,0BAA0B;AAEvC,MAAa,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"internationalization.cjs","names":[],"sources":["../../../src/defaultValues/internationalization.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { StrictMode } from '@intlayer/types/config';\n\nexport const LOCALES: Locale[] = ['en'];\n\nexport const REQUIRED_LOCALES: Locale[] = [];\n\nexport const DEFAULT_LOCALE: Locale = 'en';\n\nexport const STRICT_MODE: StrictMode = 'inclusive';\n"],"mappings":";;;AAGA,MAAa,UAAoB,CAAC,KAAK;AAEvC,MAAa,mBAA6B,EAAE;AAE5C,MAAa,iBAAyB;AAEtC,MAAa,cAA0B"}
1
+ {"version":3,"file":"internationalization.cjs","names":[],"sources":["../../../src/defaultValues/internationalization.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { StrictMode } from '@intlayer/types/config';\n\nexport const LOCALES: Locale[] = ['en'];\n\nexport const REQUIRED_LOCALES: Locale[] = [];\n\nexport const DEFAULT_LOCALE: Locale = 'en';\n\nexport const STRICT_MODE: StrictMode = 'inclusive';\n"],"mappings":";;;AAGA,MAAa,UAAoB,CAAC,IAAI;AAEtC,MAAa,mBAA6B,CAAC;AAE3C,MAAa,iBAAyB;AAEtC,MAAa,cAA0B"}
@@ -1 +1 @@
1
- {"version":3,"file":"routing.cjs","names":[],"sources":["../../../src/defaultValues/routing.ts"],"sourcesContent":["import type { RoutingStorageInput } from '@intlayer/types/config';\n\nexport const HEADER_NAME = 'x-intlayer-locale';\n\nexport const COOKIE_NAME = 'INTLAYER_LOCALE';\nexport const LOCALE_STORAGE_NAME = 'INTLAYER_LOCALE';\n\nexport const BASE_PATH = '';\n\nexport const SERVER_SET_COOKIE = 'always';\n\nexport const ROUTING_MODE = 'prefix-no-default';\n\nexport const ENABLE_PROXY = true;\n\nexport const STORAGE: RoutingStorageInput = ['cookie', 'header'];\n"],"mappings":";;;AAEA,MAAa,cAAc;AAE3B,MAAa,cAAc;AAC3B,MAAa,sBAAsB;AAEnC,MAAa,YAAY;AAEzB,MAAa,oBAAoB;AAEjC,MAAa,eAAe;AAE5B,MAAa,eAAe;AAE5B,MAAa,UAA+B,CAAC,UAAU,SAAS"}
1
+ {"version":3,"file":"routing.cjs","names":[],"sources":["../../../src/defaultValues/routing.ts"],"sourcesContent":["import type { RoutingStorageInput } from '@intlayer/types/config';\n\nexport const HEADER_NAME = 'x-intlayer-locale';\n\nexport const COOKIE_NAME = 'INTLAYER_LOCALE';\nexport const LOCALE_STORAGE_NAME = 'INTLAYER_LOCALE';\n\nexport const BASE_PATH = '';\n\nexport const SERVER_SET_COOKIE = 'always';\n\nexport const ROUTING_MODE = 'prefix-no-default';\n\nexport const ENABLE_PROXY = true;\n\nexport const STORAGE: RoutingStorageInput = ['cookie', 'header'];\n"],"mappings":";;;AAEA,MAAa,cAAc;AAE3B,MAAa,cAAc;AAC3B,MAAa,sBAAsB;AAEnC,MAAa,YAAY;AAEzB,MAAa,oBAAoB;AAEjC,MAAa,eAAe;AAE5B,MAAa,eAAe;AAE5B,MAAa,UAA+B,CAAC,UAAU,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"envVars.cjs","names":[],"sources":["../../../src/envVars/envVars.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Converts a camelCase node-type string to SCREAMING_SNAKE_CASE so that\n * the generated env-var name matches what the plugin source files check.\n *\n * @example\n * toScreamingSnakeCase('reactNode') // 'REACT_NODE'\n * toScreamingSnakeCase('markdown') // 'MARKDOWN'\n */\nconst toScreamingSnakeCase = (str: string): string =>\n str\n .replace(/([A-Z])/g, '_$1')\n .toUpperCase()\n .replace(/^_/, ''); // strip any leading underscore\n\n/**\n * Converts a list of unused NodeType keys into env-var definitions.\n * Set to `\"false\"` so bundlers can eliminate the corresponding plugin code.\n *\n * @example\n * formatNodeTypeToEnvVar(['enumeration'])\n * // { 'INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n *\n * formatNodeTypeToEnvVar(['reactNode'], (k) => `process.env.${k}`, (v) => `\"${v}\"`)\n * // { 'process.env.INTLAYER_NODE_TYPE_REACT_NODE': '\"false\"' }\n */\nexport const formatNodeTypeToEnvVar = (\n nodeTypes: string[],\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> =>\n nodeTypes.reduce(\n (acc, nodeType) => {\n acc[wrapKey(`INTLAYER_NODE_TYPE_${toScreamingSnakeCase(nodeType)}`)] =\n wrapValue('false');\n return acc;\n },\n {} as Record<string, string>\n );\n\n/**\n * Returns the env-var definition disabling the dictionary-selector resolution\n * path (collections, variants) when no built dictionary declares\n * a qualifier. Set to `\"false\"` so bundlers can dead-code-eliminate the\n * selector branch in `getIntlayer` / `useIntlayer`.\n *\n * Emits nothing when selectors are used, leaving the runtime default in place.\n *\n * @example\n * formatDictionarySelectorEnvVar(false)\n * // { INTLAYER_DICTIONARY_SELECTOR: '\"false\"' }\n *\n * formatDictionarySelectorEnvVar(true)\n * // {}\n *\n * formatDictionarySelectorEnvVar(false, (k) => `process.env.${k}`, (v) => `\"${v}\"`)\n * // { 'process.env.INTLAYER_DICTIONARY_SELECTOR': '\"false\"' }\n */\nexport const formatDictionarySelectorEnvVar = (\n hasDictionarySelector: boolean,\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> =>\n hasDictionarySelector\n ? {}\n : { [wrapKey('INTLAYER_DICTIONARY_SELECTOR')]: wrapValue('false') };\n\n/**\n * Returns env-var definitions for the full Intlayer config to be injected at\n * build time. Allows bundlers to dead-code-eliminate unused routing modes,\n * rewrite logic, storage mechanisms, and editor code.\n *\n * @example\n * getConfigEnvVars(config)\n * // { INTLAYER_ROUTING_MODE: '\"prefix-no-default\"', INTLAYER_ROUTING_REWRITE_RULES: '\"false\"', ... }\n *\n * getConfigEnvVars(config, true)\n * // { 'process.env.INTLAYER_ROUTING_MODE': '\"prefix-no-default\"', ... }\n */\nexport const getConfigEnvVars = (\n config: IntlayerConfig,\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> => {\n const { routing, editor, analytics } = config;\n\n const envVars: Record<string, string> = {\n [wrapKey('INTLAYER_ROUTING_MODE')]: wrapValue(routing.mode),\n };\n\n if (routing.enableProxy === false) {\n envVars[wrapKey('INTLAYER_ROUTING_ENABLE_PROXY')] = wrapValue('false');\n }\n\n if (!routing.rewrite) {\n envVars[wrapKey('INTLAYER_ROUTING_REWRITE_RULES')] = wrapValue('false');\n }\n\n if (!routing.domains || Object.keys(routing.domains).length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_DOMAINS')] = wrapValue('false');\n }\n\n if (!routing.storage.cookies || routing.storage.cookies.length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_COOKIES')] = wrapValue('false');\n }\n\n if (\n !routing.storage.localStorage ||\n routing.storage.localStorage.length === 0\n ) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_LOCALSTORAGE')] =\n wrapValue('false');\n }\n\n if (\n !routing.storage.sessionStorage ||\n routing.storage.sessionStorage.length === 0\n ) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE')] =\n wrapValue('false');\n }\n\n if (!routing.storage.headers || routing.storage.headers.length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_HEADERS')] = wrapValue('false');\n }\n\n if (editor?.enabled === false) {\n envVars[wrapKey('INTLAYER_EDITOR_ENABLED')] = wrapValue('false');\n }\n\n // Analytics is strictly opt-in (`analytics.enabled === true`) and requires a\n // project key (`editor.clientId`) for attribution. Otherwise, disable it so\n // bundlers dead-code-eliminate the whole `@intlayer/analytics` integration\n // (providers + node plugins).\n if (analytics?.enabled !== true || !editor?.clientId) {\n envVars[wrapKey('INTLAYER_ANALYTICS_ENABLED')] = wrapValue('false');\n }\n\n return envVars;\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,wBAAwB,QAC5B,IACG,QAAQ,YAAY,MAAM,CAC1B,aAAa,CACb,QAAQ,MAAM,GAAG;;;;;;;;;;;;AAatB,MAAa,0BACX,WACA,WAAW,QAAgB,KAC3B,aAAa,UAAkB,UAE/B,UAAU,QACP,KAAK,aAAa;AACjB,KAAI,QAAQ,sBAAsB,qBAAqB,SAAS,GAAG,IACjE,UAAU,QAAQ;AACpB,QAAO;GAET,EAAE,CACH;;;;;;;;;;;;;;;;;;;AAoBH,MAAa,kCACX,uBACA,WAAW,QAAgB,KAC3B,aAAa,UAAkB,UAE/B,wBACI,EAAE,GACF,GAAG,QAAQ,+BAA+B,GAAG,UAAU,QAAQ,EAAE;;;;;;;;;;;;;AAcvE,MAAa,oBACX,QACA,WAAW,QAAgB,KAC3B,aAAa,UAAkB,UACJ;CAC3B,MAAM,EAAE,SAAS,QAAQ,cAAc;CAEvC,MAAM,UAAkC,GACrC,QAAQ,wBAAwB,GAAG,UAAU,QAAQ,KAAK,EAC5D;AAED,KAAI,QAAQ,gBAAgB,MAC1B,SAAQ,QAAQ,gCAAgC,IAAI,UAAU,QAAQ;AAGxE,KAAI,CAAC,QAAQ,QACX,SAAQ,QAAQ,iCAAiC,IAAI,UAAU,QAAQ;AAGzE,KAAI,CAAC,QAAQ,WAAW,OAAO,KAAK,QAAQ,QAAQ,CAAC,WAAW,EAC9D,SAAQ,QAAQ,2BAA2B,IAAI,UAAU,QAAQ;AAGnE,KAAI,CAAC,QAAQ,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,WAAW,EACjE,SAAQ,QAAQ,mCAAmC,IAAI,UAAU,QAAQ;AAG3E,KACE,CAAC,QAAQ,QAAQ,gBACjB,QAAQ,QAAQ,aAAa,WAAW,EAExC,SAAQ,QAAQ,wCAAwC,IACtD,UAAU,QAAQ;AAGtB,KACE,CAAC,QAAQ,QAAQ,kBACjB,QAAQ,QAAQ,eAAe,WAAW,EAE1C,SAAQ,QAAQ,0CAA0C,IACxD,UAAU,QAAQ;AAGtB,KAAI,CAAC,QAAQ,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,WAAW,EACjE,SAAQ,QAAQ,mCAAmC,IAAI,UAAU,QAAQ;AAG3E,KAAI,QAAQ,YAAY,MACtB,SAAQ,QAAQ,0BAA0B,IAAI,UAAU,QAAQ;AAOlE,KAAI,WAAW,YAAY,QAAQ,CAAC,QAAQ,SAC1C,SAAQ,QAAQ,6BAA6B,IAAI,UAAU,QAAQ;AAGrE,QAAO"}
1
+ {"version":3,"file":"envVars.cjs","names":[],"sources":["../../../src/envVars/envVars.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Converts a camelCase node-type string to SCREAMING_SNAKE_CASE so that\n * the generated env-var name matches what the plugin source files check.\n *\n * @example\n * toScreamingSnakeCase('reactNode') // 'REACT_NODE'\n * toScreamingSnakeCase('markdown') // 'MARKDOWN'\n */\nconst toScreamingSnakeCase = (str: string): string =>\n str\n .replace(/([A-Z])/g, '_$1')\n .toUpperCase()\n .replace(/^_/, ''); // strip any leading underscore\n\n/**\n * Converts a list of unused NodeType keys into env-var definitions.\n * Set to `\"false\"` so bundlers can eliminate the corresponding plugin code.\n *\n * @example\n * formatNodeTypeToEnvVar(['enumeration'])\n * // { 'INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n *\n * formatNodeTypeToEnvVar(['reactNode'], (k) => `process.env.${k}`, (v) => `\"${v}\"`)\n * // { 'process.env.INTLAYER_NODE_TYPE_REACT_NODE': '\"false\"' }\n */\nexport const formatNodeTypeToEnvVar = (\n nodeTypes: string[],\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> =>\n nodeTypes.reduce(\n (acc, nodeType) => {\n acc[wrapKey(`INTLAYER_NODE_TYPE_${toScreamingSnakeCase(nodeType)}`)] =\n wrapValue('false');\n return acc;\n },\n {} as Record<string, string>\n );\n\n/**\n * Returns the env-var definition disabling the dictionary-selector resolution\n * path (collections, variants) when no built dictionary declares\n * a qualifier. Set to `\"false\"` so bundlers can dead-code-eliminate the\n * selector branch in `getIntlayer` / `useIntlayer`.\n *\n * Emits nothing when selectors are used, leaving the runtime default in place.\n *\n * @example\n * formatDictionarySelectorEnvVar(false)\n * // { INTLAYER_DICTIONARY_SELECTOR: '\"false\"' }\n *\n * formatDictionarySelectorEnvVar(true)\n * // {}\n *\n * formatDictionarySelectorEnvVar(false, (k) => `process.env.${k}`, (v) => `\"${v}\"`)\n * // { 'process.env.INTLAYER_DICTIONARY_SELECTOR': '\"false\"' }\n */\nexport const formatDictionarySelectorEnvVar = (\n hasDictionarySelector: boolean,\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> =>\n hasDictionarySelector\n ? {}\n : { [wrapKey('INTLAYER_DICTIONARY_SELECTOR')]: wrapValue('false') };\n\n/**\n * Returns env-var definitions for the full Intlayer config to be injected at\n * build time. Allows bundlers to dead-code-eliminate unused routing modes,\n * rewrite logic, storage mechanisms, and editor code.\n *\n * @example\n * getConfigEnvVars(config)\n * // { INTLAYER_ROUTING_MODE: '\"prefix-no-default\"', INTLAYER_ROUTING_REWRITE_RULES: '\"false\"', ... }\n *\n * getConfigEnvVars(config, true)\n * // { 'process.env.INTLAYER_ROUTING_MODE': '\"prefix-no-default\"', ... }\n */\nexport const getConfigEnvVars = (\n config: IntlayerConfig,\n wrapKey = (key: string) => key,\n wrapValue = (value: string) => value\n): Record<string, string> => {\n const { routing, editor, analytics } = config;\n\n const envVars: Record<string, string> = {\n [wrapKey('INTLAYER_ROUTING_MODE')]: wrapValue(routing.mode),\n };\n\n if (routing.enableProxy === false) {\n envVars[wrapKey('INTLAYER_ROUTING_ENABLE_PROXY')] = wrapValue('false');\n }\n\n if (!routing.rewrite) {\n envVars[wrapKey('INTLAYER_ROUTING_REWRITE_RULES')] = wrapValue('false');\n }\n\n if (!routing.domains || Object.keys(routing.domains).length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_DOMAINS')] = wrapValue('false');\n }\n\n if (!routing.storage.cookies || routing.storage.cookies.length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_COOKIES')] = wrapValue('false');\n }\n\n if (\n !routing.storage.localStorage ||\n routing.storage.localStorage.length === 0\n ) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_LOCALSTORAGE')] =\n wrapValue('false');\n }\n\n if (\n !routing.storage.sessionStorage ||\n routing.storage.sessionStorage.length === 0\n ) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE')] =\n wrapValue('false');\n }\n\n if (!routing.storage.headers || routing.storage.headers.length === 0) {\n envVars[wrapKey('INTLAYER_ROUTING_STORAGE_HEADERS')] = wrapValue('false');\n }\n\n if (editor?.enabled === false) {\n envVars[wrapKey('INTLAYER_EDITOR_ENABLED')] = wrapValue('false');\n }\n\n // Analytics is strictly opt-in (`analytics.enabled === true`) and requires a\n // project key (`editor.clientId`) for attribution. Otherwise, disable it so\n // bundlers dead-code-eliminate the whole `@intlayer/analytics` integration\n // (providers + node plugins).\n if (analytics?.enabled !== true || !editor?.clientId) {\n envV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rB,IACE,CAAC,QAAQ,QAAQ,kBACjB,QAAQ,QAAQ,eAAe,WAAW,GAE1C,QAAQ,QAAQ,yCAAyC,KACvD,UAAU,OAAO;CAGrB,IAAI,CAAC,QAAQ,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,WAAW,GACjE,QAAQ,QAAQ,kCAAkC,KAAK,UAAU,OAAO;CAG1E,IAAI,QAAQ,YAAY,OACtB,QAAQ,QAAQ,yBAAyB,KAAK,UAAU,OAAO;CAOjE,IAAI,WAAW,YAAY,QAAQ,CAAC,QAAQ,UAC1C,QAAQ,QAAQ,4BAA4B,KAAK,UAAU,OAAO;CAGpE,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"loadEnvFile.cjs","names":["existsSync"],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync, statSync } from 'node:fs';\nimport dotenv from 'dotenv';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\ntype EnvFileCacheEntry = {\n /** The env file that was resolved and parsed (undefined if none exists). */\n envFilePath: string | undefined;\n /** Fingerprint of the parsed file, used to detect edits. */\n mtimeMs: number;\n size: number;\n /** The parsed env variables. */\n parsedEnv: Record<string, string>;\n};\n\n/**\n * Cache of parsed env files keyed by `cwd|env|envFile`. Loading content\n * declarations calls `loadEnvFile` once per file; without this every call pays\n * up to 4 `existsSync` probes plus a dotenv read+parse. A cached hit is\n * validated with a single `stat` so edits to the env file are still picked up.\n */\nconst envFileCache = new Map<string, EnvFileCacheEntry>();\n\nconst parseEnvFile = (envFilePath: string): Record<string, string> => {\n const parsedEnv: Record<string, string> = {};\n\n dotenv.config({\n path: envFilePath,\n processEnv: parsedEnv,\n quiet: true,\n });\n\n return parsedEnv;\n};\n\nexport const loadEnvFile = (\n options?: Partial<LoadEnvFileOptions>\n): Record<string, string> => {\n const env = options?.env ?? DEFAULT_ENV;\n\n // Env file candidates are resolved relative to the working directory\n const cacheKey = `${process.cwd()}|${env}|${options?.envFile ?? ''}`;\n\n const cachedEntry = envFileCache.get(cacheKey);\n\n if (cachedEntry) {\n if (cachedEntry.envFilePath === undefined) {\n // No env file existed. Re-probe cheaply in case one was created since.\n const envFilePath = getEnvFilePath(env, options?.envFile);\n if (!envFilePath) return cachedEntry.parsedEnv;\n } else {\n try {\n const stats = statSync(cachedEntry.envFilePath);\n if (\n stats.mtimeMs === cachedEntry.mtimeMs &&\n stats.size === cachedEntry.size\n ) {\n return cachedEntry.parsedEnv;\n }\n } catch {\n // File was removed — fall through and re-resolve\n }\n }\n }\n\n const envFilePath = getEnvFilePath(env, options?.envFile);\n\n if (!envFilePath) {\n envFileCache.set(cacheKey, {\n envFilePath: undefined,\n mtimeMs: 0,\n size: 0,\n parsedEnv: {},\n });\n return {};\n }\n\n const parsedEnv = parseEnvFile(envFilePath);\n\n try {\n const stats = statSync(envFilePath);\n envFileCache.set(cacheKey, {\n envFilePath,\n mtimeMs: stats.mtimeMs,\n size: stats.size,\n parsedEnv,\n });\n } catch {\n // Race: file removed between parse and stat — skip caching this round\n }\n\n return parsedEnv; // Return the parsed env object\n};\n"],"mappings":";;;;;;;AAGA,MAAM,cAAc,QAAQ,IAAI,YAAY;AAO5C,MAAa,kBACX,MAAc,QAAQ,IAAI,YAAY,eACtC,YACuB;AAKvB,SAJiB,UACb,CAAC,QAAQ,GACT;EAAC,QAAQ,IAAI;EAAS,QAAQ;EAAO;EAAc;EAAO,EAE9C,KAAKA,mBAAW;;;;;;;;AAmBlC,MAAM,+BAAe,IAAI,KAAgC;AAEzD,MAAM,gBAAgB,gBAAgD;CACpE,MAAM,YAAoC,EAAE;AAE5C,gBAAO,OAAO;EACZ,MAAM;EACN,YAAY;EACZ,OAAO;EACR,CAAC;AAEF,QAAO;;AAGT,MAAa,eACX,YAC2B;CAC3B,MAAM,MAAM,SAAS,OAAO;CAG5B,MAAM,WAAW,GAAG,QAAQ,KAAK,CAAC,GAAG,IAAI,GAAG,SAAS,WAAW;CAEhE,MAAM,cAAc,aAAa,IAAI,SAAS;AAE9C,KAAI,YACF,KAAI,YAAY,gBAAgB,QAG9B;MAAI,CADgB,eAAe,KAAK,SAAS,QACjC,CAAE,QAAO,YAAY;OAErC,KAAI;EACF,MAAM,8BAAiB,YAAY,YAAY;AAC/C,MACE,MAAM,YAAY,YAAY,WAC9B,MAAM,SAAS,YAAY,KAE3B,QAAO,YAAY;SAEf;CAMZ,MAAM,cAAc,eAAe,KAAK,SAAS,QAAQ;AAEzD,KAAI,CAAC,aAAa;AAChB,eAAa,IAAI,UAAU;GACzB,aAAa;GACb,SAAS;GACT,MAAM;GACN,WAAW,EAAE;GACd,CAAC;AACF,SAAO,EAAE;;CAGX,MAAM,YAAY,aAAa,YAAY;AAE3C,KAAI;EACF,MAAM,8BAAiB,YAAY;AACnC,eAAa,IAAI,UAAU;GACzB;GACA,SAAS,MAAM;GACf,MAAM,MAAM;GACZ;GACD,CAAC;SACI;AAIR,QAAO"}
1
+ {"version":3,"file":"loadEnvFile.cjs","names":["existsSync"],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync, statSync } from 'node:fs';\nimport dotenv from 'dotenv';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\ntype EnvFileCacheEntry = {\n /** The env file that was resolved and parsed (undefined if none exists). */\n envFilePath: string | undefined;\n /** Fingerprint of the parsed file, used to detect edits. */\n mtimeMs: number;\n size: number;\n /** The parsed env variables. */\n parsedEnv: Record<string, string>;\n};\n\n/**\n * Cache of parsed env files keyed by `cwd|env|envFile`. Loading content\n * declarations calls `loadEnvFile` once per file; without this every call pays\n * up to 4 `existsSync` probes plus a dotenv read+parse. A cached hit is\n * validated with a single `stat` so edits to the env file are still picked up.\n */\nconst envFileCache = new Map<string, EnvFileCacheEntry>();\n\nconst parseEnvFile = (envFilePath: string): Record<string, string> => {\n const parsedEnv: Record<string, string> = {};\n\n dotenv.config({\n path: envFilePath,\n processEnv: parsedEnv,\n quiet: true,\n });\n\n return parsedEnv;\n};\n\nexport const loadEnvFile = (\n options?: Partial<LoadEnvFileOptions>\n): Record<string, string> => {\n const env = options?.env ?? DEFAULT_ENV;\n\n // Env file candidates are resolved relative to the working directory\n const cacheKey = `${process.cwd()}|${env}|${options?.envFile ?? ''}`;\n\n const cachedEntry = envFileCache.get(cacheKey);\n\n if (cachedEntry) {\n if (cachedEntry.envFilePath === undefined) {\n // No env file existed. Re-probe cheaply in case one was created since.\n const envFilePath = getEnvFilePath(env, options?.envFile);\n if (!envFilePath) return cachedEntry.parsedEnv;\n } else {\n try {\n const stats = statSync(cachedEntry.envFilePath);\n if (\n stats.mtimeMs === cachedEntry.mtimeMs &&\n stats.size === cachedEntry.size\n ) {\n return cachedEntry.parsedEnv;\n }\n } catch {\n // File was removed — fall through and re-resolve\n }\n }\n }\n\n const envFilePath = getEnvFilePath(env, options?.envFile);\n\n if (!envFilePath) {\n envFileCache.set(cacheKey, {\n envFilePath: undefined,\n mtimeMs: 0,\n size: 0,\n parsedEnv: {},\n });\n return {};\n }\n\n const parsedEnv = parseEnvFile(envFilePath);\n\n try {\n const stats = statSync(envFilePath);\n envFileCache.set(cacheKey, {\n envFilePath,\n mtimeMs: stats.mtimeMs,\n size: stats.size,\n parsedEnv,\n });\n } catch {\n // Race: file removed between parse and stat — skip caching this round\n }\n\n return par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defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  let node_path = require("node:path");
4
3
  let esbuild = require("esbuild");
5
4
  let node_url = require("node:url");
@@ -41,10 +40,11 @@ const getTransformationOptions = (filePath) => ({
41
40
  define: { "import.meta.url": JSON.stringify((0, node_url.pathToFileURL)(filePath).href) }
42
41
  });
43
42
  const bundleFileSync = (code, filePath, options) => {
43
+ const extension = (0, node_path.extname)(filePath);
44
44
  return (0, esbuild.buildSync)({
45
45
  stdin: {
46
46
  contents: code,
47
- loader: getLoader((0, node_path.extname)(filePath)),
47
+ loader: getLoader(extension),
48
48
  resolveDir: (0, node_path.dirname)(filePath),
49
49
  sourcefile: filePath
50
50
  },
@@ -53,10 +53,11 @@ const bundleFileSync = (code, filePath, options) => {
53
53
  }).outputFiles?.[0].text;
54
54
  };
55
55
  const bundleFile = async (code, filePath, options) => {
56
+ const extension = (0, node_path.extname)(filePath);
56
57
  return (await (0, esbuild.build)({
57
58
  stdin: {
58
59
  contents: code,
59
- loader: getLoader((0, node_path.extname)(filePath)),
60
+ loader: getLoader(extension),
60
61
  resolveDir: (0, node_path.dirname)(filePath),
61
62
  sourcefile: filePath
62
63
  },
@@ -1 +1 @@
1
- {"version":3,"file":"bundleFile.cjs","names":[],"sources":["../../../src/loadExternalFile/bundleFile.ts"],"sourcesContent":["import { dirname, extname } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n build,\n buildSync,\n type Loader,\n type Plugin,\n} from 'esbuild';\n\nexport type ESBuildPlugin = Plugin;\n\nexport const getLoader = (extension: string): Loader => {\n switch (extension) {\n case '.js':\n return 'js';\n case '.jsx':\n return 'jsx';\n case '.mjs':\n return 'js';\n case '.ts':\n return 'ts';\n case '.tsx':\n return 'tsx';\n case '.cjs':\n return 'js';\n case '.json':\n return 'json';\n case '.md':\n return 'text';\n case '.mdx':\n return 'text';\n default:\n return 'js';\n }\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: 'node16',\n platform: 'neutral',\n write: false,\n packages: 'bundle',\n external: ['esbuild'],\n bundle: true,\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n },\n});\n\nexport const bundleFileSync = (\n code: string,\n filePath: string,\n options?: BuildOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = buildSync({\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 ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n\nexport const bundleFile = async (\n code: string,\n filePath: string,\n options?: BuildOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = await build({\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 ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":";;;;;;;AAaA,MAAa,aAAa,cAA8B;AACtD,SAAQ,WAAR;EACE,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,QACE,QAAO;;;AAIb,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,UAAU,CAAC,UAAU;CACrB,QAAQ;CACR,QAAQ,EACN,mBAAmB,KAAK,sCAAwB,SAAS,CAAC,KAAK,EAChE;CACF;AAED,MAAa,kBACX,MACA,UACA,YACuB;AAiBvB,+BAb4C;EAC1C,OAAO;GACL,UAAU;GACV,QALW,iCADW,SACQ,CAKxB;GACN,mCAAoB,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAEsC,CAAC,cAAc,GAAG;;AAK3D,MAAa,aAAa,OACxB,MACA,UACA,YACgC;AAiBhC,SAF2B,yBAXmB;EAC5C,OAAO;GACL,UAAU;GACV,QALW,iCADW,SACQ,CAKxB;GACN,mCAAoB,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAAC,EAEsC,cAAc,GAAG"}
1
+ {"version":3,"file":"bundleFile.cjs","names":[],"sources":["../../../src/loadExternalFile/bundleFile.ts"],"sourcesContent":["import { dirname, extname } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n build,\n buildSync,\n type Loader,\n type Plugin,\n} from 'esbuild';\n\nexport type ESBuildPlugin = Plugin;\n\nexport const getLoader = (extension: string): Loader => {\n switch (extension) {\n case '.js':\n return 'js';\n case '.jsx':\n return 'jsx';\n case '.mjs':\n return 'js';\n case '.ts':\n return 'ts';\n case '.tsx':\n return 'tsx';\n case '.cjs':\n return 'js';\n case '.json':\n return 'json';\n case '.md':\n return 'text';\n case '.mdx':\n return 'text';\n default:\n return 'js';\n }\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: 'node16',\n platform: 'neutral',\n write: false,\n packages: 'bundle',\n external: ['esbuild'],\n bundle: true,\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n },\n});\n\nexport const bundleFileSync = (\n code: string,\n filePath: string,\n options?: BuildOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = buildSync({\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 ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n\nexport const bundleFile = async (\n code: string,\n filePath: string,\n options?: BuildOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = await build({\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 ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":";;;;;;AAaA,MAAa,aAAa,cAA8B;CACtD,QAAQ,WAAR;EACE,KAAK,OACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,SACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;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,UAAU,CAAC,SAAS;CACpB,QAAQ;CACR,QAAQ,EACN,mBAAmB,KAAK,sCAAwB,QAAQ,CAAC,CAAC,IAAI,EAChE;AACF;AAEA,MAAa,kBACX,MACA,UACA,YACuB;CACvB,MAAM,mCAAoB,QAAQ;CAgBlC,8BAb4C;EAC1C,OAAO;GACL,UAAU;GACV,QALW,UAAU,SAKhB;GACL,mCAAoB,QAAQ;GAC5B,YAAY;EACd;EACA,GAAG,yBAAyB,QAAQ;EACpC,GAAG;CACL,CAEsC,CAAC,CAAC,cAAc,EAAE,CAAC;AAG3D;AAEA,MAAa,aAAa,OACxB,MACA,UACA,YACgC;CAChC,MAAM,mCAAoB,QAAQ;CAgBlC,QAF2B,yBAXmB;EAC5C,OAAO;GACL,UAAU;GACV,QALW,UAAU,SAKhB;GACL,mCAAoB,QAAQ;GAC5B,YAAY;EACd;EACA,GAAG,yBAAyB,QAAQ;EACpC,GAAG;CACL,CAAC,EAEsC,CAAC,cAAc,EAAE,CAAC;AAG3D"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  let esbuild = require("esbuild");
4
3
 
5
4
  //#region src/loadExternalFile/bundleJSFile.ts
@@ -1 +1 @@
1
- {"version":3,"file":"bundleJSFile.cjs","names":[],"sources":["../../../src/loadExternalFile/bundleJSFile.ts"],"sourcesContent":["import { type BuildOptions, build } from 'esbuild';\n\nconst commonBuildOptions = {\n bundle: true,\n format: 'cjs',\n platform: 'node',\n target: 'es2019',\n sourcemap: false,\n logLevel: 'silent',\n write: true,\n // Bundle relative/local files, but keep bare module imports external\n packages: 'external',\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} as const;\n\nexport const bundleJSFile = async (buildOptions: BuildOptions) =>\n await build({\n ...commonBuildOptions,\n ...buildOptions,\n });\n"],"mappings":";;;;;AAEA,MAAM,qBAAqB;CACzB,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,WAAW;CACX,UAAU;CACV,OAAO;CAEP,UAAU;CACV,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;EACT;CACF;AAED,MAAa,eAAe,OAAO,iBACjC,yBAAY;CACV,GAAG;CACH,GAAG;CACJ,CAAC"}
1
+ {"version":3,"file":"bundleJSFile.cjs","names":[],"sources":["../../../src/loadExternalFile/bundleJSFile.ts"],"sourcesContent":["import { type BuildOptions, build } from 'esbuild';\n\nconst commonBuildOptions = {\n bundle: true,\n format: 'cjs',\n platform: 'node',\n target: 'es2019',\n sourcemap: false,\n logLevel: 'silent',\n write: true,\n // Bundle relative/local files, but keep bare module imports external\n packages: 'external',\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} as const;\n\nexport const bundleJSFile = async (buildOptions: BuildOptions) =>\n await build({\n ...commonBuildOptions,\n ...buildOptions,\n });\n"],"mappings":";;;;AAEA,MAAM,qBAAqB;CACzB,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,WAAW;CACX,UAAU;CACV,OAAO;CAEP,UAAU;CACV,QAAQ;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,OAAO;EACP,QAAQ;CACV;AACF;AAEA,MAAa,eAAe,OAAO,iBACjC,yBAAY;CACV,GAAG;CACH,GAAG;AACL,CAAC"}
@@ -66,7 +66,10 @@ const withPreloadedGlobals = (globals, fn) => {
66
66
  const loadExternalFile = async (filePath, options) => {
67
67
  const fileExtension = (0, node_path.extname)(filePath);
68
68
  try {
69
- if (fileExtension === ".json" || fileExtension === ".json5" || fileExtension === ".jsonc") return parseJSON5(await (0, node_fs_promises.readFile)(filePath, "utf-8"));
69
+ if (fileExtension === ".json" || fileExtension === ".json5" || fileExtension === ".jsonc") {
70
+ const fileContent = await (0, node_fs_promises.readFile)(filePath, "utf-8");
71
+ return parseJSON5(fileContent);
72
+ }
70
73
  const moduleResultString = await require_loadExternalFile_transpileTSToCJS.transpileTSToCJS(await (0, node_fs_promises.readFile)(filePath, "utf-8"), filePath, options?.buildOptions);
71
74
  if (!moduleResultString) {
72
75
  require_logger.logger("File could not be loaded.", { level: "error" });
@@ -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 /**\n * Key-value pairs to temporarily set on the main Node.js `globalThis` for the\n * synchronous duration of `parseFileContent` / `runInNewContext`. External modules\n * loaded via `require()` inside the VM (e.g. `@intlayer/core`'s `file()` helper)\n * run in the main context and read from the real `globalThis`, not the VM sandbox.\n * Values are restored (or deleted) after `runInNewContext` returns.\n */\n preloadGlobals?: Record<string, unknown>;\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 // parseFileContent/runInNewContext is synchronous, so withPreloadedGlobals\n // fully restores the globals before returning.\n const fileContent = withPreloadedGlobals(options?.preloadGlobals, () =>\n 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\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\nconst withPreloadedGlobals = <T>(\n globals: Record<string, unknown> | undefined,\n fn: () => T\n): T => {\n if (!globals) return fn();\n\n const globalVars = globalThis as Record<string, unknown>;\n const previousValues: Record<string, unknown> = {};\n const previouslyPresent: Record<string, boolean> = {};\n\n for (const [key, value] of Object.entries(globals)) {\n previouslyPresent[key] = key in globalVars;\n previousValues[key] = globalVars[key];\n globalVars[key] = value;\n }\n\n try {\n return fn();\n } finally {\n for (const key of Object.keys(globals)) {\n // `in` check (not `!== undefined`) so a global that legitimately held\n // `undefined` is restored rather than deleted.\n if (previouslyPresent[key]) {\n globalVars[key] = previousValues[key];\n } else {\n delete globalVars[key];\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 // parseFileContent/runInNewContext is synchronous, so withPreloadedGlobals\n // has no interleaving risk even when multiple files are processed concurrently.\n const fileContent = withPreloadedGlobals(options?.preloadGlobals, () =>\n 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\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;;;;;;AAqB1D,MAAa,wBACX,UACA,YACoB;CACpB,MAAM,uCAAwB,SAAS,IAAI;AAE3C,KAAI;AACF,MACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAk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ACV;AAED,MAAI,CAAC,oBAAoB;AACvB,yBAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAKF,MAAM,cAAc,qBAAqB,SAAS,sBAChDD,2DAAiB,oBAAoB;GACnC,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC,CACH;AAED,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
+ {"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 /**\n * Key-value pairs to temporarily set on the main Node.js `globalThis` for the\n * synchronous duration of `parseFileContent` / `runInNewContext`. External modules\n * loaded via `require()` inside the VM (e.g. `@intlayer/core`'s `file()` helper)\n * run in the main context and read from the real `globalThis`, not the VM sandbox.\n * Values are restored (or deleted) after `runInNewContext` returns.\n */\n preloadGlobals?: Record<string, unknown>;\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 // parseFileContent/runInNewContext is synchronous, so withPreloadedGlobals\n // fully restores the globals before returning.\n const fileContent = withPreloadedGlobals(options?.preloadGlobals, () =>\n 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\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\nconst withPreloadedGlobals = <T>(\n globals: Record<string, unknown> | undefined,\n fn: () => T\n): T => {\n if (!globals) return fn();\n\n const globalVars = globalThis as Record<string, unknown>;\n const previousValues: Record<string, unknown> = {};\n const previouslyPresent: Record<string, boolean> = {};\n\n for (const [key, value] of Object.entries(globals)) {\n previouslyPresent[key] = key in globalVars;\n previousValues[key] = globalVars[key];\n globalVars[key] = value;\n }\n\n try {\n return fn();\n } finally {\n for (const key of Object.keys(globals)) {\n // `in` check (not `!== undefined`) so a global that legitimately held\n // `undefined` is restored rather than deleted.\n if (previouslyPresent[key]) {\n globalVars[key] = previousValues[key];\n } else {\n delete globalVars[key];\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 // parseFileContent/runInNewContext is synchronous, so withPreloadedGlobals\n // has no interleaving risk even when multiple files are processed concurrently.\n const fileContent = withPreloadedGlobals(options?.preloadGlobals, () =>\n 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\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;;;;;;AAqB1D,MAAa,wBACX,UACA,YACoB;CACpB,MAAM,uCAAwB,QAAQ,KAAK;CAE3C,IAAI;EACF,IACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,UAGlB,OAAO,qCAAwB,UAAU,OAAO,CAAC;EAMnD,MAAM,qBAAyCC,yFA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EAEA,IAAI,CAAC,oBAAoB;GACvB,sBAAO,6BAA6B,EAAE,OAAO,QAAQ,CAAC;GACtD;EACF;EAIA,MAAM,cAAc,qBAAqB,SAAS,sBAChDD,2DAAiB,oBAAoB;GACnC,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;EACpB,CAAC,CACH;EAEA,IAAI,OAAO,gBAAgB,aAAa;GACtC,sBAAO,oCAAoCE,4BAAa,QAAQ,GAAG;GACnE;EACF;EAEA,OAAO;CACT,SAAS,OAAO;EACd,IAAI,SAAS,YAAY,MACvB,sBACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAChD,GACA,EACE,OAAO,QACT,CACF;CAEJ;AACF"}
@@ -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\n// Inject only Node.js-specific globals that are absent from a plain V8 context.\n// JS built-ins (Object, Array, Promise, Math, Date, JSON, Symbol, etc.) are\n// provided automatically by runInNewContext — no need to copy them.\n// Copying all of globalThis would retain hundreds of references (including the\n// full module cache via `global`) inside every sandbox, causing a memory leak.\nconst NODE_GLOBALS = [\n 'Buffer',\n 'setTimeout',\n 'clearTimeout',\n 'setInterval',\n 'clearInterval',\n 'setImmediate',\n 'clearImmediate',\n 'queueMicrotask',\n 'URL',\n 'URLSearchParams',\n 'TextEncoder',\n 'TextDecoder',\n 'AbortController',\n 'AbortSignal',\n 'performance',\n 'fetch',\n 'crypto',\n 'structuredClone',\n] as const;\n\n/**\n * Cache of the project's React module (or the JSX-capturing fallback) keyed by\n * the require's resolution paths. Node does not cache *failed* resolutions, so\n * without this every sandbox creation in a non-React project (Vue, Svelte,\n * Angular…) pays a full node_modules walk that ends in a throw.\n */\nconst reactModuleCache = new Map<string, { React: unknown }>();\n\n/**\n * Fallback React implementation used when React is not installed in the\n * project. It captures JSX elements as plain objects so JSX can be used in\n * content declarations (esbuild's tsx loader defaults to React.createElement).\n */\nconst createFallbackReact = () => ({\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\nconst getReactGlobal = (baseRequire: NodeJS.Require): { React: unknown } => {\n // resolve.paths() is computed in-memory (no fs access) and identifies the\n // node_modules chain this require instance resolves against.\n const resolutionKey =\n baseRequire.resolve.paths?.('react')?.join('|') ?? '<default>';\n\n const cachedReactModule = reactModuleCache.get(resolutionKey);\n if (cachedReactModule) return cachedReactModule;\n\n let reactGlobal: { React: unknown };\n try {\n // Dynamically try to require React if it's installed in the project\n reactGlobal = { React: baseRequire('react') };\n } catch (_err) {\n reactGlobal = { React: createFallbackReact() };\n }\n\n reactModuleCache.set(resolutionKey, reactGlobal);\n\n return reactGlobal;\n};\n\n/**\n * Snapshot of the non-env `process` properties, taken once at module load.\n * Spreading `process` enumerates ~100 properties (some behind getters); doing\n * it per sandbox is wasteful since everything except `env` is static.\n */\nconst processSnapshot = { ...process };\n\n/**\n * Builds the global context handed to `runInNewContext`.\n *\n * SECURITY NOTE: this sandbox exists for global-scope hygiene (fresh\n * module/exports, controlled env), NOT for containment. It exposes the real\n * project `require`, a copy of `process`, and `fetch` — code executed here has\n * full host privileges. Only ever run trusted, build-time project files\n * (same trust model as `vite.config.ts`).\n */\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\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 const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...processSnapshot,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...getReactGlobal(baseRequire),\n };\n\n for (const key of NODE_GLOBALS) {\n if (!(key in sandboxContext) && key in globalThis) {\n (sandboxContext as Record<string, unknown>)[key] =\n 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 let result: T | undefined;\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n result = candidate as T;\n break;\n }\n }\n\n // Drop heavy references so the V8 context created by runInNewContext can be\n // garbage-collected promptly. The extracted `result` is a plain data object\n // and does not retain the sandbox.\n (sandboxContext as Record<string, unknown>).require = undefined;\n (sandboxContext as Record<string, unknown>).process = undefined;\n (sandboxContext as Record<string, unknown>).React = undefined;\n (sandboxContext as Record<string, unknown>).module = undefined;\n (sandboxContext as Record<string, unknown>).exports = undefined;\n\n return result;\n};\n"],"mappings":";;;;;;;;;AA+BA,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;AAQD,MAAM,mCAAmB,IAAI,KAAiC;;;;;;AAO9D,MAAM,6BAA6B;CACjC,gBAAgB,MAAW,OAAY,GAAG,cAAqB;EAC7D;EACA,OAAO;GACL,GAAG;GACH,UAAU,SAAS,UAAU,IAAI,SAAS,KAAK;GAChD;EACF;CACD,UAAU,OAAO,IAAI,iBAAiB;CACvC;AAED,MAAM,kBAAkB,gBAAoD;CAG1E,MAAM,gBACJ,YAAY,QAAQ,QAAQ,QAAQ,EAAE,KAAK,IAAI,IAAI;CAErD,MAAM,oBAAoB,iBAAiB,IAAI,cAAc;AAC7D,KAAI,kBAAmB,QAAO;CAE9B,IAAI;AACJ,KAAI;AAEF,gBAAc,EAAE,OAAO,YAAY,QAAQ,EAAE;UACtC,MAAM;AACb,gBAAc,EAAE,OAAO,qBAAqB,EAAE;;AAGhD,kBAAiB,IAA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SAAS;EACxB,eAAe,QAAQ,SAAS;EAChC,eAAe,QAAQ,SAAS;EAChC,eAAe,QAAQ;EACxB;CAED,IAAI;AACJ,MAAK,MAAM,aAAa,WACtB,KACE,aACA,OAAO,cAAc,YACrB,OAAO,KAAK,UAAoB,CAAC,SAAS,GAC1C;AACA,WAAS;AACT;;AAOJ,CAAC,eAA2C,UAAU;AACtD,CAAC,eAA2C,UAAU;AACtD,CAAC,eAA2C,QAAQ;AACpD,CAAC,eAA2C,SAAS;AACrD,CAAC,eAA2C,UAAU;AAEtD,QAAO"}
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\n// Inject only Node.js-specific globals that are absent from a plain V8 context.\n// JS built-ins (Object, Array, Promise, Math, Date, JSON, Symbol, etc.) are\n// provided automatically by runInNewContext — no need to copy them.\n// Copying all of globalThis would retain hundreds of references (including the\n// full module cache via `global`) inside every sandbox, causing a memory leak.\nconst NODE_GLOBALS = [\n 'Buffer',\n 'setTimeout',\n 'clearTimeout',\n 'setInterval',\n 'clearInterval',\n 'setImmediate',\n 'clearImmediate',\n 'queueMicrotask',\n 'URL',\n 'URLSearchParams',\n 'TextEncoder',\n 'TextDecoder',\n 'AbortController',\n 'AbortSignal',\n 'performance',\n 'fetch',\n 'crypto',\n 'structuredClone',\n] as const;\n\n/**\n * Cache of the project's React module (or the JSX-capturing fallback) keyed by\n * the require's resolution paths. Node does not cache *failed* resolutions, so\n * without this every sandbox creation in a non-React project (Vue, Svelte,\n * Angular…) pays a full node_modules walk that ends in a throw.\n */\nconst reactModuleCache = new Map<string, { React: unknown }>();\n\n/**\n * Fallback React implementation used when React is not installed in the\n * project. It captures JSX elements as plain objects so JSX can be used in\n * content declarations (esbuild's tsx loader defaults to React.createElement).\n */\nconst createFallbackReact = () => ({\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\nconst getReactGlobal = (baseRequire: NodeJS.Require): { React: unknown } => {\n // resolve.paths() is computed in-memory (no fs access) and identifies the\n // node_modules chain this require instance resolves against.\n const resolutionKey =\n baseRequire.resolve.paths?.('react')?.join('|') ?? '<default>';\n\n const cachedReactModule = reactModuleCache.get(resolutionKey);\n if (cachedReactModule) return cachedReactModule;\n\n let reactGlobal: { React: unknown };\n try {\n // Dynamically try to require React if it's installed in the project\n reactGlobal = { React: baseRequire('react') };\n } catch (_err) {\n reactGlobal = { React: createFallbackReact() };\n }\n\n reactModuleCache.set(resolutionKey, reactGlobal);\n\n return reactGlobal;\n};\n\n/**\n * Snapshot of the non-env `process` properties, taken once at module load.\n * Spreading `process` enumerates ~100 properties (some behind getters); doing\n * it per sandbox is wasteful since everything except `env` is static.\n */\nconst processSnapshot = { ...process };\n\n/**\n * Builds the global context handed to `runInNewContext`.\n *\n * SECURITY NOTE: this sandbox exists for global-scope hygiene (fresh\n * module/exports, controlled env), NOT for containment. It exposes the real\n * project `require`, a copy of `process`, and `fetch` — code executed here has\n * full host privileges. Only ever run trusted, build-time project files\n * (same trust model as `vite.config.ts`).\n */\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\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 const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...processSnapshot,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...getReactGlobal(baseRequire),\n };\n\n for (const key of NODE_GLOBALS) {\n if (!(key in sandboxContext) && key in globalThis) {\n (sandboxContext as Record<string, unknown>)[key] =\n 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 let result: T | undefined;\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n result = candidate as T;\n break;\n }\n }\n\n // Drop heavy references so the V8 context created by runInNewContext can be\n // garbage-collected promptly. The extracted `result` is a plain data object\n // and does not retain the sandbox.\n (sandboxContext as Record<string, unknown>).require = undefined;\n (sandboxContext as Record<string, unknown>).process = undefined;\n (sandboxContext as Record<string, unknown>).React = undefined;\n (sandboxContext as Record<string, unknown>).module = undefined;\n (sandboxContext as Record<string, unknown>).exports = undefined;\n\n return result;\n};\n"],"mappings":";;;;;;;;;AA+BA,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAQA,MAAM,mCAAmB,IAAI,IAAgC;;;;;;AAO7D,MAAM,6BAA6B;CACjC,gBAAgB,MAAW,OAAY,GAAG,cAAqB;EAC7D;EACA,OAAO;GACL,GAAG;GACH,UAAU,SAAS,UAAU,IAAI,SAAS,KAAK;EACjD;CACF;CACA,UAAU,OAAO,IAAI,gBAAgB;AACvC;AAEA,MAAM,kBAAkB,gBAAoD;CAG1E,MAAM,gBACJ,YAAY,QAAQ,QAAQ,OAAO,CAAC,EAAE,KAAK,GAAG,KAAK;CAErD,MAAM,oBAAoB,iBAAiB,IAAI,aAAa;CAC5D,IAAI,mBAAmB,OAAO;CAE9B,IAAI;CACJ,IAAI;EAEF,cAAc,EAAE,OAAO,YAAY,OAAO,EAAE;CAC9C,SAAS,MAAM;EACb,cAAc,EAAE,OAAO,oBAAoB,EAAE;CAC/C;CAEA,iBAAiB,IAAI,eAAe,WAAW;CAE/C,OAAO;AACT;;;;;;AAOA,MAAM,kBAAkB,EAAE,GAAG,QAAQ;;;;;;;;;;AAWrC,MAAa,qBAAqB,YAA6C;CAC7E,MAAM,EAAE,eAAe,gBAAgB,mBAAmB,OAAO,YA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AAO,KAAK,SAAmB,CAAC,CAAC,SAAS,GAC1C;EACA,SAAS;EACT;CACF;CAMF,AAAC,eAA2C,UAAU;CACtD,AAAC,eAA2C,UAAU;CACtD,AAAC,eAA2C,QAAQ;CACpD,AAAC,eAA2C,SAAS;CACrD,AAAC,eAA2C,UAAU;CAEtD,OAAO;AACT"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_utils_cacheMemory = require('../utils/cacheMemory.cjs');
4
3
  const require_utils_getPackageJsonPath = require('../utils/getPackageJsonPath.cjs');
5
4
  const require_loadExternalFile_bundleFile = require('./bundleFile.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"transpileTSToCJS.cjs","names":["getPackageJsonPath","getLoader","computeKeyId","buildSync","build"],"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,KAAiC;AAE/D,MAAM,mBAAmB,aAAyC;CAChE,MAAM,uCAAwB,SAAS;AAEvC,KAAI,kBAAkB,IAAI,cAAc,CACtC,QAAO,kBAAkB,IAAI,cAAc;CAG7C,IAAI;AACJ,KAAI;EACF,MAAM,mCACJA,oDAAmB,cAAc,CAAC,SAClC,gBACD;AAGD,yCAA0B,aAAa,G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AY;;;CAKpB,MAAM,qBAAqB,aAAc,cAAc,IAAI;AAE3D,KAAI,OAAO,uBAAuB,SAChC,wBACE,UACA,UACA,YACA,cACA,mBACD;AAGH,QAAO;;AAGT,MAAa,mBAAmB,OAC9B,MACA,UACA,YACgC;CAEhC,MAAM,SAASF,qEADW,SACQ,CAAC;CAEnC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,WAAW,EAAE;CAE1D,MAAM,WAAWC,uCAAa,CAAC,KAAK,CAAC;CACrC,MAAM,aAAaA,uCAAa,CAAC,aAAa,CAAC;CAE/C,MAAM,eAAe,uBAAuB,UAAU,UAAU,WAAW;AAC3E,KAAI,OAAO,iBAAiB,SAAU,QAAO;CAM7C,MAAM,eAAe,OAFA,iBAAiB,SAASE,eAEP;EACtC,OAAO;GACL,UAAU;GACV;GACA,mCAAoB,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAAC;CAEF,MAAM,qBAAqB,aAAa,cAAc,IAAI;AAE1D,KAAI,OAAO,uBAAuB,SAChC,wBACE,UACA,UACA,YACA,cACA,mBACD;AAGH,QAAO"}
1
+ {"version":3,"file":"transpileTSToCJS.cjs","names":["getPackageJsonPath","getLoader","computeKeyId","buildSync","build"],"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,MA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AAE,mCAAoB,YAAY;CACpC,QAAQ,CAER;CAGF,IAAI;CACJ,IAAI;EACF,eAAe,iBAAiB;GAC9B,OAAO;IACL,UAAU;IACV;IACA,mCAAoB,QAAQ;IAC5B,YAAY;GACd;GACA,GAAG,yBAAyB,QAAQ;GACpC,GAAG;EACL,CAAC;CACH,UAAU;EAER,IAAI,CAAC,aAAa;GAChB,IAAI,iBAAiB,QAEnB,OAAO,EAAE;QAET,EAAE,aAAa;GAEjB,IAAI,gBAAgB,QAElB,OAAO,EAAE;QAET,EAAE,YAAY;EAElB;CACF;CAEA,MAAM,qBAAqB,aAAc,cAAc,EAAE,EAAE;CAE3D,IAAI,OAAO,uBAAuB,UAChC,uBACE,UACA,UACA,YACA,cACA,kBACF;CAGF,OAAO;AACT;AAEA,MAAa,mBAAmB,OAC9B,MACA,UACA,YACgC;CAEhC,MAAM,SAASF,qEADW,QACO,CAAC;CAElC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,WAAW,CAAC;CAEzD,MAAM,WAAWC,uCAAa,CAAC,IAAI,CAAC;CACpC,MAAM,aAAaA,uCAAa,CAAC,YAAY,CAAC;CAE9C,MAAM,eAAe,uBAAuB,UAAU,UAAU,UAAU;CAC1E,IAAI,OAAO,iBAAiB,UAAU,OAAO;CAM7C,MAAM,eAAe,OAFA,iBAAiB,SAASE,cAER,CAAC;EACtC,OAAO;GACL,UAAU;GACV;GACA,mCAAoB,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"}
@@ -94,7 +94,8 @@ const colorizeObject = (obj, indentLevel = 0, indentSize = 2, key) => {
94
94
  return `{\n${keys.map((key) => {
95
95
  const coloredKey = colorize(`"${key}"`, require_colors.GREY_LIGHT);
96
96
  const value = obj[key];
97
- return `${nextIndent}${coloredKey}: ${colorizeObject(value, indentLevel + 1, indentSize, key)}`;
97
+ const coloredValue = colorizeObject(value, indentLevel + 1, indentSize, key);
98
+ return `${nextIndent}${coloredKey}: ${coloredValue}`;
98
99
  }).join(",\n")}\n${indent}}`;
99
100
  }
100
101
  return colorize(String(obj), require_colors.GREY);