@intlayer/types 9.4.0-canary.0 → 9.4.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/README.md
CHANGED
|
@@ -214,6 +214,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
|
|
|
214
214
|
<li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
|
|
215
215
|
<li><a href="https://intlayer.org/doc/environment/nuxt-and-vue" rel=''>Vite + Nuxt</a></li>
|
|
216
216
|
<li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
|
|
217
|
+
<li><a href="https://intlayer.org/doc/environment/solid-start" rel=''>Solid Start</a></li>
|
|
217
218
|
<li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li>
|
|
218
219
|
<li>
|
|
219
220
|
<a href="https://intlayer.org/doc/environment/express" rel=''>Backend</a>
|
|
@@ -223,7 +224,9 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
|
|
|
223
224
|
<li><a href="https://intlayer.org/doc/environment/fastify" rel=''>Fastify</a></li>
|
|
224
225
|
<li><a href="https://intlayer.org/doc/environment/adonisjs" rel=''>AdonisJS</a></li>
|
|
225
226
|
<li><a href="https://intlayer.org/doc/environment/hono" rel=''>Hono</a></li>
|
|
227
|
+
<li><a href="https://intlayer.org/doc/environment/elysia" rel=''>Elysia</a></li>
|
|
226
228
|
</ul>
|
|
229
|
+
|
|
227
230
|
</li>
|
|
228
231
|
</ul>
|
|
229
232
|
</details>
|
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, DeclaredVariants, DictionaryKeys, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, GetLocaleLang, LocalesValues, LocalizedPath, LocalizedPathname, LocalizedUrl, PathWithoutLocale, RequiredLocales, ResolvedDefaultLocale, ResolvedEditor, ResolvedRewriteRules, ResolvedRoutingMode, RewriteRuleMap, Schema, SchemaKeys, StrictModeLocaleMap } from "./module_augmentation.js";
|
|
3
|
+
import { DeclaredLocales, DeclaredVariants, DictionaryKeys, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, DictionarySelectorForKey, DomainRegistryEntry, DomainRuleMap, ExtractSelectorLocale, GetLocaleLang, IsDomainExclusive, LocaleDomainOrigin, LocalesValues, LocalizedPath, LocalizedPathname, LocalizedUrl, PathWithoutLocale, RequiredLocales, ResolvedDefaultLocale, ResolvedDomains, ResolvedEditor, ResolvedRewriteRules, ResolvedRoutingMode, RewriteRuleMap, 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, SELECT, SOLID_NODE, TEXT, TRANSLATION, TypedNodeModel, UNKNOWN, formatNodeType } from "./nodeType.js";
|
|
6
6
|
import { ContentAutoTransformation, ContentNode, Dictionary, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryLocation, DictionaryQualifierType, DictionarySelector, DictionarySelectorForGroup, DictionaryVariantChain, DictionaryVariantIdsOf, DictionaryVariantValue, Fill, GetSubPath, ImportMode, LocalDictionaryId, ProviderVariant, ProviderVariantMap, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent, TypedNode } from "./dictionary.js";
|
|
7
7
|
import { MergedDictionaryOutput, MergedDictionaryResult, Plugin, UnmergedDictionaryOutput, UnmergedDictionaryResult } from "./plugin.js";
|
|
8
8
|
import { AiConfig, AiProviderConfigMap, AiProviders, AnalyticsConfig, 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, SelectNode, TranslationNode } from "./keyPath.js";
|
|
10
|
-
export { ALL_LOCALES, ARRAY, AiConfig, AiProviderConfigMap, AiProviders, AnalyticsConfig, ArrayNode, BOOLEAN, BuildConfig, CONDITION, CommonAiConfig, CompilerConfig, ConditionNode, ConfigSchema, ContentAutoTransformation, ContentConfig, ContentNode, CookiesAttributes, CustomIntlayerConfig, CustomRoutingConfig, DeclaredLocales, DeclaredVariants, Dictionary, DictionaryConfig, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryKeys, DictionaryLocation, DictionaryQualifierType, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, DictionarySelector, DictionarySelectorForGroup, DictionarySelectorForKey, DictionaryVariantChain, DictionaryVariantIdsOf, DictionaryVariantValue, 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, LocalizedPath, LocalizedPathname, 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, ProviderVariantMap, QualifiedDictionaryGroup, REACT_NODE, ReactNode, RequiredLocales, ResolveQualifiedDictionaryContent, ResolvedDefaultLocale, ResolvedEditor, ResolvedRewriteRules, ResolvedRoutingMode, RewriteObject, RewriteRule, RewriteRuleMap, RewriteRules, RoutingConfig, RoutingStorageInput, SELECT, SOLID_NODE, Schema, SchemaKeys, SelectNode, StorageAttributes, StrictMode, StrictModeLocaleMap, SystemConfig, TEXT, TRANSLATION, TranslationNode, TypedNode, TypedNodeModel, UNKNOWN, URLType, UnmergedDictionaryOutput, UnmergedDictionaryResult, formatNodeType };
|
|
10
|
+
export { ALL_LOCALES, ARRAY, AiConfig, AiProviderConfigMap, AiProviders, AnalyticsConfig, ArrayNode, BOOLEAN, BuildConfig, CONDITION, CommonAiConfig, CompilerConfig, ConditionNode, ConfigSchema, ContentAutoTransformation, ContentConfig, ContentNode, CookiesAttributes, CustomIntlayerConfig, CustomRoutingConfig, DeclaredLocales, DeclaredVariants, Dictionary, DictionaryConfig, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryKeys, DictionaryLocation, DictionaryQualifierType, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, DictionarySelector, DictionarySelectorForGroup, DictionarySelectorForKey, DictionaryVariantChain, DictionaryVariantIdsOf, DictionaryVariantValue, DomainRegistryEntry, DomainRuleMap, ENUMERATION, EditorConfig, EnumerationNode, ExtractSelectorLocale, FILE, FileNode, FilePathPattern, FilePathPatternContext, FilePathPatternFunction, Fill, GENDER, GenderNode, GetLocaleLang, GetSubPath, HTML, HTMLNode, INSERTION, ImportMode, InsertionNode, InternationalizationConfig, IntlayerConfig, IsDomainExclusive, KeyPath, LocalDictionaryId, Locale, LocaleDomainOrigin, locales_d_exports as Locales, LocalesValues, LocalizedPath, LocalizedPathname, 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, ProviderVariantMap, QualifiedDictionaryGroup, REACT_NODE, ReactNode, RequiredLocales, ResolveQualifiedDictionaryContent, ResolvedDefaultLocale, ResolvedDomains, ResolvedEditor, ResolvedRewriteRules, ResolvedRoutingMode, RewriteObject, RewriteRule, RewriteRuleMap, RewriteRules, RoutingConfig, RoutingStorageInput, SELECT, SOLID_NODE, Schema, SchemaKeys, SelectNode, StorageAttributes, StrictMode, StrictModeLocaleMap, SystemConfig, TEXT, TRANSLATION, TranslationNode, TypedNode, TypedNodeModel, UNKNOWN, URLType, UnmergedDictionaryOutput, UnmergedDictionaryResult, formatNodeType };
|
|
@@ -84,10 +84,54 @@ type ResolvedRoutingMode = __RoutingRegistry extends {
|
|
|
84
84
|
type ResolvedDefaultLocale = __RoutingRegistry extends {
|
|
85
85
|
defaultLocale: infer D extends DeclaredLocales;
|
|
86
86
|
} ? D : DeclaredLocales;
|
|
87
|
+
/**
|
|
88
|
+
* What the generated module augmentation records about the domain serving one
|
|
89
|
+
* locale: the normalized origin to prepend to its URLs, and whether that
|
|
90
|
+
* hostname serves this locale alone.
|
|
91
|
+
*/
|
|
92
|
+
type DomainRegistryEntry = {
|
|
93
|
+
origin: string;
|
|
94
|
+
exclusive: boolean;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Shape of the locale → domain map carried by the generated module augmentation.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* { en: { origin: 'https://intlayer.org'; exclusive: false }; zh: { origin: 'https://intlayer.cn'; exclusive: true } }
|
|
101
|
+
*/
|
|
102
|
+
type DomainRuleMap = Record<string, DomainRegistryEntry>;
|
|
103
|
+
/**
|
|
104
|
+
* The project's domain map resolved from the generated registry. Falls back to
|
|
105
|
+
* an empty map — no locale is then served from its own domain — when the project
|
|
106
|
+
* declares no `routing.domains`, or when the types have not been generated yet.
|
|
107
|
+
*/
|
|
108
|
+
type ResolvedDomains = __RoutingRegistry extends {
|
|
109
|
+
domains: infer Domains extends DomainRuleMap;
|
|
110
|
+
} ? Domains : {};
|
|
111
|
+
/**
|
|
112
|
+
* The origin of the domain serving `L`, or `never` when the locale maps to none.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* // domains: { zh: { origin: 'https://intlayer.cn'; exclusive: true } }
|
|
116
|
+
* type A = LocaleDomainOrigin<'zh', ResolvedDomains>; // 'https://intlayer.cn'
|
|
117
|
+
* type B = LocaleDomainOrigin<'fr', ResolvedDomains>; // never
|
|
118
|
+
*/
|
|
119
|
+
type LocaleDomainOrigin<L extends string, Domains extends DomainRuleMap = ResolvedDomains> = L extends keyof Domains ? Extract<Domains[L]["origin"], string> : never;
|
|
120
|
+
/**
|
|
121
|
+
* Whether `L` is the only locale mapped to its domain. The domain then identifies
|
|
122
|
+
* the locale on its own, so its paths carry no locale prefix — the type-level
|
|
123
|
+
* counterpart of `isLocaleExclusiveOnDomain`.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* // domains: { en: 'intlayer.org', fr: 'intlayer.org', zh: 'intlayer.cn' }
|
|
127
|
+
* type A = IsDomainExclusive<'zh'>; // true → https://intlayer.cn/about
|
|
128
|
+
* type B = IsDomainExclusive<'fr'>; // false → https://intlayer.org/fr/about
|
|
129
|
+
*/
|
|
130
|
+
type IsDomainExclusive<L extends string, Domains extends DomainRuleMap = ResolvedDomains> = L extends keyof Domains ? Domains[L]["exclusive"] : false;
|
|
87
131
|
/** Computes the locale path segment (e.g. `'fr/'`) for a given locale and routing mode. */
|
|
88
132
|
type LocalePrefixSegment<L extends string, Mode extends string, Default extends string> = Mode extends "prefix-all" ? `${L}/` : Mode extends "prefix-no-default" ? L extends Default ? "" : `${L}/` : "";
|
|
89
133
|
/**
|
|
90
|
-
* Drops a trailing slash, mirroring the normalization `
|
|
134
|
+
* Drops a trailing slash, mirroring the normalization `getLocalizedPath` applies
|
|
91
135
|
* to the path it builds. The bare root keeps its slash.
|
|
92
136
|
*
|
|
93
137
|
* @example
|
|
@@ -97,20 +141,57 @@ type LocalePrefixSegment<L extends string, Mode extends string, Default extends
|
|
|
97
141
|
*/
|
|
98
142
|
type WithoutTrailingSlash<Path extends string> = Path extends `${infer Head}/` ? Head extends "" ? "/" : Head : Path;
|
|
99
143
|
/**
|
|
100
|
-
* Prepends a locale path prefix to a
|
|
101
|
-
* untouched and never emitting a trailing slash.
|
|
144
|
+
* Prepends a locale path prefix to a path, never emitting a trailing slash.
|
|
102
145
|
*
|
|
103
146
|
* @example
|
|
104
|
-
* type A = WithLocalePrefix<'/about', 'fr/'>;
|
|
105
|
-
* type B = WithLocalePrefix<'/', 'fr/'>;
|
|
106
|
-
* type C = WithLocalePrefix<'
|
|
147
|
+
* type A = WithLocalePrefix<'/about', 'fr/'>; // '/fr/about'
|
|
148
|
+
* type B = WithLocalePrefix<'/', 'fr/'>; // '/fr'
|
|
149
|
+
* type C = WithLocalePrefix<'/about/', ''>; // '/about'
|
|
107
150
|
*/
|
|
108
|
-
type WithLocalePrefix<Path extends string, Prefix extends string> =
|
|
151
|
+
type WithLocalePrefix<Path extends string, Prefix extends string> = Path extends `/${infer Rest}` ? WithoutTrailingSlash<`/${Prefix}${Rest}`> : Path;
|
|
109
152
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
153
|
+
* Extracts the pathname of an absolute URL, leaving a relative path untouched.
|
|
154
|
+
* An absolute URL without a path resolves to the root, mirroring what the
|
|
155
|
+
* `URL` parsing of the runtime reports.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* type A = UrlPathname<'https://example.com/about'>; // '/about'
|
|
159
|
+
* type B = UrlPathname<'https://example.com/'>; // '/'
|
|
160
|
+
* type C = UrlPathname<'https://example.com'>; // '/'
|
|
161
|
+
* type D = UrlPathname<'/about'>; // '/about'
|
|
162
|
+
*/
|
|
163
|
+
type UrlPathname<Url extends string> = Url extends `${string}://${string}/${infer Pathname}` ? `/${Pathname}` : Url extends `${string}://${string}` ? "/" : Url;
|
|
164
|
+
/**
|
|
165
|
+
* Extracts the origin of an absolute URL, and the empty string for a relative
|
|
166
|
+
* path — exactly the base `getLocalizedUrl` keeps when the target locale maps to
|
|
167
|
+
* no domain of its own.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* type A = UrlOrigin<'https://example.com/about'>; // 'https://example.com'
|
|
171
|
+
* type B = UrlOrigin<'https://example.com'>; // 'https://example.com'
|
|
172
|
+
* type C = UrlOrigin<'/about'>; // ''
|
|
173
|
+
*/
|
|
174
|
+
type UrlOrigin<Url extends string> = Url extends `${infer Protocol}://${infer Host}/${string}` ? `${Protocol}://${Host}` : Url extends `${infer Protocol}://${infer Host}` ? `${Protocol}://${Host}` : "";
|
|
175
|
+
/**
|
|
176
|
+
* The path half of a localized URL, shared by {@link LocalizedPathname} and
|
|
177
|
+
* {@link LocalizedUrl}: the origin and the existing locale segment are stripped,
|
|
178
|
+
* the project's `routing.rewrite` rules are applied, then the locale prefix of
|
|
179
|
+
* the routing mode is prepended — unless the locale is served from its own
|
|
180
|
+
* exclusive domain, where the hostname already identifies it.
|
|
181
|
+
*/
|
|
182
|
+
type LocalizedPathBody<Path extends string, L extends LocalesValues, Mode extends string, Default extends LocalesValues, Locales extends string, Domains extends DomainRuleMap> = LocalizedPath<PathWithoutLocale<UrlPathname<Path>, Locales>, L> extends (infer Rewritten extends string) ? Mode extends "no-prefix" ? Rewritten : WithLocalePrefix<Rewritten, IsDomainExclusive<L & string, Domains> extends true ? "" : LocalePrefixSegment<L & string, Mode, Default & string>> : never;
|
|
183
|
+
/**
|
|
184
|
+
* Computes the localized URL string type for a given path, locale, routing mode,
|
|
185
|
+
* default locale and domain map. Mirrors the runtime behaviour of
|
|
186
|
+
* `getLocalizedUrl`: the existing locale segment is stripped from `Path`, the
|
|
187
|
+
* project's `routing.rewrite` rules are applied to the remaining pathname, the
|
|
188
|
+
* new locale prefix is prepended, and an origin is put in front of the result.
|
|
189
|
+
*
|
|
190
|
+
* When the locale is mapped to a domain via `routing.domains` the result is a
|
|
191
|
+
* union of the two URLs the runtime can produce: the absolute URL on that domain
|
|
192
|
+
* (cross-domain link, and the fallback whenever the current domain is unknown —
|
|
193
|
+
* SSR, static generation) and the relative one it returns when the page being
|
|
194
|
+
* rendered already lives on that domain.
|
|
114
195
|
*
|
|
115
196
|
* @example
|
|
116
197
|
* // prefix-no-default, defaultLocale='en'
|
|
@@ -125,34 +206,30 @@ type WithLocalePrefix<Path extends string, Prefix extends string> = Prefix exten
|
|
|
125
206
|
*
|
|
126
207
|
* // with rewrite: { '/about': { fr: '/a-propos' } }
|
|
127
208
|
* type G = LocalizedUrl<'/about', 'fr'>; // '/fr/a-propos'
|
|
128
|
-
*/
|
|
129
|
-
type LocalizedUrl<Path extends string, L extends LocalesValues, Mode extends string = ResolvedRoutingMode, Default extends LocalesValues = ResolvedDefaultLocale, Locales extends string = DeclaredLocales & string> = [string] extends [Mode] ? string : Mode extends "no-prefix" ? LocalizedUrlPath<PathWithoutLocale<Path, Locales>, L> : Mode extends "search-params" ? string : WithLocalePrefix<LocalizedUrlPath<PathWithoutLocale<Path, Locales>, L>, LocalePrefixSegment<L, Mode, Default>>;
|
|
130
|
-
/**
|
|
131
|
-
* Extracts the pathname of an absolute URL, leaving a relative path untouched.
|
|
132
|
-
* An absolute URL without a path resolves to the root, mirroring what the
|
|
133
|
-
* `URL` parsing of the runtime reports.
|
|
134
209
|
*
|
|
135
|
-
*
|
|
136
|
-
* type
|
|
137
|
-
* type B = UrlPathname<'https://example.com/'>; // '/'
|
|
138
|
-
* type C = UrlPathname<'https://example.com'>; // '/'
|
|
139
|
-
* type D = UrlPathname<'/about'>; // '/about'
|
|
210
|
+
* // with domains: { zh: 'intlayer.cn' } (exclusive → no locale prefix)
|
|
211
|
+
* type H = LocalizedUrl<'/about', 'zh'>; // 'https://intlayer.cn/about' | '/about'
|
|
140
212
|
*/
|
|
141
|
-
type
|
|
213
|
+
type LocalizedUrl<Path extends string, L extends LocalesValues, Mode extends string = ResolvedRoutingMode, Default extends LocalesValues = ResolvedDefaultLocale, Locales extends string = DeclaredLocales & string, Domains extends DomainRuleMap = ResolvedDomains> = [string] extends [Mode] ? string : Mode extends "search-params" ? string : LocalizedPathBody<Path, L, Mode, Default, Locales, Domains> extends (infer LocalPath extends string) ? [LocaleDomainOrigin<L & string, Domains>] extends [never] ? `${UrlOrigin<Path>}${LocalPath}` : `${LocaleDomainOrigin<L & string, Domains>}${LocalPath}` | `${UrlOrigin<Path>}${LocalPath}` : never;
|
|
142
214
|
/**
|
|
143
215
|
* Computes the localized path string type for a given path, locale, routing
|
|
144
|
-
* mode
|
|
216
|
+
* mode, default locale and domain map — the type-level counterpart of
|
|
217
|
+
* `getLocalizedPath`.
|
|
145
218
|
*
|
|
146
|
-
* It mirrors {@link LocalizedUrl}, except that
|
|
147
|
-
* is dropped
|
|
219
|
+
* It mirrors {@link LocalizedUrl}, except that no origin is ever emitted: the one
|
|
220
|
+
* of an absolute input is dropped, and a locale mapped to a domain resolves to
|
|
221
|
+
* the path served on that domain rather than to its absolute URL.
|
|
148
222
|
*
|
|
149
223
|
* @example
|
|
150
224
|
* // prefix-no-default, defaultLocale='en', rewrite: { '/about': { es: '/acerca-de' } }
|
|
151
225
|
* type A = LocalizedPathname<'/about', 'es'>; // '/es/acerca-de'
|
|
152
226
|
* type B = LocalizedPathname<'https://intlayer.org/about', 'es'>; // '/es/acerca-de'
|
|
153
227
|
* type C = LocalizedPathname<'https://intlayer.org', 'en'>; // '/'
|
|
228
|
+
*
|
|
229
|
+
* // with domains: { zh: 'intlayer.cn' } (exclusive → no locale prefix)
|
|
230
|
+
* type D = LocalizedPathname<'/about', 'zh'>; // '/about'
|
|
154
231
|
*/
|
|
155
|
-
type LocalizedPathname<Path extends string, L extends LocalesValues, Mode extends string = ResolvedRoutingMode, Default extends LocalesValues = ResolvedDefaultLocale, Locales extends string = DeclaredLocales & string> =
|
|
232
|
+
type LocalizedPathname<Path extends string, L extends LocalesValues, Mode extends string = ResolvedRoutingMode, Default extends LocalesValues = ResolvedDefaultLocale, Locales extends string = DeclaredLocales & string, Domains extends DomainRuleMap = ResolvedDomains> = [string] extends [Mode] ? string : Mode extends "search-params" ? string : LocalizedPathBody<Path, L, Mode, Default, Locales, Domains>;
|
|
156
233
|
/**
|
|
157
234
|
* Extracts the language subtag from a locale string.
|
|
158
235
|
*
|
|
@@ -242,14 +319,6 @@ type ResolveRewriteRules<Path extends string, L extends string, Rules extends Re
|
|
|
242
319
|
* type C = LocalizedPath<'/contact', 'fr'>; // '/contact' (no rule)
|
|
243
320
|
*/
|
|
244
321
|
type LocalizedPath<Path extends string, L extends LocalesValues = ResolvedDefaultLocale, Rules extends RewriteRuleMap = ResolvedRewriteRules> = string extends Path ? string : string extends L ? string : [keyof Rules] extends [never] ? Path : ResolveRewriteRules<Path, L & string, Rules> extends (infer Localized) ? [Localized] extends [never] ? Path : Extract<Localized, string> : never;
|
|
245
|
-
/**
|
|
246
|
-
* Applies {@link LocalizedPath} to the pathname of a URL, leaving the origin of
|
|
247
|
-
* an absolute URL untouched.
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* type A = LocalizedUrlPath<'https://example.com/about', 'fr'>; // 'https://example.com/a-propos'
|
|
251
|
-
*/
|
|
252
|
-
type LocalizedUrlPath<Url extends string, L extends LocalesValues> = Url extends `${infer Protocol}://${infer Host}/${infer Pathname}` ? `${Protocol}://${Host}${LocalizedPath<`/${Pathname}`, L>}` : LocalizedPath<Url, L>;
|
|
253
322
|
//#endregion
|
|
254
|
-
export { DeclaredLocales, DeclaredVariants, DictionaryKeys, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, type DictionarySelector, type DictionarySelectorForGroup, DictionarySelectorForKey, ExtractSelectorLocale, GetLocaleLang, LocalesValues, LocalizedPath, LocalizedPathname, LocalizedUrl, PathWithoutLocale, ProviderVariant, RequiredLocales, ResolvedDefaultLocale, ResolvedEditor, ResolvedRewriteRules, ResolvedRoutingMode, RewriteRuleMap, Schema, SchemaKeys, StrictModeLocaleMap };
|
|
323
|
+
export { DeclaredLocales, DeclaredVariants, DictionaryKeys, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, type DictionarySelector, type DictionarySelectorForGroup, DictionarySelectorForKey, DomainRegistryEntry, DomainRuleMap, ExtractSelectorLocale, GetLocaleLang, IsDomainExclusive, LocaleDomainOrigin, LocalesValues, LocalizedPath, LocalizedPathname, LocalizedUrl, PathWithoutLocale, ProviderVariant, RequiredLocales, ResolvedDefaultLocale, ResolvedDomains, ResolvedEditor, ResolvedRewriteRules, ResolvedRoutingMode, RewriteRuleMap, Schema, SchemaKeys, StrictModeLocaleMap };
|
|
255
324
|
//# sourceMappingURL=module_augmentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module_augmentation.d.ts","names":[],"sources":["../../src/module_augmentation.ts"],"mappings":";;;;;KAoBY,mBAAmB,gDAErB;KAEE,OAAO,UAAU,gCAAgC,WAEzD,gBAAgB,mBACd,iBAAiB;KAGX,uBAAuB,oDAEzB;KAGE,qBACV,2BAA2B,sCACvB,eAAe,cACf;KAEM,0BAA0B,UAAU,oCAErC,KACP,aACA,gBAAgB,uBACd,qBAAqB,WAAW,aAC9B,qBAAqB,KACrB,aACF;KAEM,0BAA0B,UAAU,gBAAgB,kBACxD,wBAEJ,qBAAqB;EAAa,eAAe;IAC/C,IACA,wBACF;;;;;;;;;;KAWQ,yBAAyB,UAAU,aAAa,oBAC1D,kBACe,wBACb,kCAAkC,qBAAqB,IAAI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AQ3C,cAAc,0BACjB,yBAAyB,mBACrB,sBAAsB,aACpB,UACA,OACF;;;;;;;;;;KAWD,cACH,qBACA,0BACE,yBAAyB,cAAc,eACvC,gBAAgB,aAAa,SAC3B,WAAW,MAAM,sBAEnB,aAAa;;;;;KAQZ,WACH,qBACA,6BACE,sCAAsC,gBAEtC,sBAAsB,eAAe,aACnC,2BAEE,cAAc,UAAU,4BAA2B,WAChD,mCAEE,UAAU,QAAQ,qCAI3B,mDAEG;;;;;;;KAQF,YACH,wBACA,oCACE,yBAAyB,cAAc,eACvC,+BACQ,+BACG,wCAET,sCAAsC,mBACjC,OAAO,SAAS,YAAY,aAAa,mBACzC,OAAO,UACZ,UACF;;KAGC,mBACH,qBACA,0BACA,WACA,oBACE,gBAAgB,YAChB,QAAQ,UAAU,2BAA0B,sCAC7B,iBAAiB,aAAa,iBAAiB,UAI1D,gBAAgB,cAAc,yCAG9B,cAAc,MAAM,0BAAyB,WAC1C,kCAEC,YAAY,QAAQ,QAAQ;;KAMnC,oBACH,qBACA,kBACA,cAAc,qBAEb,mBAAmB,iBAAiB,mBACnC,MACA,WACA,MAAM,YACN,YAEI;;;;;;;;;;;;;;;KAgBI,cACV,qBACA,UAAU,gBAAgB,uBAC1B,cAAc,iBAAiB,uCACd,+BAEA,oBAEN,yBACL,OACA,oBAAoB,MAAM,YAAY,sBAAqB,cACxD,6BACC,OACA,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/types",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.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,7 +141,7 @@
|
|
|
141
141
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
142
142
|
},
|
|
143
143
|
"devDependencies": {
|
|
144
|
-
"@types/node": "26.
|
|
144
|
+
"@types/node": "26.3.0",
|
|
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",
|