@intlayer/config 8.1.4 → 8.1.5

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 (29) hide show
  1. package/dist/cjs/configFile/buildConfigurationFields.cjs +1 -1
  2. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  3. package/dist/cjs/defaultValues/build.cjs +1 -1
  4. package/dist/cjs/defaultValues/build.cjs.map +1 -1
  5. package/dist/cjs/defaultValues/compiler.cjs +1 -1
  6. package/dist/cjs/defaultValues/compiler.cjs.map +1 -1
  7. package/dist/cjs/defaultValues/system.cjs +1 -1
  8. package/dist/cjs/defaultValues/system.cjs.map +1 -1
  9. package/dist/cjs/utils/cacheDisk.cjs +1 -1
  10. package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
  11. package/dist/esm/configFile/buildConfigurationFields.mjs +1 -1
  12. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  13. package/dist/esm/defaultValues/build.mjs +1 -1
  14. package/dist/esm/defaultValues/build.mjs.map +1 -1
  15. package/dist/esm/defaultValues/compiler.mjs +1 -1
  16. package/dist/esm/defaultValues/compiler.mjs.map +1 -1
  17. package/dist/esm/defaultValues/system.mjs +1 -1
  18. package/dist/esm/defaultValues/system.mjs.map +1 -1
  19. package/dist/esm/utils/cacheDisk.mjs +1 -1
  20. package/dist/esm/utils/cacheDisk.mjs.map +1 -1
  21. package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
  22. package/dist/types/defaultValues/build.d.ts +3 -2
  23. package/dist/types/defaultValues/build.d.ts.map +1 -1
  24. package/dist/types/defaultValues/compiler.d.ts +2 -1
  25. package/dist/types/defaultValues/compiler.d.ts.map +1 -1
  26. package/dist/types/defaultValues/system.d.ts +3 -2
  27. package/dist/types/defaultValues/system.d.ts.map +1 -1
  28. package/dist/types/utils/cacheDisk.d.ts.map +1 -1
  29. package/package.json +3 -3
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../defaultValues/build.cjs`),n=require(`../defaultValues/compiler.cjs`),r=require(`../defaultValues/content.cjs`),i=require(`../defaultValues/dictionary.cjs`),a=require(`../defaultValues/editor.cjs`),o=require(`../defaultValues/internationalization.cjs`),s=require(`../defaultValues/log.cjs`),c=require(`../defaultValues/routing.cjs`),l=require(`../defaultValues/system.cjs`),u=require(`../utils/normalizePath.cjs`);let d=require(`node:path`),f=require(`node:fs`),p=require(`@intlayer/types/package.json`);p=e.__toESM(p);let m;const h=e=>({locales:e?.locales??o.LOCALES,requiredLocales:e?.requiredLocales??e?.locales??o.REQUIRED_LOCALES,strictMode:e?.strictMode??o.STRICT_MODE,defaultLocale:e?.defaultLocale??o.DEFAULT_LOCALE}),g=e=>({mode:e?.mode??c.ROUTING_MODE,storage:e?.storage??c.STORAGE,basePath:e?.basePath??c.BASE_PATH,rewrite:e?.rewrite}),_=(e,t,n)=>{let i=e?.fileExtensions??r.FILE_EXTENSIONS,a=e?.baseDir??t??process.cwd(),o=e=>{let t;try{t=require.resolve(e,{paths:[a]})}catch{t=(0,d.isAbsolute)(e)?e:(0,d.join)(a,e)}try{if((0,f.statSync)(t).isFile())return(0,d.dirname)(t)}catch{if(/\.[a-z0-9]+$/i.test(t))return(0,d.dirname)(t)}return t},s=(e?.contentDir??r.CONTENT_DIR).map(o);return{fileExtensions:i,baseDir:a,contentDir:s,codeDir:(e?.codeDir??r.CODE_DIR).map(o),excludedPath:e?.excludedPath??r.EXCLUDED_PATHS,watch:e?.watch??r.WATCH,formatCommand:e?.formatCommand,watchedFilesPattern:i.map(e=>`/**/*${e}`),watchedFilesPatternWithPath:i.flatMap(e=>s.map(t=>`${u.normalizePath(t)}/**/*${e}`))}},v=(e,t)=>{let n=t?.baseDir??process.cwd(),r=e=>{let t;try{t=require.resolve(e,{paths:[n]})}catch{t=(0,d.isAbsolute)(e)?e:(0,d.join)(n,e)}try{if((0,f.statSync)(t).isFile())return(0,d.dirname)(t)}catch{if(/\.[a-z0-9]+$/i.test(t))return(0,d.dirname)(t)}return t},i=r(e?.dictionariesDir??l.DICTIONARIES_DIR);return{moduleAugmentationDir:r(e?.moduleAugmentationDir??l.MODULE_AUGMENTATION_DIR),unmergedDictionariesDir:r(e?.unmergedDictionariesDir??l.UNMERGED_DICTIONARIES_DIR),remoteDictionariesDir:r(e?.remoteDictionariesDir??l.REMOTE_DICTIONARIES_DIR),dictionariesDir:i,dynamicDictionariesDir:r(e?.dynamicDictionariesDir??l.DYNAMIC_DICTIONARIES_DIR),fetchDictionariesDir:r(e?.fetchDictionariesDir??l.FETCH_DICTIONARIES_DIR),typesDir:r(e?.typesDir??l.TYPES_DIR),mainDir:r(e?.mainDir??l.MAIN_DIR),configDir:r(e?.configDir??l.CONFIG_DIR),cacheDir:r(e?.cacheDir??l.CACHE_DIR),outputFilesPatternWithPath:`${u.normalizePath(i)}/**/*.json`}},y=e=>({applicationURL:e?.applicationURL??a.APPLICATION_URL,editorURL:e?.editorURL??a.EDITOR_URL,cmsURL:e?.cmsURL??a.CMS_URL,backendURL:e?.backendURL??a.BACKEND_URL,port:e?.port??a.PORT,enabled:e?.enabled??a.IS_ENABLED,clientId:e?.clientId??void 0,clientSecret:e?.clientSecret??void 0,dictionaryPriorityStrategy:e?.dictionaryPriorityStrategy??a.DICTIONARY_PRIORITY_STRATEGY,liveSync:e?.liveSync??a.LIVE_SYNC,liveSyncPort:e?.liveSyncPort??a.LIVE_SYNC_PORT,liveSyncURL:e?.liveSyncURL??`http://localhost:${e?.liveSyncPort??a.LIVE_SYNC_PORT}`}),b=(e,t)=>({mode:e?.mode??s.MODE,prefix:e?.prefix??s.PREFIX,error:t?.error,log:t?.log,info:t?.info,warn:t?.warn}),x=e=>({provider:e?.provider,apiKey:e?.apiKey,model:e?.model,temperature:e?.temperature,applicationContext:e?.applicationContext,baseURL:e?.baseURL,dataSerialization:e?.dataSerialization}),S=e=>({mode:e?.mode??t.BUILD_MODE,optimize:e?.optimize,importMode:e?.importMode,traversePattern:e?.traversePattern??t.TRAVERSE_PATTERN,outputFormat:e?.outputFormat??t.OUTPUT_FORMAT,cache:e?.cache??t.CACHE,require:e?.require}),C=e=>({enabled:e?.enabled??n.COMPILER_ENABLED,transformPattern:e?.transformPattern??n.COMPILER_TRANSFORM_PATTERN,excludePattern:e?.excludePattern??n.COMPILER_EXCLUDE_PATTERN,outputDir:e?.outputDir??n.COMPILER_OUTPUT_DIR}),w=e=>{let t=e?.contentAutoTransformation??i.CONTENT_AUTO_TRANSFORMATION;return{fill:e?.fill??i.FILL,contentAutoTransformation:typeof t==`object`?{markdown:t.markdown??!1,html:t.html??!1,insertion:t.insertion??!1}:t,location:e?.location??i.LOCATION,locale:e?.locale,title:e?.title,description:e?.description,tags:e?.tags,priority:e?.priority,importMode:e?.importMode??i.IMPORT_MODE,version:e?.version}},T=(e,t,n)=>{let r=h(e?.internationalization),i=g(e?.routing),a=_(e?.content,t,n);return m={internationalization:r,routing:i,content:a,system:v(e?.system,a),editor:y(e?.editor),log:b(e?.log,n),ai:x(e?.ai),build:S(e?.build),compiler:C(e?.compiler),dictionary:w(e?.dictionary),plugins:e?.plugins,schemas:e?.schemas,metadata:{name:`Intlayer`,version:p.default.version,doc:`https://intlayer.org/docs`}},m};exports.buildConfigurationFields=T;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../defaultValues/build.cjs`),n=require(`../defaultValues/compiler.cjs`),r=require(`../defaultValues/content.cjs`),i=require(`../defaultValues/dictionary.cjs`),a=require(`../defaultValues/editor.cjs`),o=require(`../defaultValues/internationalization.cjs`),s=require(`../defaultValues/log.cjs`),c=require(`../defaultValues/routing.cjs`),l=require(`../defaultValues/system.cjs`),u=require(`../utils/normalizePath.cjs`);let d=require(`node:path`),f=require(`node:fs`),p=require(`@intlayer/types/package.json`);p=e.__toESM(p);let m;const h=e=>({locales:e?.locales??o.LOCALES,requiredLocales:e?.requiredLocales??e?.locales??o.REQUIRED_LOCALES,strictMode:e?.strictMode??o.STRICT_MODE,defaultLocale:e?.defaultLocale??o.DEFAULT_LOCALE}),g=e=>({mode:e?.mode??c.ROUTING_MODE,storage:e?.storage??c.STORAGE,basePath:e?.basePath??c.BASE_PATH,rewrite:e?.rewrite}),_=(e,t,n)=>{let i=e?.fileExtensions??r.FILE_EXTENSIONS,a=e?.baseDir??t??process.cwd(),o=e=>{let t;try{t=require.resolve(e,{paths:[a]})}catch{t=(0,d.isAbsolute)(e)?e:(0,d.join)(a,e)}try{if((0,f.statSync)(t).isFile())return(0,d.dirname)(t)}catch{if(/\.[a-z0-9]+$/i.test(t))return(0,d.dirname)(t)}return t},s=(e?.contentDir??r.CONTENT_DIR).map(o);return{fileExtensions:i,baseDir:a,contentDir:s,codeDir:(e?.codeDir??r.CODE_DIR).map(o),excludedPath:e?.excludedPath??r.EXCLUDED_PATHS,watch:e?.watch??r.WATCH,formatCommand:e?.formatCommand,watchedFilesPattern:i.map(e=>`/**/*${e}`),watchedFilesPatternWithPath:i.flatMap(e=>s.map(t=>`${u.normalizePath(t)}/**/*${e}`))}},v=(e,t)=>{let n=t?.baseDir??process.cwd(),r=e=>{let t;try{t=require.resolve(e,{paths:[n]})}catch{t=(0,d.isAbsolute)(e)?e:(0,d.join)(n,e)}try{if((0,f.statSync)(t).isFile())return(0,d.dirname)(t)}catch{if(/\.[a-z0-9]+$/i.test(t))return(0,d.dirname)(t)}return t},i=r(e?.dictionariesDir??l.DICTIONARIES_DIR);return{moduleAugmentationDir:r(e?.moduleAugmentationDir??l.MODULE_AUGMENTATION_DIR),unmergedDictionariesDir:r(e?.unmergedDictionariesDir??l.UNMERGED_DICTIONARIES_DIR),remoteDictionariesDir:r(e?.remoteDictionariesDir??l.REMOTE_DICTIONARIES_DIR),dictionariesDir:i,dynamicDictionariesDir:r(e?.dynamicDictionariesDir??l.DYNAMIC_DICTIONARIES_DIR),fetchDictionariesDir:r(e?.fetchDictionariesDir??l.FETCH_DICTIONARIES_DIR),typesDir:r(e?.typesDir??l.TYPES_DIR),mainDir:r(e?.mainDir??l.MAIN_DIR),configDir:r(e?.configDir??l.CONFIG_DIR),cacheDir:r(e?.cacheDir??l.CACHE_DIR),tempDir:r(e?.tempDir??l.TEMP_DIR),outputFilesPatternWithPath:`${u.normalizePath(i)}/**/*.json`}},y=e=>({applicationURL:e?.applicationURL??a.APPLICATION_URL,editorURL:e?.editorURL??a.EDITOR_URL,cmsURL:e?.cmsURL??a.CMS_URL,backendURL:e?.backendURL??a.BACKEND_URL,port:e?.port??a.PORT,enabled:e?.enabled??a.IS_ENABLED,clientId:e?.clientId??void 0,clientSecret:e?.clientSecret??void 0,dictionaryPriorityStrategy:e?.dictionaryPriorityStrategy??a.DICTIONARY_PRIORITY_STRATEGY,liveSync:e?.liveSync??a.LIVE_SYNC,liveSyncPort:e?.liveSyncPort??a.LIVE_SYNC_PORT,liveSyncURL:e?.liveSyncURL??`http://localhost:${e?.liveSyncPort??a.LIVE_SYNC_PORT}`}),b=(e,t)=>({mode:e?.mode??s.MODE,prefix:e?.prefix??s.PREFIX,error:t?.error,log:t?.log,info:t?.info,warn:t?.warn}),x=e=>({provider:e?.provider,apiKey:e?.apiKey,model:e?.model,temperature:e?.temperature,applicationContext:e?.applicationContext,baseURL:e?.baseURL,dataSerialization:e?.dataSerialization}),S=e=>({mode:e?.mode??t.BUILD_MODE,optimize:e?.optimize,importMode:e?.importMode,traversePattern:e?.traversePattern??t.TRAVERSE_PATTERN,outputFormat:e?.outputFormat??t.OUTPUT_FORMAT,cache:e?.cache??t.CACHE,require:e?.require,checkTypes:e?.checkTypes??t.TYPE_CHECKING}),C=e=>({enabled:e?.enabled??n.COMPILER_ENABLED,dictionaryKeyPrefix:e?.dictionaryKeyPrefix??n.COMPILER_DICTIONARY_KEY_PREFIX,transformPattern:e?.transformPattern??n.COMPILER_TRANSFORM_PATTERN,excludePattern:e?.excludePattern??n.COMPILER_EXCLUDE_PATTERN,outputDir:e?.outputDir??n.COMPILER_OUTPUT_DIR}),w=e=>{let t=e?.contentAutoTransformation??i.CONTENT_AUTO_TRANSFORMATION;return{fill:e?.fill??i.FILL,contentAutoTransformation:typeof t==`object`?{markdown:t.markdown??!1,html:t.html??!1,insertion:t.insertion??!1}:t,location:e?.location??i.LOCATION,locale:e?.locale,title:e?.title,description:e?.description,tags:e?.tags,priority:e?.priority,importMode:e?.importMode??i.IMPORT_MODE,version:e?.version}},T=(e,t,n)=>{let r=h(e?.internationalization),i=g(e?.routing),a=_(e?.content,t,n);return m={internationalization:r,routing:i,content:a,system:v(e?.system,a),editor:y(e?.editor),log:b(e?.log,n),ai:x(e?.ai),build:S(e?.build),compiler:C(e?.compiler),dictionary:w(e?.dictionary),plugins:e?.plugins,schemas:e?.schemas,metadata:{name:`Intlayer`,version:p.default.version,doc:`https://intlayer.org/docs`}},m};exports.buildConfigurationFields=T;
2
2
  //# sourceMappingURL=buildConfigurationFields.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildConfigurationFields.cjs","names":["LOCALES","REQUIRED_LOCALES","STRICT_MODE","DEFAULT_LOCALE","ROUTING_MODE","STORAGE","BASE_PATH","FILE_EXTENSIONS","CONTENT_DIR","CODE_DIR","EXCLUDED_PATHS","WATCH","normalizePath","DICTIONARIES_DIR","MODULE_AUGMENTATION_DIR","UNMERGED_DICTIONARIES_DIR","REMOTE_DICTIONARIES_DIR","DYNAMIC_DICTIONARIES_DIR","FETCH_DICTIONARIES_DIR","TYPES_DIR","MAIN_DIR","CONFIG_DIR","CACHE_DIR","APPLICATION_URL","EDITOR_URL","CMS_URL","BACKEND_URL","PORT","IS_ENABLED","DICTIONARY_PRIORITY_STRATEGY","LIVE_SYNC","LIVE_SYNC_PORT","MODE","PREFIX","BUILD_MODE","TRAVERSE_PATTERN","OUTPUT_FORMAT","CACHE","COMPILER_ENABLED","COMPILER_TRANSFORM_PATTERN","COMPILER_EXCLUDE_PATTERN","COMPILER_OUTPUT_DIR","CONTENT_AUTO_TRANSFORMATION","FILL","LOCATION","IMPORT_MODE","packageJson"],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { statSync } from 'node:fs';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport type {\n AiConfig,\n BuildConfig,\n CompilerConfig,\n ContentConfig,\n CustomIntlayerConfig,\n DictionaryConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n LogFunctions,\n RoutingConfig,\n SystemConfig,\n} from '@intlayer/types';\nimport packageJson from '@intlayer/types/package.json' with { type: 'json' };\nimport {\n BUILD_MODE,\n CACHE,\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 CODE_DIR,\n CONTENT_DIR,\n EXCLUDED_PATHS,\n FILE_EXTENSIONS,\n WATCH,\n} from '../defaultValues/content';\nimport {\n CONTENT_AUTO_TRANSFORMATION,\n FILL,\n IMPORT_MODE,\n LOCATION,\n} 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 {\n CACHE_DIR,\n CONFIG_DIR,\n DICTIONARIES_DIR,\n DYNAMIC_DICTIONARIES_DIR,\n FETCH_DICTIONARIES_DIR,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REMOTE_DICTIONARIES_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n} from '../defaultValues/system';\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 /**\n * Custom URL rewriting rules that override the default routing mode for specific paths.\n * Allows you to define locale-specific paths that differ from the standard routing behavior.\n * Supports dynamic route parameters using `[param]` syntax.\n *\n * Default: undefined\n *\n * Example:\n * ```typescript\n * rewrite: {\n * \"/about\": {\n * en: \"/about\",\n * fr: \"/a-propos\",\n * },\n * \"/product/[slug]\": {\n * en: \"/product/[slug]\",\n * fr: \"/produit/[slug]\",\n * },\n * }\n * ```\n *\n * Note:\n * - The rewrite rules take precedence over the default `mode` behavior.\n * - If a path matches a rewrite rule, the localized path from the rewrite configuration will be used.\n * - Dynamic route parameters are supported using bracket notation (e.g., `[slug]`, `[id]`).\n * - Works with both Next.js and Vite applications.\n */\n rewrite: customConfiguration?.rewrite,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>,\n baseDir?: string,\n logFunctions?: LogFunctions\n): ContentConfig => {\n const fileExtensions = customConfiguration?.fileExtensions ?? FILE_EXTENSIONS;\n const projectBaseDir =\n customConfiguration?.baseDir ?? baseDir ?? process.cwd();\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: [projectBaseDir],\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(projectBaseDir, 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 contentDir = (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n optionalJoinBaseDir\n );\n\n const codeDirInput = customConfiguration?.codeDir;\n\n const codeDir = (codeDirInput ?? CODE_DIR).map(optionalJoinBaseDir);\n\n return {\n fileExtensions,\n baseDir: projectBaseDir,\n contentDir,\n codeDir,\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n watch: customConfiguration?.watch ?? WATCH,\n formatCommand: customConfiguration?.formatCommand,\n watchedFilesPattern: fileExtensions.map((ext) => `/**/*${ext}`),\n watchedFilesPatternWithPath: fileExtensions.flatMap((ext) =>\n contentDir.map((dir) => `${normalizePath(dir)}/**/*${ext}`)\n ),\n };\n};\n\nconst buildSystemFields = (\n customConfiguration?: Partial<SystemConfig>,\n contentConfig?: ContentConfig\n): SystemConfig => {\n const projectBaseDir = contentConfig?.baseDir ?? process.cwd();\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n absolutePath = require.resolve(pathInput, {\n paths: [projectBaseDir],\n });\n } catch {\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(projectBaseDir, pathInput);\n }\n\n try {\n const stats = statSync(absolutePath);\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n return absolutePath;\n };\n\n const dictionariesDir = optionalJoinBaseDir(\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n );\n\n return {\n moduleAugmentationDir: optionalJoinBaseDir(\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n unmergedDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n remoteDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR\n ),\n dictionariesDir,\n dynamicDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR\n ),\n fetchDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR\n ),\n typesDir: optionalJoinBaseDir(customConfiguration?.typesDir ?? TYPES_DIR),\n mainDir: optionalJoinBaseDir(customConfiguration?.mainDir ?? MAIN_DIR),\n configDir: optionalJoinBaseDir(\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n cacheDir: optionalJoinBaseDir(customConfiguration?.cacheDir ?? CACHE_DIR),\n outputFilesPatternWithPath: `${normalizePath(dictionariesDir)}/**/*.json`,\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 /**\n * Data serialization\n *\n * Options:\n * - \"json\": The industry standard. Highly reliable and structured, but consumes more tokens.\n * - \"toon\": An optimized format designed to reduce token consumption (cost-effective). However, it may slightly increase the risk of output inconsistency compared to standard JSON\n *\n * Default: \"json\"\n */\n dataSerialization: customConfiguration?.dataSerialization,\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 * @deprecated Use `dictionary.importMode` instead.\n */\n importMode: customConfiguration?.importMode,\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}', '!**\\/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 const contentAutoTransformation =\n customConfiguration?.contentAutoTransformation ??\n CONTENT_AUTO_TRANSFORMATION;\n\n return {\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: true\n */\n fill: customConfiguration?.fill ?? FILL,\n\n /**\n * Indicates if the content of the dictionary should be automatically transformed.\n *\n * Default: false\n */\n contentAutoTransformation:\n typeof contentAutoTransformation === 'object'\n ? {\n markdown: contentAutoTransformation.markdown ?? false,\n html: contentAutoTransformation.html ?? false,\n insertion: contentAutoTransformation.insertion ?? false,\n }\n : contentAutoTransformation,\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 the mode of import to use for the dictionary.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n *\n * Default: 'static'\n */\n importMode: customConfiguration?.importMode ?? IMPORT_MODE,\n\n /**\n * The version of the dictionary.\n */\n version: customConfiguration?.version,\n };\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 logFunctions\n );\n\n const systemConfig = buildSystemFields(\n customConfiguration?.system,\n contentConfig\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 system: systemConfig,\n editor: editorConfig,\n log: logConfig,\n ai: aiConfig,\n build: buildConfig,\n compiler: compilerConfig,\n dictionary: dictionaryConfig,\n plugins: customConfiguration?.plugins,\n schemas: customConfiguration?.schemas,\n metadata: {\n name: 'Intlayer',\n version: packageJson.version,\n doc: `https://intlayer.org/docs`,\n },\n } as IntlayerConfig;\n\n return storedConfiguration;\n};\n"],"mappings":"4oBA4EA,IAAI,EAEJ,MAAM,EACJ,IACgC,CAOhC,QAAS,GAAqB,SAAWA,EAAAA,QAWzC,gBACE,GAAqB,iBACrB,GAAqB,SACrBC,EAAAA,iBAUF,WAAY,GAAqB,YAAcC,EAAAA,YAO/C,cAAe,GAAqB,eAAiBC,EAAAA,eACtD,EAEK,EACJ,IACmB,CAuBnB,KAAM,GAAqB,MAAQC,EAAAA,aAWnC,QAAS,GAAqB,SAAWC,EAAAA,QAazC,SAAU,GAAqB,UAAYC,EAAAA,UA6B3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ACrB,EACA,EACD,CAyCD,MApBA,GAAsB,CACpB,qBAAsB,EACtB,QAAS,EACT,QAAS,EACT,OAvBmB,EACnB,GAAqB,OACrB,EACD,CAqBC,OAnBmB,EAAkB,GAAqB,OAAO,CAoBjE,IAlBgB,EAAe,GAAqB,IAAK,EAAa,CAmBtE,GAjBe,EAAc,GAAqB,GAAG,CAkBrD,MAhBkB,EAAiB,GAAqB,MAAM,CAiB9D,SAfqB,EAAoB,GAAqB,SAAS,CAgBvE,WAduB,EACvB,GAAqB,WACtB,CAaC,QAAS,GAAqB,QAC9B,QAAS,GAAqB,QAC9B,SAAU,CACR,KAAM,WACN,QAASC,EAAAA,QAAY,QACrB,IAAK,4BACN,CACF,CAEM"}
1
+ {"version":3,"file":"buildConfigurationFields.cjs","names":["LOCALES","REQUIRED_LOCALES","STRICT_MODE","DEFAULT_LOCALE","ROUTING_MODE","STORAGE","BASE_PATH","FILE_EXTENSIONS","CONTENT_DIR","CODE_DIR","EXCLUDED_PATHS","WATCH","normalizePath","DICTIONARIES_DIR","MODULE_AUGMENTATION_DIR","UNMERGED_DICTIONARIES_DIR","REMOTE_DICTIONARIES_DIR","DYNAMIC_DICTIONARIES_DIR","FETCH_DICTIONARIES_DIR","TYPES_DIR","MAIN_DIR","CONFIG_DIR","CACHE_DIR","TEMP_DIR","APPLICATION_URL","EDITOR_URL","CMS_URL","BACKEND_URL","PORT","IS_ENABLED","DICTIONARY_PRIORITY_STRATEGY","LIVE_SYNC","LIVE_SYNC_PORT","MODE","PREFIX","BUILD_MODE","TRAVERSE_PATTERN","OUTPUT_FORMAT","CACHE","TYPE_CHECKING","COMPILER_ENABLED","COMPILER_DICTIONARY_KEY_PREFIX","COMPILER_TRANSFORM_PATTERN","COMPILER_EXCLUDE_PATTERN","COMPILER_OUTPUT_DIR","CONTENT_AUTO_TRANSFORMATION","FILL","LOCATION","IMPORT_MODE","packageJson"],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { statSync } from 'node:fs';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport type {\n AiConfig,\n BuildConfig,\n CompilerConfig,\n ContentConfig,\n CustomIntlayerConfig,\n DictionaryConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n LogFunctions,\n RoutingConfig,\n SystemConfig,\n} from '@intlayer/types';\nimport packageJson from '@intlayer/types/package.json' with { type: 'json' };\nimport {\n BUILD_MODE,\n CACHE,\n OUTPUT_FORMAT,\n TRAVERSE_PATTERN,\n TYPE_CHECKING,\n} from '../defaultValues/build';\nimport {\n COMPILER_DICTIONARY_KEY_PREFIX,\n COMPILER_ENABLED,\n COMPILER_EXCLUDE_PATTERN,\n COMPILER_OUTPUT_DIR,\n COMPILER_TRANSFORM_PATTERN,\n} from '../defaultValues/compiler';\nimport {\n CODE_DIR,\n CONTENT_DIR,\n EXCLUDED_PATHS,\n FILE_EXTENSIONS,\n WATCH,\n} from '../defaultValues/content';\nimport {\n CONTENT_AUTO_TRANSFORMATION,\n FILL,\n IMPORT_MODE,\n LOCATION,\n} 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 {\n CACHE_DIR,\n CONFIG_DIR,\n DICTIONARIES_DIR,\n DYNAMIC_DICTIONARIES_DIR,\n FETCH_DICTIONARIES_DIR,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REMOTE_DICTIONARIES_DIR,\n TEMP_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n} from '../defaultValues/system';\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 /**\n * Custom URL rewriting rules that override the default routing mode for specific paths.\n * Allows you to define locale-specific paths that differ from the standard routing behavior.\n * Supports dynamic route parameters using `[param]` syntax.\n *\n * Default: undefined\n *\n * Example:\n * ```typescript\n * rewrite: {\n * \"/about\": {\n * en: \"/about\",\n * fr: \"/a-propos\",\n * },\n * \"/product/[slug]\": {\n * en: \"/product/[slug]\",\n * fr: \"/produit/[slug]\",\n * },\n * }\n * ```\n *\n * Note:\n * - The rewrite rules take precedence over the default `mode` behavior.\n * - If a path matches a rewrite rule, the localized path from the rewrite configuration will be used.\n * - Dynamic route parameters are supported using bracket notation (e.g., `[slug]`, `[id]`).\n * - Works with both Next.js and Vite applications.\n */\n rewrite: customConfiguration?.rewrite,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>,\n baseDir?: string,\n logFunctions?: LogFunctions\n): ContentConfig => {\n const fileExtensions = customConfiguration?.fileExtensions ?? FILE_EXTENSIONS;\n const projectBaseDir =\n customConfiguration?.baseDir ?? baseDir ?? process.cwd();\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: [projectBaseDir],\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(projectBaseDir, 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 contentDir = (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n optionalJoinBaseDir\n );\n\n const codeDirInput = customConfiguration?.codeDir;\n\n const codeDir = (codeDirInput ?? CODE_DIR).map(optionalJoinBaseDir);\n\n return {\n fileExtensions,\n baseDir: projectBaseDir,\n contentDir,\n codeDir,\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n watch: customConfiguration?.watch ?? WATCH,\n formatCommand: customConfiguration?.formatCommand,\n watchedFilesPattern: fileExtensions.map((ext) => `/**/*${ext}`),\n watchedFilesPatternWithPath: fileExtensions.flatMap((ext) =>\n contentDir.map((dir) => `${normalizePath(dir)}/**/*${ext}`)\n ),\n };\n};\n\nconst buildSystemFields = (\n customConfiguration?: Partial<SystemConfig>,\n contentConfig?: ContentConfig\n): SystemConfig => {\n const projectBaseDir = contentConfig?.baseDir ?? process.cwd();\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n absolutePath = require.resolve(pathInput, {\n paths: [projectBaseDir],\n });\n } catch {\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(projectBaseDir, pathInput);\n }\n\n try {\n const stats = statSync(absolutePath);\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n return absolutePath;\n };\n\n const dictionariesDir = optionalJoinBaseDir(\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n );\n\n return {\n moduleAugmentationDir: optionalJoinBaseDir(\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n unmergedDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n remoteDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR\n ),\n dictionariesDir,\n dynamicDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR\n ),\n fetchDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR\n ),\n typesDir: optionalJoinBaseDir(customConfiguration?.typesDir ?? TYPES_DIR),\n mainDir: optionalJoinBaseDir(customConfiguration?.mainDir ?? MAIN_DIR),\n configDir: optionalJoinBaseDir(\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n cacheDir: optionalJoinBaseDir(customConfiguration?.cacheDir ?? CACHE_DIR),\n tempDir: optionalJoinBaseDir(customConfiguration?.tempDir ?? TEMP_DIR),\n outputFilesPatternWithPath: `${normalizePath(dictionariesDir)}/**/*.json`,\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 /**\n * Data serialization\n *\n * Options:\n * - \"json\": The industry standard. Highly reliable and structured, but consumes more tokens.\n * - \"toon\": An optimized format designed to reduce token consumption (cost-effective). However, it may slightly increase the risk of output inconsistency compared to standard JSON\n *\n * Default: \"json\"\n */\n dataSerialization: customConfiguration?.dataSerialization,\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 * @deprecated Use `dictionary.importMode` instead.\n */\n importMode: customConfiguration?.importMode,\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}', '!**\\/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 /**\n * Indicates if the build should check TypeScript types\n *\n * Default: false\n *\n * If true, the build will check TypeScript types and log errors.\n * Note: This can slow down the build.\n */\n checkTypes: customConfiguration?.checkTypes ?? TYPE_CHECKING,\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 * Prefix for the extracted dictionary keys\n */\n dictionaryKeyPrefix:\n customConfiguration?.dictionaryKeyPrefix ?? COMPILER_DICTIONARY_KEY_PREFIX,\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 const contentAutoTransformation =\n customConfiguration?.contentAutoTransformation ??\n CONTENT_AUTO_TRANSFORMATION;\n\n return {\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: true\n */\n fill: customConfiguration?.fill ?? FILL,\n\n /**\n * Indicates if the content of the dictionary should be automatically transformed.\n *\n * Default: false\n */\n contentAutoTransformation:\n typeof contentAutoTransformation === 'object'\n ? {\n markdown: contentAutoTransformation.markdown ?? false,\n html: contentAutoTransformation.html ?? false,\n insertion: contentAutoTransformation.insertion ?? false,\n }\n : contentAutoTransformation,\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 the mode of import to use for the dictionary.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n *\n * Default: 'static'\n */\n importMode: customConfiguration?.importMode ?? IMPORT_MODE,\n\n /**\n * The version of the dictionary.\n */\n version: customConfiguration?.version,\n };\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 logFunctions\n );\n\n const systemConfig = buildSystemFields(\n customConfiguration?.system,\n contentConfig\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 system: systemConfig,\n editor: editorConfig,\n log: logConfig,\n ai: aiConfig,\n build: buildConfig,\n compiler: compilerConfig,\n dictionary: dictionaryConfig,\n plugins: customConfiguration?.plugins,\n schemas: customConfiguration?.schemas,\n metadata: {\n name: 'Intlayer',\n version: packageJson.version,\n doc: `https://intlayer.org/docs`,\n },\n } as IntlayerConfig;\n\n return storedConfiguration;\n};\n"],"mappings":"4oBA+EA,IAAI,EAEJ,MAAM,EACJ,IACgC,CAOhC,QAAS,GAAqB,SAAWA,EAAAA,QAWzC,gBACE,GAAqB,iBACrB,G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WAAa,GACnD,CACD,EAON,SAAU,GAAqB,UAAYC,EAAAA,SAO3C,OAAQ,GAAqB,OAK7B,MAAO,GAAqB,MAK5B,YAAa,GAAqB,YAKlC,KAAM,GAAqB,KAK3B,SAAU,GAAqB,SAY/B,WAAY,GAAqB,YAAcC,EAAAA,YAK/C,QAAS,GAAqB,QAC/B,EAMU,GACX,EACA,EACA,IACmB,CACnB,IAAM,EAA6B,EACjC,GAAqB,qBACtB,CAEK,EAAgB,EAAmB,GAAqB,QAAQ,CAEhE,EAAgB,EACpB,GAAqB,QACrB,EACA,EACD,CAyCD,MApBA,GAAsB,CACpB,qBAAsB,EACtB,QAAS,EACT,QAAS,EACT,OAvBmB,EACnB,GAAqB,OACrB,EACD,CAqBC,OAnBmB,EAAkB,GAAqB,OAAO,CAoBjE,IAlBgB,EAAe,GAAqB,IAAK,EAAa,CAmBtE,GAjBe,EAAc,GAAqB,GAAG,CAkBrD,MAhBkB,EAAiB,GAAqB,MAAM,CAiB9D,SAfqB,EAAoB,GAAqB,SAAS,CAgBvE,WAduB,EACvB,GAAqB,WACtB,CAaC,QAAS,GAAqB,QAC9B,QAAS,GAAqB,QAC9B,SAAU,CACR,KAAM,WACN,QAASC,EAAAA,QAAY,QACrB,IAAK,4BACN,CACF,CAEM"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=require(`../_virtual/_rolldown/runtime.cjs`).__exportAll({BUILD_MODE:()=>t,CACHE:()=>a,OPTIMIZE:()=>n,OUTPUT_FORMAT:()=>i,TRAVERSE_PATTERN:()=>r});const t=`auto`,n=void 0,r=[`**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,svte}`,`!**/node_modules/**`],i=[`esm`,`cjs`],a=!0;exports.BUILD_MODE=t,exports.CACHE=!0,exports.OPTIMIZE=void 0,exports.OUTPUT_FORMAT=i,exports.TRAVERSE_PATTERN=r,Object.defineProperty(exports,`build_exports`,{enumerable:!0,get:function(){return e}});
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=require(`../_virtual/_rolldown/runtime.cjs`).__exportAll({BUILD_MODE:()=>t,CACHE:()=>a,OPTIMIZE:()=>n,OUTPUT_FORMAT:()=>i,TRAVERSE_PATTERN:()=>r,TYPE_CHECKING:()=>o});const t=`auto`,n=void 0,r=[`**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,svte}`,`!**/node_modules/**`],i=[`esm`,`cjs`],a=!0,o=!1;exports.BUILD_MODE=t,exports.CACHE=!0,exports.OPTIMIZE=void 0,exports.OUTPUT_FORMAT=i,exports.TRAVERSE_PATTERN=r,exports.TYPE_CHECKING=!1,Object.defineProperty(exports,`build_exports`,{enumerable:!0,get:function(){return e}});
2
2
  //# sourceMappingURL=build.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.cjs","names":[],"sources":["../../../src/defaultValues/build.ts"],"sourcesContent":["export const BUILD_MODE = 'auto';\n\nexport const OPTIMIZE = undefined;\n\nexport const TRAVERSE_PATTERN = [\n '**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,svte}',\n '!**/node_modules/**',\n];\n\nexport const OUTPUT_FORMAT: ('cjs' | 'esm')[] = ['esm', 'cjs'];\n\nexport const CACHE = true;\n"],"mappings":"4NAAA,MAAa,EAAa,OAEb,EAAW,IAAA,GAEX,EAAmB,CAC9B,+CACA,sBACD,CAEY,EAAmC,CAAC,MAAO,MAAM,CAEjD,EAAQ"}
1
+ {"version":3,"file":"build.cjs","names":[],"sources":["../../../src/defaultValues/build.ts"],"sourcesContent":["export const BUILD_MODE = 'auto';\n\nexport const OPTIMIZE = undefined;\n\nexport const TRAVERSE_PATTERN = [\n '**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,svte}',\n '!**/node_modules/**',\n];\n\nexport const OUTPUT_FORMAT: ('cjs' | 'esm')[] = ['esm', 'cjs'];\n\nexport const CACHE = true;\n\nexport const TYPE_CHECKING = false;\n"],"mappings":"gPAAA,MAAa,EAAa,OAEb,EAAW,IAAA,GAEX,EAAmB,CAC9B,+CACA,sBACD,CAEY,EAAmC,CAAC,MAAO,MAAM,CAEjD,EAAQ,GAER,EAAgB"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=[`**/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}`],t=[`**/node_modules/**`,`**/dist/**`,`**/.next/**`,`**/.nuxt/**`,`**/.expo/**`,`**/.vercel/**`,`**/.turbo/**`,`**/.tanstack/**`,`**/*.stories.ts`,`**/*.test.ts`];exports.COMPILER_ENABLED=!0,exports.COMPILER_EXCLUDE_PATTERN=t,exports.COMPILER_OUTPUT_DIR=`./compiler`,exports.COMPILER_TRANSFORM_PATTERN=e;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=[`**/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}`],t=[`**/node_modules/**`,`**/dist/**`,`**/.next/**`,`**/.nuxt/**`,`**/.expo/**`,`**/.vercel/**`,`**/.turbo/**`,`**/.tanstack/**`,`**/*.stories.ts`,`**/*.test.ts`];exports.COMPILER_DICTIONARY_KEY_PREFIX=`comp-`,exports.COMPILER_ENABLED=!0,exports.COMPILER_EXCLUDE_PATTERN=t,exports.COMPILER_OUTPUT_DIR=`./compiler`,exports.COMPILER_TRANSFORM_PATTERN=e;
2
2
  //# sourceMappingURL=compiler.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.cjs","names":[],"sources":["../../../src/defaultValues/compiler.ts"],"sourcesContent":["export const COMPILER_ENABLED = true;\nexport const COMPILER_TRANSFORM_PATTERN = [\n '**/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}',\n];\nexport const COMPILER_EXCLUDE_PATTERN = [\n '**/node_modules/**',\n '**/dist/**',\n '**/.next/**',\n '**/.nuxt/**',\n '**/.expo/**',\n '**/.vercel/**',\n '**/.turbo/**',\n '**/.tanstack/**',\n '**/*.stories.ts',\n '**/*.test.ts',\n];\nexport const COMPILER_OUTPUT_DIR = './compiler';\n"],"mappings":"mEAAA,MACa,EAA6B,CACxC,0CACD,CACY,EAA2B,CACtC,qBACA,aACA,cACA,cACA,cACA,gBACA,eACA,kBACA,kBACA,eACD"}
1
+ {"version":3,"file":"compiler.cjs","names":[],"sources":["../../../src/defaultValues/compiler.ts"],"sourcesContent":["export const COMPILER_ENABLED = true;\n\nexport const COMPILER_DICTIONARY_KEY_PREFIX = 'comp-';\n\nexport const COMPILER_TRANSFORM_PATTERN = [\n '**/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}',\n];\nexport const COMPILER_EXCLUDE_PATTERN = [\n '**/node_modules/**',\n '**/dist/**',\n '**/.next/**',\n '**/.nuxt/**',\n '**/.expo/**',\n '**/.vercel/**',\n '**/.turbo/**',\n '**/.tanstack/**',\n '**/*.stories.ts',\n '**/*.test.ts',\n];\nexport const COMPILER_OUTPUT_DIR = './compiler';\n"],"mappings":"mEAAA,MAIa,EAA6B,CACxC,0CACD,CACY,EAA2B,CACtC,qBACA,aACA,cACA,cACA,cACA,gBACA,eACA,kBACA,kBACA,eACD"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=require(`../_virtual/_rolldown/runtime.cjs`).__exportAll({CACHE_DIR:()=>d,CONFIG_DIR:()=>u,DICTIONARIES_DIR:()=>n,DYNAMIC_DICTIONARIES_DIR:()=>o,FETCH_DICTIONARIES_DIR:()=>s,MAIN_DIR:()=>t,MASKS_DIR:()=>r,MODULE_AUGMENTATION_DIR:()=>l,REMOTE_DICTIONARIES_DIR:()=>i,TYPES_DIR:()=>c,UNMERGED_DICTIONARIES_DIR:()=>a});const t=`.intlayer/main`,n=`.intlayer/dictionary`,r=`.intlayer/mask`,i=`.intlayer/remote_dictionary`,a=`.intlayer/unmerged_dictionary`,o=`.intlayer/dynamic_dictionary`,s=`.intlayer/fetch_dictionary`,c=`.intlayer/types`,l=`.intlayer/types`,u=`.intlayer/config`,d=`.intlayer/cache`;exports.CACHE_DIR=d,exports.CONFIG_DIR=u,exports.DICTIONARIES_DIR=n,exports.DYNAMIC_DICTIONARIES_DIR=o,exports.FETCH_DICTIONARIES_DIR=s,exports.MAIN_DIR=t,exports.MASKS_DIR=r,exports.MODULE_AUGMENTATION_DIR=l,exports.REMOTE_DICTIONARIES_DIR=i,exports.TYPES_DIR=c,exports.UNMERGED_DICTIONARIES_DIR=a,Object.defineProperty(exports,`system_exports`,{enumerable:!0,get:function(){return e}});
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=require(`../_virtual/_rolldown/runtime.cjs`).__exportAll({CACHE_DIR:()=>d,CONFIG_DIR:()=>u,DICTIONARIES_DIR:()=>n,DYNAMIC_DICTIONARIES_DIR:()=>o,FETCH_DICTIONARIES_DIR:()=>s,MAIN_DIR:()=>t,MASKS_DIR:()=>r,MODULE_AUGMENTATION_DIR:()=>l,REMOTE_DICTIONARIES_DIR:()=>i,TEMP_DIR:()=>f,TYPES_DIR:()=>c,UNMERGED_DICTIONARIES_DIR:()=>a});const t=`.intlayer/main`,n=`.intlayer/dictionary`,r=`.intlayer/mask`,i=`.intlayer/remote_dictionary`,a=`.intlayer/unmerged_dictionary`,o=`.intlayer/dynamic_dictionary`,s=`.intlayer/fetch_dictionary`,c=`.intlayer/types`,l=`.intlayer/types`,u=`.intlayer/config`,d=`.intlayer/cache`,f=`.intlayer/tmp`;exports.CACHE_DIR=d,exports.CONFIG_DIR=u,exports.DICTIONARIES_DIR=n,exports.DYNAMIC_DICTIONARIES_DIR=o,exports.FETCH_DICTIONARIES_DIR=s,exports.MAIN_DIR=t,exports.MASKS_DIR=r,exports.MODULE_AUGMENTATION_DIR=l,exports.REMOTE_DICTIONARIES_DIR=i,exports.TEMP_DIR=f,exports.TYPES_DIR=c,exports.UNMERGED_DICTIONARIES_DIR=a,Object.defineProperty(exports,`system_exports`,{enumerable:!0,get:function(){return e}});
2
2
  //# sourceMappingURL=system.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.cjs","names":[],"sources":["../../../src/defaultValues/system.ts"],"sourcesContent":["export const MAIN_DIR = '.intlayer/main';\n\nexport const DICTIONARIES_DIR = '.intlayer/dictionary';\n\nexport const MASKS_DIR = '.intlayer/mask';\n\nexport const REMOTE_DICTIONARIES_DIR = '.intlayer/remote_dictionary';\n\nexport const UNMERGED_DICTIONARIES_DIR = '.intlayer/unmerged_dictionary';\n\nexport const DYNAMIC_DICTIONARIES_DIR = '.intlayer/dynamic_dictionary';\n\nexport const FETCH_DICTIONARIES_DIR = '.intlayer/fetch_dictionary';\n\nexport const TYPES_DIR = '.intlayer/types';\n\nexport const MODULE_AUGMENTATION_DIR = '.intlayer/types';\n\nexport const CONFIG_DIR = '.intlayer/config';\n\nexport const CACHE_DIR = '.intlayer/cache';\n"],"mappings":"oYAAA,MAAa,EAAW,iBAEX,EAAmB,uBAEnB,EAAY,iBAEZ,EAA0B,8BAE1B,EAA4B,gCAE5B,EAA2B,+BAE3B,EAAyB,6BAEzB,EAAY,kBAEZ,EAA0B,kBAE1B,EAAa,mBAEb,EAAY"}
1
+ {"version":3,"file":"system.cjs","names":[],"sources":["../../../src/defaultValues/system.ts"],"sourcesContent":["export const MAIN_DIR = '.intlayer/main';\n\nexport const DICTIONARIES_DIR = '.intlayer/dictionary';\n\nexport const MASKS_DIR = '.intlayer/mask';\n\nexport const REMOTE_DICTIONARIES_DIR = '.intlayer/remote_dictionary';\n\nexport const UNMERGED_DICTIONARIES_DIR = '.intlayer/unmerged_dictionary';\n\nexport const DYNAMIC_DICTIONARIES_DIR = '.intlayer/dynamic_dictionary';\n\nexport const FETCH_DICTIONARIES_DIR = '.intlayer/fetch_dictionary';\n\nexport const TYPES_DIR = '.intlayer/types';\n\nexport const MODULE_AUGMENTATION_DIR = '.intlayer/types';\n\nexport const CONFIG_DIR = '.intlayer/config';\n\nexport const CACHE_DIR = '.intlayer/cache';\n\nexport const TEMP_DIR = '.intlayer/tmp';\n"],"mappings":"mZAAA,MAAa,EAAW,iBAEX,EAAmB,uBAEnB,EAAY,iBAEZ,EAA0B,8BAE1B,EAA4B,gCAE5B,EAA2B,+BAE3B,EAAyB,6BAEzB,EAAY,kBAEZ,EAA0B,kBAE1B,EAAa,mBAEb,EAAY,kBAEZ,EAAW"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./cacheMemory.cjs`);let n=require(`node:path`),r=require(`@intlayer/types/package.json`);r=e.__toESM(r);let i=require(`node:fs/promises`),a=require(`node:v8`),o=require(`node:zlib`);const s={compress:!0},c=async e=>{await(0,i.mkdir)(e,{recursive:!0})},l=async(e,t)=>{let n=`${e}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;await(0,i.writeFile)(n,t),await(0,i.rename)(n,e)},u=(e,t)=>t===!0||t!==!1&&e.byteLength>1024,d=(e,t,r)=>(0,n.join)(e,r?(0,n.join)(r,t):t),f=new Map,p=(e,p,m)=>{let{cacheDir:h}=e.system,g=e.build.cache??!0,_=m?.persistent===!0||m?.persistent===void 0&&g,{compress:v,ttlMs:y,maxTimeMs:b,namespace:x}={...s,...m},S=t.computeKeyId(p),C=d(h,S,x),w=async()=>{try{let e=await(0,i.stat)(C).catch(()=>void 0);if(!e||typeof y==`number`&&y>0&&Date.now()-e.mtimeMs>y)return;let t=await(0,i.readFile)(C),n=t[0];t=t.subarray(1);let s=(0,a.deserialize)(n===1?(0,o.gunzipSync)(t):t),c,l=s;if(l&&typeof l==`object`&&typeof l.version==`string`&&typeof l.timestamp==`number`&&Object.hasOwn(l,`data`)){let e=l;if(e.version!==r.default.version){try{await(0,i.unlink)(C)}catch{}return}if(typeof b==`number`&&b>0&&Date.now()-e.timestamp>b){try{await(0,i.unlink)(C)}catch{}return}c=e.data}else{if(typeof b==`number`&&b>0&&Date.now()-e.mtimeMs>b){try{await(0,i.unlink)(C)}catch{}return}c=s}return f.set(S,c),c}catch{return}},T=async e=>{try{await c((0,n.dirname)(C));let t={version:r.default.version,timestamp:Date.now(),data:e},i=Buffer.from((0,a.serialize)(t)),s=u(i,v)?(0,o.gzipSync)(i):i;await l(C,Buffer.concat([Buffer.from([s===i?0:1]),s]))}catch{}};return{get:async()=>{let e=f.get(S);if(e!==void 0)return e;if(_&&g)return await w()},set:async e=>{f.set(S,e),_&&g&&await T(e)},clear:async()=>{f.delete(S);try{await(0,i.unlink)(C)}catch{}},clearAll:async()=>{if(t.clearAllCache(),_&&g){let e=x?(0,n.join)(h,x):h;try{await(0,i.rm)(e,{recursive:!0,force:!0})}catch{}try{await(0,i.mkdir)(e,{recursive:!0})}catch{}}},isValid:async()=>{if(f.get(S)!==void 0)return!0;if(!_||!g)return!1;try{let e=await(0,i.stat)(C).catch(()=>void 0);if(!e||typeof y==`number`&&y>0&&Date.now()-e.mtimeMs>y)return!1;let t=await(0,i.readFile)(C),n=t[0];t=t.subarray(1);let s=(0,a.deserialize)(n===1?(0,o.gunzipSync)(t):t);if(s&&typeof s==`object`&&typeof s.version==`string`&&typeof s.timestamp==`number`&&Object.hasOwn(s,`data`)){let e=s;return!(e.version!==r.default.version||typeof b==`number`&&b>0&&Date.now()-e.timestamp>b)}return!(typeof b==`number`&&b>0&&Date.now()-e.mtimeMs>b)}catch{return!1}},id:S,filePath:C}};exports.cacheDisk=p;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./cacheMemory.cjs`);let n=require(`node:path`),r=require(`@intlayer/types/package.json`);r=e.__toESM(r);let i=require(`node:fs/promises`),a=require(`node:v8`),o=require(`node:zlib`);const s={compress:!0},c=async e=>{await(0,i.mkdir)(e,{recursive:!0})},l=async(e,t,r)=>{if(r)try{await c(r)}catch{}let a=`${(0,n.basename)(e)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`,o=r?(0,n.join)(r,a):`${e}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;try{await(0,i.writeFile)(o,t),await(0,i.rename)(o,e)}catch(e){try{await(0,i.rm)(o,{force:!0})}catch{}throw e}},u=(e,t)=>t===!0||t!==!1&&e.byteLength>1024,d=(e,t,r)=>(0,n.join)(e,r?(0,n.join)(r,t):t),f=new Map,p=(e,p,m)=>{let{cacheDir:h,tempDir:g}=e.system,_=e.build.cache??!0,v=m?.persistent===!0||m?.persistent===void 0&&_,{compress:y,ttlMs:b,maxTimeMs:x,namespace:S}={...s,...m},C=t.computeKeyId(p),w=d(h,C,S),T=async()=>{try{let e=await(0,i.stat)(w).catch(()=>void 0);if(!e||typeof b==`number`&&b>0&&Date.now()-e.mtimeMs>b)return;let t=await(0,i.readFile)(w),n=t[0];t=t.subarray(1);let s=(0,a.deserialize)(n===1?(0,o.gunzipSync)(t):t),c,l=s;if(l&&typeof l==`object`&&typeof l.version==`string`&&typeof l.timestamp==`number`&&Object.hasOwn(l,`data`)){let e=l;if(e.version!==r.default.version){try{await(0,i.unlink)(w)}catch{}return}if(typeof x==`number`&&x>0&&Date.now()-e.timestamp>x){try{await(0,i.unlink)(w)}catch{}return}c=e.data}else{if(typeof x==`number`&&x>0&&Date.now()-e.mtimeMs>x){try{await(0,i.unlink)(w)}catch{}return}c=s}return f.set(C,c),c}catch{return}},E=async e=>{try{await c((0,n.dirname)(w));let t={version:r.default.version,timestamp:Date.now(),data:e},i=Buffer.from((0,a.serialize)(t)),s=u(i,y)?(0,o.gzipSync)(i):i;await l(w,Buffer.concat([Buffer.from([s===i?0:1]),s]),g)}catch{}};return{get:async()=>{let e=f.get(C);if(e!==void 0)return e;if(v&&_)return await T()},set:async e=>{f.set(C,e),v&&_&&await E(e)},clear:async()=>{f.delete(C);try{await(0,i.unlink)(w)}catch{}},clearAll:async()=>{if(t.clearAllCache(),v&&_){let e=S?(0,n.join)(h,S):h;try{await(0,i.rm)(e,{recursive:!0,force:!0})}catch{}try{await(0,i.mkdir)(e,{recursive:!0})}catch{}}},isValid:async()=>{if(f.get(C)!==void 0)return!0;if(!v||!_)return!1;try{let e=await(0,i.stat)(w).catch(()=>void 0);if(!e||typeof b==`number`&&b>0&&Date.now()-e.mtimeMs>b)return!1;let t=await(0,i.readFile)(w),n=t[0];t=t.subarray(1);let s=(0,a.deserialize)(n===1?(0,o.gunzipSync)(t):t);if(s&&typeof s==`object`&&typeof s.version==`string`&&typeof s.timestamp==`number`&&Object.hasOwn(s,`data`)){let e=s;return!(e.version!==r.default.version||typeof x==`number`&&x>0&&Date.now()-e.timestamp>x)}return!(typeof x==`number`&&x>0&&Date.now()-e.mtimeMs>x)}catch{return!1}},id:C,filePath:w}};exports.cacheDisk=p;
2
2
  //# sourceMappingURL=cacheDisk.cjs.map
@@ -1 +1 @@
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.system;\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":"yTA2CA,MAAM,EAA0D,CAC9D,SAAU,GACX,CAEK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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 { basename, 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 (\n file: string,\n data: Buffer,\n tempDir?: string\n) => {\n if (tempDir) {\n try {\n await ensureDir(tempDir);\n } catch {}\n }\n\n const tempFileName = `${basename(file)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n const tmp = tempDir\n ? join(tempDir, tempFileName)\n : `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n try {\n await writeFile(tmp, data);\n await rename(tmp, file);\n } catch (error) {\n try {\n await rm(tmp, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\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, tempDir } = intlayerConfig.system;\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, tempDir);\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":"yTA2CA,MAAM,EAA0D,CAC9D,SAAU,GACX,CAEK,EAAY,KAAO,IAAgB,CACvC,MAAA,EAAA,EAAA,OAAY,EAAK,CAAE,UAAW,GAAM,CAAC,EAGjC,EAAkB,MACtB,EACA,EACA,IACG,CACH,GAAI,EACF,GAAI,CACF,MAAM,EAAU,EAAQ,MAClB,EAGV,IAAM,EAAe,IAAA,EAAA,EAAA,UAAY,EAAK,CAAC,OAAO,QAAQ,IAAI,GAAG,KAAK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,KAAK,CAAG,EAAU,QACzB,QAGN,CACN,MAAO,KAIX,KAEA,WACD"}
@@ -1,2 +1,2 @@
1
- import{__require as e}from"../_virtual/_rolldown/runtime.mjs";import{BUILD_MODE as t,CACHE as n,OUTPUT_FORMAT as r,TRAVERSE_PATTERN as i}from"../defaultValues/build.mjs";import{COMPILER_ENABLED as a,COMPILER_EXCLUDE_PATTERN as o,COMPILER_OUTPUT_DIR as s,COMPILER_TRANSFORM_PATTERN as c}from"../defaultValues/compiler.mjs";import{CODE_DIR as l,CONTENT_DIR as u,EXCLUDED_PATHS as d,FILE_EXTENSIONS as f,WATCH as p}from"../defaultValues/content.mjs";import{CONTENT_AUTO_TRANSFORMATION as m,FILL as ee,IMPORT_MODE as h,LOCATION as g}from"../defaultValues/dictionary.mjs";import{APPLICATION_URL as _,BACKEND_URL as v,CMS_URL as y,DICTIONARY_PRIORITY_STRATEGY as b,EDITOR_URL as x,IS_ENABLED as S,LIVE_SYNC as C,LIVE_SYNC_PORT as w,PORT as T}from"../defaultValues/editor.mjs";import{DEFAULT_LOCALE as E,LOCALES as D,REQUIRED_LOCALES as O,STRICT_MODE as k}from"../defaultValues/internationalization.mjs";import{MODE as A,PREFIX as j}from"../defaultValues/log.mjs";import{BASE_PATH as M,ROUTING_MODE as N,STORAGE as P}from"../defaultValues/routing.mjs";import{CACHE_DIR as F,CONFIG_DIR as I,DICTIONARIES_DIR as L,DYNAMIC_DICTIONARIES_DIR as R,FETCH_DICTIONARIES_DIR as te,MAIN_DIR as z,MODULE_AUGMENTATION_DIR as B,REMOTE_DICTIONARIES_DIR as V,TYPES_DIR as H,UNMERGED_DICTIONARIES_DIR as U}from"../defaultValues/system.mjs";import{normalizePath as W}from"../utils/normalizePath.mjs";import{dirname as G,isAbsolute as K,join as q}from"node:path";import{statSync as J}from"node:fs";import Y from"@intlayer/types/package.json"with{type:"json"};let X;const Z=e=>({locales:e?.locales??D,requiredLocales:e?.requiredLocales??e?.locales??O,strictMode:e?.strictMode??k,defaultLocale:e?.defaultLocale??E}),Q=e=>({mode:e?.mode??N,storage:e?.storage??P,basePath:e?.basePath??M,rewrite:e?.rewrite}),ne=(t,n,r)=>{let i=t?.fileExtensions??f,a=t?.baseDir??n??process.cwd(),o=t=>{let n;try{n=e.resolve(t,{paths:[a]})}catch{n=K(t)?t:q(a,t)}try{if(J(n).isFile())return G(n)}catch{if(/\.[a-z0-9]+$/i.test(n))return G(n)}return n},s=(t?.contentDir??u).map(o);return{fileExtensions:i,baseDir:a,contentDir:s,codeDir:(t?.codeDir??l).map(o),excludedPath:t?.excludedPath??d,watch:t?.watch??p,formatCommand:t?.formatCommand,watchedFilesPattern:i.map(e=>`/**/*${e}`),watchedFilesPatternWithPath:i.flatMap(e=>s.map(t=>`${W(t)}/**/*${e}`))}},re=(t,n)=>{let r=n?.baseDir??process.cwd(),i=t=>{let n;try{n=e.resolve(t,{paths:[r]})}catch{n=K(t)?t:q(r,t)}try{if(J(n).isFile())return G(n)}catch{if(/\.[a-z0-9]+$/i.test(n))return G(n)}return n},a=i(t?.dictionariesDir??L);return{moduleAugmentationDir:i(t?.moduleAugmentationDir??B),unmergedDictionariesDir:i(t?.unmergedDictionariesDir??U),remoteDictionariesDir:i(t?.remoteDictionariesDir??V),dictionariesDir:a,dynamicDictionariesDir:i(t?.dynamicDictionariesDir??R),fetchDictionariesDir:i(t?.fetchDictionariesDir??te),typesDir:i(t?.typesDir??H),mainDir:i(t?.mainDir??z),configDir:i(t?.configDir??I),cacheDir:i(t?.cacheDir??F),outputFilesPatternWithPath:`${W(a)}/**/*.json`}},ie=e=>({applicationURL:e?.applicationURL??_,editorURL:e?.editorURL??x,cmsURL:e?.cmsURL??y,backendURL:e?.backendURL??v,port:e?.port??T,enabled:e?.enabled??S,clientId:e?.clientId??void 0,clientSecret:e?.clientSecret??void 0,dictionaryPriorityStrategy:e?.dictionaryPriorityStrategy??b,liveSync:e?.liveSync??C,liveSyncPort:e?.liveSyncPort??w,liveSyncURL:e?.liveSyncURL??`http://localhost:${e?.liveSyncPort??w}`}),ae=(e,t)=>({mode:e?.mode??A,prefix:e?.prefix??j,error:t?.error,log:t?.log,info:t?.info,warn:t?.warn}),oe=e=>({provider:e?.provider,apiKey:e?.apiKey,model:e?.model,temperature:e?.temperature,applicationContext:e?.applicationContext,baseURL:e?.baseURL,dataSerialization:e?.dataSerialization}),$=e=>({mode:e?.mode??t,optimize:e?.optimize,importMode:e?.importMode,traversePattern:e?.traversePattern??i,outputFormat:e?.outputFormat??r,cache:e?.cache??n,require:e?.require}),se=e=>({enabled:e?.enabled??a,transformPattern:e?.transformPattern??c,excludePattern:e?.excludePattern??o,outputDir:e?.outputDir??s}),ce=e=>{let t=e?.contentAutoTransformation??m;return{fill:e?.fill??ee,contentAutoTransformation:typeof t==`object`?{markdown:t.markdown??!1,html:t.html??!1,insertion:t.insertion??!1}:t,location:e?.location??g,locale:e?.locale,title:e?.title,description:e?.description,tags:e?.tags,priority:e?.priority,importMode:e?.importMode??h,version:e?.version}},le=(e,t,n)=>{let r=Z(e?.internationalization),i=Q(e?.routing),a=ne(e?.content,t,n);return X={internationalization:r,routing:i,content:a,system:re(e?.system,a),editor:ie(e?.editor),log:ae(e?.log,n),ai:oe(e?.ai),build:$(e?.build),compiler:se(e?.compiler),dictionary:ce(e?.dictionary),plugins:e?.plugins,schemas:e?.schemas,metadata:{name:`Intlayer`,version:Y.version,doc:`https://intlayer.org/docs`}},X};export{le as buildConfigurationFields};
1
+ import{__require as e}from"../_virtual/_rolldown/runtime.mjs";import{BUILD_MODE as t,CACHE as n,OUTPUT_FORMAT as r,TRAVERSE_PATTERN as i,TYPE_CHECKING as a}from"../defaultValues/build.mjs";import{COMPILER_DICTIONARY_KEY_PREFIX as o,COMPILER_ENABLED as s,COMPILER_EXCLUDE_PATTERN as c,COMPILER_OUTPUT_DIR as l,COMPILER_TRANSFORM_PATTERN as u}from"../defaultValues/compiler.mjs";import{CODE_DIR as d,CONTENT_DIR as f,EXCLUDED_PATHS as p,FILE_EXTENSIONS as ee,WATCH as te}from"../defaultValues/content.mjs";import{CONTENT_AUTO_TRANSFORMATION as m,FILL as h,IMPORT_MODE as g,LOCATION as _}from"../defaultValues/dictionary.mjs";import{APPLICATION_URL as v,BACKEND_URL as y,CMS_URL as b,DICTIONARY_PRIORITY_STRATEGY as x,EDITOR_URL as S,IS_ENABLED as C,LIVE_SYNC as w,LIVE_SYNC_PORT as T,PORT as E}from"../defaultValues/editor.mjs";import{DEFAULT_LOCALE as D,LOCALES as O,REQUIRED_LOCALES as k,STRICT_MODE as A}from"../defaultValues/internationalization.mjs";import{MODE as j,PREFIX as M}from"../defaultValues/log.mjs";import{BASE_PATH as N,ROUTING_MODE as P,STORAGE as F}from"../defaultValues/routing.mjs";import{CACHE_DIR as I,CONFIG_DIR as L,DICTIONARIES_DIR as ne,DYNAMIC_DICTIONARIES_DIR as R,FETCH_DICTIONARIES_DIR as z,MAIN_DIR as B,MODULE_AUGMENTATION_DIR as V,REMOTE_DICTIONARIES_DIR as H,TEMP_DIR as U,TYPES_DIR as W,UNMERGED_DICTIONARIES_DIR as G}from"../defaultValues/system.mjs";import{normalizePath as K}from"../utils/normalizePath.mjs";import{dirname as q,isAbsolute as J,join as Y}from"node:path";import{statSync as X}from"node:fs";import Z from"@intlayer/types/package.json"with{type:"json"};let Q;const re=e=>({locales:e?.locales??O,requiredLocales:e?.requiredLocales??e?.locales??k,strictMode:e?.strictMode??A,defaultLocale:e?.defaultLocale??D}),ie=e=>({mode:e?.mode??P,storage:e?.storage??F,basePath:e?.basePath??N,rewrite:e?.rewrite}),ae=(t,n,r)=>{let i=t?.fileExtensions??ee,a=t?.baseDir??n??process.cwd(),o=t=>{let n;try{n=e.resolve(t,{paths:[a]})}catch{n=J(t)?t:Y(a,t)}try{if(X(n).isFile())return q(n)}catch{if(/\.[a-z0-9]+$/i.test(n))return q(n)}return n},s=(t?.contentDir??f).map(o);return{fileExtensions:i,baseDir:a,contentDir:s,codeDir:(t?.codeDir??d).map(o),excludedPath:t?.excludedPath??p,watch:t?.watch??te,formatCommand:t?.formatCommand,watchedFilesPattern:i.map(e=>`/**/*${e}`),watchedFilesPatternWithPath:i.flatMap(e=>s.map(t=>`${K(t)}/**/*${e}`))}},oe=(t,n)=>{let r=n?.baseDir??process.cwd(),i=t=>{let n;try{n=e.resolve(t,{paths:[r]})}catch{n=J(t)?t:Y(r,t)}try{if(X(n).isFile())return q(n)}catch{if(/\.[a-z0-9]+$/i.test(n))return q(n)}return n},a=i(t?.dictionariesDir??ne);return{moduleAugmentationDir:i(t?.moduleAugmentationDir??V),unmergedDictionariesDir:i(t?.unmergedDictionariesDir??G),remoteDictionariesDir:i(t?.remoteDictionariesDir??H),dictionariesDir:a,dynamicDictionariesDir:i(t?.dynamicDictionariesDir??R),fetchDictionariesDir:i(t?.fetchDictionariesDir??z),typesDir:i(t?.typesDir??W),mainDir:i(t?.mainDir??B),configDir:i(t?.configDir??L),cacheDir:i(t?.cacheDir??I),tempDir:i(t?.tempDir??U),outputFilesPatternWithPath:`${K(a)}/**/*.json`}},$=e=>({applicationURL:e?.applicationURL??v,editorURL:e?.editorURL??S,cmsURL:e?.cmsURL??b,backendURL:e?.backendURL??y,port:e?.port??E,enabled:e?.enabled??C,clientId:e?.clientId??void 0,clientSecret:e?.clientSecret??void 0,dictionaryPriorityStrategy:e?.dictionaryPriorityStrategy??x,liveSync:e?.liveSync??w,liveSyncPort:e?.liveSyncPort??T,liveSyncURL:e?.liveSyncURL??`http://localhost:${e?.liveSyncPort??T}`}),se=(e,t)=>({mode:e?.mode??j,prefix:e?.prefix??M,error:t?.error,log:t?.log,info:t?.info,warn:t?.warn}),ce=e=>({provider:e?.provider,apiKey:e?.apiKey,model:e?.model,temperature:e?.temperature,applicationContext:e?.applicationContext,baseURL:e?.baseURL,dataSerialization:e?.dataSerialization}),le=e=>({mode:e?.mode??t,optimize:e?.optimize,importMode:e?.importMode,traversePattern:e?.traversePattern??i,outputFormat:e?.outputFormat??r,cache:e?.cache??n,require:e?.require,checkTypes:e?.checkTypes??a}),ue=e=>({enabled:e?.enabled??s,dictionaryKeyPrefix:e?.dictionaryKeyPrefix??o,transformPattern:e?.transformPattern??u,excludePattern:e?.excludePattern??c,outputDir:e?.outputDir??l}),de=e=>{let t=e?.contentAutoTransformation??m;return{fill:e?.fill??h,contentAutoTransformation:typeof t==`object`?{markdown:t.markdown??!1,html:t.html??!1,insertion:t.insertion??!1}:t,location:e?.location??_,locale:e?.locale,title:e?.title,description:e?.description,tags:e?.tags,priority:e?.priority,importMode:e?.importMode??g,version:e?.version}},fe=(e,t,n)=>{let r=re(e?.internationalization),i=ie(e?.routing),a=ae(e?.content,t,n);return Q={internationalization:r,routing:i,content:a,system:oe(e?.system,a),editor:$(e?.editor),log:se(e?.log,n),ai:ce(e?.ai),build:le(e?.build),compiler:ue(e?.compiler),dictionary:de(e?.dictionary),plugins:e?.plugins,schemas:e?.schemas,metadata:{name:`Intlayer`,version:Z.version,doc:`https://intlayer.org/docs`}},Q};export{fe as buildConfigurationFields};
2
2
  //# sourceMappingURL=buildConfigurationFields.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildConfigurationFields.mjs","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { statSync } from 'node:fs';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport type {\n AiConfig,\n BuildConfig,\n CompilerConfig,\n ContentConfig,\n CustomIntlayerConfig,\n DictionaryConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n LogFunctions,\n RoutingConfig,\n SystemConfig,\n} from '@intlayer/types';\nimport packageJson from '@intlayer/types/package.json' with { type: 'json' };\nimport {\n BUILD_MODE,\n CACHE,\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 CODE_DIR,\n CONTENT_DIR,\n EXCLUDED_PATHS,\n FILE_EXTENSIONS,\n WATCH,\n} from '../defaultValues/content';\nimport {\n CONTENT_AUTO_TRANSFORMATION,\n FILL,\n IMPORT_MODE,\n LOCATION,\n} 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 {\n CACHE_DIR,\n CONFIG_DIR,\n DICTIONARIES_DIR,\n DYNAMIC_DICTIONARIES_DIR,\n FETCH_DICTIONARIES_DIR,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REMOTE_DICTIONARIES_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n} from '../defaultValues/system';\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 /**\n * Custom URL rewriting rules that override the default routing mode for specific paths.\n * Allows you to define locale-specific paths that differ from the standard routing behavior.\n * Supports dynamic route parameters using `[param]` syntax.\n *\n * Default: undefined\n *\n * Example:\n * ```typescript\n * rewrite: {\n * \"/about\": {\n * en: \"/about\",\n * fr: \"/a-propos\",\n * },\n * \"/product/[slug]\": {\n * en: \"/product/[slug]\",\n * fr: \"/produit/[slug]\",\n * },\n * }\n * ```\n *\n * Note:\n * - The rewrite rules take precedence over the default `mode` behavior.\n * - If a path matches a rewrite rule, the localized path from the rewrite configuration will be used.\n * - Dynamic route parameters are supported using bracket notation (e.g., `[slug]`, `[id]`).\n * - Works with both Next.js and Vite applications.\n */\n rewrite: customConfiguration?.rewrite,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>,\n baseDir?: string,\n logFunctions?: LogFunctions\n): ContentConfig => {\n const fileExtensions = customConfiguration?.fileExtensions ?? FILE_EXTENSIONS;\n const projectBaseDir =\n customConfiguration?.baseDir ?? baseDir ?? process.cwd();\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: [projectBaseDir],\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(projectBaseDir, 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 contentDir = (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n optionalJoinBaseDir\n );\n\n const codeDirInput = customConfiguration?.codeDir;\n\n const codeDir = (codeDirInput ?? CODE_DIR).map(optionalJoinBaseDir);\n\n return {\n fileExtensions,\n baseDir: projectBaseDir,\n contentDir,\n codeDir,\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n watch: customConfiguration?.watch ?? WATCH,\n formatCommand: customConfiguration?.formatCommand,\n watchedFilesPattern: fileExtensions.map((ext) => `/**/*${ext}`),\n watchedFilesPatternWithPath: fileExtensions.flatMap((ext) =>\n contentDir.map((dir) => `${normalizePath(dir)}/**/*${ext}`)\n ),\n };\n};\n\nconst buildSystemFields = (\n customConfiguration?: Partial<SystemConfig>,\n contentConfig?: ContentConfig\n): SystemConfig => {\n const projectBaseDir = contentConfig?.baseDir ?? process.cwd();\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n absolutePath = require.resolve(pathInput, {\n paths: [projectBaseDir],\n });\n } catch {\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(projectBaseDir, pathInput);\n }\n\n try {\n const stats = statSync(absolutePath);\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n return absolutePath;\n };\n\n const dictionariesDir = optionalJoinBaseDir(\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n );\n\n return {\n moduleAugmentationDir: optionalJoinBaseDir(\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n unmergedDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n remoteDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR\n ),\n dictionariesDir,\n dynamicDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR\n ),\n fetchDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR\n ),\n typesDir: optionalJoinBaseDir(customConfiguration?.typesDir ?? TYPES_DIR),\n mainDir: optionalJoinBaseDir(customConfiguration?.mainDir ?? MAIN_DIR),\n configDir: optionalJoinBaseDir(\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n cacheDir: optionalJoinBaseDir(customConfiguration?.cacheDir ?? CACHE_DIR),\n outputFilesPatternWithPath: `${normalizePath(dictionariesDir)}/**/*.json`,\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 /**\n * Data serialization\n *\n * Options:\n * - \"json\": The industry standard. Highly reliable and structured, but consumes more tokens.\n * - \"toon\": An optimized format designed to reduce token consumption (cost-effective). However, it may slightly increase the risk of output inconsistency compared to standard JSON\n *\n * Default: \"json\"\n */\n dataSerialization: customConfiguration?.dataSerialization,\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 * @deprecated Use `dictionary.importMode` instead.\n */\n importMode: customConfiguration?.importMode,\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}', '!**\\/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 const contentAutoTransformation =\n customConfiguration?.contentAutoTransformation ??\n CONTENT_AUTO_TRANSFORMATION;\n\n return {\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: true\n */\n fill: customConfiguration?.fill ?? FILL,\n\n /**\n * Indicates if the content of the dictionary should be automatically transformed.\n *\n * Default: false\n */\n contentAutoTransformation:\n typeof contentAutoTransformation === 'object'\n ? {\n markdown: contentAutoTransformation.markdown ?? false,\n html: contentAutoTransformation.html ?? false,\n insertion: contentAutoTransformation.insertion ?? false,\n }\n : contentAutoTransformation,\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 the mode of import to use for the dictionary.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n *\n * Default: 'static'\n */\n importMode: customConfiguration?.importMode ?? IMPORT_MODE,\n\n /**\n * The version of the dictionary.\n */\n version: customConfiguration?.version,\n };\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 logFunctions\n );\n\n const systemConfig = buildSystemFields(\n customConfiguration?.system,\n contentConfig\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 system: systemConfig,\n editor: editorConfig,\n log: logConfig,\n ai: aiConfig,\n build: buildConfig,\n compiler: compilerConfig,\n dictionary: dictionaryConfig,\n plugins: customConfiguration?.plugins,\n schemas: customConfiguration?.schemas,\n metadata: {\n name: 'Intlayer',\n version: packageJson.version,\n doc: `https://intlayer.org/docs`,\n },\n } as IntlayerConfig;\n\n return storedConfiguration;\n};\n"],"mappings":"6/CA4EA,IAAI,EAEJ,MAAM,EACJ,IACgC,CAOhC,QAAS,GAAqB,SAAW,EAWzC,gBACE,GAAqB,iBACrB,GAAqB,SACrB,EAUF,WAAY,GAAqB,YAAc,EAO/C,cAAe,GAAqB,eAAiB,EACtD,EAEK,EACJ,IACmB,CAuBnB,KAAM,GAAqB,MAAQ,EAWnC,QAAS,GAAqB,SAAW,EAazC,SAAU,GAAqB,UAAY,EA6B3C,QAAS,GAAqB,QAC/B,EAEK,IACJ,EACA,EACA,IACkB,CAClB,IAAM,EAAiB,GAAqB,gBAAkB,EACxD,EACJ,GAAqB,SAAW,GAAW,QAAQ,KAAK,CAEpD,EAAuB,GAAsB,CACjD,IAAI,EAEJ,GAAI,CAGF,EAAA,EAAuB,QAAQ,EAAW,CACxC,MAAO,CAAC,EAAe,CACxB,CAAC,MACI,CAGN,EAAe,EAAW,EAAU,CAChC,EACA,EAAK,EAAgB,EAAU,CAGrC,GAAI,CAMF,GAJc,EAAS,EAAa,CAI1B,QAAQ,CAChB,OAAO,EAAQ,EAAa,MAExB,CAGN,GAAI,gBAAgB,KAAK,EAAa,CACpC,OAAO,EAAQ,EAAa,CAKhC,OAAO,GAGH,GAAc,GAAqB,YAAc,GAAa,IAClE,EACD,CAMD,MAAO,CACL,iBACA,QAAS,EACT,aACA,SARmB,GAAqB,SAET,GAAU,IAAI,EAAoB,CAOjE,aAAc,GAAqB,cAAgB,EACnD,MAAO,GAAqB,OAAS,EACrC,cAAe,G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A,IACmB,CACnB,IAAM,EAA6B,EACjC,GAAqB,qBACtB,CAEK,EAAgB,EAAmB,GAAqB,QAAQ,CAEhE,EAAgB,GACpB,GAAqB,QACrB,EACA,EACD,CAyCD,MApBA,GAAsB,CACpB,qBAAsB,EACtB,QAAS,EACT,QAAS,EACT,OAvBmB,GACnB,GAAqB,OACrB,EACD,CAqBC,OAnBmB,GAAkB,GAAqB,OAAO,CAoBjE,IAlBgB,GAAe,GAAqB,IAAK,EAAa,CAmBtE,GAjBe,GAAc,GAAqB,GAAG,CAkBrD,MAhBkB,EAAiB,GAAqB,MAAM,CAiB9D,SAfqB,GAAoB,GAAqB,SAAS,CAgBvE,WAduB,GACvB,GAAqB,WACtB,CAaC,QAAS,GAAqB,QAC9B,QAAS,GAAqB,QAC9B,SAAU,CACR,KAAM,WACN,QAAS,EAAY,QACrB,IAAK,4BACN,CACF,CAEM"}
1
+ {"version":3,"file":"buildConfigurationFields.mjs","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { statSync } from 'node:fs';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport type {\n AiConfig,\n BuildConfig,\n CompilerConfig,\n ContentConfig,\n CustomIntlayerConfig,\n DictionaryConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n LogFunctions,\n RoutingConfig,\n SystemConfig,\n} from '@intlayer/types';\nimport packageJson from '@intlayer/types/package.json' with { type: 'json' };\nimport {\n BUILD_MODE,\n CACHE,\n OUTPUT_FORMAT,\n TRAVERSE_PATTERN,\n TYPE_CHECKING,\n} from '../defaultValues/build';\nimport {\n COMPILER_DICTIONARY_KEY_PREFIX,\n COMPILER_ENABLED,\n COMPILER_EXCLUDE_PATTERN,\n COMPILER_OUTPUT_DIR,\n COMPILER_TRANSFORM_PATTERN,\n} from '../defaultValues/compiler';\nimport {\n CODE_DIR,\n CONTENT_DIR,\n EXCLUDED_PATHS,\n FILE_EXTENSIONS,\n WATCH,\n} from '../defaultValues/content';\nimport {\n CONTENT_AUTO_TRANSFORMATION,\n FILL,\n IMPORT_MODE,\n LOCATION,\n} 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 {\n CACHE_DIR,\n CONFIG_DIR,\n DICTIONARIES_DIR,\n DYNAMIC_DICTIONARIES_DIR,\n FETCH_DICTIONARIES_DIR,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REMOTE_DICTIONARIES_DIR,\n TEMP_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n} from '../defaultValues/system';\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 /**\n * Custom URL rewriting rules that override the default routing mode for specific paths.\n * Allows you to define locale-specific paths that differ from the standard routing behavior.\n * Supports dynamic route parameters using `[param]` syntax.\n *\n * Default: undefined\n *\n * Example:\n * ```typescript\n * rewrite: {\n * \"/about\": {\n * en: \"/about\",\n * fr: \"/a-propos\",\n * },\n * \"/product/[slug]\": {\n * en: \"/product/[slug]\",\n * fr: \"/produit/[slug]\",\n * },\n * }\n * ```\n *\n * Note:\n * - The rewrite rules take precedence over the default `mode` behavior.\n * - If a path matches a rewrite rule, the localized path from the rewrite configuration will be used.\n * - Dynamic route parameters are supported using bracket notation (e.g., `[slug]`, `[id]`).\n * - Works with both Next.js and Vite applications.\n */\n rewrite: customConfiguration?.rewrite,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>,\n baseDir?: string,\n logFunctions?: LogFunctions\n): ContentConfig => {\n const fileExtensions = customConfiguration?.fileExtensions ?? FILE_EXTENSIONS;\n const projectBaseDir =\n customConfiguration?.baseDir ?? baseDir ?? process.cwd();\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: [projectBaseDir],\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(projectBaseDir, 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 contentDir = (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n optionalJoinBaseDir\n );\n\n const codeDirInput = customConfiguration?.codeDir;\n\n const codeDir = (codeDirInput ?? CODE_DIR).map(optionalJoinBaseDir);\n\n return {\n fileExtensions,\n baseDir: projectBaseDir,\n contentDir,\n codeDir,\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n watch: customConfiguration?.watch ?? WATCH,\n formatCommand: customConfiguration?.formatCommand,\n watchedFilesPattern: fileExtensions.map((ext) => `/**/*${ext}`),\n watchedFilesPatternWithPath: fileExtensions.flatMap((ext) =>\n contentDir.map((dir) => `${normalizePath(dir)}/**/*${ext}`)\n ),\n };\n};\n\nconst buildSystemFields = (\n customConfiguration?: Partial<SystemConfig>,\n contentConfig?: ContentConfig\n): SystemConfig => {\n const projectBaseDir = contentConfig?.baseDir ?? process.cwd();\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n absolutePath = require.resolve(pathInput, {\n paths: [projectBaseDir],\n });\n } catch {\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(projectBaseDir, pathInput);\n }\n\n try {\n const stats = statSync(absolutePath);\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n return absolutePath;\n };\n\n const dictionariesDir = optionalJoinBaseDir(\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n );\n\n return {\n moduleAugmentationDir: optionalJoinBaseDir(\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n unmergedDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n remoteDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR\n ),\n dictionariesDir,\n dynamicDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR\n ),\n fetchDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR\n ),\n typesDir: optionalJoinBaseDir(customConfiguration?.typesDir ?? TYPES_DIR),\n mainDir: optionalJoinBaseDir(customConfiguration?.mainDir ?? MAIN_DIR),\n configDir: optionalJoinBaseDir(\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n cacheDir: optionalJoinBaseDir(customConfiguration?.cacheDir ?? CACHE_DIR),\n tempDir: optionalJoinBaseDir(customConfiguration?.tempDir ?? TEMP_DIR),\n outputFilesPatternWithPath: `${normalizePath(dictionariesDir)}/**/*.json`,\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 /**\n * Data serialization\n *\n * Options:\n * - \"json\": The industry standard. Highly reliable and structured, but consumes more tokens.\n * - \"toon\": An optimized format designed to reduce token consumption (cost-effective). However, it may slightly increase the risk of output inconsistency compared to standard JSON\n *\n * Default: \"json\"\n */\n dataSerialization: customConfiguration?.dataSerialization,\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 * @deprecated Use `dictionary.importMode` instead.\n */\n importMode: customConfiguration?.importMode,\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}', '!**\\/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 /**\n * Indicates if the build should check TypeScript types\n *\n * Default: false\n *\n * If true, the build will check TypeScript types and log errors.\n * Note: This can slow down the build.\n */\n checkTypes: customConfiguration?.checkTypes ?? TYPE_CHECKING,\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 * Prefix for the extracted dictionary keys\n */\n dictionaryKeyPrefix:\n customConfiguration?.dictionaryKeyPrefix ?? COMPILER_DICTIONARY_KEY_PREFIX,\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 const contentAutoTransformation =\n customConfiguration?.contentAutoTransformation ??\n CONTENT_AUTO_TRANSFORMATION;\n\n return {\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: true\n */\n fill: customConfiguration?.fill ?? FILL,\n\n /**\n * Indicates if the content of the dictionary should be automatically transformed.\n *\n * Default: false\n */\n contentAutoTransformation:\n typeof contentAutoTransformation === 'object'\n ? {\n markdown: contentAutoTransformation.markdown ?? false,\n html: contentAutoTransformation.html ?? false,\n insertion: contentAutoTransformation.insertion ?? false,\n }\n : contentAutoTransformation,\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 the mode of import to use for the dictionary.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n *\n * Default: 'static'\n */\n importMode: customConfiguration?.importMode ?? IMPORT_MODE,\n\n /**\n * The version of the dictionary.\n */\n version: customConfiguration?.version,\n };\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 logFunctions\n );\n\n const systemConfig = buildSystemFields(\n customConfiguration?.system,\n contentConfig\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 system: systemConfig,\n editor: editorConfig,\n log: logConfig,\n ai: aiConfig,\n build: buildConfig,\n compiler: compilerConfig,\n dictionary: dictionaryConfig,\n plugins: customConfiguration?.plugins,\n schemas: customConfiguration?.schemas,\n metadata: {\n name: 'Intlayer',\n version: packageJson.version,\n doc: `https://intlayer.org/docs`,\n },\n } as IntlayerConfig;\n\n return storedConfiguration;\n};\n"],"mappings":"mkDA+EA,IAAI,EAEJ,MAAM,GACJ,IACgC,CAOhC,QAAS,GAAqB,SAAW,EAWzC,gBACE,GAAqB,iBACrB,GAAqB,SACrB,EAUF,WAAY,GAAqB,YAAc,EAO/C,cAAe,GAAqB,eAAiB,EACtD,EAEK,GACJ,IACmB,CAuBnB,KAAM,GAAqB,MAAQ,EAWnC,QAAS,GAAqB,SAAW,EAazC,SAAU,GAAqB,UAAY,EA6B3C,QAAS,GAAqB,QAC/B,EAEK,IACJ,EACA,EACA,IACkB,CAClB,IAAM,EAAiB,GAAqB,gBAAkB,GACxD,EACJ,GAAqB,SAAW,GAAW,QAAQ,KAAK,CAEpD,EAAuB,GAAsB,CACjD,IAAI,EAEJ,GAAI,CAGF,EAAA,EAAuB,QAAQ,EAAW,CACxC,MAAO,CAAC,EAAe,CACxB,CAAC,MACI,CAGN,EAAe,EAAW,EAAU,CAChC,EACA,EAAK,EAAgB,EAAU,CAGrC,GAAI,CAMF,GAJc,EAAS,EAAa,CAI1B,QAAQ,CAChB,OAAO,EAAQ,EAAa,MAExB,CAGN,GAAI,gBAAgB,KAAK,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,EAOnC,0BACE,OAAO,GAA8B,SACjC,CACE,SAAU,EAA0B,UAAY,GAChD,KAAM,EAA0B,MAAQ,GACxC,UAAW,EAA0B,WAAa,GACnD,CACD,EAON,SAAU,GAAqB,UAAY,EAO3C,OAAQ,GAAqB,OAK7B,MAAO,GAAqB,MAK5B,YAAa,GAAqB,YAKlC,KAAM,GAAqB,KAK3B,SAAU,GAAqB,SAY/B,WAAY,GAAqB,YAAc,EAK/C,QAAS,GAAqB,QAC/B,EAMU,IACX,EACA,EACA,IACmB,CACnB,IAAM,EAA6B,GACjC,GAAqB,qBACtB,CAEK,EAAgB,GAAmB,GAAqB,QAAQ,CAEhE,EAAgB,GACpB,GAAqB,QACrB,EACA,EACD,CAyCD,MApBA,GAAsB,CACpB,qBAAsB,EACtB,QAAS,EACT,QAAS,EACT,OAvBmB,GACnB,GAAqB,OACrB,EACD,CAqBC,OAnBmB,EAAkB,GAAqB,OAAO,CAoBjE,IAlBgB,GAAe,GAAqB,IAAK,EAAa,CAmBtE,GAjBe,GAAc,GAAqB,GAAG,CAkBrD,MAhBkB,GAAiB,GAAqB,MAAM,CAiB9D,SAfqB,GAAoB,GAAqB,SAAS,CAgBvE,WAduB,GACvB,GAAqB,WACtB,CAaC,QAAS,GAAqB,QAC9B,QAAS,GAAqB,QAC9B,SAAU,CACR,KAAM,WACN,QAAS,EAAY,QACrB,IAAK,4BACN,CACF,CAEM"}
@@ -1,2 +1,2 @@
1
- import{__exportAll as e}from"../_virtual/_rolldown/runtime.mjs";var t=e({BUILD_MODE:()=>n,CACHE:()=>o,OPTIMIZE:()=>r,OUTPUT_FORMAT:()=>a,TRAVERSE_PATTERN:()=>i});const n=`auto`,r=void 0,i=[`**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,svte}`,`!**/node_modules/**`],a=[`esm`,`cjs`],o=!0;export{n as BUILD_MODE,o as CACHE,r as OPTIMIZE,a as OUTPUT_FORMAT,i as TRAVERSE_PATTERN,t as build_exports};
1
+ import{__exportAll as e}from"../_virtual/_rolldown/runtime.mjs";var t=e({BUILD_MODE:()=>n,CACHE:()=>o,OPTIMIZE:()=>r,OUTPUT_FORMAT:()=>a,TRAVERSE_PATTERN:()=>i,TYPE_CHECKING:()=>s});const n=`auto`,r=void 0,i=[`**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,svte}`,`!**/node_modules/**`],a=[`esm`,`cjs`],o=!0,s=!1;export{n as BUILD_MODE,o as CACHE,r as OPTIMIZE,a as OUTPUT_FORMAT,i as TRAVERSE_PATTERN,s as TYPE_CHECKING,t as build_exports};
2
2
  //# sourceMappingURL=build.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.mjs","names":[],"sources":["../../../src/defaultValues/build.ts"],"sourcesContent":["export const BUILD_MODE = 'auto';\n\nexport const OPTIMIZE = undefined;\n\nexport const TRAVERSE_PATTERN = [\n '**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,svte}',\n '!**/node_modules/**',\n];\n\nexport const OUTPUT_FORMAT: ('cjs' | 'esm')[] = ['esm', 'cjs'];\n\nexport const CACHE = true;\n"],"mappings":"kKAAA,MAAa,EAAa,OAEb,EAAW,IAAA,GAEX,EAAmB,CAC9B,+CACA,sBACD,CAEY,EAAmC,CAAC,MAAO,MAAM,CAEjD,EAAQ"}
1
+ {"version":3,"file":"build.mjs","names":[],"sources":["../../../src/defaultValues/build.ts"],"sourcesContent":["export const BUILD_MODE = 'auto';\n\nexport const OPTIMIZE = undefined;\n\nexport const TRAVERSE_PATTERN = [\n '**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,svte}',\n '!**/node_modules/**',\n];\n\nexport const OUTPUT_FORMAT: ('cjs' | 'esm')[] = ['esm', 'cjs'];\n\nexport const CACHE = true;\n\nexport const TYPE_CHECKING = false;\n"],"mappings":"sLAAA,MAAa,EAAa,OAEb,EAAW,IAAA,GAEX,EAAmB,CAC9B,+CACA,sBACD,CAEY,EAAmC,CAAC,MAAO,MAAM,CAEjD,EAAQ,GAER,EAAgB"}
@@ -1,2 +1,2 @@
1
- const e=!0,t=[`**/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}`],n=[`**/node_modules/**`,`**/dist/**`,`**/.next/**`,`**/.nuxt/**`,`**/.expo/**`,`**/.vercel/**`,`**/.turbo/**`,`**/.tanstack/**`,`**/*.stories.ts`,`**/*.test.ts`],r=`./compiler`;export{e as COMPILER_ENABLED,n as COMPILER_EXCLUDE_PATTERN,r as COMPILER_OUTPUT_DIR,t as COMPILER_TRANSFORM_PATTERN};
1
+ const e=!0,t=`comp-`,n=[`**/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}`],r=[`**/node_modules/**`,`**/dist/**`,`**/.next/**`,`**/.nuxt/**`,`**/.expo/**`,`**/.vercel/**`,`**/.turbo/**`,`**/.tanstack/**`,`**/*.stories.ts`,`**/*.test.ts`],i=`./compiler`;export{t as COMPILER_DICTIONARY_KEY_PREFIX,e as COMPILER_ENABLED,r as COMPILER_EXCLUDE_PATTERN,i as COMPILER_OUTPUT_DIR,n as COMPILER_TRANSFORM_PATTERN};
2
2
  //# sourceMappingURL=compiler.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.mjs","names":[],"sources":["../../../src/defaultValues/compiler.ts"],"sourcesContent":["export const COMPILER_ENABLED = true;\nexport const COMPILER_TRANSFORM_PATTERN = [\n '**/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}',\n];\nexport const COMPILER_EXCLUDE_PATTERN = [\n '**/node_modules/**',\n '**/dist/**',\n '**/.next/**',\n '**/.nuxt/**',\n '**/.expo/**',\n '**/.vercel/**',\n '**/.turbo/**',\n '**/.tanstack/**',\n '**/*.stories.ts',\n '**/*.test.ts',\n];\nexport const COMPILER_OUTPUT_DIR = './compiler';\n"],"mappings":"AAAA,MAAa,EAAmB,GACnB,EAA6B,CACxC,0CACD,CACY,EAA2B,CACtC,qBACA,aACA,cACA,cACA,cACA,gBACA,eACA,kBACA,kBACA,eACD,CACY,EAAsB"}
1
+ {"version":3,"file":"compiler.mjs","names":[],"sources":["../../../src/defaultValues/compiler.ts"],"sourcesContent":["export const COMPILER_ENABLED = true;\n\nexport const COMPILER_DICTIONARY_KEY_PREFIX = 'comp-';\n\nexport const COMPILER_TRANSFORM_PATTERN = [\n '**/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}',\n];\nexport const COMPILER_EXCLUDE_PATTERN = [\n '**/node_modules/**',\n '**/dist/**',\n '**/.next/**',\n '**/.nuxt/**',\n '**/.expo/**',\n '**/.vercel/**',\n '**/.turbo/**',\n '**/.tanstack/**',\n '**/*.stories.ts',\n '**/*.test.ts',\n];\nexport const COMPILER_OUTPUT_DIR = './compiler';\n"],"mappings":"AAAA,MAAa,EAAmB,GAEnB,EAAiC,QAEjC,EAA6B,CACxC,0CACD,CACY,EAA2B,CACtC,qBACA,aACA,cACA,cACA,cACA,gBACA,eACA,kBACA,kBACA,eACD,CACY,EAAsB"}
@@ -1,2 +1,2 @@
1
- import{__exportAll as e}from"../_virtual/_rolldown/runtime.mjs";var t=e({CACHE_DIR:()=>f,CONFIG_DIR:()=>d,DICTIONARIES_DIR:()=>r,DYNAMIC_DICTIONARIES_DIR:()=>s,FETCH_DICTIONARIES_DIR:()=>c,MAIN_DIR:()=>n,MASKS_DIR:()=>i,MODULE_AUGMENTATION_DIR:()=>u,REMOTE_DICTIONARIES_DIR:()=>a,TYPES_DIR:()=>l,UNMERGED_DICTIONARIES_DIR:()=>o});const n=`.intlayer/main`,r=`.intlayer/dictionary`,i=`.intlayer/mask`,a=`.intlayer/remote_dictionary`,o=`.intlayer/unmerged_dictionary`,s=`.intlayer/dynamic_dictionary`,c=`.intlayer/fetch_dictionary`,l=`.intlayer/types`,u=`.intlayer/types`,d=`.intlayer/config`,f=`.intlayer/cache`;export{f as CACHE_DIR,d as CONFIG_DIR,r as DICTIONARIES_DIR,s as DYNAMIC_DICTIONARIES_DIR,c as FETCH_DICTIONARIES_DIR,n as MAIN_DIR,i as MASKS_DIR,u as MODULE_AUGMENTATION_DIR,a as REMOTE_DICTIONARIES_DIR,l as TYPES_DIR,o as UNMERGED_DICTIONARIES_DIR,t as system_exports};
1
+ import{__exportAll as e}from"../_virtual/_rolldown/runtime.mjs";var t=e({CACHE_DIR:()=>f,CONFIG_DIR:()=>d,DICTIONARIES_DIR:()=>r,DYNAMIC_DICTIONARIES_DIR:()=>s,FETCH_DICTIONARIES_DIR:()=>c,MAIN_DIR:()=>n,MASKS_DIR:()=>i,MODULE_AUGMENTATION_DIR:()=>u,REMOTE_DICTIONARIES_DIR:()=>a,TEMP_DIR:()=>p,TYPES_DIR:()=>l,UNMERGED_DICTIONARIES_DIR:()=>o});const n=`.intlayer/main`,r=`.intlayer/dictionary`,i=`.intlayer/mask`,a=`.intlayer/remote_dictionary`,o=`.intlayer/unmerged_dictionary`,s=`.intlayer/dynamic_dictionary`,c=`.intlayer/fetch_dictionary`,l=`.intlayer/types`,u=`.intlayer/types`,d=`.intlayer/config`,f=`.intlayer/cache`,p=`.intlayer/tmp`;export{f as CACHE_DIR,d as CONFIG_DIR,r as DICTIONARIES_DIR,s as DYNAMIC_DICTIONARIES_DIR,c as FETCH_DICTIONARIES_DIR,n as MAIN_DIR,i as MASKS_DIR,u as MODULE_AUGMENTATION_DIR,a as REMOTE_DICTIONARIES_DIR,p as TEMP_DIR,l as TYPES_DIR,o as UNMERGED_DICTIONARIES_DIR,t as system_exports};
2
2
  //# sourceMappingURL=system.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.mjs","names":[],"sources":["../../../src/defaultValues/system.ts"],"sourcesContent":["export const MAIN_DIR = '.intlayer/main';\n\nexport const DICTIONARIES_DIR = '.intlayer/dictionary';\n\nexport const MASKS_DIR = '.intlayer/mask';\n\nexport const REMOTE_DICTIONARIES_DIR = '.intlayer/remote_dictionary';\n\nexport const UNMERGED_DICTIONARIES_DIR = '.intlayer/unmerged_dictionary';\n\nexport const DYNAMIC_DICTIONARIES_DIR = '.intlayer/dynamic_dictionary';\n\nexport const FETCH_DICTIONARIES_DIR = '.intlayer/fetch_dictionary';\n\nexport const TYPES_DIR = '.intlayer/types';\n\nexport const MODULE_AUGMENTATION_DIR = '.intlayer/types';\n\nexport const CONFIG_DIR = '.intlayer/config';\n\nexport const CACHE_DIR = '.intlayer/cache';\n"],"mappings":"0UAAA,MAAa,EAAW,iBAEX,EAAmB,uBAEnB,EAAY,iBAEZ,EAA0B,8BAE1B,EAA4B,gCAE5B,EAA2B,+BAE3B,EAAyB,6BAEzB,EAAY,kBAEZ,EAA0B,kBAE1B,EAAa,mBAEb,EAAY"}
1
+ {"version":3,"file":"system.mjs","names":[],"sources":["../../../src/defaultValues/system.ts"],"sourcesContent":["export const MAIN_DIR = '.intlayer/main';\n\nexport const DICTIONARIES_DIR = '.intlayer/dictionary';\n\nexport const MASKS_DIR = '.intlayer/mask';\n\nexport const REMOTE_DICTIONARIES_DIR = '.intlayer/remote_dictionary';\n\nexport const UNMERGED_DICTIONARIES_DIR = '.intlayer/unmerged_dictionary';\n\nexport const DYNAMIC_DICTIONARIES_DIR = '.intlayer/dynamic_dictionary';\n\nexport const FETCH_DICTIONARIES_DIR = '.intlayer/fetch_dictionary';\n\nexport const TYPES_DIR = '.intlayer/types';\n\nexport const MODULE_AUGMENTATION_DIR = '.intlayer/types';\n\nexport const CONFIG_DIR = '.intlayer/config';\n\nexport const CACHE_DIR = '.intlayer/cache';\n\nexport const TEMP_DIR = '.intlayer/tmp';\n"],"mappings":"yVAAA,MAAa,EAAW,iBAEX,EAAmB,uBAEnB,EAAY,iBAEZ,EAA0B,8BAE1B,EAA4B,gCAE5B,EAA2B,+BAE3B,EAAyB,6BAEzB,EAAY,kBAEZ,EAA0B,kBAE1B,EAAa,mBAEb,EAAY,kBAEZ,EAAW"}
@@ -1,2 +1,2 @@
1
- import{clearAllCache as e,computeKeyId as t}from"./cacheMemory.mjs";import{dirname as n,join as r}from"node:path";import i from"@intlayer/types/package.json"with{type:"json"};import{mkdir as a,readFile as o,rename as s,rm as c,stat as l,unlink as u,writeFile as d}from"node:fs/promises";import{deserialize as f,serialize as p}from"node:v8";import{gunzipSync as m,gzipSync as h}from"node:zlib";const g={compress:!0},_=async e=>{await a(e,{recursive:!0})},v=async(e,t)=>{let n=`${e}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;await d(n,t),await s(n,e)},y=(e,t)=>t===!0||t!==!1&&e.byteLength>1024,b=(e,t,n)=>r(e,n?r(n,t):t),x=new Map,S=(s,d,S)=>{let{cacheDir:C}=s.system,w=s.build.cache??!0,T=S?.persistent===!0||S?.persistent===void 0&&w,{compress:E,ttlMs:D,maxTimeMs:O,namespace:k}={...g,...S},A=t(d),j=b(C,A,k),M=async()=>{try{let e=await l(j).catch(()=>void 0);if(!e||typeof D==`number`&&D>0&&Date.now()-e.mtimeMs>D)return;let t=await o(j),n=t[0];t=t.subarray(1);let r=f(n===1?m(t):t),a,s=r;if(s&&typeof s==`object`&&typeof s.version==`string`&&typeof s.timestamp==`number`&&Object.hasOwn(s,`data`)){let e=s;if(e.version!==i.version){try{await u(j)}catch{}return}if(typeof O==`number`&&O>0&&Date.now()-e.timestamp>O){try{await u(j)}catch{}return}a=e.data}else{if(typeof O==`number`&&O>0&&Date.now()-e.mtimeMs>O){try{await u(j)}catch{}return}a=r}return x.set(A,a),a}catch{return}},N=async e=>{try{await _(n(j));let t={version:i.version,timestamp:Date.now(),data:e},r=Buffer.from(p(t)),a=y(r,E)?h(r):r;await v(j,Buffer.concat([Buffer.from([a===r?0:1]),a]))}catch{}};return{get:async()=>{let e=x.get(A);if(e!==void 0)return e;if(T&&w)return await M()},set:async e=>{x.set(A,e),T&&w&&await N(e)},clear:async()=>{x.delete(A);try{await u(j)}catch{}},clearAll:async()=>{if(e(),T&&w){let e=k?r(C,k):C;try{await c(e,{recursive:!0,force:!0})}catch{}try{await a(e,{recursive:!0})}catch{}}},isValid:async()=>{if(x.get(A)!==void 0)return!0;if(!T||!w)return!1;try{let e=await l(j).catch(()=>void 0);if(!e||typeof D==`number`&&D>0&&Date.now()-e.mtimeMs>D)return!1;let t=await o(j),n=t[0];t=t.subarray(1);let r=f(n===1?m(t):t);if(r&&typeof r==`object`&&typeof r.version==`string`&&typeof r.timestamp==`number`&&Object.hasOwn(r,`data`)){let e=r;return!(e.version!==i.version||typeof O==`number`&&O>0&&Date.now()-e.timestamp>O)}return!(typeof O==`number`&&O>0&&Date.now()-e.mtimeMs>O)}catch{return!1}},id:A,filePath:j}};export{S as cacheDisk};
1
+ import{clearAllCache as e,computeKeyId as t}from"./cacheMemory.mjs";import{basename as n,dirname as r,join as i}from"node:path";import a from"@intlayer/types/package.json"with{type:"json"};import{mkdir as o,readFile as s,rename as c,rm as l,stat as u,unlink as d,writeFile as f}from"node:fs/promises";import{deserialize as p,serialize as m}from"node:v8";import{gunzipSync as h,gzipSync as g}from"node:zlib";const _={compress:!0},v=async e=>{await o(e,{recursive:!0})},y=async(e,t,r)=>{if(r)try{await v(r)}catch{}let a=`${n(e)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`,o=r?i(r,a):`${e}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;try{await f(o,t),await c(o,e)}catch(e){try{await l(o,{force:!0})}catch{}throw e}},b=(e,t)=>t===!0||t!==!1&&e.byteLength>1024,x=(e,t,n)=>i(e,n?i(n,t):t),S=new Map,C=(n,c,f)=>{let{cacheDir:C,tempDir:w}=n.system,T=n.build.cache??!0,E=f?.persistent===!0||f?.persistent===void 0&&T,{compress:D,ttlMs:O,maxTimeMs:k,namespace:A}={..._,...f},j=t(c),M=x(C,j,A),N=async()=>{try{let e=await u(M).catch(()=>void 0);if(!e||typeof O==`number`&&O>0&&Date.now()-e.mtimeMs>O)return;let t=await s(M),n=t[0];t=t.subarray(1);let r=p(n===1?h(t):t),i,o=r;if(o&&typeof o==`object`&&typeof o.version==`string`&&typeof o.timestamp==`number`&&Object.hasOwn(o,`data`)){let e=o;if(e.version!==a.version){try{await d(M)}catch{}return}if(typeof k==`number`&&k>0&&Date.now()-e.timestamp>k){try{await d(M)}catch{}return}i=e.data}else{if(typeof k==`number`&&k>0&&Date.now()-e.mtimeMs>k){try{await d(M)}catch{}return}i=r}return S.set(j,i),i}catch{return}},P=async e=>{try{await v(r(M));let t={version:a.version,timestamp:Date.now(),data:e},n=Buffer.from(m(t)),i=b(n,D)?g(n):n;await y(M,Buffer.concat([Buffer.from([i===n?0:1]),i]),w)}catch{}};return{get:async()=>{let e=S.get(j);if(e!==void 0)return e;if(E&&T)return await N()},set:async e=>{S.set(j,e),E&&T&&await P(e)},clear:async()=>{S.delete(j);try{await d(M)}catch{}},clearAll:async()=>{if(e(),E&&T){let e=A?i(C,A):C;try{await l(e,{recursive:!0,force:!0})}catch{}try{await o(e,{recursive:!0})}catch{}}},isValid:async()=>{if(S.get(j)!==void 0)return!0;if(!E||!T)return!1;try{let e=await u(M).catch(()=>void 0);if(!e||typeof O==`number`&&O>0&&Date.now()-e.mtimeMs>O)return!1;let t=await s(M),n=t[0];t=t.subarray(1);let r=p(n===1?h(t):t);if(r&&typeof r==`object`&&typeof r.version==`string`&&typeof r.timestamp==`number`&&Object.hasOwn(r,`data`)){let e=r;return!(e.version!==a.version||typeof k==`number`&&k>0&&Date.now()-e.timestamp>k)}return!(typeof k==`number`&&k>0&&Date.now()-e.mtimeMs>k)}catch{return!1}},id:j,filePath:M}};export{C as cacheDisk};
2
2
  //# sourceMappingURL=cacheDisk.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cacheDisk.mjs","names":["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.system;\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":"yYA2CA,MAAM,EAA0D,CAC9D,SAAU,GACX,CAEK,EAAY,KAAO,IAAgB,CACvC,MAAM,EAAM,EAAK,CAAE,UAAW,GAAM,CAAC,EAGjC,EAAkB,MAAO,EAAc,IAAiB,CAC5D,IAAM,EAAM,GAAG,EAAK,OAAO,QAAQ,IAAI,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,GAC7E,MAAM,EAAU,EAAK,EAAK,CAC1B,MAAM,EAAO,EAAK,EAAK,EAGnB,GAAwB,EAAa,IACzC,IAAU,IAAS,IAAU,IAAS,EAAI,WAAa,KAGnD,GAAa,EAAkB,EAAY,IAC/C,EAAK,EAAU,EAAK,EAAK,EAAI,EAAG,CAAG,EAAG,CAIlC,EAAW,IAAI,IAER,GACX,EACA,EACA,IACG,CACH,GAAM,CAAE,YAAa,EAAe,OAC9B,EAAoB,EAAe,MAAM,OAAS,GAClD,EACJ,GAAS,aAAe,IAChB,GAAS,aAAe,QAAe,EAE3C,CAAE,WAAU,QAAO,YAAW,aAAc,CAChD,GAAG,EACH,GAAG,EACJ,CAGK,EAAK,EAAa,EAAK,CACvB,EAAW,EAAU,EAAU,EAAI,EAAU,CAE7C,EAAe,SAA0C,CAC7D,GAAI,CACF,IAAM,EAAY,MAAM,EAAK,EAAS,CAAC,UAAY,IAAA,GAAU,CAI7D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OAAO,GAAc,UAAY,EAAY,GACnC,KAAK,KAAK,CAAG,EAAU,QACzB,QAGN,CACN,MAAO,KAIX,KAEA,WACD"}
1
+ {"version":3,"file":"cacheDisk.mjs","names":["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 { basename, 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 (\n file: string,\n data: Buffer,\n tempDir?: string\n) => {\n if (tempDir) {\n try {\n await ensureDir(tempDir);\n } catch {}\n }\n\n const tempFileName = `${basename(file)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n const tmp = tempDir\n ? join(tempDir, tempFileName)\n : `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n try {\n await writeFile(tmp, data);\n await rename(tmp, file);\n } catch (error) {\n try {\n await rm(tmp, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\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, tempDir } = intlayerConfig.system;\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, tempDir);\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":"uZA2CA,MAAM,EAA0D,CAC9D,SAAU,GACX,CAEK,EAAY,KAAO,IAAgB,CACvC,MAAM,EAAM,EAAK,CAAE,UAAW,GAAM,CAAC,EAGjC,EAAkB,MACtB,EACA,EACA,IACG,CACH,GAAI,EACF,GAAI,CACF,MAAM,EA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AAO,EAAS,MAChB,IAGV,SAAU,SAA2B,CAEnC,GADA,GAAe,CACX,GAAc,EAAmB,CAEnC,IAAM,EAAO,EAAY,EAAK,EAAU,EAAU,CAAG,EAErD,GAAI,CACF,MAAM,EAAG,EAAM,CAAE,UAAW,GAAM,MAAO,GAAM,CAAC,MAC1C,EAER,GAAI,CACF,MAAM,EAAM,EAAM,CAAE,UAAW,GAAM,CAAC,MAChC,KAIZ,QAAS,SAA8B,CAErC,GADoB,EAAS,IAAI,EAAG,GAChB,IAAA,GAAW,MAAO,GAGtC,GAAI,CAAC,GAAc,CAAC,EAAmB,MAAO,GAE9C,GAAI,CACF,IAAM,EAAY,MAAM,EAAK,EAAS,CAAC,UAAY,IAAA,GAAU,CAG7D,GAFI,CAAC,GAED,OAAO,GAAU,UAAY,EAAQ,GAC3B,KAAK,KAAK,CAAG,EAAU,QACzB,EAAO,MAAO,GAG1B,IAAI,EAAM,MAAM,EAAS,EAAS,CAC5B,EAAO,EAAI,GACjB,EAAM,EAAI,SAAS,EAAE,CAIrB,IAAM,EAFe,EADL,IAAS,EAAO,EAAW,EAAI,CAAG,EACT,CAUzC,GANI,GACF,OAAO,GAAa,UACpB,OAAO,EAAS,SAAY,UAC5B,OAAO,EAAS,WAAc,UAC9B,OAAO,OAAO,EAAU,OAAO,CAEjB,CACd,IAAM,EAAQ,EAOd,MAJA,EAFI,EAAM,UAAYA,EAAkB,SAEpC,OAAO,GAAc,UAAY,EAAY,GACnC,KAAK,KAAK,CAAG,EAAM,UACrB,GASd,MAJA,EAAI,OAAO,GAAc,UAAY,EAAY,GACnC,KAAK,KAAK,CAAG,EAAU,QACzB,QAGN,CACN,MAAO,KAIX,KAEA,WACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildConfigurationFields.d.ts","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"mappings":";;;;;AA+vBA;cAAa,wBAAA,GACX,mBAAA,GAAsB,oBAAA,EACtB,OAAA,WACA,YAAA,GAAe,YAAA,KACd,cAAA"}
1
+ {"version":3,"file":"buildConfigurationFields.d.ts","names":[],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"mappings":";;;;;AAmxBA;cAAa,wBAAA,GACX,mBAAA,GAAsB,oBAAA,EACtB,OAAA,WACA,YAAA,GAAe,YAAA,KACd,cAAA"}
@@ -1,11 +1,12 @@
1
1
  declare namespace build_d_exports {
2
- export { BUILD_MODE, CACHE, OPTIMIZE, OUTPUT_FORMAT, TRAVERSE_PATTERN };
2
+ export { BUILD_MODE, CACHE, OPTIMIZE, OUTPUT_FORMAT, TRAVERSE_PATTERN, TYPE_CHECKING };
3
3
  }
4
4
  declare const BUILD_MODE = "auto";
5
5
  declare const OPTIMIZE: any;
6
6
  declare const TRAVERSE_PATTERN: string[];
7
7
  declare const OUTPUT_FORMAT: ('cjs' | 'esm')[];
8
8
  declare const CACHE = true;
9
+ declare const TYPE_CHECKING = false;
9
10
  //#endregion
10
- export { BUILD_MODE, CACHE, OPTIMIZE, OUTPUT_FORMAT, TRAVERSE_PATTERN, build_d_exports };
11
+ export { BUILD_MODE, CACHE, OPTIMIZE, OUTPUT_FORMAT, TRAVERSE_PATTERN, TYPE_CHECKING, build_d_exports };
11
12
  //# sourceMappingURL=build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","names":[],"sources":["../../../src/defaultValues/build.ts"],"mappings":";;;cAAa,UAAA;AAAA,cAEA,QAAA;AAAA,cAEA,gBAAA;AAAA,cAKA,aAAA;AAAA,cAEA,KAAA"}
1
+ {"version":3,"file":"build.d.ts","names":[],"sources":["../../../src/defaultValues/build.ts"],"mappings":";;;cAAa,UAAA;AAAA,cAEA,QAAA;AAAA,cAEA,gBAAA;AAAA,cAKA,aAAA;AAAA,cAEA,KAAA;AAAA,cAEA,aAAA"}
@@ -1,8 +1,9 @@
1
1
  //#region src/defaultValues/compiler.d.ts
2
2
  declare const COMPILER_ENABLED = true;
3
+ declare const COMPILER_DICTIONARY_KEY_PREFIX = "comp-";
3
4
  declare const COMPILER_TRANSFORM_PATTERN: string[];
4
5
  declare const COMPILER_EXCLUDE_PATTERN: string[];
5
6
  declare const COMPILER_OUTPUT_DIR = "./compiler";
6
7
  //#endregion
7
- export { COMPILER_ENABLED, COMPILER_EXCLUDE_PATTERN, COMPILER_OUTPUT_DIR, COMPILER_TRANSFORM_PATTERN };
8
+ export { COMPILER_DICTIONARY_KEY_PREFIX, COMPILER_ENABLED, COMPILER_EXCLUDE_PATTERN, COMPILER_OUTPUT_DIR, COMPILER_TRANSFORM_PATTERN };
8
9
  //# sourceMappingURL=compiler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.d.ts","names":[],"sources":["../../../src/defaultValues/compiler.ts"],"mappings":";cAAa,gBAAA;AAAA,cACA,0BAAA;AAAA,cAGA,wBAAA;AAAA,cAYA,mBAAA"}
1
+ {"version":3,"file":"compiler.d.ts","names":[],"sources":["../../../src/defaultValues/compiler.ts"],"mappings":";cAAa,gBAAA;AAAA,cAEA,8BAAA;AAAA,cAEA,0BAAA;AAAA,cAGA,wBAAA;AAAA,cAYA,mBAAA"}
@@ -1,5 +1,5 @@
1
1
  declare namespace system_d_exports {
2
- export { CACHE_DIR, CONFIG_DIR, DICTIONARIES_DIR, DYNAMIC_DICTIONARIES_DIR, FETCH_DICTIONARIES_DIR, MAIN_DIR, MASKS_DIR, MODULE_AUGMENTATION_DIR, REMOTE_DICTIONARIES_DIR, TYPES_DIR, UNMERGED_DICTIONARIES_DIR };
2
+ export { CACHE_DIR, CONFIG_DIR, DICTIONARIES_DIR, DYNAMIC_DICTIONARIES_DIR, FETCH_DICTIONARIES_DIR, MAIN_DIR, MASKS_DIR, MODULE_AUGMENTATION_DIR, REMOTE_DICTIONARIES_DIR, TEMP_DIR, TYPES_DIR, UNMERGED_DICTIONARIES_DIR };
3
3
  }
4
4
  declare const MAIN_DIR = ".intlayer/main";
5
5
  declare const DICTIONARIES_DIR = ".intlayer/dictionary";
@@ -12,6 +12,7 @@ declare const TYPES_DIR = ".intlayer/types";
12
12
  declare const MODULE_AUGMENTATION_DIR = ".intlayer/types";
13
13
  declare const CONFIG_DIR = ".intlayer/config";
14
14
  declare const CACHE_DIR = ".intlayer/cache";
15
+ declare const TEMP_DIR = ".intlayer/tmp";
15
16
  //#endregion
16
- export { CACHE_DIR, CONFIG_DIR, DICTIONARIES_DIR, DYNAMIC_DICTIONARIES_DIR, FETCH_DICTIONARIES_DIR, MAIN_DIR, MASKS_DIR, MODULE_AUGMENTATION_DIR, REMOTE_DICTIONARIES_DIR, TYPES_DIR, UNMERGED_DICTIONARIES_DIR, system_d_exports };
17
+ export { CACHE_DIR, CONFIG_DIR, DICTIONARIES_DIR, DYNAMIC_DICTIONARIES_DIR, FETCH_DICTIONARIES_DIR, MAIN_DIR, MASKS_DIR, MODULE_AUGMENTATION_DIR, REMOTE_DICTIONARIES_DIR, TEMP_DIR, TYPES_DIR, UNMERGED_DICTIONARIES_DIR, system_d_exports };
17
18
  //# sourceMappingURL=system.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.d.ts","names":[],"sources":["../../../src/defaultValues/system.ts"],"mappings":";;;cAAa,QAAA;AAAA,cAEA,gBAAA;AAAA,cAEA,SAAA;AAAA,cAEA,uBAAA;AAAA,cAEA,yBAAA;AAAA,cAEA,wBAAA;AAAA,cAEA,sBAAA;AAAA,cAEA,SAAA;AAAA,cAEA,uBAAA;AAAA,cAEA,UAAA;AAAA,cAEA,SAAA"}
1
+ {"version":3,"file":"system.d.ts","names":[],"sources":["../../../src/defaultValues/system.ts"],"mappings":";;;cAAa,QAAA;AAAA,cAEA,gBAAA;AAAA,cAEA,SAAA;AAAA,cAEA,uBAAA;AAAA,cAEA,yBAAA;AAAA,cAEA,wBAAA;AAAA,cAEA,sBAAA;AAAA,cAEA,SAAA;AAAA,cAEA,uBAAA;AAAA,cAEA,UAAA;AAAA,cAEA,SAAA;AAAA,cAEA,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"cacheDisk.d.ts","names":[],"sources":["../../../src/utils/cacheDisk.ts"],"mappings":";;;;KA8BK,iBAAA;kCAEH,UAAA,YAFoB;EAIpB,KAAA,WAJoB;EAMpB,SAAA,WAFA;EAIA,SAAA;EAEA,QAAA;AAAA;AAAA,cA4BW,SAAA,GACX,cAAA,EAAgB,cAAA,EAChB,IAAA,EAAM,QAAA,IACN,OAAA,GAAU,iBAAA;EAHC,kFAuHS,OAAA,CAAQ,CAAA,eAkG7B;2BAvFgC,OAAA,QAhIzB;eAwIa,OAAA,QAnBS;kBA2BN,OAAA,QAhBS;iBAgCV,OAAA,WAhBC;cAgBM"}
1
+ {"version":3,"file":"cacheDisk.d.ts","names":[],"sources":["../../../src/utils/cacheDisk.ts"],"mappings":";;;;KA8BK,iBAAA;kCAEH,UAAA,YAFoB;EAIpB,KAAA,WAJoB;EAMpB,SAAA,WAFA;EAIA,SAAA;EAEA,QAAA;AAAA;AAAA,cAkDW,SAAA,GACX,cAAA,EAAgB,cAAA,EAChB,IAAA,EAAM,QAAA,IACN,OAAA,GAAU,iBAAA;EAHC,kFAuHS,OAAA,CAAQ,CAAA,eAkG7B;2BAvFgC,OAAA,QAhIzB;eAwIa,OAAA,QAnBS;kBA2BN,OAAA,QAhBS;iBAgCV,OAAA,WAhBC;cAgBM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/config",
3
- "version": "8.1.4",
3
+ "version": "8.1.5",
4
4
  "private": false,
5
5
  "description": "Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.",
6
6
  "keywords": [
@@ -133,7 +133,7 @@
133
133
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
134
134
  },
135
135
  "dependencies": {
136
- "@intlayer/types": "8.1.4",
136
+ "@intlayer/types": "8.1.5",
137
137
  "defu": "6.1.4",
138
138
  "dotenv": "17.3.1",
139
139
  "esbuild": "0.27.2",
@@ -150,7 +150,7 @@
150
150
  "vitest": "4.0.18"
151
151
  },
152
152
  "peerDependencies": {
153
- "intlayer": "8.1.4",
153
+ "intlayer": "8.1.5",
154
154
  "react": ">=16.0.0"
155
155
  },
156
156
  "peerDependenciesMeta": {