@intlayer/config 6.0.2 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +237 -139
  2. package/dist/cjs/alias.cjs +1 -1
  3. package/dist/cjs/alias.cjs.map +1 -1
  4. package/dist/cjs/configFile/buildConfigurationFields.cjs +11 -4
  5. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  6. package/dist/cjs/configFile/getConfiguration.cjs +16 -6
  7. package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
  8. package/dist/cjs/configFile/loadConfigurationFile.cjs +7 -2
  9. package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
  10. package/dist/cjs/getSandboxContext.cjs +3 -2
  11. package/dist/cjs/getSandboxContext.cjs.map +1 -1
  12. package/dist/cjs/index.cjs +2 -0
  13. package/dist/cjs/index.cjs.map +1 -1
  14. package/dist/cjs/loadExternalFile.cjs +6 -2
  15. package/dist/cjs/loadExternalFile.cjs.map +1 -1
  16. package/dist/cjs/logger.cjs +22 -17
  17. package/dist/cjs/logger.cjs.map +1 -1
  18. package/dist/cjs/types/config.cjs.map +1 -1
  19. package/dist/cjs/utils/getExtension.cjs +3 -3
  20. package/dist/cjs/utils/getExtension.cjs.map +1 -1
  21. package/dist/esm/alias.mjs +1 -1
  22. package/dist/esm/alias.mjs.map +1 -1
  23. package/dist/esm/configFile/buildConfigurationFields.mjs +11 -4
  24. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  25. package/dist/esm/configFile/getConfiguration.mjs +16 -6
  26. package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
  27. package/dist/esm/configFile/loadConfigurationFile.mjs +7 -2
  28. package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
  29. package/dist/esm/getSandboxContext.mjs +3 -2
  30. package/dist/esm/getSandboxContext.mjs.map +1 -1
  31. package/dist/esm/index.mjs +2 -0
  32. package/dist/esm/index.mjs.map +1 -1
  33. package/dist/esm/loadExternalFile.mjs +6 -2
  34. package/dist/esm/loadExternalFile.mjs.map +1 -1
  35. package/dist/esm/logger.mjs +21 -17
  36. package/dist/esm/logger.mjs.map +1 -1
  37. package/dist/esm/utils/getExtension.mjs +3 -3
  38. package/dist/esm/utils/getExtension.mjs.map +1 -1
  39. package/dist/types/configFile/buildConfigurationFields.d.ts +2 -2
  40. package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
  41. package/dist/types/configFile/getConfiguration.d.ts +4 -1
  42. package/dist/types/configFile/getConfiguration.d.ts.map +1 -1
  43. package/dist/types/configFile/loadConfigurationFile.d.ts +1 -1
  44. package/dist/types/configFile/loadConfigurationFile.d.ts.map +1 -1
  45. package/dist/types/getSandboxContext.d.ts +1 -1
  46. package/dist/types/getSandboxContext.d.ts.map +1 -1
  47. package/dist/types/index.d.ts +2 -2
  48. package/dist/types/index.d.ts.map +1 -1
  49. package/dist/types/loadExternalFile.d.ts +1 -1
  50. package/dist/types/loadExternalFile.d.ts.map +1 -1
  51. package/dist/types/logger.d.ts +1 -0
  52. package/dist/types/logger.d.ts.map +1 -1
  53. package/dist/types/types/config.d.ts +14 -0
  54. package/dist/types/types/config.d.ts.map +1 -1
  55. package/package.json +7 -6
@@ -24,11 +24,11 @@ module.exports = __toCommonJS(getExtension_exports);
24
24
  var import_config = require("@intlayer/config");
25
25
  const getExtension = (configuration = (0, import_config.getConfiguration)(), format) => {
26
26
  const outputFormats = configuration.build.outputFormat;
27
- if (format === "esm") return "mjs";
28
27
  if (format === "cjs") return "cjs";
29
- if (outputFormats.includes("esm")) return "mjs";
28
+ if (format === "esm") return "mjs";
30
29
  if (outputFormats.includes("cjs")) return "cjs";
31
- return "mjs";
30
+ if (outputFormats.includes("esm")) return "mjs";
31
+ return "cjs";
32
32
  };
33
33
  // Annotate the CommonJS export names for ESM import in node:
34
34
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/getExtension.ts"],"sourcesContent":["import { type IntlayerConfig, getConfiguration } from '@intlayer/config';\n\nexport const getExtension = (\n configuration: IntlayerConfig = getConfiguration(),\n format?: 'esm' | 'cjs' | undefined\n) => {\n const outputFormats = configuration.build.outputFormat;\n\n if (format === 'esm') return 'mjs';\n if (format === 'cjs') return 'cjs';\n\n if (outputFormats.includes('esm')) return 'mjs';\n if (outputFormats.includes('cjs')) return 'cjs';\n\n return 'mjs';\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAsD;AAE/C,MAAM,eAAe,CAC1B,oBAAgC,gCAAiB,GACjD,WACG;AACH,QAAM,gBAAgB,cAAc,MAAM;AAE1C,MAAI,WAAW,MAAO,QAAO;AAC7B,MAAI,WAAW,MAAO,QAAO;AAE7B,MAAI,cAAc,SAAS,KAAK,EAAG,QAAO;AAC1C,MAAI,cAAc,SAAS,KAAK,EAAG,QAAO;AAE1C,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/getExtension.ts"],"sourcesContent":["import { type IntlayerConfig, getConfiguration } from '@intlayer/config';\n\nexport const getExtension = (\n configuration: IntlayerConfig = getConfiguration(),\n format?: 'esm' | 'cjs' | undefined\n) => {\n const outputFormats = configuration.build.outputFormat;\n\n if (format === 'cjs') return 'cjs';\n if (format === 'esm') return 'mjs';\n\n if (outputFormats.includes('cjs')) return 'cjs';\n if (outputFormats.includes('esm')) return 'mjs';\n\n return 'cjs';\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAsD;AAE/C,MAAM,eAAe,CAC1B,oBAAgC,gCAAiB,GACjD,WACG;AACH,QAAM,gBAAgB,cAAc,MAAM;AAE1C,MAAI,WAAW,MAAO,QAAO;AAC7B,MAAI,WAAW,MAAO,QAAO;AAE7B,MAAI,cAAc,SAAS,KAAK,EAAG,QAAO;AAC1C,MAAI,cAAc,SAAS,KAAK,EAAG,QAAO;AAE1C,SAAO;AACT;","names":[]}
@@ -4,7 +4,7 @@ import { getExtension } from "./utils/getExtension.mjs";
4
4
  import { normalizePath } from "./utils/normalizePath.mjs";
5
5
  const getAlias = ({
6
6
  configuration = getConfiguration(),
7
- format,
7
+ format = "esm",
8
8
  formatter = (value) => value
9
9
  } = {}) => {
10
10
  const extension = getExtension(configuration, format);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/alias.ts"],"sourcesContent":["import { join, relative } from 'path';\nimport { getConfiguration } from './configFile/getConfiguration';\nimport { IntlayerConfig } from './types/config';\nimport { getExtension } from './utils/getExtension';\nimport { normalizePath } from './utils/normalizePath';\n\nexport type GetAliasOptions = {\n configuration?: IntlayerConfig;\n format?: 'esm' | 'cjs';\n formatter?: (value: string) => string;\n};\n\nexport const getAlias = ({\n configuration = getConfiguration(),\n format,\n formatter = (value: string) => value,\n}: GetAliasOptions = {}) => {\n const extension = getExtension(configuration, format);\n\n const { mainDir, configDir, baseDir } = configuration.content;\n\n /**\n * Dictionaries\n */\n const dictionariesPath = join(mainDir, `dictionaries.${extension}`);\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n const normalizedDictionariesPath = formatter(\n normalizePath(relativeDictionariesPath)\n );\n\n /**\n * Unmerged dictionaries\n */\n const unmergedDictionariesPath = join(\n mainDir,\n `unmerged_dictionaries.${extension}`\n );\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n const normalizedUnmergedDictionariesPath = formatter(\n normalizePath(relativeUnmergedDictionariesPath)\n );\n\n /**\n * Remote dictionaries\n */\n const remoteDictionariesPath = join(\n mainDir,\n `remote_dictionaries.${extension}`\n );\n const relativeRemoteDictionariesPath = relative(\n baseDir,\n remoteDictionariesPath\n );\n const normalizedRemoteDictionariesPath = formatter(\n normalizePath(relativeRemoteDictionariesPath)\n );\n\n /**\n * Dynamic dictionaries\n */\n const dynamicDictionariesPath = join(\n mainDir,\n `dynamic_dictionaries.${extension}`\n );\n const relativeDynamicDictionariesPath = relative(\n baseDir,\n dynamicDictionariesPath\n );\n const normalizedDynamicDictionariesPath = formatter(\n normalizePath(relativeDynamicDictionariesPath)\n );\n\n /**\n * Fetch dictionaries\n */\n const fetchDictionariesPath = join(\n mainDir,\n `fetch_dictionaries.${extension}`\n );\n const relativeFetchDictionariesPath = relative(\n baseDir,\n fetchDictionariesPath\n );\n const normalizedFetchDictionariesPath = formatter(\n normalizePath(relativeFetchDictionariesPath)\n );\n\n /**\n * Configuration\n */\n const configurationPath = join(configDir, `configuration.json`);\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n const normalizedConfigurationPath = formatter(\n normalizePath(relativeConfigurationPath)\n );\n\n return {\n '@intlayer/dictionaries-entry': normalizedDictionariesPath,\n '@intlayer/unmerged-dictionaries-entry': normalizedUnmergedDictionariesPath,\n '@intlayer/remote-dictionaries-entry': normalizedRemoteDictionariesPath,\n '@intlayer/dynamic-dictionaries-entry': normalizedDynamicDictionariesPath,\n '@intlayer/fetch-dictionaries-entry': normalizedFetchDictionariesPath,\n '@intlayer/config/built': normalizedConfigurationPath,\n };\n};\n"],"mappings":"AAAA,SAAS,MAAM,gBAAgB;AAC/B,SAAS,wBAAwB;AAEjC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAQvB,MAAM,WAAW,CAAC;AAAA,EACvB,gBAAgB,iBAAiB;AAAA,EACjC;AAAA,EACA,YAAY,CAAC,UAAkB;AACjC,IAAqB,CAAC,MAAM;AAC1B,QAAM,YAAY,aAAa,eAAe,MAAM;AAEpD,QAAM,EAAE,SAAS,WAAW,QAAQ,IAAI,cAAc;AAKtD,QAAM,mBAAmB,KAAK,SAAS,gBAAgB,SAAS,EAAE;AAClE,QAAM,2BAA2B,SAAS,SAAS,gBAAgB;AACnE,QAAM,6BAA6B;AAAA,IACjC,cAAc,wBAAwB;AAAA,EACxC;AAKA,QAAM,2BAA2B;AAAA,IAC/B;AAAA,IACA,yBAAyB,SAAS;AAAA,EACpC;AACA,QAAM,mCAAmC;AAAA,IACvC;AAAA,IACA;AAAA,EACF;AACA,QAAM,qCAAqC;AAAA,IACzC,cAAc,gCAAgC;AAAA,EAChD;AAKA,QAAM,yBAAyB;AAAA,IAC7B;AAAA,IACA,uBAAuB,SAAS;AAAA,EAClC;AACA,QAAM,iCAAiC;AAAA,IACrC;AAAA,IACA;AAAA,EACF;AACA,QAAM,mCAAmC;AAAA,IACvC,cAAc,8BAA8B;AAAA,EAC9C;AAKA,QAAM,0BAA0B;AAAA,IAC9B;AAAA,IACA,wBAAwB,SAAS;AAAA,EACnC;AACA,QAAM,kCAAkC;AAAA,IACtC;AAAA,IACA;AAAA,EACF;AACA,QAAM,oCAAoC;AAAA,IACxC,cAAc,+BAA+B;AAAA,EAC/C;AAKA,QAAM,wBAAwB;AAAA,IAC5B;AAAA,IACA,sBAAsB,SAAS;AAAA,EACjC;AACA,QAAM,gCAAgC;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AACA,QAAM,kCAAkC;AAAA,IACtC,cAAc,6BAA6B;AAAA,EAC7C;AAKA,QAAM,oBAAoB,KAAK,WAAW,oBAAoB;AAC9D,QAAM,4BAA4B,SAAS,SAAS,iBAAiB;AACrE,QAAM,8BAA8B;AAAA,IAClC,cAAc,yBAAyB;AAAA,EACzC;AAEA,SAAO;AAAA,IACL,gCAAgC;AAAA,IAChC,yCAAyC;AAAA,IACzC,uCAAuC;AAAA,IACvC,wCAAwC;AAAA,IACxC,sCAAsC;AAAA,IACtC,0BAA0B;AAAA,EAC5B;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/alias.ts"],"sourcesContent":["import { join, relative } from 'path';\nimport { getConfiguration } from './configFile/getConfiguration';\nimport { IntlayerConfig } from './types/config';\nimport { getExtension } from './utils/getExtension';\nimport { normalizePath } from './utils/normalizePath';\n\nexport type GetAliasOptions = {\n configuration?: IntlayerConfig;\n format?: 'esm' | 'cjs';\n formatter?: (value: string) => string;\n};\n\nexport const getAlias = ({\n configuration = getConfiguration(),\n format = 'esm',\n formatter = (value: string) => value,\n}: GetAliasOptions = {}) => {\n const extension = getExtension(configuration, format);\n\n const { mainDir, configDir, baseDir } = configuration.content;\n\n /**\n * Dictionaries\n */\n const dictionariesPath = join(mainDir, `dictionaries.${extension}`);\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n const normalizedDictionariesPath = formatter(\n normalizePath(relativeDictionariesPath)\n );\n\n /**\n * Unmerged dictionaries\n */\n const unmergedDictionariesPath = join(\n mainDir,\n `unmerged_dictionaries.${extension}`\n );\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n const normalizedUnmergedDictionariesPath = formatter(\n normalizePath(relativeUnmergedDictionariesPath)\n );\n\n /**\n * Remote dictionaries\n */\n const remoteDictionariesPath = join(\n mainDir,\n `remote_dictionaries.${extension}`\n );\n const relativeRemoteDictionariesPath = relative(\n baseDir,\n remoteDictionariesPath\n );\n const normalizedRemoteDictionariesPath = formatter(\n normalizePath(relativeRemoteDictionariesPath)\n );\n\n /**\n * Dynamic dictionaries\n */\n const dynamicDictionariesPath = join(\n mainDir,\n `dynamic_dictionaries.${extension}`\n );\n const relativeDynamicDictionariesPath = relative(\n baseDir,\n dynamicDictionariesPath\n );\n const normalizedDynamicDictionariesPath = formatter(\n normalizePath(relativeDynamicDictionariesPath)\n );\n\n /**\n * Fetch dictionaries\n */\n const fetchDictionariesPath = join(\n mainDir,\n `fetch_dictionaries.${extension}`\n );\n const relativeFetchDictionariesPath = relative(\n baseDir,\n fetchDictionariesPath\n );\n const normalizedFetchDictionariesPath = formatter(\n normalizePath(relativeFetchDictionariesPath)\n );\n\n /**\n * Configuration\n */\n const configurationPath = join(configDir, `configuration.json`);\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n const normalizedConfigurationPath = formatter(\n normalizePath(relativeConfigurationPath)\n );\n\n return {\n '@intlayer/dictionaries-entry': normalizedDictionariesPath,\n '@intlayer/unmerged-dictionaries-entry': normalizedUnmergedDictionariesPath,\n '@intlayer/remote-dictionaries-entry': normalizedRemoteDictionariesPath,\n '@intlayer/dynamic-dictionaries-entry': normalizedDynamicDictionariesPath,\n '@intlayer/fetch-dictionaries-entry': normalizedFetchDictionariesPath,\n '@intlayer/config/built': normalizedConfigurationPath,\n };\n};\n"],"mappings":"AAAA,SAAS,MAAM,gBAAgB;AAC/B,SAAS,wBAAwB;AAEjC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAQvB,MAAM,WAAW,CAAC;AAAA,EACvB,gBAAgB,iBAAiB;AAAA,EACjC,SAAS;AAAA,EACT,YAAY,CAAC,UAAkB;AACjC,IAAqB,CAAC,MAAM;AAC1B,QAAM,YAAY,aAAa,eAAe,MAAM;AAEpD,QAAM,EAAE,SAAS,WAAW,QAAQ,IAAI,cAAc;AAKtD,QAAM,mBAAmB,KAAK,SAAS,gBAAgB,SAAS,EAAE;AAClE,QAAM,2BAA2B,SAAS,SAAS,gBAAgB;AACnE,QAAM,6BAA6B;AAAA,IACjC,cAAc,wBAAwB;AAAA,EACxC;AAKA,QAAM,2BAA2B;AAAA,IAC/B;AAAA,IACA,yBAAyB,SAAS;AAAA,EACpC;AACA,QAAM,mCAAmC;AAAA,IACvC;AAAA,IACA;AAAA,EACF;AACA,QAAM,qCAAqC;AAAA,IACzC,cAAc,gCAAgC;AAAA,EAChD;AAKA,QAAM,yBAAyB;AAAA,IAC7B;AAAA,IACA,uBAAuB,SAAS;AAAA,EAClC;AACA,QAAM,iCAAiC;AAAA,IACrC;AAAA,IACA;AAAA,EACF;AACA,QAAM,mCAAmC;AAAA,IACvC,cAAc,8BAA8B;AAAA,EAC9C;AAKA,QAAM,0BAA0B;AAAA,IAC9B;AAAA,IACA,wBAAwB,SAAS;AAAA,EACnC;AACA,QAAM,kCAAkC;AAAA,IACtC;AAAA,IACA;AAAA,EACF;AACA,QAAM,oCAAoC;AAAA,IACxC,cAAc,+BAA+B;AAAA,EAC/C;AAKA,QAAM,wBAAwB;AAAA,IAC5B;AAAA,IACA,sBAAsB,SAAS;AAAA,EACjC;AACA,QAAM,gCAAgC;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AACA,QAAM,kCAAkC;AAAA,IACtC,cAAc,6BAA6B;AAAA,EAC7C;AAKA,QAAM,oBAAoB,KAAK,WAAW,oBAAoB;AAC9D,QAAM,4BAA4B,SAAS,SAAS,iBAAiB;AACrE,QAAM,8BAA8B;AAAA,IAClC,cAAc,yBAAyB;AAAA,EACzC;AAEA,SAAO;AAAA,IACL,gCAAgC;AAAA,IAChC,yCAAyC;AAAA,IACzC,uCAAuC;AAAA,IACvC,wCAAwC;AAAA,IACxC,sCAAsC;AAAA,IACtC,0BAA0B;AAAA,EAC5B;AACF;","names":[]}
@@ -536,7 +536,7 @@ const buildEditorFields = (customConfiguration) => ({
536
536
  */
537
537
  liveSyncURL: customConfiguration?.liveSyncURL ?? `http://localhost:${customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT}`
538
538
  });
539
- const buildLogFields = (customConfiguration) => ({
539
+ const buildLogFields = (customConfiguration, logFunctions) => ({
540
540
  /**
541
541
  * Indicates if the logger is enabled
542
542
  *
@@ -554,7 +554,14 @@ const buildLogFields = (customConfiguration) => ({
554
554
  *
555
555
  * The prefix of the logger.
556
556
  */
557
- prefix: customConfiguration?.prefix ?? PREFIX
557
+ prefix: customConfiguration?.prefix ?? PREFIX,
558
+ /**
559
+ * Functions to log
560
+ */
561
+ error: logFunctions?.error,
562
+ log: logFunctions?.log,
563
+ info: logFunctions?.info,
564
+ warn: logFunctions?.warn
558
565
  });
559
566
  const buildAiFields = (customConfiguration) => ({
560
567
  /**
@@ -652,7 +659,7 @@ const buildBuildFields = (customConfiguration) => ({
652
659
  */
653
660
  outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT
654
661
  });
655
- const buildConfigurationFields = (customConfiguration, baseDir) => {
662
+ const buildConfigurationFields = (customConfiguration, baseDir, logFunctions) => {
656
663
  const internationalizationConfig = buildInternationalizationFields(
657
664
  customConfiguration?.internationalization
658
665
  );
@@ -664,7 +671,7 @@ const buildConfigurationFields = (customConfiguration, baseDir) => {
664
671
  baseDir
665
672
  );
666
673
  const editorConfig = buildEditorFields(customConfiguration?.editor);
667
- const logConfig = buildLogFields(customConfiguration?.log);
674
+ const logConfig = buildLogFields(customConfiguration?.log, logFunctions);
668
675
  const aiConfig = buildAiFields(customConfiguration?.ai);
669
676
  const buildConfig = buildBuildFields(customConfiguration?.build);
670
677
  storedConfiguration = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { join } from 'path';\nimport {\n IMPORT_MODE,\n OPTIMIZE,\n OUTPUT_FORMAT,\n TRAVERSE_PATTERN,\n} from '../defaultValues/build';\nimport {\n CONFIG_DIR,\n CONTENT_DIR,\n DICTIONARIES_DIR,\n DYNAMIC_DICTIONARIES_DIR,\n EXCLUDED_PATHS,\n FETCH_DICTIONARIES_DIR,\n FILE_EXTENSIONS,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REMOTE_DICTIONARIES_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n WATCH,\n} from '../defaultValues/content';\nimport {\n APPLICATION_URL,\n BACKEND_URL,\n CMS_URL,\n DICTIONARY_PRIORITY_STRATEGY,\n EDITOR_URL,\n IS_ENABLED,\n LIVE_SYNC,\n LIVE_SYNC_PORT,\n PORT,\n} from '../defaultValues/editor';\nimport {\n DEFAULT_LOCALE,\n LOCALES,\n REQUIRED_LOCALES,\n STRICT_MODE,\n} from '../defaultValues/internationalization';\nimport { MODE, PREFIX } from '../defaultValues/log';\nimport {\n BASE_PATH,\n COOKIE_NAME,\n DETECT_LOCALE_ON_PREFETCH_NO_PREFIX,\n HEADER_NAME,\n NO_PREFIX,\n PREFIX_DEFAULT,\n SERVER_SET_COOKIE,\n} from '../defaultValues/middleware';\nimport type {\n AiConfig,\n BaseContentConfig,\n BaseDerivedConfig,\n BuildConfig,\n ContentConfig,\n CustomIntlayerConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n MiddlewareConfig,\n PatternsContentConfig,\n ResultDirDerivedConfig,\n} from '../types/config';\nimport { normalizePath } from '../utils/normalizePath';\n\nlet storedConfiguration: IntlayerConfig;\n\n// @TODO - Add possibility of directories configurations to be arrays to allow multiple packages management\n\nconst buildInternationalizationFields = (\n customConfiguration?: Partial<InternationalizationConfig>\n): InternationalizationConfig => ({\n /**\n * Locales available in the application\n *\n * Default: ['en']\n *\n */\n locales: customConfiguration?.locales ?? LOCALES,\n\n /**\n * Locales required by TypeScript to ensure strong implementations of internationalized content using typescript.\n *\n * Default: []\n *\n * If empty, all locales are required in `strict` mode.\n *\n * Ensure required locales are also defined in the `locales` field.\n */\n requiredLocales:\n customConfiguration?.requiredLocales ??\n customConfiguration?.locales ??\n REQUIRED_LOCALES,\n\n /**\n * Ensure strong implementations of internationalized content using typescript.\n * - If set to \"strict\", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.\n * - If set to \"inclusive\", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.\n * - If set to \"loose\", the translation `t` function will accept any existing locale.\n *\n * Default: \"inclusive\"\n */\n strictMode: customConfiguration?.strictMode ?? STRICT_MODE,\n\n /**\n * Default locale of the application for fallback\n *\n * Default: 'en'\n */\n defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE,\n});\n\nconst buildMiddlewareFields = (\n customConfiguration?: Partial<MiddlewareConfig>\n): MiddlewareConfig => ({\n /**\n * Header name to get the locale\n *\n * Default: 'x-intlayer-locale'\n */\n headerName: customConfiguration?.headerName ?? HEADER_NAME,\n\n /**\n * Cookie name to get the locale\n *\n * Default: 'intlayer-locale'\n */\n cookieName: customConfiguration?.cookieName ?? COOKIE_NAME,\n\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n *\n * Default: false\n */\n prefixDefault: customConfiguration?.prefixDefault ?? PREFIX_DEFAULT,\n\n /**\n * Base path of the application URL\n *\n * Default: ''\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n */\n basePath: customConfiguration?.basePath ?? BASE_PATH,\n\n /**\n * Rule to set the cookie on the server\n * - 'always': Set the cookie on every request\n * - 'never': Never set the cookie\n */\n serverSetCookie: customConfiguration?.serverSetCookie ?? SERVER_SET_COOKIE,\n\n /**\n * No prefix in the URL\n * - true: No prefix in the URL\n * - false: Prefix in the URL\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n * - If no prefix is set, the URL will be https://example.com/en\n * - If the no prefix is set to true, the URL will be https://example.com\n *\n * Default: false\n */\n noPrefix: customConfiguration?.noPrefix ?? NO_PREFIX,\n\n /**\n * Controls whether locale detection occurs during Next.js prefetch requests\n * - true: Detect and apply locale during prefetch\n * - false: Use default locale during prefetch (recommended)\n *\n * This setting affects how Next.js handles locale prefetching:\n *\n * Example scenario:\n * - User's browser language is 'fr'\n * - Current page is /fr/about\n * - Link prefetches /about\n *\n * With `detectLocaleOnPrefetchNoPrefix:true`\n * - Prefetch detects 'fr' locale from browser\n * - Redirects prefetch to /fr/about\n *\n * With `detectLocaleOnPrefetchNoPrefix:false` (default)\n * - Prefetch uses default locale\n * - Redirects prefetch to /en/about (assuming 'en' is default)\n *\n * When to use true:\n * - Your app uses non-localized internal links (e.g. <a href=\"/about\">)\n * - You want consistent locale detection behavior between regular and prefetch requests\n *\n * When to use false (default):\n * - Your app uses locale-prefixed links (e.g. <a href=\"/fr/about\">)\n * - You want to optimize prefetching performance\n * - You want to avoid potential redirect loops\n *\n * Default: false\n */\n detectLocaleOnPrefetchNoPrefix:\n customConfiguration?.detectLocaleOnPrefetchNoPrefix ??\n DETECT_LOCALE_ON_PREFETCH_NO_PREFIX,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>,\n baseDir?: string\n): ContentConfig => {\n const notDerivedContentConfig: BaseContentConfig = {\n /**\n * File extensions of content to look for to build the dictionaries\n *\n * - Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * - Example: ['.data.ts', '.data.js', '.data.json']\n *\n * Note:\n * - Can exclude unused file extensions to improve performance\n * - Avoid using common file extensions like '.ts', '.js', '.json' to avoid conflicts\n */\n fileExtensions: customConfiguration?.fileExtensions ?? FILE_EXTENSIONS,\n\n /**\n * Absolute path of the directory of the project\n * - Default: process.cwd()\n * - Example: '\n *\n * Will be used to resolve all intlayer directories\n *\n * Note:\n * - The base directory should be the root of the project\n * - Can be changed to a custom directory to externalize either the content used in the project, or the intlayer application from the project\n */\n baseDir: customConfiguration?.baseDir ?? baseDir ?? process.cwd(),\n\n /**\n * Should exclude some directories from the content search\n *\n * Default: ['node_modules']\n *\n * Not used yet\n * @TODO Implement the exclusion or remove it\n */\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n\n /**\n * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.\n *\n * Default: process.env.NODE_ENV === 'development'\n */\n watch: customConfiguration?.watch ?? WATCH,\n\n /**\n * Indicate how the content should be automatically filled using AI.\n *\n * Default: undefined\n */\n autoFill: customConfiguration?.autoFill ?? undefined,\n };\n\n const baseDirDerivedConfiguration: BaseDerivedConfig = {\n /**\n * Directory where the content is stored\n *\n * Relative to the base directory of the project\n *\n * Default: ./src\n *\n * Example: 'src'\n *\n * Note:\n * - Can be changed to a custom directory to externalize the content used in the project\n * - If the content is not at the base directory level, update the contentDirName field instead\n */\n contentDir: (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n (contentDir) => join(notDerivedContentConfig.baseDir, contentDir)\n ),\n\n /**\n * Directory where the result will be stored\n *\n * Relative to the base directory of the project\n *\n * Default: .intlayer/dictionary\n *\n * Example: '.intlayer'\n *\n * Note:\n * - Can be changed to a custom directory to externalize the intlayer application from the project\n * - If the result is not at the base directory level, update the dictionariesDirName field instead\n */\n dictionariesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the module augmentation will be stored\n *\n * Module augmentation allow better IDE suggestions and type checking\n *\n * Relative to the base directory of the project\n *\n * Default: .intlayer/types\n *\n * Example: 'types'\n *\n * Note:\n * - If this path changed, be sure to include it from the tsconfig.json file\n * - If the module augmentation is not at the base directory level, update the moduleAugmentationDirName field instead\n *\n */\n moduleAugmentationDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n };\n\n const dictionariesDirDerivedConfiguration: ResultDirDerivedConfig = {\n /**\n * Directory where the unmerged dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: '.intlayer/unmerged_dictionary'\n *\n */\n unmergedDictionariesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the remote dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: '.intlayer/remote_dictionary'\n */\n remoteDictionariesDir: join(\n notDerivedContentConfig.baseDir,\n customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the final dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Example: '.intlayer/dictionary'\n *\n * Note:\n * - If the types are not at the result directory level, update the dictionariesDirName field instead\n * - The dictionaries are stored in JSON format\n * - The dictionaries are used to translate the content\n * - The dictionaries are built from the content files\n */\n dictionariesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the dynamic dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/dynamic_dictionary\n */\n dynamicDictionariesDir: join(\n notDerivedContentConfig.baseDir,\n customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the fetch dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/fetch_dictionary\n */\n fetchDictionariesDir: join(\n notDerivedContentConfig.baseDir,\n customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the dictionaries types will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Example: 'types'\n *\n * Note:\n * - If the types are not at the result directory level, update the typesDirName field instead\n */\n typesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.typesDir ?? TYPES_DIR\n ),\n\n /**\n * Directory where the main files will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Example: '.intlayer/main'\n *\n * Note:\n *\n * - If the main files are not at the result directory level, update the mainDirName field instead\n */\n mainDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.mainDir ?? MAIN_DIR\n ),\n\n /**\n * Directory where the configuration files are stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Example: '.intlayer/config'\n *\n * Note:\n *\n * - If the configuration files are not at the result directory level, update the configDirName field instead\n */\n configDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n };\n\n const patternsConfiguration: PatternsContentConfig = {\n /**\n * Pattern of files to watch\n *\n * Default: ['/**\\/*.content.ts', '/**\\/*.content.js', '/**\\/*.content.json', '/**\\/*.content.cjs', '/**\\/*.content.mjs', '/**\\/*.content.tsx', '/**\\/*.content.jsx']\n */\n watchedFilesPattern: notDerivedContentConfig.fileExtensions.map(\n (ext) => `/**/*${ext}`\n ),\n\n /**\n * Pattern of files to watch including the relative path\n *\n * Default: ['src/**\\/*.content.ts', 'src/**\\/*.content.js', 'src/**\\/*.content.json', 'src/**\\/*.content.cjs', 'src/**\\/*.content.mjs', 'src/**\\/*.content.tsx', 'src/**\\/*.content.jsx']\n */\n watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.flatMap(\n (ext) =>\n baseDirDerivedConfiguration.contentDir.map(\n (contentDir) => `${normalizePath(contentDir)}/**/*${ext}`\n )\n ),\n\n /**\n * Pattern of dictionary to interpret\n *\n * Default: '.intlayer/dictionary/**\\/*.json'\n */\n outputFilesPatternWithPath: `${normalizePath(\n dictionariesDirDerivedConfiguration.dictionariesDir\n )}/**/*.json`,\n };\n\n return {\n ...notDerivedContentConfig,\n ...baseDirDerivedConfiguration,\n ...dictionariesDirDerivedConfiguration,\n ...patternsConfiguration,\n };\n};\n\nconst buildEditorFields = (\n customConfiguration?: Partial<EditorConfig>\n): EditorConfig => ({\n /**\n * URL of the application. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n applicationURL: customConfiguration?.applicationURL ?? APPLICATION_URL,\n\n /**\n * URL of the editor server. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n editorURL: customConfiguration?.editorURL ?? EDITOR_URL,\n\n /**\n * URL of the CMS server. Used to restrict the origin of the editor for security reasons.\n */\n cmsURL: customConfiguration?.cmsURL ?? CMS_URL,\n\n /**\n * URL of the editor server\n *\n * Default: 'https://back.intlayer.org'\n */\n backendURL: customConfiguration?.backendURL ?? BACKEND_URL,\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: customConfiguration?.port ?? PORT,\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: true;\n *\n * If true, the editor will be able to interact with the application.\n * If false, the editor will not be able to interact with the application.\n * In any case, the editor can only be enabled by the visual editor.\n * Disabling the editor for specific environments is a way to enforce the security.\n *\n * Usage:\n * ```js\n * {\n * // Other configurations\n * editor: {\n * enabled: process.env.NODE_ENV !== 'production',\n * }\n * };\n * ```\n */\n enabled: customConfiguration?.enabled ?? IS_ENABLED,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://intlayer.org/dashboard/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientId: customConfiguration?.clientId ?? undefined,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://intlayer.org/dashboard/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientSecret: customConfiguration?.clientSecret ?? undefined,\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy:\n customConfiguration?.dictionaryPriorityStrategy ??\n DICTIONARY_PRIORITY_STRATEGY,\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * The hot reload is only available for clients of the `enterprise` plan.\n *\n * Default: false\n */\n liveSync: customConfiguration?.liveSync ?? LIVE_SYNC,\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT,\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${LIVE_SYNC_PORT}`\n */\n liveSyncURL:\n customConfiguration?.liveSyncURL ??\n `http://localhost:${customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT}`,\n});\n\nconst buildLogFields = (\n customConfiguration?: Partial<LogConfig>\n): LogConfig => ({\n /**\n * Indicates if the logger is enabled\n *\n * Default: 'default'\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: customConfiguration?.mode ?? MODE,\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: customConfiguration?.prefix ?? PREFIX,\n});\n\nconst buildAiFields = (customConfiguration?: Partial<AiConfig>): AiConfig => ({\n /**\n * AI configuration\n */\n provider: customConfiguration?.provider,\n\n /**\n * API key\n */\n apiKey: customConfiguration?.apiKey,\n\n /**\n * API model\n */\n model: customConfiguration?.model,\n\n /**\n * Temperature\n */\n temperature: customConfiguration?.temperature,\n\n /**\n * Application context\n */\n applicationContext: customConfiguration?.applicationContext,\n});\n\nconst buildBuildFields = (\n customConfiguration?: Partial<BuildConfig>\n): BuildConfig => ({\n /**\n * Indicates if the build should be optimized\n *\n * Default: process.env.NODE_ENV === 'production'\n *\n * If true, the build will be optimized.\n * If false, the build will not be optimized.\n *\n * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.\n * All imports will stay as static import to avoid async processing when loading the dictionaries.\n *\n * Note:\n * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.\n * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - In most cases, \"dynamic\" will be used for React applications, \"async\" for Vue.js applications.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize: customConfiguration?.optimize ?? OPTIMIZE,\n\n /**\n * Indicates the mode of import to use for the dictionaries.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Live mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as \"dynamic\" mode.\n *\n * Default: \"static\"\n *\n * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.\n *\n * Note:\n * - Dynamic imports rely on Suspense and may slightly impact rendering performance.\n * - If desabled all locales will be loaded at once, even if they are not used.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n * - This option will be ignored if `optimize` is disabled.\n * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.\n * - The \"live\" allows to sync the dictionaries to the live sync server.\n */\n importMode: customConfiguration?.importMode ?? IMPORT_MODE,\n\n /**\n * Pattern to traverse the code to optimize.\n *\n * Allows to avoid to traverse the code that is not relevant to the optimization.\n * Improve build performance.\n *\n * Default: ['**\\/*.{js,ts,mjs,cjs,jsx,tsx,mjx,cjx}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: customConfiguration?.traversePattern ?? TRAVERSE_PATTERN,\n\n /**\n * Output format of the dictionaries\n *\n * Can be set on large projects to improve build performance.\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'.\n * - 'cjs': The dictionaries are outputted as CommonJS modules.\n * - 'esm': The dictionaries are outputted as ES modules.\n */\n outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT,\n});\n\n/**\n * Build the configuration fields by merging the default values with the custom configuration\n */\nexport const buildConfigurationFields = (\n customConfiguration?: CustomIntlayerConfig,\n baseDir?: string\n): IntlayerConfig => {\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const middlewareConfig = buildMiddlewareFields(\n customConfiguration?.middleware\n );\n\n const contentConfig = buildContentFields(\n customConfiguration?.content,\n baseDir\n );\n\n const editorConfig = buildEditorFields(customConfiguration?.editor);\n\n const logConfig = buildLogFields(customConfiguration?.log);\n\n const aiConfig = buildAiFields(customConfiguration?.ai);\n\n const buildConfig = buildBuildFields(customConfiguration?.build);\n\n storedConfiguration = {\n internationalization: internationalizationConfig,\n middleware: middlewareConfig,\n content: contentConfig,\n editor: editorConfig,\n log: logConfig,\n ai: aiConfig,\n build: buildConfig,\n };\n\n return storedConfiguration;\n};\n"],"mappings":"AAAA,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,MAAM,cAAc;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgBP,SAAS,qBAAqB;AAE9B,IAAI;AAIJ,MAAM,kCAAkC,CACtC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qBAAqB;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,eAAe,kBAAkB,qBAAqB,MAAM;AAElE,QAAM,YAAY,eAAe,qBAAqB,GAAG;AAEzD,QAAM,WAAW,cAAc,qBAAqB,EAAE;AAEtD,QAAM,cAAc,iBAAiB,qBAAqB,KAAK;AAE/D,wBAAsB;AAAA,IACpB,sBAAsB;AAAA,IACtB,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,KAAK;AAAA,IACL,IAAI;AAAA,IACJ,OAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { join } from 'path';\nimport {\n IMPORT_MODE,\n OPTIMIZE,\n OUTPUT_FORMAT,\n TRAVERSE_PATTERN,\n} from '../defaultValues/build';\nimport {\n CONFIG_DIR,\n CONTENT_DIR,\n DICTIONARIES_DIR,\n DYNAMIC_DICTIONARIES_DIR,\n EXCLUDED_PATHS,\n FETCH_DICTIONARIES_DIR,\n FILE_EXTENSIONS,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REMOTE_DICTIONARIES_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n WATCH,\n} from '../defaultValues/content';\nimport {\n APPLICATION_URL,\n BACKEND_URL,\n CMS_URL,\n DICTIONARY_PRIORITY_STRATEGY,\n EDITOR_URL,\n IS_ENABLED,\n LIVE_SYNC,\n LIVE_SYNC_PORT,\n PORT,\n} from '../defaultValues/editor';\nimport {\n DEFAULT_LOCALE,\n LOCALES,\n REQUIRED_LOCALES,\n STRICT_MODE,\n} from '../defaultValues/internationalization';\nimport { MODE, PREFIX } from '../defaultValues/log';\nimport {\n BASE_PATH,\n COOKIE_NAME,\n DETECT_LOCALE_ON_PREFETCH_NO_PREFIX,\n HEADER_NAME,\n NO_PREFIX,\n PREFIX_DEFAULT,\n SERVER_SET_COOKIE,\n} from '../defaultValues/middleware';\nimport type {\n AiConfig,\n BaseContentConfig,\n BaseDerivedConfig,\n BuildConfig,\n ContentConfig,\n CustomIntlayerConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n LogFunctions,\n MiddlewareConfig,\n PatternsContentConfig,\n ResultDirDerivedConfig,\n} from '../types/config';\nimport { normalizePath } from '../utils/normalizePath';\n\nlet storedConfiguration: IntlayerConfig;\n\n// @TODO - Add possibility of directories configurations to be arrays to allow multiple packages management\n\nconst buildInternationalizationFields = (\n customConfiguration?: Partial<InternationalizationConfig>\n): InternationalizationConfig => ({\n /**\n * Locales available in the application\n *\n * Default: ['en']\n *\n */\n locales: customConfiguration?.locales ?? LOCALES,\n\n /**\n * Locales required by TypeScript to ensure strong implementations of internationalized content using typescript.\n *\n * Default: []\n *\n * If empty, all locales are required in `strict` mode.\n *\n * Ensure required locales are also defined in the `locales` field.\n */\n requiredLocales:\n customConfiguration?.requiredLocales ??\n customConfiguration?.locales ??\n REQUIRED_LOCALES,\n\n /**\n * Ensure strong implementations of internationalized content using typescript.\n * - If set to \"strict\", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.\n * - If set to \"inclusive\", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.\n * - If set to \"loose\", the translation `t` function will accept any existing locale.\n *\n * Default: \"inclusive\"\n */\n strictMode: customConfiguration?.strictMode ?? STRICT_MODE,\n\n /**\n * Default locale of the application for fallback\n *\n * Default: 'en'\n */\n defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE,\n});\n\nconst buildMiddlewareFields = (\n customConfiguration?: Partial<MiddlewareConfig>\n): MiddlewareConfig => ({\n /**\n * Header name to get the locale\n *\n * Default: 'x-intlayer-locale'\n */\n headerName: customConfiguration?.headerName ?? HEADER_NAME,\n\n /**\n * Cookie name to get the locale\n *\n * Default: 'intlayer-locale'\n */\n cookieName: customConfiguration?.cookieName ?? COOKIE_NAME,\n\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n *\n * Default: false\n */\n prefixDefault: customConfiguration?.prefixDefault ?? PREFIX_DEFAULT,\n\n /**\n * Base path of the application URL\n *\n * Default: ''\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n */\n basePath: customConfiguration?.basePath ?? BASE_PATH,\n\n /**\n * Rule to set the cookie on the server\n * - 'always': Set the cookie on every request\n * - 'never': Never set the cookie\n */\n serverSetCookie: customConfiguration?.serverSetCookie ?? SERVER_SET_COOKIE,\n\n /**\n * No prefix in the URL\n * - true: No prefix in the URL\n * - false: Prefix in the URL\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n * - If no prefix is set, the URL will be https://example.com/en\n * - If the no prefix is set to true, the URL will be https://example.com\n *\n * Default: false\n */\n noPrefix: customConfiguration?.noPrefix ?? NO_PREFIX,\n\n /**\n * Controls whether locale detection occurs during Next.js prefetch requests\n * - true: Detect and apply locale during prefetch\n * - false: Use default locale during prefetch (recommended)\n *\n * This setting affects how Next.js handles locale prefetching:\n *\n * Example scenario:\n * - User's browser language is 'fr'\n * - Current page is /fr/about\n * - Link prefetches /about\n *\n * With `detectLocaleOnPrefetchNoPrefix:true`\n * - Prefetch detects 'fr' locale from browser\n * - Redirects prefetch to /fr/about\n *\n * With `detectLocaleOnPrefetchNoPrefix:false` (default)\n * - Prefetch uses default locale\n * - Redirects prefetch to /en/about (assuming 'en' is default)\n *\n * When to use true:\n * - Your app uses non-localized internal links (e.g. <a href=\"/about\">)\n * - You want consistent locale detection behavior between regular and prefetch requests\n *\n * When to use false (default):\n * - Your app uses locale-prefixed links (e.g. <a href=\"/fr/about\">)\n * - You want to optimize prefetching performance\n * - You want to avoid potential redirect loops\n *\n * Default: false\n */\n detectLocaleOnPrefetchNoPrefix:\n customConfiguration?.detectLocaleOnPrefetchNoPrefix ??\n DETECT_LOCALE_ON_PREFETCH_NO_PREFIX,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>,\n baseDir?: string\n): ContentConfig => {\n const notDerivedContentConfig: BaseContentConfig = {\n /**\n * File extensions of content to look for to build the dictionaries\n *\n * - Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * - Example: ['.data.ts', '.data.js', '.data.json']\n *\n * Note:\n * - Can exclude unused file extensions to improve performance\n * - Avoid using common file extensions like '.ts', '.js', '.json' to avoid conflicts\n */\n fileExtensions: customConfiguration?.fileExtensions ?? FILE_EXTENSIONS,\n\n /**\n * Absolute path of the directory of the project\n * - Default: process.cwd()\n * - Example: '\n *\n * Will be used to resolve all intlayer directories\n *\n * Note:\n * - The base directory should be the root of the project\n * - Can be changed to a custom directory to externalize either the content used in the project, or the intlayer application from the project\n */\n baseDir: customConfiguration?.baseDir ?? baseDir ?? process.cwd(),\n\n /**\n * Should exclude some directories from the content search\n *\n * Default: ['node_modules']\n *\n * Not used yet\n * @TODO Implement the exclusion or remove it\n */\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n\n /**\n * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.\n *\n * Default: process.env.NODE_ENV === 'development'\n */\n watch: customConfiguration?.watch ?? WATCH,\n\n /**\n * Indicate how the content should be automatically filled using AI.\n *\n * Default: undefined\n */\n autoFill: customConfiguration?.autoFill ?? undefined,\n };\n\n const baseDirDerivedConfiguration: BaseDerivedConfig = {\n /**\n * Directory where the content is stored\n *\n * Relative to the base directory of the project\n *\n * Default: ./src\n *\n * Example: 'src'\n *\n * Note:\n * - Can be changed to a custom directory to externalize the content used in the project\n * - If the content is not at the base directory level, update the contentDirName field instead\n */\n contentDir: (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n (contentDir) => join(notDerivedContentConfig.baseDir, contentDir)\n ),\n\n /**\n * Directory where the result will be stored\n *\n * Relative to the base directory of the project\n *\n * Default: .intlayer/dictionary\n *\n * Example: '.intlayer'\n *\n * Note:\n * - Can be changed to a custom directory to externalize the intlayer application from the project\n * - If the result is not at the base directory level, update the dictionariesDirName field instead\n */\n dictionariesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the module augmentation will be stored\n *\n * Module augmentation allow better IDE suggestions and type checking\n *\n * Relative to the base directory of the project\n *\n * Default: .intlayer/types\n *\n * Example: 'types'\n *\n * Note:\n * - If this path changed, be sure to include it from the tsconfig.json file\n * - If the module augmentation is not at the base directory level, update the moduleAugmentationDirName field instead\n *\n */\n moduleAugmentationDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n };\n\n const dictionariesDirDerivedConfiguration: ResultDirDerivedConfig = {\n /**\n * Directory where the unmerged dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: '.intlayer/unmerged_dictionary'\n *\n */\n unmergedDictionariesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the remote dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: '.intlayer/remote_dictionary'\n */\n remoteDictionariesDir: join(\n notDerivedContentConfig.baseDir,\n customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the final dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Example: '.intlayer/dictionary'\n *\n * Note:\n * - If the types are not at the result directory level, update the dictionariesDirName field instead\n * - The dictionaries are stored in JSON format\n * - The dictionaries are used to translate the content\n * - The dictionaries are built from the content files\n */\n dictionariesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the dynamic dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/dynamic_dictionary\n */\n dynamicDictionariesDir: join(\n notDerivedContentConfig.baseDir,\n customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the fetch dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/fetch_dictionary\n */\n fetchDictionariesDir: join(\n notDerivedContentConfig.baseDir,\n customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR\n ),\n\n /**\n * Directory where the dictionaries types will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Example: 'types'\n *\n * Note:\n * - If the types are not at the result directory level, update the typesDirName field instead\n */\n typesDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.typesDir ?? TYPES_DIR\n ),\n\n /**\n * Directory where the main files will be stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Example: '.intlayer/main'\n *\n * Note:\n *\n * - If the main files are not at the result directory level, update the mainDirName field instead\n */\n mainDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.mainDir ?? MAIN_DIR\n ),\n\n /**\n * Directory where the configuration files are stored\n *\n * Relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Example: '.intlayer/config'\n *\n * Note:\n *\n * - If the configuration files are not at the result directory level, update the configDirName field instead\n */\n configDir: join(\n notDerivedContentConfig.baseDir,\n\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n };\n\n const patternsConfiguration: PatternsContentConfig = {\n /**\n * Pattern of files to watch\n *\n * Default: ['/**\\/*.content.ts', '/**\\/*.content.js', '/**\\/*.content.json', '/**\\/*.content.cjs', '/**\\/*.content.mjs', '/**\\/*.content.tsx', '/**\\/*.content.jsx']\n */\n watchedFilesPattern: notDerivedContentConfig.fileExtensions.map(\n (ext) => `/**/*${ext}`\n ),\n\n /**\n * Pattern of files to watch including the relative path\n *\n * Default: ['src/**\\/*.content.ts', 'src/**\\/*.content.js', 'src/**\\/*.content.json', 'src/**\\/*.content.cjs', 'src/**\\/*.content.mjs', 'src/**\\/*.content.tsx', 'src/**\\/*.content.jsx']\n */\n watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.flatMap(\n (ext) =>\n baseDirDerivedConfiguration.contentDir.map(\n (contentDir) => `${normalizePath(contentDir)}/**/*${ext}`\n )\n ),\n\n /**\n * Pattern of dictionary to interpret\n *\n * Default: '.intlayer/dictionary/**\\/*.json'\n */\n outputFilesPatternWithPath: `${normalizePath(\n dictionariesDirDerivedConfiguration.dictionariesDir\n )}/**/*.json`,\n };\n\n return {\n ...notDerivedContentConfig,\n ...baseDirDerivedConfiguration,\n ...dictionariesDirDerivedConfiguration,\n ...patternsConfiguration,\n };\n};\n\nconst buildEditorFields = (\n customConfiguration?: Partial<EditorConfig>\n): EditorConfig => ({\n /**\n * URL of the application. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n applicationURL: customConfiguration?.applicationURL ?? APPLICATION_URL,\n\n /**\n * URL of the editor server. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n editorURL: customConfiguration?.editorURL ?? EDITOR_URL,\n\n /**\n * URL of the CMS server. Used to restrict the origin of the editor for security reasons.\n */\n cmsURL: customConfiguration?.cmsURL ?? CMS_URL,\n\n /**\n * URL of the editor server\n *\n * Default: 'https://back.intlayer.org'\n */\n backendURL: customConfiguration?.backendURL ?? BACKEND_URL,\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: customConfiguration?.port ?? PORT,\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: true;\n *\n * If true, the editor will be able to interact with the application.\n * If false, the editor will not be able to interact with the application.\n * In any case, the editor can only be enabled by the visual editor.\n * Disabling the editor for specific environments is a way to enforce the security.\n *\n * Usage:\n * ```js\n * {\n * // Other configurations\n * editor: {\n * enabled: process.env.NODE_ENV !== 'production',\n * }\n * };\n * ```\n */\n enabled: customConfiguration?.enabled ?? IS_ENABLED,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://intlayer.org/dashboard/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientId: customConfiguration?.clientId ?? undefined,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://intlayer.org/dashboard/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientSecret: customConfiguration?.clientSecret ?? undefined,\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy:\n customConfiguration?.dictionaryPriorityStrategy ??\n DICTIONARY_PRIORITY_STRATEGY,\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * The hot reload is only available for clients of the `enterprise` plan.\n *\n * Default: false\n */\n liveSync: customConfiguration?.liveSync ?? LIVE_SYNC,\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT,\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${LIVE_SYNC_PORT}`\n */\n liveSyncURL:\n customConfiguration?.liveSyncURL ??\n `http://localhost:${customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT}`,\n});\n\nconst buildLogFields = (\n customConfiguration?: Partial<LogConfig>,\n logFunctions?: LogFunctions\n): LogConfig => ({\n /**\n * Indicates if the logger is enabled\n *\n * Default: 'default'\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: customConfiguration?.mode ?? MODE,\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: customConfiguration?.prefix ?? PREFIX,\n\n /**\n * Functions to log\n */\n error: logFunctions?.error,\n log: logFunctions?.log,\n info: logFunctions?.info,\n warn: logFunctions?.warn,\n});\n\nconst buildAiFields = (customConfiguration?: Partial<AiConfig>): AiConfig => ({\n /**\n * AI configuration\n */\n provider: customConfiguration?.provider,\n\n /**\n * API key\n */\n apiKey: customConfiguration?.apiKey,\n\n /**\n * API model\n */\n model: customConfiguration?.model,\n\n /**\n * Temperature\n */\n temperature: customConfiguration?.temperature,\n\n /**\n * Application context\n */\n applicationContext: customConfiguration?.applicationContext,\n});\n\nconst buildBuildFields = (\n customConfiguration?: Partial<BuildConfig>\n): BuildConfig => ({\n /**\n * Indicates if the build should be optimized\n *\n * Default: process.env.NODE_ENV === 'production'\n *\n * If true, the build will be optimized.\n * If false, the build will not be optimized.\n *\n * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.\n * All imports will stay as static import to avoid async processing when loading the dictionaries.\n *\n * Note:\n * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.\n * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - In most cases, \"dynamic\" will be used for React applications, \"async\" for Vue.js applications.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize: customConfiguration?.optimize ?? OPTIMIZE,\n\n /**\n * Indicates the mode of import to use for the dictionaries.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Live mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as \"dynamic\" mode.\n *\n * Default: \"static\"\n *\n * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.\n *\n * Note:\n * - Dynamic imports rely on Suspense and may slightly impact rendering performance.\n * - If desabled all locales will be loaded at once, even if they are not used.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n * - This option will be ignored if `optimize` is disabled.\n * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.\n * - The \"live\" allows to sync the dictionaries to the live sync server.\n */\n importMode: customConfiguration?.importMode ?? IMPORT_MODE,\n\n /**\n * Pattern to traverse the code to optimize.\n *\n * Allows to avoid to traverse the code that is not relevant to the optimization.\n * Improve build performance.\n *\n * Default: ['**\\/*.{js,ts,mjs,cjs,jsx,tsx,mjx,cjx}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: customConfiguration?.traversePattern ?? TRAVERSE_PATTERN,\n\n /**\n * Output format of the dictionaries\n *\n * Can be set on large projects to improve build performance.\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'.\n * - 'cjs': The dictionaries are outputted as CommonJS modules.\n * - 'esm': The dictionaries are outputted as ES modules.\n */\n outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT,\n});\n\n/**\n * Build the configuration fields by merging the default values with the custom configuration\n */\nexport const buildConfigurationFields = (\n customConfiguration?: CustomIntlayerConfig,\n baseDir?: string,\n logFunctions?: LogFunctions\n): IntlayerConfig => {\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const middlewareConfig = buildMiddlewareFields(\n customConfiguration?.middleware\n );\n\n const contentConfig = buildContentFields(\n customConfiguration?.content,\n baseDir\n );\n\n const editorConfig = buildEditorFields(customConfiguration?.editor);\n\n const logConfig = buildLogFields(customConfiguration?.log, logFunctions);\n\n const aiConfig = buildAiFields(customConfiguration?.ai);\n\n const buildConfig = buildBuildFields(customConfiguration?.build);\n\n storedConfiguration = {\n internationalization: internationalizationConfig,\n middleware: middlewareConfig,\n content: contentConfig,\n editor: editorConfig,\n log: logConfig,\n ai: aiConfig,\n build: buildConfig,\n };\n\n return storedConfiguration;\n};\n"],"mappings":"AAAA,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,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A;AAAA,EAgB/C,iBAAiB,qBAAqB,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAazD,cAAc,qBAAqB,gBAAgB;AACrD;AAKO,MAAM,2BAA2B,CACtC,qBACA,SACA,iBACmB;AACnB,QAAM,6BAA6B;AAAA,IACjC,qBAAqB;AAAA,EACvB;AAEA,QAAM,mBAAmB;AAAA,IACvB,qBAAqB;AAAA,EACvB;AAEA,QAAM,gBAAgB;AAAA,IACpB,qBAAqB;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,eAAe,kBAAkB,qBAAqB,MAAM;AAElE,QAAM,YAAY,eAAe,qBAAqB,KAAK,YAAY;AAEvE,QAAM,WAAW,cAAc,qBAAqB,EAAE;AAEtD,QAAM,cAAc,iBAAiB,qBAAqB,KAAK;AAE/D,wBAAsB;AAAA,IACpB,sBAAsB;AAAA,IACtB,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,KAAK;AAAA,IACL,IAAI;AAAA,IACJ,OAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -13,19 +13,29 @@ const getConfiguration = (options) => {
13
13
  baseDir: BASE_DIR_PATH,
14
14
  ...options
15
15
  };
16
- const { baseDir, env, envFile } = mergedOptions;
16
+ const {
17
+ baseDir,
18
+ env,
19
+ envFile,
20
+ logFunctions,
21
+ additionalEnvVars,
22
+ projectRequire
23
+ } = mergedOptions;
17
24
  if (!storedConfiguration || typeof options !== "undefined") {
18
25
  const { configurationFilePath, numCustomConfiguration } = searchConfigurationFile(baseDir);
19
26
  let customConfiguration;
20
27
  if (configurationFilePath) {
21
- customConfiguration = loadConfigurationFile(configurationFilePath, {
22
- env,
23
- envFile
24
- });
28
+ customConfiguration = loadConfigurationFile(
29
+ configurationFilePath,
30
+ { env, envFile },
31
+ projectRequire,
32
+ additionalEnvVars
33
+ );
25
34
  }
26
35
  storedConfiguration = buildConfigurationFields(
27
36
  customConfiguration,
28
- baseDir
37
+ baseDir,
38
+ logFunctions
29
39
  );
30
40
  storedConfigurationFilePath = configurationFilePath;
31
41
  storedNumCustomConfiguration = numCustomConfiguration;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import merge from 'deepmerge';\nimport { relative } from 'path';\nimport { logger } from '../logger';\nimport type { CustomIntlayerConfig, IntlayerConfig } from '../types/config';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nlet storedConfiguration: IntlayerConfig | undefined;\nlet storedConfigurationFilePath: string | undefined;\nlet storedNumCustomConfiguration: number | undefined;\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n env?: string;\n envFile?: string;\n};\n\nconst BASE_DIR_PATH = process.cwd();\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 => {\n const mergedOptions = {\n baseDir: BASE_DIR_PATH,\n ...options,\n };\n\n const { baseDir, env, envFile } = mergedOptions;\n\n if (!storedConfiguration || typeof options !== 'undefined') {\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n // Load the custom configuration\n let customConfiguration: CustomIntlayerConfig | undefined;\n\n if (configurationFilePath) {\n customConfiguration = loadConfigurationFile(configurationFilePath, {\n env,\n envFile,\n });\n }\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n customConfiguration,\n baseDir\n );\n\n storedConfigurationFilePath = configurationFilePath;\n storedNumCustomConfiguration = numCustomConfiguration;\n }\n\n // Log warning if multiple configuration files are found\n if (options?.override?.log?.mode === 'verbose') {\n logConfigFileResult(\n storedNumCustomConfiguration,\n storedConfigurationFilePath\n );\n }\n\n return merge(storedConfiguration, options?.override ?? {}) as IntlayerConfig;\n};\n\nconst logConfigFileResult = (\n numCustomConfiguration?: number,\n configurationFilePath?: string\n) => {\n if (numCustomConfiguration === 0) {\n logger('Configuration file not found, using default configuration.', {\n isVerbose: true,\n });\n } else {\n const relativeOutputPath = relative(BASE_DIR_PATH, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n logger(`Configuration file found: ${relativeOutputPath}.`, {\n isVerbose: true,\n });\n } else {\n logger(\n `Multiple configuration files found, using ${relativeOutputPath}.`,\n {\n isVerbose: true,\n }\n );\n }\n }\n};\n"],"mappings":"AAAA,OAAO,WAAW;AAClB,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAEvB,SAAS,gCAAgC;AACzC,SAAS,6BAA6B;AACtC,SAAS,+BAA+B;AAExC,IAAI;AACJ,IAAI;AACJ,IAAI;AASJ,MAAM,gBAAgB,QAAQ,IAAI;AAK3B,MAAM,mBAAmB,CAC9B,YACmB;AACnB,QAAM,gBAAgB;AAAA,IACpB,SAAS;AAAA,IACT,GAAG;AAAA,EACL;AAEA,QAAM,EAAE,SAAS,KAAK,QAAQ,IAAI;AAElC,MAAI,CAAC,uBAAuB,OAAO,YAAY,aAAa;AAE1D,UAAM,EAAE,uBAAuB,uBAAuB,IACpD,wBAAwB,OAAO;AAGjC,QAAI;AAEJ,QAAI,uBAAuB;AACzB,4BAAsB,sBAAsB,uBAAuB;AAAA,QACjE;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAGA,0BAAsB;AAAA,MACpB;AAAA,MACA;AAAA,IACF;AAEA,kCAA8B;AAC9B,mCAA+B;AAAA,EACjC;AAGA,MAAI,SAAS,UAAU,KAAK,SAAS,WAAW;AAC9C;AAAA,MACE;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,MAAM,qBAAqB,SAAS,YAAY,CAAC,CAAC;AAC3D;AAEA,MAAM,sBAAsB,CAC1B,wBACA,0BACG;AACH,MAAI,2BAA2B,GAAG;AAChC,WAAO,8DAA8D;AAAA,MACnE,WAAW;AAAA,IACb,CAAC;AAAA,EACH,OAAO;AACL,UAAM,qBAAqB,SAAS,eAAe,qBAAsB;AAEzE,QAAI,2BAA2B,GAAG;AAChC,aAAO,6BAA6B,kBAAkB,KAAK;AAAA,QACzD,WAAW;AAAA,MACb,CAAC;AAAA,IACH,OAAO;AACL;AAAA,QACE,6CAA6C,kBAAkB;AAAA,QAC/D;AAAA,UACE,WAAW;AAAA,QACb;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import merge from 'deepmerge';\nimport { relative } from 'path';\nimport { logger } from '../logger';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '../types/config';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nlet storedConfiguration: IntlayerConfig | undefined;\nlet storedConfigurationFilePath: string | undefined;\nlet storedNumCustomConfiguration: number | undefined;\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n env?: string;\n envFile?: string;\n logFunctions?: LogFunctions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n};\n\nconst BASE_DIR_PATH = process.cwd();\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 => {\n const mergedOptions = {\n baseDir: BASE_DIR_PATH,\n ...options,\n };\n\n const {\n baseDir,\n env,\n envFile,\n logFunctions,\n additionalEnvVars,\n projectRequire,\n } = mergedOptions;\n\n if (!storedConfiguration || typeof options !== 'undefined') {\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n // Load the custom configuration\n let customConfiguration: CustomIntlayerConfig | undefined;\n\n if (configurationFilePath) {\n customConfiguration = loadConfigurationFile(\n configurationFilePath,\n { env, envFile },\n projectRequire,\n additionalEnvVars\n );\n }\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n customConfiguration,\n baseDir,\n logFunctions\n );\n\n storedConfigurationFilePath = configurationFilePath;\n storedNumCustomConfiguration = numCustomConfiguration;\n }\n\n // Log warning if multiple configuration files are found\n if (options?.override?.log?.mode === 'verbose') {\n logConfigFileResult(\n storedNumCustomConfiguration,\n storedConfigurationFilePath\n );\n }\n\n return merge(storedConfiguration, options?.override ?? {}) as IntlayerConfig;\n};\n\nconst logConfigFileResult = (\n numCustomConfiguration?: number,\n configurationFilePath?: string\n) => {\n if (numCustomConfiguration === 0) {\n logger('Configuration file not found, using default configuration.', {\n isVerbose: true,\n });\n } else {\n const relativeOutputPath = relative(BASE_DIR_PATH, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n logger(`Configuration file found: ${relativeOutputPath}.`, {\n isVerbose: true,\n });\n } else {\n logger(\n `Multiple configuration files found, using ${relativeOutputPath}.`,\n {\n isVerbose: true,\n }\n );\n }\n }\n};\n"],"mappings":"AAAA,OAAO,WAAW;AAClB,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAMvB,SAAS,gCAAgC;AACzC,SAAS,6BAA6B;AACtC,SAAS,+BAA+B;AAExC,IAAI;AACJ,IAAI;AACJ,IAAI;AAYJ,MAAM,gBAAgB,QAAQ,IAAI;AAK3B,MAAM,mBAAmB,CAC9B,YACmB;AACnB,QAAM,gBAAgB;AAAA,IACpB,SAAS;AAAA,IACT,GAAG;AAAA,EACL;AAEA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,MAAI,CAAC,uBAAuB,OAAO,YAAY,aAAa;AAE1D,UAAM,EAAE,uBAAuB,uBAAuB,IACpD,wBAAwB,OAAO;AAGjC,QAAI;AAEJ,QAAI,uBAAuB;AACzB,4BAAsB;AAAA,QACpB;AAAA,QACA,EAAE,KAAK,QAAQ;AAAA,QACf;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAGA,0BAAsB;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,kCAA8B;AAC9B,mCAA+B;AAAA,EACjC;AAGA,MAAI,SAAS,UAAU,KAAK,SAAS,WAAW;AAC9C;AAAA,MACE;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,MAAM,qBAAqB,SAAS,YAAY,CAAC,CAAC;AAC3D;AAEA,MAAM,sBAAsB,CAC1B,wBACA,0BACG;AACH,MAAI,2BAA2B,GAAG;AAChC,WAAO,8DAA8D;AAAA,MACnE,WAAW;AAAA,IACb,CAAC;AAAA,EACH,OAAO;AACL,UAAM,qBAAqB,SAAS,eAAe,qBAAsB;AAEzE,QAAI,2BAA2B,GAAG;AAChC,aAAO,6BAA6B,kBAAkB,KAAK;AAAA,QACzD,WAAW;AAAA,MACb,CAAC;AAAA,IACH,OAAO;AACL;AAAA,QACE,6CAA6C,kBAAkB;AAAA,QAC/D;AAAA,UACE,WAAW;AAAA,QACb;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -3,9 +3,14 @@ import { logger } from "../logger.mjs";
3
3
  const filterValidConfiguration = (configuration) => {
4
4
  return configuration;
5
5
  };
6
- const loadConfigurationFile = (configFilePath, envVarOptions) => {
6
+ const loadConfigurationFile = (configFilePath, envVarOptions, projectRequire, additionalEnvVars) => {
7
7
  try {
8
- const fileContent = loadExternalFile(configFilePath, envVarOptions);
8
+ const fileContent = loadExternalFile(
9
+ configFilePath,
10
+ envVarOptions,
11
+ projectRequire,
12
+ additionalEnvVars
13
+ );
9
14
  return filterValidConfiguration(fileContent);
10
15
  } catch (error) {
11
16
  logger(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import { type LoadEnvFileOptions } from '../loadEnvFile';\nimport { loadExternalFile } from '../loadExternalFile';\nimport { logger } from '../logger';\nimport type { CustomIntlayerConfig } from '../types/config';\n\nconst filterValidConfiguration = (\n configuration: CustomIntlayerConfig\n): CustomIntlayerConfig => {\n // @TODO Implement filtering of valid configuration\n return configuration;\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 envVarOptions?: LoadEnvFileOptions\n): CustomIntlayerConfig | undefined => {\n try {\n const fileContent = loadExternalFile(configFilePath, envVarOptions);\n\n return filterValidConfiguration(fileContent);\n } catch (error) {\n logger(\n `Error: ${error} ${JSON.stringify((error as Error).stack, null, 2)}`,\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":"AACA,SAAS,wBAAwB;AACjC,SAAS,cAAc;AAGvB,MAAM,2BAA2B,CAC/B,kBACyB;AAEzB,SAAO;AACT;AAQO,MAAM,wBAAwB,CACnC,gBACA,kBACqC;AACrC,MAAI;AACF,UAAM,cAAc,iBAAiB,gBAAgB,aAAa;AAElE,WAAO,yBAAyB,WAAW;AAAA,EAC7C,SAAS,OAAO;AACd;AAAA,MACE,UAAU,KAAK,IAAI,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["import { type LoadEnvFileOptions } from '../loadEnvFile';\nimport { loadExternalFile } from '../loadExternalFile';\nimport { logger } from '../logger';\nimport type { CustomIntlayerConfig } from '../types/config';\n\nconst filterValidConfiguration = (\n configuration: CustomIntlayerConfig\n): CustomIntlayerConfig => {\n // @TODO Implement filtering of valid configuration\n return configuration;\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 envVarOptions?: LoadEnvFileOptions,\n projectRequire?: NodeJS.Require,\n additionalEnvVars?: Record<string, string>\n): CustomIntlayerConfig | undefined => {\n try {\n const fileContent = loadExternalFile(\n configFilePath,\n envVarOptions,\n projectRequire,\n additionalEnvVars\n );\n\n return filterValidConfiguration(fileContent);\n } catch (error) {\n logger(\n `Error: ${error} ${JSON.stringify((error as Error).stack, null, 2)}`,\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":"AACA,SAAS,wBAAwB;AACjC,SAAS,cAAc;AAGvB,MAAM,2BAA2B,CAC/B,kBACyB;AAEzB,SAAO;AACT;AAQO,MAAM,wBAAwB,CACnC,gBACA,eACA,gBACA,sBACqC;AACrC,MAAI;AACF,UAAM,cAAc;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,WAAO,yBAAyB,WAAW;AAAA,EAC7C,SAAS,OAAO;AACd;AAAA,MACE,UAAU,KAAK,IAAI,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import { loadEnvFile } from "./loadEnvFile.mjs";
2
2
  import { ESMxCJSRequire } from "./utils/ESMxCJSHelpers.mjs";
3
- const getSandBoxContext = (envVarOptions, projectRequire = ESMxCJSRequire) => {
3
+ const getSandBoxContext = (envVarOptions, projectRequire = ESMxCJSRequire, additionalEnvVars) => {
4
4
  let additionalGlobalVar = {};
5
5
  try {
6
6
  additionalGlobalVar = {
@@ -19,7 +19,8 @@ const getSandBoxContext = (envVarOptions, projectRequire = ESMxCJSRequire) => {
19
19
  ...process,
20
20
  env: {
21
21
  ...process.env,
22
- ...loadEnvFile(envVarOptions)
22
+ ...loadEnvFile(envVarOptions),
23
+ ...additionalEnvVars
23
24
  }
24
25
  },
25
26
  console,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/getSandboxContext.ts"],"sourcesContent":["import type { Context } from 'vm';\nimport { type LoadEnvFileOptions, loadEnvFile } from './loadEnvFile';\nimport { ESMxCJSRequire } from './utils/ESMxCJSHelpers';\n\nexport const getSandBoxContext = (\n envVarOptions?: LoadEnvFileOptions,\n projectRequire = ESMxCJSRequire\n): Context => {\n let additionalGlobalVar = {};\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: projectRequire('react'),\n };\n } catch (err) {\n // React is not installed, so we don't inject it\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 },\n },\n console,\n require: projectRequire,\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"],"mappings":"AACA,SAAkC,mBAAmB;AACrD,SAAS,sBAAsB;AAExB,MAAM,oBAAoB,CAC/B,eACA,iBAAiB,mBACL;AACZ,MAAI,sBAAsB,CAAC;AAE3B,MAAI;AAEF,0BAAsB;AAAA,MACpB,OAAO,eAAe,OAAO;AAAA,IAC/B;AAAA,EACF,SAAS,KAAK;AAAA,EAEd;AAEA,QAAM,iBAA0B;AAAA,IAC9B,SAAS;AAAA,MACP,SAAS,CAAC;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,SAAS,CAAC;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,MACP,GAAG;AAAA,MACH,KAAK;AAAA,QACH,GAAG,QAAQ;AAAA,QACX,GAAG,YAAY,aAAa;AAAA,MAC9B;AAAA,IACF;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,GAAG;AAAA,EACL;AAGA,SAAO,oBAAoB,UAAU,EAAE,QAAQ,CAAC,QAAQ;AACtD,QAAI,EAAE,OAAO,iBAAiB;AAC5B,qBAAe,GAAG,IAAI,WAAW,GAA8B;AAAA,IACjE;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/getSandboxContext.ts"],"sourcesContent":["import type { Context } from 'vm';\nimport { type LoadEnvFileOptions, loadEnvFile } from './loadEnvFile';\nimport { ESMxCJSRequire } from './utils/ESMxCJSHelpers';\n\nexport const getSandBoxContext = (\n envVarOptions?: LoadEnvFileOptions,\n projectRequire = ESMxCJSRequire,\n additionalEnvVars?: Record<string, string>\n): Context => {\n let additionalGlobalVar = {};\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: projectRequire('react'),\n };\n } catch (err) {\n // React is not installed, so we don't inject it\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: projectRequire,\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"],"mappings":"AACA,SAAkC,mBAAmB;AACrD,SAAS,sBAAsB;AAExB,MAAM,oBAAoB,CAC/B,eACA,iBAAiB,gBACjB,sBACY;AACZ,MAAI,sBAAsB,CAAC;AAE3B,MAAI;AAEF,0BAAsB;AAAA,MACpB,OAAO,eAAe,OAAO;AAAA,IAC/B;AAAA,EACF,SAAS,KAAK;AAAA,EAEd;AAEA,QAAM,iBAA0B;AAAA,IAC9B,SAAS;AAAA,MACP,SAAS,CAAC;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,SAAS,CAAC;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,MACP,GAAG;AAAA,MACH,KAAK;AAAA,QACH,GAAG,QAAQ;AAAA,QACX,GAAG,YAAY,aAAa;AAAA,QAC5B,GAAG;AAAA,MACL;AAAA,IACF;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,GAAG;AAAA,EACL;AAGA,SAAO,oBAAoB,UAAU,EAAE,QAAQ,CAAC,QAAQ;AACtD,QAAI,EAAE,OAAO,iBAAiB;AAC5B,qBAAe,GAAG,IAAI,WAAW,GAA8B;AAAA,IACjE;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -16,6 +16,7 @@ import {
16
16
  colorizePath,
17
17
  getAppLogger,
18
18
  logger,
19
+ removeColor,
19
20
  spinnerFrames,
20
21
  v,
21
22
  x
@@ -49,6 +50,7 @@ export {
49
50
  loadExternalFile,
50
51
  logger,
51
52
  normalizePath,
53
+ removeColor,
52
54
  retryManager,
53
55
  spinnerFrames,
54
56
  v,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getAlias } from './alias';\nexport {\n getConfiguration,\n type GetConfigurationOptions,\n} from './configFile/getConfiguration';\nexport { getSandBoxContext } from './getSandboxContext';\nexport { getEnvFilePath, loadEnvFile } from './loadEnvFile';\nexport { loadExternalFile } from './loadExternalFile';\nexport {\n ANSIColors,\n clock,\n colon,\n colorize,\n colorizeKey,\n colorizeLocales,\n colorizeNumber,\n colorizePath,\n getAppLogger,\n logger,\n spinnerFrames,\n v,\n x,\n type Logger,\n} from './logger';\nexport { retryManager } from './retryManager';\nexport type {\n BaseContentConfig,\n BaseDerivedConfig,\n ContentConfig,\n CustomIntlayerConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n MiddlewareConfig,\n PatternsContentConfig,\n ResultDirDerivedConfig,\n ServerSetCookieRule,\n StrictMode,\n} from './types/config';\nexport { Locales } from './types/locales';\nexport type { LocalesValues } from './types/locales';\nexport { clearModuleCache } from './utils/clearModuleCache';\nexport { ESMxCJSRequire, isESModule } from './utils/ESMxCJSHelpers';\nexport { getExtension } from './utils/getExtension';\nexport { normalizePath } from './utils/normalizePath';\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,OAEK;AACP,SAAS,yBAAyB;AAClC,SAAS,gBAAgB,mBAAmB;AAC5C,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,oBAAoB;AAe7B,SAAS,eAAe;AAExB,SAAS,wBAAwB;AACjC,SAAS,gBAAgB,kBAAkB;AAC3C,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getAlias } from './alias';\nexport {\n getConfiguration,\n type GetConfigurationOptions,\n} from './configFile/getConfiguration';\nexport { getSandBoxContext } from './getSandboxContext';\nexport { getEnvFilePath, loadEnvFile } from './loadEnvFile';\nexport { loadExternalFile } from './loadExternalFile';\nexport {\n ANSIColors,\n clock,\n colon,\n colorize,\n colorizeKey,\n colorizeLocales,\n colorizeNumber,\n colorizePath,\n getAppLogger,\n logger,\n removeColor,\n spinnerFrames,\n v,\n x,\n type Logger,\n} from './logger';\nexport { retryManager } from './retryManager';\nexport type {\n BaseContentConfig,\n BaseDerivedConfig,\n ContentConfig,\n CustomIntlayerConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n LogFunctions,\n MiddlewareConfig,\n PatternsContentConfig,\n ResultDirDerivedConfig,\n ServerSetCookieRule,\n StrictMode,\n} from './types/config';\nexport { Locales } from './types/locales';\nexport type { LocalesValues } from './types/locales';\nexport { clearModuleCache } from './utils/clearModuleCache';\nexport { ESMxCJSRequire, isESModule } from './utils/ESMxCJSHelpers';\nexport { getExtension } from './utils/getExtension';\nexport { normalizePath } from './utils/normalizePath';\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,OAEK;AACP,SAAS,yBAAyB;AAClC,SAAS,gBAAgB,mBAAmB;AAC5C,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,oBAAoB;AAgB7B,SAAS,eAAe;AAExB,SAAS,wBAAwB;AACjC,SAAS,gBAAgB,kBAAkB;AAC3C,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;","names":[]}
@@ -29,7 +29,7 @@ const getTransformationOptions = (filePath) => ({
29
29
  ].join("\n")
30
30
  }
31
31
  });
32
- const loadExternalFile = (filePath, envVarOptions, projectRequire = ESMxCJSRequire) => {
32
+ const loadExternalFile = (filePath, envVarOptions, projectRequire, additionalEnvVars) => {
33
33
  let fileContent = void 0;
34
34
  const fileExtension = filePath.split(".").pop() ?? "";
35
35
  try {
@@ -46,7 +46,11 @@ const loadExternalFile = (filePath, envVarOptions, projectRequire = ESMxCJSRequi
46
46
  logger("File could not be loaded.", { level: "error" });
47
47
  return void 0;
48
48
  }
49
- const sandboxContext = getSandBoxContext(envVarOptions, projectRequire);
49
+ const sandboxContext = getSandBoxContext(
50
+ envVarOptions,
51
+ projectRequire,
52
+ additionalEnvVars
53
+ );
50
54
  runInNewContext(moduleResultString, sandboxContext);
51
55
  if (sandboxContext.exports.default && Object.keys(sandboxContext.exports.default).length > 0) {
52
56
  fileContent = sandboxContext.exports.default;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/loadExternalFile.ts"],"sourcesContent":["import { buildSync, type BuildOptions, type BuildResult } from 'esbuild';\nimport { dirname } from 'path';\nimport { runInNewContext } from 'vm';\nimport { getSandBoxContext } from './getSandboxContext';\nimport { LoadEnvFileOptions } from './loadEnvFile';\nimport { logger } from './logger';\nimport { ESMxCJSRequire } from './utils/ESMxCJSHelpers';\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', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n banner: {\n js: [\n `globalThis.intlayer_file_path = ${JSON.stringify(filePath)};`,\n `globalThis.intlayer_file_dir = ${JSON.stringify(dirname(filePath))};`,\n ].join('\\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 = (\n filePath: string,\n envVarOptions?: LoadEnvFileOptions,\n projectRequire = ESMxCJSRequire\n): any | undefined => {\n let fileContent: any | undefined = undefined;\n\n const fileExtension = filePath.split('.').pop() ?? '';\n\n try {\n if (fileExtension === 'json') {\n // Remove cache to force reloading\n delete ESMxCJSRequire.cache[ESMxCJSRequire.resolve(filePath)];\n // Assume JSON\n return ESMxCJSRequire(filePath);\n }\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [filePath],\n ...getTransformationOptions(filePath),\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const sandboxContext = getSandBoxContext(envVarOptions, projectRequire);\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n fileContent = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n fileContent = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n fileContent = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n fileContent = sandboxContext.module.exports;\n }\n\n if (typeof fileContent === 'undefined') {\n logger(`File file could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n `Error: ${error} ${JSON.stringify((error as Error).stack, null, 2)}`,\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":"AAAA,SAAS,iBAAsD;AAC/D,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAElC,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAE/B,MAAM,2BAA2B,CAAC,cAAoC;AAAA,EACpE,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,QAAQ;AAAA;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,IACN,IAAI;AAAA,MACF,mCAAmC,KAAK,UAAU,QAAQ,CAAC;AAAA,MAC3D,kCAAkC,KAAK,UAAU,QAAQ,QAAQ,CAAC,CAAC;AAAA,IACrE,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAOO,MAAM,mBAAmB,CAC9B,UACA,eACA,iBAAiB,mBACG;AACpB,MAAI,cAA+B;AAEnC,QAAM,gBAAgB,SAAS,MAAM,GAAG,EAAE,IAAI,KAAK;AAEnD,MAAI;AACF,QAAI,kBAAkB,QAAQ;AAE5B,aAAO,eAAe,MAAM,eAAe,QAAQ,QAAQ,CAAC;AAE5D,aAAO,eAAe,QAAQ;AAAA,IAChC;AAIA,UAAM,eAA4B,UAAU;AAAA,MAC1C,aAAa,CAAC,QAAQ;AAAA,MACtB,GAAG,yBAAyB,QAAQ;AAAA,IACtC,CAAC;AAED,UAAM,qBAAqB,aAAa,cAAc,CAAC,EAAE;AAEzD,QAAI,CAAC,oBAAoB;AACvB,aAAO,6BAA6B,EAAE,OAAO,QAAQ,CAAC;AACtD,aAAO;AAAA,IACT;AAEA,UAAM,iBAAiB,kBAAkB,eAAe,cAAc;AAEtE,oBAAgB,oBAAoB,cAAc;AAElD,QACE,eAAe,QAAQ,WACvB,OAAO,KAAK,eAAe,QAAQ,OAAO,EAAE,SAAS,GACrD;AAEA,oBAAc,eAAe,QAAQ;AAAA,IACvC,WACE,eAAe,OAAO,QAAQ,YAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,QAAQ,EAAE,SAAS,GAC7D;AAEA,oBAAc,eAAe,OAAO,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,QAAQ,WAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,OAAO,EAAE,SAAS,GAC5D;AAEA,oBAAc,eAAe,OAAO,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,WACtB,OAAO,KAAK,eAAe,OAAO,OAAO,EAAE,SAAS,GACpD;AAEA,oBAAc,eAAe,OAAO;AAAA,IACtC;AAEA,QAAI,OAAO,gBAAgB,aAAa;AACtC,aAAO,yCAAyC,QAAQ,EAAE;AAC1D,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd;AAAA,MACE,UAAU,KAAK,IAAI,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/loadExternalFile.ts"],"sourcesContent":["import { buildSync, type BuildOptions, type BuildResult } from 'esbuild';\nimport { dirname } from 'path';\nimport { runInNewContext } from 'vm';\nimport { getSandBoxContext } from './getSandboxContext';\nimport { LoadEnvFileOptions } from './loadEnvFile';\nimport { logger } from './logger';\nimport { ESMxCJSRequire } from './utils/ESMxCJSHelpers';\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', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n banner: {\n js: [\n `globalThis.intlayer_file_path = ${JSON.stringify(filePath)};`,\n `globalThis.intlayer_file_dir = ${JSON.stringify(dirname(filePath))};`,\n ].join('\\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 = (\n filePath: string,\n envVarOptions?: LoadEnvFileOptions,\n projectRequire?: NodeJS.Require,\n additionalEnvVars?: Record<string, string>\n): any | undefined => {\n let fileContent: any | undefined = undefined;\n\n const fileExtension = filePath.split('.').pop() ?? '';\n\n try {\n if (fileExtension === 'json') {\n // Remove cache to force reloading\n delete ESMxCJSRequire.cache[ESMxCJSRequire.resolve(filePath)];\n // Assume JSON\n return ESMxCJSRequire(filePath);\n }\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [filePath],\n ...getTransformationOptions(filePath),\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const sandboxContext = getSandBoxContext(\n envVarOptions,\n projectRequire,\n additionalEnvVars\n );\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n fileContent = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n fileContent = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n fileContent = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n fileContent = sandboxContext.module.exports;\n }\n\n if (typeof fileContent === 'undefined') {\n logger(`File file could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n `Error: ${error} ${JSON.stringify((error as Error).stack, null, 2)}`,\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":"AAAA,SAAS,iBAAsD;AAC/D,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAElC,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAE/B,MAAM,2BAA2B,CAAC,cAAoC;AAAA,EACpE,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,QAAQ;AAAA;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,IACN,IAAI;AAAA,MACF,mCAAmC,KAAK,UAAU,QAAQ,CAAC;AAAA,MAC3D,kCAAkC,KAAK,UAAU,QAAQ,QAAQ,CAAC,CAAC;AAAA,IACrE,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAOO,MAAM,mBAAmB,CAC9B,UACA,eACA,gBACA,sBACoB;AACpB,MAAI,cAA+B;AAEnC,QAAM,gBAAgB,SAAS,MAAM,GAAG,EAAE,IAAI,KAAK;AAEnD,MAAI;AACF,QAAI,kBAAkB,QAAQ;AAE5B,aAAO,eAAe,MAAM,eAAe,QAAQ,QAAQ,CAAC;AAE5D,aAAO,eAAe,QAAQ;AAAA,IAChC;AAIA,UAAM,eAA4B,UAAU;AAAA,MAC1C,aAAa,CAAC,QAAQ;AAAA,MACtB,GAAG,yBAAyB,QAAQ;AAAA,IACtC,CAAC;AAED,UAAM,qBAAqB,aAAa,cAAc,CAAC,EAAE;AAEzD,QAAI,CAAC,oBAAoB;AACvB,aAAO,6BAA6B,EAAE,OAAO,QAAQ,CAAC;AACtD,aAAO;AAAA,IACT;AAEA,UAAM,iBAAiB;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,oBAAgB,oBAAoB,cAAc;AAElD,QACE,eAAe,QAAQ,WACvB,OAAO,KAAK,eAAe,QAAQ,OAAO,EAAE,SAAS,GACrD;AAEA,oBAAc,eAAe,QAAQ;AAAA,IACvC,WACE,eAAe,OAAO,QAAQ,YAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,QAAQ,EAAE,SAAS,GAC7D;AAEA,oBAAc,eAAe,OAAO,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,QAAQ,WAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,OAAO,EAAE,SAAS,GAC5D;AAEA,oBAAc,eAAe,OAAO,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,WACtB,OAAO,KAAK,eAAe,OAAO,OAAO,EAAE,SAAS,GACpD;AAEA,oBAAc,eAAe,OAAO;AAAA,IACtC;AAEA,QAAI,OAAO,gBAAgB,aAAa;AACtC,aAAO,yCAAyC,QAAQ,EAAE;AAC1D,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd;AAAA,MACE,UAAU,KAAK,IAAI,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,26 +1,29 @@
1
- const logger = (content, details = {
2
- isVerbose: false,
3
- level: void 0,
4
- config: { mode: "default", prefix: "" }
5
- }) => {
6
- const mode = details.config?.mode ?? "default";
7
- const prefix = Boolean(details.config?.prefix) ? details.config?.prefix : void 0;
1
+ const logger = (content, details) => {
2
+ const isVerbose = details?.isVerbose ?? false;
3
+ const mode = details?.config?.mode ?? "default";
4
+ const level = details?.level ?? "info";
5
+ const prefix = Boolean(details?.config?.prefix) ? details?.config?.prefix : void 0;
6
+ const log = details?.config?.log ?? console.log;
7
+ const info = details?.config?.info ?? console.info;
8
+ const warn = details?.config?.warn ?? console.warn;
9
+ const error = details?.config?.error ?? console.error;
10
+ const debug = details?.config?.debug ?? console.debug;
8
11
  if (mode === "disabled") return;
9
- if (details.isVerbose && mode !== "verbose") return;
12
+ if (isVerbose && mode !== "verbose") return;
10
13
  const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();
11
- if (details.level === "debug") {
12
- return console.debug(...flatContent);
14
+ if (level === "debug") {
15
+ return debug(...flatContent);
13
16
  }
14
- if (details.level === "info") {
15
- return console.info(...flatContent);
17
+ if (level === "info") {
18
+ return info(...flatContent);
16
19
  }
17
- if (details.level === "warn") {
18
- return console.warn(...flatContent);
20
+ if (level === "warn") {
21
+ return warn(...flatContent);
19
22
  }
20
- if (details.level === "error") {
21
- return console.error(...flatContent);
23
+ if (level === "error") {
24
+ return error(...flatContent);
22
25
  }
23
- console.log(...flatContent);
26
+ log(...flatContent);
24
27
  };
25
28
  var ANSIColors = /* @__PURE__ */ ((ANSIColors2) => {
26
29
  ANSIColors2["RESET"] = "\x1B[0m";
@@ -118,6 +121,7 @@ export {
118
121
  colorizePath,
119
122
  getAppLogger,
120
123
  logger,
124
+ removeColor,
121
125
  spinnerFrames,
122
126
  v,
123
127
  x
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/logger.ts"],"sourcesContent":["import type { CustomIntlayerConfig } from './types/config';\nimport { Locales } from './types/locales';\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nexport const logger: Logger = (\n content,\n details = {\n isVerbose: false,\n level: undefined,\n config: { mode: 'default', prefix: '' },\n }\n) => {\n const mode = details.config?.mode ?? 'default';\n const prefix = Boolean(details.config?.prefix)\n ? details.config?.prefix\n : undefined;\n\n if (mode === 'disabled') return;\n\n if (details.isVerbose && mode !== 'verbose') return;\n\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n\n if (details.level === 'debug') {\n return console.debug(...flatContent);\n }\n\n if (details.level === 'info') {\n return console.info(...flatContent);\n }\n\n if (details.level === 'warn') {\n return console.warn(...flatContent);\n }\n\n if (details.level === 'error') {\n return console.error(...flatContent);\n }\n\n console.log(...flatContent);\n};\n\nexport enum ANSIColors {\n RESET = '\\x1b[0m',\n GREY = '\\x1b[90m',\n GREY_DARK = '\\x1b[38;5;239m',\n BLUE = '\\x1b[34m',\n RED = '\\x1b[31m',\n GREEN = '\\x1b[32m',\n YELLOW = '\\x1b[33m',\n MAGENTA = '\\x1b[35m',\n BEIGE = '\\x1b[38;5;3m',\n CYAN = '\\x1b[36m',\n WHITE = '\\x1b[37m',\n}\n\nexport const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n/**\n * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.\n * It allows overriding the default configuration by passing a config object in the details parameter.\n * The configuration is merged with the default configuration from the intlayer config file.\n */\nexport const getAppLogger =\n (configuration?: CustomIntlayerConfig, globalDetails?: Details) =>\n (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: {\n ...configuration?.log,\n ...globalDetails?.config,\n ...(details?.config ?? {}),\n },\n });\n\nexport const colorize = (\n s: string,\n color?: ANSIColors,\n reset?: boolean | ANSIColors\n): string =>\n color\n ? `${color}${s}${reset ? (typeof reset === 'boolean' ? ANSIColors.RESET : reset) : ANSIColors.RESET}`\n : s;\n\nexport const colorizeLocales = (\n locales: Locales | Locales[],\n color = ANSIColors.GREEN,\n reset: boolean | ANSIColors = ANSIColors.RESET\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color, reset))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color = ANSIColors.BEIGE,\n reset: boolean | ANSIColors = ANSIColors.RESET\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color, reset))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color = ANSIColors.GREY,\n reset: boolean | ANSIColors = ANSIColors.RESET\n) =>\n [path]\n .flat()\n .map((p) => colorize(p, color, reset))\n .join(`, `);\n\n/**\n * Colorize numeric value using Intl.NumberFormat and optional ANSI colors.\n *\n * Examples:\n * colorizeNumber(2, [{ pluralRule: 'one' , color: ANSIColors.GREEN}, { pluralRule: 'other' , color: ANSIColors.RED}]) // \"'\\x1b[31m2\\x1b[0m\"\n */\nexport const colorizeNumber = (\n number: number,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColors>> = {\n zero: ANSIColors.BLUE,\n one: ANSIColors.BLUE,\n two: ANSIColors.BLUE,\n few: ANSIColors.BLUE,\n many: ANSIColors.BLUE,\n other: ANSIColors.BLUE,\n }\n): string => {\n if (number === 0) {\n const color = options.zero ?? ANSIColors.GREEN;\n return colorize(number.toString(), color);\n }\n\n const rule = new Intl.PluralRules('en').select(number);\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nconst removeColor = (text: string) => text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (Array.isArray(length) && length.every((l) => typeof l === 'string')) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (Array.isArray(length) && length.every((l) => typeof l === 'number')) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad, padChar } = {\n ...defaultColonOptions,\n ...(options ?? {}),\n };\n\n const length = getLength(colSize);\n const spacesLength = Math.max(\n minSize!,\n Math.min(maxSize!, length - removeColor(text).length)\n );\n\n if (pad === 'left') {\n return `${' '.repeat(spacesLength)}${text}`;\n }\n\n return `${text}${' '.repeat(spacesLength)}`;\n })\n .join('');\n\nexport const x = colorize('✗', ANSIColors.RED);\nexport const v = colorize('✓', ANSIColors.GREEN);\nexport const clock = colorize('⏲', ANSIColors.BLUE);\n"],"mappings":"AAWO,MAAM,SAAiB,CAC5B,SACA,UAAU;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ,EAAE,MAAM,WAAW,QAAQ,GAAG;AACxC,MACG;AACH,QAAM,OAAO,QAAQ,QAAQ,QAAQ;AACrC,QAAM,SAAS,QAAQ,QAAQ,QAAQ,MAAM,IACzC,QAAQ,QAAQ,SAChB;AAEJ,MAAI,SAAS,WAAY;AAEzB,MAAI,QAAQ,aAAa,SAAS,UAAW;AAE7C,QAAM,cAAc,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK;AAE5E,MAAI,QAAQ,UAAU,SAAS;AAC7B,WAAO,QAAQ,MAAM,GAAG,WAAW;AAAA,EACrC;AAEA,MAAI,QAAQ,UAAU,QAAQ;AAC5B,WAAO,QAAQ,KAAK,GAAG,WAAW;AAAA,EACpC;AAEA,MAAI,QAAQ,UAAU,QAAQ;AAC5B,WAAO,QAAQ,KAAK,GAAG,WAAW;AAAA,EACpC;AAEA,MAAI,QAAQ,UAAU,SAAS;AAC7B,WAAO,QAAQ,MAAM,GAAG,WAAW;AAAA,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AM,EAAE,SAAS,SAAS,SAAS,KAAK,QAAQ,IAAI;AAAA,IAClD,GAAG;AAAA,IACH,GAAI,WAAW,CAAC;AAAA,EAClB;AAEA,QAAM,SAAS,UAAU,OAAO;AAChC,QAAM,eAAe,KAAK;AAAA,IACxB;AAAA,IACA,KAAK,IAAI,SAAU,SAAS,YAAYA,KAAI,EAAE,MAAM;AAAA,EACtD;AAEA,MAAI,QAAQ,QAAQ;AAClB,WAAO,GAAG,IAAI,OAAO,YAAY,CAAC,GAAGA,KAAI;AAAA,EAC3C;AAEA,SAAO,GAAGA,KAAI,GAAG,IAAI,OAAO,YAAY,CAAC;AAC3C,CAAC,EACA,KAAK,EAAE;AAEL,MAAM,IAAI,SAAS,UAAK,oBAAc;AACtC,MAAM,IAAI,SAAS,UAAK,sBAAgB;AACxC,MAAM,QAAQ,SAAS,UAAK,qBAAe;","names":["ANSIColors","color","text"]}
1
+ {"version":3,"sources":["../../src/logger.ts"],"sourcesContent":["import type { CustomIntlayerConfig } from './types/config';\nimport { Locales } from './types/locales';\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nexport const logger: Logger = (content, details) => {\n const isVerbose = details?.isVerbose ?? false;\n const mode = details?.config?.mode ?? 'default';\n const level = details?.level ?? 'info';\n const prefix = Boolean(details?.config?.prefix)\n ? details?.config?.prefix\n : undefined;\n const log = details?.config?.log ?? console.log;\n const info = details?.config?.info ?? console.info;\n const warn = details?.config?.warn ?? console.warn;\n const error = details?.config?.error ?? console.error;\n const debug = details?.config?.debug ?? console.debug;\n\n if (mode === 'disabled') return;\n\n if (isVerbose && mode !== 'verbose') return;\n\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n\n if (level === 'debug') {\n return debug(...flatContent);\n }\n\n if (level === 'info') {\n return info(...flatContent);\n }\n\n if (level === 'warn') {\n return warn(...flatContent);\n }\n\n if (level === 'error') {\n return error(...flatContent);\n }\n\n log(...flatContent);\n};\n\nexport enum ANSIColors {\n RESET = '\\x1b[0m',\n GREY = '\\x1b[90m',\n GREY_DARK = '\\x1b[38;5;239m',\n BLUE = '\\x1b[34m',\n RED = '\\x1b[31m',\n GREEN = '\\x1b[32m',\n YELLOW = '\\x1b[33m',\n MAGENTA = '\\x1b[35m',\n BEIGE = '\\x1b[38;5;3m',\n CYAN = '\\x1b[36m',\n WHITE = '\\x1b[37m',\n}\n\nexport const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n/**\n * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.\n * It allows overriding the default configuration by passing a config object in the details parameter.\n * The configuration is merged with the default configuration from the intlayer config file.\n */\nexport const getAppLogger =\n (configuration?: CustomIntlayerConfig, globalDetails?: Details) =>\n (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: {\n ...configuration?.log,\n ...globalDetails?.config,\n ...(details?.config ?? {}),\n },\n });\n\nexport const colorize = (\n s: string,\n color?: ANSIColors,\n reset?: boolean | ANSIColors\n): string =>\n color\n ? `${color}${s}${reset ? (typeof reset === 'boolean' ? ANSIColors.RESET : reset) : ANSIColors.RESET}`\n : s;\n\nexport const colorizeLocales = (\n locales: Locales | Locales[],\n color = ANSIColors.GREEN,\n reset: boolean | ANSIColors = ANSIColors.RESET\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color, reset))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color = ANSIColors.BEIGE,\n reset: boolean | ANSIColors = ANSIColors.RESET\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color, reset))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color = ANSIColors.GREY,\n reset: boolean | ANSIColors = ANSIColors.RESET\n) =>\n [path]\n .flat()\n .map((p) => colorize(p, color, reset))\n .join(`, `);\n\n/**\n * Colorize numeric value using Intl.NumberFormat and optional ANSI colors.\n *\n * Examples:\n * colorizeNumber(2, [{ pluralRule: 'one' , color: ANSIColors.GREEN}, { pluralRule: 'other' , color: ANSIColors.RED}]) // \"'\\x1b[31m2\\x1b[0m\"\n */\nexport const colorizeNumber = (\n number: number,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColors>> = {\n zero: ANSIColors.BLUE,\n one: ANSIColors.BLUE,\n two: ANSIColors.BLUE,\n few: ANSIColors.BLUE,\n many: ANSIColors.BLUE,\n other: ANSIColors.BLUE,\n }\n): string => {\n if (number === 0) {\n const color = options.zero ?? ANSIColors.GREEN;\n return colorize(number.toString(), color);\n }\n\n const rule = new Intl.PluralRules('en').select(number);\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const removeColor = (text: string) =>\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (Array.isArray(length) && length.every((l) => typeof l === 'string')) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (Array.isArray(length) && length.every((l) => typeof l === 'number')) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad, padChar } = {\n ...defaultColonOptions,\n ...(options ?? {}),\n };\n\n const length = getLength(colSize);\n const spacesLength = Math.max(\n minSize!,\n Math.min(maxSize!, length - removeColor(text).length)\n );\n\n if (pad === 'left') {\n return `${' '.repeat(spacesLength)}${text}`;\n }\n\n return `${text}${' '.repeat(spacesLength)}`;\n })\n .join('');\n\nexport const x = colorize('✗', ANSIColors.RED);\nexport const v = colorize('✓', ANSIColors.GREEN);\nexport const clock = colorize('⏲', ANSIColors.BLUE);\n"],"mappings":"AAWO,MAAM,SAAiB,CAAC,SAAS,YAAY;AAClD,QAAM,YAAY,SAAS,aAAa;AACxC,QAAM,OAAO,SAAS,QAAQ,QAAQ;AACtC,QAAM,QAAQ,SAAS,SAAS;AAChC,QAAM,SAAS,QAAQ,SAAS,QAAQ,MAAM,IAC1C,SAAS,QAAQ,SACjB;AACJ,QAAM,MAAM,SAAS,QAAQ,OAAO,QAAQ;AAC5C,QAAM,OAAO,SAAS,QAAQ,QAAQ,QAAQ;AAC9C,QAAM,OAAO,SAAS,QAAQ,QAAQ,QAAQ;AAC9C,QAAM,QAAQ,SAAS,QAAQ,SAAS,QAAQ;AAChD,QAAM,QAAQ,SAAS,QAAQ,SAAS,QAAQ;AAEhD,MAAI,SAAS,WAAY;AAEzB,MAAI,aAAa,SAAS,UAAW;AAErC,QAAM,cAAc,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK;AAE5E,MAAI,UAAU,SAAS;AACrB,WAAO,MAAM,GAAG,WAAW;AAAA,EAC7B;AAEA,MAAI,UAAU,QAAQ;AACpB,WAAO,KAAK,GAAG,WAAW;AAAA,EAC5B;AAEA,MAAI,UAAU,QAAQ;AACpB,WAAO,KAAK,GAAG,WAAW;AAAA,EAC5B;AAEA,MAAI,UAAU,SAAS;AACrB,WAAO,MAAM,GAAG,WAAW;AAAA,EAC7B;AAEA,MAAI,GAAG,WAAW;AACpB;AAEO,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,YAAA,WAAQ;AACR,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,eAAY;AACZ,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,SAAM;AACN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AS,YAAYA,KAAI,EAAE,MAAM;AAAA,EACtD;AAEA,MAAI,QAAQ,QAAQ;AAClB,WAAO,GAAG,IAAI,OAAO,YAAY,CAAC,GAAGA,KAAI;AAAA,EAC3C;AAEA,SAAO,GAAGA,KAAI,GAAG,IAAI,OAAO,YAAY,CAAC;AAC3C,CAAC,EACA,KAAK,EAAE;AAEL,MAAM,IAAI,SAAS,UAAK,oBAAc;AACtC,MAAM,IAAI,SAAS,UAAK,sBAAgB;AACxC,MAAM,QAAQ,SAAS,UAAK,qBAAe;","names":["ANSIColors","color","text"]}
@@ -1,11 +1,11 @@
1
1
  import { getConfiguration } from "@intlayer/config";
2
2
  const getExtension = (configuration = getConfiguration(), format) => {
3
3
  const outputFormats = configuration.build.outputFormat;
4
- if (format === "esm") return "mjs";
5
4
  if (format === "cjs") return "cjs";
6
- if (outputFormats.includes("esm")) return "mjs";
5
+ if (format === "esm") return "mjs";
7
6
  if (outputFormats.includes("cjs")) return "cjs";
8
- return "mjs";
7
+ if (outputFormats.includes("esm")) return "mjs";
8
+ return "cjs";
9
9
  };
10
10
  export {
11
11
  getExtension
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/getExtension.ts"],"sourcesContent":["import { type IntlayerConfig, getConfiguration } from '@intlayer/config';\n\nexport const getExtension = (\n configuration: IntlayerConfig = getConfiguration(),\n format?: 'esm' | 'cjs' | undefined\n) => {\n const outputFormats = configuration.build.outputFormat;\n\n if (format === 'esm') return 'mjs';\n if (format === 'cjs') return 'cjs';\n\n if (outputFormats.includes('esm')) return 'mjs';\n if (outputFormats.includes('cjs')) return 'cjs';\n\n return 'mjs';\n};\n"],"mappings":"AAAA,SAA8B,wBAAwB;AAE/C,MAAM,eAAe,CAC1B,gBAAgC,iBAAiB,GACjD,WACG;AACH,QAAM,gBAAgB,cAAc,MAAM;AAE1C,MAAI,WAAW,MAAO,QAAO;AAC7B,MAAI,WAAW,MAAO,QAAO;AAE7B,MAAI,cAAc,SAAS,KAAK,EAAG,QAAO;AAC1C,MAAI,cAAc,SAAS,KAAK,EAAG,QAAO;AAE1C,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/getExtension.ts"],"sourcesContent":["import { type IntlayerConfig, getConfiguration } from '@intlayer/config';\n\nexport const getExtension = (\n configuration: IntlayerConfig = getConfiguration(),\n format?: 'esm' | 'cjs' | undefined\n) => {\n const outputFormats = configuration.build.outputFormat;\n\n if (format === 'cjs') return 'cjs';\n if (format === 'esm') return 'mjs';\n\n if (outputFormats.includes('cjs')) return 'cjs';\n if (outputFormats.includes('esm')) return 'mjs';\n\n return 'cjs';\n};\n"],"mappings":"AAAA,SAA8B,wBAAwB;AAE/C,MAAM,eAAe,CAC1B,gBAAgC,iBAAiB,GACjD,WACG;AACH,QAAM,gBAAgB,cAAc,MAAM;AAE1C,MAAI,WAAW,MAAO,QAAO;AAC7B,MAAI,WAAW,MAAO,QAAO;AAE7B,MAAI,cAAc,SAAS,KAAK,EAAG,QAAO;AAC1C,MAAI,cAAc,SAAS,KAAK,EAAG,QAAO;AAE1C,SAAO;AACT;","names":[]}