intor-translator 1.4.9 → 1.4.10
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.cjs +1 -0
- package/dist/index.d.cts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -441,6 +441,46 @@ interface RawNode {
|
|
|
441
441
|
value: Exclude<MessageValue, string>;
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
+
/** Flat semantic token produced by the message tokenizer. */
|
|
445
|
+
type Token = TextToken | TagOpenToken | TagCloseToken;
|
|
446
|
+
/** Plain text segment in the message. */
|
|
447
|
+
interface TextToken {
|
|
448
|
+
type: "text";
|
|
449
|
+
value: string;
|
|
450
|
+
position: number;
|
|
451
|
+
}
|
|
452
|
+
/** Opening semantic tag with parsed attributes. */
|
|
453
|
+
interface TagOpenToken {
|
|
454
|
+
type: "tag-open";
|
|
455
|
+
name: string;
|
|
456
|
+
attributes: Attributes;
|
|
457
|
+
position: number;
|
|
458
|
+
}
|
|
459
|
+
/** Closing semantic tag (no attributes). */
|
|
460
|
+
interface TagCloseToken {
|
|
461
|
+
type: "tag-close";
|
|
462
|
+
name: string;
|
|
463
|
+
position: number;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Tokenize a localized message string into semantic tokens.
|
|
468
|
+
*
|
|
469
|
+
* Supported syntax:
|
|
470
|
+
* - <tag>text</tag>
|
|
471
|
+
* - <tag key="value">text</tag>
|
|
472
|
+
*
|
|
473
|
+
* Notes:
|
|
474
|
+
* - Produces a flat token stream (nesting is handled in a later stage)
|
|
475
|
+
* - Tag names are identifier-like and case-sensitive
|
|
476
|
+
* - Attributes are strict key="value" pairs (double quotes only)
|
|
477
|
+
* - Variables are assumed to be interpolated beforehand
|
|
478
|
+
*
|
|
479
|
+
* This tokenizer is intentionally minimal and fail-closed:
|
|
480
|
+
* any unrecognized or partially valid syntax is treated as plain text.
|
|
481
|
+
*/
|
|
482
|
+
declare const tokenize: (message: string) => Token[];
|
|
483
|
+
|
|
444
484
|
/**
|
|
445
485
|
* Parse a rich message value into a semantic AST.
|
|
446
486
|
*
|
|
@@ -490,4 +530,4 @@ interface Renderer<Output> {
|
|
|
490
530
|
*/
|
|
491
531
|
declare function renderRichMessage<Output>(message: MessageValue, renderer: Renderer<Output>): Output[];
|
|
492
532
|
|
|
493
|
-
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 TranslateConfig, type TranslateContext, type TranslateHandlers, type TranslateHook, ScopeTranslator as Translator, type ScopeTranslatorMethods as TranslatorMethods, type ScopeTranslatorOptions as TranslatorOptions, type TranslatorPlugin, type Value, parseRichMessage, renderRichMessage };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -441,6 +441,46 @@ interface RawNode {
|
|
|
441
441
|
value: Exclude<MessageValue, string>;
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
+
/** Flat semantic token produced by the message tokenizer. */
|
|
445
|
+
type Token = TextToken | TagOpenToken | TagCloseToken;
|
|
446
|
+
/** Plain text segment in the message. */
|
|
447
|
+
interface TextToken {
|
|
448
|
+
type: "text";
|
|
449
|
+
value: string;
|
|
450
|
+
position: number;
|
|
451
|
+
}
|
|
452
|
+
/** Opening semantic tag with parsed attributes. */
|
|
453
|
+
interface TagOpenToken {
|
|
454
|
+
type: "tag-open";
|
|
455
|
+
name: string;
|
|
456
|
+
attributes: Attributes;
|
|
457
|
+
position: number;
|
|
458
|
+
}
|
|
459
|
+
/** Closing semantic tag (no attributes). */
|
|
460
|
+
interface TagCloseToken {
|
|
461
|
+
type: "tag-close";
|
|
462
|
+
name: string;
|
|
463
|
+
position: number;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Tokenize a localized message string into semantic tokens.
|
|
468
|
+
*
|
|
469
|
+
* Supported syntax:
|
|
470
|
+
* - <tag>text</tag>
|
|
471
|
+
* - <tag key="value">text</tag>
|
|
472
|
+
*
|
|
473
|
+
* Notes:
|
|
474
|
+
* - Produces a flat token stream (nesting is handled in a later stage)
|
|
475
|
+
* - Tag names are identifier-like and case-sensitive
|
|
476
|
+
* - Attributes are strict key="value" pairs (double quotes only)
|
|
477
|
+
* - Variables are assumed to be interpolated beforehand
|
|
478
|
+
*
|
|
479
|
+
* This tokenizer is intentionally minimal and fail-closed:
|
|
480
|
+
* any unrecognized or partially valid syntax is treated as plain text.
|
|
481
|
+
*/
|
|
482
|
+
declare const tokenize: (message: string) => Token[];
|
|
483
|
+
|
|
444
484
|
/**
|
|
445
485
|
* Parse a rich message value into a semantic AST.
|
|
446
486
|
*
|
|
@@ -490,4 +530,4 @@ interface Renderer<Output> {
|
|
|
490
530
|
*/
|
|
491
531
|
declare function renderRichMessage<Output>(message: MessageValue, renderer: Renderer<Output>): Output[];
|
|
492
532
|
|
|
493
|
-
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 TranslateConfig, type TranslateContext, type TranslateHandlers, type TranslateHook, ScopeTranslator as Translator, type ScopeTranslatorMethods as TranslatorMethods, type ScopeTranslatorOptions as TranslatorOptions, type TranslatorPlugin, type Value, parseRichMessage, renderRichMessage };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -515,4 +515,4 @@ function renderRichMessage(message, renderer) {
|
|
|
515
515
|
return render(nodes, renderer);
|
|
516
516
|
}
|
|
517
517
|
|
|
518
|
-
export { ScopeTranslator as Translator, parseRichMessage, renderRichMessage };
|
|
518
|
+
export { ScopeTranslator as Translator, parseRichMessage, renderRichMessage, tokenize };
|