@intlayer/config 6.0.1 → 6.0.2-canary.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 (46) hide show
  1. package/dist/cjs/alias.cjs +3 -2
  2. package/dist/cjs/alias.cjs.map +1 -1
  3. package/dist/cjs/configFile/buildConfigurationFields.cjs +13 -1
  4. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  5. package/dist/cjs/defaultValues/build.cjs +3 -0
  6. package/dist/cjs/defaultValues/build.cjs.map +1 -1
  7. package/dist/cjs/index.cjs +6 -0
  8. package/dist/cjs/index.cjs.map +1 -1
  9. package/dist/cjs/logger.cjs +4 -4
  10. package/dist/cjs/logger.cjs.map +1 -1
  11. package/dist/cjs/types/config.cjs.map +1 -1
  12. package/dist/cjs/utils/clearModuleCache.cjs +49 -0
  13. package/dist/cjs/utils/clearModuleCache.cjs.map +1 -0
  14. package/dist/cjs/utils/getExtension.cjs +37 -0
  15. package/dist/cjs/utils/getExtension.cjs.map +1 -0
  16. package/dist/esm/alias.mjs +3 -2
  17. package/dist/esm/alias.mjs.map +1 -1
  18. package/dist/esm/configFile/buildConfigurationFields.mjs +14 -1
  19. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  20. package/dist/esm/defaultValues/build.mjs +2 -0
  21. package/dist/esm/defaultValues/build.mjs.map +1 -1
  22. package/dist/esm/index.mjs +4 -0
  23. package/dist/esm/index.mjs.map +1 -1
  24. package/dist/esm/logger.mjs +4 -4
  25. package/dist/esm/logger.mjs.map +1 -1
  26. package/dist/esm/utils/clearModuleCache.mjs +25 -0
  27. package/dist/esm/utils/clearModuleCache.mjs.map +1 -0
  28. package/dist/esm/utils/getExtension.mjs +13 -0
  29. package/dist/esm/utils/getExtension.mjs.map +1 -0
  30. package/dist/types/alias.d.ts.map +1 -1
  31. package/dist/types/built.d.ts +1 -1
  32. package/dist/types/built.d.ts.map +1 -1
  33. package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
  34. package/dist/types/defaultValues/build.d.ts +1 -0
  35. package/dist/types/defaultValues/build.d.ts.map +1 -1
  36. package/dist/types/index.d.ts +2 -0
  37. package/dist/types/index.d.ts.map +1 -1
  38. package/dist/types/logger.d.ts +4 -4
  39. package/dist/types/logger.d.ts.map +1 -1
  40. package/dist/types/types/config.d.ts +11 -0
  41. package/dist/types/types/config.d.ts.map +1 -1
  42. package/dist/types/utils/clearModuleCache.d.ts +5 -0
  43. package/dist/types/utils/clearModuleCache.d.ts.map +1 -0
  44. package/dist/types/utils/getExtension.d.ts +3 -0
  45. package/dist/types/utils/getExtension.d.ts.map +1 -0
  46. package/package.json +4 -4
@@ -23,13 +23,14 @@ __export(alias_exports, {
23
23
  module.exports = __toCommonJS(alias_exports);
24
24
  var import_path = require("path");
25
25
  var import_getConfiguration = require('./configFile/getConfiguration.cjs');
26
+ var import_getExtension = require('./utils/getExtension.cjs');
26
27
  var import_normalizePath = require('./utils/normalizePath.cjs');
27
28
  const getAlias = ({
28
29
  configuration = (0, import_getConfiguration.getConfiguration)(),
29
- format = "esm",
30
+ format,
30
31
  formatter = (value) => value
31
32
  } = {}) => {
32
- const extension = format === "cjs" ? "cjs" : "mjs";
33
+ const extension = (0, import_getExtension.getExtension)(configuration, format);
33
34
  const { mainDir, configDir, baseDir } = configuration.content;
34
35
  const dictionariesPath = (0, import_path.join)(mainDir, `dictionaries.${extension}`);
35
36
  const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
@@ -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 { 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 = format === 'cjs' ? 'cjs' : 'mjs';\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;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA+B;AAC/B,8BAAiC;AAEjC,2BAA8B;AAQvB,MAAM,WAAW,CAAC;AAAA,EACvB,oBAAgB,0CAAiB;AAAA,EACjC,SAAS;AAAA,EACT,YAAY,CAAC,UAAkB;AACjC,IAAqB,CAAC,MAAM;AAC1B,QAAM,YAAY,WAAW,QAAQ,QAAQ;AAC7C,QAAM,EAAE,SAAS,WAAW,QAAQ,IAAI,cAAc;AAKtD,QAAM,uBAAmB,kBAAK,SAAS,gBAAgB,SAAS,EAAE;AAClE,QAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AACnE,QAAM,6BAA6B;AAAA,QACjC,oCAAc,wBAAwB;AAAA,EACxC;AAKA,QAAM,+BAA2B;AAAA,IAC/B;AAAA,IACA,yBAAyB,SAAS;AAAA,EACpC;AACA,QAAM,uCAAmC;AAAA,IACvC;AAAA,IACA;AAAA,EACF;AACA,QAAM,qCAAqC;AAAA,QACzC,oCAAc,gCAAgC;AAAA,EAChD;AAKA,QAAM,6BAAyB;AAAA,IAC7B;AAAA,IACA,uBAAuB,SAAS;AAAA,EAClC;AACA,QAAM,qCAAiC;AAAA,IACrC;AAAA,IACA;AAAA,EACF;AACA,QAAM,mCAAmC;AAAA,QACvC,oCAAc,8BAA8B;AAAA,EAC9C;AAKA,QAAM,8BAA0B;AAAA,IAC9B;AAAA,IACA,wBAAwB,SAAS;AAAA,EACnC;AACA,QAAM,sCAAkC;AAAA,IACtC;AAAA,IACA;AAAA,EACF;AACA,QAAM,oCAAoC;AAAA,QACxC,oCAAc,+BAA+B;AAAA,EAC/C;AAKA,QAAM,4BAAwB;AAAA,IAC5B;AAAA,IACA,sBAAsB,SAAS;AAAA,EACjC;AACA,QAAM,oCAAgC;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AACA,QAAM,kCAAkC;AAAA,QACtC,oCAAc,6BAA6B;AAAA,EAC7C;AAKA,QAAM,wBAAoB,kBAAK,WAAW,oBAAoB;AAC9D,QAAM,gCAA4B,sBAAS,SAAS,iBAAiB;AACrE,QAAM,8BAA8B;AAAA,QAClC,oCAAc,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,\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;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA+B;AAC/B,8BAAiC;AAEjC,0BAA6B;AAC7B,2BAA8B;AAQvB,MAAM,WAAW,CAAC;AAAA,EACvB,oBAAgB,0CAAiB;AAAA,EACjC;AAAA,EACA,YAAY,CAAC,UAAkB;AACjC,IAAqB,CAAC,MAAM;AAC1B,QAAM,gBAAY,kCAAa,eAAe,MAAM;AAEpD,QAAM,EAAE,SAAS,WAAW,QAAQ,IAAI,cAAc;AAKtD,QA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
619
619
  * - This option will be ignored if `optimize` is disabled.
620
620
  * - Use glob pattern.
621
621
  */
622
- traversePattern: customConfiguration?.traversePattern ?? import_build.TRAVERSE_PATTERN
622
+ traversePattern: customConfiguration?.traversePattern ?? import_build.TRAVERSE_PATTERN,
623
+ /**
624
+ * Output format of the dictionaries
625
+ *
626
+ * Can be set on large projects to improve build performance.
627
+ *
628
+ * Default: ['cjs', 'esm']
629
+ *
630
+ * The output format of the dictionaries. It can be either 'cjs' or 'esm'.
631
+ * - 'cjs': The dictionaries are outputted as CommonJS modules.
632
+ * - 'esm': The dictionaries are outputted as ES modules.
633
+ */
634
+ outputFormat: customConfiguration?.outputFormat ?? import_build.OUTPUT_FORMAT
623
635
  });
624
636
  const buildConfigurationFields = (customConfiguration, baseDir) => {
625
637
  const internationalizationConfig = buildInternationalizationFields(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { join } from 'path';\nimport {\n IMPORT_MODE,\n OPTIMIZE,\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/**\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;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,mBAIO;AACP,qBAcO;AACP,oBAUO;AACP,kCAKO;AACP,iBAA6B;AAC7B,wBAQO;AAgBP,2BAA8B;AAE9B,IAAI;AAIJ,MAAM,kCAAkC,CACtC,yBACgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhC,SAAS,qBAAqB,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzC,iBACE,qBAAqB,mBACrB,qBAAqB,WACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUF,YAAY,qBAAqB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO/C,eAAe,qBAAqB,iBAAiB;AACvD;AAEA,MAAM,wBAAwB,CAC5B,yBACsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMt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B;AAAA;AAAA;AAAA;AAAA,EAKlC,oBAAoB,qBAAqB;AAC3C;AAEA,MAAM,mBAAmB,CACvB,yBACiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBjB,UAAU,qBAAqB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2B3C,YAAY,qBAAqB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgB/C,iBAAiB,qBAAqB,mBAAmB;AAC3D;AAKO,MAAM,2BAA2B,CACtC,qBACA,YACmB;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,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 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;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,mBAKO;AACP,qBAcO;AACP,oBAUO;AACP,kCAKO;AACP,iBAA6B;AAC7B,wBAQO;AAgBP,2BAA8B;AAE9B,IAAI;AAIJ,MAAM,kCAAkC,CACtC,yBACgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhC,SAAS,qBAAqB,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzC,iBACE,qBAAqB,mBACrB,qBAAqB,WACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUF,YAAY,qBAAqB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO/C,eAAe,qBAAqB,iBAAiB;AACvD;AAEA,MAAM,wBAAwB,CAC5B,yBACsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtB,YAAY,qBAAqB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO/C,YAAY,qBAAqB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc/C,eAAe,qBAAqB,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAarD,UAAU,qBAAqB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO3C,iBAAiB,qBAAqB,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,YACmB;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,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":[]}
@@ -20,6 +20,7 @@ var build_exports = {};
20
20
  __export(build_exports, {
21
21
  IMPORT_MODE: () => IMPORT_MODE,
22
22
  OPTIMIZE: () => OPTIMIZE,
23
+ OUTPUT_FORMAT: () => OUTPUT_FORMAT,
23
24
  TRAVERSE_PATTERN: () => TRAVERSE_PATTERN
24
25
  });
25
26
  module.exports = __toCommonJS(build_exports);
@@ -29,10 +30,12 @@ const TRAVERSE_PATTERN = [
29
30
  "**/*.{js,ts,mjs,cjs,jsx,tsx,mjx,cjx,vue,svelte,svte}",
30
31
  "!**/node_modules/**"
31
32
  ];
33
+ const OUTPUT_FORMAT = ["cjs", "esm"];
32
34
  // Annotate the CommonJS export names for ESM import in node:
33
35
  0 && (module.exports = {
34
36
  IMPORT_MODE,
35
37
  OPTIMIZE,
38
+ OUTPUT_FORMAT,
36
39
  TRAVERSE_PATTERN
37
40
  });
38
41
  //# sourceMappingURL=build.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/defaultValues/build.ts"],"sourcesContent":["export const OPTIMIZE = process.env.NODE_ENV === 'production';\n\nexport const IMPORT_MODE = 'static';\n\nexport const TRAVERSE_PATTERN = [\n '**/*.{js,ts,mjs,cjs,jsx,tsx,mjx,cjx,vue,svelte,svte}',\n '!**/node_modules/**',\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,WAAW,QAAQ,IAAI,aAAa;AAE1C,MAAM,cAAc;AAEpB,MAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/defaultValues/build.ts"],"sourcesContent":["export const OPTIMIZE = process.env.NODE_ENV === 'production';\n\nexport const IMPORT_MODE = 'static';\n\nexport const TRAVERSE_PATTERN = [\n '**/*.{js,ts,mjs,cjs,jsx,tsx,mjx,cjx,vue,svelte,svte}',\n '!**/node_modules/**',\n];\n\nexport const OUTPUT_FORMAT: ('cjs' | 'esm')[] = ['cjs', 'esm'];\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,WAAW,QAAQ,IAAI,aAAa;AAE1C,MAAM,cAAc;AAEpB,MAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AACF;AAEO,MAAM,gBAAmC,CAAC,OAAO,KAAK;","names":[]}
@@ -21,6 +21,7 @@ __export(index_exports, {
21
21
  ANSIColors: () => import_logger.ANSIColors,
22
22
  ESMxCJSRequire: () => import_ESMxCJSHelpers.ESMxCJSRequire,
23
23
  Locales: () => import_locales.Locales,
24
+ clearModuleCache: () => import_clearModuleCache.clearModuleCache,
24
25
  clock: () => import_logger.clock,
25
26
  colon: () => import_logger.colon,
26
27
  colorize: () => import_logger.colorize,
@@ -32,6 +33,7 @@ __export(index_exports, {
32
33
  getAppLogger: () => import_logger.getAppLogger,
33
34
  getConfiguration: () => import_getConfiguration.getConfiguration,
34
35
  getEnvFilePath: () => import_loadEnvFile.getEnvFilePath,
36
+ getExtension: () => import_getExtension.getExtension,
35
37
  getSandBoxContext: () => import_getSandboxContext.getSandBoxContext,
36
38
  isESModule: () => import_ESMxCJSHelpers.isESModule,
37
39
  loadEnvFile: () => import_loadEnvFile.loadEnvFile,
@@ -52,13 +54,16 @@ var import_loadExternalFile = require('./loadExternalFile.cjs');
52
54
  var import_logger = require('./logger.cjs');
53
55
  var import_retryManager = require('./retryManager.cjs');
54
56
  var import_locales = require('./types/locales.cjs');
57
+ var import_clearModuleCache = require('./utils/clearModuleCache.cjs');
55
58
  var import_ESMxCJSHelpers = require('./utils/ESMxCJSHelpers.cjs');
59
+ var import_getExtension = require('./utils/getExtension.cjs');
56
60
  var import_normalizePath = require('./utils/normalizePath.cjs');
57
61
  // Annotate the CommonJS export names for ESM import in node:
58
62
  0 && (module.exports = {
59
63
  ANSIColors,
60
64
  ESMxCJSRequire,
61
65
  Locales,
66
+ clearModuleCache,
62
67
  clock,
63
68
  colon,
64
69
  colorize,
@@ -70,6 +75,7 @@ var import_normalizePath = require('./utils/normalizePath.cjs');
70
75
  getAppLogger,
71
76
  getConfiguration,
72
77
  getEnvFilePath,
78
+ getExtension,
73
79
  getSandBoxContext,
74
80
  isESModule,
75
81
  loadEnvFile,
@@ -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 { ESMxCJSRequire, isESModule } from './utils/ESMxCJSHelpers';\nexport { normalizePath } from './utils/normalizePath';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AACzB,8BAGO;AACP,+BAAkC;AAClC,yBAA4C;AAC5C,8BAAiC;AACjC,oBAeO;AACP,0BAA6B;AAe7B,qBAAwB;AAExB,4BAA2C;AAC3C,2BAA8B;","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 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AACzB,8BAGO;AACP,+BAAkC;AAClC,yBAA4C;AAC5C,8BAAiC;AACjC,oBAeO;AACP,0BAA6B;AAe7B,qBAAwB;AAExB,8BAAiC;AACjC,4BAA2C;AAC3C,0BAA6B;AAC7B,2BAA8B;","names":[]}
@@ -80,10 +80,10 @@ const getAppLogger = (configuration, globalDetails) => (content, details) => log
80
80
  ...details?.config ?? {}
81
81
  }
82
82
  });
83
- const colorize = (s, color) => color ? `${color}${s}${"\x1B[0m" /* RESET */}` : s;
84
- const colorizeLocales = (locales, color = "\x1B[32m" /* GREEN */) => [locales].flat().map((locale) => colorize(locale, color)).join(`, `);
85
- const colorizeKey = (keyPath, color = "\x1B[38;5;3m" /* BEIGE */) => [keyPath].flat().map((key) => colorize(key, color)).join(`, `);
86
- const colorizePath = (path, color = "\x1B[90m" /* GREY */) => [path].flat().map((p) => colorize(p, color)).join(`, `);
83
+ const colorize = (s, color, reset) => color ? `${color}${s}${reset ? typeof reset === "boolean" ? "\x1B[0m" /* RESET */ : reset : "\x1B[0m" /* RESET */}` : s;
84
+ const colorizeLocales = (locales, color = "\x1B[32m" /* GREEN */, reset = "\x1B[0m" /* RESET */) => [locales].flat().map((locale) => colorize(locale, color, reset)).join(`, `);
85
+ const colorizeKey = (keyPath, color = "\x1B[38;5;3m" /* BEIGE */, reset = "\x1B[0m" /* RESET */) => [keyPath].flat().map((key) => colorize(key, color, reset)).join(`, `);
86
+ const colorizePath = (path, color = "\x1B[90m" /* GREY */, reset = "\x1B[0m" /* RESET */) => [path].flat().map((p) => colorize(p, color, reset)).join(`, `);
87
87
  const colorizeNumber = (number, options = {
88
88
  zero: "\x1B[34m" /* BLUE */,
89
89
  one: "\x1B[34m" /* BLUE */,
@@ -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 = (s: string, color?: ANSIColors): string =>\n color ? `${color}${s}${ANSIColors.RESET}` : s;\n\nexport const colorizeLocales = (\n locales: Locales | Locales[],\n color = ANSIColors.GREEN\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color = ANSIColors.BEIGE\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color = ANSIColors.GREY\n) =>\n [path]\n .flat()\n .map((p) => colorize(p, color))\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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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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,CAAC;AAAA,EACrD;AACA,MAAI,MAAM,QAAQ,MAAM,KAAK,OAAO,MAAM,CAAC,MAAM,OAAO,MAAM,QAAQ,GAAG;AACvE,YAAQ,KAAK,IAAI,GAAG,MAAM;AAAA,EAC5B;AACA,SAAO,KAAK,IAAI,OAAO,CAAC;AAC1B;AAEA,MAAM,sBAAsB;AAAA,EAC1B,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AACX;AAQO,MAAM,QAAQ,CACnB,MACA,YAQA,CAAC,IAAI,EACF,KAAK,EACL,IAAI,CAACC,UAAS;AACb,QAAM,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 = (\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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,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SAAS;AACX;AAQO,MAAM,QAAQ,CACnB,MACA,YAQA,CAAC,IAAI,EACF,KAAK,EACL,IAAI,CAACC,UAAS;AACb,QAAM,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 +1 @@
1
- {"version":3,"sources":["../../../src/types/config.ts"],"sourcesContent":["import type { Locales } from './locales';\n\nexport type StrictMode = 'strict' | 'inclusive' | 'loose';\n\n/**\n * Configuration for internationalization settings\n */\nexport type InternationalizationConfig = {\n /**\n * Locales available in the application\n *\n * Default: [Locales.ENGLISH]\n *\n * You can define a list of available locales to support in the application.\n */\n 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: 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: StrictMode;\n\n /**\n * Default locale of the application for fallback\n *\n * Default: Locales.ENGLISH\n *\n * Used to specify a fallback locale in case no other locale is set.\n */\n defaultLocale: Locales;\n};\n\nexport type ServerSetCookieRule = 'always' | 'never';\n\n/**\n * Configuration for middleware behaviors\n */\nexport type MiddlewareConfig = {\n /**\n * Header name to get the locale from the request\n *\n * Default: 'x-intlayer-locale'\n *\n * The HTTP header key used to determine the current locale.\n */\n headerName: string;\n\n /**\n * Cookie name to store the locale information\n *\n * Default: 'INTLAYER_LOCALE'\n *\n * The cookie key where the locale information is stored.\n */\n cookieName: string;\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: boolean;\n\n /**\n * Base path for application URLs\n *\n * Default: ''\n *\n * Defines the base path where the application is accessible from.\n */\n basePath: string;\n\n /**\n * Strategy for setting the locale cookie on the server\n *\n * Default: 'always'\n *\n * This setting controls when the server sets the locale cookie. It can either set the cookie on every request or never set it.\n */\n serverSetCookie: ServerSetCookieRule;\n\n /**\n * Indicates if no prefix should be used in the URL for locale\n *\n * Default: false\n *\n * If true, no locale-based prefix is used in the URL.\n */\n noPrefix: boolean;\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: boolean;\n};\n\n/**\n * Configuration for intlayer editor\n */\nexport type 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: string;\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: 'http://localhost:8000'\n */\n editorURL: string;\n\n /**\n * URL of the CMS server. Used to restrict the origin of the editor for security reasons.\n *\n * Default: 'https://intlayer.org'\n */\n cmsURL: string;\n\n /**\n * URL of the backend\n *\n * Default: 'https://back.intlayer.org'\n *\n * The URL of the backend server.\n */\n backendURL: string;\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 */\n enabled: boolean;\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: number;\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?: string;\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?: string;\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: 'local_first' | 'distant_first';\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 * Default: true\n */\n liveSync: boolean;\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: number;\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${liveSyncPort}`\n */\n liveSyncURL: string;\n};\n\nexport type AiConfig = {\n /**\n * Provider\n *\n * The provider to use for the AI features of Intlayer.\n *\n * Available providers:\n * - 'openai'\n * - 'anthropic'\n * - 'mistral'\n * - 'deepseek'\n * - 'gemini'\n *\n * Default: 'openai'\n */\n provider?: string;\n\n /**\n * API model\n *\n * The model to use for the AI features of Intlayer.\n *\n * Example: 'gpt-4o-2024-11-20'\n *\n */\n model?: string;\n\n /**\n * temperature\n *\n * The temperature to use for the AI features of Intlayer.\n * The temperature controls the randomness of the AI's responses.\n * A higher temperature will make the AI more creative and less predictable.\n *\n * Example: 0.1\n */\n temperature?: number;\n\n /**\n * API key\n *\n * Use your own OpenAI API key to use the AI features of Intlayer.\n * If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.\n *\n */\n apiKey?: string;\n\n /**\n * Application context\n *\n * The context of the application to use for the AI features of Intlayer.\n *\n * Example: 'This is a website for a company that sells products online.'\n */\n applicationContext?: string;\n};\n\nexport type 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 * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize: boolean;\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: 'static' | 'dynamic' | 'live';\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}', '!**\\/node_modules/**']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: string[];\n};\n\n/**\n * Custom configuration that can be provided to override default settings\n */\nexport type CustomIntlayerConfig = {\n /**\n * Custom internationalization configuration\n */\n internationalization?: Partial<InternationalizationConfig>;\n\n /**\n * Custom middleware configuration\n */\n middleware?: Partial<MiddlewareConfig>;\n\n /**\n * Custom content configuration\n */\n content?: Partial<ContentConfig>;\n\n /**\n * Custom editor configuration\n */\n editor?: Partial<EditorConfig>;\n\n /**\n * Custom middleware configuration\n */\n log?: Partial<LogConfig>;\n\n /**\n * Custom AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Custom build configuration\n */\n build?: Partial<BuildConfig>;\n};\n\n/**\n * Combined configuration for internationalization, middleware, and content\n */\nexport type IntlayerConfig = {\n /**\n * Internationalization configuration\n */\n internationalization: InternationalizationConfig;\n\n /**\n * Middleware configuration\n */\n middleware: MiddlewareConfig;\n\n /**\n * Content configuration\n */\n content: ContentConfig;\n\n /**\n * Intlayer editor configuration\n */\n editor: EditorConfig;\n\n /**\n * Logger configuration\n */\n log: LogConfig;\n\n /**\n * AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Build configuration\n */\n build: BuildConfig;\n};\n\n/**\n * Base configuration for content handling\n */\nexport type BaseContentConfig = {\n /**\n * File extensions of content to look for\n *\n * Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * List of file extensions to scan for content.\n */\n fileExtensions: string[];\n\n /**\n * Absolute path of the project's base directory\n *\n * Default: process.cwd()\n *\n * The root directory of the project, typically used for resolving other paths.\n */\n baseDir: string;\n\n /**\n * Directories to be excluded from content processing\n *\n * Default: ['node_modules', '.intlayer']\n *\n * A list of directories to exclude from content processing.\n */\n excludedPath: string[];\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: boolean;\n\n /**\n * Indicate how the content should be automatically filled using AI.\n *\n * Default: undefined\n *\n */\n autoFill?: boolean | string | { [key in Locales]?: string };\n};\n\n/**\n * Configuration derived based on the base content configuration\n */\nexport type BaseDerivedConfig = {\n /**\n * Directory where the content is stored, relative to the base directory\n *\n * Default: ['.']\n *\n * Derived content directory based on the base configuration.\n */\n contentDir: string[];\n\n /**\n * Directory where the results are stored, relative to the base directory\n *\n * Default: .intlayer/dictionary\n *\n * Derived results directory based on the base configuration.\n */\n dictionariesDir: string;\n\n /**\n * Directory for module augmentation, relative to the base directory\n *\n * Default: .intlayer/types\n *\n * Defines the derived path for module augmentation.\n */\n moduleAugmentationDir: string;\n};\n\n/**\n * Configuration derived based on the result directory\n */\nexport type ResultDirDerivedConfig = {\n /**\n * Directory where unmerged dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/unmerged_dictionary\n *\n * Specifies the derived path for unmerged dictionaries relative to the result directory.\n */\n unmergedDictionariesDir: string;\n\n /**\n * Directory where remote dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/remote_dictionary\n *\n * Specifies the derived path for remote dictionaries relative to the result directory.\n */\n remoteDictionariesDir: string;\n\n /**\n * Directory where final dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Specifies the derived path for dictionaries relative to the result directory.\n */\n dictionariesDir: string;\n\n /**\n * Directory where dynamic dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dynamic_dictionary\n *\n * Specifies the derived path for dynamic dictionaries relative to the result directory.\n */\n dynamicDictionariesDir: string;\n\n /**\n * Directory where fetch dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/fetch_dictionary\n *\n * Specifies the derived path for fetch dictionaries relative to the result directory.\n */\n fetchDictionariesDir: string;\n\n /**\n * Directory where dictionary types are stored, relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Specifies the derived path for dictionary types relative to the result directory.\n */\n typesDir: string;\n\n /**\n * Directory where the main files are stored, relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Specifies the derived path for the main files relative to the result directory.\n */\n mainDir: string;\n\n /**\n * Directory where the configuration files are stored, relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Specifies the derived path for the configuration files relative to the result directory.\n */\n configDir: string;\n};\n\n/**\n * Configuration for content patterns\n */\nexport type PatternsContentConfig = {\n /**\n * Patterns of files to watch for changes\n *\n * Default: ['/**\\/*.content.ts', '/**\\/*.content.js', '/**\\/*.content.json', '/**\\/*.content.cjs', '/**\\/*.content.mjs', '/**\\/*.content.tsx', '/**\\/*.content.jsx']\n *\n * Defines file patterns for content to watch for changes.\n */\n watchedFilesPattern: string[];\n\n /**\n * Patterns of files to watch for changes 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 * Specifies the file patterns for content to watch, including relative paths.\n */\n watchedFilesPatternWithPath: string[];\n\n /**\n * Pattern for output files including the relative path\n *\n * Default: '{{dictionariesDir}}/**\\/*.json'\n *\n * Defines the pattern for output files, including the relative path.\n */\n outputFilesPatternWithPath: string;\n};\n\n// @TODO: Implement exclusion of non configurable fields, to not allow them to be set in the config\n/**\n * General configuration derived from the config file\n */\nexport type ContentConfig = BaseContentConfig &\n BaseDerivedConfig &\n ResultDirDerivedConfig &\n PatternsContentConfig;\n\nexport type LogConfig = {\n /**\n * Indicates if the logger is enabled\n *\n * Default: true\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: 'default' | 'verbose' | 'disabled';\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: string;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/types/config.ts"],"sourcesContent":["import type { Locales } from './locales';\n\nexport type StrictMode = 'strict' | 'inclusive' | 'loose';\n\n/**\n * Configuration for internationalization settings\n */\nexport type InternationalizationConfig = {\n /**\n * Locales available in the application\n *\n * Default: [Locales.ENGLISH]\n *\n * You can define a list of available locales to support in the application.\n */\n 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: 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: StrictMode;\n\n /**\n * Default locale of the application for fallback\n *\n * Default: Locales.ENGLISH\n *\n * Used to specify a fallback locale in case no other locale is set.\n */\n defaultLocale: Locales;\n};\n\nexport type ServerSetCookieRule = 'always' | 'never';\n\n/**\n * Configuration for middleware behaviors\n */\nexport type MiddlewareConfig = {\n /**\n * Header name to get the locale from the request\n *\n * Default: 'x-intlayer-locale'\n *\n * The HTTP header key used to determine the current locale.\n */\n headerName: string;\n\n /**\n * Cookie name to store the locale information\n *\n * Default: 'INTLAYER_LOCALE'\n *\n * The cookie key where the locale information is stored.\n */\n cookieName: string;\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: boolean;\n\n /**\n * Base path for application URLs\n *\n * Default: ''\n *\n * Defines the base path where the application is accessible from.\n */\n basePath: string;\n\n /**\n * Strategy for setting the locale cookie on the server\n *\n * Default: 'always'\n *\n * This setting controls when the server sets the locale cookie. It can either set the cookie on every request or never set it.\n */\n serverSetCookie: ServerSetCookieRule;\n\n /**\n * Indicates if no prefix should be used in the URL for locale\n *\n * Default: false\n *\n * If true, no locale-based prefix is used in the URL.\n */\n noPrefix: boolean;\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: boolean;\n};\n\n/**\n * Configuration for intlayer editor\n */\nexport type 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: string;\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: 'http://localhost:8000'\n */\n editorURL: string;\n\n /**\n * URL of the CMS server. Used to restrict the origin of the editor for security reasons.\n *\n * Default: 'https://intlayer.org'\n */\n cmsURL: string;\n\n /**\n * URL of the backend\n *\n * Default: 'https://back.intlayer.org'\n *\n * The URL of the backend server.\n */\n backendURL: string;\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 */\n enabled: boolean;\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: number;\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?: string;\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?: string;\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: 'local_first' | 'distant_first';\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 * Default: true\n */\n liveSync: boolean;\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: number;\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${liveSyncPort}`\n */\n liveSyncURL: string;\n};\n\nexport type AiConfig = {\n /**\n * Provider\n *\n * The provider to use for the AI features of Intlayer.\n *\n * Available providers:\n * - 'openai'\n * - 'anthropic'\n * - 'mistral'\n * - 'deepseek'\n * - 'gemini'\n *\n * Default: 'openai'\n */\n provider?: string;\n\n /**\n * API model\n *\n * The model to use for the AI features of Intlayer.\n *\n * Example: 'gpt-4o-2024-11-20'\n *\n */\n model?: string;\n\n /**\n * temperature\n *\n * The temperature to use for the AI features of Intlayer.\n * The temperature controls the randomness of the AI's responses.\n * A higher temperature will make the AI more creative and less predictable.\n *\n * Example: 0.1\n */\n temperature?: number;\n\n /**\n * API key\n *\n * Use your own OpenAI API key to use the AI features of Intlayer.\n * If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.\n *\n */\n apiKey?: string;\n\n /**\n * Application context\n *\n * The context of the application to use for the AI features of Intlayer.\n *\n * Example: 'This is a website for a company that sells products online.'\n */\n applicationContext?: string;\n};\n\nexport type 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 * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize: boolean;\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 * - Require static key to work. Example of invalid code: `const navbarKey = \"my-key\"; useIntlayer(navbarKey)`.\n */\n importMode: 'static' | 'dynamic' | 'live';\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}', '!**\\/node_modules/**']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: string[];\n\n /**\n * Output format of the dictionaries\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'. Even if dictionaries are written in JSON, entry point to access the dictionaries are generated.\n * This function will use the output format defined using this option.\n * The default format is 'cjs' as it allows better interoperability with other libraries, scripts, and applications. But some build tools, such as Vite, require ES modules.\n */\n outputFormat: ('cjs' | 'esm')[];\n};\n\n/**\n * Custom configuration that can be provided to override default settings\n */\nexport type CustomIntlayerConfig = {\n /**\n * Custom internationalization configuration\n */\n internationalization?: Partial<InternationalizationConfig>;\n\n /**\n * Custom middleware configuration\n */\n middleware?: Partial<MiddlewareConfig>;\n\n /**\n * Custom content configuration\n */\n content?: Partial<ContentConfig>;\n\n /**\n * Custom editor configuration\n */\n editor?: Partial<EditorConfig>;\n\n /**\n * Custom middleware configuration\n */\n log?: Partial<LogConfig>;\n\n /**\n * Custom AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Custom build configuration\n */\n build?: Partial<BuildConfig>;\n};\n\n/**\n * Combined configuration for internationalization, middleware, and content\n */\nexport type IntlayerConfig = {\n /**\n * Internationalization configuration\n */\n internationalization: InternationalizationConfig;\n\n /**\n * Middleware configuration\n */\n middleware: MiddlewareConfig;\n\n /**\n * Content configuration\n */\n content: ContentConfig;\n\n /**\n * Intlayer editor configuration\n */\n editor: EditorConfig;\n\n /**\n * Logger configuration\n */\n log: LogConfig;\n\n /**\n * AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Build configuration\n */\n build: BuildConfig;\n};\n\n/**\n * Base configuration for content handling\n */\nexport type BaseContentConfig = {\n /**\n * File extensions of content to look for\n *\n * Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * List of file extensions to scan for content.\n */\n fileExtensions: string[];\n\n /**\n * Absolute path of the project's base directory\n *\n * Default: process.cwd()\n *\n * The root directory of the project, typically used for resolving other paths.\n */\n baseDir: string;\n\n /**\n * Directories to be excluded from content processing\n *\n * Default: ['node_modules', '.intlayer']\n *\n * A list of directories to exclude from content processing.\n */\n excludedPath: string[];\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: boolean;\n\n /**\n * Indicate how the content should be automatically filled using AI.\n *\n * Default: undefined\n *\n */\n autoFill?: boolean | string | { [key in Locales]?: string };\n};\n\n/**\n * Configuration derived based on the base content configuration\n */\nexport type BaseDerivedConfig = {\n /**\n * Directory where the content is stored, relative to the base directory\n *\n * Default: ['.']\n *\n * Derived content directory based on the base configuration.\n */\n contentDir: string[];\n\n /**\n * Directory where the results are stored, relative to the base directory\n *\n * Default: .intlayer/dictionary\n *\n * Derived results directory based on the base configuration.\n */\n dictionariesDir: string;\n\n /**\n * Directory for module augmentation, relative to the base directory\n *\n * Default: .intlayer/types\n *\n * Defines the derived path for module augmentation.\n */\n moduleAugmentationDir: string;\n};\n\n/**\n * Configuration derived based on the result directory\n */\nexport type ResultDirDerivedConfig = {\n /**\n * Directory where unmerged dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/unmerged_dictionary\n *\n * Specifies the derived path for unmerged dictionaries relative to the result directory.\n */\n unmergedDictionariesDir: string;\n\n /**\n * Directory where remote dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/remote_dictionary\n *\n * Specifies the derived path for remote dictionaries relative to the result directory.\n */\n remoteDictionariesDir: string;\n\n /**\n * Directory where final dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Specifies the derived path for dictionaries relative to the result directory.\n */\n dictionariesDir: string;\n\n /**\n * Directory where dynamic dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dynamic_dictionary\n *\n * Specifies the derived path for dynamic dictionaries relative to the result directory.\n */\n dynamicDictionariesDir: string;\n\n /**\n * Directory where fetch dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/fetch_dictionary\n *\n * Specifies the derived path for fetch dictionaries relative to the result directory.\n */\n fetchDictionariesDir: string;\n\n /**\n * Directory where dictionary types are stored, relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Specifies the derived path for dictionary types relative to the result directory.\n */\n typesDir: string;\n\n /**\n * Directory where the main files are stored, relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Specifies the derived path for the main files relative to the result directory.\n */\n mainDir: string;\n\n /**\n * Directory where the configuration files are stored, relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Specifies the derived path for the configuration files relative to the result directory.\n */\n configDir: string;\n};\n\n/**\n * Configuration for content patterns\n */\nexport type PatternsContentConfig = {\n /**\n * Patterns of files to watch for changes\n *\n * Default: ['/**\\/*.content.ts', '/**\\/*.content.js', '/**\\/*.content.json', '/**\\/*.content.cjs', '/**\\/*.content.mjs', '/**\\/*.content.tsx', '/**\\/*.content.jsx']\n *\n * Defines file patterns for content to watch for changes.\n */\n watchedFilesPattern: string[];\n\n /**\n * Patterns of files to watch for changes 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 * Specifies the file patterns for content to watch, including relative paths.\n */\n watchedFilesPatternWithPath: string[];\n\n /**\n * Pattern for output files including the relative path\n *\n * Default: '{{dictionariesDir}}/**\\/*.json'\n *\n * Defines the pattern for output files, including the relative path.\n */\n outputFilesPatternWithPath: string;\n};\n\n// @TODO: Implement exclusion of non configurable fields, to not allow them to be set in the config\n/**\n * General configuration derived from the config file\n */\nexport type ContentConfig = BaseContentConfig &\n BaseDerivedConfig &\n ResultDirDerivedConfig &\n PatternsContentConfig;\n\nexport type LogConfig = {\n /**\n * Indicates if the logger is enabled\n *\n * Default: true\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: 'default' | 'verbose' | 'disabled';\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: string;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var clearModuleCache_exports = {};
20
+ __export(clearModuleCache_exports, {
21
+ clearModuleCache: () => clearModuleCache
22
+ });
23
+ module.exports = __toCommonJS(clearModuleCache_exports);
24
+ var import_ESMxCJSHelpers = require('./ESMxCJSHelpers.cjs');
25
+ const clearModuleCache = (modulePath, visited = /* @__PURE__ */ new Set()) => {
26
+ if (visited.has(modulePath)) {
27
+ return;
28
+ }
29
+ visited.add(modulePath);
30
+ try {
31
+ const resolvedPath = import_ESMxCJSHelpers.ESMxCJSRequire.resolve(modulePath);
32
+ const cachedModule = import_ESMxCJSHelpers.ESMxCJSRequire.cache[resolvedPath];
33
+ if (cachedModule) {
34
+ if (cachedModule.children) {
35
+ cachedModule.children.forEach((child) => {
36
+ clearModuleCache(child.filename, visited);
37
+ });
38
+ }
39
+ delete import_ESMxCJSHelpers.ESMxCJSRequire.cache[resolvedPath];
40
+ }
41
+ } catch (error) {
42
+ console.warn(`Could not clear cache for module: ${modulePath}`, error);
43
+ }
44
+ };
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ clearModuleCache
48
+ });
49
+ //# sourceMappingURL=clearModuleCache.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/clearModuleCache.ts"],"sourcesContent":["import { ESMxCJSRequire } from './ESMxCJSHelpers';\n\n/**\n * Recursively clears the require cache for a module and all its dependencies\n */\nexport const clearModuleCache = (\n modulePath: string,\n visited = new Set<string>()\n) => {\n // Avoid infinite loops\n if (visited.has(modulePath)) {\n return;\n }\n visited.add(modulePath);\n\n try {\n const resolvedPath = ESMxCJSRequire.resolve(modulePath);\n\n // Get the cached module\n const cachedModule = ESMxCJSRequire.cache[resolvedPath];\n\n if (cachedModule) {\n // Clear cache for all children (dependencies) first\n if (cachedModule.children) {\n cachedModule.children.forEach((child) => {\n clearModuleCache(child.filename, visited);\n });\n }\n\n // Clear the cache for this module\n delete ESMxCJSRequire.cache[resolvedPath];\n }\n } catch (error) {\n // Module might not exist or be resolvable, skip it\n console.warn(`Could not clear cache for module: ${modulePath}`, error);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA+B;AAKxB,MAAM,mBAAmB,CAC9B,YACA,UAAU,oBAAI,IAAY,MACvB;AAEH,MAAI,QAAQ,IAAI,UAAU,GAAG;AAC3B;AAAA,EACF;AACA,UAAQ,IAAI,UAAU;AAEtB,MAAI;AACF,UAAM,eAAe,qCAAe,QAAQ,UAAU;AAGtD,UAAM,eAAe,qCAAe,MAAM,YAAY;AAEtD,QAAI,cAAc;AAEhB,UAAI,aAAa,UAAU;AACzB,qBAAa,SAAS,QAAQ,CAAC,UAAU;AACvC,2BAAiB,MAAM,UAAU,OAAO;AAAA,QAC1C,CAAC;AAAA,MACH;AAGA,aAAO,qCAAe,MAAM,YAAY;AAAA,IAC1C;AAAA,EACF,SAAS,OAAO;AAEd,YAAQ,KAAK,qCAAqC,UAAU,IAAI,KAAK;AAAA,EACvE;AACF;","names":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var getExtension_exports = {};
20
+ __export(getExtension_exports, {
21
+ getExtension: () => getExtension
22
+ });
23
+ module.exports = __toCommonJS(getExtension_exports);
24
+ var import_config = require("@intlayer/config");
25
+ const getExtension = (configuration = (0, import_config.getConfiguration)(), format) => {
26
+ const outputFormats = configuration.build.outputFormat;
27
+ if (format === "esm") return "mjs";
28
+ if (format === "cjs") return "cjs";
29
+ if (outputFormats.includes("esm")) return "mjs";
30
+ if (outputFormats.includes("cjs")) return "cjs";
31
+ return "mjs";
32
+ };
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ getExtension
36
+ });
37
+ //# sourceMappingURL=getExtension.cjs.map
@@ -0,0 +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,12 +1,13 @@
1
1
  import { join, relative } from "path";
2
2
  import { getConfiguration } from "./configFile/getConfiguration.mjs";
3
+ import { getExtension } from "./utils/getExtension.mjs";
3
4
  import { normalizePath } from "./utils/normalizePath.mjs";
4
5
  const getAlias = ({
5
6
  configuration = getConfiguration(),
6
- format = "esm",
7
+ format,
7
8
  formatter = (value) => value
8
9
  } = {}) => {
9
- const extension = format === "cjs" ? "cjs" : "mjs";
10
+ const extension = getExtension(configuration, format);
10
11
  const { mainDir, configDir, baseDir } = configuration.content;
11
12
  const dictionariesPath = join(mainDir, `dictionaries.${extension}`);
12
13
  const relativeDictionariesPath = relative(baseDir, dictionariesPath);