import { Locale } from "./allLocales.js"; import { Dictionary } from "./dictionary.js"; import { StrictMode } from "./config.js"; import { __DeclaredLocalesRegistry, __DictionaryRegistry, __EditorRegistry, __RequiredLocalesRegistry, __RoutingRegistry, __SchemaRegistry, __StrictModeRegistry } from "intlayer"; //#region src/module_augmentation.d.ts type SchemaKeys = keyof __SchemaRegistry extends never ? string : keyof __SchemaRegistry; type Schema = [string] extends [T] ? any : T extends keyof __SchemaRegistry ? __SchemaRegistry[T] : any; type DictionaryKeys = keyof __DictionaryRegistry extends never ? string : keyof __DictionaryRegistry; type DictionaryRegistry = __DictionaryRegistry[keyof __DictionaryRegistry] extends never ? Record : __DictionaryRegistry; type DictionaryRegistryElement = [string] extends [T] ? Dictionary : T extends keyof __DictionaryRegistry ? __DictionaryRegistry[T] extends Dictionary ? __DictionaryRegistry[T] : Dictionary : Dictionary; type DictionaryRegistryContent = [T] extends [keyof __DictionaryRegistry] ? __DictionaryRegistry[T] extends { content: infer C; } ? C : Dictionary["content"] : Dictionary["content"]; type NarrowStringKeys = string extends keyof T ? never : Extract; type DeclaredLocales = [NarrowStringKeys<__DeclaredLocalesRegistry>] extends [never] ? Locale : NarrowStringKeys<__DeclaredLocalesRegistry>; type RequiredLocales = [NarrowStringKeys<__RequiredLocalesRegistry>] extends [never] ? never : NarrowStringKeys<__RequiredLocalesRegistry>; /** Define MyType using the ValueOf utility type on Locales */ type LocalesValues = DeclaredLocales | (string & {}); type ResolvedStrictMode = __StrictModeRegistry extends { mode: infer M; } ? M : "inclusive"; type StrictModeLocaleMap = RequiredLocales extends never ? Partial> : Mode extends "strict" ? Required> & Partial> : Mode extends "inclusive" ? Required> & Partial> : Partial>; type ResolvedEditor = __EditorRegistry extends { enabled: true; } ? Editor : Node; type RoutingMode = "prefix-no-default" | "prefix-all" | "no-prefix" | "search-params"; /** The routing mode resolved from the generated registry (falls back to 'prefix-no-default'). */ type ResolvedRoutingMode = __RoutingRegistry extends { mode: infer M extends RoutingMode; } ? M : "prefix-no-default"; /** The default locale resolved from the generated registry (falls back to the full LocalesValues union). */ type ResolvedDefaultLocale = __RoutingRegistry extends { defaultLocale: infer D extends LocalesValues; } ? D : LocalesValues; /** Computes the locale path segment (e.g. `'fr/'`) for a given locale and routing mode. */ type LocalePrefixSegment = Mode extends "prefix-all" ? `${L}/` : Mode extends "prefix-no-default" ? L extends Default ? "" : `${L}/` : ""; /** Prepends a locale path prefix to a URL path (e.g. `'/about'` + `'fr/'` → `'/fr/about'`). */ type WithLocalePrefix = Prefix extends "" ? Path : Path extends `/${infer Rest}` ? `/${Prefix}${Rest}` : Path; /** * Computes the localized URL string type for a given path, locale, routing mode and default locale. * Mirrors the runtime behaviour: the existing locale segment is stripped from `Path` first, then * the new locale prefix is prepended (identical to what `getLocalizedUrl` does internally). * * @example * // prefix-no-default, defaultLocale='en' * type A = LocalizedUrl<'/about', 'fr'>; // '/fr/about' * type B = LocalizedUrl<'/about', 'en'>; // '/about' * type C = LocalizedUrl<'/fr/about', 'en'>; // '/about' (existing prefix stripped) * type D = LocalizedUrl<'/fr/about', 'fr'>; // '/fr/about' * * // prefix-all * type E = LocalizedUrl<'/about', 'en', 'prefix-all', 'en'>; // '/en/about' */ type LocalizedUrl = [string] extends [Mode] ? string : Mode extends "no-prefix" ? PathWithoutLocale : Mode extends "search-params" ? string : WithLocalePrefix, LocalePrefixSegment>; /** * Extracts the language subtag from a locale string. * * @example * type A = GetLocaleLang<'en-GB'>; // 'en' * type B = GetLocaleLang<'fr'>; // 'fr' */ type GetLocaleLang = L extends `${infer Lang}-${string}` ? Lang : L; /** * Removes the locale path segment from a URL (relative or absolute). * * @example * // relative * type A = PathWithoutLocale<'/fr/about', 'fr' | 'en'>; // '/about' * type B = PathWithoutLocale<'/about', 'fr' | 'en'>; // '/about' * type C = PathWithoutLocale<'/fr', 'fr' | 'en'>; // '/' * // absolute * type D = PathWithoutLocale<'https://example.com/fr/about', 'fr' | 'en'>; // 'https://example.com/about' * type E = PathWithoutLocale<'https://sub.example.com/fr/about', 'fr' | 'en'>; // 'https://sub.example.com/about' * type F = PathWithoutLocale<'https://example.com/fr', 'fr' | 'en'>; // 'https://example.com/' */ type PathWithoutLocale = 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; //#endregion export { DeclaredLocales, DictionaryKeys, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, GetLocaleLang, LocalesValues, LocalizedUrl, PathWithoutLocale, RequiredLocales, ResolvedDefaultLocale, ResolvedEditor, ResolvedRoutingMode, Schema, SchemaKeys, StrictModeLocaleMap }; //# sourceMappingURL=module_augmentation.d.ts.map