intor 2.4.10 → 2.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.
Files changed (41) hide show
  1. package/dist/core/export/index.js +2 -6
  2. package/dist/core/export/internal/index.js +9 -0
  3. package/dist/core/src/core/constants/locale-placeholder.js +4 -0
  4. package/dist/core/src/routing/pathname/canonicalize-pathname.js +3 -3
  5. package/dist/core/src/routing/pathname/materialize-pathname.js +5 -5
  6. package/dist/core/src/routing/pathname/standardize-pathname.js +2 -2
  7. package/dist/express/src/core/constants/locale-placeholder.js +4 -0
  8. package/dist/express/src/routing/pathname/canonicalize-pathname.js +3 -3
  9. package/dist/express/src/routing/pathname/materialize-pathname.js +5 -5
  10. package/dist/express/src/routing/pathname/standardize-pathname.js +2 -2
  11. package/dist/fastify/src/core/constants/locale-placeholder.js +4 -0
  12. package/dist/fastify/src/routing/pathname/canonicalize-pathname.js +3 -3
  13. package/dist/fastify/src/routing/pathname/materialize-pathname.js +5 -5
  14. package/dist/fastify/src/routing/pathname/standardize-pathname.js +2 -2
  15. package/dist/hono/src/core/constants/locale-placeholder.js +4 -0
  16. package/dist/hono/src/routing/pathname/canonicalize-pathname.js +3 -3
  17. package/dist/hono/src/routing/pathname/materialize-pathname.js +5 -5
  18. package/dist/hono/src/routing/pathname/standardize-pathname.js +2 -2
  19. package/dist/next/src/core/constants/locale-placeholder.js +4 -0
  20. package/dist/next/src/routing/pathname/canonicalize-pathname.js +3 -3
  21. package/dist/next/src/routing/pathname/materialize-pathname.js +5 -5
  22. package/dist/next/src/routing/pathname/standardize-pathname.js +2 -2
  23. package/dist/svelte-kit/src/core/constants/locale-placeholder.js +4 -0
  24. package/dist/svelte-kit/src/routing/pathname/canonicalize-pathname.js +3 -3
  25. package/dist/svelte-kit/src/routing/pathname/materialize-pathname.js +5 -5
  26. package/dist/svelte-kit/src/routing/pathname/standardize-pathname.js +2 -2
  27. package/dist/types/export/index.d.ts +1 -2
  28. package/dist/types/export/internal/index.d.ts +5 -0
  29. package/dist/types/src/core/constants/index.d.ts +1 -1
  30. package/dist/types/src/core/constants/locale-placeholder.d.ts +1 -0
  31. package/dist/types/src/core/index.d.ts +1 -1
  32. package/dist/types/src/core/types/generated.d.ts +2 -2
  33. package/dist/types/src/server/index.d.ts +1 -1
  34. package/package.json +9 -16
  35. package/dist/core/src/core/constants/prefix-placeholder.js +0 -4
  36. package/dist/express/src/core/constants/prefix-placeholder.js +0 -4
  37. package/dist/fastify/src/core/constants/prefix-placeholder.js +0 -4
  38. package/dist/hono/src/core/constants/prefix-placeholder.js +0 -4
  39. package/dist/next/src/core/constants/prefix-placeholder.js +0 -4
  40. package/dist/svelte-kit/src/core/constants/prefix-placeholder.js +0 -4
  41. package/dist/types/src/core/constants/prefix-placeholder.d.ts +0 -1
@@ -1,14 +1,10 @@
1
- export { PREFIX_PLACEHOLDER } from '../src/core/constants/prefix-placeholder.js';
1
+ export { LOCALE_PLACEHOLDER } from '../src/core/constants/locale-placeholder.js';
2
2
  export { IntorError, IntorErrorCode } from '../src/core/error/intor-error.js';
3
- export { deepMerge } from '../src/core/utils/deep-merge.js';
4
- export { resolveLoaderOptions } from '../src/core/utils/resolve-loader-options.js';
5
3
  import 'logry';
6
4
  export { clearLoggerPool } from '../src/core/logger/global-logger-pool.js';
7
5
  import 'p-limit';
8
- export { isValidMessages } from '../src/core/messages/utils/is-valid-messages.js';
9
6
  export { mergeMessages } from '../src/core/messages/merge-messages.js';
10
- export { INTOR_MESSAGES_KIND, INTOR_MESSAGES_KIND_KEY, INTOR_PREFIX, getMessagesKind } from '../src/core/messages/internal-metadata.js';
11
- export { Translator, tokenize } from 'intor-translator';
7
+ import 'intor-translator';
12
8
  export { defineIntorConfig } from '../src/config/define-intor-config.js';
13
9
  import '../src/config/constants/cookie.js';
14
10
  export { localizePathname } from '../src/routing/pathname/localize-pathname.js';
@@ -0,0 +1,9 @@
1
+ import '../../src/core/error/intor-error.js';
2
+ export { resolveLoaderOptions } from '../../src/core/utils/resolve-loader-options.js';
3
+ import 'logry';
4
+ import 'p-limit';
5
+ export { INTOR_MESSAGES_KIND, INTOR_MESSAGES_KIND_KEY, INTOR_PREFIX, getMessagesKind } from '../../src/core/messages/internal-metadata.js';
6
+ import 'intor-translator';
7
+ export { loadMessages } from '../../src/server/messages/load-messages.js';
8
+ import 'node:path';
9
+ import 'node:fs/promises';
@@ -0,0 +1,4 @@
1
+ // Default locale placeholder
2
+ const LOCALE_PLACEHOLDER = "{locale}";
3
+
4
+ export { LOCALE_PLACEHOLDER };
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -33,8 +33,8 @@ function canonicalizePathname(rawPathname, config) {
33
33
  }
34
34
  // Detect locale segment
35
35
  const firstSegment = prefixedPathname.split("/").find(Boolean);
36
- const locale = firstSegment === PREFIX_PLACEHOLDER
37
- ? PREFIX_PLACEHOLDER
36
+ const locale = firstSegment === LOCALE_PLACEHOLDER
37
+ ? LOCALE_PLACEHOLDER
38
38
  : firstSegment && supportedLocales.includes(firstSegment)
39
39
  ? firstSegment
40
40
  : undefined;
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -27,16 +27,16 @@ const materializePathname = (standardizedPathname, config, locale) => {
27
27
  }
28
28
  // localePrefix: "all"
29
29
  if (localePrefix === "all") {
30
- return normalizePathname(standardizedPathname.replaceAll(PREFIX_PLACEHOLDER, locale));
30
+ return normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
31
31
  }
32
32
  // localePrefix: "except-default"
33
33
  if (localePrefix === "except-default") {
34
34
  return locale === config.defaultLocale
35
- ? normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""))
36
- : normalizePathname(standardizedPathname.replaceAll(PREFIX_PLACEHOLDER, locale));
35
+ ? normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""))
36
+ : normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
37
37
  }
38
38
  // localePrefix: "none"
39
- return normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""));
39
+ return normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""));
40
40
  };
41
41
 
42
42
  export { materializePathname };
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -22,7 +22,7 @@ const standardizePathname = (canonicalizedPathname, config) => {
22
22
  // Normalize each segment before join to avoid redundant slashes
23
23
  const parts = [
24
24
  normalizePathname(basePath),
25
- PREFIX_PLACEHOLDER,
25
+ LOCALE_PLACEHOLDER,
26
26
  normalizePathname(canonicalizedPathname),
27
27
  ];
28
28
  // Avoid double slashes between segments
@@ -0,0 +1,4 @@
1
+ // Default locale placeholder
2
+ const LOCALE_PLACEHOLDER = "{locale}";
3
+
4
+ export { LOCALE_PLACEHOLDER };
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -33,8 +33,8 @@ function canonicalizePathname(rawPathname, config) {
33
33
  }
34
34
  // Detect locale segment
35
35
  const firstSegment = prefixedPathname.split("/").find(Boolean);
36
- const locale = firstSegment === PREFIX_PLACEHOLDER
37
- ? PREFIX_PLACEHOLDER
36
+ const locale = firstSegment === LOCALE_PLACEHOLDER
37
+ ? LOCALE_PLACEHOLDER
38
38
  : firstSegment && supportedLocales.includes(firstSegment)
39
39
  ? firstSegment
40
40
  : undefined;
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -27,16 +27,16 @@ const materializePathname = (standardizedPathname, config, locale) => {
27
27
  }
28
28
  // localePrefix: "all"
29
29
  if (localePrefix === "all") {
30
- return normalizePathname(standardizedPathname.replaceAll(PREFIX_PLACEHOLDER, locale));
30
+ return normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
31
31
  }
32
32
  // localePrefix: "except-default"
33
33
  if (localePrefix === "except-default") {
34
34
  return locale === config.defaultLocale
35
- ? normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""))
36
- : normalizePathname(standardizedPathname.replaceAll(PREFIX_PLACEHOLDER, locale));
35
+ ? normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""))
36
+ : normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
37
37
  }
38
38
  // localePrefix: "none"
39
- return normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""));
39
+ return normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""));
40
40
  };
41
41
 
42
42
  export { materializePathname };
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -22,7 +22,7 @@ const standardizePathname = (canonicalizedPathname, config) => {
22
22
  // Normalize each segment before join to avoid redundant slashes
23
23
  const parts = [
24
24
  normalizePathname(basePath),
25
- PREFIX_PLACEHOLDER,
25
+ LOCALE_PLACEHOLDER,
26
26
  normalizePathname(canonicalizedPathname),
27
27
  ];
28
28
  // Avoid double slashes between segments
@@ -0,0 +1,4 @@
1
+ // Default locale placeholder
2
+ const LOCALE_PLACEHOLDER = "{locale}";
3
+
4
+ export { LOCALE_PLACEHOLDER };
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -33,8 +33,8 @@ function canonicalizePathname(rawPathname, config) {
33
33
  }
34
34
  // Detect locale segment
35
35
  const firstSegment = prefixedPathname.split("/").find(Boolean);
36
- const locale = firstSegment === PREFIX_PLACEHOLDER
37
- ? PREFIX_PLACEHOLDER
36
+ const locale = firstSegment === LOCALE_PLACEHOLDER
37
+ ? LOCALE_PLACEHOLDER
38
38
  : firstSegment && supportedLocales.includes(firstSegment)
39
39
  ? firstSegment
40
40
  : undefined;
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -27,16 +27,16 @@ const materializePathname = (standardizedPathname, config, locale) => {
27
27
  }
28
28
  // localePrefix: "all"
29
29
  if (localePrefix === "all") {
30
- return normalizePathname(standardizedPathname.replaceAll(PREFIX_PLACEHOLDER, locale));
30
+ return normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
31
31
  }
32
32
  // localePrefix: "except-default"
33
33
  if (localePrefix === "except-default") {
34
34
  return locale === config.defaultLocale
35
- ? normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""))
36
- : normalizePathname(standardizedPathname.replaceAll(PREFIX_PLACEHOLDER, locale));
35
+ ? normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""))
36
+ : normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
37
37
  }
38
38
  // localePrefix: "none"
39
- return normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""));
39
+ return normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""));
40
40
  };
41
41
 
42
42
  export { materializePathname };
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -22,7 +22,7 @@ const standardizePathname = (canonicalizedPathname, config) => {
22
22
  // Normalize each segment before join to avoid redundant slashes
23
23
  const parts = [
24
24
  normalizePathname(basePath),
25
- PREFIX_PLACEHOLDER,
25
+ LOCALE_PLACEHOLDER,
26
26
  normalizePathname(canonicalizedPathname),
27
27
  ];
28
28
  // Avoid double slashes between segments
@@ -0,0 +1,4 @@
1
+ // Default locale placeholder
2
+ const LOCALE_PLACEHOLDER = "{locale}";
3
+
4
+ export { LOCALE_PLACEHOLDER };
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -33,8 +33,8 @@ function canonicalizePathname(rawPathname, config) {
33
33
  }
34
34
  // Detect locale segment
35
35
  const firstSegment = prefixedPathname.split("/").find(Boolean);
36
- const locale = firstSegment === PREFIX_PLACEHOLDER
37
- ? PREFIX_PLACEHOLDER
36
+ const locale = firstSegment === LOCALE_PLACEHOLDER
37
+ ? LOCALE_PLACEHOLDER
38
38
  : firstSegment && supportedLocales.includes(firstSegment)
39
39
  ? firstSegment
40
40
  : undefined;
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -27,16 +27,16 @@ const materializePathname = (standardizedPathname, config, locale) => {
27
27
  }
28
28
  // localePrefix: "all"
29
29
  if (localePrefix === "all") {
30
- return normalizePathname(standardizedPathname.replaceAll(PREFIX_PLACEHOLDER, locale));
30
+ return normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
31
31
  }
32
32
  // localePrefix: "except-default"
33
33
  if (localePrefix === "except-default") {
34
34
  return locale === config.defaultLocale
35
- ? normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""))
36
- : normalizePathname(standardizedPathname.replaceAll(PREFIX_PLACEHOLDER, locale));
35
+ ? normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""))
36
+ : normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
37
37
  }
38
38
  // localePrefix: "none"
39
- return normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""));
39
+ return normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""));
40
40
  };
41
41
 
42
42
  export { materializePathname };
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -22,7 +22,7 @@ const standardizePathname = (canonicalizedPathname, config) => {
22
22
  // Normalize each segment before join to avoid redundant slashes
23
23
  const parts = [
24
24
  normalizePathname(basePath),
25
- PREFIX_PLACEHOLDER,
25
+ LOCALE_PLACEHOLDER,
26
26
  normalizePathname(canonicalizedPathname),
27
27
  ];
28
28
  // Avoid double slashes between segments
@@ -0,0 +1,4 @@
1
+ // Default locale placeholder
2
+ const LOCALE_PLACEHOLDER = "{locale}";
3
+
4
+ export { LOCALE_PLACEHOLDER };
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -33,8 +33,8 @@ function canonicalizePathname(rawPathname, config) {
33
33
  }
34
34
  // Detect locale segment
35
35
  const firstSegment = prefixedPathname.split("/").find(Boolean);
36
- const locale = firstSegment === PREFIX_PLACEHOLDER
37
- ? PREFIX_PLACEHOLDER
36
+ const locale = firstSegment === LOCALE_PLACEHOLDER
37
+ ? LOCALE_PLACEHOLDER
38
38
  : firstSegment && supportedLocales.includes(firstSegment)
39
39
  ? firstSegment
40
40
  : undefined;
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -27,16 +27,16 @@ const materializePathname = (standardizedPathname, config, locale) => {
27
27
  }
28
28
  // localePrefix: "all"
29
29
  if (localePrefix === "all") {
30
- return normalizePathname(standardizedPathname.replaceAll(PREFIX_PLACEHOLDER, locale));
30
+ return normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
31
31
  }
32
32
  // localePrefix: "except-default"
33
33
  if (localePrefix === "except-default") {
34
34
  return locale === config.defaultLocale
35
- ? normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""))
36
- : normalizePathname(standardizedPathname.replaceAll(PREFIX_PLACEHOLDER, locale));
35
+ ? normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""))
36
+ : normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
37
37
  }
38
38
  // localePrefix: "none"
39
- return normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""));
39
+ return normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""));
40
40
  };
41
41
 
42
42
  export { materializePathname };
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -22,7 +22,7 @@ const standardizePathname = (canonicalizedPathname, config) => {
22
22
  // Normalize each segment before join to avoid redundant slashes
23
23
  const parts = [
24
24
  normalizePathname(basePath),
25
- PREFIX_PLACEHOLDER,
25
+ LOCALE_PLACEHOLDER,
26
26
  normalizePathname(canonicalizedPathname),
27
27
  ];
28
28
  // Avoid double slashes between segments
@@ -0,0 +1,4 @@
1
+ // Default locale placeholder
2
+ const LOCALE_PLACEHOLDER = "{locale}";
3
+
4
+ export { LOCALE_PLACEHOLDER };
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -33,8 +33,8 @@ function canonicalizePathname(rawPathname, config) {
33
33
  }
34
34
  // Detect locale segment
35
35
  const firstSegment = prefixedPathname.split("/").find(Boolean);
36
- const locale = firstSegment === PREFIX_PLACEHOLDER
37
- ? PREFIX_PLACEHOLDER
36
+ const locale = firstSegment === LOCALE_PLACEHOLDER
37
+ ? LOCALE_PLACEHOLDER
38
38
  : firstSegment && supportedLocales.includes(firstSegment)
39
39
  ? firstSegment
40
40
  : undefined;
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -27,16 +27,16 @@ const materializePathname = (standardizedPathname, config, locale) => {
27
27
  }
28
28
  // localePrefix: "all"
29
29
  if (localePrefix === "all") {
30
- return normalizePathname(standardizedPathname.replaceAll(PREFIX_PLACEHOLDER, locale));
30
+ return normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
31
31
  }
32
32
  // localePrefix: "except-default"
33
33
  if (localePrefix === "except-default") {
34
34
  return locale === config.defaultLocale
35
- ? normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""))
36
- : normalizePathname(standardizedPathname.replaceAll(PREFIX_PLACEHOLDER, locale));
35
+ ? normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""))
36
+ : normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
37
37
  }
38
38
  // localePrefix: "none"
39
- return normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""));
39
+ return normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""));
40
40
  };
41
41
 
42
42
  export { materializePathname };
@@ -1,4 +1,4 @@
1
- import { PREFIX_PLACEHOLDER } from '../../core/constants/prefix-placeholder.js';
1
+ import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
2
2
  import '../../core/error/intor-error.js';
3
3
  import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
4
4
  import 'logry';
@@ -22,7 +22,7 @@ const standardizePathname = (canonicalizedPathname, config) => {
22
22
  // Normalize each segment before join to avoid redundant slashes
23
23
  const parts = [
24
24
  normalizePathname(basePath),
25
- PREFIX_PLACEHOLDER,
25
+ LOCALE_PLACEHOLDER,
26
26
  normalizePathname(canonicalizedPathname),
27
27
  ];
28
28
  // Avoid double slashes between segments
@@ -1,4 +1,3 @@
1
- export { PREFIX_PLACEHOLDER, IntorError, IntorErrorCode, deepMerge, type DeepMergeOverrideEvent, resolveLoaderOptions, clearLoggerPool, mergeMessages, isValidMessages, type MessagesReader, type MessagesReaders, INTOR_PREFIX, INTOR_MESSAGES_KIND_KEY, INTOR_MESSAGES_KIND, getMessagesKind, type IntorMessagesKind, } from "../src/core";
1
+ export { LOCALE_PLACEHOLDER, IntorError, IntorErrorCode, clearLoggerPool, mergeMessages, type MessagesReader, type MessagesReaders, type GenLocale as Locale, } from "../src/core";
2
2
  export { defineIntorConfig, type IntorRawConfig, type IntorResolvedConfig, } from "../src/config";
3
3
  export { localizePathname, type InboundContext } from "../src/routing";
4
- export { Translator, type TranslatorPlugin, type TranslateContext, type TranslateHook, type TranslateHandlers, type HandlerContext, type FormatHandler, type LoadingHandler, type MissingHandler, type LocaleMessages, type MessageObject, type MessageValue, tokenize, type Token, } from "intor-translator";
@@ -1,2 +1,7 @@
1
+ /**
2
+ * NOTE: It is not part of the public stable contract and may change without notice.
3
+ */
4
+ export { resolveLoaderOptions, type DeepMergeOverrideEvent, INTOR_PREFIX, INTOR_MESSAGES_KIND_KEY, INTOR_MESSAGES_KIND, getMessagesKind, type IntorMessagesKind, } from "../../src/core";
5
+ export { loadMessages } from "../../src/server";
1
6
  export type { GenConfigKeys, GenConfig, TranslatorInstance, } from "../../src/core";
2
7
  export type { TranslatorInstanceReact } from "../../src/client/react/translator/translator-instance";
@@ -1,2 +1,2 @@
1
- export { PREFIX_PLACEHOLDER } from "./prefix-placeholder";
1
+ export { LOCALE_PLACEHOLDER } from "./locale-placeholder";
2
2
  export { INTOR_HEADERS } from "./headers";
@@ -0,0 +1 @@
1
+ export declare const LOCALE_PLACEHOLDER = "{locale}";
@@ -1,4 +1,4 @@
1
- export { PREFIX_PLACEHOLDER, INTOR_HEADERS } from "./constants";
1
+ export { LOCALE_PLACEHOLDER, INTOR_HEADERS } from "./constants";
2
2
  export { IntorError, IntorErrorCode } from "./error";
3
3
  export { deepMerge, type PlainObject, type DeepMergeOverrideEvent, resolveLoaderOptions, parseCookieHeader, normalizePathname, normalizeCacheKey, normalizeLocale, normalizeQuery, type NormalizedQuery, } from "./utils";
4
4
  export { getLogger, clearLoggerPool } from "./logger";
@@ -1,4 +1,4 @@
1
- import type { PREFIX_PLACEHOLDER } from "../constants";
1
+ import type { LOCALE_PLACEHOLDER } from "../constants";
2
2
  import type { Locale, LocaleMessages, Replacement, Rich } from "intor-translator";
3
3
  /**
4
4
  * =================================================
@@ -40,7 +40,7 @@ type FallbackConfig = {
40
40
  */
41
41
  type ExtractGeneratedConfig<T> = T extends {
42
42
  Locales: infer L extends string;
43
- Messages: Record<typeof PREFIX_PLACEHOLDER, infer M>;
43
+ Messages: Record<typeof LOCALE_PLACEHOLDER, infer M>;
44
44
  Replacements: infer RE;
45
45
  Rich: infer RI;
46
46
  } ? {
@@ -1,4 +1,4 @@
1
1
  export { intor, type IntorValue } from "./intor";
2
- export { clearMessagesPool } from "./messages";
2
+ export { loadMessages, clearMessagesPool } from "./messages";
3
3
  export { getTranslator, type GetTranslatorParams } from "./helpers";
4
4
  export type { MessagesLoader } from "./translator";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intor",
3
- "version": "2.4.10",
3
+ "version": "2.4.12",
4
4
  "description": "The i18n library for modern JavaScript",
5
5
  "author": "Yiming Liao",
6
6
  "homepage": "https://intor.dev",
@@ -32,23 +32,20 @@
32
32
  "exports": {
33
33
  ".": {
34
34
  "import": "./dist/core/export/index.js",
35
- "types": "./dist/types/export/index.d.ts",
36
- "require": "./dist/core/export/index.js",
37
- "default": "./dist/core/export/index.js"
35
+ "types": "./dist/types/export/index.d.ts"
36
+ },
37
+ "./internal": {
38
+ "import": "./dist/core/export/internal/index.js",
39
+ "types": "./dist/types/export/internal/index.d.ts"
38
40
  },
39
41
  "./server": {
40
42
  "import": "./dist/core/export/server/index.js",
41
- "types": "./dist/types/export/server/index.d.ts",
42
- "require": "./dist/core/export/server/index.js",
43
- "default": "./dist/core/export/server/index.js"
43
+ "types": "./dist/types/export/server/index.d.ts"
44
44
  },
45
45
  "./edge": {
46
46
  "import": "./dist/core/export/edge/index.js",
47
47
  "types": "./dist/types/export/edge/index.d.ts"
48
48
  },
49
- "./internal": {
50
- "types": "./dist/types/export/internal/index.d.ts"
51
- },
52
49
  "./react": {
53
50
  "import": "./dist/react/export/react/index.js",
54
51
  "types": "./dist/types/export/react/index.d.ts"
@@ -75,15 +72,11 @@
75
72
  },
76
73
  "./express": {
77
74
  "import": "./dist/express/export/express/index.js",
78
- "types": "./dist/types/export/express/index.d.ts",
79
- "require": "./dist/express/export/express/index.js",
80
- "default": "./dist/express/export/express/index.js"
75
+ "types": "./dist/types/export/express/index.d.ts"
81
76
  },
82
77
  "./fastify": {
83
78
  "import": "./dist/fastify/export/fastify/index.js",
84
- "types": "./dist/types/export/fastify/index.d.ts",
85
- "require": "./dist/fastify/export/fastify/index.js",
86
- "default": "./dist/fastify/export/fastify/index.js"
79
+ "types": "./dist/types/export/fastify/index.d.ts"
87
80
  },
88
81
  "./hono": {
89
82
  "import": "./dist/hono/export/hono/index.js",
@@ -1,4 +0,0 @@
1
- // Default prefix placeholder
2
- const PREFIX_PLACEHOLDER = "{locale}";
3
-
4
- export { PREFIX_PLACEHOLDER };
@@ -1,4 +0,0 @@
1
- // Default prefix placeholder
2
- const PREFIX_PLACEHOLDER = "{locale}";
3
-
4
- export { PREFIX_PLACEHOLDER };
@@ -1,4 +0,0 @@
1
- // Default prefix placeholder
2
- const PREFIX_PLACEHOLDER = "{locale}";
3
-
4
- export { PREFIX_PLACEHOLDER };
@@ -1,4 +0,0 @@
1
- // Default prefix placeholder
2
- const PREFIX_PLACEHOLDER = "{locale}";
3
-
4
- export { PREFIX_PLACEHOLDER };
@@ -1,4 +0,0 @@
1
- // Default prefix placeholder
2
- const PREFIX_PLACEHOLDER = "{locale}";
3
-
4
- export { PREFIX_PLACEHOLDER };
@@ -1,4 +0,0 @@
1
- // Default prefix placeholder
2
- const PREFIX_PLACEHOLDER = "{locale}";
3
-
4
- export { PREFIX_PLACEHOLDER };
@@ -1 +0,0 @@
1
- export declare const PREFIX_PLACEHOLDER = "{locale}";