@intlayer/core 9.0.0-canary.1 → 9.0.0-canary.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.
Files changed (69) hide show
  1. package/dist/cjs/dictionaryManipulator/index.cjs +1 -0
  2. package/dist/cjs/dictionaryManipulator/mergeQualifiedDictionaries.cjs +1 -5
  3. package/dist/cjs/dictionaryManipulator/mergeQualifiedDictionaries.cjs.map +1 -1
  4. package/dist/cjs/dictionaryManipulator/qualifiedDictionary.cjs +48 -74
  5. package/dist/cjs/dictionaryManipulator/qualifiedDictionary.cjs.map +1 -1
  6. package/dist/cjs/index.cjs +4 -0
  7. package/dist/cjs/interpreter/getContent/plugins.cjs +8 -8
  8. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  9. package/dist/cjs/interpreter/getDictionary.cjs +5 -5
  10. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  11. package/dist/cjs/interpreter/getIntlayer.cjs +8 -3
  12. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  13. package/dist/cjs/localization/comparePaths.cjs +75 -0
  14. package/dist/cjs/localization/comparePaths.cjs.map +1 -0
  15. package/dist/cjs/localization/getLocalizedUrl.cjs +4 -4
  16. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  17. package/dist/cjs/localization/getPathWithoutLocale.cjs +2 -2
  18. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  19. package/dist/cjs/localization/getPrefix.cjs +2 -2
  20. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  21. package/dist/cjs/localization/index.cjs +3 -0
  22. package/dist/cjs/localization/rewriteUtils.cjs +1 -1
  23. package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
  24. package/dist/cjs/localization/validatePrefix.cjs +2 -2
  25. package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
  26. package/dist/cjs/utils/localeStorage.cjs +4 -4
  27. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  28. package/dist/esm/dictionaryManipulator/index.mjs +2 -2
  29. package/dist/esm/dictionaryManipulator/mergeQualifiedDictionaries.mjs +1 -5
  30. package/dist/esm/dictionaryManipulator/mergeQualifiedDictionaries.mjs.map +1 -1
  31. package/dist/esm/dictionaryManipulator/qualifiedDictionary.mjs +48 -75
  32. package/dist/esm/dictionaryManipulator/qualifiedDictionary.mjs.map +1 -1
  33. package/dist/esm/index.mjs +3 -2
  34. package/dist/esm/interpreter/getContent/plugins.mjs +8 -8
  35. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  36. package/dist/esm/interpreter/getDictionary.mjs +5 -5
  37. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  38. package/dist/esm/interpreter/getIntlayer.mjs +8 -3
  39. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  40. package/dist/esm/localization/comparePaths.mjs +73 -0
  41. package/dist/esm/localization/comparePaths.mjs.map +1 -0
  42. package/dist/esm/localization/getLocalizedUrl.mjs +4 -4
  43. package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
  44. package/dist/esm/localization/getPathWithoutLocale.mjs +2 -2
  45. package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
  46. package/dist/esm/localization/getPrefix.mjs +2 -2
  47. package/dist/esm/localization/getPrefix.mjs.map +1 -1
  48. package/dist/esm/localization/index.mjs +2 -1
  49. package/dist/esm/localization/rewriteUtils.mjs +1 -1
  50. package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
  51. package/dist/esm/localization/validatePrefix.mjs +2 -2
  52. package/dist/esm/localization/validatePrefix.mjs.map +1 -1
  53. package/dist/esm/utils/localeStorage.mjs +4 -4
  54. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  55. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +1 -2
  56. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +1 -2
  57. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +1 -2
  58. package/dist/types/dictionaryManipulator/index.d.ts +2 -2
  59. package/dist/types/dictionaryManipulator/mergeQualifiedDictionaries.d.ts +1 -1
  60. package/dist/types/dictionaryManipulator/mergeQualifiedDictionaries.d.ts.map +1 -1
  61. package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts +33 -20
  62. package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts.map +1 -1
  63. package/dist/types/index.d.ts +3 -2
  64. package/dist/types/interpreter/getDictionary.d.ts +5 -5
  65. package/dist/types/interpreter/getIntlayer.d.ts +1 -1
  66. package/dist/types/localization/comparePaths.d.ts +66 -0
  67. package/dist/types/localization/comparePaths.d.ts.map +1 -0
  68. package/dist/types/localization/index.d.ts +2 -1
  69. package/package.json +7 -7
@@ -0,0 +1,66 @@
1
+ import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
2
+
3
+ //#region src/localization/comparePaths.d.ts
4
+ /**
5
+ * Normalizes a URL or pathname into a canonical, locale-agnostic pathname so
6
+ * that two paths pointing to the same page compare equal — useful for
7
+ * highlighting the active navigation link.
8
+ *
9
+ * The normalization:
10
+ * - strips the locale segment (reusing {@link getPathWithoutLocale})
11
+ * - strips the protocol/host so absolute and relative inputs compare equally
12
+ * - drops the query string and hash
13
+ * - ensures a single leading slash
14
+ * - removes any trailing slash (except for the root path)
15
+ * - falls back to `'/'` for empty values
16
+ *
17
+ * Example:
18
+ *
19
+ * ```ts
20
+ * normalizePath('/ru/path') // '/path'
21
+ * normalizePath('/ru/path/') // '/path'
22
+ * normalizePath('ru/path') // '/path'
23
+ * normalizePath('/ru/') // '/'
24
+ * normalizePath('/ru') // '/'
25
+ * normalizePath('') // '/'
26
+ * normalizePath('https://example.com/ru/path') // '/path'
27
+ * ```
28
+ *
29
+ * @param inputUrl - The URL string or pathname to normalize.
30
+ * @param locales - Optional array of supported locales. Defaults to the
31
+ * configured locales.
32
+ * @returns The normalized, locale-agnostic pathname.
33
+ */
34
+ declare const normalizePath: <const L extends LocalesValues = DeclaredLocales>(inputUrl: string, locales?: L[]) => string;
35
+ /**
36
+ * Compares two URLs or pathnames for equality, ignoring locale segment,
37
+ * protocol/host, query string, hash and trailing slashes.
38
+ *
39
+ * Both inputs are normalized through {@link normalizePath} before comparison,
40
+ * making this ideal for matching the current pathname against a navigation
41
+ * link's `href`.
42
+ *
43
+ * Example:
44
+ *
45
+ * ```ts
46
+ * comparePaths('/ru/path', '/path') // true
47
+ * comparePaths('/ru/path/', '/path') // true
48
+ * comparePaths('/ru/path', '/path/') // true
49
+ * comparePaths('/ru/', '/') // true
50
+ * comparePaths('/ru', '/') // true
51
+ * comparePaths('ru/path', '/path') // true
52
+ * comparePaths('', '/') // true
53
+ * comparePaths('/ru', '') // true
54
+ * comparePaths('/ru/path', '/other') // false
55
+ * ```
56
+ *
57
+ * @param pathname - The first URL string or pathname to compare.
58
+ * @param href - The second URL string or pathname to compare.
59
+ * @param locales - Optional array of supported locales. Defaults to the
60
+ * configured locales.
61
+ * @returns `true` when both inputs resolve to the same locale-agnostic path.
62
+ */
63
+ declare const comparePaths: <const L extends LocalesValues = DeclaredLocales>(pathname: string, href: string, locales?: L[]) => boolean;
64
+ //#endregion
65
+ export { comparePaths, normalizePath };
66
+ //# sourceMappingURL=comparePaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comparePaths.d.ts","names":[],"sources":["../../../src/localization/comparePaths.ts"],"mappings":";;;;;AAqCA;;;;;;;;;;;;;;;;AAiDA;;;;;;;;;;;;cAjDa,aAAA,mBAAiC,aAAA,GAAgB,eAAA,EAC5D,QAAA,UACA,OAAA,GAAU,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+CC,YAAA,mBAAgC,aAAA,GAAgB,eAAA,EAC3D,QAAA,UACA,IAAA,UACA,OAAA,GAAU,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { comparePaths, normalizePath } from "./comparePaths.js";
1
2
  import { GenerateSitemapOptions, SitemapUrlEntry, generateSitemap, generateSitemapUrl } from "./generateSitemap.js";
2
3
  import { getBrowserLocale } from "./getBrowserLocale.js";
3
4
  import { getHTMLTextDir } from "./getHTMLTextDir.js";
@@ -14,4 +15,4 @@ import { localeFlatMap, localeMap, localeRecord } from "./localeMapper.js";
14
15
  import { localeResolver } from "./localeResolver.js";
15
16
  import { LocalizedPathResult, getCanonicalPath, getInternalPath, getLocalizedPath, getRewritePath, getRewriteRules } from "./rewriteUtils.js";
16
17
  import { validatePrefix } from "./validatePrefix.js";
17
- export { type GenerateSitemapOptions, type GetPrefixOptions, type GetPrefixResult, type LocalizedPathResult, type SitemapUrlEntry, generateSitemap, generateSitemapUrl, getBrowserLocale, getCanonicalPath, getHTMLTextDir, getInternalPath, getLocale, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedPath, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, getRewritePath, getRewriteRules, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, validatePrefix };
18
+ export { type GenerateSitemapOptions, type GetPrefixOptions, type GetPrefixResult, type LocalizedPathResult, type SitemapUrlEntry, comparePaths, generateSitemap, generateSitemapUrl, getBrowserLocale, getCanonicalPath, getHTMLTextDir, getInternalPath, getLocale, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedPath, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, getRewritePath, getRewriteRules, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, normalizePath, validatePrefix };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/core",
3
- "version": "9.0.0-canary.1",
3
+ "version": "9.0.0-canary.10",
4
4
  "private": false,
5
5
  "description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
6
6
  "keywords": [
@@ -172,15 +172,15 @@
172
172
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
173
173
  },
174
174
  "dependencies": {
175
- "@intlayer/api": "9.0.0-canary.1",
176
- "@intlayer/config": "9.0.0-canary.1",
177
- "@intlayer/dictionaries-entry": "9.0.0-canary.1",
178
- "@intlayer/types": "9.0.0-canary.1",
179
- "@intlayer/unmerged-dictionaries-entry": "9.0.0-canary.1",
175
+ "@intlayer/api": "9.0.0-canary.10",
176
+ "@intlayer/config": "9.0.0-canary.10",
177
+ "@intlayer/dictionaries-entry": "9.0.0-canary.10",
178
+ "@intlayer/types": "9.0.0-canary.10",
179
+ "@intlayer/unmerged-dictionaries-entry": "9.0.0-canary.10",
180
180
  "defu": "6.1.7"
181
181
  },
182
182
  "devDependencies": {
183
- "@types/node": "25.9.3",
183
+ "@types/node": "25.9.4",
184
184
  "@utils/ts-config": "1.0.4",
185
185
  "@utils/ts-config-types": "1.0.4",
186
186
  "@utils/tsdown-config": "1.0.4",