@intlayer/config 7.5.13 → 7.6.0-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 (56) hide show
  1. package/dist/cjs/_virtual/rolldown_runtime.cjs +2 -2
  2. package/dist/cjs/built.cjs.map +1 -1
  3. package/dist/cjs/configFile/buildConfigurationFields.cjs +1 -0
  4. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  5. package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
  6. package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
  7. package/dist/cjs/defaultValues/build.cjs +1 -1
  8. package/dist/cjs/defaultValues/build.cjs.map +1 -1
  9. package/dist/cjs/defaultValues/content.cjs +1 -1
  10. package/dist/cjs/defaultValues/dictionary.cjs +2 -0
  11. package/dist/cjs/defaultValues/dictionary.cjs.map +1 -1
  12. package/dist/cjs/defaultValues/editor.cjs +1 -1
  13. package/dist/cjs/defaultValues/index.cjs +1 -1
  14. package/dist/cjs/defaultValues/internationalization.cjs +1 -1
  15. package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
  16. package/dist/cjs/defaultValues/log.cjs +1 -1
  17. package/dist/cjs/defaultValues/routing.cjs +1 -1
  18. package/dist/cjs/defaultValues/routing.cjs.map +1 -1
  19. package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
  20. package/dist/cjs/loadExternalFile/parseFileContent.cjs.map +1 -1
  21. package/dist/cjs/logger.cjs.map +1 -1
  22. package/dist/cjs/retryManager.cjs.map +1 -1
  23. package/dist/cjs/utils/ESMxCJSHelpers.cjs.map +1 -1
  24. package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
  25. package/dist/cjs/utils/cacheMemory.cjs.map +1 -1
  26. package/dist/esm/_virtual/rolldown_runtime.mjs +2 -2
  27. package/dist/esm/built.mjs.map +1 -1
  28. package/dist/esm/configFile/buildConfigurationFields.mjs +2 -1
  29. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  30. package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
  31. package/dist/esm/configFile/searchConfigurationFile.mjs.map +1 -1
  32. package/dist/esm/defaultValues/build.mjs +2 -2
  33. package/dist/esm/defaultValues/build.mjs.map +1 -1
  34. package/dist/esm/defaultValues/content.mjs +2 -2
  35. package/dist/esm/defaultValues/dictionary.mjs +2 -1
  36. package/dist/esm/defaultValues/dictionary.mjs.map +1 -1
  37. package/dist/esm/defaultValues/editor.mjs +2 -2
  38. package/dist/esm/defaultValues/index.mjs +2 -2
  39. package/dist/esm/defaultValues/internationalization.mjs +2 -2
  40. package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
  41. package/dist/esm/defaultValues/log.mjs +2 -2
  42. package/dist/esm/defaultValues/routing.mjs +2 -2
  43. package/dist/esm/defaultValues/routing.mjs.map +1 -1
  44. package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
  45. package/dist/esm/loadExternalFile/parseFileContent.mjs.map +1 -1
  46. package/dist/esm/logger.mjs.map +1 -1
  47. package/dist/esm/retryManager.mjs.map +1 -1
  48. package/dist/esm/utils/ESMxCJSHelpers.mjs.map +1 -1
  49. package/dist/esm/utils/cacheDisk.mjs.map +1 -1
  50. package/dist/esm/utils/cacheMemory.mjs.map +1 -1
  51. package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
  52. package/dist/types/defaultValues/dictionary.d.ts +4 -1
  53. package/dist/types/defaultValues/dictionary.d.ts.map +1 -1
  54. package/dist/types/loadExternalFile/transpileTSToCJS.d.ts.map +1 -1
  55. package/dist/types/utils/cacheMemory.d.ts.map +1 -1
  56. package/package.json +6 -6
@@ -5,7 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (all, symbols) => {
8
+ var __exportAll = (all, symbols) => {
9
9
  let target = {};
10
10
  for (var name in all) {
11
11
  __defProp(target, name, {
@@ -39,5 +39,5 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
39
39
 
40
40
  //#endregion
41
41
 
42
- exports.__export = __export;
42
+ exports.__exportAll = __exportAll;
43
43
  exports.__toESM = __toESM;
@@ -1 +1 @@
1
- {"version":3,"file":"built.cjs","names":["configuration: IntlayerConfig","getConfiguration"],"sources":["../../src/built.ts"],"sourcesContent":["/**\n * @intlayer/config/built is a package that only returns the configuration file as a JSON object.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n */\n\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { getConfiguration } from './configFile/getConfiguration';\n\nconst configuration: IntlayerConfig = getConfiguration();\n\nexport default configuration;\n"],"mappings":";;;AAQA,MAAMA,gBAAgCC,sDAAkB;AAExD,oBAAe"}
1
+ {"version":3,"file":"built.cjs","names":["getConfiguration"],"sources":["../../src/built.ts"],"sourcesContent":["/**\n * @intlayer/config/built is a package that only returns the configuration file as a JSON object.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n */\n\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { getConfiguration } from './configFile/getConfiguration';\n\nconst configuration: IntlayerConfig = getConfiguration();\n\nexport default configuration;\n"],"mappings":";;;AAQA,MAAM,gBAAgCA,sDAAkB;AAExD,oBAAe"}
@@ -119,6 +119,7 @@ const buildCompilerFields = (customConfiguration) => ({
119
119
  });
120
120
  const buildDictionaryFields = (customConfiguration) => ({
121
121
  fill: customConfiguration?.fill ?? require_defaultValues_dictionary.FILL,
122
+ location: customConfiguration?.location ?? require_defaultValues_dictionary.LOCATION,
122
123
  locale: customConfiguration?.locale,
123
124
  title: customConfiguration?.title,
124
125
  description: customConfiguration?.description,
@@ -1 +1 @@
1
- {"version":3,"file":"buildConfigurationFields.cjs","names":["storedConfiguration: IntlayerConfig","LOCALES","REQUIRED_LOCALES","STRICT_MODE","DEFAULT_LOCALE","ROUTING_MODE","STORAGE","BASE_PATH","notDerivedContentConfig: BaseContentConfig","FILE_EXTENSIONS","EXCLUDED_PATHS","WATCH","absolutePath: string","baseDirDerivedConfiguration: BaseDerivedConfig","CONTENT_DIR","MODULE_AUGMENTATION_DIR","UNMERGED_DICTIONARIES_DIR","REMOTE_DICTIONARIES_DIR","DICTIONARIES_DIR","DYNAMIC_DICTIONARIES_DIR","FETCH_DICTIONARIES_DIR","TYPES_DIR","MAIN_DIR","CONFIG_DIR","CACHE_DIR","patternsConfiguration: PatternsContentConfig","normalizePath","APPLICATION_URL","EDITOR_URL","CMS_URL","BACKEND_URL","PORT","IS_ENABLED","DICTIONARY_PRIORITY_STRATEGY","LIVE_SYNC","LIVE_SYNC_PORT","MODE","PREFIX","BUILD_MODE","IMPORT_MODE","TRAVERSE_PATTERN","OUTPUT_FORMAT","CACHE","COMPILER_ENABLED","COMPILER_TRANSFORM_PATTERN","COMPILER_EXCLUDE_PATTERN","COMPILER_OUTPUT_DIR","FILL","packageJson"],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { statSync } from 'node:fs';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport type {\n AiConfig,\n BaseContentConfig,\n BaseDerivedConfig,\n BuildConfig,\n CompilerConfig,\n ContentConfig,\n CustomIntlayerConfig,\n DictionaryConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n LogFunctions,\n PatternsContentConfig,\n RoutingConfig,\n} from '@intlayer/types';\nimport packageJson from '@intlayer/types/package.json' with { type: 'json' };\nimport {\n BUILD_MODE,\n CACHE,\n IMPORT_MODE,\n OUTPUT_FORMAT,\n TRAVERSE_PATTERN,\n} from '../defaultValues/build';\nimport {\n COMPILER_ENABLED,\n COMPILER_EXCLUDE_PATTERN,\n COMPILER_OUTPUT_DIR,\n COMPILER_TRANSFORM_PATTERN,\n} from '../defaultValues/compiler';\nimport {\n CACHE_DIR,\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 { FILL } from '../defaultValues/dictionary';\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 { BASE_PATH, ROUTING_MODE, STORAGE } from '../defaultValues/routing';\nimport { normalizePath } from '../utils/normalizePath';\n\nlet storedConfiguration: IntlayerConfig;\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 buildRoutingFields = (\n customConfiguration?: Partial<RoutingConfig>\n): RoutingConfig => ({\n /**\n * URL routing mode for locale handling\n *\n * Controls how locales are represented in application URLs:\n * - 'prefix-no-default': Prefix all locales except the default locale (default)\n * - en → /dashboard\n * - fr → /fr/dashboard\n *\n * - 'prefix-all': Prefix all locales including the default locale\n * - en → /en/dashboard\n * - fr → /fr/dashboard\n *\n * - 'search-params': Use search parameters for locale handling\n * - en → /dashboard?locale=en\n * - fr → /fr/dashboard?locale=fr\n *\n * - 'no-prefix': No locale prefixing in URLs\n * - en → /dashboard\n * - fr → /dashboard\n *\n * Default: 'prefix-no-default'\n */\n mode: customConfiguration?.mode ?? ROUTING_MODE,\n\n /**\n * Configuration for storing the locale in the client (localStorage or sessionStorage)\n *\n * If false, the locale will not be stored by the middleware.\n * If true, the locale storage will consider all default values. (cookie and header)\n *\n * Default: ['cookie', 'header']\n *\n */\n storage: customConfiguration?.storage ?? STORAGE,\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\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/**', '**\\/dist/**', '**\\/build/**', '**\\/.intlayer/**', '**\\/.next/**', '**\\/.nuxt/**', '**\\/.expo/**', '**\\/.vercel/**', '**\\/.turbo/**', '**\\/.tanstack/**']\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 * Command to format the content. When intlayer write your .content files locally, this command will be used to format the content.\n * Intlayer will replace the {{file}} with the path of the file to format.\n *\n * If not set, Intlayer will try to detect the format command automatically. By trying to resolve the following commands: prettier, biome, eslint.\n *\n * Example:\n *\n * ```bash\n * npx prettier --write {{file}}\n * ```\n *\n * ```bash\n * bunx biome format {{file}}\n * ```\n *\n * ```bash\n * bun format {{file}}\n * ```\n *\n * ```bash\n * npx eslint --fix {{file}}\n * ```\n *\n * Default: undefined\n */\n formatCommand: customConfiguration?.formatCommand,\n };\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n // Try resolving as a Node module first (e.g. '@intlayer/design-system')\n // Passing { paths: [...] } ensures we look starting from your project baseDir\n absolutePath = require.resolve(pathInput, {\n paths: [notDerivedContentConfig.baseDir],\n });\n } catch {\n // If resolution fails (it's not a module or it's a relative path like './src'),\n // fall back to standard path joining.\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(notDerivedContentConfig.baseDir, pathInput);\n }\n\n try {\n // Smart Detection: File vs Directory\n const stats = statSync(absolutePath);\n\n // If it resolved to a file (like package.json \"main\" or index.js),\n // we want the FOLDER containing that file.\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n // Safety Fallback:\n // If statSync fails but it looks like a file (has an extension), strip it.\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n // Return the calculated path (usually a directory)\n return absolutePath;\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 optionalJoinBaseDir\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: optionalJoinBaseDir(\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n\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: optionalJoinBaseDir(\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: optionalJoinBaseDir(\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: optionalJoinBaseDir(\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: optionalJoinBaseDir(\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: optionalJoinBaseDir(\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: optionalJoinBaseDir(customConfiguration?.typesDir ?? TYPES_DIR),\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: optionalJoinBaseDir(customConfiguration?.mainDir ?? MAIN_DIR),\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: optionalJoinBaseDir(\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n\n /**\n * Directory where the cache files are stored, relative to the result directory\n *\n * Default: .intlayer/cache\n */\n cacheDir: optionalJoinBaseDir(customConfiguration?.cacheDir ?? CACHE_DIR),\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 baseDirDerivedConfiguration.dictionariesDir\n )}/**/*.json`,\n };\n\n return {\n ...notDerivedContentConfig,\n ...baseDirDerivedConfiguration,\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://app.intlayer.org/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://app.intlayer.org/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientSecret: customConfiguration?.clientSecret ?? undefined,\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy:\n customConfiguration?.dictionaryPriorityStrategy ??\n DICTIONARY_PRIORITY_STRATEGY,\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * The hot reload is only available for clients of the `enterprise` plan.\n *\n * Default: false\n */\n liveSync: customConfiguration?.liveSync ?? LIVE_SYNC,\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT,\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${LIVE_SYNC_PORT}`\n */\n liveSyncURL:\n customConfiguration?.liveSyncURL ??\n `http://localhost:${customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT}`,\n});\n\nconst buildLogFields = (\n customConfiguration?: Partial<LogConfig>,\n logFunctions?: LogFunctions\n): LogConfig => ({\n /**\n * Indicates if the logger is enabled\n *\n * Default: 'prefix-no-default'\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: customConfiguration?.mode ?? MODE,\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: customConfiguration?.prefix ?? PREFIX,\n\n /**\n * Functions to log\n */\n error: logFunctions?.error,\n log: logFunctions?.log,\n info: logFunctions?.info,\n warn: logFunctions?.warn,\n});\n\nconst buildAiFields = (customConfiguration?: Partial<AiConfig>): AiConfig => ({\n /**\n * AI configuration\n */\n provider: customConfiguration?.provider,\n\n /**\n * API key\n */\n apiKey: customConfiguration?.apiKey,\n\n /**\n * API model\n */\n model: customConfiguration?.model,\n\n /**\n * Temperature\n */\n temperature: customConfiguration?.temperature,\n\n /**\n * Application context\n *\n * Default: undefined\n *\n * The application context.\n *\n * Example: `'My application context'`\n *\n * Note: Can be used to provide additional context about the application to the AI model. You can add more rules (e.g. \"You should not transform urls\").\n */\n applicationContext: customConfiguration?.applicationContext,\n\n /**\n * Base URL for the AI API\n *\n * Default: undefined\n *\n * The base URL for the AI API.\n *\n * Example: `'http://localhost:5000'`\n *\n * Note: Can be used to point to a local, or custom AI API endpoint.\n */\n baseURL: customConfiguration?.baseURL,\n});\n\nconst buildBuildFields = (\n customConfiguration?: Partial<BuildConfig>\n): BuildConfig => ({\n /**\n * Indicates the mode of the build\n *\n * Default: 'auto'\n *\n * If 'auto', the build will be enabled automatically when the application is built.\n * If 'manual', the build will be set only when the build command is executed.\n *\n * Can be used to disable dictionaries build, for instance when execution on Node.js environment should be avoided.\n */\n mode: customConfiguration?.mode ?? BUILD_MODE,\n\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,\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 disabled 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 * Cache\n */\n cache: customConfiguration?.cache ?? CACHE,\n\n /**\n * Require function\n */\n require: customConfiguration?.require,\n});\n\nconst buildCompilerFields = (\n customConfiguration?: Partial<CompilerConfig>\n): CompilerConfig => ({\n /**\n * Indicates if the compiler should be enabled\n */\n enabled: customConfiguration?.enabled ?? COMPILER_ENABLED,\n\n /**\n * Pattern to traverse the code to optimize.\n */\n transformPattern:\n customConfiguration?.transformPattern ?? COMPILER_TRANSFORM_PATTERN,\n\n /**\n * Pattern to exclude from the optimization.\n */\n excludePattern:\n customConfiguration?.excludePattern ?? COMPILER_EXCLUDE_PATTERN,\n\n /**\n * Output directory for the optimized dictionaries.\n */\n outputDir: customConfiguration?.outputDir ?? COMPILER_OUTPUT_DIR,\n});\n\nconst buildDictionaryFields = (\n customConfiguration?: Partial<DictionaryConfig>\n): DictionaryConfig => ({\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: true\n */\n fill: customConfiguration?.fill ?? FILL,\n\n /**\n * Transform the dictionary in a per-locale dictionary.\n * Each field declared in a per-locale dictionary will be transformed in a translation node.\n * If missing, the dictionary will be treated as a multilingual dictionary.\n */\n locale: customConfiguration?.locale,\n\n /**\n * The title of the dictionary.\n */\n title: customConfiguration?.title,\n\n /**\n * The description of the dictionary.\n */\n description: customConfiguration?.description,\n\n /**\n * Tags to categorize the dictionaries.\n */\n tags: customConfiguration?.tags,\n\n /**\n * The priority of the dictionary.\n */\n priority: customConfiguration?.priority,\n\n /**\n * Indicates if the dictionary should be live synced.\n */\n live: customConfiguration?.live,\n\n /**\n * The version of the dictionary.\n */\n version: customConfiguration?.version,\n});\n\n/**\n * Build the configuration fields by merging the default values with the custom configuration\n */\nexport const buildConfigurationFields = (\n customConfiguration?: CustomIntlayerConfig,\n baseDir?: string,\n logFunctions?: LogFunctions\n): IntlayerConfig => {\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const routingConfig = buildRoutingFields(customConfiguration?.routing);\n\n const contentConfig = buildContentFields(\n customConfiguration?.content,\n baseDir\n );\n\n const editorConfig = buildEditorFields(customConfiguration?.editor);\n\n const logConfig = buildLogFields(customConfiguration?.log, logFunctions);\n\n const aiConfig = buildAiFields(customConfiguration?.ai);\n\n const buildConfig = buildBuildFields(customConfiguration?.build);\n\n const compilerConfig = buildCompilerFields(customConfiguration?.compiler);\n\n const dictionaryConfig = buildDictionaryFields(\n customConfiguration?.dictionary\n );\n\n storedConfiguration = {\n internationalization: internationalizationConfig,\n routing: routingConfig,\n content: contentConfig,\n editor: editorConfig,\n log: logConfig,\n ai: aiConfig,\n build: buildConfig,\n compiler: compilerConfig,\n dictionary: dictionaryConfig,\n plugins: customConfiguration?.plugins,\n metadata: {\n name: 'Intlayer',\n version: packageJson.version,\n doc: `https://intlayer.org/docs`,\n },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ASE_PATH","FILE_EXTENSIONS","EXCLUDED_PATHS","WATCH","CONTENT_DIR","MODULE_AUGMENTATION_DIR","UNMERGED_DICTIONARIES_DIR","REMOTE_DICTIONARIES_DIR","DICTIONARIES_DIR","DYNAMIC_DICTIONARIES_DIR","FETCH_DICTIONARIES_DIR","TYPES_DIR","MAIN_DIR","CONFIG_DIR","CACHE_DIR","normalizePath","APPLICATION_URL","EDITOR_URL","CMS_URL","BACKEND_URL","PORT","IS_ENABLED","DICTIONARY_PRIORITY_STRATEGY","LIVE_SYNC","LIVE_SYNC_PORT","MODE","PREFIX","BUILD_MODE","IMPORT_MODE","TRAVERSE_PATTERN","OUTPUT_FORMAT","CACHE","COMPILER_ENABLED","COMPILER_TRANSFORM_PATTERN","COMPILER_EXCLUDE_PATTERN","COMPILER_OUTPUT_DIR","FILL","LOCATION","packageJson"],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { statSync } from 'node:fs';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport type {\n AiConfig,\n BaseContentConfig,\n BaseDerivedConfig,\n BuildConfig,\n CompilerConfig,\n ContentConfig,\n CustomIntlayerConfig,\n DictionaryConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n LogFunctions,\n PatternsContentConfig,\n RoutingConfig,\n} from '@intlayer/types';\nimport packageJson from '@intlayer/types/package.json' with { type: 'json' };\nimport {\n BUILD_MODE,\n CACHE,\n IMPORT_MODE,\n OUTPUT_FORMAT,\n TRAVERSE_PATTERN,\n} from '../defaultValues/build';\nimport {\n COMPILER_ENABLED,\n COMPILER_EXCLUDE_PATTERN,\n COMPILER_OUTPUT_DIR,\n COMPILER_TRANSFORM_PATTERN,\n} from '../defaultValues/compiler';\nimport {\n CACHE_DIR,\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 { FILL, LOCATION } from '../defaultValues/dictionary';\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 { BASE_PATH, ROUTING_MODE, STORAGE } from '../defaultValues/routing';\nimport { normalizePath } from '../utils/normalizePath';\n\nlet storedConfiguration: IntlayerConfig;\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 buildRoutingFields = (\n customConfiguration?: Partial<RoutingConfig>\n): RoutingConfig => ({\n /**\n * URL routing mode for locale handling\n *\n * Controls how locales are represented in application URLs:\n * - 'prefix-no-default': Prefix all locales except the default locale (default)\n * - en → /dashboard\n * - fr → /fr/dashboard\n *\n * - 'prefix-all': Prefix all locales including the default locale\n * - en → /en/dashboard\n * - fr → /fr/dashboard\n *\n * - 'search-params': Use search parameters for locale handling\n * - en → /dashboard?locale=en\n * - fr → /fr/dashboard?locale=fr\n *\n * - 'no-prefix': No locale prefixing in URLs\n * - en → /dashboard\n * - fr → /dashboard\n *\n * Default: 'prefix-no-default'\n */\n mode: customConfiguration?.mode ?? ROUTING_MODE,\n\n /**\n * Configuration for storing the locale in the client (localStorage or sessionStorage)\n *\n * If false, the locale will not be stored by the middleware.\n * If true, the locale storage will consider all default values. (cookie and header)\n *\n * Default: ['cookie', 'header']\n *\n */\n storage: customConfiguration?.storage ?? STORAGE,\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\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/**', '**\\/dist/**', '**\\/build/**', '**\\/.intlayer/**', '**\\/.next/**', '**\\/.nuxt/**', '**\\/.expo/**', '**\\/.vercel/**', '**\\/.turbo/**', '**\\/.tanstack/**']\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 * Command to format the content. When intlayer write your .content files locally, this command will be used to format the content.\n * Intlayer will replace the {{file}} with the path of the file to format.\n *\n * If not set, Intlayer will try to detect the format command automatically. By trying to resolve the following commands: prettier, biome, eslint.\n *\n * Example:\n *\n * ```bash\n * npx prettier --write {{file}}\n * ```\n *\n * ```bash\n * bunx biome format {{file}}\n * ```\n *\n * ```bash\n * bun format {{file}}\n * ```\n *\n * ```bash\n * npx eslint --fix {{file}}\n * ```\n *\n * Default: undefined\n */\n formatCommand: customConfiguration?.formatCommand,\n };\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n // Try resolving as a Node module first (e.g. '@intlayer/design-system')\n // Passing { paths: [...] } ensures we look starting from your project baseDir\n absolutePath = require.resolve(pathInput, {\n paths: [notDerivedContentConfig.baseDir],\n });\n } catch {\n // If resolution fails (it's not a module or it's a relative path like './src'),\n // fall back to standard path joining.\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(notDerivedContentConfig.baseDir, pathInput);\n }\n\n try {\n // Smart Detection: File vs Directory\n const stats = statSync(absolutePath);\n\n // If it resolved to a file (like package.json \"main\" or index.js),\n // we want the FOLDER containing that file.\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n // Safety Fallback:\n // If statSync fails but it looks like a file (has an extension), strip it.\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n // Return the calculated path (usually a directory)\n return absolutePath;\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 optionalJoinBaseDir\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: optionalJoinBaseDir(\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n\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: optionalJoinBaseDir(\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: optionalJoinBaseDir(\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: optionalJoinBaseDir(\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: optionalJoinBaseDir(\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: optionalJoinBaseDir(\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: optionalJoinBaseDir(customConfiguration?.typesDir ?? TYPES_DIR),\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: optionalJoinBaseDir(customConfiguration?.mainDir ?? MAIN_DIR),\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: optionalJoinBaseDir(\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n\n /**\n * Directory where the cache files are stored, relative to the result directory\n *\n * Default: .intlayer/cache\n */\n cacheDir: optionalJoinBaseDir(customConfiguration?.cacheDir ?? CACHE_DIR),\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 baseDirDerivedConfiguration.dictionariesDir\n )}/**/*.json`,\n };\n\n return {\n ...notDerivedContentConfig,\n ...baseDirDerivedConfiguration,\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://app.intlayer.org/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://app.intlayer.org/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientSecret: customConfiguration?.clientSecret ?? undefined,\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy:\n customConfiguration?.dictionaryPriorityStrategy ??\n DICTIONARY_PRIORITY_STRATEGY,\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * The hot reload is only available for clients of the `enterprise` plan.\n *\n * Default: false\n */\n liveSync: customConfiguration?.liveSync ?? LIVE_SYNC,\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT,\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${LIVE_SYNC_PORT}`\n */\n liveSyncURL:\n customConfiguration?.liveSyncURL ??\n `http://localhost:${customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT}`,\n});\n\nconst buildLogFields = (\n customConfiguration?: Partial<LogConfig>,\n logFunctions?: LogFunctions\n): LogConfig => ({\n /**\n * Indicates if the logger is enabled\n *\n * Default: 'prefix-no-default'\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: customConfiguration?.mode ?? MODE,\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: customConfiguration?.prefix ?? PREFIX,\n\n /**\n * Functions to log\n */\n error: logFunctions?.error,\n log: logFunctions?.log,\n info: logFunctions?.info,\n warn: logFunctions?.warn,\n});\n\nconst buildAiFields = (customConfiguration?: Partial<AiConfig>): AiConfig => ({\n /**\n * AI configuration\n */\n provider: customConfiguration?.provider,\n\n /**\n * API key\n */\n apiKey: customConfiguration?.apiKey,\n\n /**\n * API model\n */\n model: customConfiguration?.model,\n\n /**\n * Temperature\n */\n temperature: customConfiguration?.temperature,\n\n /**\n * Application context\n *\n * Default: undefined\n *\n * The application context.\n *\n * Example: `'My application context'`\n *\n * Note: Can be used to provide additional context about the application to the AI model. You can add more rules (e.g. \"You should not transform urls\").\n */\n applicationContext: customConfiguration?.applicationContext,\n\n /**\n * Base URL for the AI API\n *\n * Default: undefined\n *\n * The base URL for the AI API.\n *\n * Example: `'http://localhost:5000'`\n *\n * Note: Can be used to point to a local, or custom AI API endpoint.\n */\n baseURL: customConfiguration?.baseURL,\n});\n\nconst buildBuildFields = (\n customConfiguration?: Partial<BuildConfig>\n): BuildConfig => ({\n /**\n * Indicates the mode of the build\n *\n * Default: 'auto'\n *\n * If 'auto', the build will be enabled automatically when the application is built.\n * If 'manual', the build will be set only when the build command is executed.\n *\n * Can be used to disable dictionaries build, for instance when execution on Node.js environment should be avoided.\n */\n mode: customConfiguration?.mode ?? BUILD_MODE,\n\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,\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 disabled 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 * Cache\n */\n cache: customConfiguration?.cache ?? CACHE,\n\n /**\n * Require function\n */\n require: customConfiguration?.require,\n});\n\nconst buildCompilerFields = (\n customConfiguration?: Partial<CompilerConfig>\n): CompilerConfig => ({\n /**\n * Indicates if the compiler should be enabled\n */\n enabled: customConfiguration?.enabled ?? COMPILER_ENABLED,\n\n /**\n * Pattern to traverse the code to optimize.\n */\n transformPattern:\n customConfiguration?.transformPattern ?? COMPILER_TRANSFORM_PATTERN,\n\n /**\n * Pattern to exclude from the optimization.\n */\n excludePattern:\n customConfiguration?.excludePattern ?? COMPILER_EXCLUDE_PATTERN,\n\n /**\n * Output directory for the optimized dictionaries.\n */\n outputDir: customConfiguration?.outputDir ?? COMPILER_OUTPUT_DIR,\n});\n\nconst buildDictionaryFields = (\n customConfiguration?: Partial<DictionaryConfig>\n): DictionaryConfig => ({\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: true\n */\n fill: customConfiguration?.fill ?? FILL,\n\n /**\n * The location of the dictionary.\n *\n * Default: 'local'\n */\n location: customConfiguration?.location ?? LOCATION,\n\n /**\n * Transform the dictionary in a per-locale dictionary.\n * Each field declared in a per-locale dictionary will be transformed in a translation node.\n * If missing, the dictionary will be treated as a multilingual dictionary.\n */\n locale: customConfiguration?.locale,\n\n /**\n * The title of the dictionary.\n */\n title: customConfiguration?.title,\n\n /**\n * The description of the dictionary.\n */\n description: customConfiguration?.description,\n\n /**\n * Tags to categorize the dictionaries.\n */\n tags: customConfiguration?.tags,\n\n /**\n * The priority of the dictionary.\n */\n priority: customConfiguration?.priority,\n\n /**\n * Indicates if the dictionary should be live synced.\n */\n live: customConfiguration?.live,\n\n /**\n * The version of the dictionary.\n */\n version: customConfiguration?.version,\n});\n\n/**\n * Build the configuration fields by merging the default values with the custom configuration\n */\nexport const buildConfigurationFields = (\n customConfiguration?: CustomIntlayerConfig,\n baseDir?: string,\n logFunctions?: LogFunctions\n): IntlayerConfig => {\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const routingConfig = buildRoutingFields(customConfiguration?.routing);\n\n const contentConfig = buildContentFields(\n customConfiguration?.content,\n baseDir\n );\n\n const editorConfig = buildEditorFields(customConfiguration?.editor);\n\n const logConfig = buildLogFields(customConfiguration?.log, logFunctions);\n\n const aiConfig = buildAiFields(customConfiguration?.ai);\n\n const buildConfig = buildBuildFields(customConfiguration?.build);\n\n const compilerConfig = buildCompilerFields(customConfiguration?.compiler);\n\n const dictionaryConfig = buildDictionaryFields(\n customConfiguration?.dictionary\n );\n\n storedConfiguration = {\n internationalization: internationalizationConfig,\n routing: routingConfig,\n content: contentConfig,\n editor: editorConfig,\n log: logConfig,\n ai: aiConfig,\n build: buildConfig,\n compiler: compilerConfig,\n dictionary: dictionaryConfig,\n plugins: customConfiguration?.plugins,\n metadata: {\n name: 'Intlayer',\n version: packageJson.version,\n doc: `https://intlayer.org/docs`,\n },\n } as IntlayerConfig;\n\n return storedConfiguration;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ACJ,yBACiB;CAWjB,MAAM,qBAAqB,QAAQC;CAoBnC,UAAU,qBAAqB;CA2B/B,YAAY,qBAAqB,cAAcC;CAgB/C,iBAAiB,qBAAqB,mBAAmBC;CAazD,cAAc,qBAAqB,gBAAgBC;CAKnD,OAAO,qBAAqB,SAASC;CAKrC,SAAS,qBAAqB;CAC/B;AAED,MAAM,uBACJ,yBACoB;CAIpB,SAAS,qBAAqB,WAAWC;CAKzC,kBACE,qBAAqB,oBAAoBC;CAK3C,gBACE,qBAAqB,kBAAkBC;CAKzC,WAAW,qBAAqB,aAAaC;CAC9C;AAED,MAAM,yBACJ,yBACsB;CAMtB,MAAM,qBAAqB,QAAQC;CAOnC,UAAU,qBAAqB,YAAYC;CAO3C,QAAQ,qBAAqB;CAK7B,OAAO,qBAAqB;CAK5B,aAAa,qBAAqB;CAKlC,MAAM,qBAAqB;CAK3B,UAAU,qBAAqB;CAK/B,MAAM,qBAAqB;CAK3B,SAAS,qBAAqB;CAC/B;;;;AAKD,MAAa,4BACX,qBACA,SACA,iBACmB;AA0BnB,uBAAsB;EACpB,sBA1BiC,gCACjC,qBAAqB,qBACtB;EAyBC,SAvBoB,mBAAmB,qBAAqB,QAAQ;EAwBpE,SAtBoB,mBACpB,qBAAqB,SACrB,QACD;EAoBC,QAlBmB,kBAAkB,qBAAqB,OAAO;EAmBjE,KAjBgB,eAAe,qBAAqB,KAAK,aAAa;EAkBtE,IAhBe,cAAc,qBAAqB,GAAG;EAiBrD,OAfkB,iBAAiB,qBAAqB,MAAM;EAgB9D,UAdqB,oBAAoB,qBAAqB,SAAS;EAevE,YAbuB,sBACvB,qBAAqB,WACtB;EAYC,SAAS,qBAAqB;EAC9B,UAAU;GACR,MAAM;GACN,SAASC,qCAAY;GACrB,KAAK;GACN;EACF;AAED,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"getConfiguration.cjs","names":["baseDir: string | undefined","getPackageJsonPath","buildConfigurationFields","cacheMemory","searchConfigurationFile","storedConfiguration: IntlayerConfig","loadConfigurationFile"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types';\nimport { defu } from 'defu';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { logger } from '../logger';\nimport { cacheMemory } from '../utils/cacheMemory';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n // Dotenv options\n env?: string;\n envFile?: string;\n // Log functions\n logFunctions?: LogFunctions;\n // Require function\n require?: NodeJS.Require;\n // cache\n cache?: boolean;\n} & Omit<SandBoxContextOptions, 'projectRequire'>;\n\nexport type GetConfigurationAndFilePathResult = {\n configuration: IntlayerConfig;\n configurationFilePath: string | undefined;\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfigurationAndFilePath = (\n options?: GetConfigurationOptions\n): GetConfigurationAndFilePathResult => {\n let baseDir: string | undefined;\n\n try {\n // Can fail in some environments (e.g. MCP server, VScode extension)\n baseDir = options?.baseDir ?? getPackageJsonPath().baseDir;\n } catch (_err) {\n // Return default config if the package.json is not found\n return {\n configuration: buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions\n ),\n configurationFilePath: undefined,\n };\n }\n\n const cachedConfiguration =\n cacheMemory.get<GetConfigurationAndFilePathResult>(options);\n\n if (cachedConfiguration) return cachedConfiguration;\n\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n if (options?.override?.log?.mode === 'verbose') {\n logConfigFileResult(baseDir, numCustomConfiguration, configurationFilePath);\n }\n\n let storedConfiguration: IntlayerConfig;\n\n if (configurationFilePath) {\n // Load the custom configuration\n const customConfiguration: CustomIntlayerConfig | undefined =\n loadConfigurationFile(configurationFilePath, {\n projectRequire: options?.require,\n // Dotenv options\n envVarOptions: {\n env: options?.env,\n envFile: options?.envFile,\n },\n // Sandbox context additional variables\n additionalEnvVars: options?.additionalEnvVars,\n aliases: options?.aliases,\n });\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n customConfiguration,\n options?.baseDir,\n options?.logFunctions\n );\n } else {\n // No configuration file found, use default configuration\n storedConfiguration = buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions\n );\n }\n\n // Log warning if multiple configuration files are found\n\n const projectRequireConfig: CustomIntlayerConfig = options?.require\n ? {\n build: {\n require: options?.require,\n cache: options?.cache,\n },\n }\n : {};\n\n const configWithProjectRequire = defu(\n projectRequireConfig,\n storedConfiguration\n ) as IntlayerConfig;\n\n const configuration = defu(\n options?.override ?? {},\n configWithProjectRequire\n ) as IntlayerConfig;\n\n cacheMemory.set(options, {\n configuration,\n configurationFilePath,\n });\n\n return {\n configuration,\n configurationFilePath,\n };\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfiguration = (\n options?: GetConfigurationOptions\n): IntlayerConfig => getConfigurationAndFilePath(options).configuration;\n\nconst logConfigFileResult = (\n baseDir: string,\n numCustomConfiguration?: number,\n configurationFilePath?: string\n) => {\n if (numCustomConfiguration === 0) {\n logger('Configuration file not found, using default configuration.', {\n isVerbose: true,\n });\n } else {\n const relativeOutputPath = relative(baseDir, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n logger(`Configuration file found: ${relativeOutputPath}.`, {\n isVerbose: true,\n });\n } else {\n logger(\n `Multiple configuration files found, using ${relativeOutputPath}.`,\n {\n isVerbose: true,\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAqCA,MAAa,+BACX,YACsC;CACtC,IAAIA;AAEJ,KAAI;AAEF,YAAU,SAAS,WAAWC,qDAAoB,CAAC;UAC5C,MAAM;AAEb,SAAO;GACL,eAAeC,qEACb,EAAE,EACF,SAAS,SACT,SAAS,aACV;GACD,uBAAuB;GACxB;;CAGH,MAAM,sBACJC,sCAAY,IAAuC,QAAQ;AAE7D,KAAI,oBAAqB,QAAO;CAGhC,MAAM,EAAE,uBAAuB,2BAC7BC,mEAAwB,QAAQ;AAElC,KAAI,SAAS,UAAU,KAAK,SAAS,UACnC,qBAAoB,SAAS,wBAAwB,sBAAsB;CAG7E,IAAIC;AAEJ,KAAI,sBAgBF,uBAAsBH,qEAbpBI,+DAAsB,uBAAuB;EAC3C,gBAAgB,SAAS;EAEzB,eAAe;GACb,KAAK,SAAS;GACd,SAAS,SAAS;GACnB;EAED,mBAAmB,SAAS;EAC5B,SAAS,SAAS;EACnB,CAAC,EAKF,SAAS,SACT,SAAS,aACV;KAGD,uBAAsBJ,qEACpB,EAAE,EACF,SAAS,SACT,SAAS,aACV;CAcH,MAAM,0CAT6C,SAAS,UACxD,EACE,OAAO;EACL,SAAS,SAAS;EAClB,OAAO,SAAS;EACjB,EACF,GACD,EAAE,EAIJ,oBACD;CAED,MAAM,+BACJ,SAAS,YAAY,EAAE,EACvB,yBACD;AAED,uCAAY,IAAI,SAAS;EACvB;EACA;EACD,CAAC;AAEF,QAAO;EACL;EACA;EACD;;;;;AAMH,MAAa,oBACX,YACmB,4BAA4B,QAAQ,CAAC;AAE1D,MAAM,uBACJ,SACA,wBACA,0BACG;AACH,KAAI,2BAA2B,EAC7B,uBAAO,8DAA8D,EACnE,WAAW,MACZ,CAAC;MACG;EACL,MAAM,6CAA8B,SAAS,sBAAuB;AAEpE,MAAI,2BAA2B,EAC7B,uBAAO,6BAA6B,mBAAmB,IAAI,EACzD,WAAW,MACZ,CAAC;MAEF,uBACE,6CAA6C,mBAAmB,IAChE,EACE,WAAW,MACZ,CACF"}
1
+ {"version":3,"file":"getConfiguration.cjs","names":["getPackageJsonPath","buildConfigurationFields","cacheMemory","searchConfigurationFile","loadConfigurationFile"],"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n LogFunctions,\n} from '@intlayer/types';\nimport { defu } from 'defu';\nimport type { SandBoxContextOptions } from '../loadExternalFile/parseFileContent';\nimport { logger } from '../logger';\nimport { cacheMemory } from '../utils/cacheMemory';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nexport type GetConfigurationOptions = {\n baseDir?: string;\n override?: CustomIntlayerConfig;\n // Dotenv options\n env?: string;\n envFile?: string;\n // Log functions\n logFunctions?: LogFunctions;\n // Require function\n require?: NodeJS.Require;\n // cache\n cache?: boolean;\n} & Omit<SandBoxContextOptions, 'projectRequire'>;\n\nexport type GetConfigurationAndFilePathResult = {\n configuration: IntlayerConfig;\n configurationFilePath: string | undefined;\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfigurationAndFilePath = (\n options?: GetConfigurationOptions\n): GetConfigurationAndFilePathResult => {\n let baseDir: string | undefined;\n\n try {\n // Can fail in some environments (e.g. MCP server, VScode extension)\n baseDir = options?.baseDir ?? getPackageJsonPath().baseDir;\n } catch (_err) {\n // Return default config if the package.json is not found\n return {\n configuration: buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions\n ),\n configurationFilePath: undefined,\n };\n }\n\n const cachedConfiguration =\n cacheMemory.get<GetConfigurationAndFilePathResult>(options);\n\n if (cachedConfiguration) return cachedConfiguration;\n\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n if (options?.override?.log?.mode === 'verbose') {\n logConfigFileResult(baseDir, numCustomConfiguration, configurationFilePath);\n }\n\n let storedConfiguration: IntlayerConfig;\n\n if (configurationFilePath) {\n // Load the custom configuration\n const customConfiguration: CustomIntlayerConfig | undefined =\n loadConfigurationFile(configurationFilePath, {\n projectRequire: options?.require,\n // Dotenv options\n envVarOptions: {\n env: options?.env,\n envFile: options?.envFile,\n },\n // Sandbox context additional variables\n additionalEnvVars: options?.additionalEnvVars,\n aliases: options?.aliases,\n });\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n customConfiguration,\n options?.baseDir,\n options?.logFunctions\n );\n } else {\n // No configuration file found, use default configuration\n storedConfiguration = buildConfigurationFields(\n {},\n options?.baseDir,\n options?.logFunctions\n );\n }\n\n // Log warning if multiple configuration files are found\n\n const projectRequireConfig: CustomIntlayerConfig = options?.require\n ? {\n build: {\n require: options?.require,\n cache: options?.cache,\n },\n }\n : {};\n\n const configWithProjectRequire = defu(\n projectRequireConfig,\n storedConfiguration\n ) as IntlayerConfig;\n\n const configuration = defu(\n options?.override ?? {},\n configWithProjectRequire\n ) as IntlayerConfig;\n\n cacheMemory.set(options, {\n configuration,\n configurationFilePath,\n });\n\n return {\n configuration,\n configurationFilePath,\n };\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfiguration = (\n options?: GetConfigurationOptions\n): IntlayerConfig => getConfigurationAndFilePath(options).configuration;\n\nconst logConfigFileResult = (\n baseDir: string,\n numCustomConfiguration?: number,\n configurationFilePath?: string\n) => {\n if (numCustomConfiguration === 0) {\n logger('Configuration file not found, using default configuration.', {\n isVerbose: true,\n });\n } else {\n const relativeOutputPath = relative(baseDir, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n logger(`Configuration file found: ${relativeOutputPath}.`, {\n isVerbose: true,\n });\n } else {\n logger(\n `Multiple configuration files found, using ${relativeOutputPath}.`,\n {\n isVerbose: true,\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAqCA,MAAa,+BACX,YACsC;CACtC,IAAI;AAEJ,KAAI;AAEF,YAAU,SAAS,WAAWA,qDAAoB,CAAC;UAC5C,MAAM;AAEb,SAAO;GACL,eAAeC,qEACb,EAAE,EACF,SAAS,SACT,SAAS,aACV;GACD,uBAAuB;GACxB;;CAGH,MAAM,sBACJC,sCAAY,IAAuC,QAAQ;AAE7D,KAAI,oBAAqB,QAAO;CAGhC,MAAM,EAAE,uBAAuB,2BAC7BC,mEAAwB,QAAQ;AAElC,KAAI,SAAS,UAAU,KAAK,SAAS,UACnC,qBAAoB,SAAS,wBAAwB,sBAAsB;CAG7E,IAAI;AAEJ,KAAI,sBAgBF,uBAAsBF,qEAbpBG,+DAAsB,uBAAuB;EAC3C,gBAAgB,SAAS;EAEzB,eAAe;GACb,KAAK,SAAS;GACd,SAAS,SAAS;GACnB;EAED,mBAAmB,SAAS;EAC5B,SAAS,SAAS;EACnB,CAAC,EAKF,SAAS,SACT,SAAS,aACV;KAGD,uBAAsBH,qEACpB,EAAE,EACF,SAAS,SACT,SAAS,aACV;CAcH,MAAM,0CAT6C,SAAS,UACxD,EACE,OAAO;EACL,SAAS,SAAS;EAClB,OAAO,SAAS;EACjB,EACF,GACD,EAAE,EAIJ,oBACD;CAED,MAAM,+BACJ,SAAS,YAAY,EAAE,EACvB,yBACD;AAED,uCAAY,IAAI,SAAS;EACvB;EACA;EACD,CAAC;AAEF,QAAO;EACL;EACA;EACD;;;;;AAMH,MAAa,oBACX,YACmB,4BAA4B,QAAQ,CAAC;AAE1D,MAAM,uBACJ,SACA,wBACA,0BACG;AACH,KAAI,2BAA2B,EAC7B,uBAAO,8DAA8D,EACnE,WAAW,MACZ,CAAC;MACG;EACL,MAAM,6CAA8B,SAAS,sBAAuB;AAEpE,MAAI,2BAA2B,EAC7B,uBAAO,6BAA6B,mBAAmB,IAAI,EACzD,WAAW,MACZ,CAAC;MAEF,uBACE,6CAA6C,mBAAmB,IAChE,EACE,WAAW,MACZ,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"searchConfigurationFile.cjs","names":["configurationFilePath: string | undefined","getPackageJsonPath"],"sources":["../../../src/configFile/searchConfigurationFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { logger } from '../logger';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\n\nexport const configurationFilesCandidates = [\n 'intlayer.config.ts',\n 'intlayer.config.js',\n 'intlayer.config.json',\n 'intlayer.config.json5',\n 'intlayer.config.jsonc',\n 'intlayer.config.cjs',\n 'intlayer.config.mjs',\n '.intlayerrc',\n] as const;\n\ntype SearchConfigurationFileResult = {\n configurationFilePath?: string;\n numCustomConfiguration: number;\n};\n\n/**\n * Search for the configuration file in the given path\n *\n * List of detected configuration files:\n * - intlayer.config.ts\n * - intlayer.config.js\n * - intlayer.config.json\n * - intlayer.config.cjs\n * - intlayer.config.mjs\n * - .intlayerrc\n */\nexport const searchConfigurationFile = (\n startDir: string\n): SearchConfigurationFileResult => {\n let configurationFilePath: string | undefined;\n let numCustomConfiguration = 0;\n\n const { baseDir } = getPackageJsonPath(startDir);\n\n for (const fileName of configurationFilesCandidates) {\n try {\n const filePath = resolve(baseDir, fileName);\n\n // Check if the file exists\n if (!existsSync(filePath)) {\n } else {\n numCustomConfiguration += 1;\n\n if (!configurationFilePath) {\n configurationFilePath = filePath;\n }\n }\n } catch (error) {\n // Return \"Cannot use import statement outside a module\"\n logger(`${fileName}: ${error as string}`, { level: 'error' });\n }\n }\n\n return { configurationFilePath, numCustomConfiguration };\n};\n"],"mappings":";;;;;;;AAKA,MAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;;;AAkBD,MAAa,2BACX,aACkC;CAClC,IAAIA;CACJ,IAAI,yBAAyB;CAE7B,MAAM,EAAE,YAAYC,oDAAmB,SAAS;AAEhD,MAAK,MAAM,YAAY,6BACrB,KAAI;EACF,MAAM,kCAAmB,SAAS,SAAS;AAG3C,MAAI,yBAAY,SAAS,EAAE,QACpB;AACL,6BAA0B;AAE1B,OAAI,CAAC,sBACH,yBAAwB;;UAGrB,OAAO;AAEd,wBAAO,GAAG,SAAS,IAAI,SAAmB,EAAE,OAAO,SAAS,CAAC;;AAIjE,QAAO;EAAE;EAAuB;EAAwB"}
1
+ {"version":3,"file":"searchConfigurationFile.cjs","names":["getPackageJsonPath"],"sources":["../../../src/configFile/searchConfigurationFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { logger } from '../logger';\nimport { getPackageJsonPath } from '../utils/getPackageJsonPath';\n\nexport const configurationFilesCandidates = [\n 'intlayer.config.ts',\n 'intlayer.config.js',\n 'intlayer.config.json',\n 'intlayer.config.json5',\n 'intlayer.config.jsonc',\n 'intlayer.config.cjs',\n 'intlayer.config.mjs',\n '.intlayerrc',\n] as const;\n\ntype SearchConfigurationFileResult = {\n configurationFilePath?: string;\n numCustomConfiguration: number;\n};\n\n/**\n * Search for the configuration file in the given path\n *\n * List of detected configuration files:\n * - intlayer.config.ts\n * - intlayer.config.js\n * - intlayer.config.json\n * - intlayer.config.cjs\n * - intlayer.config.mjs\n * - .intlayerrc\n */\nexport const searchConfigurationFile = (\n startDir: string\n): SearchConfigurationFileResult => {\n let configurationFilePath: string | undefined;\n let numCustomConfiguration = 0;\n\n const { baseDir } = getPackageJsonPath(startDir);\n\n for (const fileName of configurationFilesCandidates) {\n try {\n const filePath = resolve(baseDir, fileName);\n\n // Check if the file exists\n if (!existsSync(filePath)) {\n } else {\n numCustomConfiguration += 1;\n\n if (!configurationFilePath) {\n configurationFilePath = filePath;\n }\n }\n } catch (error) {\n // Return \"Cannot use import statement outside a module\"\n logger(`${fileName}: ${error as string}`, { level: 'error' });\n }\n }\n\n return { configurationFilePath, numCustomConfiguration };\n};\n"],"mappings":";;;;;;;AAKA,MAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;;;AAkBD,MAAa,2BACX,aACkC;CAClC,IAAI;CACJ,IAAI,yBAAyB;CAE7B,MAAM,EAAE,YAAYA,oDAAmB,SAAS;AAEhD,MAAK,MAAM,YAAY,6BACrB,KAAI;EACF,MAAM,kCAAmB,SAAS,SAAS;AAG3C,MAAI,yBAAY,SAAS,EAAE,QACpB;AACL,6BAA0B;AAE1B,OAAI,CAAC,sBACH,yBAAwB;;UAGrB,OAAO;AAEd,wBAAO,GAAG,SAAS,IAAI,SAAmB,EAAE,OAAO,SAAS,CAAC;;AAIjE,QAAO;EAAE;EAAuB;EAAwB"}
@@ -1,7 +1,7 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
 
3
3
  //#region src/defaultValues/build.ts
4
- var build_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
4
+ var build_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
5
5
  BUILD_MODE: () => BUILD_MODE,
6
6
  CACHE: () => CACHE,
7
7
  IMPORT_MODE: () => IMPORT_MODE,
@@ -1 +1 @@
1
- {"version":3,"file":"build.cjs","names":["OUTPUT_FORMAT: ('cjs' | 'esm')[]"],"sources":["../../../src/defaultValues/build.ts"],"sourcesContent":["export const BUILD_MODE = 'auto';\n\nexport const OPTIMIZE = undefined;\n\nexport const IMPORT_MODE = 'static';\n\nexport const TRAVERSE_PATTERN = [\n '**/*.{tsx,ts,js,mjs,cjs,jsx,mjx,cjx,vue,svelte,svte}',\n '!**/node_modules/**',\n];\n\nexport const OUTPUT_FORMAT: ('cjs' | 'esm')[] = ['cjs', 'esm'];\n\nexport const CACHE = true;\n"],"mappings":";;;;;;;;;;;AAAA,MAAa,aAAa;AAE1B,MAAa,WAAW;AAExB,MAAa,cAAc;AAE3B,MAAa,mBAAmB,CAC9B,wDACA,sBACD;AAED,MAAaA,gBAAmC,CAAC,OAAO,MAAM;AAE9D,MAAa,QAAQ"}
1
+ {"version":3,"file":"build.cjs","names":[],"sources":["../../../src/defaultValues/build.ts"],"sourcesContent":["export const BUILD_MODE = 'auto';\n\nexport const OPTIMIZE = undefined;\n\nexport const IMPORT_MODE = 'static';\n\nexport const TRAVERSE_PATTERN = [\n '**/*.{tsx,ts,js,mjs,cjs,jsx,mjx,cjx,vue,svelte,svte}',\n '!**/node_modules/**',\n];\n\nexport const OUTPUT_FORMAT: ('cjs' | 'esm')[] = ['cjs', 'esm'];\n\nexport const CACHE = true;\n"],"mappings":";;;;;;;;;;;AAAA,MAAa,aAAa;AAE1B,MAAa,WAAW;AAExB,MAAa,cAAc;AAE3B,MAAa,mBAAmB,CAC9B,wDACA,sBACD;AAED,MAAa,gBAAmC,CAAC,OAAO,MAAM;AAE9D,MAAa,QAAQ"}
@@ -1,7 +1,7 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
 
3
3
  //#region src/defaultValues/content.ts
4
- var content_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
4
+ var content_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
5
5
  CACHE_DIR: () => CACHE_DIR,
6
6
  CONFIG_DIR: () => CONFIG_DIR,
7
7
  CONTENT_DIR: () => CONTENT_DIR,
@@ -1,7 +1,9 @@
1
1
 
2
2
  //#region src/defaultValues/dictionary.ts
3
3
  const FILL = true;
4
+ const LOCATION = "local";
4
5
 
5
6
  //#endregion
6
7
  exports.FILL = FILL;
8
+ exports.LOCATION = LOCATION;
7
9
  //# sourceMappingURL=dictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"dictionary.cjs","names":[],"sources":["../../../src/defaultValues/dictionary.ts"],"sourcesContent":["export const FILL = true;\n"],"mappings":";;AAAA,MAAa,OAAO"}
1
+ {"version":3,"file":"dictionary.cjs","names":[],"sources":["../../../src/defaultValues/dictionary.ts"],"sourcesContent":["import type { DictionaryLocation } from '@intlayer/types';\n\nexport const FILL = true;\nexport const LOCATION: DictionaryLocation = 'local';\n"],"mappings":";;AAEA,MAAa,OAAO;AACpB,MAAa,WAA+B"}
@@ -1,7 +1,7 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
 
3
3
  //#region src/defaultValues/editor.ts
4
- var editor_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
4
+ var editor_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
5
5
  APPLICATION_URL: () => APPLICATION_URL,
6
6
  BACKEND_URL: () => BACKEND_URL,
7
7
  CMS_URL: () => CMS_URL,
@@ -7,7 +7,7 @@ const require_defaultValues_log = require('./log.cjs');
7
7
  const require_defaultValues_routing = require('./routing.cjs');
8
8
 
9
9
  //#region src/defaultValues/index.ts
10
- var defaultValues_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
10
+ var defaultValues_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
11
11
  Build: () => require_defaultValues_build.build_exports,
12
12
  Content: () => require_defaultValues_content.content_exports,
13
13
  Editor: () => require_defaultValues_editor.editor_exports,
@@ -2,7 +2,7 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  let _intlayer_types = require("@intlayer/types");
3
3
 
4
4
  //#region src/defaultValues/internationalization.ts
5
- var internationalization_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
5
+ var internationalization_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
6
6
  DEFAULT_LOCALE: () => DEFAULT_LOCALE,
7
7
  LOCALES: () => LOCALES,
8
8
  REQUIRED_LOCALES: () => REQUIRED_LOCALES,
@@ -1 +1 @@
1
- {"version":3,"file":"internationalization.cjs","names":["LOCALES: Locale[]","Locales","REQUIRED_LOCALES: Locale[]","DEFAULT_LOCALE: Locale","STRICT_MODE: StrictMode"],"sources":["../../../src/defaultValues/internationalization.ts"],"sourcesContent":["import { type Locale, Locales, type StrictMode } from '@intlayer/types';\n\nexport const LOCALES: Locale[] = [Locales.ENGLISH];\n\nexport const REQUIRED_LOCALES: Locale[] = [];\n\nexport const DEFAULT_LOCALE: Locale = Locales.ENGLISH;\n\nexport const STRICT_MODE: StrictMode = 'inclusive';\n"],"mappings":";;;;;;;;;;AAEA,MAAaA,UAAoB,CAACC,wBAAQ,QAAQ;AAElD,MAAaC,mBAA6B,EAAE;AAE5C,MAAaC,iBAAyBF,wBAAQ;AAE9C,MAAaG,cAA0B"}
1
+ {"version":3,"file":"internationalization.cjs","names":["Locales"],"sources":["../../../src/defaultValues/internationalization.ts"],"sourcesContent":["import { type Locale, Locales, type StrictMode } from '@intlayer/types';\n\nexport const LOCALES: Locale[] = [Locales.ENGLISH];\n\nexport const REQUIRED_LOCALES: Locale[] = [];\n\nexport const DEFAULT_LOCALE: Locale = Locales.ENGLISH;\n\nexport const STRICT_MODE: StrictMode = 'inclusive';\n"],"mappings":";;;;;;;;;;AAEA,MAAa,UAAoB,CAACA,wBAAQ,QAAQ;AAElD,MAAa,mBAA6B,EAAE;AAE5C,MAAa,iBAAyBA,wBAAQ;AAE9C,MAAa,cAA0B"}
@@ -2,7 +2,7 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_logger = require('../logger.cjs');
3
3
 
4
4
  //#region src/defaultValues/log.ts
5
- var log_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
5
+ var log_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
6
6
  MODE: () => MODE,
7
7
  PREFIX: () => PREFIX
8
8
  });
@@ -1,7 +1,7 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
 
3
3
  //#region src/defaultValues/routing.ts
4
- var routing_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
4
+ var routing_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
5
5
  BASE_PATH: () => BASE_PATH,
6
6
  COOKIE_NAME: () => COOKIE_NAME,
7
7
  HEADER_NAME: () => HEADER_NAME,
@@ -1 +1 @@
1
- {"version":3,"file":"routing.cjs","names":["STORAGE: RoutingConfig['storage']"],"sources":["../../../src/defaultValues/routing.ts"],"sourcesContent":["import type { RoutingConfig } from '@intlayer/types';\n\nexport const HEADER_NAME = 'x-intlayer-locale';\n\nexport const COOKIE_NAME = 'INTLAYER_LOCALE';\nexport const LOCALE_STORAGE_NAME = 'INTLAYER_LOCALE';\n\nexport const BASE_PATH = '';\n\nexport const SERVER_SET_COOKIE = 'always';\n\nexport const ROUTING_MODE = 'prefix-no-default';\n\nexport const STORAGE: RoutingConfig['storage'] = ['cookie', 'header'];\n"],"mappings":";;;;;;;;;;;;AAEA,MAAa,cAAc;AAE3B,MAAa,cAAc;AAC3B,MAAa,sBAAsB;AAEnC,MAAa,YAAY;AAEzB,MAAa,oBAAoB;AAEjC,MAAa,eAAe;AAE5B,MAAaA,UAAoC,CAAC,UAAU,SAAS"}
1
+ {"version":3,"file":"routing.cjs","names":[],"sources":["../../../src/defaultValues/routing.ts"],"sourcesContent":["import type { RoutingConfig } from '@intlayer/types';\n\nexport const HEADER_NAME = 'x-intlayer-locale';\n\nexport const COOKIE_NAME = 'INTLAYER_LOCALE';\nexport const LOCALE_STORAGE_NAME = 'INTLAYER_LOCALE';\n\nexport const BASE_PATH = '';\n\nexport const SERVER_SET_COOKIE = 'always';\n\nexport const ROUTING_MODE = 'prefix-no-default';\n\nexport const STORAGE: RoutingConfig['storage'] = ['cookie', 'header'];\n"],"mappings":";;;;;;;;;;;;AAEA,MAAa,cAAc;AAE3B,MAAa,cAAc;AAC3B,MAAa,sBAAsB;AAEnC,MAAa,YAAY;AAEzB,MAAa,oBAAoB;AAEjC,MAAa,eAAe;AAE5B,MAAa,UAAoC,CAAC,UAAU,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"loadExternalFile.cjs","names":["JSON5","moduleResultString: string | undefined","transpileTSToCJSSync","parseFileContent","fileContent","transpileTSToCJS","colorizePath"],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport type { BuildOptions, Plugin } from 'esbuild';\nimport JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport { transpileTSToCJS, transpileTSToCJSSync } from './transpileTSToCJS';\n\nexport type ESBuildPlugin = Plugin;\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: BuildOptions;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return JSON5.parse(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return JSON5.parse(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,MAAa,wBACX,UACA,YACoB;CACpB,MAAM,uCAAwB,SAAS,IAAI;AAE3C,KAAI;AACF,MACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,SAGlB,QAAOA,cAAM,gCAAmB,UAAU,QAAQ,CAAC;EAMrD,MAAMC,qBAAyCC,yFAFrB,UAAU,QAAQ,EAI1C,SACD;AAED,MAAI,CAAC,oBAAoB;AACvB,yBAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAGF,MAAM,cAAcC,2DAAiB,oBAAoB;GACvD,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC;AAEF,MAAI,OAAO,gBAAgB,aAAa;AACtC,yBAAO,oCAAoC,WAAW;AACtD;;AAGF,SAAO;UACA,OAAO;AACd,wBACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,EAAE,CAChD,EACD,EACE,OAAO,SACR,CACF;;;;;;;;AASL,MAAa,mBAAmB,OAC9B,UACA,YAC6B;CAC7B,MAAM,uCAAwB,SAAS;AAEvC,KAAI;AACF,MACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,UAClB;GAEA,MAAMC,gBAAc,qCAAe,UAAU,QAAQ;AACrD,UAAOJ,cAAM,MAAMI,cAAY;;EAMjC,MAAMH,qBAAyC,MAAMI,2DAFxC,qCAAe,UAAU,QAAQ,EAI5C,UACA,SAAS,aACV;AAED,MAAI,CAAC,oBAAoB;AACvB,yBAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAGF,MAAM,cAAcF,2DAAiB,oBAAoB;GACvD,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC;AAEF,MAAI,OAAO,gBAAgB,aAAa;AACtC,yBAAO,oCAAoCG,4BAAa,SAAS,GAAG;AACpE;;AAGF,SAAO;UACA,OAAO;AACd,wBACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,EAAE,CAChD,EACD,EACE,OAAO,SACR,CACF"}
1
+ {"version":3,"file":"loadExternalFile.cjs","names":["JSON5","transpileTSToCJSSync","parseFileContent","fileContent","transpileTSToCJS","colorizePath"],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport type { BuildOptions, Plugin } from 'esbuild';\nimport JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport { transpileTSToCJS, transpileTSToCJSSync } from './transpileTSToCJS';\n\nexport type ESBuildPlugin = Plugin;\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: BuildOptions;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return JSON5.parse(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return JSON5.parse(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,MAAa,wBACX,UACA,YACoB;CACpB,MAAM,uCAAwB,SAAS,IAAI;AAE3C,KAAI;AACF,MACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,SAGlB,QAAOA,cAAM,gCAAmB,UAAU,QAAQ,CAAC;EAMrD,MAAM,qBAAyCC,yFAFrB,UAAU,QAAQ,EAI1C,SACD;AAED,MAAI,CAAC,oBAAoB;AACvB,yBAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAGF,MAAM,cAAcC,2DAAiB,oBAAoB;GACvD,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC;AAEF,MAAI,OAAO,gBAAgB,aAAa;AACtC,yBAAO,oCAAoC,WAAW;AACtD;;AAGF,SAAO;UACA,OAAO;AACd,wBACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,EAAE,CAChD,EACD,EACE,OAAO,SACR,CACF;;;;;;;;AASL,MAAa,mBAAmB,OAC9B,UACA,YAC6B;CAC7B,MAAM,uCAAwB,SAAS;AAEvC,KAAI;AACF,MACE,kBAAkB,WAClB,kBAAkB,YAClB,kBAAkB,UAClB;GAEA,MAAMC,gBAAc,qCAAe,UAAU,QAAQ;AACrD,UAAOH,cAAM,MAAMG,cAAY;;EAMjC,MAAM,qBAAyC,MAAMC,2DAFxC,qCAAe,UAAU,QAAQ,EAI5C,UACA,SAAS,aACV;AAED,MAAI,CAAC,oBAAoB;AACvB,yBAAO,6BAA6B,EAAE,OAAO,SAAS,CAAC;AACvD;;EAGF,MAAM,cAAcF,2DAAiB,oBAAoB;GACvD,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,mBAAmB,SAAS;GAC5B,OAAO,SAAS;GAChB,SAAS,SAAS;GACnB,CAAC;AAEF,MAAI,OAAO,gBAAgB,aAAa;AACtC,yBAAO,oCAAoCG,4BAAa,SAAS,GAAG;AACpE;;AAGF,SAAO;UACA,OAAO;AACd,wBACE,CACE,UAAW,MAAgB,QAAQ,MACnC,KAAK,UAAW,MAAgB,OAAO,MAAM,EAAE,CAChD,EACD,EACE,OAAO,SACR,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"parseFileContent.cjs","names":["baseRequire: NodeJS.Require","getProjectRequire","mockedRequire: NodeJS.Require","sandboxContext: Context","loadEnvFile","candidates: unknown[]"],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we don't inject it\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":";;;;;;;;AA0BA,MAAa,qBAAqB,YAA6C;CAC7E,MAAM,EAAE,eAAe,gBAAgB,mBAAmB,OAAO,YAC/D,WAAW,EAAE;CAEf,IAAI,sBAAsB,EAAE;CAE5B,MAAMA,cACJ,OAAO,mBAAmB,aAAa,iBAAiBC,gDAAmB;CAG7E,MAAMC,uBAAuC;EAC3C,MAAM,YAAY,OAAO,OACvB,EACE,SACD,EACD,MACD;EACD,MAAM,aAAa,OAAO,OAAO,EAAE,EAAE,QAAQ;EAE7C,MAAM,iBAAiB,SAAS,gBAAgB,IAAY;GAC1D,MAAM,SAAS,aAAa,MAAM,WAAW,MAAM;AAEnD,OAAI,aAAa,OAAO,OAAO,WAAW,OAAO,CAC/C,QAAO,UAAU;AAInB,OAAI,WAAW,MAAM,aAAa,OAAO,OAAO,WAAW,GAAG,CAC5D,QAAO,UAAU;AAGnB,UAAO,YAAY,OAAO;;AAI5B,iBAAe,UAAU,YAAY,QAAQ,KAAK,YAAY;AAC9D,iBAAe,OAAO,YAAY;AAClC,iBAAe,aAAa,YAAY;AACxC,iBAAe,QAAQ,YAAY;AAEnC,SAAO;KACL;AAEJ,KAAI;AAEF,wBAAsB,EACpB,OAAO,YAAY,QAAQ,EAC5B;UACM,MAAM;CAIf,MAAMC,iBAA0B;EAC9B,SAAS,EACP,SAAS,EAAE,EACZ;EACD,QAAQ,EACN,SAAS,EAAE,EACZ;EACD,SAAS;GACP,GAAG;GACH,KAAK;IACH,GAAG,QAAQ;IACX,GAAGC,gCAAY,cAAc;IAC7B,GAAG;IACJ;GACF;EACD;EACA,SAAS;EACT,GAAG;EACJ;AAGD,QAAO,oBAAoB,WAAW,CAAC,SAAS,QAAQ;AACtD,MAAI,EAAE,OAAO,gBACX,gBAAe,OAAO,WAAW;GAEnC;AAEF,QAAO;;AAGT,MAAa,oBACX,mBACA,YACkB;CAClB,MAAM,iBAAiB,kBAAkB,QAAQ;AAGjD,8BAAgB,kBAAkB,qBAAqB,eAAe;CAEtE,MAAMC,aAAwB;EAC5B,eAAe,SAAS;EACxB,eAAe,QAAQ,SAAS;EAChC,eAAe,QAAQ,SAAS;EAChC,eAAe,QAAQ;EACxB;AAED,MAAK,MAAM,aAAa,WACtB,KACE,aACA,OAAO,cAAc,YACrB,OAAO,KAAK,UAAoB,CAAC,SAAS,EAE1C,QAAO"}
1
+ {"version":3,"file":"parseFileContent.cjs","names":["getProjectRequire","loadEnvFile"],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we don't inject it\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":";;;;;;;;AA0BA,MAAa,qBAAqB,YAA6C;CAC7E,MAAM,EAAE,eAAe,gBAAgB,mBAAmB,OAAO,YAC/D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EACxB;AAED,MAAK,MAAM,aAAa,WACtB,KACE,aACA,OAAO,cAAc,YACrB,OAAO,KAAK,UAAoB,CAAC,SAAS,EAE1C,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"logger.cjs","names":["logger: Logger","color","value: number","text"],"sources":["../../src/logger.ts"],"sourcesContent":["import type { CustomIntlayerConfig, Locale } from '@intlayer/types';\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nexport const logger: Logger = (content, details) => {\n const isVerbose = details?.isVerbose ?? false;\n const mode = details?.config?.mode ?? 'default';\n const level = details?.level ?? 'info';\n const prefix = details?.config?.prefix ? details?.config?.prefix : undefined;\n const log = details?.config?.log ?? console.log;\n const info = details?.config?.info ?? console.info;\n const warn = details?.config?.warn ?? console.warn;\n const error = details?.config?.error ?? console.error;\n const debug = details?.config?.debug ?? console.debug;\n\n if (mode === 'disabled') return;\n\n if (isVerbose && mode !== 'verbose') return;\n\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n\n if (level === 'debug') {\n return debug(...flatContent);\n }\n\n if (level === 'info') {\n return info(...flatContent);\n }\n\n if (level === 'warn') {\n return warn(...flatContent);\n }\n\n if (level === 'error') {\n return error(...flatContent);\n }\n\n log(...flatContent);\n};\n\nexport enum ANSIColors {\n RESET = '\\x1b[0m',\n GREY = '\\x1b[90m',\n GREY_DARK = '\\x1b[38;5;239m',\n GREY_LIGHT = '\\x1b[38;5;252m',\n BLUE = '\\x1b[34m',\n RED = '\\x1b[31m',\n GREEN = '\\x1b[32m',\n YELLOW = '\\x1b[38;5;226m',\n MAGENTA = '\\x1b[35m',\n BEIGE = '\\x1b[38;5;3m',\n ORANGE = '\\x1b[38;5;208m',\n CYAN = '\\x1b[36m',\n WHITE = '\\x1b[37m',\n BOLD = '\\x1b[1m',\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: Locale | Locale[],\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 | string,\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(number));\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const removeColor = (text: string) =>\n // biome-ignore lint/suspicious/noControlCharactersInRegex: we need to remove the color codes\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (Array.isArray(length) && length.every((l) => typeof l === 'string')) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (Array.isArray(length) && length.every((l) => typeof l === 'number')) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad, 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":";;AAUA,MAAaA,UAAkB,SAAS,YAAY;CAClD,MAAM,YAAY,SAAS,aAAa;CACxC,MAAM,OAAO,SAAS,QAAQ,QAAQ;CACtC,MAAM,QAAQ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AI,OAAO,EAAE;;AAG3B,MAAM,sBAAsB;CAC1B,SAAS;CACT,SAAS;CACT,SAAS;CACT,KAAK;CACL,SAAS;CACV;;;;;;;AAQD,MAAa,SACX,MACA,YAQA,CAAC,KAAK,CACH,MAAM,CACN,KAAK,WAAS;CACb,MAAM,EAAE,SAAS,SAAS,SAAS,KAAK,YAAY;EAClD,GAAG;EACH,GAAI,WAAW,EAAE;EAClB;CAED,MAAM,SAAS,UAAU,QAAQ;CACjC,MAAM,eAAe,KAAK,IACxB,SACA,KAAK,IAAI,SAAU,SAAS,YAAYC,OAAK,CAAC,OAAO,CACtD;AAED,KAAI,QAAQ,OACV,QAAO,GAAG,IAAI,OAAO,aAAa,GAAGA;AAGvC,QAAO,GAAGA,SAAO,IAAI,OAAO,aAAa;EACzC,CACD,KAAK,GAAG;AAEb,MAAa,IAAI,SAAS,KAAK,WAAW,IAAI;AAC9C,MAAa,IAAI,SAAS,KAAK,WAAW,MAAM;AAChD,MAAa,QAAQ,SAAS,KAAK,WAAW,KAAK"}
1
+ {"version":3,"file":"logger.cjs","names":["color","text"],"sources":["../../src/logger.ts"],"sourcesContent":["import type { CustomIntlayerConfig, Locale } from '@intlayer/types';\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nexport const logger: Logger = (content, details) => {\n const isVerbose = details?.isVerbose ?? false;\n const mode = details?.config?.mode ?? 'default';\n const level = details?.level ?? 'info';\n const prefix = details?.config?.prefix ? details?.config?.prefix : undefined;\n const log = details?.config?.log ?? console.log;\n const info = details?.config?.info ?? console.info;\n const warn = details?.config?.warn ?? console.warn;\n const error = details?.config?.error ?? console.error;\n const debug = details?.config?.debug ?? console.debug;\n\n if (mode === 'disabled') return;\n\n if (isVerbose && mode !== 'verbose') return;\n\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n\n if (level === 'debug') {\n return debug(...flatContent);\n }\n\n if (level === 'info') {\n return info(...flatContent);\n }\n\n if (level === 'warn') {\n return warn(...flatContent);\n }\n\n if (level === 'error') {\n return error(...flatContent);\n }\n\n log(...flatContent);\n};\n\nexport enum ANSIColors {\n RESET = '\\x1b[0m',\n GREY = '\\x1b[90m',\n GREY_DARK = '\\x1b[38;5;239m',\n GREY_LIGHT = '\\x1b[38;5;252m',\n BLUE = '\\x1b[34m',\n RED = '\\x1b[31m',\n GREEN = '\\x1b[32m',\n YELLOW = '\\x1b[38;5;226m',\n MAGENTA = '\\x1b[35m',\n BEIGE = '\\x1b[38;5;3m',\n ORANGE = '\\x1b[38;5;208m',\n CYAN = '\\x1b[36m',\n WHITE = '\\x1b[37m',\n BOLD = '\\x1b[1m',\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: Locale | Locale[],\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 | string,\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(number));\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const removeColor = (text: string) =>\n // biome-ignore lint/suspicious/noControlCharactersInRegex: we need to remove the color codes\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (Array.isArray(length) && length.every((l) => typeof l === 'string')) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (Array.isArray(length) && length.every((l) => typeof l === 'number')) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad, 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":";;AAUA,MAAa,UAAkB,SAAS,YAAY;CAClD,MAAM,YAAY,SAAS,aAAa;CACxC,MAAM,OAAO,SAAS,QAAQ,QAAQ;CACtC,MAAM,QAAQ,SAAS,SAAS;CAChC,MAAM,SAAS,SAAS,QAAQ,SAAS,SAAS,QAAQ,SAAS;CACnE,MAAM,MAAM,SAAS,QAAQ,OAAO,QAAQ;CAC5C,MAAM,OAAO,SAAS,QAAQ,QAAQ,QAAQ;CAC9C,MAAM,OAAO,SAAS,QAAQ,QAAQ,QAAQ;CAC9C,MAAM,QAAQ,SAAS,QAAQ,SAAS,QAAQ;CAChD,MAAM,QAAQ,SAAS,QAAQ,SAAS,QAAQ;AAEhD,KAAI,SAAS,WAAY;AAEzB,KAAI,aAAa,SAAS,UAAW;CAErC,MAAM,cAAc,SAAS,CAAC,QAAQ,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM;AAE7E,KAAI,UAAU,QACZ,QAAO,MAAM,GAAG,YAAY;AAG9B,KAAI,UAAU,OACZ,QAAO,KAAK,GAAG,YAAY;AAG7B,KAAI,UAAU,OACZ,QAAO,KAAK,GAAG,YAAY;AAG7B,KAAI,UAAU,QACZ,QAAO,MAAM,GAAG,YAAY;AAG9B,KAAI,GAAG,YAAY;;AAGrB,IAAY,oDAAL;AACL;AACA;AACA;AACA;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"sourcesContent":["import { logger } from './logger';\nimport { extractErrorMessage } from './utils/extractErrorMessage';\n\nexport type RetryManagerOptions = {\n /** maximum number of retries before giving up */\n maxRetry?: number;\n /** delay between attempts, in milliseconds */\n delay?: number;\n /** function to call when an error occurs */\n onError?: (details: {\n error: string;\n attempt: number;\n maxRetry: number;\n }) => void;\n /** function to call when the maximum number of retries is reached */\n onMaxTryReached?: (details: {\n error: string;\n attempt: number;\n maxRetry: number;\n }) => void;\n};\n\nconst DEFAULT_MAX_RETRY = 3;\nconst DEFAULT_DELAY = 0;\n\n/**\n * Wrap an async function `fn` so it’s retried on failure.\n *\n * @param fn The async function to wrap\n * @param options { maxRetry, delay }\n * @returns A new function with the same signature as `fn`\n */\nexport const retryManager =\n <Args extends any[], R>(\n fn: (...args: Args) => Promise<R>,\n {\n maxRetry = DEFAULT_MAX_RETRY,\n delay = DEFAULT_DELAY,\n onError,\n onMaxTryReached,\n }: RetryManagerOptions = {}\n ): ((...args: Args) => Promise<R>) =>\n // ───────────────────────────────^ returned wrapper function\n async (...args: Args): Promise<R> => {\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= maxRetry; attempt++) {\n try {\n return await fn(...args);\n } catch (err) {\n lastError = err;\n const error = extractErrorMessage(err);\n\n // If this was the last attempt, handle max retry reached\n if (attempt >= maxRetry) {\n if (onMaxTryReached) {\n onMaxTryReached?.({ error, attempt, maxRetry });\n return null as R;\n }\n\n // Otherwise, throw the error\n throw err;\n }\n\n if (onError) {\n onError?.({ error, attempt, maxRetry });\n } else {\n logger(error, {\n level: 'error',\n });\n }\n\n // Wait before retrying\n if (delay > 0) {\n await new Promise((res) => setTimeout(res, delay));\n }\n }\n }\n\n // This should never be reached, but TypeScript needs it\n throw (\n lastError ?? new Error('Unexpected: retry loop completed without result')\n );\n };\n"],"mappings":";;;;AAsBA,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;;;;;;;;AAStB,MAAa,gBAET,IACA,EACE,WAAW,mBACX,QAAQ,eACR,SACA,oBACuB,EAAE,KAG7B,OAAO,GAAG,SAA2B;CACnC,IAAIA;AAEJ,MAAK,IAAI,UAAU,GAAG,WAAW,UAAU,UACzC,KAAI;AACF,SAAO,MAAM,GAAG,GAAG,KAAK;UACjB,KAAK;AACZ,cAAY;EACZ,MAAM,QAAQC,sDAAoB,IAAI;AAGtC,MAAI,WAAW,UAAU;AACvB,OAAI,iBAAiB;AACnB,sBAAkB;KAAE;KAAO;KAAS;KAAU,CAAC;AAC/C,WAAO;;AAIT,SAAM;;AAGR,MAAI,QACF,WAAU;GAAE;GAAO;GAAS;GAAU,CAAC;MAEvC,uBAAO,OAAO,EACZ,OAAO,SACR,CAAC;AAIJ,MAAI,QAAQ,EACV,OAAM,IAAI,SAAS,QAAQ,WAAW,KAAK,MAAM,CAAC;;AAMxD,OACE,6BAAa,IAAI,MAAM,kDAAkD"}
1
+ {"version":3,"file":"retryManager.cjs","names":["extractErrorMessage"],"sources":["../../src/retryManager.ts"],"sourcesContent":["import { logger } from './logger';\nimport { extractErrorMessage } from './utils/extractErrorMessage';\n\nexport type RetryManagerOptions = {\n /** maximum number of retries before giving up */\n maxRetry?: number;\n /** delay between attempts, in milliseconds */\n delay?: number;\n /** function to call when an error occurs */\n onError?: (details: {\n error: string;\n attempt: number;\n maxRetry: number;\n }) => void;\n /** function to call when the maximum number of retries is reached */\n onMaxTryReached?: (details: {\n error: string;\n attempt: number;\n maxRetry: number;\n }) => void;\n};\n\nconst DEFAULT_MAX_RETRY = 3;\nconst DEFAULT_DELAY = 0;\n\n/**\n * Wrap an async function `fn` so it’s retried on failure.\n *\n * @param fn The async function to wrap\n * @param options { maxRetry, delay }\n * @returns A new function with the same signature as `fn`\n */\nexport const retryManager =\n <Args extends any[], R>(\n fn: (...args: Args) => Promise<R>,\n {\n maxRetry = DEFAULT_MAX_RETRY,\n delay = DEFAULT_DELAY,\n onError,\n onMaxTryReached,\n }: RetryManagerOptions = {}\n ): ((...args: Args) => Promise<R>) =>\n // ───────────────────────────────^ returned wrapper function\n async (...args: Args): Promise<R> => {\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= maxRetry; attempt++) {\n try {\n return await fn(...args);\n } catch (err) {\n lastError = err;\n const error = extractErrorMessage(err);\n\n // If this was the last attempt, handle max retry reached\n if (attempt >= maxRetry) {\n if (onMaxTryReached) {\n onMaxTryReached?.({ error, attempt, maxRetry });\n return null as R;\n }\n\n // Otherwise, throw the error\n throw err;\n }\n\n if (onError) {\n onError?.({ error, attempt, maxRetry });\n } else {\n logger(error, {\n level: 'error',\n });\n }\n\n // Wait before retrying\n if (delay > 0) {\n await new Promise((res) => setTimeout(res, delay));\n }\n }\n }\n\n // This should never be reached, but TypeScript needs it\n throw (\n lastError ?? new Error('Unexpected: retry loop completed without result')\n );\n };\n"],"mappings":";;;;AAsBA,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;;;;;;;;AAStB,MAAa,gBAET,IACA,EACE,WAAW,mBACX,QAAQ,eACR,SACA,oBACuB,EAAE,KAG7B,OAAO,GAAG,SAA2B;CACnC,IAAI;AAEJ,MAAK,IAAI,UAAU,GAAG,WAAW,UAAU,UACzC,KAAI;AACF,SAAO,MAAM,GAAG,GAAG,KAAK;UACjB,KAAK;AACZ,cAAY;EACZ,MAAM,QAAQA,sDAAoB,IAAI;AAGtC,MAAI,WAAW,UAAU;AACvB,OAAI,iBAAiB;AACnB,sBAAkB;KAAE;KAAO;KAAS;KAAU,CAAC;AAC/C,WAAO;;AAIT,SAAM;;AAGR,MAAI,QACF,WAAU;GAAE;GAAO;GAAS;GAAU,CAAC;MAEvC,uBAAO,OAAO,EACZ,OAAO,SACR,CAAC;AAIJ,MAAI,QAAQ,EACV,OAAM,IAAI,SAAS,QAAQ,WAAW,KAAK,MAAM,CAAC;;AAMxD,OACE,6BAAa,IAAI,MAAM,kDAAkD"}
@@ -1 +1 @@
1
- {"version":3,"file":"ESMxCJSHelpers.cjs","names":["getPackageJsonPath","configESMxCJSRequire: NodeJS.Require"],"sources":["../../../src/utils/ESMxCJSHelpers.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { getPackageJsonPath } from './getPackageJsonPath';\n\nexport const isESModule = typeof import.meta.url === 'string';\n\n/**\n * Require relative to the user project\n *\n * Note: Can resolve package that are installed in the user project, ex `'intlayer'`\n */\nexport const getProjectRequire = (startDir?: string): NodeJS.Require => {\n // Can fail on VSCode extensions\n const { packageJsonPath } = getPackageJsonPath(startDir);\n\n return createRequire(packageJsonPath);\n};\n\n/**\n * Require relative to the @intlayer/config package\n *\n * Note: Can resolve package that are installed in the config package, ex `'@intlayer/types'`\n */\nexport const configESMxCJSRequire: NodeJS.Require = isESModule\n ? createRequire(import.meta.url)\n : require;\n"],"mappings":";;;;;AAGA,MAAa,aAAa,yDAA2B;;;;;;AAOrD,MAAa,qBAAqB,aAAsC;CAEtE,MAAM,EAAE,oBAAoBA,oDAAmB,SAAS;AAExD,uCAAqB,gBAAgB;;;;;;;AAQvC,MAAaC,uBAAuC,0FAClB,GAC9B"}
1
+ {"version":3,"file":"ESMxCJSHelpers.cjs","names":["getPackageJsonPath"],"sources":["../../../src/utils/ESMxCJSHelpers.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { getPackageJsonPath } from './getPackageJsonPath';\n\nexport const isESModule = typeof import.meta.url === 'string';\n\n/**\n * Require relative to the user project\n *\n * Note: Can resolve package that are installed in the user project, ex `'intlayer'`\n */\nexport const getProjectRequire = (startDir?: string): NodeJS.Require => {\n // Can fail on VSCode extensions\n const { packageJsonPath } = getPackageJsonPath(startDir);\n\n return createRequire(packageJsonPath);\n};\n\n/**\n * Require relative to the @intlayer/config package\n *\n * Note: Can resolve package that are installed in the config package, ex `'@intlayer/types'`\n */\nexport const configESMxCJSRequire: NodeJS.Require = isESModule\n ? createRequire(import.meta.url)\n : require;\n"],"mappings":";;;;;AAGA,MAAa,aAAa,yDAA2B;;;;;;AAOrD,MAAa,qBAAqB,aAAsC;CAEtE,MAAM,EAAE,oBAAoBA,oDAAmB,SAAS;AAExD,uCAAqB,gBAAgB;;;;;;;AAQvC,MAAa,uBAAuC,0FAClB,GAC9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"cacheDisk.cjs","names":["DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>>","computeKeyId","value: unknown","configPackageJson","envelope: CacheEnvelope"],"sources":["../../../src/utils/cacheDisk.ts"],"sourcesContent":["import {\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport configPackageJson from '@intlayer/types/package.json' with {\n type: 'json',\n};\nimport { type CacheKey, clearAllCache, computeKeyId } from './cacheMemory';\n\n/** ------------------------- Persistence layer ------------------------- **/\n\n/** Cache envelope structure stored on disk */\ntype CacheEnvelope = {\n /** Version of the config package (for cache invalidation) */\n version: string;\n /** Timestamp when the cache entry was created (in milliseconds) */\n timestamp: number;\n /** Data payload (the actual cached value) */\n data: unknown;\n};\n\ntype LocalCacheOptions = {\n /** Preferred new option name */\n persistent?: boolean;\n /** Time-to-live in ms; if expired, disk entry is ignored. */\n ttlMs?: number;\n /** Max age in ms based on stored creation timestamp; invalidates on exceed. */\n maxTimeMs?: number;\n /** Optional namespace to separate different logical caches. */\n namespace?: string;\n /** Gzip values on disk (on by default for blobs > 1KB). */\n compress?: boolean;\n};\n\nconst DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>> = {\n compress: true,\n};\n\nconst ensureDir = async (dir: string) => {\n await mkdir(dir, { recursive: true });\n};\n\nconst atomicWriteFile = async (file: string, data: Buffer) => {\n const tmp = `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n await writeFile(tmp, data);\n await rename(tmp, file);\n};\n\nconst shouldUseCompression = (buf: Buffer, force?: boolean) =>\n force === true || (force !== false && buf.byteLength > 1024);\n\n/** Derive on-disk path from config dir + namespace + key id. */\nconst cachePath = (cacheDir: string, id: string, ns?: string) =>\n join(cacheDir, ns ? join(ns, id) : id);\n\n/** ------------------------- Local cache facade ------------------------- **/\n\nconst cacheMap = new Map<string, any>();\n\nexport const cacheDisk = (\n intlayerConfig: IntlayerConfig,\n keys: CacheKey[],\n options?: LocalCacheOptions\n) => {\n const { cacheDir } = intlayerConfig.content;\n const buildCacheEnabled = intlayerConfig.build.cache ?? true;\n const persistent =\n options?.persistent === true ||\n (typeof options?.persistent === 'undefined' && buildCacheEnabled);\n\n const { compress, ttlMs, maxTimeMs, namespace } = {\n ...DEFAULTS,\n ...options,\n };\n\n // single stable id for this key tuple (works for both memory & disk)\n const id = computeKeyId(keys);\n const filePath = cachePath(cacheDir, id, namespace);\n\n const readFromDisk = async (): Promise<unknown | undefined> => {\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n\n if (!statValue) return undefined;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return undefined;\n }\n let raw = await readFile(filePath);\n // header: 1 byte flag (0x00 raw, 0x01 gzip)\n const flag = raw[0];\n\n raw = raw.subarray(1);\n\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n let value: unknown;\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof (maybeObj as any).version === 'string' &&\n typeof (maybeObj as any).timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n\n if (entry.version !== configPackageJson.version) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n\n value = entry.data;\n } else {\n // Backward compatibility: old entries had raw serialized value.\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n value = deserialized;\n }\n\n // hydrate memory cache as well\n cacheMap.set(id, value);\n return value;\n } catch {\n return undefined;\n }\n };\n\n const writeToDisk = async (value: unknown) => {\n try {\n await ensureDir(dirname(filePath));\n const envelope: CacheEnvelope = {\n version: configPackageJson.version,\n timestamp: Date.now(),\n data: value,\n };\n const payload = Buffer.from(serialize(envelope));\n\n const gz = shouldUseCompression(payload, compress)\n ? gzipSync(payload)\n : payload;\n\n // prepend a 1-byte header indicating compression\n const buf = Buffer.concat([\n Buffer.from([gz === payload ? 0x00 : 0x01]),\n gz,\n ]);\n\n await atomicWriteFile(filePath, buf);\n } catch {\n // swallow disk errors for cache writes\n }\n };\n\n return {\n /** In-memory first, then disk (if enabled), otherwise undefined. */\n get: async <T>(): Promise<T | undefined> => {\n const mem = cacheMap.get(id);\n\n if (mem !== undefined) return mem as T;\n\n if (persistent && buildCacheEnabled) {\n return (await readFromDisk()) as T | undefined;\n }\n return undefined;\n },\n /** Sets in-memory (always) and persists to disk if enabled. */\n set: async (value: unknown): Promise<void> => {\n cacheMap.set(id, value);\n\n if (persistent && buildCacheEnabled) {\n await writeToDisk(value);\n }\n },\n /** Clears only this entry from memory and disk. */\n clear: async (): Promise<void> => {\n cacheMap.delete(id);\n\n try {\n await unlink(filePath);\n } catch {}\n },\n /** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */\n clearAll: async (): Promise<void> => {\n clearAllCache();\n if (persistent && buildCacheEnabled) {\n // remove only the current namespace (if provided), else the root dir\n const base = namespace ? join(cacheDir, namespace) : cacheDir;\n\n try {\n await rm(base, { recursive: true, force: true });\n } catch {}\n\n try {\n await mkdir(base, { recursive: true });\n } catch {}\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n isValid: async (): Promise<boolean> => {\n const cachedValue = cacheMap.get(id);\n if (cachedValue !== undefined) return true;\n\n // If persistence is disabled or build cache disabled, only memory can be valid\n if (!persistent || !buildCacheEnabled) return false;\n\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n if (!statValue) return false;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return false;\n }\n\n let raw = await readFile(filePath);\n const flag = raw[0];\n raw = raw.subarray(1);\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof maybeObj.version === 'string' &&\n typeof maybeObj.timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n if (entry.version !== configPackageJson.version) return false;\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) return false;\n }\n return true;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) return false;\n }\n return true;\n } catch {\n return false;\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n id,\n /** Expose the absolute file path for debugging. */\n filePath,\n };\n};\n"],"mappings":";;;;;;;;;;AA2CA,MAAMA,WAA0D,EAC9D,UAAU,MACX;AAED,MAAM,YAAY,OAAO,QAAgB;AACvC,mCAAY,KAAK,EAAE,WAAW,MAAM,CAAC;;AAGvC,MAAM,kBAAkB,OAAO,MAAc,SAAiB;CAC5D,MAAM,MAAM,GAAG,KAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE;AAC7E,uCAAgB,KAAK,KAAK;AAC1B,oCAAa,KAAK,KAAK;;AAGzB,MAAM,wBAAwB,KAAa,UACzC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,OAAI,CAAC,cAAc,CAAC,kBAAmB,QAAO;AAE9C,OAAI;IACF,MAAM,YAAY,iCAAW,SAAS,CAAC,YAAY,OAAU;AAC7D,QAAI,CAAC,UAAW,QAAO;AAEvB,QAAI,OAAO,UAAU,YAAY,QAAQ,GAEvC;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,MAAO,QAAO;;IAG1B,IAAI,MAAM,qCAAe,SAAS;IAClC,MAAM,OAAO,IAAI;AACjB,UAAM,IAAI,SAAS,EAAE;IAIrB,MAAM,oCAHU,SAAS,8BAAkB,IAAI,GAAG,IACT;AAUzC,QANE,CAAC,CAAC,YACF,OAAO,aAAa,YACpB,OAAO,SAAS,YAAY,YAC5B,OAAO,SAAS,cAAc,YAC9B,OAAO,OAAO,UAAU,OAAO,EAEjB;KACd,MAAM,QAAQ;AACd,SAAI,MAAM,YAAYA,qCAAkB,QAAS,QAAO;AAExD,SAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;UADY,KAAK,KAAK,GAAG,MAAM,YACrB,UAAW,QAAO;;AAE9B,YAAO;;AAGT,QAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,UAAW,QAAO;;AAE9B,WAAO;WACD;AACN,WAAO;;;EAIX;EAEA;EACD"}
1
+ {"version":3,"file":"cacheDisk.cjs","names":["computeKeyId","configPackageJson"],"sources":["../../../src/utils/cacheDisk.ts"],"sourcesContent":["import {\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport configPackageJson from '@intlayer/types/package.json' with {\n type: 'json',\n};\nimport { type CacheKey, clearAllCache, computeKeyId } from './cacheMemory';\n\n/** ------------------------- Persistence layer ------------------------- **/\n\n/** Cache envelope structure stored on disk */\ntype CacheEnvelope = {\n /** Version of the config package (for cache invalidation) */\n version: string;\n /** Timestamp when the cache entry was created (in milliseconds) */\n timestamp: number;\n /** Data payload (the actual cached value) */\n data: unknown;\n};\n\ntype LocalCacheOptions = {\n /** Preferred new option name */\n persistent?: boolean;\n /** Time-to-live in ms; if expired, disk entry is ignored. */\n ttlMs?: number;\n /** Max age in ms based on stored creation timestamp; invalidates on exceed. */\n maxTimeMs?: number;\n /** Optional namespace to separate different logical caches. */\n namespace?: string;\n /** Gzip values on disk (on by default for blobs > 1KB). */\n compress?: boolean;\n};\n\nconst DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>> = {\n compress: true,\n};\n\nconst ensureDir = async (dir: string) => {\n await mkdir(dir, { recursive: true });\n};\n\nconst atomicWriteFile = async (file: string, data: Buffer) => {\n const tmp = `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n await writeFile(tmp, data);\n await rename(tmp, file);\n};\n\nconst shouldUseCompression = (buf: Buffer, force?: boolean) =>\n force === true || (force !== false && buf.byteLength > 1024);\n\n/** Derive on-disk path from config dir + namespace + key id. */\nconst cachePath = (cacheDir: string, id: string, ns?: string) =>\n join(cacheDir, ns ? join(ns, id) : id);\n\n/** ------------------------- Local cache facade ------------------------- **/\n\nconst cacheMap = new Map<string, any>();\n\nexport const cacheDisk = (\n intlayerConfig: IntlayerConfig,\n keys: CacheKey[],\n options?: LocalCacheOptions\n) => {\n const { cacheDir } = intlayerConfig.content;\n const buildCacheEnabled = intlayerConfig.build.cache ?? true;\n const persistent =\n options?.persistent === true ||\n (typeof options?.persistent === 'undefined' && buildCacheEnabled);\n\n const { compress, ttlMs, maxTimeMs, namespace } = {\n ...DEFAULTS,\n ...options,\n };\n\n // single stable id for this key tuple (works for both memory & disk)\n const id = computeKeyId(keys);\n const filePath = cachePath(cacheDir, id, namespace);\n\n const readFromDisk = async (): Promise<unknown | undefined> => {\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n\n if (!statValue) return undefined;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return undefined;\n }\n let raw = await readFile(filePath);\n // header: 1 byte flag (0x00 raw, 0x01 gzip)\n const flag = raw[0];\n\n raw = raw.subarray(1);\n\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n let value: unknown;\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof (maybeObj as any).version === 'string' &&\n typeof (maybeObj as any).timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n\n if (entry.version !== configPackageJson.version) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n\n value = entry.data;\n } else {\n // Backward compatibility: old entries had raw serialized value.\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n value = deserialized;\n }\n\n // hydrate memory cache as well\n cacheMap.set(id, value);\n return value;\n } catch {\n return undefined;\n }\n };\n\n const writeToDisk = async (value: unknown) => {\n try {\n await ensureDir(dirname(filePath));\n const envelope: CacheEnvelope = {\n version: configPackageJson.version,\n timestamp: Date.now(),\n data: value,\n };\n const payload = Buffer.from(serialize(envelope));\n\n const gz = shouldUseCompression(payload, compress)\n ? gzipSync(payload)\n : payload;\n\n // prepend a 1-byte header indicating compression\n const buf = Buffer.concat([\n Buffer.from([gz === payload ? 0x00 : 0x01]),\n gz,\n ]);\n\n await atomicWriteFile(filePath, buf);\n } catch {\n // swallow disk errors for cache writes\n }\n };\n\n return {\n /** In-memory first, then disk (if enabled), otherwise undefined. */\n get: async <T>(): Promise<T | undefined> => {\n const mem = cacheMap.get(id);\n\n if (mem !== undefined) return mem as T;\n\n if (persistent && buildCacheEnabled) {\n return (await readFromDisk()) as T | undefined;\n }\n return undefined;\n },\n /** Sets in-memory (always) and persists to disk if enabled. */\n set: async (value: unknown): Promise<void> => {\n cacheMap.set(id, value);\n\n if (persistent && buildCacheEnabled) {\n await writeToDisk(value);\n }\n },\n /** Clears only this entry from memory and disk. */\n clear: async (): Promise<void> => {\n cacheMap.delete(id);\n\n try {\n await unlink(filePath);\n } catch {}\n },\n /** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */\n clearAll: async (): Promise<void> => {\n clearAllCache();\n if (persistent && buildCacheEnabled) {\n // remove only the current namespace (if provided), else the root dir\n const base = namespace ? join(cacheDir, namespace) : cacheDir;\n\n try {\n await rm(base, { recursive: true, force: true });\n } catch {}\n\n try {\n await mkdir(base, { recursive: true });\n } catch {}\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n isValid: async (): Promise<boolean> => {\n const cachedValue = cacheMap.get(id);\n if (cachedValue !== undefined) return true;\n\n // If persistence is disabled or build cache disabled, only memory can be valid\n if (!persistent || !buildCacheEnabled) return false;\n\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n if (!statValue) return false;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return false;\n }\n\n let raw = await readFile(filePath);\n const flag = raw[0];\n raw = raw.subarray(1);\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof maybeObj.version === 'string' &&\n typeof maybeObj.timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n if (entry.version !== configPackageJson.version) return false;\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) return false;\n }\n return true;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) return false;\n }\n return true;\n } catch {\n return false;\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n id,\n /** Expose the absolute file path for debugging. */\n filePath,\n };\n};\n"],"mappings":";;;;;;;;;;AA2CA,MAAM,WAA0D,EAC9D,UAAU,MACX;AAED,MAAM,YAAY,OAAO,QAAgB;AACvC,mCAAY,KAAK,EAAE,WAAW,MAAM,CAAC;;AAGvC,MAAM,kBAAkB,OAAO,MAAc,SAAiB;CAC5D,MAAM,MAAM,GAAG,KAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE;AAC7E,uCAAgB,KAAK,KAAK;AAC1B,oCAAa,KAAK,KAAK;;AAGzB,MAAM,wBAAwB,KAAa,UACzC,UAAU,QAAS,UAAU,SAAS,IAAI,aAAa;;AAGzD,MAAM,aAAa,UAAkB,IAAY,2BAC1C,UAAU,yBAAU,IAAI,GAAG,GAAG,GAAG;;AAIxC,MAAM,2BAAW,IAAI,KAAkB;AAEvC,MAAa,aACX,gBACA,MACA,YACG;CACH,MAAM,EAAE,aAAa,eAAe;CACpC,MAAM,oBAAoB,eAAe,MAAM,SAAS;CACxD,MAAM,aACJ,SAAS,eAAe,QACvB,OAAO,SAAS,eAAe,eAAe;CAEjD,MAAM,EAAE,UAAU,OAAO,WAAW,cAAc;EAChD,GAAG;EACH,GAAG;EACJ;CAGD,MAAM,KAAKA,uCAAa,KAAK;CAC7B,MAAM,WAAW,UAAU,UAAU,IAAI,UAAU;CAEnD,MAAM,eAAe,YAA0C;AAC7D,MAAI;GACF,MAAM,YAAY,iCAAW,SAAS,CAAC,YAAY,OAAU;AAE7D,OAAI,CAAC,UAAW,QAAO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