@intlayer/core 9.3.2 → 9.4.0-canary.0
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 +1 -1
- package/dist/cjs/dictionaryManipulator/index.cjs +5 -1
- package/dist/cjs/dictionaryManipulator/plainDynamicLoader.cjs +71 -0
- package/dist/cjs/dictionaryManipulator/plainDynamicLoader.cjs.map +1 -0
- package/dist/cjs/dictionaryManipulator/preloadedDynamicLoader.cjs +29 -0
- package/dist/cjs/dictionaryManipulator/preloadedDynamicLoader.cjs.map +1 -0
- package/dist/cjs/dictionaryManipulator/qualifiedDynamicLoader.cjs +4 -10
- package/dist/cjs/dictionaryManipulator/qualifiedDynamicLoader.cjs.map +1 -1
- package/dist/cjs/index.cjs +13 -2
- package/dist/cjs/localization/comparePaths.cjs +1 -1
- package/dist/cjs/localization/comparePaths.cjs.map +1 -1
- package/dist/cjs/localization/domainUtils.cjs.map +1 -1
- package/dist/cjs/localization/getHTMLTextDir.cjs +11 -10
- package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
- package/dist/cjs/localization/getLocale.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleFromPath.cjs +3 -3
- package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
- package/dist/cjs/localization/getLocalizedPath.cjs +74 -0
- package/dist/cjs/localization/getLocalizedPath.cjs.map +1 -0
- package/dist/cjs/localization/getLocalizedPath.test-d.cjs +83 -0
- package/dist/cjs/localization/getLocalizedPath.test-d.cjs.map +1 -0
- package/dist/cjs/localization/getLocalizedUrl.cjs +9 -25
- package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
- package/dist/cjs/localization/getLocalizedUrl.test-d.cjs +42 -0
- package/dist/cjs/localization/getLocalizedUrl.test-d.cjs.map +1 -0
- package/dist/cjs/localization/getPathWithoutLocale.cjs +2 -2
- package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
- package/dist/cjs/localization/getPrefix.cjs +15 -1
- package/dist/cjs/localization/getPrefix.cjs.map +1 -1
- package/dist/cjs/localization/index.cjs +7 -1
- package/dist/cjs/localization/localeDetector.cjs +5 -3
- package/dist/cjs/localization/localeDetector.cjs.map +1 -1
- package/dist/cjs/localization/localeMapper.cjs.map +1 -1
- package/dist/cjs/localization/localeResolver.cjs.map +1 -1
- package/dist/cjs/localization/resolveBrowserLocale.cjs +63 -0
- package/dist/cjs/localization/resolveBrowserLocale.cjs.map +1 -0
- package/dist/cjs/localization/rewriteUtils.cjs +26 -14
- package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
- package/dist/cjs/localization/rewriteUtils.test-d.cjs +48 -0
- package/dist/cjs/localization/rewriteUtils.test-d.cjs.map +1 -0
- package/dist/cjs/markdown/constants.cjs +3 -0
- package/dist/cjs/markdown/constants.cjs.map +1 -1
- package/dist/cjs/markdown/index.cjs +1 -0
- package/dist/cjs/markdown/utils.cjs +23 -1
- package/dist/cjs/markdown/utils.cjs.map +1 -1
- package/dist/esm/dictionaryManipulator/index.mjs +2 -1
- package/dist/esm/dictionaryManipulator/plainDynamicLoader.mjs +70 -0
- package/dist/esm/dictionaryManipulator/plainDynamicLoader.mjs.map +1 -0
- package/dist/esm/dictionaryManipulator/preloadedDynamicLoader.mjs +27 -0
- package/dist/esm/dictionaryManipulator/preloadedDynamicLoader.mjs.map +1 -0
- package/dist/esm/dictionaryManipulator/qualifiedDynamicLoader.mjs +2 -8
- package/dist/esm/dictionaryManipulator/qualifiedDynamicLoader.mjs.map +1 -1
- package/dist/esm/index.mjs +7 -4
- package/dist/esm/localization/comparePaths.mjs +1 -1
- package/dist/esm/localization/comparePaths.mjs.map +1 -1
- package/dist/esm/localization/domainUtils.mjs.map +1 -1
- package/dist/esm/localization/getHTMLTextDir.mjs +11 -10
- package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
- package/dist/esm/localization/getLocale.mjs.map +1 -1
- package/dist/esm/localization/getLocaleFromPath.mjs +4 -4
- package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
- package/dist/esm/localization/getLocalizedPath.mjs +73 -0
- package/dist/esm/localization/getLocalizedPath.mjs.map +1 -0
- package/dist/esm/localization/getLocalizedPath.test-d.mjs +83 -0
- package/dist/esm/localization/getLocalizedPath.test-d.mjs.map +1 -0
- package/dist/esm/localization/getLocalizedUrl.mjs +10 -26
- package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
- package/dist/esm/localization/getLocalizedUrl.test-d.mjs +42 -0
- package/dist/esm/localization/getLocalizedUrl.test-d.mjs.map +1 -0
- package/dist/esm/localization/getPathWithoutLocale.mjs +2 -2
- package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
- package/dist/esm/localization/getPrefix.mjs +15 -2
- package/dist/esm/localization/getPrefix.mjs.map +1 -1
- package/dist/esm/localization/index.mjs +5 -3
- package/dist/esm/localization/localeDetector.mjs +5 -3
- package/dist/esm/localization/localeDetector.mjs.map +1 -1
- package/dist/esm/localization/localeMapper.mjs.map +1 -1
- package/dist/esm/localization/localeResolver.mjs.map +1 -1
- package/dist/esm/localization/resolveBrowserLocale.mjs +61 -0
- package/dist/esm/localization/resolveBrowserLocale.mjs.map +1 -0
- package/dist/esm/localization/rewriteUtils.mjs +26 -14
- package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
- package/dist/esm/localization/rewriteUtils.test-d.mjs +48 -0
- package/dist/esm/localization/rewriteUtils.test-d.mjs.map +1 -0
- package/dist/esm/markdown/constants.mjs +3 -1
- package/dist/esm/markdown/constants.mjs.map +1 -1
- package/dist/esm/markdown/index.mjs +2 -2
- package/dist/esm/markdown/utils.mjs +24 -2
- package/dist/esm/markdown/utils.mjs.map +1 -1
- package/dist/types/dictionaryManipulator/index.d.ts +2 -1
- package/dist/types/dictionaryManipulator/plainDynamicLoader.d.ts +50 -0
- package/dist/types/dictionaryManipulator/plainDynamicLoader.d.ts.map +1 -0
- package/dist/types/dictionaryManipulator/preloadedDynamicLoader.d.ts +38 -0
- package/dist/types/dictionaryManipulator/preloadedDynamicLoader.d.ts.map +1 -0
- package/dist/types/dictionaryManipulator/qualifiedDynamicLoader.d.ts +1 -7
- package/dist/types/dictionaryManipulator/qualifiedDynamicLoader.d.ts.map +1 -1
- package/dist/types/index.d.ts +7 -4
- package/dist/types/localization/domainUtils.d.ts +2 -3
- package/dist/types/localization/domainUtils.d.ts.map +1 -1
- package/dist/types/localization/getHTMLTextDir.d.ts.map +1 -1
- package/dist/types/localization/getLocale.d.ts +2 -2
- package/dist/types/localization/getLocale.d.ts.map +1 -1
- package/dist/types/localization/getLocaleFromPath.d.ts +2 -2
- package/dist/types/localization/getLocaleFromPath.d.ts.map +1 -1
- package/dist/types/localization/getLocalizedPath.d.ts +47 -0
- package/dist/types/localization/getLocalizedPath.d.ts.map +1 -0
- package/dist/types/localization/getLocalizedPath.test-d.d.ts +1 -0
- package/dist/types/localization/getLocalizedUrl.d.ts +5 -1
- package/dist/types/localization/getLocalizedUrl.d.ts.map +1 -1
- package/dist/types/localization/getLocalizedUrl.test-d.d.ts +1 -0
- package/dist/types/localization/getPrefix.d.ts +20 -8
- package/dist/types/localization/getPrefix.d.ts.map +1 -1
- package/dist/types/localization/index.d.ts +5 -3
- package/dist/types/localization/localeDetector.d.ts +2 -1
- package/dist/types/localization/localeDetector.d.ts.map +1 -1
- package/dist/types/localization/localeMapper.d.ts +4 -5
- package/dist/types/localization/localeMapper.d.ts.map +1 -1
- package/dist/types/localization/localeResolver.d.ts +2 -3
- package/dist/types/localization/localeResolver.d.ts.map +1 -1
- package/dist/types/localization/resolveBrowserLocale.d.ts +35 -0
- package/dist/types/localization/resolveBrowserLocale.d.ts.map +1 -0
- package/dist/types/localization/rewriteUtils.d.ts +51 -11
- package/dist/types/localization/rewriteUtils.d.ts.map +1 -1
- package/dist/types/localization/rewriteUtils.test-d.d.ts +1 -0
- package/dist/types/markdown/constants.d.ts +3 -1
- package/dist/types/markdown/constants.d.ts.map +1 -1
- package/dist/types/markdown/index.d.ts +2 -2
- package/dist/types/markdown/utils.d.ts +6 -0
- package/dist/types/markdown/utils.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
2
|
+
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
|
+
import { PRELOADED_DYNAMIC_KEY } from "@intlayer/config/defaultValues";
|
|
4
|
+
//#region src/dictionaryManipulator/preloadedDynamicLoader.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The value attached under {@link PRELOADED_DYNAMIC_KEY}.
|
|
7
|
+
*
|
|
8
|
+
* `locale` is the locale the preamble resolved at module-evaluation time. It is
|
|
9
|
+
* compared against the locale the read actually asks for, so a disagreement
|
|
10
|
+
* (a client-side locale switch, or a resolution the provider overrode) falls
|
|
11
|
+
* back to loading rather than serving content in the wrong language.
|
|
12
|
+
*/
|
|
13
|
+
type PreloadedDynamicEntry = {
|
|
14
|
+
locale: LocalesValues;
|
|
15
|
+
dictionary: Dictionary;
|
|
16
|
+
};
|
|
17
|
+
/** A plain dynamic loader map that may carry a preloaded entry. */
|
|
18
|
+
type PreloadableDynamicLoaderMap = {
|
|
19
|
+
[PRELOADED_DYNAMIC_KEY]?: PreloadedDynamicEntry;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Reads the preloaded dictionary of a dynamic loader map, when one was resolved
|
|
23
|
+
* for the requested locale.
|
|
24
|
+
*
|
|
25
|
+
* Deliberately synchronous, and deliberately not routed through the suspender
|
|
26
|
+
* cache: a suspender only leaves `pending` inside a `.then` callback, so feeding
|
|
27
|
+
* it an already-resolved promise would still suspend for one microtask — long
|
|
28
|
+
* enough for a pending fallback to paint, which is the flash this whole
|
|
29
|
+
* mechanism exists to remove.
|
|
30
|
+
*
|
|
31
|
+
* @param loaderMap - Default export of a generated dynamic entry point.
|
|
32
|
+
* @param locale - Locale the caller is about to render.
|
|
33
|
+
* @returns The dictionary when it was preloaded for `locale`, else `undefined`.
|
|
34
|
+
*/
|
|
35
|
+
declare const getPreloadedDictionary: (loaderMap: unknown, locale: LocalesValues) => Dictionary | undefined;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { PRELOADED_DYNAMIC_KEY, PreloadableDynamicLoaderMap, PreloadedDynamicEntry, getPreloadedDictionary };
|
|
38
|
+
//# sourceMappingURL=preloadedDynamicLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preloadedDynamicLoader.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/preloadedDynamicLoader.ts"],"mappings":";;;;;;;;;;;;KAoBY;EACV,QAAQ;EACR,YAAY;;;KAIF;GACT,yBAAyB;;;;;;;;;;;;;;;;cAiBf,yBAAsB,oBACf,QACV,kBACP"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { Dictionary, DictionaryQualifierType, DictionarySelector } from "@intlayer/types/dictionary";
|
|
2
|
+
import { QUALIFIER_DYNAMIC_TYPES_KEY } from "@intlayer/config/defaultValues";
|
|
2
3
|
//#region src/dictionaryManipulator/qualifiedDynamicLoader.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Marker property carrying the ordered qualifier dimensions on a dynamic loader
|
|
5
|
-
* map. Its presence distinguishes a qualified group loader map (a nested tree
|
|
6
|
-
* of chunks) from a plain dynamic loader map (one chunk per `locale`). Prefixed
|
|
7
|
-
* and unlikely to collide with a real locale code.
|
|
8
|
-
*/
|
|
9
|
-
declare const QUALIFIER_DYNAMIC_TYPES_KEY = "__intlayerQualifierTypes";
|
|
10
4
|
/**
|
|
11
5
|
* A lazily-imported per-locale dictionary chunk loader.
|
|
12
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qualifiedDynamicLoader.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/qualifiedDynamicLoader.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"qualifiedDynamicLoader.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/qualifiedDynamicLoader.ts"],"mappings":";;;;;;KAuBY,gCAAgC,QAAQ;;;;;KAMxC;GACT,kBAAkB,6BAA6B;;;;;;;;;;;;;;KAetC;GACT,8BAA8B;GAC9B,iBAAiB,6BAA6B;;;;;;cAOpC,8BAA2B,mBAErC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;cAiHC,iCAAkC,SAAO;EACpD,WAAW;EACX;EACA;EACA,UAAU;EACV,YAAY,kBAAkB,SAAS,QAAQ,gBAAgB;EAC/D,YAAY,YAAY,eAAe;MACrC,UAAU;;;;;;;;;;;;cAkCD,sCAA6C,SAAO;EAC/D,WAAW;EACX;EACA;EACA,UAAU;EACV,YAAY,YAAY,eAAe;MACrC,QAAQ,UAAU"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ import { mergeDictionaries } from "./dictionaryManipulator/mergeDictionaries.js"
|
|
|
55
55
|
import { mergeQualifiedDictionaries } from "./dictionaryManipulator/mergeQualifiedDictionaries.js";
|
|
56
56
|
import { normalizeDictionaries, normalizeDictionary } from "./dictionaryManipulator/normalizeDictionary.js";
|
|
57
57
|
import { orderDictionaries } from "./dictionaryManipulator/orderDictionaries.js";
|
|
58
|
+
import { PRELOADED_DYNAMIC_KEY, PreloadableDynamicLoaderMap, PreloadedDynamicEntry, getPreloadedDictionary } from "./dictionaryManipulator/preloadedDynamicLoader.js";
|
|
58
59
|
import { COMPOSITE_ID_SEPARATOR, DEFAULT_VARIANT_ID, getDictionarySelectorCacheKey, isQualifiedDictionaryGroup, parseDictionarySelector, reconstructQualifiedEntry, resolveDictionaryArgument, resolveEffectiveVariantId, resolveProviderVariant, resolveQualifiedDictionary, serializeVariant, serializeVariantChain } from "./dictionaryManipulator/qualifiedDictionary.js";
|
|
59
60
|
import { QUALIFIER_ORDER, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getVariantIds } from "./dictionaryManipulator/qualifiedDictionaryDeclaration.js";
|
|
60
61
|
import { DynamicDictionaryLoader, QUALIFIER_DYNAMIC_TYPES_KEY, QualifiedDynamicLoaderMap, QualifiedDynamicLoaderTree, isQualifiedDynamicLoaderMap, resolveQualifiedDynamicContent, resolveQualifiedDynamicContentAsync } from "./dictionaryManipulator/qualifiedDynamicLoader.js";
|
|
@@ -78,10 +79,11 @@ import { GenerateSitemapOptions, SitemapUrlEntry, generateSitemap, generateSitem
|
|
|
78
79
|
import { getBrowserLocale } from "./localization/getBrowserLocale.js";
|
|
79
80
|
import { getHTMLTextDir } from "./localization/getHTMLTextDir.js";
|
|
80
81
|
import { getLocale } from "./localization/getLocale.js";
|
|
81
|
-
import { GetPrefixOptions, GetPrefixResult, getPrefix } from "./localization/getPrefix.js";
|
|
82
|
+
import { GetPrefixOptions, GetPrefixResult, getPrefix, isDeclaredLocale } from "./localization/getPrefix.js";
|
|
82
83
|
import { getLocaleFromPath } from "./localization/getLocaleFromPath.js";
|
|
83
84
|
import { getLocaleLang } from "./localization/getLocaleLang.js";
|
|
84
85
|
import { getLocaleName } from "./localization/getLocaleName.js";
|
|
86
|
+
import { getLocalizedPath } from "./localization/getLocalizedPath.js";
|
|
85
87
|
import { getLocalizedUrl } from "./localization/getLocalizedUrl.js";
|
|
86
88
|
import { getMultilingualUrls } from "./localization/getMultilingualUrls.js";
|
|
87
89
|
import { getPathWithoutLocale } from "./localization/getPathWithoutLocale.js";
|
|
@@ -89,12 +91,13 @@ import { localeDetector } from "./localization/localeDetector.js";
|
|
|
89
91
|
import { localeFlatMap, localeMap, localeRecord } from "./localization/localeMapper.js";
|
|
90
92
|
import { localeResolver } from "./localization/localeResolver.js";
|
|
91
93
|
import { ProxyMode, formatProxyEnabledMessage, isProxyStorageLocaleEnabled, resolveProxyMode } from "./localization/proxyMode.js";
|
|
92
|
-
import {
|
|
94
|
+
import { getPreloadLocale, resolveBrowserLocale } from "./localization/resolveBrowserLocale.js";
|
|
95
|
+
import { LocalizedPathResult, getCanonicalPath, getInternalPath, getRewritePath, getRewriteRules, resolveLocalizedPath } from "./localization/rewriteUtils.js";
|
|
93
96
|
import { validatePrefix } from "./localization/validatePrefix.js";
|
|
94
97
|
import "./localization/index.js";
|
|
95
98
|
import { BlockQuoteNode, BoldTextNode, BreakLineNode, BreakThematicNode, CodeBlockNode, CodeFencedNode, CodeInlineNode, CompileOptions, ComponentOverrides, CustomComponentNode, ElementType, EscapedTextNode, FootnoteNode, FootnoteReferenceNode, GFMTaskNode, HTMLCommentNode, HTMLNode, HTMLSelfClosingNode, HTMLTag, HeadingNode, HeadingSetextNode, ImageNode, ItalicTextNode, LinkAngleBraceNode, LinkBareURLNode, LinkNode, MarkdownContext, MarkdownOptions, MarkdownRuntime, MarkedTextNode, NestedParser, NewlineNode, OrderedListNode, ParagraphNode, ParseState, Parser, ParserResult, ReferenceImageNode, ReferenceLinkNode, ReferenceNode, RenderRuleHook, Rule, RuleOutput, Rules, StrikethroughTextNode, TableNode, TableSeparatorNode, TextNode, UnorderedListNode } from "./markdown/types.js";
|
|
96
99
|
import { MarkdownReferences, ParsedMarkdown, compile, compileWithOptions, createCompiler, parseMarkdown, renderMarkdownAst } from "./markdown/compiler.js";
|
|
97
|
-
import { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, INLINE_SKIP_R, INTERPOLATION_R, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, ListType, NAMED_CODES_TO_UNICODE, NP_TABLE_R, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, PARAGRAPH_R, Priority, PriorityValue, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, RuleType, RuleTypeValue, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex } from "./markdown/constants.js";
|
|
100
|
+
import { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, FENCE_DELIMITER_R, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, INLINE_SKIP_R, INTERPOLATION_R, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, ListType, NAMED_CODES_TO_UNICODE, NP_TABLE_R, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, PARAGRAPH_R, Priority, PriorityValue, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, RuleType, RuleTypeValue, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex } from "./markdown/constants.js";
|
|
98
101
|
import { parserFor } from "./markdown/parser.js";
|
|
99
102
|
import { createRenderer, renderFor } from "./markdown/renderer.js";
|
|
100
103
|
import { allowInline, anyScopeRegex, attributeValueToNodePropValue, blockRegex, captureNothing, cx, get, inlineRegex, normalizeAttributeKey, normalizeWhitespace, parseBlock, parseCaptureInline, parseInline, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, qualifies, renderNothing, sanitizer, simpleInlineRegex, slugify, some, startsWith, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, unquote } from "./markdown/utils.js";
|
|
@@ -114,4 +117,4 @@ import { CookieBuildAttributes, LocaleStorage, LocaleStorageClient, LocaleStorag
|
|
|
114
117
|
import { YamlRecord, YamlValue, parseYaml } from "./utils/parseYaml.js";
|
|
115
118
|
import { stringifyYaml } from "./utils/stringifyYaml.js";
|
|
116
119
|
import "./utils/index.js";
|
|
117
|
-
export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, type BlockQuoteNode, type BoldTextNode, type BreakLineNode, type BreakThematicNode, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, COMPOSITE_ID_SEPARATOR, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, CachedIntl, CachedIntl as Intl, type CodeBlockNode, type CodeFencedNode, type CodeInlineNode, type CompileOptions, type ComponentOverrides, ConditionCond, ConditionContent, ConditionContentStates, CookieBuildAttributes, type CustomComponentNode, DEFAULT_VARIANT_ID, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, DateTimePreset, DeepTransformContent, DotPath, DynamicDictionaryLoader, type ElementType, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, type EscapedTextNode, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, FileCond, type FileContent, type FileContentConstructor, type FootnoteNode, type FootnoteReferenceNode, type GFMTaskNode, GFM_TASK_R, Gender, GenderCond, GenderContent, GenderContentStates, type GenerateSitemapOptions, GetNestingResult, type GetPrefixOptions, type GetPrefixResult, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, type HTMLCommentNode, HTMLContent, HTMLContentConstructor, type HTMLNode, type HTMLSelfClosingNode, type HTMLTag, HTMLTagsType, HTMLValidationIssue, HTMLValidationResult, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, HTML_TAGS, type HeadingNode, type HeadingSetextNode, IInterpreterPlugin, IInterpreterPluginState, INLINE_SKIP_R, INTERPOLATION_R, type ImageNode, InsertionCond, InsertionContent, InsertionContentConstructor, InterpolableNode, IntlConstructorName, IsAny, type ItalicTextNode, JsonValue, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, type LinkAngleBraceNode, type LinkBareURLNode, type LinkNode, ListType, type LocaleDomainMap, LocaleStorage, LocaleStorageClient, LocaleStorageClientOptions, LocaleStorageOptions, LocaleStorageServer, LocaleStorageServerOptions, type LocalizedPathResult, MarkdownContent, MarkdownContentConstructor, type MarkdownContext, type MarkdownOptions, MarkdownReferences, type MarkdownRuntime, type HTMLValidationIssue as MarkdownValidationIssue, MarkdownValidationResult, type MarkedTextNode, MessageFormatDialect, MessageValues, NAMED_CODES_TO_UNICODE, NP_TABLE_R, NestedCond, NestedContent, NestedContentState, NestedFieldReferences, type NestedParser, type NewlineNode, NodeProps, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, type OrderedListNode, PARAGRAPH_R, type ParagraphNode, type ParseState, ParsedMarkdown, type Parser, type ParserResult, Plugins, PluralCategory, PluralCond, PluralContent, PluralContentState, PortableObject, Priority, PriorityValue, type ProxyMode, QUALIFIER_DYNAMIC_TYPES_KEY, QUALIFIER_ORDER, QualifiedDynamicLoaderMap, QualifiedDynamicLoaderTree, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, type ReferenceImageNode, type ReferenceLinkNode, type ReferenceNode, type RenderRuleHook, type Rule, type RuleOutput, RuleType, RuleTypeValue, type Rules, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, SelectCond, SelectContent, SelectContentStates, SelectSelector, type SitemapUrlEntry, type StrikethroughTextNode, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, type TableNode, type TableSeparatorNode, TaggedMessageToken, type TextNode, TranslationCond, TranslationContent, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, UnionKeys, type UnorderedListNode, VOID_HTML_ELEMENTS, ValidDotPathsFor, ValueAtKey, WrappedIntl, YamlRecord, YamlValue, allowInline, anyScopeRegex, attributeValueToNodePropValue, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, comparePaths, compile, compileWithOptions, condition as cond, conditionPlugin, createCompiler, createRenderer, currency, cx, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, fallbackPlugin, type file, type fileContent, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, formatProxyEnabledMessage, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, generateSitemap, generateSitemapUrl, get, getBasePlugins, getBrowserLocale, getCachedIntl, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getDictionarySelectorCacheKey, getDomainHostname, getDomainOrigin, getEditedContent, getEditedDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getGender, getHTML, getHTMLTextDir, getInsertion, getInsertionValues, getInternalPath, getInterpolableContent, getIntlayer, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNestedDictionaryGraph, getNestedDictionaryKeys, getNestedDictionaryReferences, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPlural, getPrefix, getReplacedValuesContent, getRewritePath, getRewriteRules, getSelect, getSplittedContent, getSplittedDictionaryContent, getTranslation, getVariantIds, html, i18nextToIntlayerFormatter, icuToIntlayerFormatter, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, interpolateMessage, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToPortableObjectFormatter, intlayerToVueI18nFormatter, isInterpolableWrapperNode, isLocaleExclusiveOnDomain, isProxyStorageLocaleEnabled, isQualifiedDictionaryGroup, isQualifiedDynamicLoaderMap, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, mergeQualifiedDictionaries, navigatePath, nesting as nest, nestedPlugin, normalizeAttributeKey, normalizeDictionaries, normalizeDictionary, normalizePath, normalizeWhitespace, number, orderDictionaries, parseBlock, parseCaptureInline, parseDictionarySelector, parseInline, parseMarkdown, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, parseTaggedMessage, parseYaml, parserFor, percentage, plural, pluralPlugin, portableObjectToIntlayerFormatter, presets, qualifies, rebuildInterpolableContent, reconstructQualifiedEntry, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderMarkdownAst, renderNothing, resolveDictionaryArgument, resolveEffectiveVariantId, resolveMessage, resolveMessageNode, resolveProviderVariant, resolveProxyMode, resolveQualifiedDictionary, resolveQualifiedDynamicContent, resolveQualifiedDynamicContentAsync, sanitizer, select, selectPlugin, serializeVariant, serializeVariantChain, setLocaleInStorage, setLocaleInStorageClient, setLocaleInStorageServer, simpleInlineRegex, slugify, some, splitInsertionTemplate, startsWith, stringifyYaml, translation as t, transformInterpolableNode, translationPlugin, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, units, unquote, updateNodeChildren, validateHTML, validateMarkdown, validatePrefix, vueI18nToIntlayerFormatter };
|
|
120
|
+
export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, type BlockQuoteNode, type BoldTextNode, type BreakLineNode, type BreakThematicNode, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, COMPOSITE_ID_SEPARATOR, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, CachedIntl, CachedIntl as Intl, type CodeBlockNode, type CodeFencedNode, type CodeInlineNode, type CompileOptions, type ComponentOverrides, ConditionCond, ConditionContent, ConditionContentStates, CookieBuildAttributes, type CustomComponentNode, DEFAULT_VARIANT_ID, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, DateTimePreset, DeepTransformContent, DotPath, DynamicDictionaryLoader, type ElementType, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, type EscapedTextNode, FENCE_DELIMITER_R, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, FileCond, type FileContent, type FileContentConstructor, type FootnoteNode, type FootnoteReferenceNode, type GFMTaskNode, GFM_TASK_R, Gender, GenderCond, GenderContent, GenderContentStates, type GenerateSitemapOptions, GetNestingResult, type GetPrefixOptions, type GetPrefixResult, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, type HTMLCommentNode, HTMLContent, HTMLContentConstructor, type HTMLNode, type HTMLSelfClosingNode, type HTMLTag, HTMLTagsType, HTMLValidationIssue, HTMLValidationResult, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, HTML_TAGS, type HeadingNode, type HeadingSetextNode, IInterpreterPlugin, IInterpreterPluginState, INLINE_SKIP_R, INTERPOLATION_R, type ImageNode, InsertionCond, InsertionContent, InsertionContentConstructor, InterpolableNode, IntlConstructorName, IsAny, type ItalicTextNode, JsonValue, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, type LinkAngleBraceNode, type LinkBareURLNode, type LinkNode, ListType, type LocaleDomainMap, LocaleStorage, LocaleStorageClient, LocaleStorageClientOptions, LocaleStorageOptions, LocaleStorageServer, LocaleStorageServerOptions, type LocalizedPathResult, MarkdownContent, MarkdownContentConstructor, type MarkdownContext, type MarkdownOptions, MarkdownReferences, type MarkdownRuntime, type HTMLValidationIssue as MarkdownValidationIssue, MarkdownValidationResult, type MarkedTextNode, MessageFormatDialect, MessageValues, NAMED_CODES_TO_UNICODE, NP_TABLE_R, NestedCond, NestedContent, NestedContentState, NestedFieldReferences, type NestedParser, type NewlineNode, NodeProps, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, type OrderedListNode, PARAGRAPH_R, PRELOADED_DYNAMIC_KEY, type ParagraphNode, type ParseState, ParsedMarkdown, type Parser, type ParserResult, Plugins, PluralCategory, PluralCond, PluralContent, PluralContentState, PortableObject, PreloadableDynamicLoaderMap, PreloadedDynamicEntry, Priority, PriorityValue, type ProxyMode, QUALIFIER_DYNAMIC_TYPES_KEY, QUALIFIER_ORDER, QualifiedDynamicLoaderMap, QualifiedDynamicLoaderTree, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, type ReferenceImageNode, type ReferenceLinkNode, type ReferenceNode, type RenderRuleHook, type Rule, type RuleOutput, RuleType, RuleTypeValue, type Rules, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, SelectCond, SelectContent, SelectContentStates, SelectSelector, type SitemapUrlEntry, type StrikethroughTextNode, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, type TableNode, type TableSeparatorNode, TaggedMessageToken, type TextNode, TranslationCond, TranslationContent, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, UnionKeys, type UnorderedListNode, VOID_HTML_ELEMENTS, ValidDotPathsFor, ValueAtKey, WrappedIntl, YamlRecord, YamlValue, allowInline, anyScopeRegex, attributeValueToNodePropValue, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, comparePaths, compile, compileWithOptions, condition as cond, conditionPlugin, createCompiler, createRenderer, currency, cx, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, fallbackPlugin, type file, type fileContent, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, formatProxyEnabledMessage, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, generateSitemap, generateSitemapUrl, get, getBasePlugins, getBrowserLocale, getCachedIntl, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getDictionarySelectorCacheKey, getDomainHostname, getDomainOrigin, getEditedContent, getEditedDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getGender, getHTML, getHTMLTextDir, getInsertion, getInsertionValues, getInternalPath, getInterpolableContent, getIntlayer, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNestedDictionaryGraph, getNestedDictionaryKeys, getNestedDictionaryReferences, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPlural, getPrefix, getPreloadLocale, getPreloadedDictionary, getReplacedValuesContent, getRewritePath, getRewriteRules, getSelect, getSplittedContent, getSplittedDictionaryContent, getTranslation, getVariantIds, html, i18nextToIntlayerFormatter, icuToIntlayerFormatter, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, interpolateMessage, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToPortableObjectFormatter, intlayerToVueI18nFormatter, isDeclaredLocale, isInterpolableWrapperNode, isLocaleExclusiveOnDomain, isProxyStorageLocaleEnabled, isQualifiedDictionaryGroup, isQualifiedDynamicLoaderMap, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, mergeQualifiedDictionaries, navigatePath, nesting as nest, nestedPlugin, normalizeAttributeKey, normalizeDictionaries, normalizeDictionary, normalizePath, normalizeWhitespace, number, orderDictionaries, parseBlock, parseCaptureInline, parseDictionarySelector, parseInline, parseMarkdown, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, parseTaggedMessage, parseYaml, parserFor, percentage, plural, pluralPlugin, portableObjectToIntlayerFormatter, presets, qualifies, rebuildInterpolableContent, reconstructQualifiedEntry, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderMarkdownAst, renderNothing, resolveBrowserLocale, resolveDictionaryArgument, resolveEffectiveVariantId, resolveLocalizedPath, resolveMessage, resolveMessageNode, resolveProviderVariant, resolveProxyMode, resolveQualifiedDictionary, resolveQualifiedDynamicContent, resolveQualifiedDynamicContentAsync, sanitizer, select, selectPlugin, serializeVariant, serializeVariantChain, setLocaleInStorage, setLocaleInStorageClient, setLocaleInStorageServer, simpleInlineRegex, slugify, some, splitInsertionTemplate, startsWith, stringifyYaml, translation as t, transformInterpolableNode, translationPlugin, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, units, unquote, updateNodeChildren, validateHTML, validateMarkdown, validatePrefix, vueI18nToIntlayerFormatter };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { Locale } from "@intlayer/types/allLocales";
|
|
1
|
+
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
2
|
import { RoutingConfig } from "@intlayer/types/config";
|
|
4
3
|
//#region src/localization/domainUtils.d.ts
|
|
5
4
|
/**
|
|
@@ -52,7 +51,7 @@ declare const getDomainOrigin: (domain: string) => string;
|
|
|
52
51
|
* @param domains - The configured locale → domain map.
|
|
53
52
|
* @returns The exclusively mapped locale, or `undefined`.
|
|
54
53
|
*/
|
|
55
|
-
declare const getLocaleFromDomain: (hostname: string, domains: LocaleDomainMap) =>
|
|
54
|
+
declare const getLocaleFromDomain: (hostname: string, domains: LocaleDomainMap) => DeclaredLocales | undefined;
|
|
56
55
|
/**
|
|
57
56
|
* Checks whether a locale is the only locale mapped to its configured domain.
|
|
58
57
|
* When true, the domain alone identifies the locale and no URL prefix is needed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domainUtils.d.ts","names":[],"sources":["../../../src/localization/domainUtils.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"domainUtils.d.ts","names":[],"sources":["../../../src/localization/domainUtils.ts"],"mappings":";;;;;;;KAUY,kBAAkB;;;;;;;;;;;;;;cAejB,oBAAiB;;;;;;;;;;;;;;;cAsBjB,kBAAe;;;;;;;;;;;;;;;;;cAmBf,sBAAmB,kBACd,SACP,oBACR;;;;;;;;;;;cAuBU,4BAAyB,QAC5B,eAAa,SACZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHTMLTextDir.d.ts","names":[],"sources":["../../../src/localization/getHTMLTextDir.ts"],"mappings":";;KAEK;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getHTMLTextDir.d.ts","names":[],"sources":["../../../src/localization/getHTMLTextDir.ts"],"mappings":";;KAEK;;;;;;;;;;;;;;cA0BQ,iBAAc,SAAa,kBAAgB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
2
2
|
//#region src/localization/getLocale.d.ts
|
|
3
3
|
type RequestContext = {
|
|
4
4
|
getHeader?: (name: string) => string | null | undefined;
|
|
5
5
|
getCookie?: (name: string) => string | null | undefined;
|
|
6
6
|
};
|
|
7
|
-
declare const getLocale: (ctx?: RequestContext) => Promise<
|
|
7
|
+
declare const getLocale: (ctx?: RequestContext) => Promise<DeclaredLocales>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { RequestContext, getLocale };
|
|
10
10
|
//# sourceMappingURL=getLocale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocale.d.ts","names":[],"sources":["../../../src/localization/getLocale.ts"],"mappings":";;KAOY;EACV,aAAa;EACb,aAAa;;cAGF,YAAS,
|
|
1
|
+
{"version":3,"file":"getLocale.d.ts","names":[],"sources":["../../../src/localization/getLocale.ts"],"mappings":";;KAOY;EACV,aAAa;EACb,aAAa;;cAGF,YAAS,MACf,mBACJ,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RoutingOptions } from "./getPrefix.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
3
3
|
//#region src/localization/getLocaleFromPath.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Extracts the locale segment from the given URL or pathname based on the routing mode.
|
|
@@ -13,7 +13,7 @@ import { Locale } from "@intlayer/types/allLocales";
|
|
|
13
13
|
* @param inputUrl - The complete URL string or pathname to process.
|
|
14
14
|
* @returns The detected locale, default locale (if fallback/implicit), or undefined.
|
|
15
15
|
*/
|
|
16
|
-
declare const getLocaleFromPath: (inputUrl?: string, options?: RoutingOptions) =>
|
|
16
|
+
declare const getLocaleFromPath: (inputUrl?: string, options?: RoutingOptions) => DeclaredLocales | undefined;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { getLocaleFromPath };
|
|
19
19
|
//# sourceMappingURL=getLocaleFromPath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocaleFromPath.d.ts","names":[],"sources":["../../../src/localization/getLocaleFromPath.ts"],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getLocaleFromPath.d.ts","names":[],"sources":["../../../src/localization/getLocaleFromPath.ts"],"mappings":";;;;;;;;;;;;;;;cAoBa,oBAAiB,mBACZ,UACN,mBACT"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { RoutingOptions } from "./getPrefix.js";
|
|
2
|
+
import { LocalesValues, LocalizedPathname, ResolvedDefaultLocale } from "@intlayer/types/module_augmentation";
|
|
3
|
+
//#region src/localization/getLocalizedPath.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Localizes an application path for a locale: resolves the `routing.rewrite`
|
|
6
|
+
* rules, then applies the locale representation of the routing mode — a path
|
|
7
|
+
* prefix, a `locale` search parameter, or nothing at all.
|
|
8
|
+
*
|
|
9
|
+
* Any query string and hash of the input are preserved.
|
|
10
|
+
*
|
|
11
|
+
* This is the relative half of {@link getLocalizedUrl}, which builds on it to
|
|
12
|
+
* add an origin and cross-domain routing. For a relative input both return the
|
|
13
|
+
* same value; this one never returns an absolute URL — the origin of an
|
|
14
|
+
* absolute input is dropped and only its path is localized.
|
|
15
|
+
*
|
|
16
|
+
* Use `resolveLocalizedPath` instead to apply the rewrite rules alone, without
|
|
17
|
+
* any locale representation.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* // routing: { mode: 'prefix-no-default', rewrite: { '/about': { fr: '/a-propos' } } }
|
|
22
|
+
* getLocalizedPath('/about', 'fr'); // '/fr/a-propos'
|
|
23
|
+
* getLocalizedPath('/about', 'en'); // '/about' (default locale, no prefix)
|
|
24
|
+
* getLocalizedPath('/', 'fr'); // '/fr'
|
|
25
|
+
* getLocalizedPath('/contact', 'fr'); // '/fr/contact' (no rewrite rule matches)
|
|
26
|
+
* getLocalizedPath('https://intlayer.org/about', 'fr'); // '/fr/a-propos' (origin dropped)
|
|
27
|
+
*
|
|
28
|
+
* // Manual rules, bypassing the configuration
|
|
29
|
+
* getLocalizedPath('/contact', 'fr', {
|
|
30
|
+
* rewrite: { '/contact': { fr: '/contactez-nous' } },
|
|
31
|
+
* });
|
|
32
|
+
* // '/fr/contactez-nous'
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @param canonicalPath - The internal application path (e.g. `/about`, `/product/123`).
|
|
36
|
+
* An absolute URL is accepted; only its path, query and hash are kept.
|
|
37
|
+
* @param locale - The target locale. Defaults to the configured default locale.
|
|
38
|
+
* @param options - Routing overrides (`locales`, `defaultLocale`, `mode`, `rewrite`,
|
|
39
|
+
* `domains`). Each one defaults to the project configuration. `domains` only
|
|
40
|
+
* suppresses the prefix of a locale served from its own domain — the origin
|
|
41
|
+
* itself is never emitted.
|
|
42
|
+
* @returns The localized path for the target locale.
|
|
43
|
+
*/
|
|
44
|
+
declare const getLocalizedPath: <const CanonicalPath extends string, const CurrentLocale extends LocalesValues = ResolvedDefaultLocale>(canonicalPath: CanonicalPath, locale?: CurrentLocale, options?: RoutingOptions) => LocalizedPathname<CanonicalPath, CurrentLocale>;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { getLocalizedPath };
|
|
47
|
+
//# sourceMappingURL=getLocalizedPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocalizedPath.d.ts","names":[],"sources":["../../../src/localization/getLocalizedPath.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2Da,yBACL,oCACA,sBAAsB,gBAAgB,uBAAqB,eAElD,eAAa,SACpB,eAAa,UACZ,mBACR,kBAAkB,eAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -7,6 +7,10 @@ import { LocalesValues, LocalizedUrl, ResolvedDefaultLocale } from "@intlayer/ty
|
|
|
7
7
|
*
|
|
8
8
|
* This function gets the locales, default locale, and routing mode from the configuration if not provided.
|
|
9
9
|
*
|
|
10
|
+
* The path itself is localized by {@link getLocalizedPath}; this function only
|
|
11
|
+
* resolves the origin to put in front of it — the one of an absolute input, or
|
|
12
|
+
* the domain mapped to the target locale.
|
|
13
|
+
*
|
|
10
14
|
* Example:
|
|
11
15
|
*
|
|
12
16
|
* ```ts
|
|
@@ -47,5 +51,5 @@ import { LocalesValues, LocalizedUrl, ResolvedDefaultLocale } from "@intlayer/ty
|
|
|
47
51
|
*/
|
|
48
52
|
declare const getLocalizedUrl: <const T extends string, const L extends LocalesValues = ResolvedDefaultLocale>(url: T, currentLocale?: L, options?: RoutingOptions) => LocalizedUrl<T, L>;
|
|
49
53
|
//#endregion
|
|
50
|
-
export {
|
|
54
|
+
export { getLocalizedUrl };
|
|
51
55
|
//# sourceMappingURL=getLocalizedUrl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocalizedUrl.d.ts","names":[],"sources":["../../../src/localization/getLocalizedUrl.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getLocalizedUrl.d.ts","names":[],"sources":["../../../src/localization/getLocalizedUrl.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2Da,wBACL,wBACA,UAAU,gBAAgB,uBAAqB,KAEhD,GAAC,gBACS,GAAC,UACP,mBACR,aAAa,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DeclaredLocales, LocalesValues, ResolvedDefaultLocale, ResolvedRoutingMode } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import {
|
|
3
|
-
import { RoutingConfig } from "@intlayer/types/config";
|
|
2
|
+
import { RewriteRules, RoutingConfig } from "@intlayer/types/config";
|
|
4
3
|
//#region src/localization/getPrefix.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Shared routing options used across all URL localization functions.
|
|
@@ -9,7 +8,7 @@ type RoutingOptions = {
|
|
|
9
8
|
locales?: LocalesValues[];
|
|
10
9
|
defaultLocale?: LocalesValues;
|
|
11
10
|
mode?: RoutingConfig['mode'];
|
|
12
|
-
rewrite?: RoutingConfig['rewrite'];
|
|
11
|
+
rewrite?: RoutingConfig['rewrite'] | RewriteRules;
|
|
13
12
|
domains?: RoutingConfig['domains'];
|
|
14
13
|
/**
|
|
15
14
|
* The hostname of the page currently being rendered (e.g. `'intlayer.org'`).
|
|
@@ -29,12 +28,25 @@ type RoutingOptions = {
|
|
|
29
28
|
* Single source of truth for default routing config resolution across all localization functions.
|
|
30
29
|
*/
|
|
31
30
|
declare const resolveRoutingConfig: (options?: RoutingOptions) => Omit<RoutingOptions, 'defaultLocale' | 'mode' | 'locales'> & {
|
|
32
|
-
defaultLocale:
|
|
31
|
+
defaultLocale: DeclaredLocales;
|
|
33
32
|
mode: RoutingConfig['mode'];
|
|
34
|
-
locales:
|
|
33
|
+
locales: DeclaredLocales[];
|
|
35
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Narrows an arbitrary string to a declared locale by membership test.
|
|
37
|
+
*
|
|
38
|
+
* `locales` is typed as `DeclaredLocales[]`, so a plain `includes` rejects the
|
|
39
|
+
* `string` values that actually need testing (a URL segment, a query param, a
|
|
40
|
+
* stored value). This keeps the check honest and hands back a narrowed type
|
|
41
|
+
* instead of forcing a cast at every call site.
|
|
42
|
+
*
|
|
43
|
+
* @param value - The candidate locale, from a URL segment / storage / header.
|
|
44
|
+
* @param locales - The locales declared by the configuration.
|
|
45
|
+
* @returns Whether `value` is one of the declared locales.
|
|
46
|
+
*/
|
|
47
|
+
declare const isDeclaredLocale: (value: LocalesValues | undefined | null, locales?: readonly LocalesValues[]) => value is DeclaredLocales;
|
|
36
48
|
type GetPrefixOptions = {
|
|
37
|
-
defaultLocale?:
|
|
49
|
+
defaultLocale?: ResolvedDefaultLocale;
|
|
38
50
|
mode?: RoutingConfig['mode'];
|
|
39
51
|
};
|
|
40
52
|
type GetPrefixResult = {
|
|
@@ -46,7 +58,7 @@ type GetPrefixResult = {
|
|
|
46
58
|
/**
|
|
47
59
|
* The bare locale identifier (e.g. `'fr'`), or `undefined` when no prefix is applied.
|
|
48
60
|
*/
|
|
49
|
-
localePrefix:
|
|
61
|
+
localePrefix: DeclaredLocales | undefined;
|
|
50
62
|
};
|
|
51
63
|
/**
|
|
52
64
|
* Narrowed return type for {@link getPrefix} that carries the locale literal through.
|
|
@@ -108,5 +120,5 @@ type GetPrefixResultNarrowed<L extends LocalesValues | undefined, Mode extends s
|
|
|
108
120
|
*/
|
|
109
121
|
declare const getPrefix: <const L extends LocalesValues | undefined>(locale: L, options?: RoutingOptions) => GetPrefixResultNarrowed<L>;
|
|
110
122
|
//#endregion
|
|
111
|
-
export { GetPrefixOptions, GetPrefixResult, GetPrefixResultNarrowed, RoutingOptions, getPrefix, resolveRoutingConfig };
|
|
123
|
+
export { GetPrefixOptions, GetPrefixResult, GetPrefixResultNarrowed, RoutingOptions, getPrefix, isDeclaredLocale, resolveRoutingConfig };
|
|
112
124
|
//# sourceMappingURL=getPrefix.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrefix.d.ts","names":[],"sources":["../../../src/localization/getPrefix.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPrefix.d.ts","names":[],"sources":["../../../src/localization/getPrefix.ts"],"mappings":";;;;;;KAkBY;EACV,UAAU;EACV,gBAAgB;EAChB,OAAO;EACP,UAAU,2BAA2B;EACrC,UAAU;;;;;;;;;;;;EAYV;;;;;;cAOW,uBAAoB,UACtB,mBACR,KAAK;EACN,eAAe;EACf,MAAM;EACN,SAAS;;;;;;;;;;;;;;cAsBE,mBAAgB,OACpB,kCAAgC,mBACpB,oBAClB,SAAS;KAGA;EACV,gBAAgB;EAChB,OAAO;;KAGG;;;;;EAKV;;;;EAIA,cAAc;;;;;;;;;;;KAYJ,wBACV,UAAU,2BACV,sBAAsB,qBACtB,gBAAgB,gBAAgB,yBAC9B,qCACkB,KAChB,wBAAwB,iBAAiB,MAAM,6BAC7B,QAChB,kBACA;EACI,WAAW;EAAM,cAAc;IACjC,mCACE,UAAU;EACN;EAAY;;EACZ,WAAW;EAAM,cAAc;;EACjC;EAAY;;EACpB;EAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmCL,kBAAmB,UAAU,2BAAyB,QACzD,GAAC,UACA,mBACR,wBAAwB"}
|
|
@@ -4,10 +4,11 @@ import { GenerateSitemapOptions, SitemapUrlEntry, generateSitemap, generateSitem
|
|
|
4
4
|
import { getBrowserLocale } from "./getBrowserLocale.js";
|
|
5
5
|
import { getHTMLTextDir } from "./getHTMLTextDir.js";
|
|
6
6
|
import { getLocale } from "./getLocale.js";
|
|
7
|
-
import { GetPrefixOptions, GetPrefixResult, getPrefix } from "./getPrefix.js";
|
|
7
|
+
import { GetPrefixOptions, GetPrefixResult, getPrefix, isDeclaredLocale } from "./getPrefix.js";
|
|
8
8
|
import { getLocaleFromPath } from "./getLocaleFromPath.js";
|
|
9
9
|
import { getLocaleLang } from "./getLocaleLang.js";
|
|
10
10
|
import { getLocaleName } from "./getLocaleName.js";
|
|
11
|
+
import { getLocalizedPath } from "./getLocalizedPath.js";
|
|
11
12
|
import { getLocalizedUrl } from "./getLocalizedUrl.js";
|
|
12
13
|
import { getMultilingualUrls } from "./getMultilingualUrls.js";
|
|
13
14
|
import { getPathWithoutLocale } from "./getPathWithoutLocale.js";
|
|
@@ -15,6 +16,7 @@ import { localeDetector } from "./localeDetector.js";
|
|
|
15
16
|
import { localeFlatMap, localeMap, localeRecord } from "./localeMapper.js";
|
|
16
17
|
import { localeResolver } from "./localeResolver.js";
|
|
17
18
|
import { ProxyMode, formatProxyEnabledMessage, isProxyStorageLocaleEnabled, resolveProxyMode } from "./proxyMode.js";
|
|
18
|
-
import {
|
|
19
|
+
import { getPreloadLocale, resolveBrowserLocale } from "./resolveBrowserLocale.js";
|
|
20
|
+
import { LocalizedPathResult, getCanonicalPath, getInternalPath, getRewritePath, getRewriteRules, resolveLocalizedPath } from "./rewriteUtils.js";
|
|
19
21
|
import { validatePrefix } from "./validatePrefix.js";
|
|
20
|
-
export { type GenerateSitemapOptions, type GetPrefixOptions, type GetPrefixResult, type LocaleDomainMap, type LocalizedPathResult, type ProxyMode, type SitemapUrlEntry, comparePaths, formatProxyEnabledMessage, generateSitemap, generateSitemapUrl, getBrowserLocale, getCanonicalPath, getDomainHostname, getDomainOrigin, getHTMLTextDir, getInternalPath, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedPath, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, getRewritePath, getRewriteRules, isLocaleExclusiveOnDomain, isProxyStorageLocaleEnabled, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, normalizePath, resolveProxyMode, validatePrefix };
|
|
22
|
+
export { type GenerateSitemapOptions, type GetPrefixOptions, type GetPrefixResult, type LocaleDomainMap, type LocalizedPathResult, type ProxyMode, type SitemapUrlEntry, comparePaths, formatProxyEnabledMessage, generateSitemap, generateSitemapUrl, getBrowserLocale, getCanonicalPath, getDomainHostname, getDomainOrigin, getHTMLTextDir, getInternalPath, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedPath, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, getPreloadLocale, getRewritePath, getRewriteRules, isDeclaredLocale, isLocaleExclusiveOnDomain, isProxyStorageLocaleEnabled, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, normalizePath, resolveBrowserLocale, resolveLocalizedPath, resolveProxyMode, validatePrefix };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
1
2
|
import { Locale } from "@intlayer/types/allLocales";
|
|
2
3
|
//#region src/localization/localeDetector.d.ts
|
|
3
4
|
/**
|
|
@@ -11,7 +12,7 @@ declare const getPreferredLanguages: (acceptHeader: string | undefined, availabl
|
|
|
11
12
|
* Headers are provided by the browser/client and can be used to determine the user's preferred language.
|
|
12
13
|
* This function intersects the user's `Accept-Language` header with the application's available locales.
|
|
13
14
|
*/
|
|
14
|
-
declare const localeDetector: (headers: Record<string, string | undefined>, availableLocales?: Locale[], defaultLocale?: Locale) =>
|
|
15
|
+
declare const localeDetector: (headers: Record<string, string | undefined>, availableLocales?: Locale[], defaultLocale?: Locale) => DeclaredLocales;
|
|
15
16
|
//#endregion
|
|
16
17
|
export { getPreferredLanguages, localeDetector };
|
|
17
18
|
//# sourceMappingURL=localeDetector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeDetector.d.ts","names":[],"sources":["../../../src/localization/localeDetector.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"localeDetector.d.ts","names":[],"sources":["../../../src/localization/localeDetector.ts"],"mappings":";;;;;;;cAqNa,wBAAqB,kCACA;;;;;;;cAgCrB,iBAAc,SAChB,oCAAkC,mBACxB,UAAQ,gBACX,WACf"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { Locale } from "@intlayer/types/allLocales";
|
|
1
|
+
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
2
|
//#region src/localization/localeMapper.d.ts
|
|
4
3
|
type LocaleData = {
|
|
5
|
-
locale:
|
|
6
|
-
defaultLocale:
|
|
4
|
+
locale: DeclaredLocales;
|
|
5
|
+
defaultLocale: DeclaredLocales;
|
|
7
6
|
isDefault: boolean;
|
|
8
|
-
locales:
|
|
7
|
+
locales: DeclaredLocales[];
|
|
9
8
|
urlPrefix: string;
|
|
10
9
|
};
|
|
11
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeMapper.d.ts","names":[],"sources":["../../../src/localization/localeMapper.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"localeMapper.d.ts","names":[],"sources":["../../../src/localization/localeMapper.ts"],"mappings":";;KAQY;EACV,QAAQ;EACR,eAAe;EACf;EACA,SAAS;EACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA6BW,YAAa,GAAC,SAChB,QAAQ,eAAe,GAAC,UACxB,iBAAe,gBACT,eAAa,8EAO3B;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwCU,gBAAiB,GAAC,SACpB,QAAQ,eAAe,KAAG,UAC1B,iBAAe,gBACT,eAAa,8EAO3B;;;;;;;;;;;;;;;;;;;;;;;;cAqCU,eAAgB,GAAC,SACnB,QAAQ,eAAe,GAAC,UACxB,iBAAe,gBACT,eAAa,8EAO3B,OAAO,eAAe"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { Locale } from "@intlayer/types/allLocales";
|
|
1
|
+
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
2
|
//#region src/localization/localeResolver.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Resolves the most specific locale from a user-provided list,
|
|
6
5
|
* or falls back to the default locale if no match is found.
|
|
7
6
|
*/
|
|
8
|
-
declare const localeResolver: (selectedLocale: LocalesValues | LocalesValues[], locales?: LocalesValues[], defaultLocale?: LocalesValues) =>
|
|
7
|
+
declare const localeResolver: (selectedLocale: LocalesValues | LocalesValues[], locales?: LocalesValues[], defaultLocale?: LocalesValues) => DeclaredLocales;
|
|
9
8
|
//#endregion
|
|
10
9
|
export { localeResolver };
|
|
11
10
|
//# sourceMappingURL=localeResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeResolver.d.ts","names":[],"sources":["../../../src/localization/localeResolver.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"localeResolver.d.ts","names":[],"sources":["../../../src/localization/localeResolver.ts"],"mappings":";;;;;;cAUa,iBAAc,gBACT,gBAAgB,iBAAe,UACtC,iBAAe,gBACT,kBACd"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { RoutingOptions } from "./getPrefix.js";
|
|
2
|
+
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
|
+
//#region src/localization/resolveBrowserLocale.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the locale of the current document outside of React.
|
|
6
|
+
*
|
|
7
|
+
* Generated dynamic entry points need the locale while they are still
|
|
8
|
+
* evaluating, long before a provider exists, so this reproduces the precedence
|
|
9
|
+
* a provider applies — URL first (which is what a router hands the provider as
|
|
10
|
+
* `locale`), then browser storage, then the configured default. Agreeing with
|
|
11
|
+
* the provider is what makes the preloaded read hit; disagreeing is safe but
|
|
12
|
+
* costs a load, since the consumer compares locales before using a preloaded
|
|
13
|
+
* dictionary.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Routing overrides, defaulting to the built configuration.
|
|
16
|
+
* @returns The resolved locale, falling back to the default locale off-browser.
|
|
17
|
+
*/
|
|
18
|
+
declare const resolveBrowserLocale: (options?: RoutingOptions) => LocalesValues;
|
|
19
|
+
/**
|
|
20
|
+
* {@link resolveBrowserLocale}, memoized for the current URL.
|
|
21
|
+
*
|
|
22
|
+
* Every generated dynamic entry point calls this as it evaluates, and an
|
|
23
|
+
* application has hundreds of them — repeating the cookie and storage reads
|
|
24
|
+
* that many times on startup is pure cost, since they cannot change while a
|
|
25
|
+
* page is being assembled.
|
|
26
|
+
*
|
|
27
|
+
* Keying the cache on the URL rather than caching forever keeps a client-side
|
|
28
|
+
* locale change honest: navigating to another locale's URL loads further
|
|
29
|
+
* chunks with that locale, instead of preloading the old one and silently
|
|
30
|
+
* falling back to an asynchronous read.
|
|
31
|
+
*/
|
|
32
|
+
declare const getPreloadLocale: () => LocalesValues;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { getPreloadLocale, resolveBrowserLocale };
|
|
35
|
+
//# sourceMappingURL=resolveBrowserLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveBrowserLocale.d.ts","names":[],"sources":["../../../src/localization/resolveBrowserLocale.ts"],"mappings":";;;;;;;;;;;;;;;;;cAoBa,uBAAoB,UACrB,mBACT;;;;;;;;;;;;;;cAqDU,wBAAuB"}
|
|
@@ -1,33 +1,73 @@
|
|
|
1
|
-
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { Locale } from "@intlayer/types/allLocales";
|
|
1
|
+
import { LocalesValues, ResolvedDefaultLocale } from "@intlayer/types/module_augmentation";
|
|
3
2
|
import { RewriteObject, RewriteRules, RoutingConfig } from "@intlayer/types/config";
|
|
4
3
|
//#region src/localization/rewriteUtils.d.ts
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Outcome of resolving a canonical path against the rewrite rules.
|
|
6
|
+
*
|
|
7
|
+
* Discriminated on `isRewritten`: when no rule matched, `path` is the very
|
|
8
|
+
* input that was passed in, so a literal input keeps its literal type. Only a
|
|
9
|
+
* rewritten path is computed at runtime and therefore widens to `string`.
|
|
10
|
+
*/
|
|
11
|
+
type LocalizedPathResult<CanonicalPath extends string = string> = {
|
|
12
|
+
path: CanonicalPath;
|
|
13
|
+
isRewritten: false;
|
|
14
|
+
} | {
|
|
6
15
|
path: string;
|
|
7
|
-
isRewritten:
|
|
16
|
+
isRewritten: true;
|
|
8
17
|
};
|
|
18
|
+
/** Adds the leading slash a path may be missing. */
|
|
19
|
+
type WithLeadingSlash<Path extends string> = Path extends `/${string}` ? Path : `/${Path}`;
|
|
20
|
+
/**
|
|
21
|
+
* Computes the locale-prefixed internal path for a path and a locale, mirroring
|
|
22
|
+
* `getInternalPath`'s runtime behaviour: an already-prefixed path is returned
|
|
23
|
+
* untouched, the root collapses to `/${Locale}` (never a trailing slash), and
|
|
24
|
+
* anything else gets the prefix prepended.
|
|
25
|
+
*
|
|
26
|
+
* Falls back to `string` for a non-literal path, where the prefixed and
|
|
27
|
+
* already-prefixed cases cannot be told apart.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* type A = InternalPath<'/about', 'fr'>; // '/fr/about'
|
|
31
|
+
* type B = InternalPath<'/', 'fr'>; // '/fr'
|
|
32
|
+
* type C = InternalPath<'/fr/about', 'fr'>; // '/fr/about' (already prefixed)
|
|
33
|
+
*/
|
|
34
|
+
type InternalPath<Path extends string, Locale extends string> = string extends Path ? string : WithLeadingSlash<Path> extends (infer Prefixed extends string) ? Prefixed extends `/${Locale}` | `/${Locale}/${string}` ? Prefixed : Prefixed extends '/' ? `/${Locale}` : `/${Locale}${Prefixed}` : never;
|
|
9
35
|
/**
|
|
10
36
|
* Normalizes legacy Record format or extracts specialized rules from RewriteObject.
|
|
37
|
+
*
|
|
38
|
+
* Idempotent: already-normalized rules are handed back untouched, so a caller
|
|
39
|
+
* holding resolved rules can pass them on without re-normalizing.
|
|
11
40
|
*/
|
|
12
|
-
declare const getRewriteRules: (rewrite: RoutingConfig['rewrite'], context?:
|
|
41
|
+
declare const getRewriteRules: <const Context extends keyof RewriteObject = 'url'>(rewrite: RoutingConfig['rewrite'] | RewriteRules, context?: Context) => RewriteRules | undefined;
|
|
13
42
|
/**
|
|
14
43
|
* Given a localized URL (e.g., "/produits/123"), finds the canonical internal path (e.g., "/products/123").
|
|
15
44
|
* If locale is provided, only check for that locale. Otherwise, check for all locales.
|
|
16
45
|
*/
|
|
17
|
-
declare const getCanonicalPath: (localizedPath:
|
|
46
|
+
declare const getCanonicalPath: <const Path extends string, const Locale extends LocalesValues = LocalesValues>(localizedPath: Path, locale?: Locale, rewriteRules?: RewriteRules) => string;
|
|
18
47
|
/**
|
|
19
|
-
* Given a canonical path (e.g., "/products/123"), finds the localized URL pattern
|
|
48
|
+
* Given a canonical path (e.g., "/products/123"), finds the localized URL pattern
|
|
49
|
+
* (e.g., "/produits/123") and reports whether a rule actually matched.
|
|
50
|
+
*
|
|
51
|
+
* Takes already-normalized rules, so callers that resolve the rules once (proxies,
|
|
52
|
+
* static emitters) can reuse them. {@link getLocalizedPath} is the user-facing
|
|
53
|
+
* counterpart: it accepts the raw `routing.rewrite` configuration, defaults to the
|
|
54
|
+
* project configuration, and returns the path alone.
|
|
55
|
+
*
|
|
56
|
+
* @param canonicalPath - The internal application path (e.g. `/product/:id`, `/about`).
|
|
57
|
+
* @param locale - The target locale. Defaults to the configured default locale.
|
|
58
|
+
* @param rewriteRules - Normalized rules, as returned by {@link getRewriteRules}.
|
|
59
|
+
* @returns The localized path, discriminated on whether a rewrite rule matched.
|
|
20
60
|
*/
|
|
21
|
-
declare const
|
|
61
|
+
declare const resolveLocalizedPath: <const CanonicalPath extends string, const Locale extends LocalesValues = ResolvedDefaultLocale>(canonicalPath: CanonicalPath, locale?: Locale, rewriteRules?: RewriteRules) => LocalizedPathResult<CanonicalPath>;
|
|
22
62
|
/**
|
|
23
63
|
* Returns the internal path for a given canonical path and locale.
|
|
24
64
|
* Ensures the locale prefix is present exactly once.
|
|
25
65
|
*/
|
|
26
|
-
declare const getInternalPath: (canonicalPath:
|
|
66
|
+
declare const getInternalPath: <const Path extends string, const Locale extends LocalesValues>(canonicalPath: Path, locale: Locale) => InternalPath<Path, Locale>;
|
|
27
67
|
/**
|
|
28
68
|
* Given a current pathname and locale, returns the pretty localized path if a rewrite rule exists and the path is not already localized.
|
|
29
69
|
*/
|
|
30
|
-
declare const getRewritePath: (pathname:
|
|
70
|
+
declare const getRewritePath: <const Path extends string, const Locale extends LocalesValues = ResolvedDefaultLocale>(pathname: Path, locale: Locale, rewrite?: RoutingConfig['rewrite']) => string | undefined;
|
|
31
71
|
//#endregion
|
|
32
|
-
export { LocalizedPathResult, getCanonicalPath, getInternalPath,
|
|
72
|
+
export { InternalPath, LocalizedPathResult, getCanonicalPath, getInternalPath, getRewritePath, getRewriteRules, resolveLocalizedPath };
|
|
33
73
|
//# sourceMappingURL=rewriteUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewriteUtils.d.ts","names":[],"sources":["../../../src/localization/rewriteUtils.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rewriteUtils.d.ts","names":[],"sources":["../../../src/localization/rewriteUtils.ts"],"mappings":";;;;;;;;;;KAkBY,oBAAoB;EAC1B,MAAM;EAAe;;EACrB;EAAc;;;KAGf,iBAAiB,uBAAuB,4BACzC,WACI;;;;;;;;;;;;;;;KAgBI,aACV,qBACA,wCACiB,gBAEf,iBAAiB,qBAAoB,2BACnC,qBAAqB,eAAe,qBAClC,WACA,2BACM,eACA,SAAS;;;;;;;cASV,wBACL,sBAAsB,uBAAqB,SAExC,2BAA2B,cAAY,UACvC,YACR;;;;;cAsFU,yBACL,2BACA,eAAe,gBAAgB,eAAa,eAEnC,MAAI,SACV,QAAM,eACA;;;;;;;;;;;;;;;cA2CJ,6BACL,oCACA,eAAe,gBAAgB,uBAAqB,eAE3C,eAAa,SACnB,QAAM,eACA,iBACd,oBAAoB;;;;;cAkCV,wBACL,2BACA,eAAe,eAAa,eAEnB,MAAI,QACX,WACP,aAAa,MAAM;;;;cAoBT,uBACL,2BACA,eAAe,gBAAgB,uBAAqB,UAEhD,MAAI,QACN,QAAM,UACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|