intor 2.3.15 → 2.3.16

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 (144) hide show
  1. package/dist/core/export/index.js +1 -1
  2. package/dist/core/src/routing/pathname/{get-unprefixed-pathname.js → canonicalize-pathname.js} +3 -3
  3. package/dist/core/src/routing/pathname/localize-pathname.js +15 -15
  4. package/dist/{next/src/routing/pathname/locale-prefix-pathname.js → core/src/routing/pathname/materialize-pathname.js} +6 -5
  5. package/dist/core/src/routing/pathname/standardize-pathname.js +9 -9
  6. package/dist/core/src/server/helpers/get-translator.js +0 -1
  7. package/dist/core/src/server/intor/intor.js +2 -2
  8. package/dist/core/src/server/translator/create-translator.js +0 -1
  9. package/dist/express/src/adapters/express/helpers/get-translator.js +4 -0
  10. package/dist/express/src/adapters/express/middleware/create-intor.js +3 -5
  11. package/dist/express/src/routing/inbound/resolve-pathname/resolve-pathname.js +1 -1
  12. package/dist/{next/src/routing/pathname/get-unprefixed-pathname.js → express/src/routing/pathname/canonicalize-pathname.js} +3 -3
  13. package/dist/express/src/routing/pathname/localize-pathname.js +15 -15
  14. package/dist/{core/src/routing/pathname/locale-prefix-pathname.js → express/src/routing/pathname/materialize-pathname.js} +6 -5
  15. package/dist/express/src/routing/pathname/standardize-pathname.js +9 -9
  16. package/dist/express/src/server/helpers/get-translator.js +0 -1
  17. package/dist/express/src/server/translator/create-translator.js +0 -1
  18. package/dist/next/src/adapters/next/navigation/use-pathname.js +4 -4
  19. package/dist/next/src/adapters/next/proxy/intor-proxy.js +1 -1
  20. package/dist/next/src/adapters/next/server/get-pathname.js +4 -4
  21. package/dist/next/src/adapters/next/server/get-translator.js +4 -0
  22. package/dist/next/src/adapters/next/server/intor.js +1 -1
  23. package/dist/next/src/routing/inbound/resolve-pathname/resolve-pathname.js +1 -1
  24. package/dist/next/src/routing/navigation/derive-target.js +5 -5
  25. package/dist/next/src/routing/navigation/utils/derive-host-destination.js +1 -1
  26. package/dist/next/src/routing/navigation/utils/derive-query-destination.js +1 -1
  27. package/dist/{express/src/routing/pathname/get-unprefixed-pathname.js → next/src/routing/pathname/canonicalize-pathname.js} +3 -3
  28. package/dist/next/src/routing/pathname/localize-pathname.js +15 -15
  29. package/dist/{react/src/routing/pathname/locale-prefix-pathname.js → next/src/routing/pathname/materialize-pathname.js} +6 -5
  30. package/dist/next/src/routing/pathname/standardize-pathname.js +9 -9
  31. package/dist/next/src/server/helpers/get-translator.js +0 -1
  32. package/dist/next/src/server/intor/intor.js +2 -2
  33. package/dist/next/src/server/translator/create-translator.js +0 -1
  34. package/dist/react/export/react/index.js +1 -1
  35. package/dist/react/src/client/react/navigation/use-execute-navigation.js +3 -3
  36. package/dist/react/src/client/react/provider/effects/use-locale-effects.js +5 -5
  37. package/dist/react/src/client/react/render/create-react-renderer.js +5 -0
  38. package/dist/react/src/client/react/translator/create-t-rich.js +2 -2
  39. package/dist/react/src/client/react/translator/{t.js → trans.js} +4 -4
  40. package/dist/react/src/client/react/translator/use-translator.js +0 -5
  41. package/dist/react/src/client/shared/helpers/get-client-locale.js +2 -2
  42. package/dist/react/src/client/shared/utils/locale/detect-browser-locale.js +1 -1
  43. package/dist/{vue/src/client/shared/utils/locale/get-locale-cookie-browser.js → react/src/client/shared/utils/locale/get-locale-from-cookie.js} +3 -3
  44. package/dist/react/src/client/shared/utils/locale/set-document-locale.js +2 -2
  45. package/dist/{svelte/src/client/shared/utils/locale/set-locale-cookie-browser.js → react/src/client/shared/utils/locale/set-locale-cookie.js} +4 -4
  46. package/dist/react/src/routing/navigation/derive-target.js +5 -5
  47. package/dist/react/src/routing/navigation/utils/derive-host-destination.js +1 -1
  48. package/dist/react/src/routing/navigation/utils/derive-query-destination.js +1 -1
  49. package/dist/react/src/routing/pathname/{get-unprefixed-pathname.js → canonicalize-pathname.js} +3 -3
  50. package/dist/react/src/routing/pathname/localize-pathname.js +15 -15
  51. package/dist/{express/src/routing/pathname/locale-prefix-pathname.js → react/src/routing/pathname/materialize-pathname.js} +6 -5
  52. package/dist/react/src/routing/pathname/standardize-pathname.js +9 -9
  53. package/dist/svelte/src/client/shared/helpers/get-client-locale.js +2 -2
  54. package/dist/svelte/src/client/shared/utils/locale/detect-browser-locale.js +1 -1
  55. package/dist/{react/src/client/shared/utils/locale/get-locale-cookie-browser.js → svelte/src/client/shared/utils/locale/get-locale-from-cookie.js} +3 -3
  56. package/dist/svelte/src/client/shared/utils/locale/set-document-locale.js +2 -2
  57. package/dist/{vue/src/client/shared/utils/locale/set-locale-cookie-browser.js → svelte/src/client/shared/utils/locale/set-locale-cookie.js} +4 -4
  58. package/dist/svelte/src/client/svelte/render/create-svelte-renderer.js +12 -0
  59. package/dist/svelte/src/client/svelte/runtime/create-intor-api.js +0 -4
  60. package/dist/svelte/src/client/svelte/runtime/create-intor.js +3 -14
  61. package/dist/svelte/src/client/svelte/runtime/effects/locale-effects.js +5 -5
  62. package/dist/types/export/index.d.ts +1 -1
  63. package/dist/types/export/internal/index.d.ts +2 -1
  64. package/dist/types/export/react/index.d.ts +1 -1
  65. package/dist/types/export/server/index.d.ts +1 -1
  66. package/dist/types/export/vue/index.d.ts +1 -1
  67. package/dist/types/src/adapters/express/global.d.ts +4 -5
  68. package/dist/types/src/adapters/express/helpers/get-translator.d.ts +5 -5
  69. package/dist/types/src/adapters/express/middleware/create-intor.d.ts +1 -1
  70. package/dist/types/src/adapters/next/navigation/use-pathname.d.ts +3 -3
  71. package/dist/types/src/adapters/next/proxy/intor-proxy.d.ts +1 -1
  72. package/dist/types/src/adapters/next/server/get-pathname.d.ts +3 -3
  73. package/dist/types/src/adapters/next/server/get-translator.d.ts +5 -5
  74. package/dist/types/src/adapters/next/server/intor.d.ts +3 -3
  75. package/dist/types/src/client/react/helpers/use-runtime-state.d.ts +5 -3
  76. package/dist/types/src/client/react/index.d.ts +1 -1
  77. package/dist/types/src/client/react/provider/types.d.ts +10 -9
  78. package/dist/types/src/client/react/render/create-react-renderer.d.ts +1 -0
  79. package/dist/types/src/client/react/render/render-rich-message-react.d.ts +2 -1
  80. package/dist/types/src/client/react/render/types.d.ts +15 -10
  81. package/dist/types/src/client/react/translator/index.d.ts +1 -1
  82. package/dist/types/src/client/react/translator/trans.d.ts +27 -0
  83. package/dist/types/src/client/react/translator/translator-instance.d.ts +4 -4
  84. package/dist/types/src/client/react/translator/use-translator.d.ts +4 -4
  85. package/dist/types/src/client/shared/utils/index.d.ts +1 -1
  86. package/dist/types/src/client/shared/utils/locale/detect-browser-locale.d.ts +1 -1
  87. package/dist/types/src/client/shared/utils/locale/get-locale-from-cookie.d.ts +6 -0
  88. package/dist/types/src/client/shared/utils/locale/index.d.ts +2 -2
  89. package/dist/types/src/client/shared/utils/locale/set-document-locale.d.ts +2 -2
  90. package/dist/types/src/client/shared/utils/locale/set-locale-cookie.d.ts +7 -0
  91. package/dist/types/src/client/svelte/helpers/create-runtime-state.d.ts +7 -6
  92. package/dist/types/src/client/svelte/render/render-rich-message-svelte.d.ts +2 -1
  93. package/dist/types/src/client/svelte/runtime/create-intor-api.d.ts +0 -2
  94. package/dist/types/src/client/svelte/runtime/create-intor.d.ts +1 -2
  95. package/dist/types/src/client/svelte/runtime/types.d.ts +19 -23
  96. package/dist/types/src/client/vue/helpers/use-runtime-state.d.ts +7 -6
  97. package/dist/types/src/client/vue/index.d.ts +1 -1
  98. package/dist/types/src/client/vue/provider/inject.d.ts +1 -2
  99. package/dist/types/src/client/vue/provider/resolver/resolve-runtime.d.ts +1 -1
  100. package/dist/types/src/client/vue/provider/types.d.ts +11 -11
  101. package/dist/types/src/client/vue/render/create-vue-renderer.d.ts +1 -0
  102. package/dist/types/src/client/vue/render/render-rich-message-vue.d.ts +2 -1
  103. package/dist/types/src/client/vue/render/types.d.ts +14 -6
  104. package/dist/types/src/client/vue/translator/index.d.ts +1 -1
  105. package/dist/types/src/client/vue/translator/{t.d.ts → trans.d.ts} +4 -5
  106. package/dist/types/src/client/vue/translator/translator-instance.d.ts +4 -4
  107. package/dist/types/src/client/vue/translator/use-translator.d.ts +5 -5
  108. package/dist/types/src/core/index.d.ts +1 -1
  109. package/dist/types/src/core/types/generated.d.ts +14 -5
  110. package/dist/types/src/core/types/index.d.ts +2 -3
  111. package/dist/types/src/core/types/translator-instance.d.ts +5 -21
  112. package/dist/types/src/routing/navigation/utils/derive-host-destination.d.ts +1 -1
  113. package/dist/types/src/routing/navigation/utils/derive-query-destination.d.ts +1 -1
  114. package/dist/types/src/routing/pathname/{get-unprefixed-pathname.d.ts → canonicalize-pathname.d.ts} +2 -2
  115. package/dist/types/src/routing/pathname/localize-pathname.d.ts +16 -13
  116. package/dist/types/src/routing/pathname/materialize-pathname.d.ts +17 -0
  117. package/dist/types/src/routing/pathname/standardize-pathname.d.ts +7 -6
  118. package/dist/types/src/server/helpers/get-translator.d.ts +5 -5
  119. package/dist/types/src/server/index.d.ts +1 -1
  120. package/dist/types/src/server/intor/index.d.ts +1 -1
  121. package/dist/types/src/server/intor/intor.d.ts +4 -4
  122. package/dist/types/src/server/intor/types.d.ts +5 -3
  123. package/dist/types/src/server/runtime/create-intor-runtime.d.ts +1 -2
  124. package/dist/types/src/server/runtime/types.d.ts +6 -12
  125. package/dist/types/src/server/translator/create-translator.d.ts +1 -2
  126. package/dist/types/src/server/translator/translator-instance.d.ts +3 -3
  127. package/dist/vue/export/vue/index.js +1 -1
  128. package/dist/vue/src/client/shared/helpers/get-client-locale.js +2 -2
  129. package/dist/vue/src/client/shared/utils/locale/detect-browser-locale.js +1 -1
  130. package/dist/{svelte/src/client/shared/utils/locale/get-locale-cookie-browser.js → vue/src/client/shared/utils/locale/get-locale-from-cookie.js} +3 -3
  131. package/dist/vue/src/client/shared/utils/locale/set-document-locale.js +2 -2
  132. package/dist/{react/src/client/shared/utils/locale/set-locale-cookie-browser.js → vue/src/client/shared/utils/locale/set-locale-cookie.js} +4 -4
  133. package/dist/vue/src/client/vue/provider/effects/use-locale-effects.js +5 -5
  134. package/dist/vue/src/client/vue/render/create-vue-renderer.js +5 -0
  135. package/dist/vue/src/client/vue/translator/{t.js → trans.js} +3 -3
  136. package/dist/vue/src/client/vue/translator/use-translator.js +0 -2
  137. package/package.json +2 -2
  138. package/dist/types/src/client/react/translator/t.d.ts +0 -27
  139. package/dist/types/src/client/shared/types/index.d.ts +0 -1
  140. package/dist/types/src/client/shared/types/runtime-state.d.ts +0 -13
  141. package/dist/types/src/client/shared/utils/locale/get-locale-cookie-browser.d.ts +0 -6
  142. package/dist/types/src/client/shared/utils/locale/set-locale-cookie-browser.d.ts +0 -7
  143. package/dist/types/src/core/types/bootstrap.d.ts +0 -13
  144. package/dist/types/src/routing/pathname/locale-prefix-pathname.d.ts +0 -16
@@ -10,4 +10,4 @@ export { mergeMessages } from '../src/core/messages/merge-messages.js';
10
10
  export { defineIntorConfig } from '../src/config/define-intor-config.js';
11
11
  import '../src/config/constants/cookie.js';
12
12
  export { localizePathname } from '../src/routing/pathname/localize-pathname.js';
13
- export { Translator } from 'intor-translator';
13
+ export { Translator, tokenize } from 'intor-translator';
@@ -10,11 +10,11 @@ import 'logry';
10
10
  * // config.supportedLocales: ["en-US"]
11
11
  * // config.routing.basePath: "/app"
12
12
  * // config.routing.prefix: "all"
13
- * getUnprefixedPathname(config, "/app/en-US/about" );
13
+ * canonicalizePathname("/app/en-US/about", config);
14
14
  * // => "/about"
15
15
  *```
16
16
  */
17
- function getUnprefixedPathname(config, rawPathname) {
17
+ function canonicalizePathname(rawPathname, config) {
18
18
  const { routing, supportedLocales } = config;
19
19
  const { basePath } = routing;
20
20
  // 1. Normalize pathname
@@ -38,4 +38,4 @@ function getUnprefixedPathname(config, rawPathname) {
38
38
  : prefixedPathname;
39
39
  }
40
40
 
41
- export { getUnprefixedPathname };
41
+ export { canonicalizePathname };
@@ -1,5 +1,5 @@
1
- import { getUnprefixedPathname } from './get-unprefixed-pathname.js';
2
- import { localePrefixPathname } from './locale-prefix-pathname.js';
1
+ import { canonicalizePathname } from './canonicalize-pathname.js';
2
+ import { materializePathname } from './materialize-pathname.js';
3
3
  import { standardizePathname } from './standardize-pathname.js';
4
4
 
5
5
  /**
@@ -11,25 +11,25 @@ import { standardizePathname } from './standardize-pathname.js';
11
11
  * // config.supportedLocales: ["en-US"]
12
12
  * // config.routing.basePath: "/app"
13
13
  * // config.routing.prefix: "all"
14
- * localePrefixPathname({ config, pathname: "/app/en-US/about", locale: "en-US" });
14
+ * localizePathname(config, "/app/en-US/about", "en-US");
15
15
  * // => {
16
+ * // pathname: '/app/en-US/about'
16
17
  * // unprefixedPathname: '/about',
17
- * // standardizedPathname: '/app/{locale}/about',
18
- * // localizedPathname: '/app/en-US/about'
18
+ * // templatedPathname: '/app/{locale}/about',
19
19
  * // }
20
20
  * ```
21
21
  */
22
- const localizePathname = (config, rawPathname, locale) => {
23
- // 1. Canonicalize: extract basePath and strip locale
24
- const unprefixedPathname = getUnprefixedPathname(config, rawPathname);
25
- // 2. Standardize: build a pathname with locale placeholder
26
- const standardizedPathname = standardizePathname(config, unprefixedPathname);
27
- // 3. Apply strategy: resolve locale prefix based on routing rules
28
- const pathname = localePrefixPathname(config, standardizedPathname, locale);
22
+ const localizePathname = (rawPathname, config, locale) => {
23
+ // 1. Canonicalize: normalize and remove routing-specific prefixes
24
+ const canonicalized = canonicalizePathname(rawPathname, config);
25
+ // 2. Standardize: convert to internal pathname shape with locale placeholder
26
+ const standardized = standardizePathname(canonicalized, config);
27
+ // 3. Materialize: apply routing rules to produce the final pathname
28
+ const materialized = materializePathname(standardized, config, locale);
29
29
  return {
30
- pathname,
31
- unprefixedPathname,
32
- standardizedPathname,
30
+ pathname: materialized,
31
+ unprefixedPathname: canonicalized,
32
+ templatedPathname: standardized,
33
33
  };
34
34
  };
35
35
 
@@ -4,20 +4,21 @@ import { normalizePathname } from '../../core/utils/normalizers/normalize-pathna
4
4
  import 'logry';
5
5
 
6
6
  /**
7
- * Applies the configured locale prefix behavior to a standardized pathname.
7
+ * Materializes a standardized pathname by applying
8
+ * the configured locale prefix behavior.
8
9
  *
9
10
  * @example
10
11
  * ```ts
11
12
  * // config.routing.localePrefix: "all"
12
- * localePrefixPathname({ config, pathname: "/app/{locale}/about", locale: "en-US" });
13
+ * materializePathname("/app/{locale}/about", config, "en-US");
13
14
  * // => /app/en-US/about
14
15
  *
15
16
  * // config.routing.localePrefix: "none"
16
- * localePrefixPathname({ config, pathname: "/app/{locale}/about", locale: "en-US" });
17
+ * materializePathname("/app/{locale}/about", config, "en-US");
17
18
  * // => /app/about
18
19
  * ```
19
20
  */
20
- const localePrefixPathname = (config, standardizedPathname, locale) => {
21
+ const materializePathname = (standardizedPathname, config, locale) => {
21
22
  const { localePrefix } = config.routing;
22
23
  if (localePrefix !== "none" && !locale) {
23
24
  throw new Error('No locale when using localePrefix "all", "except-default"');
@@ -36,4 +37,4 @@ const localePrefixPathname = (config, standardizedPathname, locale) => {
36
37
  return normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""));
37
38
  };
38
39
 
39
- export { localePrefixPathname };
40
+ export { materializePathname };
@@ -4,24 +4,24 @@ import { normalizePathname } from '../../core/utils/normalizers/normalize-pathna
4
4
  import 'logry';
5
5
 
6
6
  /**
7
- * Standardizes a canonical pathname by applying the base path
8
- * and injecting the locale placeholder.
7
+ * Standardizes a canonical pathname into an internal routing template
8
+ * by applying the base path and injecting a locale placeholder.
9
9
  *
10
10
  * @example
11
11
  * ```ts
12
- * // routing.basePath: "/app",
13
- * standardizePathname({ config, pathname: "/cms" });
14
- * // => "/app/{locale}/cms"
12
+ * // config.routing.basePath: "/app",
13
+ * // config.routing.prefix: "all"
14
+ * standardizePathname("/about", config);
15
+ * // => "/app/{locale}/about"
15
16
  * ```
16
17
  */
17
- const standardizePathname = (config, unprefixedPathname) => {
18
- const { routing } = config;
19
- const { basePath } = routing;
18
+ const standardizePathname = (canonicalizedPathname, config) => {
19
+ const { basePath } = config.routing;
20
20
  // Normalize each segment before join to avoid redundant slashes
21
21
  const parts = [
22
22
  normalizePathname(basePath),
23
23
  PREFIX_PLACEHOLDER,
24
- normalizePathname(unprefixedPathname),
24
+ normalizePathname(canonicalizedPathname),
25
25
  ];
26
26
  // Avoid double slashes between segments
27
27
  const standardizedPathname = parts.join("/").replaceAll(/\/{2,}/g, "/");
@@ -21,7 +21,6 @@ async function getTranslator(config, params) {
21
21
  locale,
22
22
  hasKey: translator.hasKey,
23
23
  t: translator.t,
24
- tRaw: translator.tRaw,
25
24
  };
26
25
  }
27
26
 
@@ -5,8 +5,8 @@ import { createIntorRuntime } from '../runtime/create-intor-runtime.js';
5
5
  /**
6
6
  * Initializes Intor for the current execution context.
7
7
  *
8
- * Provides server-side bootstrap logic for SSR-based
9
- * full-stack frameworks.
8
+ * Produces a server-side snapshot for SSR and
9
+ * full-stack rendering environments.
10
10
  */
11
11
  async function intor(config, localeOrResolver, options) {
12
12
  const baseLogger = getLogger(config.logger);
@@ -34,7 +34,6 @@ function createTranslator(params) {
34
34
  locale,
35
35
  hasKey: scoped ? scoped.hasKey : translator.hasKey,
36
36
  t: scoped ? scoped.t : translator.t,
37
- tRaw: scoped ? scoped.tRaw : translator.tRaw,
38
37
  };
39
38
  }
40
39
 
@@ -16,6 +16,10 @@ async function getTranslator(config, req, params) {
16
16
  plugins,
17
17
  readers,
18
18
  allowCacheWrite,
19
+ // NOTE:
20
+ // The runtime implementation is intentionally erased.
21
+ // Type safety is guaranteed by public type contracts.
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
23
  });
20
24
  }
21
25
 
@@ -15,7 +15,7 @@ import { getTranslator } from '../../../server/helpers/get-translator.js';
15
15
  *
16
16
  * The resolved routing state is exposed via response headers.
17
17
  *
18
- * - Acts as the bootstrap entry where cache writes are permitted.
18
+ * - Permits cache writes during server execution.
19
19
  * - Convenience routing shortcuts are also bound to the request for downstream consumption.
20
20
  *
21
21
  * @platform Express
@@ -43,20 +43,18 @@ function createIntor(config, options) {
43
43
  // --------------------------------------------------
44
44
  // Bind inbound routing context
45
45
  // --------------------------------------------------
46
- const { hasKey, t, tRaw } = (await getTranslator(config, {
46
+ const { hasKey, t } = (await getTranslator(config, {
47
47
  locale,
48
48
  handlers: options?.handlers,
49
49
  plugins: options?.plugins,
50
50
  readers: options?.readers,
51
51
  allowCacheWrite: true,
52
52
  }));
53
- req.intor = { locale, localeSource };
53
+ req.intor = { locale, localeSource, pathname };
54
54
  // DX shortcuts (optional)
55
55
  req.locale = locale;
56
- req.localeSource = localeSource;
57
56
  req.hasKey = hasKey;
58
57
  req.t = t;
59
- req.tRaw = tRaw;
60
58
  return next();
61
59
  };
62
60
  }
@@ -32,7 +32,7 @@ const resolvePathname = (config, rawPathname, context) => {
32
32
  return assertNever(localePrefix);
33
33
  }
34
34
  }
35
- const { pathname } = localizePathname(config, rawPathname, context.locale);
35
+ const { pathname } = localizePathname(rawPathname, config, context.locale);
36
36
  return {
37
37
  pathname,
38
38
  shouldRedirect: directive.type === "redirect",
@@ -10,11 +10,11 @@ import 'logry';
10
10
  * // config.supportedLocales: ["en-US"]
11
11
  * // config.routing.basePath: "/app"
12
12
  * // config.routing.prefix: "all"
13
- * getUnprefixedPathname(config, "/app/en-US/about" );
13
+ * canonicalizePathname("/app/en-US/about", config);
14
14
  * // => "/about"
15
15
  *```
16
16
  */
17
- function getUnprefixedPathname(config, rawPathname) {
17
+ function canonicalizePathname(rawPathname, config) {
18
18
  const { routing, supportedLocales } = config;
19
19
  const { basePath } = routing;
20
20
  // 1. Normalize pathname
@@ -38,4 +38,4 @@ function getUnprefixedPathname(config, rawPathname) {
38
38
  : prefixedPathname;
39
39
  }
40
40
 
41
- export { getUnprefixedPathname };
41
+ export { canonicalizePathname };
@@ -1,5 +1,5 @@
1
- import { getUnprefixedPathname } from './get-unprefixed-pathname.js';
2
- import { localePrefixPathname } from './locale-prefix-pathname.js';
1
+ import { canonicalizePathname } from './canonicalize-pathname.js';
2
+ import { materializePathname } from './materialize-pathname.js';
3
3
  import { standardizePathname } from './standardize-pathname.js';
4
4
 
5
5
  /**
@@ -11,25 +11,25 @@ import { standardizePathname } from './standardize-pathname.js';
11
11
  * // config.supportedLocales: ["en-US"]
12
12
  * // config.routing.basePath: "/app"
13
13
  * // config.routing.prefix: "all"
14
- * localePrefixPathname({ config, pathname: "/app/en-US/about", locale: "en-US" });
14
+ * localizePathname(config, "/app/en-US/about", "en-US");
15
15
  * // => {
16
+ * // pathname: '/app/en-US/about'
16
17
  * // unprefixedPathname: '/about',
17
- * // standardizedPathname: '/app/{locale}/about',
18
- * // localizedPathname: '/app/en-US/about'
18
+ * // templatedPathname: '/app/{locale}/about',
19
19
  * // }
20
20
  * ```
21
21
  */
22
- const localizePathname = (config, rawPathname, locale) => {
23
- // 1. Canonicalize: extract basePath and strip locale
24
- const unprefixedPathname = getUnprefixedPathname(config, rawPathname);
25
- // 2. Standardize: build a pathname with locale placeholder
26
- const standardizedPathname = standardizePathname(config, unprefixedPathname);
27
- // 3. Apply strategy: resolve locale prefix based on routing rules
28
- const pathname = localePrefixPathname(config, standardizedPathname, locale);
22
+ const localizePathname = (rawPathname, config, locale) => {
23
+ // 1. Canonicalize: normalize and remove routing-specific prefixes
24
+ const canonicalized = canonicalizePathname(rawPathname, config);
25
+ // 2. Standardize: convert to internal pathname shape with locale placeholder
26
+ const standardized = standardizePathname(canonicalized, config);
27
+ // 3. Materialize: apply routing rules to produce the final pathname
28
+ const materialized = materializePathname(standardized, config, locale);
29
29
  return {
30
- pathname,
31
- unprefixedPathname,
32
- standardizedPathname,
30
+ pathname: materialized,
31
+ unprefixedPathname: canonicalized,
32
+ templatedPathname: standardized,
33
33
  };
34
34
  };
35
35
 
@@ -4,20 +4,21 @@ import { normalizePathname } from '../../core/utils/normalizers/normalize-pathna
4
4
  import 'logry';
5
5
 
6
6
  /**
7
- * Applies the configured locale prefix behavior to a standardized pathname.
7
+ * Materializes a standardized pathname by applying
8
+ * the configured locale prefix behavior.
8
9
  *
9
10
  * @example
10
11
  * ```ts
11
12
  * // config.routing.localePrefix: "all"
12
- * localePrefixPathname({ config, pathname: "/app/{locale}/about", locale: "en-US" });
13
+ * materializePathname("/app/{locale}/about", config, "en-US");
13
14
  * // => /app/en-US/about
14
15
  *
15
16
  * // config.routing.localePrefix: "none"
16
- * localePrefixPathname({ config, pathname: "/app/{locale}/about", locale: "en-US" });
17
+ * materializePathname("/app/{locale}/about", config, "en-US");
17
18
  * // => /app/about
18
19
  * ```
19
20
  */
20
- const localePrefixPathname = (config, standardizedPathname, locale) => {
21
+ const materializePathname = (standardizedPathname, config, locale) => {
21
22
  const { localePrefix } = config.routing;
22
23
  if (localePrefix !== "none" && !locale) {
23
24
  throw new Error('No locale when using localePrefix "all", "except-default"');
@@ -36,4 +37,4 @@ const localePrefixPathname = (config, standardizedPathname, locale) => {
36
37
  return normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""));
37
38
  };
38
39
 
39
- export { localePrefixPathname };
40
+ export { materializePathname };
@@ -4,24 +4,24 @@ import { normalizePathname } from '../../core/utils/normalizers/normalize-pathna
4
4
  import 'logry';
5
5
 
6
6
  /**
7
- * Standardizes a canonical pathname by applying the base path
8
- * and injecting the locale placeholder.
7
+ * Standardizes a canonical pathname into an internal routing template
8
+ * by applying the base path and injecting a locale placeholder.
9
9
  *
10
10
  * @example
11
11
  * ```ts
12
- * // routing.basePath: "/app",
13
- * standardizePathname({ config, pathname: "/cms" });
14
- * // => "/app/{locale}/cms"
12
+ * // config.routing.basePath: "/app",
13
+ * // config.routing.prefix: "all"
14
+ * standardizePathname("/about", config);
15
+ * // => "/app/{locale}/about"
15
16
  * ```
16
17
  */
17
- const standardizePathname = (config, unprefixedPathname) => {
18
- const { routing } = config;
19
- const { basePath } = routing;
18
+ const standardizePathname = (canonicalizedPathname, config) => {
19
+ const { basePath } = config.routing;
20
20
  // Normalize each segment before join to avoid redundant slashes
21
21
  const parts = [
22
22
  normalizePathname(basePath),
23
23
  PREFIX_PLACEHOLDER,
24
- normalizePathname(unprefixedPathname),
24
+ normalizePathname(canonicalizedPathname),
25
25
  ];
26
26
  // Avoid double slashes between segments
27
27
  const standardizedPathname = parts.join("/").replaceAll(/\/{2,}/g, "/");
@@ -21,7 +21,6 @@ async function getTranslator(config, params) {
21
21
  locale,
22
22
  hasKey: translator.hasKey,
23
23
  t: translator.t,
24
- tRaw: translator.tRaw,
25
24
  };
26
25
  }
27
26
 
@@ -34,7 +34,6 @@ function createTranslator(params) {
34
34
  locale,
35
35
  hasKey: scoped ? scoped.hasKey : translator.hasKey,
36
36
  t: scoped ? scoped.t : translator.t,
37
- tRaw: scoped ? scoped.tRaw : translator.tRaw,
38
37
  };
39
38
  }
40
39
 
@@ -9,17 +9,17 @@ import { localizePathname } from '../../../routing/pathname/localize-pathname.js
9
9
  *
10
10
  * @example
11
11
  * ```ts
12
- * const { pathname, standardizedPathname, unprefixedPathname } = usePathname();
13
- * // pathname => "/en-US/about"
14
- * // standardizedPathname => "/{locale}/about"
12
+ * const { pathname, unprefixedPathname, templatedPathname } = usePathname();
13
+ * // pathname => "/app/en-US/about"
15
14
  * // unprefixedPathname => "/about"
15
+ * // templatedPathname => "/app/{locale}/about"
16
16
  * ```
17
17
  * @platform Next.js
18
18
  */
19
19
  const usePathname = () => {
20
20
  const { config, locale } = useIntor();
21
21
  const rawPathname = usePathname$1();
22
- return localizePathname(config, rawPathname, locale);
22
+ return localizePathname(rawPathname, config, locale);
23
23
  };
24
24
 
25
25
  export { usePathname };
@@ -11,7 +11,7 @@ import { getLocaleFromAcceptLanguage } from '../../../routing/locale/get-locale-
11
11
  *
12
12
  * The resolved routing state is exposed via response headers.
13
13
  *
14
- * - Acts as the canonical routing authority, guaranteeing a canonical routing result for every request.
14
+ * - Acts as the canonical routing authority, guaranteeing a canonical routing result for every request.
15
15
  *
16
16
  * @platform Next.js
17
17
  */
@@ -9,10 +9,10 @@ import { localizePathname } from '../../../routing/pathname/localize-pathname.js
9
9
  *
10
10
  * @example
11
11
  * ```ts
12
- * const { pathname, standardizedPathname, unprefixedPathname } = usePathname();
13
- * // pathname => "/en-US/about"
14
- * // standardizedPathname => "/{locale}/about"
12
+ * const { pathname, unprefixedPathname, templatedPathname } = await getPathname();
13
+ * // pathname => "/app/en-US/about"
15
14
  * // unprefixedPathname => "/about"
15
+ * // templatedPathname => "/app/{locale}/about"
16
16
  * ```
17
17
  * @note Requires inbound routing context; otherwise the result may be inferred.
18
18
  * @platform Next.js
@@ -21,7 +21,7 @@ async function getPathname(config) {
21
21
  const headersStore = await headers();
22
22
  const locale = headersStore.get(INTOR_HEADERS.LOCALE) || config.defaultLocale;
23
23
  const rawPathname = headersStore.get(INTOR_HEADERS.PATHNAME) || "/";
24
- return localizePathname(config, rawPathname, locale);
24
+ return localizePathname(rawPathname, config, locale);
25
25
  }
26
26
 
27
27
  export { getPathname };
@@ -17,6 +17,10 @@ async function getTranslator(config, params) {
17
17
  plugins,
18
18
  readers,
19
19
  allowCacheWrite,
20
+ // NOTE:
21
+ // The runtime implementation is intentionally erased.
22
+ // Type safety is guaranteed by public type contracts.
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
24
  });
21
25
  }
22
26
 
@@ -11,7 +11,7 @@ import { getLocale } from './get-locale.js';
11
11
  * Initializes Intor for the current execution context.
12
12
  *
13
13
  * - Automatically resolves the locale from the framework context.
14
- * - Acts as the bootstrap entry where cache writes are permitted.
14
+ * - Permits cache writes during server execution.
15
15
  * @platform Next.js
16
16
  */
17
17
  async function intor(config, readers) {
@@ -32,7 +32,7 @@ const resolvePathname = (config, rawPathname, context) => {
32
32
  return assertNever(localePrefix);
33
33
  }
34
34
  }
35
- const { pathname } = localizePathname(config, rawPathname, context.locale);
35
+ const { pathname } = localizePathname(rawPathname, config, context.locale);
36
36
  return {
37
37
  pathname,
38
38
  shouldRedirect: directive.type === "redirect",
@@ -1,4 +1,4 @@
1
- import { getUnprefixedPathname } from '../pathname/get-unprefixed-pathname.js';
1
+ import { canonicalizePathname } from '../pathname/canonicalize-pathname.js';
2
2
  import { localizePathname } from '../pathname/localize-pathname.js';
3
3
  import { deriveHostDestination } from './utils/derive-host-destination.js';
4
4
  import { deriveQueryDestination } from './utils/derive-query-destination.js';
@@ -23,7 +23,7 @@ function deriveTarget(config, currentLocale, currentPathname, intent) {
23
23
  // ----------------------------------------------------------------
24
24
  // Use the unprefixed logical path as the navigation base.
25
25
  // Locale prefixes are applied later by inbound canonicalization.
26
- const rawDestination = intent?.destination ?? getUnprefixedPathname(config, currentPathname);
26
+ const rawDestination = intent?.destination ?? canonicalizePathname(currentPathname, config);
27
27
  const isExternal = isExternalDestination(rawDestination);
28
28
  // ----------------------------------------------------------------
29
29
  // Project destination by navigation carrier
@@ -32,15 +32,15 @@ function deriveTarget(config, currentLocale, currentPathname, intent) {
32
32
  if (!isExternal) {
33
33
  switch (routing.outbound.localeCarrier) {
34
34
  case "path": {
35
- destination = localizePathname(config, rawDestination, locale).pathname;
35
+ destination = localizePathname(rawDestination, config, locale).pathname;
36
36
  break;
37
37
  }
38
38
  case "host": {
39
- destination = deriveHostDestination(config, rawDestination, locale);
39
+ destination = deriveHostDestination(rawDestination, config, locale);
40
40
  break;
41
41
  }
42
42
  case "query": {
43
- destination = deriveQueryDestination(config, rawDestination, locale);
43
+ destination = deriveQueryDestination(rawDestination, config, locale);
44
44
  break;
45
45
  }
46
46
  default: {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Derives a locale-specific destination using host-based navigation.
3
3
  */
4
- const deriveHostDestination = (config, rawDestination, locale) => {
4
+ const deriveHostDestination = (rawDestination, config, locale) => {
5
5
  const { host } = config.routing.outbound;
6
6
  const resolvedHost = host.map[locale] ?? host.default;
7
7
  if (!resolvedHost)
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Derives a locale-specific destination using query-based navigation.
3
3
  */
4
- const deriveQueryDestination = (config, rawDestination, locale) => {
4
+ const deriveQueryDestination = (rawDestination, config, locale) => {
5
5
  const { queryKey } = config.routing.outbound;
6
6
  const url = new URL(rawDestination, "http://internal");
7
7
  url.searchParams.set(queryKey, locale);
@@ -10,11 +10,11 @@ import 'logry';
10
10
  * // config.supportedLocales: ["en-US"]
11
11
  * // config.routing.basePath: "/app"
12
12
  * // config.routing.prefix: "all"
13
- * getUnprefixedPathname(config, "/app/en-US/about" );
13
+ * canonicalizePathname("/app/en-US/about", config);
14
14
  * // => "/about"
15
15
  *```
16
16
  */
17
- function getUnprefixedPathname(config, rawPathname) {
17
+ function canonicalizePathname(rawPathname, config) {
18
18
  const { routing, supportedLocales } = config;
19
19
  const { basePath } = routing;
20
20
  // 1. Normalize pathname
@@ -38,4 +38,4 @@ function getUnprefixedPathname(config, rawPathname) {
38
38
  : prefixedPathname;
39
39
  }
40
40
 
41
- export { getUnprefixedPathname };
41
+ export { canonicalizePathname };
@@ -1,5 +1,5 @@
1
- import { getUnprefixedPathname } from './get-unprefixed-pathname.js';
2
- import { localePrefixPathname } from './locale-prefix-pathname.js';
1
+ import { canonicalizePathname } from './canonicalize-pathname.js';
2
+ import { materializePathname } from './materialize-pathname.js';
3
3
  import { standardizePathname } from './standardize-pathname.js';
4
4
 
5
5
  /**
@@ -11,25 +11,25 @@ import { standardizePathname } from './standardize-pathname.js';
11
11
  * // config.supportedLocales: ["en-US"]
12
12
  * // config.routing.basePath: "/app"
13
13
  * // config.routing.prefix: "all"
14
- * localePrefixPathname({ config, pathname: "/app/en-US/about", locale: "en-US" });
14
+ * localizePathname(config, "/app/en-US/about", "en-US");
15
15
  * // => {
16
+ * // pathname: '/app/en-US/about'
16
17
  * // unprefixedPathname: '/about',
17
- * // standardizedPathname: '/app/{locale}/about',
18
- * // localizedPathname: '/app/en-US/about'
18
+ * // templatedPathname: '/app/{locale}/about',
19
19
  * // }
20
20
  * ```
21
21
  */
22
- const localizePathname = (config, rawPathname, locale) => {
23
- // 1. Canonicalize: extract basePath and strip locale
24
- const unprefixedPathname = getUnprefixedPathname(config, rawPathname);
25
- // 2. Standardize: build a pathname with locale placeholder
26
- const standardizedPathname = standardizePathname(config, unprefixedPathname);
27
- // 3. Apply strategy: resolve locale prefix based on routing rules
28
- const pathname = localePrefixPathname(config, standardizedPathname, locale);
22
+ const localizePathname = (rawPathname, config, locale) => {
23
+ // 1. Canonicalize: normalize and remove routing-specific prefixes
24
+ const canonicalized = canonicalizePathname(rawPathname, config);
25
+ // 2. Standardize: convert to internal pathname shape with locale placeholder
26
+ const standardized = standardizePathname(canonicalized, config);
27
+ // 3. Materialize: apply routing rules to produce the final pathname
28
+ const materialized = materializePathname(standardized, config, locale);
29
29
  return {
30
- pathname,
31
- unprefixedPathname,
32
- standardizedPathname,
30
+ pathname: materialized,
31
+ unprefixedPathname: canonicalized,
32
+ templatedPathname: standardized,
33
33
  };
34
34
  };
35
35
 
@@ -4,20 +4,21 @@ import { normalizePathname } from '../../core/utils/normalizers/normalize-pathna
4
4
  import 'logry';
5
5
 
6
6
  /**
7
- * Applies the configured locale prefix behavior to a standardized pathname.
7
+ * Materializes a standardized pathname by applying
8
+ * the configured locale prefix behavior.
8
9
  *
9
10
  * @example
10
11
  * ```ts
11
12
  * // config.routing.localePrefix: "all"
12
- * localePrefixPathname({ config, pathname: "/app/{locale}/about", locale: "en-US" });
13
+ * materializePathname("/app/{locale}/about", config, "en-US");
13
14
  * // => /app/en-US/about
14
15
  *
15
16
  * // config.routing.localePrefix: "none"
16
- * localePrefixPathname({ config, pathname: "/app/{locale}/about", locale: "en-US" });
17
+ * materializePathname("/app/{locale}/about", config, "en-US");
17
18
  * // => /app/about
18
19
  * ```
19
20
  */
20
- const localePrefixPathname = (config, standardizedPathname, locale) => {
21
+ const materializePathname = (standardizedPathname, config, locale) => {
21
22
  const { localePrefix } = config.routing;
22
23
  if (localePrefix !== "none" && !locale) {
23
24
  throw new Error('No locale when using localePrefix "all", "except-default"');
@@ -36,4 +37,4 @@ const localePrefixPathname = (config, standardizedPathname, locale) => {
36
37
  return normalizePathname(standardizedPathname.replaceAll(`/${PREFIX_PLACEHOLDER}`, ""));
37
38
  };
38
39
 
39
- export { localePrefixPathname };
40
+ export { materializePathname };