@intlayer/types 8.12.5-canary.0 → 9.0.0-canary.1
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.
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/esm/config.mjs.map +1 -1
- package/dist/types/config.d.ts +27 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/dictionary.d.ts +245 -1
- package/dist/types/dictionary.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/module_augmentation.d.ts +25 -2
- package/dist/types/module_augmentation.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/cjs/config.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","names":[],"sources":["../../src/config.ts"],"sourcesContent":["import type { Locale } from './allLocales';\nimport type {\n ContentAutoTransformation,\n DictionaryLocation,\n Fill,\n} from './dictionary';\nimport type { LocalesValues, StrictModeLocaleMap } from './module_augmentation';\nimport type { Plugin } from './plugin';\n\n/**\n * Structural type for schema validation, compatible with Zod and other\n * schema libraries that implement safeParse. Avoids a hard dependency on Zod.\n */\nexport type ConfigSchema = {\n safeParse(data: unknown): {\n success: boolean;\n data?: unknown;\n error?: unknown;\n };\n};\n\nexport type StrictMode = 'strict' | 'inclusive' | 'loose';\n\ntype Protocol = 'http' | 'https';\n\ntype URLPath = `/${string}`;\n\ntype OptionalURLPath = `/${string}` | '';\n\n// Localhost: STRICTLY requires a port\ntype LocalhostURL = `${Protocol}://localhost:${number}${OptionalURLPath}`;\n// IP Address: Start with number, allows optional port\n// (Heuristic: Starts with a number, contains dots)\ntype IPUrl =\n | `${Protocol}://${number}.${string}${OptionalURLPath}`\n | `${Protocol}://${number}.${string}:${number}${OptionalURLPath}`;\n\n// Standard Domain: Requires at least one dot to rule out plain \"localhost\"\n// (Heuristic: starts with non-number string, contains dot)\ntype DomainURL = `${Protocol}://${string}.${string}${OptionalURLPath}`;\n\nexport type URLType = LocalhostURL | IPUrl | DomainURL | (string & {});\n\n/**\n * Configuration for internationalization settings\n */\nexport type InternationalizationConfig = {\n /**\n * Locales available in the application\n *\n * Default: [Locales.ENGLISH]\n *\n * You can define a list of available locales to support in the application.\n */\n locales: Locale[];\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: Locale[];\n\n /**\n * Ensure strong implementations of internationalized content using typescript.\n * - If set to \"strict\", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.\n * - If set to \"inclusive\", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.\n * - If set to \"loose\", the translation `t` function will accept any existing locale.\n *\n * Default: \"inclusive\"\n */\n strictMode: StrictMode;\n\n /**\n * Default locale of the application for fallback\n *\n * Default: Locales.ENGLISH\n *\n * Used to specify a fallback locale in case no other locale is set.\n */\n defaultLocale: Locale;\n};\n\nexport type CookiesAttributes = {\n /**\n * Type of the storage\n *\n * The type of the storage. It can be 'cookie'.\n */\n type: 'cookie';\n /**\n * Cookie name to store the locale information\n *\n * Default: 'INTLAYER_LOCALE'\n *\n * The cookie key where the locale information is stored.\n */\n name?: string;\n /**\n * Cookie domain to store the locale information\n *\n * Default: undefined\n *\n * Define the domain where the cookie is available. Defaults to\n * the domain of the page where the cookie was created.\n */\n domain?: string;\n /**\n * Cookie path to store the locale information\n *\n * Default: undefined\n *\n * Define the path where the cookie is available. Defaults to '/'\n */\n path?: string;\n /**\n * Cookie secure to store the locale information\n *\n * Default: undefined\n *\n * A Boolean indicating if the cookie transmission requires a\n * secure protocol (https). Defaults to false.\n */\n secure?: boolean;\n /**\n * Cookie httpOnly to store the locale information\n *\n * Default: undefined\n *\n * The cookie httpOnly where the locale information is stored.\n */\n httpOnly?: boolean;\n /**\n * Cookie sameSite to store the locale information\n *\n * Default: undefined\n *\n * Asserts that a cookie must not be sent with cross-origin requests,\n * providing some protection against cross-site request forgery\n * attacks (CSRF)\n */\n sameSite?: 'strict' | 'lax' | 'none';\n\n /**\n * Cookie expires to store the locale information\n *\n * Default: undefined\n *\n * Define when the cookie will be removed:\n * - a `number` is interpreted as **days from the time of creation**;\n * - a `Date` instance (or an ISO date string, e.g. produced when the\n * configuration is serialized) is interpreted as an **absolute moment**.\n *\n * If omitted, the cookie becomes a session cookie. When `maxAge` is set it\n * takes precedence over `expires`.\n */\n expires?: Date | number | string | undefined;\n /**\n * Cookie max-age to store the locale information\n *\n * Default: undefined\n *\n * Define the cookie lifetime in seconds from the time of creation\n * (e.g. `60 * 60 * 24 * 365` for one year). Takes precedence over\n * `expires` when both are set.\n */\n maxAge?: number;\n};\n\nexport type StorageAttributes = {\n /**\n * Storage type where the locale is stored\n *\n * Determines whether the locale is persisted in `localStorage` (across sessions)\n * or `sessionStorage` (cleared when the browser session ends) or `header` (from the request header).\n */\n type: 'localStorage' | 'sessionStorage' | 'header';\n\n /**\n * Storage key to store the locale information\n *\n * Default: 'INTLAYER_LOCALE'\n *\n * The key name used in the client storage to save the locale.\n */\n name?: string;\n};\n\n/**\n * Cookie attributes after the config-build normalization step.\n *\n * The user-facing `expires` (days / `Date` / ISO string) and `maxAge` (seconds)\n * are merged into a single, serialization-safe `expires` field so the client\n * runtime stays minimal:\n * - `number` → seconds from cookie creation (relative);\n * - `string` → an absolute expiry as an ISO date string.\n */\nexport type ProcessedCookieAttributes = {\n domain?: string;\n path?: string;\n secure?: boolean;\n httpOnly?: boolean;\n sameSite?: 'strict' | 'lax' | 'none';\n expires?: number | string;\n};\n\n/**\n * Pre-computed storage attributes derived from `RoutingConfig.storage`.\n * Computed at config-build time to avoid repeated processing at runtime.\n */\nexport type ProcessedStorageAttributes = {\n cookies?: {\n name: string;\n attributes: ProcessedCookieAttributes;\n }[];\n localStorage?: {\n name: string;\n }[];\n sessionStorage?: {\n name: string;\n }[];\n headers?: {\n name: string;\n }[];\n};\n\nexport type RewriteRule<T extends string = string> = {\n canonical: T;\n localized: StrictModeLocaleMap<string>;\n};\n\nexport type RewriteRules = {\n rules: RewriteRule[];\n};\n\nexport type RewriteObject = {\n /**\n * Used for client-side URL generation (e.g., getLocalizedUrl).\n * Patterns are usually stripped of locale prefixes as the core logic handles prefixing.\n */\n url: RewriteRules;\n /**\n * Used for Next.js middleware / proxy.\n * Patterns usually include [locale] or :locale to match incoming full URLs.\n */\n nextjs?: RewriteRules;\n /**\n * Used for Vite proxy middleware.\n */\n vite?: RewriteRules;\n};\n\n/**\n * Configuration for routing behaviors\n */\nexport type RoutingConfig = {\n /**\n * Rewrite the URLs to a localized path\n *\n * Example:\n * ```ts\n * // ...\n * routing: {\n * rewrite: nextjsRewrite({\n * '[locale]/about': {\n * fr: '[locale]/a-propos'\n * }\n * })\n * }\n * ```\n */\n rewrite?: Record<URLPath, StrictModeLocaleMap<URLPath>> | RewriteObject;\n\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\n * - 'prefix-all': Prefix all locales including the default locale\n * - 'no-prefix': No locale prefixing in URLs\n * - 'search-params': Use search parameters for locale handling\n *\n * Examples with defaultLocale = 'en':\n * - 'prefix-no-default': /dashboard (en) or /fr/dashboard (fr)\n * - 'prefix-all': /en/dashboard (en) or /fr/dashboard (fr)\n * - 'no-prefix': /dashboard (locale handled via other means)\n * - 'search-params': /dashboard?locale=fr\n *\n * Note: This setting do not impact the cookie, or locale storage management.\n *\n * Default: 'prefix-no-default'\n */\n mode: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n\n /**\n * Pre-computed storage attributes derived from the raw `storage` input.\n * Populated at config-build time by `getStorageAttributes(rawStorage)`.\n * Use this at runtime instead of re-processing the raw storage config.\n */\n storage: ProcessedStorageAttributes;\n\n /**\n * Base path for application URLs\n *\n * Default: ''\n *\n * Defines the base path where the application is accessible from.\n */\n basePath?: string;\n\n /**\n * Maps locales to specific domain hostnames for domain-based routing.\n * When a locale is mapped to a domain, URLs generated for that locale\n * will use that domain as the base URL (absolute URL), and no locale\n * prefix will be added to the path (the domain itself implies the locale).\n *\n * Default: undefined\n *\n * Example:\n * ```ts\n * domains: {\n * en: 'intlayer.org',\n * zh: 'intlayer.cn',\n * }\n * ```\n */\n domains?: Partial<Record<LocalesValues, string>>;\n};\n\n/**\n * Raw storage input accepted in the user-facing config (`intlayer.config.ts`).\n * Converted to {@link ProcessedStorageAttributes} during config build.\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.\n *\n * Default: ['cookie', 'header]\n *\n * Note: Check out GDPR compliance for cookies. See https://gdpr.eu/cookies/\n * Note: useLocale hook includes a prop to disable the cookie storage.\n * Note: Even if storage is disabled, the middleware will still detect the locale from the request header (1- check for `x-intlayer-locale`, 2- fallback to the `accept-language`).\n *\n * Recommendation:\n * - Config both localStorage and cookies for the storage of the locale if you want to support GDPR compliance.\n * - Disable the cookie storage by default on the useLocale hook by waiting for the user to consent to the cookie storage.\n */\nexport type RoutingStorageInput =\n | false\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes\n | (\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes\n )[];\n\n/**\n * User-facing routing configuration (accepted in `intlayer.config.ts`).\n */\nexport type CustomRoutingConfig = Omit<RoutingConfig, 'storage'> & {\n storage?: RoutingStorageInput;\n};\n\n/**\n * Configuration for intlayer editor\n */\nexport type EditorConfig = {\n /**\n * URL of the application. Used to restrict the origin of the editor for security reasons.\n *\n * Default: ''\n */\n applicationURL?: URLType;\n editorURL?: URLType;\n cmsURL?: URLType;\n backendURL?: URLType;\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: false;\n *\n * If true, the editor will be able to interact with the application.\n * If false, the editor will not be able to interact with the application.\n * In any case, the editor can only be enabled by the visual editor.\n * Disabling the editor for specific environments is a way to enforce the security.\n *\n * Usage:\n * ```js\n * {\n * // Other configurations\n * editor: {\n * enabled: process.env.NODE_ENV !== 'production',\n * }\n * };\n * ```\n *\n */\n enabled: boolean;\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: number;\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://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?: string;\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://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?: string;\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy: 'local_first' | 'distant_first';\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * Default: true\n */\n liveSync: boolean;\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: number;\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${liveSyncPort}`\n */\n liveSyncURL: URLType;\n};\n\nexport enum AiProviders {\n OPENAI = 'openai',\n ANTHROPIC = 'anthropic',\n MISTRAL = 'mistral',\n DEEPSEEK = 'deepseek',\n GEMINI = 'gemini',\n OLLAMA = 'ollama',\n OPENROUTER = 'openrouter',\n ALIBABA = 'alibaba',\n FIREWORKS = 'fireworks',\n GROQ = 'groq',\n HUGGINGFACE = 'huggingface',\n BEDROCK = 'bedrock',\n GOOGLEVERTEX = 'googlevertex',\n GOOGLEGENERATIVEAI = 'googlegenerativeai',\n TOGETHERAI = 'togetherai',\n LMSTUDIO = 'lmstudio',\n}\n\nexport type CommonAiConfig = {\n /**\n * API model\n *\n * The model to use for the AI features of Intlayer.\n *\n * Example: 'gpt-4o-2024-11-20'\n *\n */\n model?: string;\n\n /**\n * temperature\n *\n * The temperature to use for the AI features of Intlayer.\n * The temperature controls the randomness of the AI's responses.\n * A higher temperature will make the AI more creative and less predictable.\n *\n * Example: 0.1\n */\n temperature?: number;\n\n /**\n * API key\n *\n * Use your own OpenAI API key to use the AI features of Intlayer.\n * If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.\n *\n */\n apiKey?: string;\n\n /**\n * Application context\n *\n * The context of the application to use for the AI features of Intlayer.\n *\n * Example: 'This is a website for a company that sells products online.'\n */\n applicationContext?: string;\n\n /**\n * Base URL\n *\n * The base URL to use for the AI features of Intlayer.\n *\n * Example: 'https://api.openai.com/v1'\n */\n baseURL?: string;\n\n /**\n * Data serialization\n *\n * The data serialization format to use for the AI features of Intlayer.\n *\n * Default: 'json'\n */\n dataSerialization?: 'json' | 'toon';\n};\n\nexport type AiProviderConfigMap = {};\n\ntype AiConfigUnion = {\n [P in keyof AiProviderConfigMap]: {\n provider: P | `${P}`;\n } & AiProviderConfigMap[P];\n}[keyof AiProviderConfigMap];\n\nexport type AiConfig = CommonAiConfig &\n (AiConfigUnion | { provider?: AiProviders | `${AiProviders}` });\n\nexport type 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: 'auto' | 'manual';\n\n /**\n * Indicates if the build should be optimized\n *\n * Default: undefined\n *\n * If true, the build will be optimized.\n * If false, the build will not be optimized.\n *\n * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.\n * All imports will stay as static import to avoid async processing when loading the dictionaries.\n *\n * Note:\n * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.\n * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize?: boolean;\n\n /**\n * Indicates the mode of import to use for the dictionaries.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * - \"fetch\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Fetch mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as \"dynamic\" mode.\n *\n * Default: \"static\"\n *\n * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.\n *\n * Note:\n * - Dynamic imports rely on Suspense and may slightly impact rendering performance.\n * - If desabled all locales will be loaded at once, even if they are not used.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n * - This option will be ignored if `optimize` is disabled.\n * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.\n * - The \"fetch\" allows to sync the dictionaries to the live sync server.\n * - Require static key to work. Example of invalid code: `const navbarKey = \"my-key\"; useIntlayer(navbarKey)`.\n *\n * @deprecated Use `dictionary.importMode` instead.\n */\n importMode?: 'static' | 'dynamic' | 'fetch';\n\n /**\n * Minify the dictionaries to reduce the bundle size.\n *\n * Default: false\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - This option will be ignore if `editor.enabled` is true.\n * - If there is edge cases where the minification is not working properly, the dictionary will be not minified.\n */\n minify: boolean;\n\n /**\n * Purge the unused keys in a dictionaries\n *\n * Default: false\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n */\n purge: boolean;\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}', '!**\\/node_modules/**']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: string[];\n\n /**\n * Output format of the dictionaries\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'. Even if dictionaries are written in JSON, entry point to access the dictionaries are generated.\n * This function will use the output format defined using this option.\n * The default format is 'cjs' as it allows better interoperability with other libraries, scripts, and applications. But some build tools, such as Vite, require ES modules.\n */\n outputFormat: ('cjs' | 'esm')[];\n\n /**\n * Indicates if the cache should be enabled\n *\n * Default: true\n *\n * If true, the cache will be enabled.\n * If false, the cache will not be enabled.\n */\n cache: boolean;\n\n /**\n * Require function\n *\n * In some environments, as VSCode extension, the require function should be set relatively to the project root to work properly.\n *\n * Default: undefined\n *\n * If undefined, the require function will be set to the default require function.\n * If defined, the require function will be set to the defined require function.\n *\n * Example:\n * ```js\n * {\n * require: require\n * }\n * ```\n */\n require?: NodeJS.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: boolean;\n};\n\nexport type CompilerConfig = {\n /**\n * Indicates if the compiler should be enabled.\n * If 'build-only', the compiler will be skipped during development mode to speed up start times.\n */\n enabled: boolean | 'build-only';\n\n /**\n * Prefix for the extracted dictionary keys.\n * Default: ''\n */\n dictionaryKeyPrefix?: string;\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: ['**\\/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}', '!**\\/node_modules/**']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n *\n * @deprecated use build.traversePattern instead\n */\n transformPattern?: string | string[];\n\n /**\n * Pattern to exclude from the optimization.\n *\n * Allows to exclude files from the optimization.\n *\n * Default: ['**\\/node_modules/**']\n *\n * Example: `['**\\/node_modules/**', '!**\\/node_modules/react/**']`\n *\n * @deprecated use build.traversePattern instead\n */\n excludePattern?: string | string[];\n\n /**\n * Defines the output files path. Replaces `outputDir`.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.\n *\n * Example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * output: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // output: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create per-locale JSON files with locale-specific output paths\n * output: {\n * en: ({ fileName, locale }) => `${fileName}.${locale}.content.json`,\n * fr: '{{fileName}}.{{locale}}.content.json',\n * es: false, // skip this locale\n * },\n * }\n * ```\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n output?: Fill;\n\n /**\n * Indicates if the metadata should be saved in the file.\n *\n * If true, the compiler will not save the metadata of the dictionaries.\n *\n * If true:\n *\n * ```json\n * {\n * \"key\": \"value\"\n * }\n * ```\n *\n * If false:\n *\n * ```json\n * {\n * \"key\": \"value\",\n * \"content\": {\n * \"key\": \"value\"\n * }\n * }\n * ```\n *\n * Default: false\n *\n * Note: Useful if used with loadJSON plugin\n *\n */\n noMetadata?: boolean;\n\n /**\n * Indicates if the components should be saved after being transformed.\n *\n * If true, the compiler will replace the original files with the transformed files.\n * That way, the compiler can be run only once to transform the app, and then it can be removed.\n *\n * Default: false\n */\n saveComponents: boolean;\n};\n\n/**\n * Custom configuration that can be provided to override default settings\n */\nexport type CustomIntlayerConfig = {\n /**\n * Custom internationalization configuration\n */\n internationalization?: Partial<InternationalizationConfig>;\n\n /**\n * Custom dictionary configuration\n */\n dictionary?: Partial<DictionaryConfig>;\n\n /**\n * Custom routing configuration\n */\n routing?: Partial<CustomRoutingConfig>;\n\n /**\n * Custom content configuration\n */\n content?: Partial<ContentConfig>;\n\n /**\n * Custom editor configuration\n */\n editor?: Partial<EditorConfig>;\n\n /**\n * Custom log configuration\n */\n log?: Partial<LogConfig>;\n\n /**\n * Custom AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Custom build configuration\n */\n build?: Partial<BuildConfig>;\n\n /**\n * Custom compiler configuration\n */\n compiler?: Partial<CompilerConfig>;\n\n /**\n * Custom system configuration\n */\n system?: Partial<SystemConfig>;\n\n /**\n * Custom schemas to validate the dictionaries content.\n *\n * Example:\n * ```ts\n * {\n * schemas: {\n * 'my-schema': z.object({\n * title: z.string(),\n * description: z.string(),\n * }),\n * }\n * }\n * ```\n */\n schemas?: Record<string, ConfigSchema>;\n\n /**\n * Custom plugins configuration\n */\n plugins?: (Plugin | Promise<Plugin>)[];\n};\n\nexport type DictionaryConfig = {\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: `true`\n *\n * - If `true`, will consider the `compiler.output` field.\n * - If `false`, will skip the fill process.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - If includes `{{locale}}` variable in the path, will trigger the generation of separate dictionaries per locale.\n *\n * Example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * fill: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // fill: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * fill: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // fill: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create custom output based on the locale\n * fill: {\n * en: ({ key }) => `/locales/en/${key}.content.json`,\n * fr: '/locales/fr/{{key}}.content.json',\n * es: false,\n * de: true,\n * },\n * }\n * ```\n *\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n fill?: Fill;\n /**\n * The description of the dictionary. Helps to understand the purpose of the dictionary in the editor, and the CMS.\n * The description is also used as context for translations generation.\n *\n * Example:\n * ```ts\n * {\n * \"key\": \"about-page-meta\",\n * \"description\":[\n * \"This dictionary is manage the metadata of the About Page\",\n * \"Consider good practices for SEO:\",\n * \"- The title should be between 50 and 60 characters\",\n * \"- The description should be between 150 and 160 characters\",\n * ].join('\\n'),\n * \"content\": { ... }\n * }\n * ```\n */\n description?: string;\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 * If declared, do not use translation nodes in the content.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"locale\": \"en\",\n * \"content\": {\n * \"multilingualContent\": \"English content\"\n * }\n * }\n * ```\n */\n locale?: LocalesValues;\n /**\n * Indicators if the content of the dictionary should be automatically transformed.\n * If true, the content will be transformed to the corresponding node type.\n * - Markdown: `### Title` -> `md('### Title')`\n * - HTML: `<div>Title</div>` -> `html('<div>Title</div>')`\n * - Insertion: `Hello {{name}}` -> `insert('Hello {{name}}')`\n *\n * If an object is provided, you can specify which transformations should be enabled.\n *\n * Default: false\n */\n contentAutoTransformation?: ContentAutoTransformation;\n /**\n * Indicates the priority of the dictionary.\n * In the case of conflicts, the dictionary with the highest priority will override the other dictionaries.\n */\n priority?: number;\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 * - \"fetch\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Fetch 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 \"fetch\" allows to sync the dictionaries to the live sync server.\n * - Require static key to work. Example of invalid code: `const navbarKey = \"my-key\"; useIntlayer(navbarKey)`.\n */\n importMode?: 'static' | 'dynamic' | 'fetch';\n /**\n * The title of the dictionary. Helps to identify the dictionary in the editor, and the CMS.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page-meta\",\n * \"title\": \"About Page\",\n * \"content\": { ... }\n * }\n * ```\n */\n title?: string;\n /**\n * Helps to categorize the dictionaries. The tags can provide more context and instructions for the dictionary.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page-meta\",\n * \"tags\": [\"metadata\",\"about-page\"]\n * }\n * ```\n */\n tags?: string[];\n /**\n * Indicates the location of the dictionary and controls how it synchronizes with the CMS.\n *\n * - 'hybrid': The dictionary is managed locally and remotely. Once pushed on the CMS, it will be synchronized from the local one. The local dictionary will be pulled from the CMS.\n * - 'remote': The dictionary is managed remotely only. Once pushed on the CMS, it will be detached from the local one. At content load time, the remote dictionary will be pulled from the CMS. A '.content' file with remote location will be ignored.\n * - 'local': The dictionary is managed locally. It will not be pushed to the remote CMS.\n * - 'plugin' (or any custom string): The dictionary is managed by a plugin, or a custom source. When you will try to push it, the system will ask an action to the user.\n */\n location?: DictionaryLocation;\n};\n\n/**\n * Combined configuration for internationalization, middleware, and content\n */\nexport type IntlayerConfig = {\n /**\n * Internationalization configuration\n */\n internationalization: InternationalizationConfig;\n\n /**\n * Default dictionary configuration\n */\n dictionary?: Partial<DictionaryConfig>;\n\n /**\n * Routing configuration\n */\n routing: RoutingConfig;\n\n /**\n * Content configuration\n */\n content: ContentConfig;\n\n /**\n * System configuration\n */\n system: SystemConfig;\n\n /**\n * Intlayer editor configuration\n */\n editor: EditorConfig;\n\n /**\n * Logger configuration\n */\n log: LogConfig;\n\n /**\n * AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Build configuration\n */\n build: BuildConfig;\n\n /**\n * Compiler configuration\n */\n compiler: CompilerConfig;\n\n /**\n * Custom schemas to validate the dictionaries content.\n */\n schemas?: Record<string, ConfigSchema>;\n\n /**\n * Plugins configuration\n */\n plugins?: Plugin[];\n};\n\n/**\n * Configuration for content handling\n */\nexport type ContentConfig = {\n /**\n * File extensions of content to look for\n *\n * Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * List of file extensions to scan for content.\n */\n fileExtensions: string[];\n\n /**\n * Directory where the content is stored, relative to the base directory\n *\n * Default: ['.']\n *\n * Derived content directory based on the base configuration.\n *\n * Note: This is used to watch for content files.\n */\n contentDir: string[];\n\n /**\n * Directory where the code is stored, relative to the base directory\n *\n * Default: ['.']\n *\n * Derived code directory based on the base configuration.\n *\n * Note: This is used to watch for code files to transform.\n */\n codeDir: string[];\n\n /**\n * Directories to be excluded from content processing\n *\n * Default: ['node_modules', '.intlayer']\n *\n * A list of directories to exclude from content processing.\n */\n excludedPath: string[];\n\n /**\n * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.\n *\n * Default: process.env.NODE_ENV === 'development'\n */\n watch: boolean;\n\n /**\n * Command to format the content. When intlayer write your .content files locally, this command will be used to format the content.\n *\n * Example:\n *\n * ```bash\n * npx prettier --write {{file}}\n * ```\n *\n * ```bash\n * bunx biome format {{file}}\n * ```\n *\n * ```bash\n * bun format {{file}}\n * ```\n *\n * ```bash\n * npx eslint --fix {{file}}\n * ```\n *\n * Intlayer will replace the {{file}} with the path of the file to format.\n *\n * Default: undefined\n */\n formatCommand: string | undefined;\n};\n\nexport type SystemConfig = {\n /**\n * Absolute path of the project's base directory\n *\n * Default: process.cwd()\n *\n * The root directory of the project, typically used for resolving other paths.\n */\n baseDir: string;\n\n /**\n * Directory for module augmentation, relative to the base directory\n *\n * Default: .intlayer/types\n *\n * Defines the derived path for module augmentation.\n */\n moduleAugmentationDir: string;\n\n /**\n * Directory where unmerged dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/unmerged_dictionary\n *\n * Specifies the derived path for unmerged dictionaries relative to the result directory.\n */\n unmergedDictionariesDir: string;\n\n /**\n * Directory where remote dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/remote_dictionary\n *\n * Specifies the derived path for remote dictionaries relative to the result directory.\n */\n remoteDictionariesDir: string;\n\n /**\n * Directory where final dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Specifies the derived path for dictionaries relative to the result directory.\n */\n dictionariesDir: string;\n\n /**\n * Directory where dynamic dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dynamic_dictionary\n *\n * Specifies the derived path for dynamic dictionaries relative to the result directory.\n */\n dynamicDictionariesDir: string;\n\n /**\n * Directory where fetch dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/fetch_dictionary\n *\n * Specifies the derived path for fetch dictionaries relative to the result directory.\n */\n fetchDictionariesDir: string;\n\n /**\n * Directory where dictionary types are stored, relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Specifies the derived path for dictionary types relative to the result directory.\n */\n typesDir: string;\n\n /**\n * Directory where the main files are stored, relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Specifies the derived path for the main files relative to the result directory.\n */\n mainDir: string;\n\n /**\n * Directory where the configuration files are stored, relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Specifies the derived path for the configuration files relative to the result directory.\n */\n configDir: string;\n\n /**\n * Directory where the cache files are stored, relative to the result directory\n *\n * Default: .intlayer/cache\n *\n * Specifies the derived path for the cache files relative to the result directory.\n */\n cacheDir: string;\n\n /**\n * Directory where the temp files are stored, relative to the result directory\n *\n * Default: .intlayer/tmp\n *\n * Specifies the derived path for the tmp files relative to the result directory.\n */\n tempDir: string;\n};\n\nexport type LogFunctions = {\n error?: typeof console.error;\n log?: typeof console.log;\n info?: typeof console.info;\n warn?: typeof console.warn;\n};\n\nexport type LogConfig = {\n /**\n * Indicates if the logger is enabled\n *\n * Default: true\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: 'default' | 'verbose' | 'disabled';\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: string;\n\n /**\n * Functions to log\n */\n error?: typeof console.error;\n log?: typeof console.log;\n info?: typeof console.info;\n warn?: typeof console.warn;\n debug?: typeof console.debug;\n};\n"],"mappings":";;;AA4dA,IAAY,cAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;KACD"}
|
|
1
|
+
{"version":3,"file":"config.cjs","names":[],"sources":["../../src/config.ts"],"sourcesContent":["import type { Locale } from './allLocales';\nimport type {\n ContentAutoTransformation,\n DictionaryFormat,\n DictionaryLocation,\n Fill,\n} from './dictionary';\nimport type { LocalesValues, StrictModeLocaleMap } from './module_augmentation';\nimport type { Plugin } from './plugin';\n\n/**\n * Structural type for schema validation, compatible with Zod and other\n * schema libraries that implement safeParse. Avoids a hard dependency on Zod.\n */\nexport type ConfigSchema = {\n safeParse(data: unknown): {\n success: boolean;\n data?: unknown;\n error?: unknown;\n };\n};\n\nexport type StrictMode = 'strict' | 'inclusive' | 'loose';\n\ntype Protocol = 'http' | 'https';\n\ntype URLPath = `/${string}`;\n\ntype OptionalURLPath = `/${string}` | '';\n\n// Localhost: STRICTLY requires a port\ntype LocalhostURL = `${Protocol}://localhost:${number}${OptionalURLPath}`;\n// IP Address: Start with number, allows optional port\n// (Heuristic: Starts with a number, contains dots)\ntype IPUrl =\n | `${Protocol}://${number}.${string}${OptionalURLPath}`\n | `${Protocol}://${number}.${string}:${number}${OptionalURLPath}`;\n\n// Standard Domain: Requires at least one dot to rule out plain \"localhost\"\n// (Heuristic: starts with non-number string, contains dot)\ntype DomainURL = `${Protocol}://${string}.${string}${OptionalURLPath}`;\n\nexport type URLType = LocalhostURL | IPUrl | DomainURL | (string & {});\n\n/**\n * Configuration for internationalization settings\n */\nexport type InternationalizationConfig = {\n /**\n * Locales available in the application\n *\n * Default: [Locales.ENGLISH]\n *\n * You can define a list of available locales to support in the application.\n */\n locales: Locale[];\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: Locale[];\n\n /**\n * Ensure strong implementations of internationalized content using typescript.\n * - If set to \"strict\", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.\n * - If set to \"inclusive\", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.\n * - If set to \"loose\", the translation `t` function will accept any existing locale.\n *\n * Default: \"inclusive\"\n */\n strictMode: StrictMode;\n\n /**\n * Default locale of the application for fallback\n *\n * Default: Locales.ENGLISH\n *\n * Used to specify a fallback locale in case no other locale is set.\n */\n defaultLocale: Locale;\n};\n\nexport type CookiesAttributes = {\n /**\n * Type of the storage\n *\n * The type of the storage. It can be 'cookie'.\n */\n type: 'cookie';\n /**\n * Cookie name to store the locale information\n *\n * Default: 'INTLAYER_LOCALE'\n *\n * The cookie key where the locale information is stored.\n */\n name?: string;\n /**\n * Cookie domain to store the locale information\n *\n * Default: undefined\n *\n * Define the domain where the cookie is available. Defaults to\n * the domain of the page where the cookie was created.\n */\n domain?: string;\n /**\n * Cookie path to store the locale information\n *\n * Default: undefined\n *\n * Define the path where the cookie is available. Defaults to '/'\n */\n path?: string;\n /**\n * Cookie secure to store the locale information\n *\n * Default: undefined\n *\n * A Boolean indicating if the cookie transmission requires a\n * secure protocol (https). Defaults to false.\n */\n secure?: boolean;\n /**\n * Cookie httpOnly to store the locale information\n *\n * Default: undefined\n *\n * The cookie httpOnly where the locale information is stored.\n */\n httpOnly?: boolean;\n /**\n * Cookie sameSite to store the locale information\n *\n * Default: undefined\n *\n * Asserts that a cookie must not be sent with cross-origin requests,\n * providing some protection against cross-site request forgery\n * attacks (CSRF)\n */\n sameSite?: 'strict' | 'lax' | 'none';\n\n /**\n * Cookie expires to store the locale information\n *\n * Default: undefined\n *\n * Define when the cookie will be removed:\n * - a `number` is interpreted as **days from the time of creation**;\n * - a `Date` instance (or an ISO date string, e.g. produced when the\n * configuration is serialized) is interpreted as an **absolute moment**.\n *\n * If omitted, the cookie becomes a session cookie. When `maxAge` is set it\n * takes precedence over `expires`.\n */\n expires?: Date | number | string | undefined;\n /**\n * Cookie max-age to store the locale information\n *\n * Default: undefined\n *\n * Define the cookie lifetime in seconds from the time of creation\n * (e.g. `60 * 60 * 24 * 365` for one year). Takes precedence over\n * `expires` when both are set.\n */\n maxAge?: number;\n};\n\nexport type StorageAttributes = {\n /**\n * Storage type where the locale is stored\n *\n * Determines whether the locale is persisted in `localStorage` (across sessions)\n * or `sessionStorage` (cleared when the browser session ends) or `header` (from the request header).\n */\n type: 'localStorage' | 'sessionStorage' | 'header';\n\n /**\n * Storage key to store the locale information\n *\n * Default: 'INTLAYER_LOCALE'\n *\n * The key name used in the client storage to save the locale.\n */\n name?: string;\n};\n\n/**\n * Cookie attributes after the config-build normalization step.\n *\n * The user-facing `expires` (days / `Date` / ISO string) and `maxAge` (seconds)\n * are merged into a single, serialization-safe `expires` field so the client\n * runtime stays minimal:\n * - `number` → seconds from cookie creation (relative);\n * - `string` → an absolute expiry as an ISO date string.\n */\nexport type ProcessedCookieAttributes = {\n domain?: string;\n path?: string;\n secure?: boolean;\n httpOnly?: boolean;\n sameSite?: 'strict' | 'lax' | 'none';\n expires?: number | string;\n};\n\n/**\n * Pre-computed storage attributes derived from `RoutingConfig.storage`.\n * Computed at config-build time to avoid repeated processing at runtime.\n */\nexport type ProcessedStorageAttributes = {\n cookies?: {\n name: string;\n attributes: ProcessedCookieAttributes;\n }[];\n localStorage?: {\n name: string;\n }[];\n sessionStorage?: {\n name: string;\n }[];\n headers?: {\n name: string;\n }[];\n};\n\nexport type RewriteRule<T extends string = string> = {\n canonical: T;\n localized: StrictModeLocaleMap<string>;\n};\n\nexport type RewriteRules = {\n rules: RewriteRule[];\n};\n\nexport type RewriteObject = {\n /**\n * Used for client-side URL generation (e.g., getLocalizedUrl).\n * Patterns are usually stripped of locale prefixes as the core logic handles prefixing.\n */\n url: RewriteRules;\n /**\n * Used for Next.js middleware / proxy.\n * Patterns usually include [locale] or :locale to match incoming full URLs.\n */\n nextjs?: RewriteRules;\n /**\n * Used for Vite proxy middleware.\n */\n vite?: RewriteRules;\n};\n\n/**\n * Configuration for routing behaviors\n */\nexport type RoutingConfig = {\n /**\n * Rewrite the URLs to a localized path\n *\n * Example:\n * ```ts\n * // ...\n * routing: {\n * rewrite: nextjsRewrite({\n * '[locale]/about': {\n * fr: '[locale]/a-propos'\n * }\n * })\n * }\n * ```\n */\n rewrite?: Record<URLPath, StrictModeLocaleMap<URLPath>> | RewriteObject;\n\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\n * - 'prefix-all': Prefix all locales including the default locale\n * - 'no-prefix': No locale prefixing in URLs\n * - 'search-params': Use search parameters for locale handling\n *\n * Examples with defaultLocale = 'en':\n * - 'prefix-no-default': /dashboard (en) or /fr/dashboard (fr)\n * - 'prefix-all': /en/dashboard (en) or /fr/dashboard (fr)\n * - 'no-prefix': /dashboard (locale handled via other means)\n * - 'search-params': /dashboard?locale=fr\n *\n * Note: This setting do not impact the cookie, or locale storage management.\n *\n * Default: 'prefix-no-default'\n */\n mode: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n\n /**\n * Pre-computed storage attributes derived from the raw `storage` input.\n * Populated at config-build time by `getStorageAttributes(rawStorage)`.\n * Use this at runtime instead of re-processing the raw storage config.\n */\n storage: ProcessedStorageAttributes;\n\n /**\n * Base path for application URLs\n *\n * Default: ''\n *\n * Defines the base path where the application is accessible from.\n */\n basePath?: string;\n\n /**\n * Maps locales to specific domain hostnames for domain-based routing.\n * When a locale is mapped to a domain, URLs generated for that locale\n * will use that domain as the base URL (absolute URL), and no locale\n * prefix will be added to the path (the domain itself implies the locale).\n *\n * Default: undefined\n *\n * Example:\n * ```ts\n * domains: {\n * en: 'intlayer.org',\n * zh: 'intlayer.cn',\n * }\n * ```\n */\n domains?: Partial<Record<LocalesValues, string>>;\n};\n\n/**\n * Raw storage input accepted in the user-facing config (`intlayer.config.ts`).\n * Converted to {@link ProcessedStorageAttributes} during config build.\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.\n *\n * Default: ['cookie', 'header]\n *\n * Note: Check out GDPR compliance for cookies. See https://gdpr.eu/cookies/\n * Note: useLocale hook includes a prop to disable the cookie storage.\n * Note: Even if storage is disabled, the middleware will still detect the locale from the request header (1- check for `x-intlayer-locale`, 2- fallback to the `accept-language`).\n *\n * Recommendation:\n * - Config both localStorage and cookies for the storage of the locale if you want to support GDPR compliance.\n * - Disable the cookie storage by default on the useLocale hook by waiting for the user to consent to the cookie storage.\n */\nexport type RoutingStorageInput =\n | false\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes\n | (\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes\n )[];\n\n/**\n * User-facing routing configuration (accepted in `intlayer.config.ts`).\n */\nexport type CustomRoutingConfig = Omit<RoutingConfig, 'storage'> & {\n storage?: RoutingStorageInput;\n};\n\n/**\n * Configuration for intlayer editor\n */\nexport type EditorConfig = {\n /**\n * URL of the application. Used to restrict the origin of the editor for security reasons.\n *\n * Default: ''\n */\n applicationURL?: URLType;\n\n /**\n * Public URL for the editor.\n * Default: \"http://localhost:8000\"\n */\n editorURL?: URLType;\n\n /**\n * Intlayer CMS URL.\n * Default: \"https://app.intlayer.org\"\n */\n cmsURL?: URLType;\n\n /**\n * Backend API URL.\n * Default: \"https://back.intlayer.org\"\n */\n backendURL?: URLType;\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: false;\n *\n * If true, the editor will be able to interact with the application.\n * If false, the editor will not be able to interact with the application.\n * In any case, the editor can only be enabled by the visual editor.\n * Disabling the editor for specific environments is a way to enforce the security.\n *\n * Usage:\n * ```js\n * {\n * // Other configurations\n * editor: {\n * enabled: process.env.NODE_ENV !== 'production',\n * }\n * };\n * ```\n *\n */\n enabled: boolean;\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: number;\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://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?: string;\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://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?: string;\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy: 'local_first' | 'distant_first';\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * Default: true\n */\n liveSync: boolean;\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: number;\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${liveSyncPort}`\n */\n liveSyncURL: URLType;\n};\n\nexport enum AiProviders {\n OPENAI = 'openai',\n ANTHROPIC = 'anthropic',\n MISTRAL = 'mistral',\n DEEPSEEK = 'deepseek',\n GEMINI = 'gemini',\n OLLAMA = 'ollama',\n OPENROUTER = 'openrouter',\n ALIBABA = 'alibaba',\n FIREWORKS = 'fireworks',\n GROQ = 'groq',\n HUGGINGFACE = 'huggingface',\n BEDROCK = 'bedrock',\n GOOGLEVERTEX = 'googlevertex',\n GOOGLEGENERATIVEAI = 'googlegenerativeai',\n TOGETHERAI = 'togetherai',\n LMSTUDIO = 'lmstudio',\n}\n\nexport type CommonAiConfig = {\n /**\n * API model\n *\n * The model to use for the AI features of Intlayer.\n *\n * Example: 'gpt-4o-2024-11-20'\n *\n */\n model?: string;\n\n /**\n * temperature\n *\n * The temperature to use for the AI features of Intlayer.\n * The temperature controls the randomness of the AI's responses.\n * A higher temperature will make the AI more creative and less predictable.\n *\n * Example: 0.1\n */\n temperature?: number;\n\n /**\n * API key\n *\n * Use your own OpenAI API key to use the AI features of Intlayer.\n * If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.\n *\n */\n apiKey?: string;\n\n /**\n * Application context\n *\n * The context of the application to use for the AI features of Intlayer.\n *\n * Example: 'This is a website for a company that sells products online.'\n */\n applicationContext?: string;\n\n /**\n * Base URL\n *\n * The base URL to use for the AI features of Intlayer.\n *\n * Example: 'https://api.openai.com/v1'\n */\n baseURL?: string;\n\n /**\n * Data serialization\n *\n * The data serialization format to use for the AI features of Intlayer.\n *\n * Default: 'json'\n */\n dataSerialization?: 'json' | 'toon';\n};\n\nexport type AiProviderConfigMap = {};\n\ntype AiConfigUnion = {\n [P in keyof AiProviderConfigMap]: {\n provider: P | `${P}`;\n } & AiProviderConfigMap[P];\n}[keyof AiProviderConfigMap];\n\nexport type AiConfig = CommonAiConfig &\n (AiConfigUnion | { provider?: AiProviders | `${AiProviders}` });\n\nexport type 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: 'auto' | 'manual';\n\n /**\n * Indicates if the build should be optimized\n *\n * Default: undefined\n *\n * If true, the build will be optimized.\n * If false, the build will not be optimized.\n *\n * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.\n * All imports will stay as static import to avoid async processing when loading the dictionaries.\n *\n * Note:\n * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.\n * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize?: boolean;\n\n /**\n * Indicates the mode of import to use for the dictionaries.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * - \"fetch\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Fetch mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as \"dynamic\" mode.\n *\n * Default: \"static\"\n *\n * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.\n *\n * Note:\n * - Dynamic imports rely on Suspense and may slightly impact rendering performance.\n * - If desabled all locales will be loaded at once, even if they are not used.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n * - This option will be ignored if `optimize` is disabled.\n * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.\n * - The \"fetch\" allows to sync the dictionaries to the live sync server.\n * - Require static key to work. Example of invalid code: `const navbarKey = \"my-key\"; useIntlayer(navbarKey)`.\n *\n * @deprecated Use `dictionary.importMode` instead.\n */\n importMode?: 'static' | 'dynamic' | 'fetch';\n\n /**\n * Minify the dictionaries to reduce the bundle size.\n *\n * Default: false\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - This option will be ignore if `editor.enabled` is true.\n * - If there is edge cases where the minification is not working properly, the dictionary will be not minified.\n */\n minify: boolean;\n\n /**\n * Purge the unused keys in a dictionaries\n *\n * Default: false\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n */\n purge: boolean;\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}', '!**\\/node_modules/**']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: string[];\n\n /**\n * Output format of the dictionaries\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'. Even if dictionaries are written in JSON, entry point to access the dictionaries are generated.\n * This function will use the output format defined using this option.\n * The default format is 'cjs' as it allows better interoperability with other libraries, scripts, and applications. But some build tools, such as Vite, require ES modules.\n */\n outputFormat: ('cjs' | 'esm')[];\n\n /**\n * Indicates if the cache should be enabled\n *\n * Default: true\n *\n * If true, the cache will be enabled.\n * If false, the cache will not be enabled.\n */\n cache: boolean;\n\n /**\n * Require function\n *\n * In some environments, as VSCode extension, the require function should be set relatively to the project root to work properly.\n *\n * Default: undefined\n *\n * If undefined, the require function will be set to the default require function.\n * If defined, the require function will be set to the defined require function.\n *\n * Example:\n * ```js\n * {\n * require: require\n * }\n * ```\n */\n require?: NodeJS.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: boolean;\n};\n\nexport type CompilerConfig = {\n /**\n * Indicates if the compiler should be enabled.\n * If 'build-only', the compiler will be skipped during development mode to speed up start times.\n */\n enabled: boolean | 'build-only';\n\n /**\n * Prefix for the extracted dictionary keys.\n * Default: ''\n */\n dictionaryKeyPrefix?: string;\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: ['**\\/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}', '!**\\/node_modules/**']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n *\n * @deprecated use build.traversePattern instead\n */\n transformPattern?: string | string[];\n\n /**\n * Pattern to exclude from the optimization.\n *\n * Allows to exclude files from the optimization.\n *\n * Default: ['**\\/node_modules/**']\n *\n * Example: `['**\\/node_modules/**', '!**\\/node_modules/react/**']`\n *\n * @deprecated use build.traversePattern instead\n */\n excludePattern?: string | string[];\n\n /**\n * Defines the output files path. Replaces `outputDir`.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.\n *\n * Example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * output: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // output: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create per-locale JSON files with locale-specific output paths\n * output: {\n * en: ({ fileName, locale }) => `${fileName}.${locale}.content.json`,\n * fr: '{{fileName}}.{{locale}}.content.json',\n * es: false, // skip this locale\n * },\n * }\n * ```\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n output?: Fill;\n\n /**\n * Indicates if the metadata should be saved in the file.\n *\n * If true, the compiler will not save the metadata of the dictionaries.\n *\n * If true:\n *\n * ```json\n * {\n * \"key\": \"value\"\n * }\n * ```\n *\n * If false:\n *\n * ```json\n * {\n * \"key\": \"value\",\n * \"content\": {\n * \"key\": \"value\"\n * }\n * }\n * ```\n *\n * Default: false\n *\n * Note: Useful if used with loadJSON plugin\n *\n */\n noMetadata?: boolean;\n\n /**\n * Indicates if the components should be saved after being transformed.\n *\n * If true, the compiler will replace the original files with the transformed files.\n * That way, the compiler can be run only once to transform the app, and then it can be removed.\n *\n * Default: false\n */\n saveComponents: boolean;\n};\n\n/**\n * Custom configuration that can be provided to override default settings\n */\nexport type CustomIntlayerConfig = {\n /**\n * Custom internationalization configuration\n */\n internationalization?: Partial<InternationalizationConfig>;\n\n /**\n * Custom dictionary configuration\n */\n dictionary?: Partial<DictionaryConfig>;\n\n /**\n * Custom routing configuration\n */\n routing?: Partial<CustomRoutingConfig>;\n\n /**\n * Custom content configuration\n */\n content?: Partial<ContentConfig>;\n\n /**\n * Custom editor configuration\n */\n editor?: Partial<EditorConfig>;\n\n /**\n * Custom log configuration\n */\n log?: Partial<LogConfig>;\n\n /**\n * Custom AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Custom build configuration\n */\n build?: Partial<BuildConfig>;\n\n /**\n * Custom compiler configuration\n */\n compiler?: Partial<CompilerConfig>;\n\n /**\n * Custom system configuration\n */\n system?: Partial<SystemConfig>;\n\n /**\n * Custom schemas to validate the dictionaries content.\n *\n * Example:\n * ```ts\n * {\n * schemas: {\n * 'my-schema': z.object({\n * title: z.string(),\n * description: z.string(),\n * }),\n * }\n * }\n * ```\n */\n schemas?: Record<string, ConfigSchema>;\n\n /**\n * Custom plugins configuration\n */\n plugins?: (Plugin | Promise<Plugin>)[];\n};\n\nexport type DictionaryConfig = {\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: `true`\n *\n * - If `true`, will consider the `compiler.output` field.\n * - If `false`, will skip the fill process.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - If includes `{{locale}}` variable in the path, will trigger the generation of separate dictionaries per locale.\n *\n * Example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * fill: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // fill: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * fill: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // fill: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create custom output based on the locale\n * fill: {\n * en: ({ key }) => `/locales/en/${key}.content.json`,\n * fr: '/locales/fr/{{key}}.content.json',\n * es: false,\n * de: true,\n * },\n * }\n * ```\n *\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n fill?: Fill;\n /**\n * The description of the dictionary. Helps to understand the purpose of the dictionary in the editor, and the CMS.\n * The description is also used as context for translations generation.\n *\n * Example:\n * ```ts\n * {\n * \"key\": \"about-page-meta\",\n * \"description\":[\n * \"This dictionary is manage the metadata of the About Page\",\n * \"Consider good practices for SEO:\",\n * \"- The title should be between 50 and 60 characters\",\n * \"- The description should be between 150 and 160 characters\",\n * ].join('\\n'),\n * \"content\": { ... }\n * }\n * ```\n */\n description?: string;\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 * If declared, do not use translation nodes in the content.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"locale\": \"en\",\n * \"content\": {\n * \"multilingualContent\": \"English content\"\n * }\n * }\n * ```\n */\n locale?: LocalesValues;\n /**\n * Indicators if the content of the dictionary should be automatically transformed.\n * If true, the content will be transformed to the corresponding node type.\n * - Markdown: `### Title` -> `md('### Title')`\n * - HTML: `<div>Title</div>` -> `html('<div>Title</div>')`\n * - Insertion: `Hello {{name}}` -> `insert('Hello {{name}}')`\n *\n * If an object is provided, you can specify which transformations should be enabled.\n *\n * Default: false\n */\n contentAutoTransformation?: ContentAutoTransformation;\n /**\n * Indicates the priority of the dictionary.\n * In the case of conflicts, the dictionary with the highest priority will override the other dictionaries.\n */\n priority?: number;\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 * - \"fetch\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Fetch 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 \"fetch\" allows to sync the dictionaries to the live sync server.\n * - Require static key to work. Example of invalid code: `const navbarKey = \"my-key\"; useIntlayer(navbarKey)`.\n */\n importMode?: 'static' | 'dynamic' | 'fetch';\n /**\n * The title of the dictionary. Helps to identify the dictionary in the editor, and the CMS.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page-meta\",\n * \"title\": \"About Page\",\n * \"content\": { ... }\n * }\n * ```\n */\n title?: string;\n /**\n * Helps to categorize the dictionaries. The tags can provide more context and instructions for the dictionary.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page-meta\",\n * \"tags\": [\"metadata\",\"about-page\"]\n * }\n * ```\n */\n tags?: string[];\n /**\n * Indicates the location of the dictionary and controls how it synchronizes with the CMS.\n *\n * - 'hybrid': The dictionary is managed locally and remotely. Once pushed on the CMS, it will be synchronized from the local one. The local dictionary will be pulled from the CMS.\n * - 'remote': The dictionary is managed remotely only. Once pushed on the CMS, it will be detached from the local one. At content load time, the remote dictionary will be pulled from the CMS. A '.content' file with remote location will be ignored.\n * - 'local': The dictionary is managed locally. It will not be pushed to the remote CMS.\n * - 'plugin' (or any custom string): The dictionary is managed by a plugin, or a custom source. When you will try to push it, the system will ask an action to the user.\n */\n location?: DictionaryLocation;\n\n /**\n * The default message format for all dictionaries in the project.\n *\n * Controls how dictionary content strings are interpreted at runtime.\n *\n * - 'intlayer': Native intlayer format (default).\n * - 'icu': ICU message format (used by next-intl, react-intl, etc.).\n * - 'i18next': i18next interpolation format (used by i18next, react-i18next, next-i18next).\n * - 'vue-i18n': Vue I18n format (used by vue-i18n).\n * - 'po': GNU Gettext PO format.\n *\n * Default: 'intlayer'\n */\n format?: DictionaryFormat;\n};\n\n/**\n * Combined configuration for internationalization, middleware, and content\n */\nexport type IntlayerConfig = {\n /**\n * Internationalization configuration\n */\n internationalization: InternationalizationConfig;\n\n /**\n * Default dictionary configuration\n */\n dictionary?: Partial<DictionaryConfig>;\n\n /**\n * Routing configuration\n */\n routing: RoutingConfig;\n\n /**\n * Content configuration\n */\n content: ContentConfig;\n\n /**\n * System configuration\n */\n system: SystemConfig;\n\n /**\n * Intlayer editor configuration\n */\n editor: EditorConfig;\n\n /**\n * Logger configuration\n */\n log: LogConfig;\n\n /**\n * AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Build configuration\n */\n build: BuildConfig;\n\n /**\n * Compiler configuration\n */\n compiler: CompilerConfig;\n\n /**\n * Custom schemas to validate the dictionaries content.\n */\n schemas?: Record<string, ConfigSchema>;\n\n /**\n * Plugins configuration\n */\n plugins?: Plugin[];\n};\n\n/**\n * Configuration for content handling\n */\nexport type ContentConfig = {\n /**\n * File extensions of content to look for\n *\n * Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * List of file extensions to scan for content.\n */\n fileExtensions: string[];\n\n /**\n * Directory where the content is stored, relative to the base directory\n *\n * Default: ['.']\n *\n * Derived content directory based on the base configuration.\n *\n * Note: This is used to watch for content files.\n */\n contentDir: string[];\n\n /**\n * Directory where the code is stored, relative to the base directory\n *\n * Default: ['.']\n *\n * Derived code directory based on the base configuration.\n *\n * Note: This is used to watch for code files to transform.\n */\n codeDir: string[];\n\n /**\n * Directories to be excluded from content processing\n *\n * Default: ['node_modules', '.intlayer']\n *\n * A list of directories to exclude from content processing.\n */\n excludedPath: string[];\n\n /**\n * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.\n *\n * Default: process.env.NODE_ENV === 'development'\n */\n watch: boolean;\n\n /**\n * Command to format the content. When intlayer write your .content files locally, this command will be used to format the content.\n *\n * Example:\n *\n * ```bash\n * npx prettier --write {{file}}\n * ```\n *\n * ```bash\n * bunx biome format {{file}}\n * ```\n *\n * ```bash\n * bun format {{file}}\n * ```\n *\n * ```bash\n * npx eslint --fix {{file}}\n * ```\n *\n * Intlayer will replace the {{file}} with the path of the file to format.\n *\n * Default: undefined\n */\n formatCommand: string | undefined;\n};\n\nexport type SystemConfig = {\n /**\n * Absolute path of the project's base directory\n *\n * Default: process.cwd()\n *\n * The root directory of the project, typically used for resolving other paths.\n */\n baseDir: string;\n\n /**\n * Directory for module augmentation, relative to the base directory\n *\n * Default: .intlayer/types\n *\n * Defines the derived path for module augmentation.\n */\n moduleAugmentationDir: string;\n\n /**\n * Directory where unmerged dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/unmerged_dictionary\n *\n * Specifies the derived path for unmerged dictionaries relative to the result directory.\n */\n unmergedDictionariesDir: string;\n\n /**\n * Directory where remote dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/remote_dictionary\n *\n * Specifies the derived path for remote dictionaries relative to the result directory.\n */\n remoteDictionariesDir: string;\n\n /**\n * Directory where final dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Specifies the derived path for dictionaries relative to the result directory.\n */\n dictionariesDir: string;\n\n /**\n * Directory where dynamic dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dynamic_dictionary\n *\n * Specifies the derived path for dynamic dictionaries relative to the result directory.\n */\n dynamicDictionariesDir: string;\n\n /**\n * Directory where fetch dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/fetch_dictionary\n *\n * Specifies the derived path for fetch dictionaries relative to the result directory.\n */\n fetchDictionariesDir: string;\n\n /**\n * Directory where dictionary types are stored, relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Specifies the derived path for dictionary types relative to the result directory.\n */\n typesDir: string;\n\n /**\n * Directory where the main files are stored, relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Specifies the derived path for the main files relative to the result directory.\n */\n mainDir: string;\n\n /**\n * Directory where the configuration files are stored, relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Specifies the derived path for the configuration files relative to the result directory.\n */\n configDir: string;\n\n /**\n * Directory where the cache files are stored, relative to the result directory\n *\n * Default: .intlayer/cache\n *\n * Specifies the derived path for the cache files relative to the result directory.\n */\n cacheDir: string;\n\n /**\n * Directory where the temp files are stored, relative to the result directory\n *\n * Default: .intlayer/tmp\n *\n * Specifies the derived path for the tmp files relative to the result directory.\n */\n tempDir: string;\n};\n\nexport type LogFunctions = {\n error?: typeof console.error;\n log?: typeof console.log;\n info?: typeof console.info;\n warn?: typeof console.warn;\n};\n\nexport type LogConfig = {\n /**\n * Indicates if the logger is enabled\n *\n * Default: true\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: 'default' | 'verbose' | 'disabled';\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: string;\n\n /**\n * Functions to log\n */\n error?: typeof console.error;\n log?: typeof console.log;\n info?: typeof console.info;\n warn?: typeof console.warn;\n debug?: typeof console.debug;\n};\n"],"mappings":";;;AA4eA,IAAY,cAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;KACD"}
|
package/dist/esm/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../../src/config.ts"],"sourcesContent":["import type { Locale } from './allLocales';\nimport type {\n ContentAutoTransformation,\n DictionaryLocation,\n Fill,\n} from './dictionary';\nimport type { LocalesValues, StrictModeLocaleMap } from './module_augmentation';\nimport type { Plugin } from './plugin';\n\n/**\n * Structural type for schema validation, compatible with Zod and other\n * schema libraries that implement safeParse. Avoids a hard dependency on Zod.\n */\nexport type ConfigSchema = {\n safeParse(data: unknown): {\n success: boolean;\n data?: unknown;\n error?: unknown;\n };\n};\n\nexport type StrictMode = 'strict' | 'inclusive' | 'loose';\n\ntype Protocol = 'http' | 'https';\n\ntype URLPath = `/${string}`;\n\ntype OptionalURLPath = `/${string}` | '';\n\n// Localhost: STRICTLY requires a port\ntype LocalhostURL = `${Protocol}://localhost:${number}${OptionalURLPath}`;\n// IP Address: Start with number, allows optional port\n// (Heuristic: Starts with a number, contains dots)\ntype IPUrl =\n | `${Protocol}://${number}.${string}${OptionalURLPath}`\n | `${Protocol}://${number}.${string}:${number}${OptionalURLPath}`;\n\n// Standard Domain: Requires at least one dot to rule out plain \"localhost\"\n// (Heuristic: starts with non-number string, contains dot)\ntype DomainURL = `${Protocol}://${string}.${string}${OptionalURLPath}`;\n\nexport type URLType = LocalhostURL | IPUrl | DomainURL | (string & {});\n\n/**\n * Configuration for internationalization settings\n */\nexport type InternationalizationConfig = {\n /**\n * Locales available in the application\n *\n * Default: [Locales.ENGLISH]\n *\n * You can define a list of available locales to support in the application.\n */\n locales: Locale[];\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: Locale[];\n\n /**\n * Ensure strong implementations of internationalized content using typescript.\n * - If set to \"strict\", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.\n * - If set to \"inclusive\", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.\n * - If set to \"loose\", the translation `t` function will accept any existing locale.\n *\n * Default: \"inclusive\"\n */\n strictMode: StrictMode;\n\n /**\n * Default locale of the application for fallback\n *\n * Default: Locales.ENGLISH\n *\n * Used to specify a fallback locale in case no other locale is set.\n */\n defaultLocale: Locale;\n};\n\nexport type CookiesAttributes = {\n /**\n * Type of the storage\n *\n * The type of the storage. It can be 'cookie'.\n */\n type: 'cookie';\n /**\n * Cookie name to store the locale information\n *\n * Default: 'INTLAYER_LOCALE'\n *\n * The cookie key where the locale information is stored.\n */\n name?: string;\n /**\n * Cookie domain to store the locale information\n *\n * Default: undefined\n *\n * Define the domain where the cookie is available. Defaults to\n * the domain of the page where the cookie was created.\n */\n domain?: string;\n /**\n * Cookie path to store the locale information\n *\n * Default: undefined\n *\n * Define the path where the cookie is available. Defaults to '/'\n */\n path?: string;\n /**\n * Cookie secure to store the locale information\n *\n * Default: undefined\n *\n * A Boolean indicating if the cookie transmission requires a\n * secure protocol (https). Defaults to false.\n */\n secure?: boolean;\n /**\n * Cookie httpOnly to store the locale information\n *\n * Default: undefined\n *\n * The cookie httpOnly where the locale information is stored.\n */\n httpOnly?: boolean;\n /**\n * Cookie sameSite to store the locale information\n *\n * Default: undefined\n *\n * Asserts that a cookie must not be sent with cross-origin requests,\n * providing some protection against cross-site request forgery\n * attacks (CSRF)\n */\n sameSite?: 'strict' | 'lax' | 'none';\n\n /**\n * Cookie expires to store the locale information\n *\n * Default: undefined\n *\n * Define when the cookie will be removed:\n * - a `number` is interpreted as **days from the time of creation**;\n * - a `Date` instance (or an ISO date string, e.g. produced when the\n * configuration is serialized) is interpreted as an **absolute moment**.\n *\n * If omitted, the cookie becomes a session cookie. When `maxAge` is set it\n * takes precedence over `expires`.\n */\n expires?: Date | number | string | undefined;\n /**\n * Cookie max-age to store the locale information\n *\n * Default: undefined\n *\n * Define the cookie lifetime in seconds from the time of creation\n * (e.g. `60 * 60 * 24 * 365` for one year). Takes precedence over\n * `expires` when both are set.\n */\n maxAge?: number;\n};\n\nexport type StorageAttributes = {\n /**\n * Storage type where the locale is stored\n *\n * Determines whether the locale is persisted in `localStorage` (across sessions)\n * or `sessionStorage` (cleared when the browser session ends) or `header` (from the request header).\n */\n type: 'localStorage' | 'sessionStorage' | 'header';\n\n /**\n * Storage key to store the locale information\n *\n * Default: 'INTLAYER_LOCALE'\n *\n * The key name used in the client storage to save the locale.\n */\n name?: string;\n};\n\n/**\n * Cookie attributes after the config-build normalization step.\n *\n * The user-facing `expires` (days / `Date` / ISO string) and `maxAge` (seconds)\n * are merged into a single, serialization-safe `expires` field so the client\n * runtime stays minimal:\n * - `number` → seconds from cookie creation (relative);\n * - `string` → an absolute expiry as an ISO date string.\n */\nexport type ProcessedCookieAttributes = {\n domain?: string;\n path?: string;\n secure?: boolean;\n httpOnly?: boolean;\n sameSite?: 'strict' | 'lax' | 'none';\n expires?: number | string;\n};\n\n/**\n * Pre-computed storage attributes derived from `RoutingConfig.storage`.\n * Computed at config-build time to avoid repeated processing at runtime.\n */\nexport type ProcessedStorageAttributes = {\n cookies?: {\n name: string;\n attributes: ProcessedCookieAttributes;\n }[];\n localStorage?: {\n name: string;\n }[];\n sessionStorage?: {\n name: string;\n }[];\n headers?: {\n name: string;\n }[];\n};\n\nexport type RewriteRule<T extends string = string> = {\n canonical: T;\n localized: StrictModeLocaleMap<string>;\n};\n\nexport type RewriteRules = {\n rules: RewriteRule[];\n};\n\nexport type RewriteObject = {\n /**\n * Used for client-side URL generation (e.g., getLocalizedUrl).\n * Patterns are usually stripped of locale prefixes as the core logic handles prefixing.\n */\n url: RewriteRules;\n /**\n * Used for Next.js middleware / proxy.\n * Patterns usually include [locale] or :locale to match incoming full URLs.\n */\n nextjs?: RewriteRules;\n /**\n * Used for Vite proxy middleware.\n */\n vite?: RewriteRules;\n};\n\n/**\n * Configuration for routing behaviors\n */\nexport type RoutingConfig = {\n /**\n * Rewrite the URLs to a localized path\n *\n * Example:\n * ```ts\n * // ...\n * routing: {\n * rewrite: nextjsRewrite({\n * '[locale]/about': {\n * fr: '[locale]/a-propos'\n * }\n * })\n * }\n * ```\n */\n rewrite?: Record<URLPath, StrictModeLocaleMap<URLPath>> | RewriteObject;\n\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\n * - 'prefix-all': Prefix all locales including the default locale\n * - 'no-prefix': No locale prefixing in URLs\n * - 'search-params': Use search parameters for locale handling\n *\n * Examples with defaultLocale = 'en':\n * - 'prefix-no-default': /dashboard (en) or /fr/dashboard (fr)\n * - 'prefix-all': /en/dashboard (en) or /fr/dashboard (fr)\n * - 'no-prefix': /dashboard (locale handled via other means)\n * - 'search-params': /dashboard?locale=fr\n *\n * Note: This setting do not impact the cookie, or locale storage management.\n *\n * Default: 'prefix-no-default'\n */\n mode: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n\n /**\n * Pre-computed storage attributes derived from the raw `storage` input.\n * Populated at config-build time by `getStorageAttributes(rawStorage)`.\n * Use this at runtime instead of re-processing the raw storage config.\n */\n storage: ProcessedStorageAttributes;\n\n /**\n * Base path for application URLs\n *\n * Default: ''\n *\n * Defines the base path where the application is accessible from.\n */\n basePath?: string;\n\n /**\n * Maps locales to specific domain hostnames for domain-based routing.\n * When a locale is mapped to a domain, URLs generated for that locale\n * will use that domain as the base URL (absolute URL), and no locale\n * prefix will be added to the path (the domain itself implies the locale).\n *\n * Default: undefined\n *\n * Example:\n * ```ts\n * domains: {\n * en: 'intlayer.org',\n * zh: 'intlayer.cn',\n * }\n * ```\n */\n domains?: Partial<Record<LocalesValues, string>>;\n};\n\n/**\n * Raw storage input accepted in the user-facing config (`intlayer.config.ts`).\n * Converted to {@link ProcessedStorageAttributes} during config build.\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.\n *\n * Default: ['cookie', 'header]\n *\n * Note: Check out GDPR compliance for cookies. See https://gdpr.eu/cookies/\n * Note: useLocale hook includes a prop to disable the cookie storage.\n * Note: Even if storage is disabled, the middleware will still detect the locale from the request header (1- check for `x-intlayer-locale`, 2- fallback to the `accept-language`).\n *\n * Recommendation:\n * - Config both localStorage and cookies for the storage of the locale if you want to support GDPR compliance.\n * - Disable the cookie storage by default on the useLocale hook by waiting for the user to consent to the cookie storage.\n */\nexport type RoutingStorageInput =\n | false\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes\n | (\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes\n )[];\n\n/**\n * User-facing routing configuration (accepted in `intlayer.config.ts`).\n */\nexport type CustomRoutingConfig = Omit<RoutingConfig, 'storage'> & {\n storage?: RoutingStorageInput;\n};\n\n/**\n * Configuration for intlayer editor\n */\nexport type EditorConfig = {\n /**\n * URL of the application. Used to restrict the origin of the editor for security reasons.\n *\n * Default: ''\n */\n applicationURL?: URLType;\n editorURL?: URLType;\n cmsURL?: URLType;\n backendURL?: URLType;\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: false;\n *\n * If true, the editor will be able to interact with the application.\n * If false, the editor will not be able to interact with the application.\n * In any case, the editor can only be enabled by the visual editor.\n * Disabling the editor for specific environments is a way to enforce the security.\n *\n * Usage:\n * ```js\n * {\n * // Other configurations\n * editor: {\n * enabled: process.env.NODE_ENV !== 'production',\n * }\n * };\n * ```\n *\n */\n enabled: boolean;\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: number;\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://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?: string;\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://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?: string;\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy: 'local_first' | 'distant_first';\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * Default: true\n */\n liveSync: boolean;\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: number;\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${liveSyncPort}`\n */\n liveSyncURL: URLType;\n};\n\nexport enum AiProviders {\n OPENAI = 'openai',\n ANTHROPIC = 'anthropic',\n MISTRAL = 'mistral',\n DEEPSEEK = 'deepseek',\n GEMINI = 'gemini',\n OLLAMA = 'ollama',\n OPENROUTER = 'openrouter',\n ALIBABA = 'alibaba',\n FIREWORKS = 'fireworks',\n GROQ = 'groq',\n HUGGINGFACE = 'huggingface',\n BEDROCK = 'bedrock',\n GOOGLEVERTEX = 'googlevertex',\n GOOGLEGENERATIVEAI = 'googlegenerativeai',\n TOGETHERAI = 'togetherai',\n LMSTUDIO = 'lmstudio',\n}\n\nexport type CommonAiConfig = {\n /**\n * API model\n *\n * The model to use for the AI features of Intlayer.\n *\n * Example: 'gpt-4o-2024-11-20'\n *\n */\n model?: string;\n\n /**\n * temperature\n *\n * The temperature to use for the AI features of Intlayer.\n * The temperature controls the randomness of the AI's responses.\n * A higher temperature will make the AI more creative and less predictable.\n *\n * Example: 0.1\n */\n temperature?: number;\n\n /**\n * API key\n *\n * Use your own OpenAI API key to use the AI features of Intlayer.\n * If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.\n *\n */\n apiKey?: string;\n\n /**\n * Application context\n *\n * The context of the application to use for the AI features of Intlayer.\n *\n * Example: 'This is a website for a company that sells products online.'\n */\n applicationContext?: string;\n\n /**\n * Base URL\n *\n * The base URL to use for the AI features of Intlayer.\n *\n * Example: 'https://api.openai.com/v1'\n */\n baseURL?: string;\n\n /**\n * Data serialization\n *\n * The data serialization format to use for the AI features of Intlayer.\n *\n * Default: 'json'\n */\n dataSerialization?: 'json' | 'toon';\n};\n\nexport type AiProviderConfigMap = {};\n\ntype AiConfigUnion = {\n [P in keyof AiProviderConfigMap]: {\n provider: P | `${P}`;\n } & AiProviderConfigMap[P];\n}[keyof AiProviderConfigMap];\n\nexport type AiConfig = CommonAiConfig &\n (AiConfigUnion | { provider?: AiProviders | `${AiProviders}` });\n\nexport type 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: 'auto' | 'manual';\n\n /**\n * Indicates if the build should be optimized\n *\n * Default: undefined\n *\n * If true, the build will be optimized.\n * If false, the build will not be optimized.\n *\n * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.\n * All imports will stay as static import to avoid async processing when loading the dictionaries.\n *\n * Note:\n * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.\n * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize?: boolean;\n\n /**\n * Indicates the mode of import to use for the dictionaries.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * - \"fetch\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Fetch mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as \"dynamic\" mode.\n *\n * Default: \"static\"\n *\n * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.\n *\n * Note:\n * - Dynamic imports rely on Suspense and may slightly impact rendering performance.\n * - If desabled all locales will be loaded at once, even if they are not used.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n * - This option will be ignored if `optimize` is disabled.\n * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.\n * - The \"fetch\" allows to sync the dictionaries to the live sync server.\n * - Require static key to work. Example of invalid code: `const navbarKey = \"my-key\"; useIntlayer(navbarKey)`.\n *\n * @deprecated Use `dictionary.importMode` instead.\n */\n importMode?: 'static' | 'dynamic' | 'fetch';\n\n /**\n * Minify the dictionaries to reduce the bundle size.\n *\n * Default: false\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - This option will be ignore if `editor.enabled` is true.\n * - If there is edge cases where the minification is not working properly, the dictionary will be not minified.\n */\n minify: boolean;\n\n /**\n * Purge the unused keys in a dictionaries\n *\n * Default: false\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n */\n purge: boolean;\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}', '!**\\/node_modules/**']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: string[];\n\n /**\n * Output format of the dictionaries\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'. Even if dictionaries are written in JSON, entry point to access the dictionaries are generated.\n * This function will use the output format defined using this option.\n * The default format is 'cjs' as it allows better interoperability with other libraries, scripts, and applications. But some build tools, such as Vite, require ES modules.\n */\n outputFormat: ('cjs' | 'esm')[];\n\n /**\n * Indicates if the cache should be enabled\n *\n * Default: true\n *\n * If true, the cache will be enabled.\n * If false, the cache will not be enabled.\n */\n cache: boolean;\n\n /**\n * Require function\n *\n * In some environments, as VSCode extension, the require function should be set relatively to the project root to work properly.\n *\n * Default: undefined\n *\n * If undefined, the require function will be set to the default require function.\n * If defined, the require function will be set to the defined require function.\n *\n * Example:\n * ```js\n * {\n * require: require\n * }\n * ```\n */\n require?: NodeJS.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: boolean;\n};\n\nexport type CompilerConfig = {\n /**\n * Indicates if the compiler should be enabled.\n * If 'build-only', the compiler will be skipped during development mode to speed up start times.\n */\n enabled: boolean | 'build-only';\n\n /**\n * Prefix for the extracted dictionary keys.\n * Default: ''\n */\n dictionaryKeyPrefix?: string;\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: ['**\\/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}', '!**\\/node_modules/**']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n *\n * @deprecated use build.traversePattern instead\n */\n transformPattern?: string | string[];\n\n /**\n * Pattern to exclude from the optimization.\n *\n * Allows to exclude files from the optimization.\n *\n * Default: ['**\\/node_modules/**']\n *\n * Example: `['**\\/node_modules/**', '!**\\/node_modules/react/**']`\n *\n * @deprecated use build.traversePattern instead\n */\n excludePattern?: string | string[];\n\n /**\n * Defines the output files path. Replaces `outputDir`.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.\n *\n * Example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * output: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // output: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create per-locale JSON files with locale-specific output paths\n * output: {\n * en: ({ fileName, locale }) => `${fileName}.${locale}.content.json`,\n * fr: '{{fileName}}.{{locale}}.content.json',\n * es: false, // skip this locale\n * },\n * }\n * ```\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n output?: Fill;\n\n /**\n * Indicates if the metadata should be saved in the file.\n *\n * If true, the compiler will not save the metadata of the dictionaries.\n *\n * If true:\n *\n * ```json\n * {\n * \"key\": \"value\"\n * }\n * ```\n *\n * If false:\n *\n * ```json\n * {\n * \"key\": \"value\",\n * \"content\": {\n * \"key\": \"value\"\n * }\n * }\n * ```\n *\n * Default: false\n *\n * Note: Useful if used with loadJSON plugin\n *\n */\n noMetadata?: boolean;\n\n /**\n * Indicates if the components should be saved after being transformed.\n *\n * If true, the compiler will replace the original files with the transformed files.\n * That way, the compiler can be run only once to transform the app, and then it can be removed.\n *\n * Default: false\n */\n saveComponents: boolean;\n};\n\n/**\n * Custom configuration that can be provided to override default settings\n */\nexport type CustomIntlayerConfig = {\n /**\n * Custom internationalization configuration\n */\n internationalization?: Partial<InternationalizationConfig>;\n\n /**\n * Custom dictionary configuration\n */\n dictionary?: Partial<DictionaryConfig>;\n\n /**\n * Custom routing configuration\n */\n routing?: Partial<CustomRoutingConfig>;\n\n /**\n * Custom content configuration\n */\n content?: Partial<ContentConfig>;\n\n /**\n * Custom editor configuration\n */\n editor?: Partial<EditorConfig>;\n\n /**\n * Custom log configuration\n */\n log?: Partial<LogConfig>;\n\n /**\n * Custom AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Custom build configuration\n */\n build?: Partial<BuildConfig>;\n\n /**\n * Custom compiler configuration\n */\n compiler?: Partial<CompilerConfig>;\n\n /**\n * Custom system configuration\n */\n system?: Partial<SystemConfig>;\n\n /**\n * Custom schemas to validate the dictionaries content.\n *\n * Example:\n * ```ts\n * {\n * schemas: {\n * 'my-schema': z.object({\n * title: z.string(),\n * description: z.string(),\n * }),\n * }\n * }\n * ```\n */\n schemas?: Record<string, ConfigSchema>;\n\n /**\n * Custom plugins configuration\n */\n plugins?: (Plugin | Promise<Plugin>)[];\n};\n\nexport type DictionaryConfig = {\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: `true`\n *\n * - If `true`, will consider the `compiler.output` field.\n * - If `false`, will skip the fill process.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - If includes `{{locale}}` variable in the path, will trigger the generation of separate dictionaries per locale.\n *\n * Example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * fill: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // fill: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * fill: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // fill: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create custom output based on the locale\n * fill: {\n * en: ({ key }) => `/locales/en/${key}.content.json`,\n * fr: '/locales/fr/{{key}}.content.json',\n * es: false,\n * de: true,\n * },\n * }\n * ```\n *\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n fill?: Fill;\n /**\n * The description of the dictionary. Helps to understand the purpose of the dictionary in the editor, and the CMS.\n * The description is also used as context for translations generation.\n *\n * Example:\n * ```ts\n * {\n * \"key\": \"about-page-meta\",\n * \"description\":[\n * \"This dictionary is manage the metadata of the About Page\",\n * \"Consider good practices for SEO:\",\n * \"- The title should be between 50 and 60 characters\",\n * \"- The description should be between 150 and 160 characters\",\n * ].join('\\n'),\n * \"content\": { ... }\n * }\n * ```\n */\n description?: string;\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 * If declared, do not use translation nodes in the content.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"locale\": \"en\",\n * \"content\": {\n * \"multilingualContent\": \"English content\"\n * }\n * }\n * ```\n */\n locale?: LocalesValues;\n /**\n * Indicators if the content of the dictionary should be automatically transformed.\n * If true, the content will be transformed to the corresponding node type.\n * - Markdown: `### Title` -> `md('### Title')`\n * - HTML: `<div>Title</div>` -> `html('<div>Title</div>')`\n * - Insertion: `Hello {{name}}` -> `insert('Hello {{name}}')`\n *\n * If an object is provided, you can specify which transformations should be enabled.\n *\n * Default: false\n */\n contentAutoTransformation?: ContentAutoTransformation;\n /**\n * Indicates the priority of the dictionary.\n * In the case of conflicts, the dictionary with the highest priority will override the other dictionaries.\n */\n priority?: number;\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 * - \"fetch\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Fetch 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 \"fetch\" allows to sync the dictionaries to the live sync server.\n * - Require static key to work. Example of invalid code: `const navbarKey = \"my-key\"; useIntlayer(navbarKey)`.\n */\n importMode?: 'static' | 'dynamic' | 'fetch';\n /**\n * The title of the dictionary. Helps to identify the dictionary in the editor, and the CMS.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page-meta\",\n * \"title\": \"About Page\",\n * \"content\": { ... }\n * }\n * ```\n */\n title?: string;\n /**\n * Helps to categorize the dictionaries. The tags can provide more context and instructions for the dictionary.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page-meta\",\n * \"tags\": [\"metadata\",\"about-page\"]\n * }\n * ```\n */\n tags?: string[];\n /**\n * Indicates the location of the dictionary and controls how it synchronizes with the CMS.\n *\n * - 'hybrid': The dictionary is managed locally and remotely. Once pushed on the CMS, it will be synchronized from the local one. The local dictionary will be pulled from the CMS.\n * - 'remote': The dictionary is managed remotely only. Once pushed on the CMS, it will be detached from the local one. At content load time, the remote dictionary will be pulled from the CMS. A '.content' file with remote location will be ignored.\n * - 'local': The dictionary is managed locally. It will not be pushed to the remote CMS.\n * - 'plugin' (or any custom string): The dictionary is managed by a plugin, or a custom source. When you will try to push it, the system will ask an action to the user.\n */\n location?: DictionaryLocation;\n};\n\n/**\n * Combined configuration for internationalization, middleware, and content\n */\nexport type IntlayerConfig = {\n /**\n * Internationalization configuration\n */\n internationalization: InternationalizationConfig;\n\n /**\n * Default dictionary configuration\n */\n dictionary?: Partial<DictionaryConfig>;\n\n /**\n * Routing configuration\n */\n routing: RoutingConfig;\n\n /**\n * Content configuration\n */\n content: ContentConfig;\n\n /**\n * System configuration\n */\n system: SystemConfig;\n\n /**\n * Intlayer editor configuration\n */\n editor: EditorConfig;\n\n /**\n * Logger configuration\n */\n log: LogConfig;\n\n /**\n * AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Build configuration\n */\n build: BuildConfig;\n\n /**\n * Compiler configuration\n */\n compiler: CompilerConfig;\n\n /**\n * Custom schemas to validate the dictionaries content.\n */\n schemas?: Record<string, ConfigSchema>;\n\n /**\n * Plugins configuration\n */\n plugins?: Plugin[];\n};\n\n/**\n * Configuration for content handling\n */\nexport type ContentConfig = {\n /**\n * File extensions of content to look for\n *\n * Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * List of file extensions to scan for content.\n */\n fileExtensions: string[];\n\n /**\n * Directory where the content is stored, relative to the base directory\n *\n * Default: ['.']\n *\n * Derived content directory based on the base configuration.\n *\n * Note: This is used to watch for content files.\n */\n contentDir: string[];\n\n /**\n * Directory where the code is stored, relative to the base directory\n *\n * Default: ['.']\n *\n * Derived code directory based on the base configuration.\n *\n * Note: This is used to watch for code files to transform.\n */\n codeDir: string[];\n\n /**\n * Directories to be excluded from content processing\n *\n * Default: ['node_modules', '.intlayer']\n *\n * A list of directories to exclude from content processing.\n */\n excludedPath: string[];\n\n /**\n * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.\n *\n * Default: process.env.NODE_ENV === 'development'\n */\n watch: boolean;\n\n /**\n * Command to format the content. When intlayer write your .content files locally, this command will be used to format the content.\n *\n * Example:\n *\n * ```bash\n * npx prettier --write {{file}}\n * ```\n *\n * ```bash\n * bunx biome format {{file}}\n * ```\n *\n * ```bash\n * bun format {{file}}\n * ```\n *\n * ```bash\n * npx eslint --fix {{file}}\n * ```\n *\n * Intlayer will replace the {{file}} with the path of the file to format.\n *\n * Default: undefined\n */\n formatCommand: string | undefined;\n};\n\nexport type SystemConfig = {\n /**\n * Absolute path of the project's base directory\n *\n * Default: process.cwd()\n *\n * The root directory of the project, typically used for resolving other paths.\n */\n baseDir: string;\n\n /**\n * Directory for module augmentation, relative to the base directory\n *\n * Default: .intlayer/types\n *\n * Defines the derived path for module augmentation.\n */\n moduleAugmentationDir: string;\n\n /**\n * Directory where unmerged dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/unmerged_dictionary\n *\n * Specifies the derived path for unmerged dictionaries relative to the result directory.\n */\n unmergedDictionariesDir: string;\n\n /**\n * Directory where remote dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/remote_dictionary\n *\n * Specifies the derived path for remote dictionaries relative to the result directory.\n */\n remoteDictionariesDir: string;\n\n /**\n * Directory where final dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Specifies the derived path for dictionaries relative to the result directory.\n */\n dictionariesDir: string;\n\n /**\n * Directory where dynamic dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dynamic_dictionary\n *\n * Specifies the derived path for dynamic dictionaries relative to the result directory.\n */\n dynamicDictionariesDir: string;\n\n /**\n * Directory where fetch dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/fetch_dictionary\n *\n * Specifies the derived path for fetch dictionaries relative to the result directory.\n */\n fetchDictionariesDir: string;\n\n /**\n * Directory where dictionary types are stored, relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Specifies the derived path for dictionary types relative to the result directory.\n */\n typesDir: string;\n\n /**\n * Directory where the main files are stored, relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Specifies the derived path for the main files relative to the result directory.\n */\n mainDir: string;\n\n /**\n * Directory where the configuration files are stored, relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Specifies the derived path for the configuration files relative to the result directory.\n */\n configDir: string;\n\n /**\n * Directory where the cache files are stored, relative to the result directory\n *\n * Default: .intlayer/cache\n *\n * Specifies the derived path for the cache files relative to the result directory.\n */\n cacheDir: string;\n\n /**\n * Directory where the temp files are stored, relative to the result directory\n *\n * Default: .intlayer/tmp\n *\n * Specifies the derived path for the tmp files relative to the result directory.\n */\n tempDir: string;\n};\n\nexport type LogFunctions = {\n error?: typeof console.error;\n log?: typeof console.log;\n info?: typeof console.info;\n warn?: typeof console.warn;\n};\n\nexport type LogConfig = {\n /**\n * Indicates if the logger is enabled\n *\n * Default: true\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: 'default' | 'verbose' | 'disabled';\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: string;\n\n /**\n * Functions to log\n */\n error?: typeof console.error;\n log?: typeof console.log;\n info?: typeof console.info;\n warn?: typeof console.warn;\n debug?: typeof console.debug;\n};\n"],"mappings":";AA4dA,IAAY,cAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;KACD"}
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../../src/config.ts"],"sourcesContent":["import type { Locale } from './allLocales';\nimport type {\n ContentAutoTransformation,\n DictionaryFormat,\n DictionaryLocation,\n Fill,\n} from './dictionary';\nimport type { LocalesValues, StrictModeLocaleMap } from './module_augmentation';\nimport type { Plugin } from './plugin';\n\n/**\n * Structural type for schema validation, compatible with Zod and other\n * schema libraries that implement safeParse. Avoids a hard dependency on Zod.\n */\nexport type ConfigSchema = {\n safeParse(data: unknown): {\n success: boolean;\n data?: unknown;\n error?: unknown;\n };\n};\n\nexport type StrictMode = 'strict' | 'inclusive' | 'loose';\n\ntype Protocol = 'http' | 'https';\n\ntype URLPath = `/${string}`;\n\ntype OptionalURLPath = `/${string}` | '';\n\n// Localhost: STRICTLY requires a port\ntype LocalhostURL = `${Protocol}://localhost:${number}${OptionalURLPath}`;\n// IP Address: Start with number, allows optional port\n// (Heuristic: Starts with a number, contains dots)\ntype IPUrl =\n | `${Protocol}://${number}.${string}${OptionalURLPath}`\n | `${Protocol}://${number}.${string}:${number}${OptionalURLPath}`;\n\n// Standard Domain: Requires at least one dot to rule out plain \"localhost\"\n// (Heuristic: starts with non-number string, contains dot)\ntype DomainURL = `${Protocol}://${string}.${string}${OptionalURLPath}`;\n\nexport type URLType = LocalhostURL | IPUrl | DomainURL | (string & {});\n\n/**\n * Configuration for internationalization settings\n */\nexport type InternationalizationConfig = {\n /**\n * Locales available in the application\n *\n * Default: [Locales.ENGLISH]\n *\n * You can define a list of available locales to support in the application.\n */\n locales: Locale[];\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: Locale[];\n\n /**\n * Ensure strong implementations of internationalized content using typescript.\n * - If set to \"strict\", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.\n * - If set to \"inclusive\", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.\n * - If set to \"loose\", the translation `t` function will accept any existing locale.\n *\n * Default: \"inclusive\"\n */\n strictMode: StrictMode;\n\n /**\n * Default locale of the application for fallback\n *\n * Default: Locales.ENGLISH\n *\n * Used to specify a fallback locale in case no other locale is set.\n */\n defaultLocale: Locale;\n};\n\nexport type CookiesAttributes = {\n /**\n * Type of the storage\n *\n * The type of the storage. It can be 'cookie'.\n */\n type: 'cookie';\n /**\n * Cookie name to store the locale information\n *\n * Default: 'INTLAYER_LOCALE'\n *\n * The cookie key where the locale information is stored.\n */\n name?: string;\n /**\n * Cookie domain to store the locale information\n *\n * Default: undefined\n *\n * Define the domain where the cookie is available. Defaults to\n * the domain of the page where the cookie was created.\n */\n domain?: string;\n /**\n * Cookie path to store the locale information\n *\n * Default: undefined\n *\n * Define the path where the cookie is available. Defaults to '/'\n */\n path?: string;\n /**\n * Cookie secure to store the locale information\n *\n * Default: undefined\n *\n * A Boolean indicating if the cookie transmission requires a\n * secure protocol (https). Defaults to false.\n */\n secure?: boolean;\n /**\n * Cookie httpOnly to store the locale information\n *\n * Default: undefined\n *\n * The cookie httpOnly where the locale information is stored.\n */\n httpOnly?: boolean;\n /**\n * Cookie sameSite to store the locale information\n *\n * Default: undefined\n *\n * Asserts that a cookie must not be sent with cross-origin requests,\n * providing some protection against cross-site request forgery\n * attacks (CSRF)\n */\n sameSite?: 'strict' | 'lax' | 'none';\n\n /**\n * Cookie expires to store the locale information\n *\n * Default: undefined\n *\n * Define when the cookie will be removed:\n * - a `number` is interpreted as **days from the time of creation**;\n * - a `Date` instance (or an ISO date string, e.g. produced when the\n * configuration is serialized) is interpreted as an **absolute moment**.\n *\n * If omitted, the cookie becomes a session cookie. When `maxAge` is set it\n * takes precedence over `expires`.\n */\n expires?: Date | number | string | undefined;\n /**\n * Cookie max-age to store the locale information\n *\n * Default: undefined\n *\n * Define the cookie lifetime in seconds from the time of creation\n * (e.g. `60 * 60 * 24 * 365` for one year). Takes precedence over\n * `expires` when both are set.\n */\n maxAge?: number;\n};\n\nexport type StorageAttributes = {\n /**\n * Storage type where the locale is stored\n *\n * Determines whether the locale is persisted in `localStorage` (across sessions)\n * or `sessionStorage` (cleared when the browser session ends) or `header` (from the request header).\n */\n type: 'localStorage' | 'sessionStorage' | 'header';\n\n /**\n * Storage key to store the locale information\n *\n * Default: 'INTLAYER_LOCALE'\n *\n * The key name used in the client storage to save the locale.\n */\n name?: string;\n};\n\n/**\n * Cookie attributes after the config-build normalization step.\n *\n * The user-facing `expires` (days / `Date` / ISO string) and `maxAge` (seconds)\n * are merged into a single, serialization-safe `expires` field so the client\n * runtime stays minimal:\n * - `number` → seconds from cookie creation (relative);\n * - `string` → an absolute expiry as an ISO date string.\n */\nexport type ProcessedCookieAttributes = {\n domain?: string;\n path?: string;\n secure?: boolean;\n httpOnly?: boolean;\n sameSite?: 'strict' | 'lax' | 'none';\n expires?: number | string;\n};\n\n/**\n * Pre-computed storage attributes derived from `RoutingConfig.storage`.\n * Computed at config-build time to avoid repeated processing at runtime.\n */\nexport type ProcessedStorageAttributes = {\n cookies?: {\n name: string;\n attributes: ProcessedCookieAttributes;\n }[];\n localStorage?: {\n name: string;\n }[];\n sessionStorage?: {\n name: string;\n }[];\n headers?: {\n name: string;\n }[];\n};\n\nexport type RewriteRule<T extends string = string> = {\n canonical: T;\n localized: StrictModeLocaleMap<string>;\n};\n\nexport type RewriteRules = {\n rules: RewriteRule[];\n};\n\nexport type RewriteObject = {\n /**\n * Used for client-side URL generation (e.g., getLocalizedUrl).\n * Patterns are usually stripped of locale prefixes as the core logic handles prefixing.\n */\n url: RewriteRules;\n /**\n * Used for Next.js middleware / proxy.\n * Patterns usually include [locale] or :locale to match incoming full URLs.\n */\n nextjs?: RewriteRules;\n /**\n * Used for Vite proxy middleware.\n */\n vite?: RewriteRules;\n};\n\n/**\n * Configuration for routing behaviors\n */\nexport type RoutingConfig = {\n /**\n * Rewrite the URLs to a localized path\n *\n * Example:\n * ```ts\n * // ...\n * routing: {\n * rewrite: nextjsRewrite({\n * '[locale]/about': {\n * fr: '[locale]/a-propos'\n * }\n * })\n * }\n * ```\n */\n rewrite?: Record<URLPath, StrictModeLocaleMap<URLPath>> | RewriteObject;\n\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\n * - 'prefix-all': Prefix all locales including the default locale\n * - 'no-prefix': No locale prefixing in URLs\n * - 'search-params': Use search parameters for locale handling\n *\n * Examples with defaultLocale = 'en':\n * - 'prefix-no-default': /dashboard (en) or /fr/dashboard (fr)\n * - 'prefix-all': /en/dashboard (en) or /fr/dashboard (fr)\n * - 'no-prefix': /dashboard (locale handled via other means)\n * - 'search-params': /dashboard?locale=fr\n *\n * Note: This setting do not impact the cookie, or locale storage management.\n *\n * Default: 'prefix-no-default'\n */\n mode: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n\n /**\n * Pre-computed storage attributes derived from the raw `storage` input.\n * Populated at config-build time by `getStorageAttributes(rawStorage)`.\n * Use this at runtime instead of re-processing the raw storage config.\n */\n storage: ProcessedStorageAttributes;\n\n /**\n * Base path for application URLs\n *\n * Default: ''\n *\n * Defines the base path where the application is accessible from.\n */\n basePath?: string;\n\n /**\n * Maps locales to specific domain hostnames for domain-based routing.\n * When a locale is mapped to a domain, URLs generated for that locale\n * will use that domain as the base URL (absolute URL), and no locale\n * prefix will be added to the path (the domain itself implies the locale).\n *\n * Default: undefined\n *\n * Example:\n * ```ts\n * domains: {\n * en: 'intlayer.org',\n * zh: 'intlayer.cn',\n * }\n * ```\n */\n domains?: Partial<Record<LocalesValues, string>>;\n};\n\n/**\n * Raw storage input accepted in the user-facing config (`intlayer.config.ts`).\n * Converted to {@link ProcessedStorageAttributes} during config build.\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.\n *\n * Default: ['cookie', 'header]\n *\n * Note: Check out GDPR compliance for cookies. See https://gdpr.eu/cookies/\n * Note: useLocale hook includes a prop to disable the cookie storage.\n * Note: Even if storage is disabled, the middleware will still detect the locale from the request header (1- check for `x-intlayer-locale`, 2- fallback to the `accept-language`).\n *\n * Recommendation:\n * - Config both localStorage and cookies for the storage of the locale if you want to support GDPR compliance.\n * - Disable the cookie storage by default on the useLocale hook by waiting for the user to consent to the cookie storage.\n */\nexport type RoutingStorageInput =\n | false\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes\n | (\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes\n )[];\n\n/**\n * User-facing routing configuration (accepted in `intlayer.config.ts`).\n */\nexport type CustomRoutingConfig = Omit<RoutingConfig, 'storage'> & {\n storage?: RoutingStorageInput;\n};\n\n/**\n * Configuration for intlayer editor\n */\nexport type EditorConfig = {\n /**\n * URL of the application. Used to restrict the origin of the editor for security reasons.\n *\n * Default: ''\n */\n applicationURL?: URLType;\n\n /**\n * Public URL for the editor.\n * Default: \"http://localhost:8000\"\n */\n editorURL?: URLType;\n\n /**\n * Intlayer CMS URL.\n * Default: \"https://app.intlayer.org\"\n */\n cmsURL?: URLType;\n\n /**\n * Backend API URL.\n * Default: \"https://back.intlayer.org\"\n */\n backendURL?: URLType;\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: false;\n *\n * If true, the editor will be able to interact with the application.\n * If false, the editor will not be able to interact with the application.\n * In any case, the editor can only be enabled by the visual editor.\n * Disabling the editor for specific environments is a way to enforce the security.\n *\n * Usage:\n * ```js\n * {\n * // Other configurations\n * editor: {\n * enabled: process.env.NODE_ENV !== 'production',\n * }\n * };\n * ```\n *\n */\n enabled: boolean;\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: number;\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://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?: string;\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://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?: string;\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy: 'local_first' | 'distant_first';\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * Default: true\n */\n liveSync: boolean;\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: number;\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${liveSyncPort}`\n */\n liveSyncURL: URLType;\n};\n\nexport enum AiProviders {\n OPENAI = 'openai',\n ANTHROPIC = 'anthropic',\n MISTRAL = 'mistral',\n DEEPSEEK = 'deepseek',\n GEMINI = 'gemini',\n OLLAMA = 'ollama',\n OPENROUTER = 'openrouter',\n ALIBABA = 'alibaba',\n FIREWORKS = 'fireworks',\n GROQ = 'groq',\n HUGGINGFACE = 'huggingface',\n BEDROCK = 'bedrock',\n GOOGLEVERTEX = 'googlevertex',\n GOOGLEGENERATIVEAI = 'googlegenerativeai',\n TOGETHERAI = 'togetherai',\n LMSTUDIO = 'lmstudio',\n}\n\nexport type CommonAiConfig = {\n /**\n * API model\n *\n * The model to use for the AI features of Intlayer.\n *\n * Example: 'gpt-4o-2024-11-20'\n *\n */\n model?: string;\n\n /**\n * temperature\n *\n * The temperature to use for the AI features of Intlayer.\n * The temperature controls the randomness of the AI's responses.\n * A higher temperature will make the AI more creative and less predictable.\n *\n * Example: 0.1\n */\n temperature?: number;\n\n /**\n * API key\n *\n * Use your own OpenAI API key to use the AI features of Intlayer.\n * If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.\n *\n */\n apiKey?: string;\n\n /**\n * Application context\n *\n * The context of the application to use for the AI features of Intlayer.\n *\n * Example: 'This is a website for a company that sells products online.'\n */\n applicationContext?: string;\n\n /**\n * Base URL\n *\n * The base URL to use for the AI features of Intlayer.\n *\n * Example: 'https://api.openai.com/v1'\n */\n baseURL?: string;\n\n /**\n * Data serialization\n *\n * The data serialization format to use for the AI features of Intlayer.\n *\n * Default: 'json'\n */\n dataSerialization?: 'json' | 'toon';\n};\n\nexport type AiProviderConfigMap = {};\n\ntype AiConfigUnion = {\n [P in keyof AiProviderConfigMap]: {\n provider: P | `${P}`;\n } & AiProviderConfigMap[P];\n}[keyof AiProviderConfigMap];\n\nexport type AiConfig = CommonAiConfig &\n (AiConfigUnion | { provider?: AiProviders | `${AiProviders}` });\n\nexport type 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: 'auto' | 'manual';\n\n /**\n * Indicates if the build should be optimized\n *\n * Default: undefined\n *\n * If true, the build will be optimized.\n * If false, the build will not be optimized.\n *\n * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.\n * All imports will stay as static import to avoid async processing when loading the dictionaries.\n *\n * Note:\n * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.\n * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize?: boolean;\n\n /**\n * Indicates the mode of import to use for the dictionaries.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * - \"fetch\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Fetch mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as \"dynamic\" mode.\n *\n * Default: \"static\"\n *\n * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.\n *\n * Note:\n * - Dynamic imports rely on Suspense and may slightly impact rendering performance.\n * - If desabled all locales will be loaded at once, even if they are not used.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n * - This option will be ignored if `optimize` is disabled.\n * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.\n * - The \"fetch\" allows to sync the dictionaries to the live sync server.\n * - Require static key to work. Example of invalid code: `const navbarKey = \"my-key\"; useIntlayer(navbarKey)`.\n *\n * @deprecated Use `dictionary.importMode` instead.\n */\n importMode?: 'static' | 'dynamic' | 'fetch';\n\n /**\n * Minify the dictionaries to reduce the bundle size.\n *\n * Default: false\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - This option will be ignore if `editor.enabled` is true.\n * - If there is edge cases where the minification is not working properly, the dictionary will be not minified.\n */\n minify: boolean;\n\n /**\n * Purge the unused keys in a dictionaries\n *\n * Default: false\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n */\n purge: boolean;\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}', '!**\\/node_modules/**']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: string[];\n\n /**\n * Output format of the dictionaries\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'. Even if dictionaries are written in JSON, entry point to access the dictionaries are generated.\n * This function will use the output format defined using this option.\n * The default format is 'cjs' as it allows better interoperability with other libraries, scripts, and applications. But some build tools, such as Vite, require ES modules.\n */\n outputFormat: ('cjs' | 'esm')[];\n\n /**\n * Indicates if the cache should be enabled\n *\n * Default: true\n *\n * If true, the cache will be enabled.\n * If false, the cache will not be enabled.\n */\n cache: boolean;\n\n /**\n * Require function\n *\n * In some environments, as VSCode extension, the require function should be set relatively to the project root to work properly.\n *\n * Default: undefined\n *\n * If undefined, the require function will be set to the default require function.\n * If defined, the require function will be set to the defined require function.\n *\n * Example:\n * ```js\n * {\n * require: require\n * }\n * ```\n */\n require?: NodeJS.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: boolean;\n};\n\nexport type CompilerConfig = {\n /**\n * Indicates if the compiler should be enabled.\n * If 'build-only', the compiler will be skipped during development mode to speed up start times.\n */\n enabled: boolean | 'build-only';\n\n /**\n * Prefix for the extracted dictionary keys.\n * Default: ''\n */\n dictionaryKeyPrefix?: string;\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: ['**\\/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}', '!**\\/node_modules/**']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n *\n * @deprecated use build.traversePattern instead\n */\n transformPattern?: string | string[];\n\n /**\n * Pattern to exclude from the optimization.\n *\n * Allows to exclude files from the optimization.\n *\n * Default: ['**\\/node_modules/**']\n *\n * Example: `['**\\/node_modules/**', '!**\\/node_modules/react/**']`\n *\n * @deprecated use build.traversePattern instead\n */\n excludePattern?: string | string[];\n\n /**\n * Defines the output files path. Replaces `outputDir`.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.\n *\n * Example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * output: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // output: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create per-locale JSON files with locale-specific output paths\n * output: {\n * en: ({ fileName, locale }) => `${fileName}.${locale}.content.json`,\n * fr: '{{fileName}}.{{locale}}.content.json',\n * es: false, // skip this locale\n * },\n * }\n * ```\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n output?: Fill;\n\n /**\n * Indicates if the metadata should be saved in the file.\n *\n * If true, the compiler will not save the metadata of the dictionaries.\n *\n * If true:\n *\n * ```json\n * {\n * \"key\": \"value\"\n * }\n * ```\n *\n * If false:\n *\n * ```json\n * {\n * \"key\": \"value\",\n * \"content\": {\n * \"key\": \"value\"\n * }\n * }\n * ```\n *\n * Default: false\n *\n * Note: Useful if used with loadJSON plugin\n *\n */\n noMetadata?: boolean;\n\n /**\n * Indicates if the components should be saved after being transformed.\n *\n * If true, the compiler will replace the original files with the transformed files.\n * That way, the compiler can be run only once to transform the app, and then it can be removed.\n *\n * Default: false\n */\n saveComponents: boolean;\n};\n\n/**\n * Custom configuration that can be provided to override default settings\n */\nexport type CustomIntlayerConfig = {\n /**\n * Custom internationalization configuration\n */\n internationalization?: Partial<InternationalizationConfig>;\n\n /**\n * Custom dictionary configuration\n */\n dictionary?: Partial<DictionaryConfig>;\n\n /**\n * Custom routing configuration\n */\n routing?: Partial<CustomRoutingConfig>;\n\n /**\n * Custom content configuration\n */\n content?: Partial<ContentConfig>;\n\n /**\n * Custom editor configuration\n */\n editor?: Partial<EditorConfig>;\n\n /**\n * Custom log configuration\n */\n log?: Partial<LogConfig>;\n\n /**\n * Custom AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Custom build configuration\n */\n build?: Partial<BuildConfig>;\n\n /**\n * Custom compiler configuration\n */\n compiler?: Partial<CompilerConfig>;\n\n /**\n * Custom system configuration\n */\n system?: Partial<SystemConfig>;\n\n /**\n * Custom schemas to validate the dictionaries content.\n *\n * Example:\n * ```ts\n * {\n * schemas: {\n * 'my-schema': z.object({\n * title: z.string(),\n * description: z.string(),\n * }),\n * }\n * }\n * ```\n */\n schemas?: Record<string, ConfigSchema>;\n\n /**\n * Custom plugins configuration\n */\n plugins?: (Plugin | Promise<Plugin>)[];\n};\n\nexport type DictionaryConfig = {\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: `true`\n *\n * - If `true`, will consider the `compiler.output` field.\n * - If `false`, will skip the fill process.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - If includes `{{locale}}` variable in the path, will trigger the generation of separate dictionaries per locale.\n *\n * Example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * fill: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // fill: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * fill: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // fill: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create custom output based on the locale\n * fill: {\n * en: ({ key }) => `/locales/en/${key}.content.json`,\n * fr: '/locales/fr/{{key}}.content.json',\n * es: false,\n * de: true,\n * },\n * }\n * ```\n *\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n fill?: Fill;\n /**\n * The description of the dictionary. Helps to understand the purpose of the dictionary in the editor, and the CMS.\n * The description is also used as context for translations generation.\n *\n * Example:\n * ```ts\n * {\n * \"key\": \"about-page-meta\",\n * \"description\":[\n * \"This dictionary is manage the metadata of the About Page\",\n * \"Consider good practices for SEO:\",\n * \"- The title should be between 50 and 60 characters\",\n * \"- The description should be between 150 and 160 characters\",\n * ].join('\\n'),\n * \"content\": { ... }\n * }\n * ```\n */\n description?: string;\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 * If declared, do not use translation nodes in the content.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"locale\": \"en\",\n * \"content\": {\n * \"multilingualContent\": \"English content\"\n * }\n * }\n * ```\n */\n locale?: LocalesValues;\n /**\n * Indicators if the content of the dictionary should be automatically transformed.\n * If true, the content will be transformed to the corresponding node type.\n * - Markdown: `### Title` -> `md('### Title')`\n * - HTML: `<div>Title</div>` -> `html('<div>Title</div>')`\n * - Insertion: `Hello {{name}}` -> `insert('Hello {{name}}')`\n *\n * If an object is provided, you can specify which transformations should be enabled.\n *\n * Default: false\n */\n contentAutoTransformation?: ContentAutoTransformation;\n /**\n * Indicates the priority of the dictionary.\n * In the case of conflicts, the dictionary with the highest priority will override the other dictionaries.\n */\n priority?: number;\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 * - \"fetch\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Fetch 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 \"fetch\" allows to sync the dictionaries to the live sync server.\n * - Require static key to work. Example of invalid code: `const navbarKey = \"my-key\"; useIntlayer(navbarKey)`.\n */\n importMode?: 'static' | 'dynamic' | 'fetch';\n /**\n * The title of the dictionary. Helps to identify the dictionary in the editor, and the CMS.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page-meta\",\n * \"title\": \"About Page\",\n * \"content\": { ... }\n * }\n * ```\n */\n title?: string;\n /**\n * Helps to categorize the dictionaries. The tags can provide more context and instructions for the dictionary.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page-meta\",\n * \"tags\": [\"metadata\",\"about-page\"]\n * }\n * ```\n */\n tags?: string[];\n /**\n * Indicates the location of the dictionary and controls how it synchronizes with the CMS.\n *\n * - 'hybrid': The dictionary is managed locally and remotely. Once pushed on the CMS, it will be synchronized from the local one. The local dictionary will be pulled from the CMS.\n * - 'remote': The dictionary is managed remotely only. Once pushed on the CMS, it will be detached from the local one. At content load time, the remote dictionary will be pulled from the CMS. A '.content' file with remote location will be ignored.\n * - 'local': The dictionary is managed locally. It will not be pushed to the remote CMS.\n * - 'plugin' (or any custom string): The dictionary is managed by a plugin, or a custom source. When you will try to push it, the system will ask an action to the user.\n */\n location?: DictionaryLocation;\n\n /**\n * The default message format for all dictionaries in the project.\n *\n * Controls how dictionary content strings are interpreted at runtime.\n *\n * - 'intlayer': Native intlayer format (default).\n * - 'icu': ICU message format (used by next-intl, react-intl, etc.).\n * - 'i18next': i18next interpolation format (used by i18next, react-i18next, next-i18next).\n * - 'vue-i18n': Vue I18n format (used by vue-i18n).\n * - 'po': GNU Gettext PO format.\n *\n * Default: 'intlayer'\n */\n format?: DictionaryFormat;\n};\n\n/**\n * Combined configuration for internationalization, middleware, and content\n */\nexport type IntlayerConfig = {\n /**\n * Internationalization configuration\n */\n internationalization: InternationalizationConfig;\n\n /**\n * Default dictionary configuration\n */\n dictionary?: Partial<DictionaryConfig>;\n\n /**\n * Routing configuration\n */\n routing: RoutingConfig;\n\n /**\n * Content configuration\n */\n content: ContentConfig;\n\n /**\n * System configuration\n */\n system: SystemConfig;\n\n /**\n * Intlayer editor configuration\n */\n editor: EditorConfig;\n\n /**\n * Logger configuration\n */\n log: LogConfig;\n\n /**\n * AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Build configuration\n */\n build: BuildConfig;\n\n /**\n * Compiler configuration\n */\n compiler: CompilerConfig;\n\n /**\n * Custom schemas to validate the dictionaries content.\n */\n schemas?: Record<string, ConfigSchema>;\n\n /**\n * Plugins configuration\n */\n plugins?: Plugin[];\n};\n\n/**\n * Configuration for content handling\n */\nexport type ContentConfig = {\n /**\n * File extensions of content to look for\n *\n * Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * List of file extensions to scan for content.\n */\n fileExtensions: string[];\n\n /**\n * Directory where the content is stored, relative to the base directory\n *\n * Default: ['.']\n *\n * Derived content directory based on the base configuration.\n *\n * Note: This is used to watch for content files.\n */\n contentDir: string[];\n\n /**\n * Directory where the code is stored, relative to the base directory\n *\n * Default: ['.']\n *\n * Derived code directory based on the base configuration.\n *\n * Note: This is used to watch for code files to transform.\n */\n codeDir: string[];\n\n /**\n * Directories to be excluded from content processing\n *\n * Default: ['node_modules', '.intlayer']\n *\n * A list of directories to exclude from content processing.\n */\n excludedPath: string[];\n\n /**\n * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.\n *\n * Default: process.env.NODE_ENV === 'development'\n */\n watch: boolean;\n\n /**\n * Command to format the content. When intlayer write your .content files locally, this command will be used to format the content.\n *\n * Example:\n *\n * ```bash\n * npx prettier --write {{file}}\n * ```\n *\n * ```bash\n * bunx biome format {{file}}\n * ```\n *\n * ```bash\n * bun format {{file}}\n * ```\n *\n * ```bash\n * npx eslint --fix {{file}}\n * ```\n *\n * Intlayer will replace the {{file}} with the path of the file to format.\n *\n * Default: undefined\n */\n formatCommand: string | undefined;\n};\n\nexport type SystemConfig = {\n /**\n * Absolute path of the project's base directory\n *\n * Default: process.cwd()\n *\n * The root directory of the project, typically used for resolving other paths.\n */\n baseDir: string;\n\n /**\n * Directory for module augmentation, relative to the base directory\n *\n * Default: .intlayer/types\n *\n * Defines the derived path for module augmentation.\n */\n moduleAugmentationDir: string;\n\n /**\n * Directory where unmerged dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/unmerged_dictionary\n *\n * Specifies the derived path for unmerged dictionaries relative to the result directory.\n */\n unmergedDictionariesDir: string;\n\n /**\n * Directory where remote dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/remote_dictionary\n *\n * Specifies the derived path for remote dictionaries relative to the result directory.\n */\n remoteDictionariesDir: string;\n\n /**\n * Directory where final dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Specifies the derived path for dictionaries relative to the result directory.\n */\n dictionariesDir: string;\n\n /**\n * Directory where dynamic dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dynamic_dictionary\n *\n * Specifies the derived path for dynamic dictionaries relative to the result directory.\n */\n dynamicDictionariesDir: string;\n\n /**\n * Directory where fetch dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/fetch_dictionary\n *\n * Specifies the derived path for fetch dictionaries relative to the result directory.\n */\n fetchDictionariesDir: string;\n\n /**\n * Directory where dictionary types are stored, relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Specifies the derived path for dictionary types relative to the result directory.\n */\n typesDir: string;\n\n /**\n * Directory where the main files are stored, relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Specifies the derived path for the main files relative to the result directory.\n */\n mainDir: string;\n\n /**\n * Directory where the configuration files are stored, relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Specifies the derived path for the configuration files relative to the result directory.\n */\n configDir: string;\n\n /**\n * Directory where the cache files are stored, relative to the result directory\n *\n * Default: .intlayer/cache\n *\n * Specifies the derived path for the cache files relative to the result directory.\n */\n cacheDir: string;\n\n /**\n * Directory where the temp files are stored, relative to the result directory\n *\n * Default: .intlayer/tmp\n *\n * Specifies the derived path for the tmp files relative to the result directory.\n */\n tempDir: string;\n};\n\nexport type LogFunctions = {\n error?: typeof console.error;\n log?: typeof console.log;\n info?: typeof console.info;\n warn?: typeof console.warn;\n};\n\nexport type LogConfig = {\n /**\n * Indicates if the logger is enabled\n *\n * Default: true\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: 'default' | 'verbose' | 'disabled';\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: string;\n\n /**\n * Functions to log\n */\n error?: typeof console.error;\n log?: typeof console.log;\n info?: typeof console.info;\n warn?: typeof console.warn;\n debug?: typeof console.debug;\n};\n"],"mappings":";AA4eA,IAAY,cAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;KACD"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Locale } from "./allLocales.js";
|
|
2
2
|
import { LocalesValues, StrictModeLocaleMap } from "./module_augmentation.js";
|
|
3
|
-
import { ContentAutoTransformation, DictionaryLocation, Fill } from "./dictionary.js";
|
|
3
|
+
import { ContentAutoTransformation, DictionaryFormat, DictionaryLocation, Fill } from "./dictionary.js";
|
|
4
4
|
import { Plugin } from "./plugin.js";
|
|
5
5
|
|
|
6
6
|
//#region src/config.d.ts
|
|
@@ -331,8 +331,20 @@ type EditorConfig = {
|
|
|
331
331
|
* Default: ''
|
|
332
332
|
*/
|
|
333
333
|
applicationURL?: URLType;
|
|
334
|
+
/**
|
|
335
|
+
* Public URL for the editor.
|
|
336
|
+
* Default: "http://localhost:8000"
|
|
337
|
+
*/
|
|
334
338
|
editorURL?: URLType;
|
|
339
|
+
/**
|
|
340
|
+
* Intlayer CMS URL.
|
|
341
|
+
* Default: "https://app.intlayer.org"
|
|
342
|
+
*/
|
|
335
343
|
cmsURL?: URLType;
|
|
344
|
+
/**
|
|
345
|
+
* Backend API URL.
|
|
346
|
+
* Default: "https://back.intlayer.org"
|
|
347
|
+
*/
|
|
336
348
|
backendURL?: URLType;
|
|
337
349
|
/**
|
|
338
350
|
* Indicates if the application interact with the visual editor
|
|
@@ -999,6 +1011,20 @@ type DictionaryConfig = {
|
|
|
999
1011
|
* - 'plugin' (or any custom string): The dictionary is managed by a plugin, or a custom source. When you will try to push it, the system will ask an action to the user.
|
|
1000
1012
|
*/
|
|
1001
1013
|
location?: DictionaryLocation;
|
|
1014
|
+
/**
|
|
1015
|
+
* The default message format for all dictionaries in the project.
|
|
1016
|
+
*
|
|
1017
|
+
* Controls how dictionary content strings are interpreted at runtime.
|
|
1018
|
+
*
|
|
1019
|
+
* - 'intlayer': Native intlayer format (default).
|
|
1020
|
+
* - 'icu': ICU message format (used by next-intl, react-intl, etc.).
|
|
1021
|
+
* - 'i18next': i18next interpolation format (used by i18next, react-i18next, next-i18next).
|
|
1022
|
+
* - 'vue-i18n': Vue I18n format (used by vue-i18n).
|
|
1023
|
+
* - 'po': GNU Gettext PO format.
|
|
1024
|
+
*
|
|
1025
|
+
* Default: 'intlayer'
|
|
1026
|
+
*/
|
|
1027
|
+
format?: DictionaryFormat;
|
|
1002
1028
|
};
|
|
1003
1029
|
/**
|
|
1004
1030
|
* Combined configuration for internationalization, middleware, and content
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","names":[],"sources":["../../src/config.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"config.d.ts","names":[],"sources":["../../src/config.ts"],"mappings":";;;;;;;;AAcA;;KAAY,YAAA;EACV,SAAA,CAAU,IAAA;IACR,OAAA;IACA,IAAA;IACA,KAAA;EAAA;AAAA;AAAA,KAIQ,UAAA;AAAA,KAEP,QAAA;AAAA,KAEA,OAAA;AAAA,KAEA,eAAA;AAAA,KAGA,YAAA,MAAkB,QAAA,yBAAiC,eAAA;AAAA,KAGnD,KAAA,MACE,QAAA,yBAAiC,eAAA,QACjC,QAAA,mCAA2C,eAAA;AAAA,KAI7C,SAAA,MAAe,QAAA,yBAAiC,eAAA;AAAA,KAEzC,OAAA,G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ASA,SAAA;;;;;;;;EASA,QAAA;;;;;;;;EASA,OAAA;AAAA;AAAA,KAGU,YAAA;EACV,KAAA,UAAe,OAAA,CAAQ,KAAA;EACvB,GAAA,UAAa,OAAA,CAAQ,GAAA;EACrB,IAAA,UAAc,OAAA,CAAQ,IAAA;EACtB,IAAA,UAAc,OAAA,CAAQ,IAAA;AAAA;AAAA,KAGZ,SAAA;;;;;;;;;;EAUV,IAAA;;;;;;;;EASA,MAAA;;;;EAKA,KAAA,UAAe,OAAA,CAAQ,KAAA;EACvB,GAAA,UAAa,OAAA,CAAQ,GAAA;EACrB,IAAA,UAAc,OAAA,CAAQ,IAAA;EACtB,IAAA,UAAc,OAAA,CAAQ,IAAA;EACtB,KAAA,UAAe,OAAA,CAAQ,KAAA;AAAA"}
|
|
@@ -73,6 +73,204 @@ type ReplaceContentValue<NodeType, FetchableNode = true> = NodeType extends obje
|
|
|
73
73
|
type Fill = boolean | FilePathPattern | Partial<Record<DeclaredLocales, boolean | FilePathPattern>>;
|
|
74
74
|
type DictionaryId = string;
|
|
75
75
|
type DictionaryKey = string;
|
|
76
|
+
/**
|
|
77
|
+
* Meta record qualifier of a dictionary.
|
|
78
|
+
*
|
|
79
|
+
* The `id` field is the designated discriminator used to resolve the record at
|
|
80
|
+
* runtime (`useIntlayer('product-copy', { id: 'prod_abc', ... })`). All other
|
|
81
|
+
* fields are typed payload that must be provided by the selector to match.
|
|
82
|
+
*/
|
|
83
|
+
type DictionaryMeta = {
|
|
84
|
+
id: string | number;
|
|
85
|
+
} & Record<string, string | number>;
|
|
86
|
+
/**
|
|
87
|
+
* A dimension used to discriminate sibling dictionaries sharing the same key.
|
|
88
|
+
*
|
|
89
|
+
* - 'variant': named alternative content shapes (A/B testing, seasonal banners…)
|
|
90
|
+
* - 'meta': record-keyed content resolved by the `meta.id` discriminator
|
|
91
|
+
* - 'item': ordered collection items (blog posts, FAQs…)
|
|
92
|
+
*
|
|
93
|
+
* A key may declare SEVERAL dimensions at once (e.g. a collection whose items
|
|
94
|
+
* also have variants). They are always ordered canonically as
|
|
95
|
+
* `variant → meta → item`, with `item` as the innermost / collection axis.
|
|
96
|
+
*/
|
|
97
|
+
type DictionaryQualifierType = "variant" | "meta" | "item";
|
|
98
|
+
/**
|
|
99
|
+
* Output of the merge step for a key whose dictionaries declare one or more
|
|
100
|
+
* qualifier dimensions (`item`, `variant`, `meta`).
|
|
101
|
+
*
|
|
102
|
+
* Sibling dictionaries sharing the same qualifier coordinates are merged
|
|
103
|
+
* together (locale completion / priority overrides preserved). Sibling
|
|
104
|
+
* dictionaries without any qualifier act as shared base content merged into
|
|
105
|
+
* every entry as fallback.
|
|
106
|
+
*
|
|
107
|
+
* `content` is keyed by the composite id — the per-dimension ids joined in
|
|
108
|
+
* canonical order with `/` (e.g. `"promo/2"` for a variant × item key). Each
|
|
109
|
+
* value is the resolved content node directly: the qualifier coordinates are
|
|
110
|
+
* decoded from the composite id, not duplicated on a per-entry wrapper.
|
|
111
|
+
*
|
|
112
|
+
* Example (`.intlayer/dictionaries/faq.json`):
|
|
113
|
+
* ```json
|
|
114
|
+
* {
|
|
115
|
+
* "key": "faq",
|
|
116
|
+
* "qualifierTypes": ["item"],
|
|
117
|
+
* "content": {
|
|
118
|
+
* "1": { "nodeType": "translation", "translation": { ... } },
|
|
119
|
+
* "2": { "nodeType": "translation", "translation": { ... } }
|
|
120
|
+
* }
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
type QualifiedDictionaryGroup = {
|
|
125
|
+
$schema?: "https://intlayer.org/schema.json";
|
|
126
|
+
key: DictionaryKey;
|
|
127
|
+
qualifierTypes: DictionaryQualifierType[];
|
|
128
|
+
/**
|
|
129
|
+
* Maps each composite id to its resolved content node. Replaces the former
|
|
130
|
+
* per-entry `Dictionary` wrapper — coordinates live in the key, not the value.
|
|
131
|
+
*/
|
|
132
|
+
content: Record<string, unknown>;
|
|
133
|
+
/**
|
|
134
|
+
* Extra meta fields preserved per composite id, present only for groups that
|
|
135
|
+
* declare the `meta` dimension. The composite id only encodes `meta.id`, so
|
|
136
|
+
* the remaining declared meta fields are kept here for selector matching.
|
|
137
|
+
*/
|
|
138
|
+
meta?: Record<string, DictionaryMeta>; /** Import mode shared by the group (collected from its qualified entries). */
|
|
139
|
+
importMode?: ImportMode;
|
|
140
|
+
localIds?: LocalDictionaryId[];
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Selector accepted as second argument of `useIntlayer` / `getIntlayer` (and
|
|
144
|
+
* forwarded by the build-time transform to `useDictionary` / `getDictionary`).
|
|
145
|
+
*
|
|
146
|
+
* - `{ item: 2 }` selects a collection item (1-based index)
|
|
147
|
+
* - `{ variant: 'black-friday' }` selects a named variant
|
|
148
|
+
* - `{ id: 'prod_abc', ...metaFields }` selects a meta record; every meta field
|
|
149
|
+
* declared on the matching dictionary must be provided and equal
|
|
150
|
+
* - `locale` composes with any of the above and overrides the context locale
|
|
151
|
+
*
|
|
152
|
+
* The keys `locale`, `item` and `variant` are reserved and cannot be used as
|
|
153
|
+
* meta field names.
|
|
154
|
+
*/
|
|
155
|
+
type DictionarySelector = {
|
|
156
|
+
locale?: LocalesValues;
|
|
157
|
+
item?: number;
|
|
158
|
+
variant?: string;
|
|
159
|
+
} & Record<string, string | number | undefined>;
|
|
160
|
+
type QualifiedEntryContent<Entry> = Entry extends {
|
|
161
|
+
content: infer Content;
|
|
162
|
+
} ? Content : unknown;
|
|
163
|
+
/** Splits a composite id literal (`"a/b/c"`) into its ordered segments. */
|
|
164
|
+
type SplitCompositeId<Id extends string> = Id extends `${infer Head}/${infer Tail}` ? [Head, ...SplitCompositeId<Tail>] : [Id];
|
|
165
|
+
/**
|
|
166
|
+
* Zips the declared qualifier dimensions with the segments decoded from a
|
|
167
|
+
* composite id into a coordinate record (e.g. `['variant', 'item']` +
|
|
168
|
+
* `['promo', '2']` → `{ variant: 'promo'; item: '2' }`).
|
|
169
|
+
*/
|
|
170
|
+
type ZipQualifierCoordinates<QualifierTypes extends readonly DictionaryQualifierType[], Segments extends readonly string[]> = { [Index in keyof QualifierTypes as QualifierTypes[Index] extends DictionaryQualifierType ? QualifierTypes[Index] : never]: Index extends keyof Segments ? Segments[Index] : never };
|
|
171
|
+
/**
|
|
172
|
+
* Rebuilds the per-entry shape (`{ variant; item; meta; content }`) from the
|
|
173
|
+
* `content` map keyed by composite id, so the coordinate-comparison helpers can
|
|
174
|
+
* be reused unchanged. Coordinates are decoded from each key.
|
|
175
|
+
*/
|
|
176
|
+
type ReconstructedEntries<ContentMap, QualifierTypes extends readonly DictionaryQualifierType[]> = { [Key in keyof ContentMap & string]: ZipQualifierCoordinates<QualifierTypes, SplitCompositeId<Key>> extends infer Coordinates ? {
|
|
177
|
+
content: ContentMap[Key];
|
|
178
|
+
} & (Coordinates extends {
|
|
179
|
+
variant: infer V;
|
|
180
|
+
} ? {
|
|
181
|
+
variant: V;
|
|
182
|
+
} : unknown) & (Coordinates extends {
|
|
183
|
+
item: infer Item;
|
|
184
|
+
} ? {
|
|
185
|
+
item: Item;
|
|
186
|
+
} : unknown) & (Coordinates extends {
|
|
187
|
+
meta: infer Id;
|
|
188
|
+
} ? {
|
|
189
|
+
meta: {
|
|
190
|
+
id: Id;
|
|
191
|
+
};
|
|
192
|
+
} : unknown) : never };
|
|
193
|
+
/** Stringifies a literal coordinate for comparison. */
|
|
194
|
+
type StringifyCoordinate<Value> = Value extends string | number ? `${Value}` : never;
|
|
195
|
+
/** Literal equality between two coordinate values. */
|
|
196
|
+
type CoordinateEquals<Left, Right> = [StringifyCoordinate<Left>] extends [StringifyCoordinate<Right>] ? true : false;
|
|
197
|
+
/** The coordinate a selector pins for each dimension. */
|
|
198
|
+
type SelectorVariant<Selector> = Selector extends {
|
|
199
|
+
variant: infer Variant;
|
|
200
|
+
} ? Variant : "default";
|
|
201
|
+
type SelectorItem<Selector> = Selector extends {
|
|
202
|
+
item: infer Item;
|
|
203
|
+
} ? Item : undefined;
|
|
204
|
+
type SelectorMetaId<Selector> = Selector extends {
|
|
205
|
+
id: infer Id;
|
|
206
|
+
} ? Id : undefined;
|
|
207
|
+
/**
|
|
208
|
+
* Whether a single group entry matches the selector across every declared
|
|
209
|
+
* dimension. The `item` dimension matches any value when the selector leaves it
|
|
210
|
+
* open (collection axis).
|
|
211
|
+
*/
|
|
212
|
+
type EntryMatchesSelector<Entry, QualifierTypes extends readonly DictionaryQualifierType[], Selector> = ("variant" extends QualifierTypes[number] ? Entry extends {
|
|
213
|
+
variant: infer Variant;
|
|
214
|
+
} ? CoordinateEquals<Variant, SelectorVariant<Selector>> : false : true) extends true ? ("meta" extends QualifierTypes[number] ? Entry extends {
|
|
215
|
+
meta: {
|
|
216
|
+
id: infer Id;
|
|
217
|
+
};
|
|
218
|
+
} ? CoordinateEquals<Id, SelectorMetaId<Selector>> : false : true) extends true ? "item" extends QualifierTypes[number] ? [SelectorItem<Selector>] extends [undefined] ? true : Entry extends {
|
|
219
|
+
item: infer Item;
|
|
220
|
+
} ? CoordinateEquals<Item, SelectorItem<Selector>> : false : true : false : false;
|
|
221
|
+
/** Entries that match the selector. */
|
|
222
|
+
type MatchingEntries<Entries, QualifierTypes extends readonly DictionaryQualifierType[], Selector> = { [Key in keyof Entries as EntryMatchesSelector<Entries[Key], QualifierTypes, Selector> extends true ? Key : never]: Entries[Key] };
|
|
223
|
+
/** Whether the collection (`item`) axis is left open (→ array result). */
|
|
224
|
+
type IsItemAxisOpen<QualifierTypes extends readonly DictionaryQualifierType[], Selector> = "item" extends QualifierTypes[number] ? [SelectorItem<Selector>] extends [undefined] ? true : false : false;
|
|
225
|
+
/**
|
|
226
|
+
* Computes the content type returned by `getIntlayer` / `getDictionary` for a
|
|
227
|
+
* dictionary (or qualified dictionary group) `T` given the selector argument
|
|
228
|
+
* `Selector`.
|
|
229
|
+
*
|
|
230
|
+
* The result is resolved against the **specific** entries the selector targets
|
|
231
|
+
* (matched across variant / meta / item coordinates), never the union of every
|
|
232
|
+
* entry:
|
|
233
|
+
* - `item` left open → array of the matching entries' content
|
|
234
|
+
* - all dimensions pinned → that single entry's content (or `null` if none match)
|
|
235
|
+
* - plain dictionary → its `content` (selector ignored)
|
|
236
|
+
*/
|
|
237
|
+
type ResolveQualifiedDictionaryContent<T, Selector = undefined> = T extends {
|
|
238
|
+
qualifierTypes: infer QualifierTypes extends readonly DictionaryQualifierType[];
|
|
239
|
+
content: infer ContentMap extends Record<string, any>;
|
|
240
|
+
} ? ReconstructedEntries<ContentMap, QualifierTypes> extends infer Entries ? IsItemAxisOpen<QualifierTypes, Selector> extends true ? QualifiedEntryContent<MatchingEntries<Entries, QualifierTypes, Selector>[keyof MatchingEntries<Entries, QualifierTypes, Selector>]>[] : [keyof MatchingEntries<Entries, QualifierTypes, Selector>] extends [never] ? null : QualifiedEntryContent<MatchingEntries<Entries, QualifierTypes, Selector>[keyof MatchingEntries<Entries, QualifierTypes, Selector>]> : never : T extends {
|
|
241
|
+
content: infer Content;
|
|
242
|
+
} ? Content : never;
|
|
243
|
+
/** Distributes over the union of a group's entries. */
|
|
244
|
+
type GroupEntryUnion<T> = T extends {
|
|
245
|
+
qualifierTypes: infer QualifierTypes extends readonly DictionaryQualifierType[];
|
|
246
|
+
content: infer ContentMap;
|
|
247
|
+
} ? ReconstructedEntries<ContentMap, QualifierTypes>[keyof ReconstructedEntries<ContentMap, QualifierTypes>] : never;
|
|
248
|
+
type EntryVariant<Entry> = Entry extends {
|
|
249
|
+
variant: infer Variant;
|
|
250
|
+
} ? Variant : never;
|
|
251
|
+
type EntryItem<Entry> = Entry extends {
|
|
252
|
+
item: infer Item;
|
|
253
|
+
} ? Item : never;
|
|
254
|
+
type EntryMetaId<Entry> = Entry extends {
|
|
255
|
+
meta: {
|
|
256
|
+
id: infer Id;
|
|
257
|
+
};
|
|
258
|
+
} ? Id : never;
|
|
259
|
+
/**
|
|
260
|
+
* The selector accepted for a specific qualified dictionary group `T`: each
|
|
261
|
+
* dimension is constrained to the coordinates that actually exist, so an unknown
|
|
262
|
+
* `variant` / `item` / `id` is a compile-time error. Plain dictionaries (no
|
|
263
|
+
* `entries`) fall back to the loose {@link DictionarySelector}.
|
|
264
|
+
*/
|
|
265
|
+
type DictionarySelectorForGroup<T> = [GroupEntryUnion<T>] extends [never] ? DictionarySelector : {
|
|
266
|
+
locale?: LocalesValues;
|
|
267
|
+
} & ([EntryVariant<GroupEntryUnion<T>>] extends [never] ? unknown : {
|
|
268
|
+
variant?: EntryVariant<GroupEntryUnion<T>> | (string & {});
|
|
269
|
+
}) & ([EntryItem<GroupEntryUnion<T>>] extends [never] ? unknown : {
|
|
270
|
+
item?: EntryItem<GroupEntryUnion<T>> | number | (string & {});
|
|
271
|
+
}) & ([EntryMetaId<GroupEntryUnion<T>>] extends [never] ? unknown : {
|
|
272
|
+
id?: EntryMetaId<GroupEntryUnion<T>> | number | (string & {});
|
|
273
|
+
} & Record<string, string | number | undefined>);
|
|
76
274
|
type DictionaryLocation = "remote" | "local" | "hybrid" | "plugin" | (string & {});
|
|
77
275
|
type LocalDictionaryId = `${DictionaryKey}::${Dictionary["location"]}::${Dictionary["filePath"] | DictionaryId}`;
|
|
78
276
|
type DictionaryFormat = "intlayer" | "icu" | "i18next" | "vue-i18n" | "po";
|
|
@@ -228,6 +426,52 @@ type DictionaryBase = {
|
|
|
228
426
|
*/
|
|
229
427
|
tags?: string[];
|
|
230
428
|
/**
|
|
429
|
+
* Collection item index (1-based) of this dictionary inside the collection
|
|
430
|
+
* identified by `key`.
|
|
431
|
+
*
|
|
432
|
+
* Sibling dictionaries sharing the same key but different `item` values form
|
|
433
|
+
* an ordered collection:
|
|
434
|
+
*
|
|
435
|
+
* ```ts
|
|
436
|
+
* // faq.1.content.ts → { key: 'faq', item: 1, content: { ... } }
|
|
437
|
+
* // faq.2.content.ts → { key: 'faq', item: 2, content: { ... } }
|
|
438
|
+
*
|
|
439
|
+
* const allFaqs = useIntlayer('faq'); // → every item, ordered
|
|
440
|
+
* const faq2 = useIntlayer('faq', { item: 2 }); // → single item
|
|
441
|
+
* ```
|
|
442
|
+
*
|
|
443
|
+
* A sibling dictionary without any qualifier acts as shared base content
|
|
444
|
+
* merged into every item as fallback.
|
|
445
|
+
*/
|
|
446
|
+
item?: number;
|
|
447
|
+
/**
|
|
448
|
+
* Variant name of this dictionary inside the variant set identified by `key`.
|
|
449
|
+
*
|
|
450
|
+
* Sibling dictionaries sharing the same key but different `variant` values
|
|
451
|
+
* form a named variant set (A/B testing, seasonal banners, feature flags…):
|
|
452
|
+
*
|
|
453
|
+
* ```ts
|
|
454
|
+
* // hero.content.ts → { key: 'hero-banner', variant: 'default', content: { ... } }
|
|
455
|
+
* // hero.bf.content.ts → { key: 'hero-banner', variant: 'black-friday', content: { ... } }
|
|
456
|
+
*
|
|
457
|
+
* const hero = useIntlayer('hero-banner'); // → 'default' variant
|
|
458
|
+
* const heroBf = useIntlayer('hero-banner', { variant: 'black-friday' }); // → named variant
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
variant?: string;
|
|
462
|
+
/**
|
|
463
|
+
* Meta record qualifier of this dictionary. The `meta.id` field is the
|
|
464
|
+
* discriminator used to resolve the record at runtime; every other meta
|
|
465
|
+
* field must be provided by the selector to match:
|
|
466
|
+
*
|
|
467
|
+
* ```ts
|
|
468
|
+
* // product.abc.content.ts → { key: 'product-copy', meta: { id: 'abc', userId: '123' }, content: { ... } }
|
|
469
|
+
*
|
|
470
|
+
* const product = useIntlayer('product-copy', { id: 'abc', userId: '123' });
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
473
|
+
meta?: DictionaryMeta;
|
|
474
|
+
/**
|
|
231
475
|
* Transform the dictionary in a per-locale dictionary.
|
|
232
476
|
* Each field declared in a per-locale dictionary will be transformed in a translation node.
|
|
233
477
|
* If missing, the dictionary will be treated as a multilingual dictionary.
|
|
@@ -372,5 +616,5 @@ type DictionaryWithoutSchema<ContentType, FetchableNode> = {
|
|
|
372
616
|
type Dictionary<ContentType = undefined, SchemaKey extends SchemaKeys | undefined = undefined, FetchableNode = false> = DictionaryBase & (SchemaKey extends SchemaKeys ? DictionaryWithSchema<ContentType, FetchableNode, SchemaKey> : undefined extends SchemaKey ? DictionaryWithoutSchema<ContentType, FetchableNode> | DictionaryWithSchema<ContentType, FetchableNode> : never);
|
|
373
617
|
type GetSubPath<T, P> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? GetSubPath<T[K], Rest> : never : P extends keyof T ? T[P] : T;
|
|
374
618
|
//#endregion
|
|
375
|
-
export { ContentAutoTransformation, ContentNode, Dictionary, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryLocation, Fill, GetSubPath, ImportMode, LocalDictionaryId, TypedNode };
|
|
619
|
+
export { ContentAutoTransformation, ContentNode, Dictionary, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryLocation, DictionaryMeta, DictionaryQualifierType, DictionarySelector, DictionarySelectorForGroup, Fill, GetSubPath, ImportMode, LocalDictionaryId, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent, TypedNode };
|
|
376
620
|
//# sourceMappingURL=dictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.d.ts","names":[],"sources":["../../src/dictionary.ts"],"mappings":";;;;;KASK,QAAA;AAAA,KAEA,aAAA;EACH,QAAA,EAAU,QAAA;AAAA;AAAA,UAGK,SAAA,gCAAyC,aAAA;AAAA,KAErD,oBAAA,cACH,IAAA,WACG,WAAA,CAAY,QAAA,IAAY,OAAA,CAAQ,WAAA,CAAY,QAAA;AAAA,KAErC,WAAA,mDAGC,CAAA,qBAAsB,QAAA,GAAW,CAAA,KAE1C,QAAA,GACA,SAAA,CAAU,QAAA,MACR,IAAA,WAAe,WAAA,CAAY,QAAA,MAC5B,aAAA,gBAA6B,oBAAA,CAAqB,QAAA;AAAA,KAGlD,OAAA,MAAa,CAAA;AAAA,KAEb,wBAAA,qBAA6C,CAAA,uBAG9C,WAAA,CAAY,CAAA,EAAG,aAAA,IAAiB,mBAAA,CAAoB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A,OAAA,EAAS,WAAA,2BAEL,mBAAA,CAAoB,WAAA,EAAa,aAAA,IAAiB,WAAA;AAAA;;AArZxD;;KA2ZY,UAAA,4CAEQ,UAAA,mDAEhB,cAAA,IACD,SAAA,SAAkB,UAAA,GACf,oBAAA,CAAqB,WAAA,EAAa,aAAA,EAAe,SAAA,sBAC/B,SAAA,GAEZ,uBAAA,CAAwB,WAAA,EAAa,aAAA,IACrC,oBAAA,CAAqB,WAAA,EAAa,aAAA;AAAA,KAGlC,UAAA,SAAmB,CAAA,sCAC3B,CAAA,eAAgB,CAAA,GACd,UAAA,CAAW,CAAA,CAAE,CAAA,GAAI,IAAA,YAEnB,CAAA,eAAgB,CAAA,GACd,CAAA,CAAE,CAAA,IACF,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { locales_d_exports } from "./locales.js";
|
|
2
2
|
import { ALL_LOCALES, Locale } from "./allLocales.js";
|
|
3
|
-
import { DeclaredLocales, DictionaryKeys, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, GetLocaleLang, LocalesValues, LocalizedUrl, PathWithoutLocale, RequiredLocales, ResolvedDefaultLocale, ResolvedEditor, ResolvedRoutingMode, Schema, SchemaKeys, StrictModeLocaleMap } from "./module_augmentation.js";
|
|
3
|
+
import { DeclaredLocales, DictionaryKeys, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, GetLocaleLang, LocalesValues, LocalizedUrl, PathWithoutLocale, RequiredLocales, ResolvedDefaultLocale, ResolvedEditor, ResolvedRoutingMode, Schema, SchemaKeys, StrictModeLocaleMap } from "./module_augmentation.js";
|
|
4
4
|
import { FilePathPattern, FilePathPatternContext, FilePathPatternFunction } from "./filePathPattern.js";
|
|
5
5
|
import { ARRAY, BOOLEAN, CONDITION, ENUMERATION, FILE, GENDER, HTML, INSERTION, MARKDOWN, NESTED, NULL, NUMBER, NodeType, OBJECT, PLUGIN_NODE_TYPES, PLURAL, PREACT_NODE, REACT_NODE, SOLID_NODE, TEXT, TRANSLATION, TypedNodeModel, UNKNOWN, formatNodeType } from "./nodeType.js";
|
|
6
|
-
import { ContentAutoTransformation, ContentNode, Dictionary, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryLocation, Fill, GetSubPath, ImportMode, LocalDictionaryId, TypedNode } from "./dictionary.js";
|
|
6
|
+
import { ContentAutoTransformation, ContentNode, Dictionary, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryLocation, DictionaryMeta, DictionaryQualifierType, DictionarySelector, DictionarySelectorForGroup, Fill, GetSubPath, ImportMode, LocalDictionaryId, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent, TypedNode } from "./dictionary.js";
|
|
7
7
|
import { MergedDictionaryOutput, MergedDictionaryResult, Plugin, UnmergedDictionaryOutput, UnmergedDictionaryResult } from "./plugin.js";
|
|
8
8
|
import { AiConfig, AiProviderConfigMap, AiProviders, BuildConfig, CommonAiConfig, CompilerConfig, ConfigSchema, ContentConfig, CookiesAttributes, CustomIntlayerConfig, CustomRoutingConfig, DictionaryConfig, EditorConfig, InternationalizationConfig, IntlayerConfig, LogConfig, LogFunctions, ProcessedCookieAttributes, ProcessedStorageAttributes, RewriteObject, RewriteRule, RewriteRules, RoutingConfig, RoutingStorageInput, StorageAttributes, StrictMode, SystemConfig, URLType } from "./config.js";
|
|
9
9
|
import { ArrayNode, ConditionNode, EnumerationNode, FileNode, GenderNode, HTMLNode, InsertionNode, KeyPath, MarkdownNode, NestedNode, ObjectNode, PluralNode, ReactNode, TranslationNode } from "./keyPath.js";
|
|
10
|
-
export { ALL_LOCALES, ARRAY, AiConfig, AiProviderConfigMap, AiProviders, ArrayNode, BOOLEAN, BuildConfig, CONDITION, CommonAiConfig, CompilerConfig, ConditionNode, ConfigSchema, ContentAutoTransformation, ContentConfig, ContentNode, CookiesAttributes, CustomIntlayerConfig, CustomRoutingConfig, DeclaredLocales, Dictionary, DictionaryConfig, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryKeys, DictionaryLocation, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, ENUMERATION, EditorConfig, EnumerationNode, FILE, FileNode, FilePathPattern, FilePathPatternContext, FilePathPatternFunction, Fill, GENDER, GenderNode, GetLocaleLang, GetSubPath, HTML, HTMLNode, INSERTION, ImportMode, InsertionNode, InternationalizationConfig, IntlayerConfig, KeyPath, LocalDictionaryId, Locale, locales_d_exports as Locales, LocalesValues, LocalizedUrl, LogConfig, LogFunctions, MARKDOWN, MarkdownNode, MergedDictionaryOutput, MergedDictionaryResult, NESTED, NULL, NUMBER, NestedNode, NodeType, OBJECT, ObjectNode, PLUGIN_NODE_TYPES, PLURAL, PREACT_NODE, PathWithoutLocale, Plugin, PluralNode, ProcessedCookieAttributes, ProcessedStorageAttributes, REACT_NODE, ReactNode, RequiredLocales, ResolvedDefaultLocale, ResolvedEditor, ResolvedRoutingMode, RewriteObject, RewriteRule, RewriteRules, RoutingConfig, RoutingStorageInput, SOLID_NODE, Schema, SchemaKeys, StorageAttributes, StrictMode, StrictModeLocaleMap, SystemConfig, TEXT, TRANSLATION, TranslationNode, TypedNode, TypedNodeModel, UNKNOWN, URLType, UnmergedDictionaryOutput, UnmergedDictionaryResult, formatNodeType };
|
|
10
|
+
export { ALL_LOCALES, ARRAY, AiConfig, AiProviderConfigMap, AiProviders, ArrayNode, BOOLEAN, BuildConfig, CONDITION, CommonAiConfig, CompilerConfig, ConditionNode, ConfigSchema, ContentAutoTransformation, ContentConfig, ContentNode, CookiesAttributes, CustomIntlayerConfig, CustomRoutingConfig, DeclaredLocales, Dictionary, DictionaryConfig, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryKeys, DictionaryLocation, DictionaryMeta, DictionaryQualifierType, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, DictionarySelector, DictionarySelectorForGroup, DictionarySelectorForKey, ENUMERATION, EditorConfig, EnumerationNode, ExtractSelectorLocale, FILE, FileNode, FilePathPattern, FilePathPatternContext, FilePathPatternFunction, Fill, GENDER, GenderNode, GetLocaleLang, GetSubPath, HTML, HTMLNode, INSERTION, ImportMode, InsertionNode, InternationalizationConfig, IntlayerConfig, KeyPath, LocalDictionaryId, Locale, locales_d_exports as Locales, LocalesValues, LocalizedUrl, LogConfig, LogFunctions, MARKDOWN, MarkdownNode, MergedDictionaryOutput, MergedDictionaryResult, NESTED, NULL, NUMBER, NestedNode, NodeType, OBJECT, ObjectNode, PLUGIN_NODE_TYPES, PLURAL, PREACT_NODE, PathWithoutLocale, Plugin, PluralNode, ProcessedCookieAttributes, ProcessedStorageAttributes, QualifiedDictionaryGroup, REACT_NODE, ReactNode, RequiredLocales, ResolveQualifiedDictionaryContent, ResolvedDefaultLocale, ResolvedEditor, ResolvedRoutingMode, RewriteObject, RewriteRule, RewriteRules, RoutingConfig, RoutingStorageInput, SOLID_NODE, Schema, SchemaKeys, StorageAttributes, StrictMode, StrictModeLocaleMap, SystemConfig, TEXT, TRANSLATION, TranslationNode, TypedNode, TypedNodeModel, UNKNOWN, URLType, UnmergedDictionaryOutput, UnmergedDictionaryResult, formatNodeType };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Locale } from "./allLocales.js";
|
|
2
|
-
import { Dictionary } from "./dictionary.js";
|
|
2
|
+
import { Dictionary, DictionarySelector, DictionarySelectorForGroup, ResolveQualifiedDictionaryContent } from "./dictionary.js";
|
|
3
3
|
import { StrictMode } from "./config.js";
|
|
4
4
|
import { __DeclaredLocalesRegistry, __DictionaryRegistry, __EditorRegistry, __RequiredLocalesRegistry, __RoutingRegistry, __SchemaRegistry, __StrictModeRegistry } from "intlayer";
|
|
5
5
|
|
|
@@ -12,6 +12,29 @@ type DictionaryRegistryElement<T extends DictionaryKeys> = [string] extends [T]
|
|
|
12
12
|
type DictionaryRegistryContent<T extends PropertyKey> = [T] extends [keyof __DictionaryRegistry] ? __DictionaryRegistry[T] extends {
|
|
13
13
|
content: infer C;
|
|
14
14
|
} ? C : Dictionary["content"] : Dictionary["content"];
|
|
15
|
+
/**
|
|
16
|
+
* Computes the content type returned by `getIntlayer` / `useIntlayer` for the
|
|
17
|
+
* dictionary key `T` given the second argument `Arg` (a locale string or a
|
|
18
|
+
* `DictionarySelector`).
|
|
19
|
+
*
|
|
20
|
+
* For plain dictionaries this is the registry content; for qualified groups
|
|
21
|
+
* (collections, variants, meta records) the selector shape drives the result
|
|
22
|
+
* (single entry, array of entries, or null).
|
|
23
|
+
*/
|
|
24
|
+
type DictionaryRegistryResult<T extends PropertyKey, Arg = undefined> = [T] extends [keyof __DictionaryRegistry] ? ResolveQualifiedDictionaryContent<__DictionaryRegistry[T], Arg> : Dictionary["content"];
|
|
25
|
+
/**
|
|
26
|
+
* Extracts the effective locale from the second argument of
|
|
27
|
+
* `getIntlayer` / `useIntlayer` (locale string or selector object).
|
|
28
|
+
*/
|
|
29
|
+
type ExtractSelectorLocale<Arg> = Arg extends {
|
|
30
|
+
locale: infer L extends LocalesValues;
|
|
31
|
+
} ? L : Arg extends LocalesValues ? Arg : DeclaredLocales;
|
|
32
|
+
/**
|
|
33
|
+
* The selector accepted for a dictionary **key** `T`: its `variant` / `item` /
|
|
34
|
+
* `id` are constrained to the coordinates that exist for that key, so an unknown
|
|
35
|
+
* value is a compile-time error. Plain keys fall back to {@link DictionarySelector}.
|
|
36
|
+
*/
|
|
37
|
+
type DictionarySelectorForKey<T extends PropertyKey> = [T] extends [keyof __DictionaryRegistry] ? DictionarySelectorForGroup<__DictionaryRegistry[T]> : DictionarySelector;
|
|
15
38
|
type NarrowStringKeys<T> = string extends keyof T ? never : Extract<keyof T, string>;
|
|
16
39
|
type DeclaredLocales = [NarrowStringKeys<__DeclaredLocalesRegistry>] extends [never] ? Locale : NarrowStringKeys<__DeclaredLocalesRegistry>;
|
|
17
40
|
type RequiredLocales = [NarrowStringKeys<__RequiredLocalesRegistry>] extends [never] ? never : NarrowStringKeys<__RequiredLocalesRegistry>;
|
|
@@ -76,5 +99,5 @@ type GetLocaleLang<L extends string> = L extends `${infer Lang}-${string}` ? Lan
|
|
|
76
99
|
*/
|
|
77
100
|
type PathWithoutLocale<Path extends string, Locales extends string> = Path extends `${infer Protocol}://${infer Domain}/${infer Seg}/${infer Rest}` ? Seg extends Locales ? `${Protocol}://${Domain}/${Rest}` : Path : Path extends `${infer Protocol}://${infer Domain}/${infer Seg}` ? Seg extends Locales ? `${Protocol}://${Domain}/` : Path : Path extends `/${infer Seg}/${infer Rest}` ? Seg extends Locales ? `/${Rest}` : Path : Path extends `/${infer Seg}` ? Seg extends Locales ? "/" : Path : Path;
|
|
78
101
|
//#endregion
|
|
79
|
-
export { DeclaredLocales, DictionaryKeys, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, GetLocaleLang, LocalesValues, LocalizedUrl, PathWithoutLocale, RequiredLocales, ResolvedDefaultLocale, ResolvedEditor, ResolvedRoutingMode, Schema, SchemaKeys, StrictModeLocaleMap };
|
|
102
|
+
export { DeclaredLocales, DictionaryKeys, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, type DictionarySelector, type DictionarySelectorForGroup, DictionarySelectorForKey, ExtractSelectorLocale, GetLocaleLang, LocalesValues, LocalizedUrl, PathWithoutLocale, RequiredLocales, ResolvedDefaultLocale, ResolvedEditor, ResolvedRoutingMode, Schema, SchemaKeys, StrictModeLocaleMap };
|
|
80
103
|
//# sourceMappingURL=module_augmentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module_augmentation.d.ts","names":[],"sources":["../../src/module_augmentation.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"module_augmentation.d.ts","names":[],"sources":["../../src/module_augmentation.ts"],"mappings":";;;;;;KAkBY,UAAA,SAAmB,gBAAA,gCAErB,gBAAA;AAAA,KAEE,MAAA,WAAiB,UAAA,sBAAgC,CAAA,UAEzD,CAAA,e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,OAAA,MACP,QAAA,MAAc,MAAA,MACjB,IAAA,GAEF,IAAA,yCACE,GAAA,SAAY,OAAA,OACN,IAAA,KACJ,IAAA,GAEF,IAAA,2BACE,GAAA,SAAY,OAAA,SAEV,IAAA,GACF,IAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/types",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-canary.1",
|
|
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": [
|
|
@@ -141,14 +141,14 @@
|
|
|
141
141
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
142
142
|
},
|
|
143
143
|
"devDependencies": {
|
|
144
|
-
"@types/node": "25.9.
|
|
144
|
+
"@types/node": "25.9.3",
|
|
145
145
|
"@utils/ts-config": "1.0.4",
|
|
146
146
|
"@utils/ts-config-types": "1.0.4",
|
|
147
147
|
"@utils/tsdown-config": "1.0.4",
|
|
148
148
|
"rimraf": "6.1.3",
|
|
149
149
|
"tsdown": "0.21.10",
|
|
150
150
|
"typescript": "6.0.3",
|
|
151
|
-
"vitest": "4.1.
|
|
151
|
+
"vitest": "4.1.9",
|
|
152
152
|
"zod": "4.4.3"
|
|
153
153
|
},
|
|
154
154
|
"engines": {
|