intor 2.3.33 → 2.3.34

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 (123) hide show
  1. package/dist/core/src/core/utils/resolve-loader-options.js +7 -3
  2. package/dist/core/src/server/messages/load-messages.js +5 -5
  3. package/dist/express/export/express/index.js +2 -2
  4. package/dist/express/src/adapters/express/{middleware/create-intor-middleware.js → create-intor-handler.js} +13 -12
  5. package/dist/express/src/adapters/express/{helpers/get-translator.js → get-translator.js} +2 -6
  6. package/dist/express/src/core/utils/resolve-loader-options.js +3 -1
  7. package/dist/express/src/routing/inbound/resolve-inbound.js +3 -4
  8. package/dist/express/src/routing/inbound/resolve-locale/resolve-locale.js +6 -5
  9. package/dist/express/src/routing/locale/get-locale-from-query.js +1 -9
  10. package/dist/express/src/server/messages/load-messages.js +5 -5
  11. package/dist/next/export/next/index.js +4 -3
  12. package/dist/next/src/adapters/next/{proxy/intor-proxy.js → create-intor-handler.js} +13 -12
  13. package/dist/next/src/adapters/next/{navigation/link.js → link.js} +6 -6
  14. package/dist/next/src/adapters/next/{navigation/redirect.js → redirect.js} +4 -4
  15. package/dist/next/src/adapters/next/server/get-translator.js +0 -4
  16. package/dist/next/src/adapters/next/{navigation/use-router.js → use-router.js} +10 -10
  17. package/dist/next/src/client/shared/navigation/execute-navigation.js +6 -6
  18. package/dist/next/src/core/utils/resolve-loader-options.js +7 -3
  19. package/dist/next/src/policies/shoud-full-reload.js +1 -1
  20. package/dist/next/src/routing/inbound/resolve-inbound.js +4 -5
  21. package/dist/next/src/routing/inbound/resolve-locale/resolve-locale.js +6 -5
  22. package/dist/next/src/routing/locale/get-locale-from-query.js +1 -9
  23. package/dist/next/src/routing/{navigation → outbound}/decide-strategy.js +2 -5
  24. package/dist/{svelte-kit/src/routing/navigation/derive-target.js → next/src/routing/outbound/determine-target.js} +3 -6
  25. package/dist/next/src/routing/outbound/resolve-outbound.js +23 -0
  26. package/dist/next/src/server/messages/load-messages.js +5 -5
  27. package/dist/react/src/client/react/helpers/use-intor.js +3 -8
  28. package/dist/react/src/client/react/provider/intor-provider.js +2 -2
  29. package/dist/react/src/client/shared/messages/create-refetch-messages.js +1 -1
  30. package/dist/react/src/core/utils/resolve-loader-options.js +4 -2
  31. package/dist/svelte/src/client/shared/messages/create-refetch-messages.js +1 -1
  32. package/dist/svelte/src/core/utils/resolve-loader-options.js +4 -2
  33. package/dist/svelte-kit/export/svelte-kit/index.js +1 -1
  34. package/dist/svelte-kit/export/svelte-kit/server/index.js +1 -1
  35. package/dist/svelte-kit/src/adapters/svelte-kit/server/{create-intor-handle.js → create-intor-handler.js} +10 -9
  36. package/dist/svelte-kit/src/adapters/svelte-kit/{navigation/use-navigation.js → use-navigation.js} +6 -6
  37. package/dist/svelte-kit/src/client/shared/navigation/execute-navigation.js +6 -6
  38. package/dist/svelte-kit/src/core/utils/resolve-loader-options.js +7 -3
  39. package/dist/svelte-kit/src/policies/shoud-full-reload.js +1 -1
  40. package/dist/svelte-kit/src/routing/inbound/resolve-inbound.js +3 -4
  41. package/dist/svelte-kit/src/routing/inbound/resolve-locale/resolve-locale.js +6 -5
  42. package/dist/svelte-kit/src/routing/locale/get-locale-from-query.js +1 -9
  43. package/dist/svelte-kit/src/routing/{navigation → outbound}/decide-strategy.js +2 -5
  44. package/dist/{next/src/routing/navigation/derive-target.js → svelte-kit/src/routing/outbound/determine-target.js} +3 -6
  45. package/dist/svelte-kit/src/routing/outbound/resolve-outbound.js +23 -0
  46. package/dist/svelte-kit/src/server/messages/load-messages.js +5 -5
  47. package/dist/types/export/express/index.d.ts +1 -1
  48. package/dist/types/export/next/index.d.ts +1 -1
  49. package/dist/types/export/svelte-kit/index.d.ts +1 -1
  50. package/dist/types/export/svelte-kit/server/index.d.ts +1 -1
  51. package/dist/types/src/adapters/express/{middleware/create-intor-middleware.d.ts → create-intor-handler.d.ts} +3 -3
  52. package/dist/types/src/adapters/express/{helpers/get-translator.d.ts → get-translator.d.ts} +3 -3
  53. package/dist/types/src/adapters/express/global.d.ts +5 -4
  54. package/dist/types/src/adapters/express/index.d.ts +2 -2
  55. package/dist/types/src/adapters/next/{proxy/intor-proxy.d.ts → create-intor-handler.d.ts} +2 -2
  56. package/dist/types/src/adapters/next/{navigation/index.d.ts → index.d.ts} +1 -0
  57. package/dist/types/src/adapters/next/{navigation/link.d.ts → link.d.ts} +1 -1
  58. package/dist/types/src/adapters/next/{navigation/redirect.d.ts → redirect.d.ts} +2 -2
  59. package/dist/types/src/adapters/next/{navigation/use-router.d.ts → use-router.d.ts} +1 -1
  60. package/dist/types/src/adapters/svelte-kit/server/{create-intor-handle.d.ts → create-intor-handler.d.ts} +1 -1
  61. package/dist/types/src/adapters/svelte-kit/server/index.d.ts +1 -1
  62. package/dist/types/src/adapters/svelte-kit/server/utils/is-svelte-kit-ssg.d.ts +1 -1
  63. package/dist/types/src/adapters/svelte-kit/{navigation/use-navigation.d.ts → use-navigation.d.ts} +1 -1
  64. package/dist/types/src/client/react/helpers/use-intor.d.ts +2 -2
  65. package/dist/types/src/client/react/provider/intor-provider.d.ts +1 -1
  66. package/dist/types/src/client/shared/messages/create-refetch-messages.d.ts +2 -2
  67. package/dist/types/src/client/shared/navigation/execute-navigation.d.ts +9 -8
  68. package/dist/types/src/client/shared/utils/locale/set-document-locale.d.ts +2 -1
  69. package/dist/types/src/client/shared/utils/locale/set-locale-cookie.d.ts +2 -1
  70. package/dist/types/src/client/vue/helpers/use-intor.d.ts +1 -1
  71. package/dist/types/src/config/types/intor-config.d.ts +2 -2
  72. package/dist/types/src/config/types/loader.d.ts +3 -3
  73. package/dist/types/src/config/validators/validate-default-locale.d.ts +2 -1
  74. package/dist/types/src/core/index.d.ts +1 -1
  75. package/dist/types/src/core/messages/load-remote-messages/collect-remote-resources.d.ts +2 -1
  76. package/dist/types/src/core/messages/load-remote-messages/types.d.ts +3 -2
  77. package/dist/types/src/core/utils/index.d.ts +1 -1
  78. package/dist/types/src/core/utils/normalizers/index.d.ts +1 -1
  79. package/dist/types/src/core/utils/normalizers/normalize-locale.d.ts +2 -1
  80. package/dist/types/src/core/utils/normalizers/normalize-query.d.ts +2 -1
  81. package/dist/types/src/policies/should-sync-locale.d.ts +2 -1
  82. package/dist/types/src/routing/inbound/index.d.ts +1 -1
  83. package/dist/types/src/routing/inbound/resolve-inbound.d.ts +12 -7
  84. package/dist/types/src/routing/inbound/resolve-locale/resolve-locale.d.ts +3 -3
  85. package/dist/types/src/routing/inbound/resolve-locale/types.d.ts +7 -6
  86. package/dist/types/src/routing/inbound/resolve-pathname/types.d.ts +2 -1
  87. package/dist/types/src/routing/inbound/types.d.ts +4 -3
  88. package/dist/types/src/routing/index.d.ts +2 -2
  89. package/dist/types/src/routing/locale/get-locale-from-query.d.ts +2 -5
  90. package/dist/types/src/routing/outbound/decide-strategy.d.ts +7 -0
  91. package/dist/types/src/routing/outbound/determine-target.d.ts +14 -0
  92. package/dist/types/src/routing/outbound/index.d.ts +1 -0
  93. package/dist/types/src/routing/outbound/resolve-outbound.d.ts +14 -0
  94. package/dist/types/src/server/helpers/get-translator.d.ts +2 -2
  95. package/dist/types/src/server/messages/load-local-messages/read-locale-messages/types.d.ts +2 -1
  96. package/dist/types/src/server/messages/load-local-messages/types.d.ts +2 -1
  97. package/dist/types/src/server/translator/create-translator.d.ts +2 -2
  98. package/dist/vue/src/client/shared/messages/create-refetch-messages.js +1 -1
  99. package/dist/vue/src/client/vue/helpers/use-intor.js +2 -10
  100. package/dist/vue/src/client/vue/provider/intor-provider.js +0 -1
  101. package/dist/vue/src/core/utils/resolve-loader-options.js +4 -2
  102. package/package.json +1 -5
  103. package/dist/next/export/next/proxy/index.js +0 -1
  104. package/dist/next/src/routing/navigation/resolve-navigation.js +0 -26
  105. package/dist/svelte-kit/src/routing/navigation/resolve-navigation.js +0 -26
  106. package/dist/types/export/next/proxy/index.d.ts +0 -1
  107. package/dist/types/src/adapters/express/helpers/index.d.ts +0 -1
  108. package/dist/types/src/adapters/express/middleware/index.d.ts +0 -1
  109. package/dist/types/src/adapters/next/proxy/index.d.ts +0 -1
  110. package/dist/types/src/routing/navigation/decide-strategy.d.ts +0 -17
  111. package/dist/types/src/routing/navigation/derive-target.d.ts +0 -17
  112. package/dist/types/src/routing/navigation/index.d.ts +0 -1
  113. package/dist/types/src/routing/navigation/resolve-navigation.d.ts +0 -25
  114. /package/dist/next/src/routing/{navigation → outbound}/utils/derive-host-destination.js +0 -0
  115. /package/dist/next/src/routing/{navigation → outbound}/utils/derive-query-destination.js +0 -0
  116. /package/dist/next/src/routing/{navigation → outbound}/utils/is-external-destination.js +0 -0
  117. /package/dist/svelte-kit/src/routing/{navigation → outbound}/utils/derive-host-destination.js +0 -0
  118. /package/dist/svelte-kit/src/routing/{navigation → outbound}/utils/derive-query-destination.js +0 -0
  119. /package/dist/svelte-kit/src/routing/{navigation → outbound}/utils/is-external-destination.js +0 -0
  120. /package/dist/types/src/adapters/svelte-kit/{navigation/index.d.ts → index.d.ts} +0 -0
  121. /package/dist/types/src/routing/{navigation → outbound}/utils/derive-host-destination.d.ts +0 -0
  122. /package/dist/types/src/routing/{navigation → outbound}/utils/derive-query-destination.d.ts +0 -0
  123. /package/dist/types/src/routing/{navigation → outbound}/utils/is-external-destination.d.ts +0 -0
@@ -0,0 +1,23 @@
1
+ import { decideStrategy } from './decide-strategy.js';
2
+ import { determineTarget } from './determine-target.js';
3
+
4
+ /**
5
+ * Resolve an outbound routing attempt into an executable result.
6
+ */
7
+ function resolveOutbound(config, currentLocale, currentPathname, intent) {
8
+ // --------------------------------------------------
9
+ // Determine outbound target
10
+ // --------------------------------------------------
11
+ const target = determineTarget(config, currentLocale, currentPathname, intent);
12
+ // --------------------------------------------------
13
+ // Decide outbound strategy
14
+ // --------------------------------------------------
15
+ const strategy = decideStrategy(config, target);
16
+ return {
17
+ locale: target.locale,
18
+ destination: target.destination,
19
+ kind: strategy,
20
+ };
21
+ }
22
+
23
+ export { resolveOutbound };
@@ -29,12 +29,12 @@ const loadMessages = async ({ config, locale, readers, allowCacheWrite = false,
29
29
  logger.warn("No loader options have been configured in the current config.");
30
30
  return;
31
31
  }
32
- const { type, namespaces, concurrency } = loader;
32
+ const { mode, namespaces, concurrency } = loader;
33
33
  const fallbackLocales = config.fallbackLocales[locale] || [];
34
34
  logger.info(`Loading messages for locale "${locale}".`);
35
35
  logger.trace("Starting to load messages with runtime context.", {
36
- loaderType: type,
37
- ...(type === "local" ? { rootDir: loader.rootDir } : {}),
36
+ loaderMode: mode,
37
+ ...(mode === "local" ? { rootDir: loader.rootDir } : {}),
38
38
  locale,
39
39
  fallbackLocales: fallbackLocales.join(", "),
40
40
  namespaces: namespaces && namespaces.length > 0 ? [...namespaces] : "*",
@@ -43,7 +43,7 @@ const loadMessages = async ({ config, locale, readers, allowCacheWrite = false,
43
43
  // Dispatch to loader implementation
44
44
  // ---------------------------------------------------------------------------
45
45
  let loadedMessages;
46
- if (type === "local") {
46
+ if (mode === "local") {
47
47
  loadedMessages = await loadLocalMessages({
48
48
  id: config.id,
49
49
  locale,
@@ -56,7 +56,7 @@ const loadMessages = async ({ config, locale, readers, allowCacheWrite = false,
56
56
  loggerOptions: config.logger,
57
57
  });
58
58
  }
59
- else if (type === "remote") {
59
+ else if (mode === "remote") {
60
60
  loadedMessages = await loadRemoteMessages({
61
61
  locale,
62
62
  fallbackLocales,
@@ -1,9 +1,4 @@
1
1
  import * as React from 'react';
2
- import '../../../core/error/intor-error.js';
3
- import 'logry';
4
- import 'p-limit';
5
- import { mergeMessages } from '../../../core/messages/merge-messages.js';
6
- import 'intor-translator';
7
2
  import { getClientLocale } from '../../shared/helpers/get-client-locale.js';
8
3
 
9
4
  function useIntor(config, loader) {
@@ -23,13 +18,13 @@ function useIntor(config, loader) {
23
18
  const onLocaleChange = React.useCallback(async (newLocale) => {
24
19
  activeLocaleRef.current = newLocale;
25
20
  setIsLoading(true);
26
- const loaded = await loader(newLocale);
21
+ const loaded = await loader(config, newLocale);
27
22
  // Ignore outdated results when locale changes again.
28
23
  if (activeLocaleRef.current !== newLocale)
29
24
  return;
30
- setMessages(mergeMessages(config.messages, loaded, { config, locale: newLocale }));
25
+ setMessages(loaded);
31
26
  setIsLoading(false);
32
- }, [loader, config]);
27
+ }, [config, loader]);
33
28
  // ---------------------------------------------------------------------------
34
29
  // Initial load
35
30
  // ---------------------------------------------------------------------------
@@ -6,7 +6,7 @@ import { useLocaleEffects } from './effects/use-locale-effects.js';
6
6
  import { useMessagesEffects } from './effects/use-messages-effects.js';
7
7
 
8
8
  const IntorContext = React.createContext(undefined);
9
- const IntorProvider = ({ value: { config, locale: initialLocale, messages, handlers, plugins, onLocaleChange, isLoading: externalIsLoading, }, children, }) => {
9
+ function IntorProvider({ value: { config, locale: initialLocale, messages, handlers, plugins, onLocaleChange, isLoading: externalIsLoading, }, children, }) {
10
10
  // -----------------------------------------------------------------------------
11
11
  // Internal state
12
12
  // -----------------------------------------------------------------------------
@@ -58,6 +58,6 @@ const IntorProvider = ({ value: { config, locale: initialLocale, messages, handl
58
58
  useLocaleEffects(config, locale);
59
59
  useMessagesEffects(config, locale, setRuntimeMessages, setInternalIsLoading);
60
60
  return (jsx(IntorContext.Provider, { value: { config, locale, setLocale, translator }, children: children }));
61
- };
61
+ }
62
62
 
63
63
  export { IntorContext, IntorProvider };
@@ -18,7 +18,7 @@ const createRefetchMessages = ({ config, onLoadingStart, onLoadingEnd, onMessage
18
18
  return async function refetchMessages(newLocale) {
19
19
  // No-op when remote loading is not enabled
20
20
  const loader = resolveLoaderOptions(config);
21
- if (!loader || loader.type !== "remote")
21
+ if (!loader || loader.mode !== "remote")
22
22
  return;
23
23
  // Abort previous request
24
24
  controller?.abort();
@@ -18,12 +18,14 @@
18
18
  * for the given runtime.
19
19
  */
20
20
  const resolveLoaderOptions = (config, runtime) => {
21
- // --- runtime: client ---
21
+ // ------------------------------------------------
22
+ // runtime: client
23
+ // ------------------------------------------------
22
24
  {
23
25
  const client = config.client?.loader;
24
26
  if (client) {
25
27
  // Client loader is always remote by design
26
- return { type: "remote", ...client };
28
+ return { mode: "remote", ...client };
27
29
  }
28
30
  return config.server?.loader ?? config.loader;
29
31
  }
@@ -18,7 +18,7 @@ const createRefetchMessages = ({ config, onLoadingStart, onLoadingEnd, onMessage
18
18
  return async function refetchMessages(newLocale) {
19
19
  // No-op when remote loading is not enabled
20
20
  const loader = resolveLoaderOptions(config);
21
- if (!loader || loader.type !== "remote")
21
+ if (!loader || loader.mode !== "remote")
22
22
  return;
23
23
  // Abort previous request
24
24
  controller?.abort();
@@ -18,12 +18,14 @@
18
18
  * for the given runtime.
19
19
  */
20
20
  const resolveLoaderOptions = (config, runtime) => {
21
- // --- runtime: client ---
21
+ // ------------------------------------------------
22
+ // runtime: client
23
+ // ------------------------------------------------
22
24
  {
23
25
  const client = config.client?.loader;
24
26
  if (client) {
25
27
  // Client loader is always remote by design
26
- return { type: "remote", ...client };
28
+ return { mode: "remote", ...client };
27
29
  }
28
30
  return config.server?.loader ?? config.loader;
29
31
  }
@@ -1 +1 @@
1
- export { useNavigation } from '../../src/adapters/svelte-kit/navigation/use-navigation.js';
1
+ export { useNavigation } from '../../src/adapters/svelte-kit/use-navigation.js';
@@ -1,2 +1,2 @@
1
- export { createIntorHandle } from '../../../src/adapters/svelte-kit/server/create-intor-handle.js';
1
+ export { createIntorHandler } from '../../../src/adapters/svelte-kit/server/create-intor-handler.js';
2
2
  export { intor } from '../../../src/adapters/svelte-kit/server/intor.js';
@@ -17,32 +17,33 @@ import { getLocaleFromAcceptLanguage } from '../../../routing/locale/get-locale-
17
17
  *
18
18
  * @platform SvelteKit
19
19
  */
20
- function createIntorHandle(config) {
20
+ function createIntorHandler(config) {
21
21
  return async ({ event, resolve }) => {
22
+ const { host, searchParams, pathname: rawPathname } = event.url;
22
23
  // Locale from Accept-Language header
23
24
  const acceptLanguage = event.request.headers.get("accept-language");
24
25
  const localeFromAcceptLanguage = getLocaleFromAcceptLanguage(acceptLanguage, config.supportedLocales);
25
26
  // ----------------------------------------------------------
26
27
  // Resolve inbound routing decision (pure computation)
27
28
  // ----------------------------------------------------------
28
- let inbound;
29
+ let inboundResult;
29
30
  if (isSvelteKitSSG(event)) {
30
- inbound = {
31
+ inboundResult = {
31
32
  locale: event.params?.locale,
32
33
  localeSource: "path",
33
- pathname: event.url.pathname,
34
+ pathname: rawPathname,
34
35
  shouldRedirect: false,
35
36
  };
36
37
  }
37
38
  else {
38
- inbound = await resolveInbound(config, event.url.pathname, false, {
39
- host: event.url.host,
40
- query: normalizeQuery(Object.fromEntries(event.url.searchParams.entries())),
39
+ inboundResult = await resolveInbound(config, rawPathname, {
40
+ host,
41
+ query: normalizeQuery(Object.fromEntries(searchParams.entries())),
41
42
  cookie: event.cookies.get(config.cookie.name),
42
43
  detected: localeFromAcceptLanguage || config.defaultLocale,
43
44
  });
44
45
  }
45
- const { locale, localeSource, pathname, shouldRedirect } = inbound;
46
+ const { locale, localeSource, pathname, shouldRedirect } = inboundResult;
46
47
  // ----------------------------------------------------------
47
48
  // Redirect if needed
48
49
  // ----------------------------------------------------------
@@ -64,4 +65,4 @@ function createIntorHandle(config) {
64
65
  };
65
66
  }
66
67
 
67
- export { createIntorHandle };
68
+ export { createIntorHandler };
@@ -1,11 +1,11 @@
1
1
  import { get } from 'svelte/store';
2
- import { executeNavigation } from '../../../client/shared/navigation/execute-navigation.js';
2
+ import { executeNavigation } from '../../client/shared/navigation/execute-navigation.js';
3
3
  import { useIntorContext } from 'intor/svelte';
4
- import '../../../core/error/intor-error.js';
4
+ import '../../core/error/intor-error.js';
5
5
  import 'logry';
6
6
  import 'p-limit';
7
7
  import 'intor-translator';
8
- import { resolveNavigation } from '../../../routing/navigation/resolve-navigation.js';
8
+ import { resolveOutbound } from '../../routing/outbound/resolve-outbound.js';
9
9
  import { goto } from '$app/navigation';
10
10
  import { page } from '$app/state';
11
11
 
@@ -21,13 +21,13 @@ function useNavigation() {
21
21
  const { config, locale: currentLocale, setLocale } = useIntorContext();
22
22
  async function goto$1(url, opts) {
23
23
  const { locale, ...rest } = opts || {};
24
- const navigationResult = resolveNavigation(config, get(currentLocale), page.url.pathname, { destination: url, locale });
25
- executeNavigation(navigationResult, {
24
+ const outboundResult = resolveOutbound(config, get(currentLocale), page.url.pathname, { destination: url, locale });
25
+ executeNavigation(outboundResult, {
26
26
  config,
27
27
  currentLocale: get(currentLocale),
28
28
  setLocale,
29
29
  });
30
- return goto(navigationResult.destination, rest);
30
+ return goto(outboundResult.destination, rest);
31
31
  }
32
32
  return {
33
33
  goto: goto$1,
@@ -6,17 +6,17 @@ import { shouldSyncLocale } from '../../../policies/should-sync-locale.js';
6
6
  import { setLocaleCookie } from '../utils/locale/set-locale-cookie.js';
7
7
 
8
8
  /**
9
- * Executes a resolved navigation result.
9
+ * Executes a resolved outbound routing result.
10
10
  *
11
- * Applies all imperative side effects required to complete navigation,
12
- * including locale synchronization, cookie persistence, and full reloads.
11
+ * Applies all imperative side effects required to realize the outbound decision,
12
+ * including locale synchronization, cookie persistence, and full page reloads.
13
13
  *
14
- * This function must be called after `resolveNavigation`.
14
+ * This function must be called after `resolveOutbound`.
15
15
  */
16
- function executeNavigation(navigationResult, context, e) {
16
+ function executeNavigation(outboundResult, context, e) {
17
17
  const { config, currentLocale, setLocale } = context;
18
18
  const { cookie } = config;
19
- const { destination, kind, locale } = navigationResult;
19
+ const { destination, kind, locale } = outboundResult;
20
20
  // ------------------------------------------------------
21
21
  // External navigation: let browser handle it
22
22
  // ------------------------------------------------------
@@ -18,16 +18,20 @@
18
18
  * for the given runtime.
19
19
  */
20
20
  const resolveLoaderOptions = (config, runtime) => {
21
- // --- runtime: client ---
21
+ // ------------------------------------------------
22
+ // runtime: client
23
+ // ------------------------------------------------
22
24
  if (runtime === "client") {
23
25
  const client = config.client?.loader;
24
26
  if (client) {
25
27
  // Client loader is always remote by design
26
- return { type: "remote", ...client };
28
+ return { mode: "remote", ...client };
27
29
  }
28
30
  return config.server?.loader ?? config.loader;
29
31
  }
30
- // --- runtime: server ---
32
+ // ------------------------------------------------
33
+ // runtime: server
34
+ // ------------------------------------------------
31
35
  return config.server?.loader ?? config.loader;
32
36
  };
33
37
 
@@ -9,7 +9,7 @@ import 'intor-translator';
9
9
  */
10
10
  function shouldFullReload(config) {
11
11
  const loader = resolveLoaderOptions(config, "client");
12
- return (loader?.type === "local" || config.routing.outbound.forceFullReload === true);
12
+ return (loader?.mode === "local" || config.routing.outbound.forceFullReload === true);
13
13
  }
14
14
 
15
15
  export { shouldFullReload };
@@ -13,7 +13,8 @@ import { resolvePathname } from './resolve-pathname/resolve-pathname.js';
13
13
  *
14
14
  * No side effects. No navigation.
15
15
  */
16
- async function resolveInbound(config, rawPathname, hasRedirected, localeInputs) {
16
+ async function resolveInbound(config, rawPathname, localeInputs, options) {
17
+ const { queryKey } = config.routing.inbound;
17
18
  const { host, query, cookie, detected } = localeInputs;
18
19
  // ------------------------------------------------------
19
20
  // Resolve locale from inbound inputs
@@ -22,9 +23,7 @@ async function resolveInbound(config, rawPathname, hasRedirected, localeInputs)
22
23
  const { locale, localeSource } = resolveLocale(config, {
23
24
  path: { locale: pathLocale },
24
25
  host: { locale: getLocaleFromHost(host) },
25
- query: {
26
- locale: getLocaleFromQuery(query, config.routing.inbound.queryKey),
27
- },
26
+ query: { locale: getLocaleFromQuery(query, queryKey) },
28
27
  cookie: { locale: cookie },
29
28
  detected: { locale: detected },
30
29
  });
@@ -7,9 +7,9 @@ import 'intor-translator';
7
7
  /**
8
8
  * Resolve the active locale from inbound routing configuration.
9
9
  *
10
- * Iterates through configured locale sources and returns the first
11
- * normalized, supported locale. Falls back to the detected locale
12
- * or the default locale if none match.
10
+ * Iterates through configured locale sources and returns the first normalized, supported locale.
11
+ *
12
+ * Falls back to the detected locale or the default locale if none match.
13
13
  */
14
14
  function resolveLocale(config, context) {
15
15
  const { localeSources } = config.routing.inbound;
@@ -24,9 +24,10 @@ function resolveLocale(config, context) {
24
24
  };
25
25
  }
26
26
  // Fallback: detected is always available
27
+ const fallback = normalizeLocale(context.detected.locale, config.supportedLocales) ||
28
+ config.defaultLocale;
27
29
  return {
28
- locale: normalizeLocale(context.detected.locale, config.supportedLocales) ||
29
- config.defaultLocale,
30
+ locale: fallback,
30
31
  localeSource: "detected",
31
32
  };
32
33
  }
@@ -11,19 +11,11 @@
11
11
  *
12
12
  * getLocaleFromQuery({}, "locale")
13
13
  * // => undefined
14
- *
15
- * getLocaleFromQuery({ locale: ["zh-TW"] }, "locale")
16
- * // => "zh-TW"
17
- * ```
18
14
  */
19
15
  function getLocaleFromQuery(query, queryKey) {
20
16
  if (!query)
21
17
  return;
22
- const raw = query[queryKey];
23
- if (!raw)
24
- return;
25
- const value = Array.isArray(raw) ? raw[0] : raw;
26
- return value;
18
+ return query[queryKey];
27
19
  }
28
20
 
29
21
  export { getLocaleFromQuery };
@@ -2,16 +2,13 @@ import { shouldFullReload } from '../../policies/shoud-full-reload.js';
2
2
 
3
3
  /**
4
4
  * Decide how a resolved navigation target should be executed.
5
- *
6
- * This function determines whether navigation should be handled
7
- * by the browser, performed client-side, or forced to reload.
8
5
  */
9
6
  function decideStrategy(config, target) {
10
7
  // External destinations are always handled by the browser
11
8
  if (target.isExternal) {
12
- return { kind: "external" };
9
+ return "external";
13
10
  }
14
- return shouldFullReload(config) ? { kind: "reload" } : { kind: "client" };
11
+ return shouldFullReload(config) ? "reload" : "client";
15
12
  }
16
13
 
17
14
  export { decideStrategy };
@@ -5,12 +5,9 @@ import { deriveQueryDestination } from './utils/derive-query-destination.js';
5
5
  import { isExternalDestination } from './utils/is-external-destination.js';
6
6
 
7
7
  /**
8
- * Derives a navigation target for a single navigation attempt.
9
- *
10
- * This function computes the final destination URL and execution flags
11
- * based on the current routing configuration and locale context.
8
+ * Determines the outbound routing target.
12
9
  */
13
- function deriveTarget(config, currentLocale, currentPathname, intent) {
10
+ function determineTarget(config, currentLocale, currentPathname, intent) {
14
11
  const { supportedLocales, routing } = config;
15
12
  // ----------------------------------------------------------------
16
13
  // Resolve effective locale
@@ -55,4 +52,4 @@ function deriveTarget(config, currentLocale, currentPathname, intent) {
55
52
  };
56
53
  }
57
54
 
58
- export { deriveTarget };
55
+ export { determineTarget };
@@ -0,0 +1,23 @@
1
+ import { decideStrategy } from './decide-strategy.js';
2
+ import { determineTarget } from './determine-target.js';
3
+
4
+ /**
5
+ * Resolve an outbound routing attempt into an executable result.
6
+ */
7
+ function resolveOutbound(config, currentLocale, currentPathname, intent) {
8
+ // --------------------------------------------------
9
+ // Determine outbound target
10
+ // --------------------------------------------------
11
+ const target = determineTarget(config, currentLocale, currentPathname, intent);
12
+ // --------------------------------------------------
13
+ // Decide outbound strategy
14
+ // --------------------------------------------------
15
+ const strategy = decideStrategy(config, target);
16
+ return {
17
+ locale: target.locale,
18
+ destination: target.destination,
19
+ kind: strategy,
20
+ };
21
+ }
22
+
23
+ export { resolveOutbound };
@@ -29,12 +29,12 @@ const loadMessages = async ({ config, locale, readers, allowCacheWrite = false,
29
29
  logger.warn("No loader options have been configured in the current config.");
30
30
  return;
31
31
  }
32
- const { type, namespaces, concurrency } = loader;
32
+ const { mode, namespaces, concurrency } = loader;
33
33
  const fallbackLocales = config.fallbackLocales[locale] || [];
34
34
  logger.info(`Loading messages for locale "${locale}".`);
35
35
  logger.trace("Starting to load messages with runtime context.", {
36
- loaderType: type,
37
- ...(type === "local" ? { rootDir: loader.rootDir } : {}),
36
+ loaderMode: mode,
37
+ ...(mode === "local" ? { rootDir: loader.rootDir } : {}),
38
38
  locale,
39
39
  fallbackLocales: fallbackLocales.join(", "),
40
40
  namespaces: namespaces && namespaces.length > 0 ? [...namespaces] : "*",
@@ -43,7 +43,7 @@ const loadMessages = async ({ config, locale, readers, allowCacheWrite = false,
43
43
  // Dispatch to loader implementation
44
44
  // ---------------------------------------------------------------------------
45
45
  let loadedMessages;
46
- if (type === "local") {
46
+ if (mode === "local") {
47
47
  loadedMessages = await loadLocalMessages({
48
48
  id: config.id,
49
49
  locale,
@@ -56,7 +56,7 @@ const loadMessages = async ({ config, locale, readers, allowCacheWrite = false,
56
56
  loggerOptions: config.logger,
57
57
  });
58
58
  }
59
- else if (type === "remote") {
59
+ else if (mode === "remote") {
60
60
  loadedMessages = await loadRemoteMessages({
61
61
  locale,
62
62
  fallbackLocales,
@@ -1 +1 @@
1
- export { createIntorMiddleware, getTranslator } from "../../src/adapters/express";
1
+ export { createIntorHandler, getTranslator } from "../../src/adapters/express";
@@ -1 +1 @@
1
- export { Link, useRouter, redirect } from "../../src/adapters/next/navigation";
1
+ export { Link, useRouter, redirect, createIntorHandler } from "../../src/adapters/next";
@@ -1 +1 @@
1
- export { useNavigation } from "../../src/adapters/svelte-kit/navigation";
1
+ export { useNavigation } from "../../src/adapters/svelte-kit";
@@ -1 +1 @@
1
- export { createIntorHandle, intor } from "../../../src/adapters/svelte-kit/server";
1
+ export { createIntorHandler, intor } from "../../../src/adapters/svelte-kit/server";
@@ -1,6 +1,6 @@
1
- import type { IntorResolvedConfig } from "../../../config";
1
+ import type { IntorResolvedConfig } from "../../config";
2
2
  import type { Request, Response, NextFunction } from "express";
3
- import { type GetTranslatorParams } from "../../../server";
3
+ import { type GetTranslatorParams } from "../../server";
4
4
  /**
5
5
  * Resolves locale-aware routing for the current execution context.
6
6
  *
@@ -11,4 +11,4 @@ import { type GetTranslatorParams } from "../../../server";
11
11
  *
12
12
  * @platform Express
13
13
  */
14
- export declare function createIntorMiddleware(config: IntorResolvedConfig, options?: Omit<GetTranslatorParams, "locale">): (req: Request, _res: Response, next: NextFunction) => Promise<void>;
14
+ export declare function createIntorHandler(config: IntorResolvedConfig, options?: Omit<GetTranslatorParams, "locale">): (req: Request, _res: Response, next: NextFunction) => Promise<void>;
@@ -1,6 +1,6 @@
1
- import type { IntorResolvedConfig } from "../../../config";
2
- import type { GenConfigKeys, GenMessages, GenReplacements } from "../../../core";
3
- import type { GetTranslatorParams, TranslatorInstanceServer } from "../../../server";
1
+ import type { IntorResolvedConfig } from "../../config";
2
+ import type { GenConfigKeys, GenMessages, GenReplacements } from "../../core";
3
+ import type { GetTranslatorParams, TranslatorInstanceServer } from "../../server";
4
4
  import type { Request } from "express";
5
5
  import type { LocalizedPreKey } from "intor-translator";
6
6
  type GetTranslatorExpressParams = Omit<GetTranslatorParams, "locale">;
@@ -1,6 +1,6 @@
1
- import type { TranslatorInstance } from "../../core";
2
1
  import type { InboundContext } from "../../routing";
3
- import type { Locale, LocaleMessages, Replacement } from "intor-translator";
2
+ import type { TranslatorInstanceServer } from "../../server";
3
+ import type { Locale, LocaleMessages } from "intor-translator";
4
4
  /**
5
5
  * Global type augmentations for Express request
6
6
  */
@@ -9,8 +9,9 @@ declare global {
9
9
  interface Request {
10
10
  intor: InboundContext;
11
11
  locale: Locale;
12
- hasKey: TranslatorInstance<LocaleMessages, Replacement, "string">["hasKey"];
13
- t: TranslatorInstance<LocaleMessages, Replacement, "string">["t"];
12
+ hasKey: TranslatorInstanceServer<LocaleMessages>["hasKey"];
13
+ t: TranslatorInstanceServer<LocaleMessages>["t"];
14
+ tRich: TranslatorInstanceServer<LocaleMessages>["tRich"];
14
15
  }
15
16
  }
16
17
  }
@@ -1,3 +1,3 @@
1
- export { createIntorMiddleware } from "./middleware";
2
- export { getTranslator } from "./helpers";
1
+ export { createIntorHandler } from "./create-intor-handler";
2
+ export { getTranslator } from "./get-translator";
3
3
  export * from "./global";
@@ -1,4 +1,4 @@
1
- import type { IntorResolvedConfig } from "../../../config";
1
+ import type { IntorResolvedConfig } from "../../config";
2
2
  import type { NextRequest } from "next/server";
3
3
  /**
4
4
  * Resolves locale-aware routing for the current execution context.
@@ -9,4 +9,4 @@ import type { NextRequest } from "next/server";
9
9
  *
10
10
  * @platform Next.js
11
11
  */
12
- export declare const intorProxy: (config: IntorResolvedConfig, request: NextRequest) => Promise<Response>;
12
+ export declare const createIntorHandler: (config: IntorResolvedConfig, request: NextRequest) => Promise<Response>;
@@ -1,3 +1,4 @@
1
1
  export { Link } from "./link";
2
2
  export { useRouter } from "./use-router";
3
3
  export { redirect } from "./redirect";
4
+ export { createIntorHandler } from "./create-intor-handler";
@@ -1,4 +1,4 @@
1
- import type { GenConfigKeys, GenLocale } from "../../../core";
1
+ import type { GenConfigKeys, GenLocale } from "../../core";
2
2
  import type { Url } from "next/dist/shared/lib/router/router";
3
3
  import type { LinkProps as NextLinkProps } from "next/link";
4
4
  import * as React from "react";
@@ -1,5 +1,5 @@
1
- import type { IntorResolvedConfig } from "../../../config";
2
- import type { GenConfigKeys, GenLocale } from "../../../core";
1
+ import type { IntorResolvedConfig } from "../../config";
2
+ import type { GenConfigKeys, GenLocale } from "../../core";
3
3
  import type { RedirectType } from "next/navigation";
4
4
  /**
5
5
  * Redirect to a locale-aware destination for the current execution context.
@@ -1,4 +1,4 @@
1
- import type { GenConfigKeys, GenLocale } from "../../../core";
1
+ import type { GenConfigKeys, GenLocale } from "../../core";
2
2
  import type { NavigateOptions, PrefetchOptions } from "next/dist/shared/lib/app-router-context.shared-runtime";
3
3
  /**
4
4
  * Locale-aware router hook for the current execution context.
@@ -9,4 +9,4 @@ import type { Handle } from "@sveltejs/kit";
9
9
  *
10
10
  * @platform SvelteKit
11
11
  */
12
- export declare function createIntorHandle(config: IntorResolvedConfig): Handle;
12
+ export declare function createIntorHandler(config: IntorResolvedConfig): Handle;
@@ -1,2 +1,2 @@
1
- export { createIntorHandle } from "./create-intor-handle";
1
+ export { createIntorHandler } from "./create-intor-handler";
2
2
  export { intor } from "./intor";
@@ -5,4 +5,4 @@ import type { RequestEvent } from "@sveltejs/kit";
5
5
  * This is NOT a guaranteed signal.
6
6
  * It intentionally prefers false positives over false negatives.
7
7
  */
8
- export declare function isSvelteKitSSG(event: RequestEvent<Record<string, string>, string | null>): boolean;
8
+ export declare function isSvelteKitSSG(event: RequestEvent): boolean;
@@ -1,4 +1,4 @@
1
- import type { GenConfigKeys, GenLocale } from "../../../core";
1
+ import type { GenConfigKeys, GenLocale } from "../../core";
2
2
  import { goto as svelteGoto } from "$app/navigation";
3
3
  /**
4
4
  * Locale-aware navigation utilities for SvelteKit.