@intlayer/config 8.4.4 → 8.4.6

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 (227) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/cjs/built.cjs +7 -1
  3. package/dist/cjs/built.cjs.map +1 -1
  4. package/dist/cjs/client.cjs +16 -1
  5. package/dist/cjs/colors.cjs +33 -1
  6. package/dist/cjs/colors.cjs.map +1 -1
  7. package/dist/cjs/configFile/buildConfigurationFields.cjs +199 -1
  8. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  9. package/dist/cjs/configFile/configurationSchema.cjs +210 -1
  10. package/dist/cjs/configFile/configurationSchema.cjs.map +1 -1
  11. package/dist/cjs/configFile/getConfiguration.cjs +69 -1
  12. package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
  13. package/dist/cjs/configFile/index.cjs +28 -1
  14. package/dist/cjs/configFile/loadConfigurationFile.cjs +30 -1
  15. package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
  16. package/dist/cjs/configFile/searchConfigurationFile.cjs +53 -1
  17. package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
  18. package/dist/cjs/defaultValues/build.cjs +35 -1
  19. package/dist/cjs/defaultValues/build.cjs.map +1 -1
  20. package/dist/cjs/defaultValues/compiler.cjs +13 -1
  21. package/dist/cjs/defaultValues/compiler.cjs.map +1 -1
  22. package/dist/cjs/defaultValues/content.cjs +40 -1
  23. package/dist/cjs/defaultValues/content.cjs.map +1 -1
  24. package/dist/cjs/defaultValues/dictionary.cjs +13 -1
  25. package/dist/cjs/defaultValues/dictionary.cjs.map +1 -1
  26. package/dist/cjs/defaultValues/editor.cjs +23 -1
  27. package/dist/cjs/defaultValues/editor.cjs.map +1 -1
  28. package/dist/cjs/defaultValues/index.cjs +66 -1
  29. package/dist/cjs/defaultValues/internationalization.cjs +15 -1
  30. package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
  31. package/dist/cjs/defaultValues/log.cjs +10 -1
  32. package/dist/cjs/defaultValues/log.cjs.map +1 -1
  33. package/dist/cjs/defaultValues/routing.cjs +19 -1
  34. package/dist/cjs/defaultValues/routing.cjs.map +1 -1
  35. package/dist/cjs/defaultValues/system.cjs +29 -1
  36. package/dist/cjs/defaultValues/system.cjs.map +1 -1
  37. package/dist/cjs/loadEnvFile.cjs +31 -1
  38. package/dist/cjs/loadEnvFile.cjs.map +1 -1
  39. package/dist/cjs/loadExternalFile/bundleFile.cjs +71 -1
  40. package/dist/cjs/loadExternalFile/bundleFile.cjs.map +1 -1
  41. package/dist/cjs/loadExternalFile/bundleJSFile.cjs +33 -1
  42. package/dist/cjs/loadExternalFile/bundleJSFile.cjs.map +1 -1
  43. package/dist/cjs/loadExternalFile/index.cjs +17 -1
  44. package/dist/cjs/loadExternalFile/loadExternalFile.cjs +77 -1
  45. package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
  46. package/dist/cjs/loadExternalFile/parseFileContent.cjs +77 -1
  47. package/dist/cjs/loadExternalFile/parseFileContent.cjs.map +1 -1
  48. package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs +67 -1
  49. package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs.map +1 -1
  50. package/dist/cjs/logger.cjs +133 -1
  51. package/dist/cjs/logger.cjs.map +1 -1
  52. package/dist/cjs/node.cjs +28 -1
  53. package/dist/cjs/utils/ESMxCJSHelpers.cjs +27 -1
  54. package/dist/cjs/utils/ESMxCJSHelpers.cjs.map +1 -1
  55. package/dist/cjs/utils/alias.cjs +29 -1
  56. package/dist/cjs/utils/alias.cjs.map +1 -1
  57. package/dist/cjs/utils/cacheDisk.cjs +173 -1
  58. package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
  59. package/dist/cjs/utils/cacheMemory.cjs +269 -1
  60. package/dist/cjs/utils/cacheMemory.cjs.map +1 -1
  61. package/dist/cjs/utils/clearModuleCache.cjs +26 -1
  62. package/dist/cjs/utils/clearModuleCache.cjs.map +1 -1
  63. package/dist/cjs/utils/compareVersions.cjs +38 -1
  64. package/dist/cjs/utils/compareVersions.cjs.map +1 -1
  65. package/dist/cjs/utils/extractErrorMessage.cjs +95 -1
  66. package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
  67. package/dist/cjs/utils/getExtension.cjs +14 -1
  68. package/dist/cjs/utils/getExtension.cjs.map +1 -1
  69. package/dist/cjs/utils/getPackageJsonPath.cjs +33 -1
  70. package/dist/cjs/utils/getPackageJsonPath.cjs.map +1 -1
  71. package/dist/cjs/utils/index.cjs +45 -1
  72. package/dist/cjs/utils/logStack.cjs +17 -1
  73. package/dist/cjs/utils/logStack.cjs.map +1 -1
  74. package/dist/cjs/utils/normalizePath.cjs +17 -1
  75. package/dist/cjs/utils/normalizePath.cjs.map +1 -1
  76. package/dist/cjs/utils/parseFilePathPattern.cjs +24 -1
  77. package/dist/cjs/utils/parseFilePathPattern.cjs.map +1 -1
  78. package/dist/cjs/utils/retryManager.cjs +45 -1
  79. package/dist/cjs/utils/retryManager.cjs.map +1 -1
  80. package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs +13 -1
  81. package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs.map +1 -1
  82. package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs +16 -1
  83. package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs.map +1 -1
  84. package/dist/cjs/utils/stringFormatter/index.cjs +10 -1
  85. package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs +14 -1
  86. package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs.map +1 -1
  87. package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs +19 -1
  88. package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs.map +1 -1
  89. package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
  90. package/dist/esm/built.mjs +7 -1
  91. package/dist/esm/built.mjs.map +1 -1
  92. package/dist/esm/client.mjs +9 -1
  93. package/dist/esm/colors.mjs +18 -1
  94. package/dist/esm/colors.mjs.map +1 -1
  95. package/dist/esm/configFile/buildConfigurationFields.mjs +197 -1
  96. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  97. package/dist/esm/configFile/configurationSchema.mjs +191 -1
  98. package/dist/esm/configFile/configurationSchema.mjs.map +1 -1
  99. package/dist/esm/configFile/getConfiguration.mjs +66 -1
  100. package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
  101. package/dist/esm/configFile/index.mjs +6 -1
  102. package/dist/esm/configFile/loadConfigurationFile.mjs +29 -1
  103. package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
  104. package/dist/esm/configFile/searchConfigurationFile.mjs +50 -1
  105. package/dist/esm/configFile/searchConfigurationFile.mjs.map +1 -1
  106. package/dist/esm/defaultValues/build.mjs +28 -1
  107. package/dist/esm/defaultValues/build.mjs.map +1 -1
  108. package/dist/esm/defaultValues/compiler.mjs +8 -1
  109. package/dist/esm/defaultValues/compiler.mjs.map +1 -1
  110. package/dist/esm/defaultValues/content.mjs +32 -1
  111. package/dist/esm/defaultValues/content.mjs.map +1 -1
  112. package/dist/esm/defaultValues/dictionary.mjs +8 -1
  113. package/dist/esm/defaultValues/dictionary.mjs.map +1 -1
  114. package/dist/esm/defaultValues/editor.mjs +13 -1
  115. package/dist/esm/defaultValues/editor.mjs.map +1 -1
  116. package/dist/esm/defaultValues/index.mjs +11 -1
  117. package/dist/esm/defaultValues/internationalization.mjs +10 -1
  118. package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
  119. package/dist/esm/defaultValues/log.mjs +8 -1
  120. package/dist/esm/defaultValues/log.mjs.map +1 -1
  121. package/dist/esm/defaultValues/routing.mjs +11 -1
  122. package/dist/esm/defaultValues/routing.mjs.map +1 -1
  123. package/dist/esm/defaultValues/system.mjs +16 -1
  124. package/dist/esm/defaultValues/system.mjs.map +1 -1
  125. package/dist/esm/loadEnvFile.mjs +27 -1
  126. package/dist/esm/loadEnvFile.mjs.map +1 -1
  127. package/dist/esm/loadExternalFile/bundleFile.mjs +67 -1
  128. package/dist/esm/loadExternalFile/bundleFile.mjs.map +1 -1
  129. package/dist/esm/loadExternalFile/bundleJSFile.mjs +31 -1
  130. package/dist/esm/loadExternalFile/bundleJSFile.mjs.map +1 -1
  131. package/dist/esm/loadExternalFile/index.mjs +7 -1
  132. package/dist/esm/loadExternalFile/loadExternalFile.mjs +73 -1
  133. package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
  134. package/dist/esm/loadExternalFile/parseFileContent.mjs +73 -1
  135. package/dist/esm/loadExternalFile/parseFileContent.mjs.map +1 -1
  136. package/dist/esm/loadExternalFile/transpileTSToCJS.mjs +64 -1
  137. package/dist/esm/loadExternalFile/transpileTSToCJS.mjs.map +1 -1
  138. package/dist/esm/logger.mjs +118 -1
  139. package/dist/esm/logger.mjs.map +1 -1
  140. package/dist/esm/node.mjs +6 -1
  141. package/dist/esm/utils/ESMxCJSHelpers.mjs +25 -1
  142. package/dist/esm/utils/ESMxCJSHelpers.mjs.map +1 -0
  143. package/dist/esm/utils/alias.mjs +27 -1
  144. package/dist/esm/utils/alias.mjs.map +1 -1
  145. package/dist/esm/utils/cacheDisk.mjs +170 -1
  146. package/dist/esm/utils/cacheDisk.mjs.map +1 -1
  147. package/dist/esm/utils/cacheMemory.mjs +261 -1
  148. package/dist/esm/utils/cacheMemory.mjs.map +1 -1
  149. package/dist/esm/utils/clearModuleCache.mjs +25 -1
  150. package/dist/esm/utils/clearModuleCache.mjs.map +1 -1
  151. package/dist/esm/utils/compareVersions.mjs +36 -1
  152. package/dist/esm/utils/compareVersions.mjs.map +1 -1
  153. package/dist/esm/utils/extractErrorMessage.mjs +93 -1
  154. package/dist/esm/utils/extractErrorMessage.mjs.map +1 -1
  155. package/dist/esm/utils/getExtension.mjs +12 -1
  156. package/dist/esm/utils/getExtension.mjs.map +1 -1
  157. package/dist/esm/utils/getPackageJsonPath.mjs +31 -1
  158. package/dist/esm/utils/getPackageJsonPath.mjs.map +1 -1
  159. package/dist/esm/utils/index.mjs +19 -1
  160. package/dist/esm/utils/logStack.mjs +16 -1
  161. package/dist/esm/utils/logStack.mjs.map +1 -1
  162. package/dist/esm/utils/normalizePath.mjs +15 -1
  163. package/dist/esm/utils/normalizePath.mjs.map +1 -1
  164. package/dist/esm/utils/parseFilePathPattern.mjs +21 -1
  165. package/dist/esm/utils/parseFilePathPattern.mjs.map +1 -1
  166. package/dist/esm/utils/retryManager.mjs +44 -1
  167. package/dist/esm/utils/retryManager.mjs.map +1 -1
  168. package/dist/esm/utils/stringFormatter/camelCaseToKebabCase.mjs +11 -1
  169. package/dist/esm/utils/stringFormatter/camelCaseToKebabCase.mjs.map +1 -1
  170. package/dist/esm/utils/stringFormatter/camelCaseToSentence.mjs +14 -1
  171. package/dist/esm/utils/stringFormatter/camelCaseToSentence.mjs.map +1 -1
  172. package/dist/esm/utils/stringFormatter/index.mjs +6 -1
  173. package/dist/esm/utils/stringFormatter/kebabCaseToCamelCase.mjs +12 -1
  174. package/dist/esm/utils/stringFormatter/kebabCaseToCamelCase.mjs.map +1 -1
  175. package/dist/esm/utils/stringFormatter/toLowerCamelCase.mjs +17 -1
  176. package/dist/esm/utils/stringFormatter/toLowerCamelCase.mjs.map +1 -1
  177. package/dist/types/client.d.ts +4 -4
  178. package/dist/types/colors.d.ts +20 -2
  179. package/dist/types/colors.d.ts.map +1 -0
  180. package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
  181. package/dist/types/configFile/configurationSchema.d.ts +10 -10
  182. package/dist/types/configFile/getConfiguration.d.ts +2 -2
  183. package/dist/types/configFile/loadConfigurationFile.d.ts +1 -1
  184. package/dist/types/configFile/loadConfigurationFile.d.ts.map +1 -1
  185. package/dist/types/loadEnvFile.d.ts +10 -2
  186. package/dist/types/loadEnvFile.d.ts.map +1 -0
  187. package/dist/types/loadExternalFile/index.d.ts +3 -3
  188. package/dist/types/loadExternalFile/loadExternalFile.d.ts +25 -2
  189. package/dist/types/loadExternalFile/loadExternalFile.d.ts.map +1 -0
  190. package/dist/types/loadExternalFile/parseFileContent.d.ts +29 -2
  191. package/dist/types/loadExternalFile/parseFileContent.d.ts.map +1 -0
  192. package/dist/types/loadExternalFile/transpileTSToCJS.d.ts +19 -2
  193. package/dist/types/loadExternalFile/transpileTSToCJS.d.ts.map +1 -0
  194. package/dist/types/logger.d.ts +4 -4
  195. package/dist/types/logger.d.ts.map +1 -1
  196. package/dist/types/utils/index.d.ts +4 -4
  197. package/dist/types/utils/stringFormatter/camelCaseToKebabCase.d.ts +9 -2
  198. package/dist/types/utils/stringFormatter/camelCaseToKebabCase.d.ts.map +1 -0
  199. package/dist/types/utils/stringFormatter/camelCaseToSentence.d.ts +9 -2
  200. package/dist/types/utils/stringFormatter/camelCaseToSentence.d.ts.map +1 -0
  201. package/dist/types/utils/stringFormatter/index.d.ts +4 -4
  202. package/dist/types/utils/stringFormatter/kebabCaseToCamelCase.d.ts +5 -2
  203. package/dist/types/utils/stringFormatter/kebabCaseToCamelCase.d.ts.map +1 -0
  204. package/dist/types/utils/stringFormatter/toLowerCamelCase.d.ts +10 -2
  205. package/dist/types/utils/stringFormatter/toLowerCamelCase.d.ts.map +1 -0
  206. package/package.json +2 -2
  207. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  208. package/dist/esm/ESMxCJSHelpers-BAuqwNXV.mjs +0 -2
  209. package/dist/esm/ESMxCJSHelpers-BAuqwNXV.mjs.map +0 -1
  210. package/dist/types/camelCaseToKebabCase-BV_lLJHR.d.ts +0 -9
  211. package/dist/types/camelCaseToKebabCase-BV_lLJHR.d.ts.map +0 -1
  212. package/dist/types/camelCaseToSentence-DAbbkwe6.d.ts +0 -9
  213. package/dist/types/camelCaseToSentence-DAbbkwe6.d.ts.map +0 -1
  214. package/dist/types/colors-BbZeGWYU.d.ts +0 -20
  215. package/dist/types/colors-BbZeGWYU.d.ts.map +0 -1
  216. package/dist/types/kebabCaseToCamelCase-h9PkNVuO.d.ts +0 -5
  217. package/dist/types/kebabCaseToCamelCase-h9PkNVuO.d.ts.map +0 -1
  218. package/dist/types/loadEnvFile-BiTBX4fe.d.ts +0 -10
  219. package/dist/types/loadEnvFile-BiTBX4fe.d.ts.map +0 -1
  220. package/dist/types/loadExternalFile-DmM_TGcA.d.ts +0 -25
  221. package/dist/types/loadExternalFile-DmM_TGcA.d.ts.map +0 -1
  222. package/dist/types/parseFileContent--o_QlW5j.d.ts +0 -29
  223. package/dist/types/parseFileContent--o_QlW5j.d.ts.map +0 -1
  224. package/dist/types/toLowerCamelCase-DUdT00I1.d.ts +0 -10
  225. package/dist/types/toLowerCamelCase-DUdT00I1.d.ts.map +0 -1
  226. package/dist/types/transpileTSToCJS-OifpV3zk.d.ts +0 -19
  227. package/dist/types/transpileTSToCJS-OifpV3zk.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"editor.mjs","names":[],"sources":["../../../src/defaultValues/editor.ts"],"sourcesContent":["export const APPLICATION_URL = undefined;\nexport const EDITOR_URL = 'http://localhost:8000';\nexport const CMS_URL = 'https://app.intlayer.org';\nexport const BACKEND_URL = 'https://back.intlayer.org';\nexport const PORT = 8000;\nexport const IS_ENABLED = false;\nexport const LIVE_SYNC = true;\nexport const DICTIONARY_PRIORITY_STRATEGY = 'local_first';\nexport const LIVE_SYNC_PORT = 4000;\n"],"mappings":"AAAA,MAAa,EAAkB,IAAA,GAClB,EAAa,wBACb,EAAU,2BACV,EAAc,4BACd,EAAO,IACP,EAAa,GACb,EAAY,GACZ,EAA+B,cAC/B,EAAiB"}
1
+ {"version":3,"file":"editor.mjs","names":[],"sources":["../../../src/defaultValues/editor.ts"],"sourcesContent":["export const APPLICATION_URL = undefined;\nexport const EDITOR_URL = 'http://localhost:8000';\nexport const CMS_URL = 'https://app.intlayer.org';\nexport const BACKEND_URL = 'https://back.intlayer.org';\nexport const PORT = 8000;\nexport const IS_ENABLED = false;\nexport const LIVE_SYNC = true;\nexport const DICTIONARY_PRIORITY_STRATEGY = 'local_first';\nexport const LIVE_SYNC_PORT = 4000;\n"],"mappings":";AAAA,MAAa,kBAAkB;AAC/B,MAAa,aAAa;AAC1B,MAAa,UAAU;AACvB,MAAa,cAAc;AAC3B,MAAa,OAAO;AACpB,MAAa,aAAa;AAC1B,MAAa,YAAY;AACzB,MAAa,+BAA+B;AAC5C,MAAa,iBAAiB"}
@@ -1 +1,11 @@
1
- import{BUILD_MODE as e,CACHE as t,OPTIMIZE as n,OUTPUT_FORMAT as r,TRAVERSE_PATTERN as i,TYPE_CHECKING as a}from"./build.mjs";import{COMPILER_DICTIONARY_KEY_PREFIX as o,COMPILER_ENABLED as s,COMPILER_NO_METADATA as c,COMPILER_SAVE_COMPONENTS as l}from"./compiler.mjs";import{CODE_DIR as u,CONTENT_DIR as d,EXCLUDED_PATHS as f,FILE_EXTENSIONS as p,I18NEXT_DICTIONARIES_DIR as m,REACT_INTL_MESSAGES_DIR as h,WATCH as g}from"./content.mjs";import{CONTENT_AUTO_TRANSFORMATION as _,FILL as v,IMPORT_MODE as y,LOCATION as b}from"./dictionary.mjs";import{APPLICATION_URL as x,BACKEND_URL as S,CMS_URL as C,DICTIONARY_PRIORITY_STRATEGY as w,EDITOR_URL as T,IS_ENABLED as E,LIVE_SYNC as D,LIVE_SYNC_PORT as O,PORT as k}from"./editor.mjs";import{DEFAULT_LOCALE as A,LOCALES as j,REQUIRED_LOCALES as M,STRICT_MODE as N}from"./internationalization.mjs";import{MODE as P,PREFIX as F}from"./log.mjs";import{BASE_PATH as I,COOKIE_NAME as L,HEADER_NAME as R,LOCALE_STORAGE_NAME as z,ROUTING_MODE as B,SERVER_SET_COOKIE as V,STORAGE as H}from"./routing.mjs";import{CACHE_DIR as U,CONFIG_DIR as W,DICTIONARIES_DIR as G,DYNAMIC_DICTIONARIES_DIR as K,FETCH_DICTIONARIES_DIR as q,MAIN_DIR as J,MASKS_DIR as Y,MODULE_AUGMENTATION_DIR as X,REMOTE_DICTIONARIES_DIR as Z,TEMP_DIR as Q,TYPES_DIR as $,UNMERGED_DICTIONARIES_DIR as ee}from"./system.mjs";export{x as APPLICATION_URL,S as BACKEND_URL,I as BASE_PATH,e as BUILD_MODE,t as CACHE,U as CACHE_DIR,C as CMS_URL,u as CODE_DIR,o as COMPILER_DICTIONARY_KEY_PREFIX,s as COMPILER_ENABLED,c as COMPILER_NO_METADATA,l as COMPILER_SAVE_COMPONENTS,W as CONFIG_DIR,_ as CONTENT_AUTO_TRANSFORMATION,d as CONTENT_DIR,L as COOKIE_NAME,A as DEFAULT_LOCALE,G as DICTIONARIES_DIR,w as DICTIONARY_PRIORITY_STRATEGY,K as DYNAMIC_DICTIONARIES_DIR,T as EDITOR_URL,f as EXCLUDED_PATHS,q as FETCH_DICTIONARIES_DIR,p as FILE_EXTENSIONS,v as FILL,R as HEADER_NAME,m as I18NEXT_DICTIONARIES_DIR,y as IMPORT_MODE,E as IS_ENABLED,D as LIVE_SYNC,O as LIVE_SYNC_PORT,j as LOCALES,z as LOCALE_STORAGE_NAME,b as LOCATION,J as MAIN_DIR,Y as MASKS_DIR,P as MODE,X as MODULE_AUGMENTATION_DIR,n as OPTIMIZE,r as OUTPUT_FORMAT,k as PORT,F as PREFIX,h as REACT_INTL_MESSAGES_DIR,Z as REMOTE_DICTIONARIES_DIR,M as REQUIRED_LOCALES,B as ROUTING_MODE,V as SERVER_SET_COOKIE,H as STORAGE,N as STRICT_MODE,Q as TEMP_DIR,i as TRAVERSE_PATTERN,$ as TYPES_DIR,a as TYPE_CHECKING,ee as UNMERGED_DICTIONARIES_DIR,g as WATCH};
1
+ import { BUILD_MODE, CACHE, OPTIMIZE, OUTPUT_FORMAT, TRAVERSE_PATTERN, TYPE_CHECKING } from "./build.mjs";
2
+ import { COMPILER_DICTIONARY_KEY_PREFIX, COMPILER_ENABLED, COMPILER_NO_METADATA, COMPILER_SAVE_COMPONENTS } from "./compiler.mjs";
3
+ import { CODE_DIR, CONTENT_DIR, EXCLUDED_PATHS, FILE_EXTENSIONS, I18NEXT_DICTIONARIES_DIR, REACT_INTL_MESSAGES_DIR, WATCH } from "./content.mjs";
4
+ import { CONTENT_AUTO_TRANSFORMATION, FILL, IMPORT_MODE, LOCATION } from "./dictionary.mjs";
5
+ import { APPLICATION_URL, BACKEND_URL, CMS_URL, DICTIONARY_PRIORITY_STRATEGY, EDITOR_URL, IS_ENABLED, LIVE_SYNC, LIVE_SYNC_PORT, PORT } from "./editor.mjs";
6
+ import { DEFAULT_LOCALE, LOCALES, REQUIRED_LOCALES, STRICT_MODE } from "./internationalization.mjs";
7
+ import { MODE, PREFIX } from "./log.mjs";
8
+ import { BASE_PATH, COOKIE_NAME, HEADER_NAME, LOCALE_STORAGE_NAME, ROUTING_MODE, SERVER_SET_COOKIE, STORAGE } from "./routing.mjs";
9
+ import { CACHE_DIR, CONFIG_DIR, DICTIONARIES_DIR, DYNAMIC_DICTIONARIES_DIR, FETCH_DICTIONARIES_DIR, MAIN_DIR, MASKS_DIR, MODULE_AUGMENTATION_DIR, REMOTE_DICTIONARIES_DIR, TEMP_DIR, TYPES_DIR, UNMERGED_DICTIONARIES_DIR } from "./system.mjs";
10
+
11
+ export { APPLICATION_URL, BACKEND_URL, BASE_PATH, BUILD_MODE, CACHE, CACHE_DIR, CMS_URL, CODE_DIR, COMPILER_DICTIONARY_KEY_PREFIX, COMPILER_ENABLED, COMPILER_NO_METADATA, COMPILER_SAVE_COMPONENTS, CONFIG_DIR, CONTENT_AUTO_TRANSFORMATION, CONTENT_DIR, COOKIE_NAME, DEFAULT_LOCALE, DICTIONARIES_DIR, DICTIONARY_PRIORITY_STRATEGY, DYNAMIC_DICTIONARIES_DIR, EDITOR_URL, EXCLUDED_PATHS, FETCH_DICTIONARIES_DIR, FILE_EXTENSIONS, FILL, HEADER_NAME, I18NEXT_DICTIONARIES_DIR, IMPORT_MODE, IS_ENABLED, LIVE_SYNC, LIVE_SYNC_PORT, LOCALES, LOCALE_STORAGE_NAME, LOCATION, MAIN_DIR, MASKS_DIR, MODE, MODULE_AUGMENTATION_DIR, OPTIMIZE, OUTPUT_FORMAT, PORT, PREFIX, REACT_INTL_MESSAGES_DIR, REMOTE_DICTIONARIES_DIR, REQUIRED_LOCALES, ROUTING_MODE, SERVER_SET_COOKIE, STORAGE, STRICT_MODE, TEMP_DIR, TRAVERSE_PATTERN, TYPES_DIR, TYPE_CHECKING, UNMERGED_DICTIONARIES_DIR, WATCH };
@@ -1,2 +1,11 @@
1
- import{ENGLISH as e}from"@intlayer/types/locales";const t=[e],n=[],r=e,i=`inclusive`;export{r as DEFAULT_LOCALE,t as LOCALES,n as REQUIRED_LOCALES,i as STRICT_MODE};
1
+ import { ENGLISH } from "@intlayer/types/locales";
2
+
3
+ //#region src/defaultValues/internationalization.ts
4
+ const LOCALES = [ENGLISH];
5
+ const REQUIRED_LOCALES = [];
6
+ const DEFAULT_LOCALE = ENGLISH;
7
+ const STRICT_MODE = "inclusive";
8
+
9
+ //#endregion
10
+ export { DEFAULT_LOCALE, LOCALES, REQUIRED_LOCALES, STRICT_MODE };
2
11
  //# sourceMappingURL=internationalization.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"internationalization.mjs","names":[],"sources":["../../../src/defaultValues/internationalization.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { StrictMode } from '@intlayer/types/config';\nimport { ENGLISH } from '@intlayer/types/locales';\n\nexport const LOCALES: Locale[] = [ENGLISH];\n\nexport const REQUIRED_LOCALES: Locale[] = [];\n\nexport const DEFAULT_LOCALE: Locale = ENGLISH;\n\nexport const STRICT_MODE: StrictMode = 'inclusive';\n"],"mappings":"kDAIA,MAAa,EAAoB,CAAC,EAAQ,CAE7B,EAA6B,EAAE,CAE/B,EAAyB,EAEzB,EAA0B"}
1
+ {"version":3,"file":"internationalization.mjs","names":[],"sources":["../../../src/defaultValues/internationalization.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { StrictMode } from '@intlayer/types/config';\nimport { ENGLISH } from '@intlayer/types/locales';\n\nexport const LOCALES: Locale[] = [ENGLISH];\n\nexport const REQUIRED_LOCALES: Locale[] = [];\n\nexport const DEFAULT_LOCALE: Locale = ENGLISH;\n\nexport const STRICT_MODE: StrictMode = 'inclusive';\n"],"mappings":";;;AAIA,MAAa,UAAoB,CAAC,QAAQ;AAE1C,MAAa,mBAA6B,EAAE;AAE5C,MAAa,iBAAyB;AAEtC,MAAa,cAA0B"}
@@ -1,2 +1,9 @@
1
- import{GREY_DARK as e,RESET as t}from"../colors.mjs";const n=`default`,r=`${e}[intlayer] ${t}`;export{n as MODE,r as PREFIX};
1
+ import { GREY_DARK, RESET } from "../colors.mjs";
2
+
3
+ //#region src/defaultValues/log.ts
4
+ const MODE = "default";
5
+ const PREFIX = `${GREY_DARK}[intlayer] ${RESET}`;
6
+
7
+ //#endregion
8
+ export { MODE, PREFIX };
2
9
  //# sourceMappingURL=log.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"log.mjs","names":["ANSIColors.GREY_DARK","ANSIColors.RESET"],"sources":["../../../src/defaultValues/log.ts"],"sourcesContent":["import * as ANSIColors from '../colors';\n\nexport const MODE = 'default';\n\nexport const PREFIX = `${ANSIColors.GREY_DARK}[intlayer] ${ANSIColors.RESET}`;\n"],"mappings":"qDAEA,MAAa,EAAO,UAEP,EAAS,GAAGA,EAAqB,aAAaC"}
1
+ {"version":3,"file":"log.mjs","names":["ANSIColors.GREY_DARK","ANSIColors.RESET"],"sources":["../../../src/defaultValues/log.ts"],"sourcesContent":["import * as ANSIColors from '../colors';\n\nexport const MODE = 'default';\n\nexport const PREFIX = `${ANSIColors.GREY_DARK}[intlayer] ${ANSIColors.RESET}`;\n"],"mappings":";;;AAEA,MAAa,OAAO;AAEpB,MAAa,SAAS,GAAGA,UAAqB,aAAaC"}
@@ -1,2 +1,12 @@
1
- const e=`x-intlayer-locale`,t=`INTLAYER_LOCALE`,n=`INTLAYER_LOCALE`,r=``,i=`always`,a=`prefix-no-default`,o=[`cookie`,`header`];export{r as BASE_PATH,t as COOKIE_NAME,e as HEADER_NAME,n as LOCALE_STORAGE_NAME,a as ROUTING_MODE,i as SERVER_SET_COOKIE,o as STORAGE};
1
+ //#region src/defaultValues/routing.ts
2
+ const HEADER_NAME = "x-intlayer-locale";
3
+ const COOKIE_NAME = "INTLAYER_LOCALE";
4
+ const LOCALE_STORAGE_NAME = "INTLAYER_LOCALE";
5
+ const BASE_PATH = "";
6
+ const SERVER_SET_COOKIE = "always";
7
+ const ROUTING_MODE = "prefix-no-default";
8
+ const STORAGE = ["cookie", "header"];
9
+
10
+ //#endregion
11
+ export { BASE_PATH, COOKIE_NAME, HEADER_NAME, LOCALE_STORAGE_NAME, ROUTING_MODE, SERVER_SET_COOKIE, STORAGE };
2
12
  //# sourceMappingURL=routing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"routing.mjs","names":[],"sources":["../../../src/defaultValues/routing.ts"],"sourcesContent":["import type { RoutingConfig } 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 STORAGE: RoutingConfig['storage'] = ['cookie', 'header'];\n"],"mappings":"AAEA,MAAa,EAAc,oBAEd,EAAc,kBACd,EAAsB,kBAEtB,EAAY,GAEZ,EAAoB,SAEpB,EAAe,oBAEf,EAAoC,CAAC,SAAU,SAAS"}
1
+ {"version":3,"file":"routing.mjs","names":[],"sources":["../../../src/defaultValues/routing.ts"],"sourcesContent":["import type { RoutingConfig } 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 STORAGE: RoutingConfig['storage'] = ['cookie', 'header'];\n"],"mappings":";AAEA,MAAa,cAAc;AAE3B,MAAa,cAAc;AAC3B,MAAa,sBAAsB;AAEnC,MAAa,YAAY;AAEzB,MAAa,oBAAoB;AAEjC,MAAa,eAAe;AAE5B,MAAa,UAAoC,CAAC,UAAU,SAAS"}
@@ -1,2 +1,17 @@
1
- const e=`.intlayer/main`,t=`.intlayer/dictionary`,n=`.intlayer/mask`,r=`.intlayer/remote_dictionary`,i=`.intlayer/unmerged_dictionary`,a=`.intlayer/dynamic_dictionary`,o=`.intlayer/fetch_dictionary`,s=`.intlayer/types`,c=`.intlayer/types`,l=`.intlayer/config`,u=`.intlayer/cache`,d=`.intlayer/tmp`;export{u as CACHE_DIR,l as CONFIG_DIR,t as DICTIONARIES_DIR,a as DYNAMIC_DICTIONARIES_DIR,o as FETCH_DICTIONARIES_DIR,e as MAIN_DIR,n as MASKS_DIR,c as MODULE_AUGMENTATION_DIR,r as REMOTE_DICTIONARIES_DIR,d as TEMP_DIR,s as TYPES_DIR,i as UNMERGED_DICTIONARIES_DIR};
1
+ //#region src/defaultValues/system.ts
2
+ const MAIN_DIR = ".intlayer/main";
3
+ const DICTIONARIES_DIR = ".intlayer/dictionary";
4
+ const MASKS_DIR = ".intlayer/mask";
5
+ const REMOTE_DICTIONARIES_DIR = ".intlayer/remote_dictionary";
6
+ const UNMERGED_DICTIONARIES_DIR = ".intlayer/unmerged_dictionary";
7
+ const DYNAMIC_DICTIONARIES_DIR = ".intlayer/dynamic_dictionary";
8
+ const FETCH_DICTIONARIES_DIR = ".intlayer/fetch_dictionary";
9
+ const TYPES_DIR = ".intlayer/types";
10
+ const MODULE_AUGMENTATION_DIR = ".intlayer/types";
11
+ const CONFIG_DIR = ".intlayer/config";
12
+ const CACHE_DIR = ".intlayer/cache";
13
+ const TEMP_DIR = ".intlayer/tmp";
14
+
15
+ //#endregion
16
+ export { CACHE_DIR, CONFIG_DIR, DICTIONARIES_DIR, DYNAMIC_DICTIONARIES_DIR, FETCH_DICTIONARIES_DIR, MAIN_DIR, MASKS_DIR, MODULE_AUGMENTATION_DIR, REMOTE_DICTIONARIES_DIR, TEMP_DIR, TYPES_DIR, UNMERGED_DICTIONARIES_DIR };
2
17
  //# sourceMappingURL=system.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.mjs","names":[],"sources":["../../../src/defaultValues/system.ts"],"sourcesContent":["export const MAIN_DIR = '.intlayer/main';\n\nexport const DICTIONARIES_DIR = '.intlayer/dictionary';\n\nexport const MASKS_DIR = '.intlayer/mask';\n\nexport const REMOTE_DICTIONARIES_DIR = '.intlayer/remote_dictionary';\n\nexport const UNMERGED_DICTIONARIES_DIR = '.intlayer/unmerged_dictionary';\n\nexport const DYNAMIC_DICTIONARIES_DIR = '.intlayer/dynamic_dictionary';\n\nexport const FETCH_DICTIONARIES_DIR = '.intlayer/fetch_dictionary';\n\nexport const TYPES_DIR = '.intlayer/types';\n\nexport const MODULE_AUGMENTATION_DIR = '.intlayer/types';\n\nexport const CONFIG_DIR = '.intlayer/config';\n\nexport const CACHE_DIR = '.intlayer/cache';\n\nexport const TEMP_DIR = '.intlayer/tmp';\n"],"mappings":"AAAA,MAAa,EAAW,iBAEX,EAAmB,uBAEnB,EAAY,iBAEZ,EAA0B,8BAE1B,EAA4B,gCAE5B,EAA2B,+BAE3B,EAAyB,6BAEzB,EAAY,kBAEZ,EAA0B,kBAE1B,EAAa,mBAEb,EAAY,kBAEZ,EAAW"}
1
+ {"version":3,"file":"system.mjs","names":[],"sources":["../../../src/defaultValues/system.ts"],"sourcesContent":["export const MAIN_DIR = '.intlayer/main';\n\nexport const DICTIONARIES_DIR = '.intlayer/dictionary';\n\nexport const MASKS_DIR = '.intlayer/mask';\n\nexport const REMOTE_DICTIONARIES_DIR = '.intlayer/remote_dictionary';\n\nexport const UNMERGED_DICTIONARIES_DIR = '.intlayer/unmerged_dictionary';\n\nexport const DYNAMIC_DICTIONARIES_DIR = '.intlayer/dynamic_dictionary';\n\nexport const FETCH_DICTIONARIES_DIR = '.intlayer/fetch_dictionary';\n\nexport const TYPES_DIR = '.intlayer/types';\n\nexport const MODULE_AUGMENTATION_DIR = '.intlayer/types';\n\nexport const CONFIG_DIR = '.intlayer/config';\n\nexport const CACHE_DIR = '.intlayer/cache';\n\nexport const TEMP_DIR = '.intlayer/tmp';\n"],"mappings":";AAAA,MAAa,WAAW;AAExB,MAAa,mBAAmB;AAEhC,MAAa,YAAY;AAEzB,MAAa,0BAA0B;AAEvC,MAAa,4BAA4B;AAEzC,MAAa,2BAA2B;AAExC,MAAa,yBAAyB;AAEtC,MAAa,YAAY;AAEzB,MAAa,0BAA0B;AAEvC,MAAa,aAAa;AAE1B,MAAa,YAAY;AAEzB,MAAa,WAAW"}
@@ -1,2 +1,28 @@
1
- import{existsSync as e}from"node:fs";import t from"dotenv";const n=(t=`production`,n)=>(n?[n]:[`.env.${t}.local`,`.env.${t}`,`.env.local`,`.env`]).find(e),r=e=>{let r=n(e?.env??`production`,e?.envFile);if(!r)return{};let i={};return t.config({path:r,processEnv:i,quiet:!0}),i};export{n as getEnvFilePath,r as loadEnvFile};
1
+ import { existsSync } from "node:fs";
2
+ import dotenv from "dotenv";
3
+
4
+ //#region src/loadEnvFile.ts
5
+ const DEFAULT_ENV = "development";
6
+ const getEnvFilePath = (env = "development", envFile) => {
7
+ return (envFile ? [envFile] : [
8
+ `.env.${env}.local`,
9
+ `.env.${env}`,
10
+ ".env.local",
11
+ ".env"
12
+ ]).find(existsSync);
13
+ };
14
+ const loadEnvFile = (options) => {
15
+ const envFiles = getEnvFilePath(options?.env ?? DEFAULT_ENV, options?.envFile);
16
+ if (!envFiles) return {};
17
+ const result = {};
18
+ dotenv.config({
19
+ path: envFiles,
20
+ processEnv: result,
21
+ quiet: true
22
+ });
23
+ return result;
24
+ };
25
+
26
+ //#endregion
27
+ export { getEnvFilePath, loadEnvFile };
2
28
  //# sourceMappingURL=loadEnvFile.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadEnvFile.mjs","names":[],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync } 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\nexport const loadEnvFile = (options?: Partial<LoadEnvFileOptions>) => {\n const env = options?.env ?? DEFAULT_ENV;\n\n const envFiles = getEnvFilePath(env, options?.envFile);\n\n if (!envFiles) {\n return {};\n }\n\n const result = {};\n\n dotenv.config({\n path: envFiles,\n processEnv: result,\n quiet: true,\n });\n\n return result; // Return the parsed env object\n};\n"],"mappings":"2DAGA,MAOa,GACX,EAAA,aACA,KAEiB,EACb,CAAC,EAAQ,CACT,CAAC,QAAQ,EAAI,QAAS,QAAQ,IAAO,aAAc,OAAO,EAE9C,KAAK,EAAW,CAGrB,EAAe,GAA0C,CAGpE,IAAM,EAAW,EAFL,GAAS,KAAO,aAES,GAAS,QAAQ,CAEtD,GAAI,CAAC,EACH,MAAO,EAAE,CAGX,IAAM,EAAS,EAAE,CAQjB,OANA,EAAO,OAAO,CACZ,KAAM,EACN,WAAY,EACZ,MAAO,GACR,CAAC,CAEK"}
1
+ {"version":3,"file":"loadEnvFile.mjs","names":[],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync } 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\nexport const loadEnvFile = (options?: Partial<LoadEnvFileOptions>) => {\n const env = options?.env ?? DEFAULT_ENV;\n\n const envFiles = getEnvFilePath(env, options?.envFile);\n\n if (!envFiles) {\n return {};\n }\n\n const result = {};\n\n dotenv.config({\n path: envFiles,\n processEnv: result,\n quiet: true,\n });\n\n return result; // Return the parsed env object\n};\n"],"mappings":";;;;AAGA,MAAM;AAON,MAAa,kBACX,qBACA,YACuB;AAKvB,SAJiB,UACb,CAAC,QAAQ,GACT;EAAC,QAAQ,IAAI;EAAS,QAAQ;EAAO;EAAc;EAAO,EAE9C,KAAK,WAAW;;AAGlC,MAAa,eAAe,YAA0C;CAGpE,MAAM,WAAW,eAFL,SAAS,OAAO,aAES,SAAS,QAAQ;AAEtD,KAAI,CAAC,SACH,QAAO,EAAE;CAGX,MAAM,SAAS,EAAE;AAEjB,QAAO,OAAO;EACZ,MAAM;EACN,YAAY;EACZ,OAAO;EACR,CAAC;AAEF,QAAO"}
@@ -1,2 +1,68 @@
1
- import{dirname as e,extname as t}from"node:path";import{build as n,buildSync as r}from"esbuild";import{pathToFileURL as i}from"node:url";const a=e=>{switch(e){case`.js`:return`js`;case`.jsx`:return`jsx`;case`.mjs`:return`js`;case`.ts`:return`ts`;case`.tsx`:return`tsx`;case`.cjs`:return`js`;case`.json`:return`json`;case`.md`:return`text`;case`.mdx`:return`text`;default:return`js`}},o=e=>({loader:{".js":`js`,".jsx":`jsx`,".mjs":`js`,".ts":`ts`,".tsx":`tsx`,".cjs":`js`,".json":`json`,".md":`text`,".mdx":`text`},format:`cjs`,target:`node16`,platform:`neutral`,write:!1,packages:`bundle`,external:[`esbuild`],bundle:!0,define:{"import.meta.url":JSON.stringify(i(e).href)}}),s=(n,i,s)=>r({stdin:{contents:n,loader:a(t(i)),resolveDir:e(i),sourcefile:i},...o(i),...s}).outputFiles?.[0].text,c=async(r,i,s)=>(await n({stdin:{contents:r,loader:a(t(i)),resolveDir:e(i),sourcefile:i},...o(i),...s})).outputFiles?.[0].text;export{c as bundleFile,s as bundleFileSync,a as getLoader};
1
+ import { dirname, extname } from "node:path";
2
+ import { build, buildSync } from "esbuild";
3
+ import { pathToFileURL } from "node:url";
4
+
5
+ //#region src/loadExternalFile/bundleFile.ts
6
+ const getLoader = (extension) => {
7
+ switch (extension) {
8
+ case ".js": return "js";
9
+ case ".jsx": return "jsx";
10
+ case ".mjs": return "js";
11
+ case ".ts": return "ts";
12
+ case ".tsx": return "tsx";
13
+ case ".cjs": return "js";
14
+ case ".json": return "json";
15
+ case ".md": return "text";
16
+ case ".mdx": return "text";
17
+ default: return "js";
18
+ }
19
+ };
20
+ const getTransformationOptions = (filePath) => ({
21
+ loader: {
22
+ ".js": "js",
23
+ ".jsx": "jsx",
24
+ ".mjs": "js",
25
+ ".ts": "ts",
26
+ ".tsx": "tsx",
27
+ ".cjs": "js",
28
+ ".json": "json",
29
+ ".md": "text",
30
+ ".mdx": "text"
31
+ },
32
+ format: "cjs",
33
+ target: "node16",
34
+ platform: "neutral",
35
+ write: false,
36
+ packages: "bundle",
37
+ external: ["esbuild"],
38
+ bundle: true,
39
+ define: { "import.meta.url": JSON.stringify(pathToFileURL(filePath).href) }
40
+ });
41
+ const bundleFileSync = (code, filePath, options) => {
42
+ return buildSync({
43
+ stdin: {
44
+ contents: code,
45
+ loader: getLoader(extname(filePath)),
46
+ resolveDir: dirname(filePath),
47
+ sourcefile: filePath
48
+ },
49
+ ...getTransformationOptions(filePath),
50
+ ...options
51
+ }).outputFiles?.[0].text;
52
+ };
53
+ const bundleFile = async (code, filePath, options) => {
54
+ return (await build({
55
+ stdin: {
56
+ contents: code,
57
+ loader: getLoader(extname(filePath)),
58
+ resolveDir: dirname(filePath),
59
+ sourcefile: filePath
60
+ },
61
+ ...getTransformationOptions(filePath),
62
+ ...options
63
+ })).outputFiles?.[0].text;
64
+ };
65
+
66
+ //#endregion
67
+ export { bundleFile, bundleFileSync, getLoader };
2
68
  //# sourceMappingURL=bundleFile.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundleFile.mjs","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":"yIAaA,MAAa,EAAa,GAA8B,CACtD,OAAQ,EAAR,CACE,IAAK,MACH,MAAO,KACT,IAAK,OACH,MAAO,MACT,IAAK,OACH,MAAO,KACT,IAAK,MACH,MAAO,KACT,IAAK,OACH,MAAO,MACT,IAAK,OACH,MAAO,KACT,IAAK,QACH,MAAO,OACT,IAAK,MACH,MAAO,OACT,IAAK,OACH,MAAO,OACT,QACE,MAAO,OAIP,EAA4B,IAAoC,CACpE,OAAQ,CACN,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,QAAS,OACT,MAAO,OACP,OAAQ,OACT,CACD,OAAQ,MACR,OAAQ,SACR,SAAU,UACV,MAAO,GACP,SAAU,SACV,SAAU,CAAC,UAAU,CACrB,OAAQ,GACR,OAAQ,CACN,kBAAmB,KAAK,UAAU,EAAc,EAAS,CAAC,KAAK,CAChE,CACF,EAEY,GACX,EACA,EACA,IAKkC,EAAU,CAC1C,MAAO,CACL,SAAU,EACV,OALW,EADG,EAAQ,EAAS,CACA,CAM/B,WAAY,EAAQ,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,CAEsC,cAAc,GAAG,KAK9C,EAAa,MACxB,EACA,EACA,KAKkC,MAAM,EAAM,CAC5C,MAAO,CACL,SAAU,EACV,OALW,EADG,EAAQ,EAAS,CACA,CAM/B,WAAY,EAAQ,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,EAEsC,cAAc,GAAG"}
1
+ {"version":3,"file":"bundleFile.mjs","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,UAAU,cAAc,SAAS,CAAC,KAAK,EAChE;CACF;AAED,MAAa,kBACX,MACA,UACA,YACuB;AAiBvB,QAbkC,UAAU;EAC1C,OAAO;GACL,UAAU;GACV,QALW,UADG,QAAQ,SAAS,CACA;GAM/B,YAAY,QAAQ,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAAC,CAEsC,cAAc,GAAG;;AAK3D,MAAa,aAAa,OACxB,MACA,UACA,YACgC;AAiBhC,SAbkC,MAAM,MAAM;EAC5C,OAAO;GACL,UAAU;GACV,QALW,UADG,QAAQ,SAAS,CACA;GAM/B,YAAY,QAAQ,SAAS;GAC7B,YAAY;GACb;EACD,GAAG,yBAAyB,SAAS;EACrC,GAAG;EACJ,CAAC,EAEsC,cAAc,GAAG"}
@@ -1,2 +1,32 @@
1
- import{build as e}from"esbuild";const t={bundle:!0,format:`cjs`,platform:`node`,target:`es2019`,sourcemap:!1,logLevel:`silent`,write:!0,packages:`external`,loader:{".js":`js`,".jsx":`jsx`,".mjs":`js`,".ts":`ts`,".tsx":`tsx`,".cjs":`js`,".json":`json`,".md":`text`,".mdx":`text`}},n=async n=>await e({...t,...n});export{n as bundleJSFile};
1
+ import { build } from "esbuild";
2
+
3
+ //#region src/loadExternalFile/bundleJSFile.ts
4
+ const commonBuildOptions = {
5
+ bundle: true,
6
+ format: "cjs",
7
+ platform: "node",
8
+ target: "es2019",
9
+ sourcemap: false,
10
+ logLevel: "silent",
11
+ write: true,
12
+ packages: "external",
13
+ loader: {
14
+ ".js": "js",
15
+ ".jsx": "jsx",
16
+ ".mjs": "js",
17
+ ".ts": "ts",
18
+ ".tsx": "tsx",
19
+ ".cjs": "js",
20
+ ".json": "json",
21
+ ".md": "text",
22
+ ".mdx": "text"
23
+ }
24
+ };
25
+ const bundleJSFile = async (buildOptions) => await build({
26
+ ...commonBuildOptions,
27
+ ...buildOptions
28
+ });
29
+
30
+ //#endregion
31
+ export { bundleJSFile };
2
32
  //# sourceMappingURL=bundleJSFile.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundleJSFile.mjs","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":"gCAEA,MAAM,EAAqB,CACzB,OAAQ,GACR,OAAQ,MACR,SAAU,OACV,OAAQ,SACR,UAAW,GACX,SAAU,SACV,MAAO,GAEP,SAAU,WACV,OAAQ,CACN,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,QAAS,OACT,MAAO,OACP,OAAQ,OACT,CACF,CAEY,EAAe,KAAO,IACjC,MAAM,EAAM,CACV,GAAG,EACH,GAAG,EACJ,CAAC"}
1
+ {"version":3,"file":"bundleJSFile.mjs","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,MAAM,MAAM;CACV,GAAG;CACH,GAAG;CACJ,CAAC"}
@@ -1 +1,7 @@
1
- import{getSandBoxContext as e,parseFileContent as t}from"./parseFileContent.mjs";import{bundleFile as n,bundleFileSync as r,getLoader as i}from"./bundleFile.mjs";import{transpileTSToCJS as a,transpileTSToCJSSync as o}from"./transpileTSToCJS.mjs";import{loadExternalFile as s,loadExternalFileSync as c}from"./loadExternalFile.mjs";import{bundleJSFile as l}from"./bundleJSFile.mjs";export{n as bundleFile,r as bundleFileSync,l as bundleJSFile,i as getLoader,e as getSandBoxContext,s as loadExternalFile,c as loadExternalFileSync,t as parseFileContent,a as transpileTSToCJS,o as transpileTSToCJSSync};
1
+ import { getSandBoxContext, parseFileContent } from "./parseFileContent.mjs";
2
+ import { bundleFile, bundleFileSync, getLoader } from "./bundleFile.mjs";
3
+ import { transpileTSToCJS, transpileTSToCJSSync } from "./transpileTSToCJS.mjs";
4
+ import { loadExternalFile, loadExternalFileSync } from "./loadExternalFile.mjs";
5
+ import { bundleJSFile } from "./bundleJSFile.mjs";
6
+
7
+ export { bundleFile, bundleFileSync, bundleJSFile, getLoader, getSandBoxContext, loadExternalFile, loadExternalFileSync, parseFileContent, transpileTSToCJS, transpileTSToCJSSync };
@@ -1,2 +1,74 @@
1
- import{colorizePath as e,logger as t}from"../logger.mjs";import{parseFileContent as n}from"./parseFileContent.mjs";import{transpileTSToCJS as r,transpileTSToCJSSync as i}from"./transpileTSToCJS.mjs";import{readFileSync as a}from"node:fs";import{extname as o}from"node:path";import{readFile as s}from"node:fs/promises";import c from"json5";const l=c.parse||c.default?.parse,u=(e,r)=>{let s=o(e)||`.json`;try{if(s===`.json`||s===`.json5`||s===`.jsonc`)return l(a(e,`utf-8`));let o=i(a(e,`utf-8`),e,r?.buildOptions);if(!o){t(`File could not be loaded.`,{level:`error`});return}let c=n(o,{projectRequire:r?.projectRequire,envVarOptions:r?.envVarOptions,additionalEnvVars:r?.additionalEnvVars,mocks:r?.mocks,aliases:r?.aliases});if(c===void 0){t(`File could not be loaded. Path : ${e}`);return}return c}catch(e){t([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}},d=async(i,a)=>{let c=o(i);try{if(c===`.json`||c===`.json5`||c===`.jsonc`)return l(await s(i,`utf-8`));let o=await r(await s(i,`utf-8`),i,a?.buildOptions);if(!o){t(`File could not be loaded.`,{level:`error`});return}let u=n(o,{projectRequire:a?.projectRequire,envVarOptions:a?.envVarOptions,additionalEnvVars:a?.additionalEnvVars,mocks:a?.mocks,aliases:a?.aliases});if(u===void 0){t(`File could not be loaded. Path : ${e(i)}`);return}return u}catch(e){(a?.logError??!0)&&t([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}};export{d as loadExternalFile,u as loadExternalFileSync};
1
+ import { colorizePath, logger } from "../logger.mjs";
2
+ import { parseFileContent } from "./parseFileContent.mjs";
3
+ import { transpileTSToCJS, transpileTSToCJSSync } from "./transpileTSToCJS.mjs";
4
+ import { readFileSync } from "node:fs";
5
+ import { extname } from "node:path";
6
+ import { readFile } from "node:fs/promises";
7
+ import JSON5 from "json5";
8
+
9
+ //#region src/loadExternalFile/loadExternalFile.ts
10
+ const parseJSON5 = JSON5.parse || JSON5.default?.parse;
11
+ /**
12
+ * Load the content declaration from the given path
13
+ *
14
+ * Accepts JSON, JS, MJS and TS files as configuration
15
+ */
16
+ const loadExternalFileSync = (filePath, options) => {
17
+ const fileExtension = extname(filePath) || ".json";
18
+ try {
19
+ if (fileExtension === ".json" || fileExtension === ".json5" || fileExtension === ".jsonc") return parseJSON5(readFileSync(filePath, "utf-8"));
20
+ const moduleResultString = transpileTSToCJSSync(readFileSync(filePath, "utf-8"), filePath, options?.buildOptions);
21
+ if (!moduleResultString) {
22
+ logger("File could not be loaded.", { level: "error" });
23
+ return;
24
+ }
25
+ const fileContent = parseFileContent(moduleResultString, {
26
+ projectRequire: options?.projectRequire,
27
+ envVarOptions: options?.envVarOptions,
28
+ additionalEnvVars: options?.additionalEnvVars,
29
+ mocks: options?.mocks,
30
+ aliases: options?.aliases
31
+ });
32
+ if (typeof fileContent === "undefined") {
33
+ logger(`File could not be loaded. Path : ${filePath}`);
34
+ return;
35
+ }
36
+ return fileContent;
37
+ } catch (error) {
38
+ logger([`Error: ${error.message} - `, JSON.stringify(error.stack, null, 2)], { level: "error" });
39
+ }
40
+ };
41
+ /**
42
+ * Load the content declaration from the given path
43
+ *
44
+ * Accepts JSON, JS, MJS and TS files as configuration
45
+ */
46
+ const loadExternalFile = async (filePath, options) => {
47
+ const fileExtension = extname(filePath);
48
+ try {
49
+ if (fileExtension === ".json" || fileExtension === ".json5" || fileExtension === ".jsonc") return parseJSON5(await readFile(filePath, "utf-8"));
50
+ const moduleResultString = await transpileTSToCJS(await readFile(filePath, "utf-8"), filePath, options?.buildOptions);
51
+ if (!moduleResultString) {
52
+ logger("File could not be loaded.", { level: "error" });
53
+ return;
54
+ }
55
+ const fileContent = parseFileContent(moduleResultString, {
56
+ projectRequire: options?.projectRequire,
57
+ envVarOptions: options?.envVarOptions,
58
+ additionalEnvVars: options?.additionalEnvVars,
59
+ mocks: options?.mocks,
60
+ aliases: options?.aliases
61
+ });
62
+ if (typeof fileContent === "undefined") {
63
+ logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);
64
+ return;
65
+ }
66
+ return fileContent;
67
+ } catch (error) {
68
+ if (options?.logError ?? true) logger([`Error: ${error.message} - `, JSON.stringify(error.stack, null, 2)], { level: "error" });
69
+ }
70
+ };
71
+
72
+ //#endregion
73
+ export { loadExternalFile, loadExternalFileSync };
2
74
  //# sourceMappingURL=loadExternalFile.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadExternalFile.mjs","names":[],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport {\n type TranspileOptions,\n transpileTSToCJS,\n transpileTSToCJSSync,\n} from './transpileTSToCJS';\n\n// CJS MJS cross usage\nconst parseJSON5 = JSON5.parse || (JSON5 as any).default?.parse;\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: TranspileOptions;\n logError?: boolean;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return parseJSON5(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return parseJSON5(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n if (options?.logError ?? true) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n }\n};\n"],"mappings":"mVAiBA,MAAM,EAAa,EAAM,OAAU,EAAc,SAAS,MAa7C,GACX,EACA,IACoB,CACpB,IAAM,EAAgB,EAAQ,EAAS,EAAI,QAE3C,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAGlB,OAAO,EAAW,EAAa,EAAU,QAAQ,CAAC,CAMpD,IAAM,EAAyC,EAFlC,EAAa,EAAU,QAAQ,CAI1C,EACA,GAAS,aACV,CAED,GAAI,CAAC,EAAoB,CACvB,EAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAc,EAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAO,oCAAoC,IAAW,CACtD,OAGF,OAAO,QACA,EAAO,CACd,EACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF,GASQ,EAAmB,MAC9B,EACA,IAC6B,CAC7B,IAAM,EAAgB,EAAQ,EAAS,CAEvC,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAIlB,OAAO,EADa,MAAM,EAAS,EAAU,QAAQ,CACvB,CAMhC,IAAM,EAAyC,MAAM,EAFxC,MAAM,EAAS,EAAU,QAAQ,CAI5C,EACA,GAAS,aACV,CAED,GAAI,CAAC,EAAoB,CACvB,EAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAc,EAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAO,oCAAoC,EAAa,EAAS,GAAG,CACpE,OAGF,OAAO,QACA,EAAO,EACV,GAAS,UAAY,KACvB,EACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF"}
1
+ {"version":3,"file":"loadExternalFile.mjs","names":[],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport {\n type TranspileOptions,\n transpileTSToCJS,\n transpileTSToCJSSync,\n} from './transpileTSToCJS';\n\n// CJS MJS cross usage\nconst parseJSON5 = JSON5.parse || (JSON5 as any).default?.parse;\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: TranspileOptions;\n logError?: boolean;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return parseJSON5(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return parseJSON5(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n if (options?.logError ?? true) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;AAiBA,MAAM,aAAa,MAAM,SAAU,MAAc,SAAS;;;;;;AAa1D,MAAa,wBACX,UACA,YACoB;CACpB,MAAM,gBAAgB,QAAQ,SAAS,IAAI;AAE3C,KAAI;AACF,MACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,SAGlB,QAAO,WAAW,aAAa,UAAU,QAAQ,CAAC;EAMpD,MAAM,qBAAyC,qBAFlC,aAAa,UAAU,QAAQ,EAI1C,UACA,SAAS,aACV;AAED,MAAI,CAAC,oBAAoB;AACvB,UAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAGF,MAAM,cAAc,iBAAiB,oBAAoB;GACvD,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC;AAEF,MAAI,OAAO,gBAAgB,aAAa;AACtC,UAAO,oCAAoC,WAAW;AACtD;;AAGF,SAAO;UACA,OAAO;AACd,SACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,EAAE,CAChD,EACD,EACE,OAAO,SACR,CACF;;;;;;;;AASL,MAAa,mBAAmB,OAC9B,UACA,YAC6B;CAC7B,MAAM,gBAAgB,QAAQ,SAAS;AAEvC,KAAI;AACF,MACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,SAIlB,QAAO,WADa,MAAM,SAAS,UAAU,QAAQ,CACvB;EAMhC,MAAM,qBAAyC,MAAM,iBAFxC,MAAM,SAAS,UAAU,QAAQ,EAI5C,UACA,SAAS,aACV;AAED,MAAI,CAAC,oBAAoB;AACvB,UAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAGF,MAAM,cAAc,iBAAiB,oBAAoB;GACvD,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC;AAEF,MAAI,OAAO,gBAAgB,aAAa;AACtC,UAAO,oCAAoC,aAAa,SAAS,GAAG;AACpE;;AAGF,SAAO;UACA,OAAO;AACd,MAAI,SAAS,YAAY,KACvB,QACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,EAAE,CAChD,EACD,EACE,OAAO,SACR,CACF"}
@@ -1,2 +1,74 @@
1
- import{n as e}from"../ESMxCJSHelpers-BAuqwNXV.mjs";import{loadEnvFile as t}from"../loadEnvFile.mjs";import{runInNewContext as n}from"node:vm";import*as r from"esbuild";const i=n=>{let{envVarOptions:i,projectRequire:a,additionalEnvVars:o,mocks:s,aliases:c}=n??{},l={},u=typeof a==`function`?a:e(),d=(()=>{let e=Object.assign({esbuild:r},s),t=Object.assign({},c),n=function(n){let r=t?.[n]?t[n]:n;return e&&Object.hasOwn(e,r)?e[r]:r!==n&&e&&Object.hasOwn(e,n)?e[n]:u(r)};return n.resolve=u.resolve.bind(u),n.main=u.main,n.extensions=u.extensions,n.cache=u.cache,n})();try{l={React:u(`react`)}}catch{l={React:{createElement:(e,t,...n)=>({type:e,props:{...t,children:n.length<=1?n[0]:n}}),Fragment:Symbol.for(`react.fragment`)}}}let f={exports:{default:{}},module:{exports:{}},process:{...process,env:{...process.env,...t(i),...o}},console,require:d,...l};return Object.getOwnPropertyNames(globalThis).forEach(e=>{e in f||(f[e]=globalThis[e])}),f},a=(e,t)=>{let r=i(t);n(`"use strict";\n${e}`,r);let a=[r.exports?.default,r.module?.exports?.defaults,r.module?.exports?.default,r.module?.exports];for(let e of a)if(e&&typeof e==`object`&&Object.keys(e).length>0)return e};export{i as getSandBoxContext,a as parseFileContent};
1
+ import { getProjectRequire } from "../utils/ESMxCJSHelpers.mjs";
2
+ import { loadEnvFile } from "../loadEnvFile.mjs";
3
+ import { runInNewContext } from "node:vm";
4
+ import * as esbuild from "esbuild";
5
+
6
+ //#region src/loadExternalFile/parseFileContent.ts
7
+ const getSandBoxContext = (options) => {
8
+ const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } = options ?? {};
9
+ let additionalGlobalVar = {};
10
+ const baseRequire = typeof projectRequire === "function" ? projectRequire : getProjectRequire();
11
+ const mockedRequire = (() => {
12
+ const mockTable = Object.assign({ esbuild }, mocks);
13
+ const aliasTable = Object.assign({}, aliases);
14
+ const wrappedRequire = function mockableRequire(id) {
15
+ const target = aliasTable?.[id] ? aliasTable[id] : id;
16
+ if (mockTable && Object.hasOwn(mockTable, target)) return mockTable[target];
17
+ if (target !== id && mockTable && Object.hasOwn(mockTable, id)) return mockTable[id];
18
+ return baseRequire(target);
19
+ };
20
+ wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);
21
+ wrappedRequire.main = baseRequire.main;
22
+ wrappedRequire.extensions = baseRequire.extensions;
23
+ wrappedRequire.cache = baseRequire.cache;
24
+ return wrappedRequire;
25
+ })();
26
+ try {
27
+ additionalGlobalVar = { React: baseRequire("react") };
28
+ } catch (_err) {
29
+ additionalGlobalVar = { React: {
30
+ createElement: (type, props, ...children) => ({
31
+ type,
32
+ props: {
33
+ ...props,
34
+ children: children.length <= 1 ? children[0] : children
35
+ }
36
+ }),
37
+ Fragment: Symbol.for("react.fragment")
38
+ } };
39
+ }
40
+ const sandboxContext = {
41
+ exports: { default: {} },
42
+ module: { exports: {} },
43
+ process: {
44
+ ...process,
45
+ env: {
46
+ ...process.env,
47
+ ...loadEnvFile(envVarOptions),
48
+ ...additionalEnvVars
49
+ }
50
+ },
51
+ console,
52
+ require: mockedRequire,
53
+ ...additionalGlobalVar
54
+ };
55
+ Object.getOwnPropertyNames(globalThis).forEach((key) => {
56
+ if (!(key in sandboxContext)) sandboxContext[key] = globalThis[key];
57
+ });
58
+ return sandboxContext;
59
+ };
60
+ const parseFileContent = (fileContentString, options) => {
61
+ const sandboxContext = getSandBoxContext(options);
62
+ runInNewContext(`"use strict";\n${fileContentString}`, sandboxContext);
63
+ const candidates = [
64
+ sandboxContext.exports?.default,
65
+ sandboxContext.module?.exports?.defaults,
66
+ sandboxContext.module?.exports?.default,
67
+ sandboxContext.module?.exports
68
+ ];
69
+ for (const candidate of candidates) if (candidate && typeof candidate === "object" && Object.keys(candidate).length > 0) return candidate;
70
+ };
71
+
72
+ //#endregion
73
+ export { getSandBoxContext, parseFileContent };
2
74
  //# sourceMappingURL=parseFileContent.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseFileContent.mjs","names":[],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we inject a dummy React object to capture JSX elements\n // This allows using JSX in content declarations even if React is not installed (e.g. in Solid.js or Vue projects)\n // because esbuild's tsx loader defaults to React.createElement.\n additionalGlobalVar = {\n React: {\n createElement: (type: any, props: any, ...children: any[]) => ({\n type,\n props: {\n ...props,\n children: children.length <= 1 ? children[0] : children,\n },\n }),\n Fragment: Symbol.for('react.fragment'),\n },\n };\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":"wKA0BA,MAAa,EAAqB,GAA6C,CAC7E,GAAM,CAAE,gBAAe,iBAAgB,oBAAmB,QAAO,WAC/D,GAAW,EAAE,CAEX,EAAsB,EAAE,CAEtB,EACJ,OAAO,GAAmB,WAAa,EAAiB,GAAmB,CAGvE,OAAuC,CAC3C,IAAM,EAAY,OAAO,OACvB,CACE,UACD,CACD,EACD,CACK,EAAa,OAAO,OAAO,EAAE,CAAE,EAAQ,CAEvC,EAAiB,SAAyB,EAAY,CAC1D,IAAM,EAAS,IAAa,GAAM,EAAW,GAAM,EAWnD,OATI,GAAa,OAAO,OAAO,EAAW,EAAO,CACxC,EAAU,GAIf,IAAW,GAAM,GAAa,OAAO,OAAO,EAAW,EAAG,CACrD,EAAU,GAGZ,EAAY,EAAO,EAS5B,MALA,GAAe,QAAU,EAAY,QAAQ,KAAK,EAAY,CAC9D,EAAe,KAAO,EAAY,KAClC,EAAe,WAAa,EAAY,WACxC,EAAe,MAAQ,EAAY,MAE5B,KACL,CAEJ,GAAI,CAEF,EAAsB,CACpB,MAAO,EAAY,QAAQ,CAC5B,MACY,CAIb,EAAsB,CACpB,MAAO,CACL,eAAgB,EAAW,EAAY,GAAG,KAAqB,CAC7D,OACA,MAAO,CACL,GAAG,EACH,SAAU,EAAS,QAAU,EAAI,EAAS,GAAK,EAChD,CACF,EACD,SAAU,OAAO,IAAI,iBAAiB,CACvC,CACF,CAGH,IAAM,EAA0B,CAC9B,QAAS,CACP,QAAS,EAAE,CACZ,CACD,OAAQ,CACN,QAAS,EAAE,CACZ,CACD,QAAS,CACP,GAAG,QACH,IAAK,CACH,GAAG,QAAQ,IACX,GAAG,EAAY,EAAc,CAC7B,GAAG,EACJ,CACF,CACD,QACA,QAAS,EACT,GAAG,EACJ,CASD,OANA,OAAO,oBAAoB,WAAW,CAAC,QAAS,GAAQ,CAChD,KAAO,IACX,EAAe,GAAO,WAAW,KAEnC,CAEK,GAGI,GACX,EACA,IACkB,CAClB,IAAM,EAAiB,EAAkB,EAAQ,CAGjD,EAAgB,kBAAkB,IAAqB,EAAe,CAEtE,IAAM,EAAwB,CAC5B,EAAe,SAAS,QACxB,EAAe,QAAQ,SAAS,SAChC,EAAe,QAAQ,SAAS,QAChC,EAAe,QAAQ,QACxB,CAED,IAAK,IAAM,KAAa,EACtB,GACE,GACA,OAAO,GAAc,UACrB,OAAO,KAAK,EAAoB,CAAC,OAAS,EAE1C,OAAO"}
1
+ {"version":3,"file":"parseFileContent.mjs","names":[],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we inject a dummy React object to capture JSX elements\n // This allows using JSX in content declarations even if React is not installed (e.g. in Solid.js or Vue projects)\n // because esbuild's tsx loader defaults to React.createElement.\n additionalGlobalVar = {\n React: {\n createElement: (type: any, props: any, ...children: any[]) => ({\n type,\n props: {\n ...props,\n children: children.length <= 1 ? children[0] : children,\n },\n }),\n Fragment: Symbol.for('react.fragment'),\n },\n };\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":";;;;;;AA0BA,MAAa,qBAAqB,YAA6C;CAC7E,MAAM,EAAE,eAAe,gBAAgB,mBAAmB,OAAO,YAC/D,WAAW,EAAE;CAEf,IAAI,sBAAsB,EAAE;CAE5B,MAAM,cACJ,OAAO,mBAAmB,aAAa,iBAAiB,mBAAmB;CAG7E,MAAM,uBAAuC;EAC3C,MAAM,YAAY,OAAO,OACvB,EACE,SACD,EACD,MACD;EACD,MAAM,aAAa,OAAO,OAAO,EAAE,EAAE,QAAQ;EAE7C,MAAM,iBAAiB,SAAS,gBAAgB,IAAY;GAC1D,MAAM,SAAS,aAAa,MAAM,WAAW,MAAM;AAEnD,OAAI,aAAa,OAAO,OAAO,WAAW,OAAO,CAC/C,QAAO,UAAU;AAInB,OAAI,WAAW,MAAM,aAAa,OAAO,OAAO,WAAW,GAAG,CAC5D,QAAO,UAAU;AAGnB,UAAO,YAAY,OAAO;;AAI5B,iBAAe,UAAU,YAAY,QAAQ,KAAK,YAAY;AAC9D,iBAAe,OAAO,YAAY;AAClC,iBAAe,aAAa,YAAY;AACxC,iBAAe,QAAQ,YAAY;AAEnC,SAAO;KACL;AAEJ,KAAI;AAEF,wBAAsB,EACpB,OAAO,YAAY,QAAQ,EAC5B;UACM,MAAM;AAIb,wBAAsB,EACpB,OAAO;GACL,gBAAgB,MAAW,OAAY,GAAG,cAAqB;IAC7D;IACA,OAAO;KACL,GAAG;KACH,UAAU,SAAS,UAAU,IAAI,SAAS,KAAK;KAChD;IACF;GACD,UAAU,OAAO,IAAI,iBAAiB;GACvC,EACF;;CAGH,MAAM,iBAA0B;EAC9B,SAAS,EACP,SAAS,EAAE,EACZ;EACD,QAAQ,EACN,SAAS,EAAE,EACZ;EACD,SAAS;GACP,GAAG;GACH,KAAK;IACH,GAAG,QAAQ;IACX,GAAG,YAAY,cAAc;IAC7B,GAAG;IACJ;GACF;EACD;EACA,SAAS;EACT,GAAG;EACJ;AAGD,QAAO,oBAAoB,WAAW,CAAC,SAAS,QAAQ;AACtD,MAAI,EAAE,OAAO,gBACX,gBAAe,OAAO,WAAW;GAEnC;AAEF,QAAO;;AAGT,MAAa,oBACX,mBACA,YACkB;CAClB,MAAM,iBAAiB,kBAAkB,QAAQ;AAGjD,iBAAgB,kBAAkB,qBAAqB,eAAe;CAEtE,MAAM,aAAwB;EAC5B,eAAe,SAAS;EACxB,eAAe,QAAQ,SAAS;EAChC,eAAe,QAAQ,SAAS;EAChC,eAAe,QAAQ;EACxB;AAED,MAAK,MAAM,aAAa,WACtB,KACE,aACA,OAAO,cAAc,YACrB,OAAO,KAAK,UAAoB,CAAC,SAAS,EAE1C,QAAO"}
@@ -1,2 +1,65 @@
1
- import{getPackageJsonPath as e}from"../utils/getPackageJsonPath.mjs";import{getLoader as t}from"./bundleFile.mjs";import{existsSync as n}from"node:fs";import{dirname as r,extname as i,join as a}from"node:path";import{build as o,buildSync as s}from"esbuild";import{pathToFileURL as c}from"node:url";const l=t=>{let i=a(e(r(t)).baseDir,`tsconfig.json`);return n(i)?i:void 0},u=e=>({loader:{".js":`js`,".jsx":`jsx`,".mjs":`js`,".ts":`ts`,".tsx":`tsx`,".cjs":`js`,".json":`json`,".md":`text`,".mdx":`text`},format:`cjs`,target:`node20`,platform:`node`,write:!1,packages:`external`,bundle:!0,tsconfig:l(e),define:{"import.meta.url":JSON.stringify(c(e).href)}}),d=(e,n,a)=>{let o=t(i(n)),{esbuildInstance:c,...l}=a??{};return(c?.buildSync??s)({stdin:{contents:e,loader:o,resolveDir:r(n),sourcefile:n},...u(n),...l}).outputFiles?.[0].text},f=async(e,n,a)=>{let s=t(i(n)),{esbuildInstance:c,...l}=a??{};return(await(c?.build??o)({stdin:{contents:e,loader:s,resolveDir:r(n),sourcefile:n},...u(n),...l})).outputFiles?.[0].text};export{f as transpileTSToCJS,d as transpileTSToCJSSync};
1
+ import { getPackageJsonPath } from "../utils/getPackageJsonPath.mjs";
2
+ import { getLoader } from "./bundleFile.mjs";
3
+ import { existsSync } from "node:fs";
4
+ import { dirname, extname, join } from "node:path";
5
+ import { build, buildSync } from "esbuild";
6
+ import { pathToFileURL } from "node:url";
7
+
8
+ //#region src/loadExternalFile/transpileTSToCJS.ts
9
+ const getTsConfigPath = (filePath) => {
10
+ const tsconfigPath = join(getPackageJsonPath(dirname(filePath)).baseDir, "tsconfig.json");
11
+ return existsSync(tsconfigPath) ? tsconfigPath : void 0;
12
+ };
13
+ const getTransformationOptions = (filePath) => ({
14
+ loader: {
15
+ ".js": "js",
16
+ ".jsx": "jsx",
17
+ ".mjs": "js",
18
+ ".ts": "ts",
19
+ ".tsx": "tsx",
20
+ ".cjs": "js",
21
+ ".json": "json",
22
+ ".md": "text",
23
+ ".mdx": "text"
24
+ },
25
+ format: "cjs",
26
+ target: "node20",
27
+ platform: "node",
28
+ write: false,
29
+ packages: "external",
30
+ bundle: true,
31
+ tsconfig: getTsConfigPath(filePath),
32
+ define: { "import.meta.url": JSON.stringify(pathToFileURL(filePath).href) }
33
+ });
34
+ const transpileTSToCJSSync = (code, filePath, options) => {
35
+ const loader = getLoader(extname(filePath));
36
+ const { esbuildInstance, ...buildOptions } = options ?? {};
37
+ return (esbuildInstance?.buildSync ?? buildSync)({
38
+ stdin: {
39
+ contents: code,
40
+ loader,
41
+ resolveDir: dirname(filePath),
42
+ sourcefile: filePath
43
+ },
44
+ ...getTransformationOptions(filePath),
45
+ ...buildOptions
46
+ }).outputFiles?.[0].text;
47
+ };
48
+ const transpileTSToCJS = async (code, filePath, options) => {
49
+ const loader = getLoader(extname(filePath));
50
+ const { esbuildInstance, ...buildOptions } = options ?? {};
51
+ return (await (esbuildInstance?.build ?? build)({
52
+ stdin: {
53
+ contents: code,
54
+ loader,
55
+ resolveDir: dirname(filePath),
56
+ sourcefile: filePath
57
+ },
58
+ ...getTransformationOptions(filePath),
59
+ ...buildOptions
60
+ })).outputFiles?.[0].text;
61
+ };
62
+
63
+ //#endregion
64
+ export { transpileTSToCJS, transpileTSToCJSSync };
2
65
  //# sourceMappingURL=transpileTSToCJS.mjs.map