intor-translator 1.4.10 → 1.4.12
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/index.d.cts +38 -1
- package/dist/index.d.ts +38 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -239,6 +239,43 @@ type LocalizedReplacement<ReplacementSchema, K extends string> = ReplacementSche
|
|
|
239
239
|
*/
|
|
240
240
|
type ScopedReplacement<ReplacementSchema, PK extends string | undefined, K extends string> = LocalizedReplacement<ReplacementSchema, `${PK}.${K}`>;
|
|
241
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Generic rich tag map used when no schema is available.
|
|
244
|
+
*
|
|
245
|
+
* Acts as a safe fallback for dynamic or unknown rich tag shapes.
|
|
246
|
+
*/
|
|
247
|
+
type Rich = Record<string, unknown>;
|
|
248
|
+
/**
|
|
249
|
+
* Rich tag map resolved from a localized rich schema.
|
|
250
|
+
*
|
|
251
|
+
* - If the key exists in the schema, resolves to the declared tag map
|
|
252
|
+
* - Otherwise falls back to generic `Rich`
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* type RichSchema = { "{locale}": { link: { a: {} } } }
|
|
257
|
+
* LocalizedRich<RichSchema, "link"> // => { a: {} }
|
|
258
|
+
* LocalizedRich<RichSchema, "missing">; // => Rich
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
type LocalizedRich<RichSchema, K extends string> = RichSchema extends {
|
|
262
|
+
"{locale}": infer LM;
|
|
263
|
+
} ? IsNever<AtPath<LM, K>> extends true ? Rich : AtPath<LM, K> extends MessageObject ? AtPath<LM, K> : Rich : Rich;
|
|
264
|
+
/**
|
|
265
|
+
* Rich tag map resolved under a scoped prefix key.
|
|
266
|
+
*
|
|
267
|
+
* Internally composes the full dot-path (`"${PK}.${K}"`)
|
|
268
|
+
* and delegates resolution to `LocalizedRich`.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* type RichSchema = { "{locale}": { app: { link: { a: {} } } } };
|
|
273
|
+
* ScopedRich<RichSchema, "app", "link">; // => { a: {} }
|
|
274
|
+
* ScopedRich<RichSchema, "app", "missing">; // => Rich
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
type ScopedRich<RichSchema, PK extends string | undefined, K extends string> = LocalizedRich<RichSchema, `${PK}.${K}`>;
|
|
278
|
+
|
|
242
279
|
/**
|
|
243
280
|
* Options for initializing a translator
|
|
244
281
|
*
|
|
@@ -530,4 +567,4 @@ interface Renderer<Output> {
|
|
|
530
567
|
*/
|
|
531
568
|
declare function renderRichMessage<Output>(message: MessageValue, renderer: Renderer<Output>): Output[];
|
|
532
569
|
|
|
533
|
-
export { type ASTNode, type AtPath, type Attributes, type FallbackLocalesMap, type FormatHandler, type GeneratePaths, type HandlerContext, type IfLocaleMessages, type IfMessageObject, type Key, type LoadingHandler, type Locale, type LocaleMessages, type LocalizedKey, type LocalizedPreKey, type LocalizedReplacement, type LocalizedValue, type MessageObject, type MessageValue, type MissingHandler, type PreKey, type Renderer, type Replacement, type ScopedKey, type ScopedReplacement, type ScopedValue, type Token, type TranslateConfig, type TranslateContext, type TranslateHandlers, type TranslateHook, ScopeTranslator as Translator, type ScopeTranslatorMethods as TranslatorMethods, type ScopeTranslatorOptions as TranslatorOptions, type TranslatorPlugin, type Value, parseRichMessage, renderRichMessage, tokenize };
|
|
570
|
+
export { type ASTNode, type AtPath, type Attributes, type FallbackLocalesMap, type FormatHandler, type GeneratePaths, type HandlerContext, type IfLocaleMessages, type IfMessageObject, type Key, type LoadingHandler, type Locale, type LocaleMessages, type LocalizedKey, type LocalizedPreKey, type LocalizedReplacement, type LocalizedRich, type LocalizedValue, type MessageObject, type MessageValue, type MissingHandler, type PreKey, type Renderer, type Replacement, type Rich, type ScopedKey, type ScopedReplacement, type ScopedRich, type ScopedValue, type Token, type TranslateConfig, type TranslateContext, type TranslateHandlers, type TranslateHook, ScopeTranslator as Translator, type ScopeTranslatorMethods as TranslatorMethods, type ScopeTranslatorOptions as TranslatorOptions, type TranslatorPlugin, type Value, parseRichMessage, renderRichMessage, tokenize };
|
package/dist/index.d.ts
CHANGED
|
@@ -239,6 +239,43 @@ type LocalizedReplacement<ReplacementSchema, K extends string> = ReplacementSche
|
|
|
239
239
|
*/
|
|
240
240
|
type ScopedReplacement<ReplacementSchema, PK extends string | undefined, K extends string> = LocalizedReplacement<ReplacementSchema, `${PK}.${K}`>;
|
|
241
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Generic rich tag map used when no schema is available.
|
|
244
|
+
*
|
|
245
|
+
* Acts as a safe fallback for dynamic or unknown rich tag shapes.
|
|
246
|
+
*/
|
|
247
|
+
type Rich = Record<string, unknown>;
|
|
248
|
+
/**
|
|
249
|
+
* Rich tag map resolved from a localized rich schema.
|
|
250
|
+
*
|
|
251
|
+
* - If the key exists in the schema, resolves to the declared tag map
|
|
252
|
+
* - Otherwise falls back to generic `Rich`
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* type RichSchema = { "{locale}": { link: { a: {} } } }
|
|
257
|
+
* LocalizedRich<RichSchema, "link"> // => { a: {} }
|
|
258
|
+
* LocalizedRich<RichSchema, "missing">; // => Rich
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
type LocalizedRich<RichSchema, K extends string> = RichSchema extends {
|
|
262
|
+
"{locale}": infer LM;
|
|
263
|
+
} ? IsNever<AtPath<LM, K>> extends true ? Rich : AtPath<LM, K> extends MessageObject ? AtPath<LM, K> : Rich : Rich;
|
|
264
|
+
/**
|
|
265
|
+
* Rich tag map resolved under a scoped prefix key.
|
|
266
|
+
*
|
|
267
|
+
* Internally composes the full dot-path (`"${PK}.${K}"`)
|
|
268
|
+
* and delegates resolution to `LocalizedRich`.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* type RichSchema = { "{locale}": { app: { link: { a: {} } } } };
|
|
273
|
+
* ScopedRich<RichSchema, "app", "link">; // => { a: {} }
|
|
274
|
+
* ScopedRich<RichSchema, "app", "missing">; // => Rich
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
type ScopedRich<RichSchema, PK extends string | undefined, K extends string> = LocalizedRich<RichSchema, `${PK}.${K}`>;
|
|
278
|
+
|
|
242
279
|
/**
|
|
243
280
|
* Options for initializing a translator
|
|
244
281
|
*
|
|
@@ -530,4 +567,4 @@ interface Renderer<Output> {
|
|
|
530
567
|
*/
|
|
531
568
|
declare function renderRichMessage<Output>(message: MessageValue, renderer: Renderer<Output>): Output[];
|
|
532
569
|
|
|
533
|
-
export { type ASTNode, type AtPath, type Attributes, type FallbackLocalesMap, type FormatHandler, type GeneratePaths, type HandlerContext, type IfLocaleMessages, type IfMessageObject, type Key, type LoadingHandler, type Locale, type LocaleMessages, type LocalizedKey, type LocalizedPreKey, type LocalizedReplacement, type LocalizedValue, type MessageObject, type MessageValue, type MissingHandler, type PreKey, type Renderer, type Replacement, type ScopedKey, type ScopedReplacement, type ScopedValue, type Token, type TranslateConfig, type TranslateContext, type TranslateHandlers, type TranslateHook, ScopeTranslator as Translator, type ScopeTranslatorMethods as TranslatorMethods, type ScopeTranslatorOptions as TranslatorOptions, type TranslatorPlugin, type Value, parseRichMessage, renderRichMessage, tokenize };
|
|
570
|
+
export { type ASTNode, type AtPath, type Attributes, type FallbackLocalesMap, type FormatHandler, type GeneratePaths, type HandlerContext, type IfLocaleMessages, type IfMessageObject, type Key, type LoadingHandler, type Locale, type LocaleMessages, type LocalizedKey, type LocalizedPreKey, type LocalizedReplacement, type LocalizedRich, type LocalizedValue, type MessageObject, type MessageValue, type MissingHandler, type PreKey, type Renderer, type Replacement, type Rich, type ScopedKey, type ScopedReplacement, type ScopedRich, type ScopedValue, type Token, type TranslateConfig, type TranslateContext, type TranslateHandlers, type TranslateHook, ScopeTranslator as Translator, type ScopeTranslatorMethods as TranslatorMethods, type ScopeTranslatorOptions as TranslatorOptions, type TranslatorPlugin, type Value, parseRichMessage, renderRichMessage, tokenize };
|