@fluenti/next 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/chunk-DyIg6Wiv.js +7 -0
  2. package/dist/i18n-config.cjs +1 -1
  3. package/dist/i18n-config.cjs.map +1 -1
  4. package/dist/index.cjs +69 -41
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.js +188 -124
  7. package/dist/index.js.map +1 -1
  8. package/dist/loader.cjs +1 -1
  9. package/dist/loader.cjs.map +1 -1
  10. package/dist/loader.js +5 -0
  11. package/dist/loader.js.map +1 -1
  12. package/dist/middleware.cjs +1 -1
  13. package/dist/middleware.cjs.map +1 -1
  14. package/dist/middleware.js +66 -71
  15. package/dist/middleware.js.map +1 -1
  16. package/dist/navigation.cjs +1 -1
  17. package/dist/navigation.cjs.map +1 -1
  18. package/dist/navigation.js +61 -63
  19. package/dist/navigation.js.map +1 -1
  20. package/dist/{client-provider.d.ts → packages/next-plugin/src/client-provider.d.ts} +1 -1
  21. package/dist/packages/next-plugin/src/client-provider.d.ts.map +1 -0
  22. package/dist/packages/next-plugin/src/create-navigation.d.ts.map +1 -0
  23. package/dist/packages/next-plugin/src/dev-runner.d.ts.map +1 -0
  24. package/dist/packages/next-plugin/src/dev-watcher.d.ts.map +1 -0
  25. package/dist/packages/next-plugin/src/generate-server-module.d.ts.map +1 -0
  26. package/dist/packages/next-plugin/src/i18n-config.d.ts.map +1 -0
  27. package/dist/{index.d.ts → packages/next-plugin/src/index.d.ts} +32 -29
  28. package/dist/packages/next-plugin/src/index.d.ts.map +1 -0
  29. package/dist/packages/next-plugin/src/middleware.d.ts.map +1 -0
  30. package/dist/{navigation.d.ts → packages/next-plugin/src/navigation.d.ts} +2 -2
  31. package/dist/packages/next-plugin/src/navigation.d.ts.map +1 -0
  32. package/dist/packages/next-plugin/src/provider.d.ts.map +1 -0
  33. package/dist/packages/next-plugin/src/read-config.d.ts.map +1 -0
  34. package/dist/packages/next-plugin/src/routing.d.ts.map +1 -0
  35. package/dist/packages/next-plugin/src/server.d.ts.map +1 -0
  36. package/dist/{types.d.ts → packages/next-plugin/src/types.d.ts} +11 -1
  37. package/dist/packages/next-plugin/src/types.d.ts.map +1 -0
  38. package/dist/packages/next-plugin/src/with-fluenti.d.ts.map +1 -0
  39. package/dist/packages/next-plugin/src/with-locale.d.ts.map +1 -0
  40. package/dist/provider.cjs +1 -1
  41. package/dist/provider.cjs.map +1 -1
  42. package/dist/routing-CRln5Gw7.js +65 -0
  43. package/dist/routing-CRln5Gw7.js.map +1 -0
  44. package/dist/routing-D4p8HvMH.cjs +2 -0
  45. package/dist/routing-D4p8HvMH.cjs.map +1 -0
  46. package/dist/server.cjs +1 -1
  47. package/dist/server.cjs.map +1 -1
  48. package/package.json +16 -16
  49. package/dist/client-provider.d.ts.map +0 -1
  50. package/dist/create-navigation.d.ts.map +0 -1
  51. package/dist/dev-runner.d.ts.map +0 -1
  52. package/dist/dev-watcher.d.ts.map +0 -1
  53. package/dist/generate-server-module.d.ts.map +0 -1
  54. package/dist/i18n-config.d.ts.map +0 -1
  55. package/dist/index.d.ts.map +0 -1
  56. package/dist/middleware.d.ts.map +0 -1
  57. package/dist/navigation.d.ts.map +0 -1
  58. package/dist/provider.d.ts.map +0 -1
  59. package/dist/read-config.d.ts.map +0 -1
  60. package/dist/routing-DBVu_7tk.js +0 -72
  61. package/dist/routing-DBVu_7tk.js.map +0 -1
  62. package/dist/routing-Dy57-Uao.cjs +0 -2
  63. package/dist/routing-Dy57-Uao.cjs.map +0 -1
  64. package/dist/routing.d.ts.map +0 -1
  65. package/dist/server.d.ts.map +0 -1
  66. package/dist/types.d.ts.map +0 -1
  67. package/dist/with-fluenti.d.ts.map +0 -1
  68. package/dist/with-locale.d.ts.map +0 -1
  69. /package/dist/{create-navigation.d.ts → packages/next-plugin/src/create-navigation.d.ts} +0 -0
  70. /package/dist/{dev-runner.d.ts → packages/next-plugin/src/dev-runner.d.ts} +0 -0
  71. /package/dist/{dev-watcher.d.ts → packages/next-plugin/src/dev-watcher.d.ts} +0 -0
  72. /package/dist/{generate-server-module.d.ts → packages/next-plugin/src/generate-server-module.d.ts} +0 -0
  73. /package/dist/{i18n-config.d.ts → packages/next-plugin/src/i18n-config.d.ts} +0 -0
  74. /package/dist/{middleware.d.ts → packages/next-plugin/src/middleware.d.ts} +0 -0
  75. /package/dist/{provider.d.ts → packages/next-plugin/src/provider.d.ts} +0 -0
  76. /package/dist/{read-config.d.ts → packages/next-plugin/src/read-config.d.ts} +0 -0
  77. /package/dist/{routing.d.ts → packages/next-plugin/src/routing.d.ts} +0 -0
  78. /package/dist/{server.d.ts → packages/next-plugin/src/server.d.ts} +0 -0
  79. /package/dist/{with-fluenti.d.ts → packages/next-plugin/src/with-fluenti.d.ts} +0 -0
  80. /package/dist/{with-locale.d.ts → packages/next-plugin/src/with-locale.d.ts} +0 -0
@@ -1,62 +1,62 @@
1
1
  "use client";
2
2
  "use client";
3
- import { a as e, i as t, n, o as r, s as i, t as a } from "./routing-DBVu_7tk.js";
4
- import { useI18n as o } from "@fluenti/react";
5
- import { createElement as s, forwardRef as c } from "react";
6
- import { cookieName as l } from "@fluenti/next/i18n-config";
7
- import { usePathname as u, useRouter as d } from "next/navigation";
3
+ import { t as e } from "./chunk-DyIg6Wiv.js";
4
+ import { n as t, r as n, t as r } from "./routing-CRln5Gw7.js";
5
+ import { useI18n as i } from "@fluenti/react";
6
+ import { createElement as a, forwardRef as o } from "react";
7
+ import { cookieName as s } from "@fluenti/next/i18n-config";
8
+ import { usePathname as c, useRouter as l } from "next/navigation";
8
9
  //#region src/create-navigation.tsx
9
- n();
10
- function f(e) {
11
- let { locales: n, sourceLocale: i, localePrefix: a = "as-needed", pathnames: o } = e;
12
- function l(e, n) {
10
+ function u(t) {
11
+ let { locales: r, sourceLocale: i, localePrefix: s = "as-needed", pathnames: c } = t;
12
+ function l(e, t) {
13
13
  let r = e;
14
- if (o) {
15
- let i = t(e, n, o);
14
+ if (c) {
15
+ let i = n(e, t, c);
16
16
  i && (r = i);
17
17
  }
18
- return a === "never" || a === "as-needed" && n === i ? r : `/${n}${r}`;
18
+ return s === "never" || s === "as-needed" && t === i ? r : `/${t}${r}`;
19
19
  }
20
20
  function u(e) {
21
- if (a === "never") return e;
22
- let t = e.split("/"), r = (t[1] ?? "").toLowerCase();
23
- return n.some((e) => e.toLowerCase() === r) ? "/" + t.slice(2).join("/") || "/" : e;
21
+ if (s === "never") return e;
22
+ let t = e.split("/"), n = (t[1] ?? "").toLowerCase();
23
+ return r.some((e) => e.toLowerCase() === n) ? "/" + t.slice(2).join("/") || "/" : e;
24
24
  }
25
- let d = c(function({ href: e, locale: t, ...n }, a) {
26
- let o = r("next/link").default, c = i;
25
+ let d = o(function({ href: t, locale: n, ...r }, o) {
26
+ let s = e("next/link").default, c = i;
27
27
  try {
28
- let { useI18n: e } = r("@fluenti/react");
29
- c = e().locale;
28
+ let { useI18n: t } = e("@fluenti/react");
29
+ c = t().locale;
30
30
  } catch {}
31
- return s(o, {
32
- ref: a,
33
- href: l(String(e), String(t ?? c)),
34
- ...n
31
+ return a(s, {
32
+ ref: o,
33
+ href: l(String(t), String(n ?? c)),
34
+ ...r
35
35
  });
36
36
  });
37
37
  d.displayName = "I18nLink";
38
38
  function f() {
39
- let { useRouter: e } = r("next/navigation"), { useI18n: t } = r("@fluenti/react"), n = e(), { locale: i } = t();
39
+ let { useRouter: t } = e("next/navigation"), { useI18n: n } = e("@fluenti/react"), r = t(), { locale: i } = n();
40
40
  return {
41
41
  push(e, t) {
42
- n.push(l(String(e), String(t?.locale ?? i)));
42
+ r.push(l(String(e), String(t?.locale ?? i)));
43
43
  },
44
44
  replace(e, t) {
45
- n.replace(l(String(e), String(t?.locale ?? i)));
45
+ r.replace(l(String(e), String(t?.locale ?? i)));
46
46
  },
47
- back: () => n.back(),
48
- forward: () => n.forward(),
49
- refresh: () => n.refresh(),
50
- prefetch: (e) => n.prefetch(e)
47
+ back: () => r.back(),
48
+ forward: () => r.forward(),
49
+ refresh: () => r.refresh(),
50
+ prefetch: (e) => r.prefetch(e)
51
51
  };
52
52
  }
53
- function p(e, t) {
54
- let { redirect: n } = r("next/navigation");
55
- return n(l(String(e), String(t ?? i)));
53
+ function p(t, n) {
54
+ let { redirect: r } = e("next/navigation");
55
+ return r(l(String(t), String(n ?? i)));
56
56
  }
57
57
  function m() {
58
- let { usePathname: e } = r("next/navigation");
59
- return u(e());
58
+ let { usePathname: t } = e("next/navigation");
59
+ return u(t());
60
60
  }
61
61
  function h(e, t) {
62
62
  return l(String(e), String(t));
@@ -71,51 +71,49 @@ function f(e) {
71
71
  }
72
72
  //#endregion
73
73
  //#region src/navigation.ts
74
- n();
75
- function p(e, t, n) {
76
- let r = n?.sourceLocale ?? "en", i = n?.localePrefix ?? "as-needed", a = e.split("/"), o = a[1] ?? "", s = (n?.locales ? n.locales.includes(o) : /^[a-z]{2}(-[A-Za-z]{2,})?$/.test(o)) ? "/" + a.slice(2).join("/") : e;
74
+ function d(e, t, n) {
75
+ let r = n?.sourceLocale ?? "en", i = n?.localePrefix ?? "as-needed", a = e.split("/"), o = a[1] ?? "", s = n?.locales && n.locales.some((e) => e.toLowerCase() === o.toLowerCase()) ? "/" + a.slice(2).join("/") : e;
77
76
  return i === "never" || i !== "always" && t === r ? s || "/" : `/${t}${s}`;
78
77
  }
79
- function m(e) {
80
- let t = d(), n = u(), { locale: r, setLocale: i, getLocales: a } = o(), s = a(), c = e?.sourceLocale ?? s[0] ?? "en", f = e?.cookieName ?? l, m = e?.localePrefix ?? "as-needed";
78
+ function f(e) {
79
+ let t = l(), n = c(), { locale: r, setLocale: a, getLocales: o } = i(), u = o(), f = e?.sourceLocale ?? u[0] ?? "en", p = e?.cookieName ?? s, m = e?.localePrefix ?? "as-needed";
81
80
  return {
82
81
  switchLocale: (e) => {
83
- if (!s.includes(e)) {
82
+ if (!u.includes(e)) {
84
83
  typeof process < "u" && process.env.NODE_ENV !== "production" && console.warn(`[fluenti] switchLocale: invalid locale "${e}"`);
85
84
  return;
86
85
  }
87
- document.cookie = `${f}=${encodeURIComponent(e)};path=/;max-age=31536000;samesite=lax`, i(e);
88
- let r = p(n, e, {
89
- sourceLocale: c,
90
- locales: s,
86
+ document.cookie = `${p}=${encodeURIComponent(e)};path=/;max-age=31536000;samesite=lax`, a(e);
87
+ let r = d(n, e, {
88
+ sourceLocale: f,
89
+ locales: u,
91
90
  localePrefix: m
92
91
  });
93
92
  t.push(r), t.refresh();
94
93
  },
95
94
  currentLocale: r,
96
- locales: s,
97
- sourceLocale: c
95
+ locales: u,
96
+ sourceLocale: f
98
97
  };
99
98
  }
100
- function h(t) {
101
- let { routing: r, baseUrl: a = "" } = t, o = u(), s = o.split("/"), c = s[1] ?? "", l = r.locales.some((e) => e.toLowerCase() === c.toLowerCase()) ? "/" + s.slice(2).join("/") || "/" : o, d = r.locales.map((t) => {
102
- let o = l;
103
- if (r.pathnames) {
104
- let { resolveLocalizedPath: a } = (n(), i(e)), s = a(l, t, r.pathnames);
105
- s && (o = s);
106
- }
107
- let s;
108
- return s = r.localePrefix === "never" || r.localePrefix !== "always" && t === r.sourceLocale ? `${a}${o}` : `${a}/${t}${o}`, {
109
- hreflang: t,
110
- href: s
99
+ function p(e) {
100
+ let { routing: r, baseUrl: a = "" } = e, o = c(), s = r.sourceLocale;
101
+ try {
102
+ s = i().locale;
103
+ } catch {}
104
+ let l = o.split("/"), u = l[1] ?? "", d = r.localePrefix === "never" ? null : r.locales.find((e) => e.toLowerCase() === u.toLowerCase()) ?? null, f = d ? "/" + l.slice(2).join("/") || "/" : o, p = d ?? s ?? r.sourceLocale, m = r.pathnames ? t(f, p, r.pathnames) ?? f : f, h = r.locales.map((e) => {
105
+ let t = r.pathnames ? n(m, e, r.pathnames) ?? m : m, i;
106
+ return i = r.localePrefix === "never" || r.localePrefix !== "always" && e === r.sourceLocale ? `${a}${t}` : `${a}/${e}${t}`, {
107
+ hreflang: e,
108
+ href: i
111
109
  };
112
- }), f = r.localePrefix === "always" ? `${a}/${r.sourceLocale}${l}` : `${a}${l}`;
113
- return d.push({
110
+ }), g = r.pathnames ? n(m, r.sourceLocale, r.pathnames) ?? m : m, _ = r.localePrefix === "always" ? `${a}/${r.sourceLocale}${g}` : `${a}${g}`;
111
+ return h.push({
114
112
  hreflang: "x-default",
115
- href: f
116
- }), d;
113
+ href: _
114
+ }), h;
117
115
  }
118
116
  //#endregion
119
- export { f as createNavigation, a as defineRouting, p as getLocalePath, t as resolveLocalizedPath, h as useAlternateLinks, m as useLocaleSwitcher };
117
+ export { u as createNavigation, r as defineRouting, d as getLocalePath, n as resolveLocalizedPath, p as useAlternateLinks, f as useLocaleSwitcher };
120
118
 
121
119
  //# sourceMappingURL=navigation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.js","names":[],"sources":["../src/create-navigation.tsx","../src/navigation.ts"],"sourcesContent":["/**\n * @module @fluenti/next/navigation\n *\n * Type-safe navigation factory for Next.js i18n routing.\n *\n * @example\n * ```tsx\n * // src/lib/navigation.ts\n * import { createNavigation } from '@fluenti/next/navigation'\n *\n * export const { Link, useRouter, redirect, usePathname, getPathname } = createNavigation({\n * locales: ['en', 'fr', 'ja'] as const,\n * sourceLocale: 'en',\n * localePrefix: 'as-needed',\n * pathnames: {\n * '/': { fr: '/', ja: '/' },\n * '/about': { fr: '/a-propos', ja: '/about' },\n * '/blog/[slug]': { fr: '/articles/[slug]', ja: '/blog/[slug]' },\n * },\n * })\n * ```\n */\n'use client'\n\nimport { createElement, forwardRef } from 'react'\nimport type { ReactNode } from 'react'\nimport { resolveLocalizedPath } from './routing'\nimport type { RoutingConfig } from './routing'\n\nexport type { RoutingConfig }\n\ninterface NavigationLinkProps<P extends string = string, L extends string = string> {\n href: P | (string & Record<never, never>)\n locale?: L\n children?: ReactNode\n prefetch?: boolean | null\n replace?: boolean\n scroll?: boolean\n target?: string\n className?: string\n [key: string]: unknown\n}\n\ninterface TypedRouter<P extends string = string, L extends string = string> {\n push(href: P | (string & Record<never, never>), options?: { locale?: L }): void\n replace(href: P | (string & Record<never, never>), options?: { locale?: L }): void\n back(): void\n forward(): void\n refresh(): void\n prefetch(href: string): void\n}\n\n// ── Factory ───────────────────────────────────────────────────────────────\n\nexport function createNavigation<\n const L extends string,\n const P extends string,\n>(routing: RoutingConfig<L, P>) {\n const { locales, sourceLocale, localePrefix = 'as-needed', pathnames } = routing\n\n function resolvePath(href: string, locale: string): string {\n // Apply pathnames mapping if configured (supports [param] and [...slug])\n let resolved = href\n if (pathnames) {\n const mapped = resolveLocalizedPath(href, locale, pathnames as Record<string, Record<string, string>>)\n if (mapped) resolved = mapped\n }\n\n // Apply locale prefix\n if (localePrefix === 'never') return resolved\n if (localePrefix === 'as-needed' && locale === sourceLocale) return resolved\n return `/${locale}${resolved}`\n }\n\n function stripPrefix(pathname: string): string {\n if (localePrefix === 'never') return pathname\n const segments = pathname.split('/')\n const first = segments[1] ?? ''\n const lower = first.toLowerCase()\n const isLocale = locales.some(l => l.toLowerCase() === lower)\n if (isLocale) return '/' + segments.slice(2).join('/') || '/'\n return pathname\n }\n\n // ── Link component ────────────────────────────────────────────────────\n\n const Link = forwardRef<HTMLAnchorElement, NavigationLinkProps<P, L>>(\n function I18nLink({ href, locale: localeProp, ...rest }, ref) {\n // Dynamic imports to avoid SSR issues — these are resolved at runtime\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const NextLink = require('next/link').default\n let currentLocale = sourceLocale\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { useI18n } = require('@fluenti/react')\n const i18n = useI18n()\n currentLocale = i18n.locale\n } catch {\n // Outside I18nProvider, use sourceLocale\n }\n const locale = localeProp ?? currentLocale\n const resolvedHref = resolvePath(String(href), String(locale))\n return createElement(NextLink, { ref, href: resolvedHref, ...rest })\n },\n )\n Link.displayName = 'I18nLink'\n\n // ── useRouter hook ────────────────────────────────────────────────────\n\n function useRouter(): TypedRouter<P, L> {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { useRouter: useNextRouter } = require('next/navigation')\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { useI18n } = require('@fluenti/react')\n\n const nextRouter = useNextRouter()\n const { locale } = useI18n()\n\n return {\n push(href: P | string, options?: { locale?: L }) {\n nextRouter.push(resolvePath(String(href), String(options?.locale ?? locale)))\n },\n replace(href: P | string, options?: { locale?: L }) {\n nextRouter.replace(resolvePath(String(href), String(options?.locale ?? locale)))\n },\n back: () => nextRouter.back(),\n forward: () => nextRouter.forward(),\n refresh: () => nextRouter.refresh(),\n prefetch: (href: string) => nextRouter.prefetch(href),\n }\n }\n\n // ── redirect function (server-side) ───────────────────────────────────\n\n function redirect(href: P | (string & Record<never, never>), locale?: L): never {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { redirect: nextRedirect } = require('next/navigation') as { redirect: (url: string) => never }\n const resolvedLocale = locale ?? sourceLocale\n return nextRedirect(resolvePath(String(href), String(resolvedLocale)))\n }\n\n // ── usePathname hook ──────────────────────────────────────────────────\n\n function usePathname(): string {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { usePathname: useNextPathname } = require('next/navigation')\n const pathname = useNextPathname()\n return stripPrefix(pathname)\n }\n\n // ── getPathname utility ───────────────────────────────────────────────\n\n function getPathname(href: P | (string & Record<never, never>), locale: L): string {\n return resolvePath(String(href), String(locale))\n }\n\n return { Link, useRouter, redirect, usePathname, getPathname }\n}\n","'use client'\n\n/**\n * @module @fluenti/next/navigation\n *\n * Navigation utilities for locale-aware routing in Next.js App Router.\n *\n * @example\n * ```tsx\n * import { useLocaleSwitcher } from '@fluenti/next/navigation'\n *\n * function LanguagePicker() {\n * const { switchLocale, currentLocale, locales } = useLocaleSwitcher()\n * return (\n * <select value={currentLocale} onChange={(e) => switchLocale(e.target.value)}>\n * {locales.map((l) => <option key={l} value={l}>{l}</option>)}\n * </select>\n * )\n * }\n * ```\n */\nimport { useRouter, usePathname } from 'next/navigation'\nimport { useI18n } from '@fluenti/react'\nimport { cookieName as _configCookieName } from '@fluenti/next/i18n-config'\n\nexport interface GetLocalePathOptions {\n /** Source/default locale (no prefix in as-needed mode) */\n sourceLocale?: string\n /**\n * Known locale codes (e.g. ['en', 'fr', 'ja']).\n * When provided, the existing prefix is only stripped when it's an actual locale —\n * preventing false matches on generic 2-letter path segments like /my or /us.\n */\n locales?: string[]\n /**\n * Locale prefix strategy. Matches the middleware `localePrefix` setting.\n * - `'as-needed'` (default): source locale has no prefix (`/about` for en, `/fr/about` for fr)\n * - `'always'`: all locales get a prefix (`/en/about`, `/fr/about`)\n * - `'never'`: no locale prefix in URLs\n */\n localePrefix?: 'always' | 'as-needed' | 'never'\n}\n\n/**\n * Get the locale-prefixed path for a given pathname and locale.\n *\n * Pure function — works on both server and client.\n *\n * @example\n * ```ts\n * getLocalePath('/about', 'fr') // → '/fr/about'\n * getLocalePath('/about', 'en') // → '/about' (source locale, no prefix)\n * getLocalePath('/fr/about', 'en') // → '/about'\n * getLocalePath('/fr/about', 'ja') // → '/ja/about'\n * getLocalePath('/about', 'en', { localePrefix: 'always' }) // → '/en/about'\n * ```\n */\nexport function getLocalePath(\n pathname: string,\n locale: string,\n options?: GetLocalePathOptions,\n): string {\n const sourceLocale = options?.sourceLocale ?? 'en'\n const localePrefix = options?.localePrefix ?? 'as-needed'\n\n // Strip existing locale prefix if present\n const segments = pathname.split('/')\n const firstSegment = segments[1] ?? ''\n\n // Check if the first segment is a locale prefix.\n // If a locales list is provided, do an exact membership check to avoid false positives\n // on generic 2-letter path segments (e.g. /my/page or /us/pricing).\n // Otherwise fall back to the heuristic regex.\n const hasLocalePrefix = options?.locales\n ? options.locales.includes(firstSegment)\n : /^[a-z]{2}(-[A-Za-z]{2,})?$/.test(firstSegment)\n const pathWithoutLocale = hasLocalePrefix\n ? '/' + segments.slice(2).join('/')\n : pathname\n\n // 'never' mode: no prefix for any locale\n if (localePrefix === 'never') {\n return pathWithoutLocale || '/'\n }\n\n // In 'as-needed' mode, source locale gets no prefix\n if (localePrefix !== 'always' && locale === sourceLocale) {\n return pathWithoutLocale || '/'\n }\n\n return `/${locale}${pathWithoutLocale}`\n}\n\n/**\n * Hook for switching locales in Next.js App Router.\n *\n * Sets a cookie to remember user preference, navigates to the new locale path,\n * and triggers a server component refresh.\n */\nexport function useLocaleSwitcher(options?: {\n /** Override the source/default locale instead of inferring from locales[0]. */\n sourceLocale?: string\n /**\n * Cookie name used by the middleware for locale preference.\n * Defaults to the value from `fluenti.config.ts` (auto-read at build time).\n * Must match the middleware `cookieName` option.\n */\n cookieName?: string\n /** Locale prefix strategy — must match the middleware `localePrefix` option. */\n localePrefix?: 'always' | 'as-needed' | 'never'\n}) {\n const router = useRouter()\n const pathname = usePathname()\n const { locale, setLocale, getLocales } = useI18n()\n\n // Read locales from I18nProvider context (works on client without fs)\n const locales = getLocales()\n const sourceLocale = options?.sourceLocale ?? locales[0] ?? 'en'\n const cookieName = options?.cookieName ?? _configCookieName\n const localePrefix = options?.localePrefix ?? 'as-needed'\n\n const switchLocale = (newLocale: string) => {\n // Validate locale against known locales to prevent cookie injection\n if (!locales.includes(newLocale)) {\n if (typeof process !== 'undefined' && process.env?.['NODE_ENV'] !== 'production') {\n console.warn(`[fluenti] switchLocale: invalid locale \"${newLocale}\"`)\n }\n return\n }\n // 1. Set cookie to remember preference (uses configured cookie name)\n document.cookie = `${cookieName}=${encodeURIComponent(newLocale)};path=/;max-age=31536000;samesite=lax`\n // 2. Update React context\n setLocale(newLocale)\n // 3. Navigate to new locale path\n const newPath = getLocalePath(pathname, newLocale, { sourceLocale, locales, localePrefix })\n router.push(newPath)\n // 4. Refresh server components\n router.refresh()\n }\n\n return {\n switchLocale,\n currentLocale: locale,\n locales,\n sourceLocale,\n }\n}\n\n// Re-export createNavigation and routing utilities\nexport { createNavigation } from './create-navigation'\nexport { defineRouting, resolveLocalizedPath } from './routing'\nexport type { RoutingConfig } from './routing'\n\n// ── useAlternateLinks ─────────────────────────────────────────────────────\n\nexport interface AlternateLink {\n hreflang: string\n href: string\n}\n\n/**\n * Generate alternate link entries for SEO `<head>` tags.\n *\n * Returns an array of `{ hreflang, href }` entries for all configured locales\n * plus `x-default`. Use in `<head>` for hreflang tags.\n *\n * @example\n * ```tsx\n * import { useAlternateLinks } from '@fluenti/next/navigation'\n * import { routing } from '@/i18n/routing'\n *\n * export function Head() {\n * const links = useAlternateLinks({ routing, baseUrl: 'https://example.com' })\n * return (\n * <head>\n * {links.map(l => (\n * <link key={l.hreflang} rel=\"alternate\" hreflang={l.hreflang} href={l.href} />\n * ))}\n * </head>\n * )\n * }\n * ```\n */\nexport function useAlternateLinks(options: {\n routing: { locales: readonly string[]; sourceLocale: string; localePrefix?: 'always' | 'as-needed' | 'never'; pathnames?: Record<string, Record<string, string>> }\n baseUrl?: string\n}): AlternateLink[] {\n const { routing: r, baseUrl = '' } = options\n const pathname = usePathname()\n // Strip locale prefix from current path\n const segments = pathname.split('/')\n const firstSeg = segments[1] ?? ''\n const isLocalePrefix = (r.locales as string[]).some(l => l.toLowerCase() === firstSeg.toLowerCase())\n const cleanPath = isLocalePrefix ? '/' + segments.slice(2).join('/') || '/' : pathname\n\n const links: AlternateLink[] = (r.locales as string[]).map(loc => {\n let localePath = cleanPath\n if (r.pathnames) {\n const { resolveLocalizedPath: resolve } = require('./routing') as typeof import('./routing')\n const mapped = resolve(cleanPath, loc, r.pathnames as Record<string, Record<string, string>>)\n if (mapped) localePath = mapped\n }\n\n let href: string\n if (r.localePrefix === 'never') {\n href = `${baseUrl}${localePath}`\n } else if (r.localePrefix !== 'always' && loc === r.sourceLocale) {\n href = `${baseUrl}${localePath}`\n } else {\n href = `${baseUrl}/${loc}${localePath}`\n }\n\n return { hreflang: loc, href }\n })\n\n // x-default\n const defaultPath = r.localePrefix === 'always' ? `${baseUrl}/${r.sourceLocale}${cleanPath}` : `${baseUrl}${cleanPath}`\n links.push({ hreflang: 'x-default', href: defaultPath })\n\n return links\n}\n"],"mappings":";;;;;;;GA0BqC;AA4BrC,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,QAAA,IAAA,aAA6C,gBAClE,QAAQ,KAAK,2CAA2C,EAAU,GAAG;AAEvE;;AAKF,GAFA,SAAS,SAAS,GAAG,EAAW,GAAG,mBAAmB,EAAU,CAAC,wCAEjE,EAAU,EAAU;GAEpB,IAAM,IAAU,EAAc,GAAU,GAAW;IAAE;IAAc;IAAS;IAAc,CAAC;AAG3F,GAFA,EAAO,KAAK,EAAQ,EAEpB,EAAO,SAAS;;EAKhB,eAAe;EACf;EACA;EACD;;AAsCH,SAAgB,EAAkB,GAGd;CAClB,IAAM,EAAE,SAAS,GAAG,aAAU,OAAO,GAC/B,IAAW,GAAa,EAExB,IAAW,EAAS,MAAM,IAAI,EAC9B,IAAW,EAAS,MAAM,IAE1B,IADkB,EAAE,QAAqB,MAAK,MAAK,EAAE,aAAa,KAAK,EAAS,aAAa,CAAC,GACjE,MAAM,EAAS,MAAM,EAAE,CAAC,KAAK,IAAI,IAAI,MAAM,GAExE,IAA0B,EAAE,QAAqB,KAAI,MAAO;EAChE,IAAI,IAAa;AACjB,MAAI,EAAE,WAAW;GACf,IAAM,EAAE,sBAAsB,OAAA,GAAA,EAAA,EAAA,EAAA,GACxB,IAAS,EAAQ,GAAW,GAAK,EAAE,UAAoD;AAC7F,GAAI,MAAQ,IAAa;;EAG3B,IAAI;AASJ,SARA,AAKE,IALE,EAAE,iBAAiB,WAEZ,EAAE,iBAAiB,YAAY,MAAQ,EAAE,eAD3C,GAAG,IAAU,MAIb,GAAG,EAAQ,GAAG,IAAM,KAGtB;GAAE,UAAU;GAAK;GAAM;GAC9B,EAGI,IAAc,EAAE,iBAAiB,WAAW,GAAG,EAAQ,GAAG,EAAE,eAAe,MAAc,GAAG,IAAU;AAG5G,QAFA,EAAM,KAAK;EAAE,UAAU;EAAa,MAAM;EAAa,CAAC,EAEjD"}
1
+ {"version":3,"file":"navigation.js","names":[],"sources":["../src/create-navigation.tsx","../src/navigation.ts"],"sourcesContent":["/**\n * @module @fluenti/next/navigation\n *\n * Type-safe navigation factory for Next.js i18n routing.\n *\n * @example\n * ```tsx\n * // src/lib/navigation.ts\n * import { createNavigation } from '@fluenti/next/navigation'\n *\n * export const { Link, useRouter, redirect, usePathname, getPathname } = createNavigation({\n * locales: ['en', 'fr', 'ja'] as const,\n * sourceLocale: 'en',\n * localePrefix: 'as-needed',\n * pathnames: {\n * '/': { fr: '/', ja: '/' },\n * '/about': { fr: '/a-propos', ja: '/about' },\n * '/blog/[slug]': { fr: '/articles/[slug]', ja: '/blog/[slug]' },\n * },\n * })\n * ```\n */\n'use client'\n\nimport { createElement, forwardRef } from 'react'\nimport type { ReactNode } from 'react'\nimport { resolveLocalizedPath } from './routing'\nimport type { RoutingConfig } from './routing'\n\nexport type { RoutingConfig }\n\ninterface NavigationLinkProps<P extends string = string, L extends string = string> {\n href: P | (string & Record<never, never>)\n locale?: L\n children?: ReactNode\n prefetch?: boolean | null\n replace?: boolean\n scroll?: boolean\n target?: string\n className?: string\n [key: string]: unknown\n}\n\ninterface TypedRouter<P extends string = string, L extends string = string> {\n push(href: P | (string & Record<never, never>), options?: { locale?: L }): void\n replace(href: P | (string & Record<never, never>), options?: { locale?: L }): void\n back(): void\n forward(): void\n refresh(): void\n prefetch(href: string): void\n}\n\n// ── Factory ───────────────────────────────────────────────────────────────\n\nexport function createNavigation<\n const L extends string,\n const P extends string,\n>(routing: RoutingConfig<L, P>) {\n const { locales, sourceLocale, localePrefix = 'as-needed', pathnames } = routing\n\n function resolvePath(href: string, locale: string): string {\n // Apply pathnames mapping if configured (supports [param] and [...slug])\n let resolved = href\n if (pathnames) {\n const mapped = resolveLocalizedPath(href, locale, pathnames as Record<string, Record<string, string>>)\n if (mapped) resolved = mapped\n }\n\n // Apply locale prefix\n if (localePrefix === 'never') return resolved\n if (localePrefix === 'as-needed' && locale === sourceLocale) return resolved\n return `/${locale}${resolved}`\n }\n\n function stripPrefix(pathname: string): string {\n if (localePrefix === 'never') return pathname\n const segments = pathname.split('/')\n const first = segments[1] ?? ''\n const lower = first.toLowerCase()\n const isLocale = locales.some(l => l.toLowerCase() === lower)\n if (isLocale) return '/' + segments.slice(2).join('/') || '/'\n return pathname\n }\n\n // ── Link component ────────────────────────────────────────────────────\n\n const Link = forwardRef<HTMLAnchorElement, NavigationLinkProps<P, L>>(\n function I18nLink({ href, locale: localeProp, ...rest }, ref) {\n // Dynamic imports to avoid SSR issues — these are resolved at runtime\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const NextLink = require('next/link').default\n let currentLocale = sourceLocale\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { useI18n } = require('@fluenti/react')\n const i18n = useI18n()\n currentLocale = i18n.locale\n } catch {\n // Outside I18nProvider, use sourceLocale\n }\n const locale = localeProp ?? currentLocale\n const resolvedHref = resolvePath(String(href), String(locale))\n return createElement(NextLink, { ref, href: resolvedHref, ...rest })\n },\n )\n Link.displayName = 'I18nLink'\n\n // ── useRouter hook ────────────────────────────────────────────────────\n\n function useRouter(): TypedRouter<P, L> {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { useRouter: useNextRouter } = require('next/navigation')\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { useI18n } = require('@fluenti/react')\n\n const nextRouter = useNextRouter()\n const { locale } = useI18n()\n\n return {\n push(href: P | string, options?: { locale?: L }) {\n nextRouter.push(resolvePath(String(href), String(options?.locale ?? locale)))\n },\n replace(href: P | string, options?: { locale?: L }) {\n nextRouter.replace(resolvePath(String(href), String(options?.locale ?? locale)))\n },\n back: () => nextRouter.back(),\n forward: () => nextRouter.forward(),\n refresh: () => nextRouter.refresh(),\n prefetch: (href: string) => nextRouter.prefetch(href),\n }\n }\n\n // ── redirect function (server-side) ───────────────────────────────────\n\n function redirect(href: P | (string & Record<never, never>), locale?: L): never {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { redirect: nextRedirect } = require('next/navigation') as { redirect: (url: string) => never }\n const resolvedLocale = locale ?? sourceLocale\n return nextRedirect(resolvePath(String(href), String(resolvedLocale)))\n }\n\n // ── usePathname hook ──────────────────────────────────────────────────\n\n function usePathname(): string {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { usePathname: useNextPathname } = require('next/navigation')\n const pathname = useNextPathname()\n return stripPrefix(pathname)\n }\n\n // ── getPathname utility ───────────────────────────────────────────────\n\n function getPathname(href: P | (string & Record<never, never>), locale: L): string {\n return resolvePath(String(href), String(locale))\n }\n\n return { Link, useRouter, redirect, usePathname, getPathname }\n}\n","'use client'\n\n/**\n * @module @fluenti/next/navigation\n *\n * Navigation utilities for locale-aware routing in Next.js App Router.\n *\n * @example\n * ```tsx\n * import { useLocaleSwitcher } from '@fluenti/next/navigation'\n *\n * function LanguagePicker() {\n * const { switchLocale, currentLocale, locales } = useLocaleSwitcher()\n * return (\n * <select value={currentLocale} onChange={(e) => switchLocale(e.target.value)}>\n * {locales.map((l) => <option key={l} value={l}>{l}</option>)}\n * </select>\n * )\n * }\n * ```\n */\nimport { useRouter, usePathname } from 'next/navigation'\nimport { useI18n } from '@fluenti/react'\nimport { cookieName as _configCookieName } from '@fluenti/next/i18n-config'\nimport { resolveInternalPath, resolveLocalizedPath } from './routing'\n\nexport interface GetLocalePathOptions {\n /** Source/default locale (no prefix in as-needed mode) */\n sourceLocale?: string\n /**\n * Known locale codes (e.g. ['en', 'fr', 'ja']).\n * When provided, the existing prefix is only stripped when it's an actual locale —\n * preventing false matches on generic 2-letter path segments like /my or /us.\n */\n locales?: string[]\n /**\n * Locale prefix strategy. Matches the middleware `localePrefix` setting.\n * - `'as-needed'` (default): source locale has no prefix (`/about` for en, `/fr/about` for fr)\n * - `'always'`: all locales get a prefix (`/en/about`, `/fr/about`)\n * - `'never'`: no locale prefix in URLs\n */\n localePrefix?: 'always' | 'as-needed' | 'never'\n}\n\n/**\n * Get the locale-prefixed path for a given pathname and locale.\n *\n * Pure function — works on both server and client.\n *\n * @example\n * ```ts\n * getLocalePath('/about', 'fr') // → '/fr/about'\n * getLocalePath('/about', 'en') // → '/about' (source locale, no prefix)\n * getLocalePath('/fr/about', 'en', { locales: ['en', 'fr', 'ja'] }) // → '/about'\n * getLocalePath('/fr/about', 'ja', { locales: ['en', 'fr', 'ja'] }) // → '/ja/about'\n * getLocalePath('/about', 'en', { localePrefix: 'always' }) // → '/en/about'\n * ```\n */\nexport function getLocalePath(\n pathname: string,\n locale: string,\n options?: GetLocalePathOptions,\n): string {\n const sourceLocale = options?.sourceLocale ?? 'en'\n const localePrefix = options?.localePrefix ?? 'as-needed'\n\n // Strip existing locale prefix if present\n const segments = pathname.split('/')\n const firstSegment = segments[1] ?? ''\n\n // Only strip an existing locale prefix when the caller provides the known locale list.\n const hasLocalePrefix = options?.locales\n ? options.locales.some(loc => loc.toLowerCase() === firstSegment.toLowerCase())\n : false\n const pathWithoutLocale = hasLocalePrefix\n ? '/' + segments.slice(2).join('/')\n : pathname\n\n // 'never' mode: no prefix for any locale\n if (localePrefix === 'never') {\n return pathWithoutLocale || '/'\n }\n\n // In 'as-needed' mode, source locale gets no prefix\n if (localePrefix !== 'always' && locale === sourceLocale) {\n return pathWithoutLocale || '/'\n }\n\n return `/${locale}${pathWithoutLocale}`\n}\n\n/**\n * Hook for switching locales in Next.js App Router.\n *\n * Sets a cookie to remember user preference, navigates to the new locale path,\n * and triggers a server component refresh.\n */\nexport function useLocaleSwitcher(options?: {\n /** Override the source/default locale instead of inferring from locales[0]. */\n sourceLocale?: string\n /**\n * Cookie name used by the middleware for locale preference.\n * Defaults to the value from `fluenti.config.ts` (auto-read at build time).\n * Must match the middleware `cookieName` option.\n */\n cookieName?: string\n /** Locale prefix strategy — must match the middleware `localePrefix` option. */\n localePrefix?: 'always' | 'as-needed' | 'never'\n}) {\n const router = useRouter()\n const pathname = usePathname()\n const { locale, setLocale, getLocales } = useI18n()\n\n // Read locales from I18nProvider context (works on client without fs)\n const locales = getLocales()\n const sourceLocale = options?.sourceLocale ?? locales[0] ?? 'en'\n const cookieName = options?.cookieName ?? _configCookieName\n const localePrefix = options?.localePrefix ?? 'as-needed'\n\n const switchLocale = (newLocale: string) => {\n // Validate locale against known locales to prevent cookie injection\n if (!locales.includes(newLocale)) {\n if (typeof process !== 'undefined' && process.env?.['NODE_ENV'] !== 'production') {\n console.warn(`[fluenti] switchLocale: invalid locale \"${newLocale}\"`)\n }\n return\n }\n // 1. Set cookie to remember preference (uses configured cookie name)\n document.cookie = `${cookieName}=${encodeURIComponent(newLocale)};path=/;max-age=31536000;samesite=lax`\n // 2. Update React context\n setLocale(newLocale)\n // 3. Navigate to new locale path\n const newPath = getLocalePath(pathname, newLocale, { sourceLocale, locales, localePrefix })\n router.push(newPath)\n // 4. Refresh server components\n router.refresh()\n }\n\n return {\n switchLocale,\n currentLocale: locale,\n locales,\n sourceLocale,\n }\n}\n\n// Re-export createNavigation and routing utilities\nexport { createNavigation } from './create-navigation'\nexport { defineRouting, resolveLocalizedPath } from './routing'\nexport type { RoutingConfig } from './routing'\n\n// ── useAlternateLinks ─────────────────────────────────────────────────────\n\nexport interface AlternateLink {\n hreflang: string\n href: string\n}\n\n/**\n * Generate alternate link entries for SEO `<head>` tags.\n *\n * Returns an array of `{ hreflang, href }` entries for all configured locales\n * plus `x-default`. Use in `<head>` for hreflang tags.\n *\n * @example\n * ```tsx\n * import { useAlternateLinks } from '@fluenti/next/navigation'\n * import { routing } from '@/i18n/routing'\n *\n * export function Head() {\n * const links = useAlternateLinks({ routing, baseUrl: 'https://example.com' })\n * return (\n * <head>\n * {links.map(l => (\n * <link key={l.hreflang} rel=\"alternate\" hreflang={l.hreflang} href={l.href} />\n * ))}\n * </head>\n * )\n * }\n * ```\n */\nexport function useAlternateLinks(options: {\n routing: { locales: readonly string[]; sourceLocale: string; localePrefix?: 'always' | 'as-needed' | 'never'; pathnames?: Record<string, Record<string, string>> }\n baseUrl?: string\n}): AlternateLink[] {\n const { routing: r, baseUrl = '' } = options\n const pathname = usePathname()\n let activeLocale = r.sourceLocale\n try {\n activeLocale = useI18n().locale\n } catch {\n // Outside I18nProvider, fall back to sourceLocale.\n }\n // Strip locale prefix from current path\n const segments = pathname.split('/')\n const firstSeg = segments[1] ?? ''\n const pathLocale = r.localePrefix === 'never'\n ? null\n : (r.locales as string[]).find(l => l.toLowerCase() === firstSeg.toLowerCase()) ?? null\n const cleanPath = pathLocale ? '/' + segments.slice(2).join('/') || '/' : pathname\n const requestLocale = pathLocale ?? activeLocale ?? r.sourceLocale\n const internalPath = r.pathnames\n ? resolveInternalPath(cleanPath, requestLocale, r.pathnames as Record<string, Record<string, string>>) ?? cleanPath\n : cleanPath\n\n const links: AlternateLink[] = (r.locales as string[]).map(loc => {\n const localePath = r.pathnames\n ? resolveLocalizedPath(internalPath, loc, r.pathnames as Record<string, Record<string, string>>) ?? internalPath\n : internalPath\n\n let href: string\n if (r.localePrefix === 'never') {\n href = `${baseUrl}${localePath}`\n } else if (r.localePrefix !== 'always' && loc === r.sourceLocale) {\n href = `${baseUrl}${localePath}`\n } else {\n href = `${baseUrl}/${loc}${localePath}`\n }\n\n return { hreflang: loc, href }\n })\n\n // x-default\n const sourcePath = r.pathnames\n ? resolveLocalizedPath(internalPath, r.sourceLocale, r.pathnames as Record<string, Record<string, string>>) ?? internalPath\n : internalPath\n const defaultPath = r.localePrefix === 'always'\n ? `${baseUrl}/${r.sourceLocale}${sourcePath}`\n : `${baseUrl}${sourcePath}`\n links.push({ hreflang: 'x-default', href: defaultPath })\n\n return links\n}\n"],"mappings":";;;;;;;;AAsDA,SAAgB,EAGd,GAA8B;CAC9B,IAAM,EAAE,YAAS,iBAAc,kBAAe,aAAa,iBAAc;CAEzE,SAAS,EAAY,GAAc,GAAwB;EAEzD,IAAI,IAAW;AACf,MAAI,GAAW;GACb,IAAM,IAAS,EAAqB,GAAM,GAAQ,EAAoD;AACtG,GAAI,MAAQ,IAAW;;AAMzB,SAFI,MAAiB,WACjB,MAAiB,eAAe,MAAW,IAAqB,IAC7D,IAAI,IAAS;;CAGtB,SAAS,EAAY,GAA0B;AAC7C,MAAI,MAAiB,QAAS,QAAO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AAE,SAAS,GAAG,aAAU,OAAO,GAC/B,IAAW,GAAa,EAC1B,IAAe,EAAE;AACrB,KAAI;AACF,MAAe,GAAS,CAAC;SACnB;CAIR,IAAM,IAAW,EAAS,MAAM,IAAI,EAC9B,IAAW,EAAS,MAAM,IAC1B,IAAa,EAAE,iBAAiB,UAClC,OACC,EAAE,QAAqB,MAAK,MAAK,EAAE,aAAa,KAAK,EAAS,aAAa,CAAC,IAAI,MAC/E,IAAY,IAAa,MAAM,EAAS,MAAM,EAAE,CAAC,KAAK,IAAI,IAAI,MAAM,GACpE,IAAgB,KAAc,KAAgB,EAAE,cAChD,IAAe,EAAE,YACnB,EAAoB,GAAW,GAAe,EAAE,UAAoD,IAAI,IACxG,GAEE,IAA0B,EAAE,QAAqB,KAAI,MAAO;EAChE,IAAM,IAAa,EAAE,YACjB,EAAqB,GAAc,GAAK,EAAE,UAAoD,IAAI,IAClG,GAEA;AASJ,SARA,AAKE,IALE,EAAE,iBAAiB,WAEZ,EAAE,iBAAiB,YAAY,MAAQ,EAAE,eAD3C,GAAG,IAAU,MAIb,GAAG,EAAQ,GAAG,IAAM,KAGtB;GAAE,UAAU;GAAK;GAAM;GAC9B,EAGI,IAAa,EAAE,YACjB,EAAqB,GAAc,EAAE,cAAc,EAAE,UAAoD,IAAI,IAC7G,GACE,IAAc,EAAE,iBAAiB,WACnC,GAAG,EAAQ,GAAG,EAAE,eAAe,MAC/B,GAAG,IAAU;AAGjB,QAFA,EAAM,KAAK;EAAE,UAAU;EAAa,MAAM;EAAa,CAAC,EAEjD"}
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { AllMessages, DateFormatOptions, NumberFormatOptions, Locale } from '@fluenti/core';
2
+ import { AllMessages, DateFormatOptions, NumberFormatOptions, Locale } from '../../core/src/index.ts';
3
3
  export interface ClientI18nProviderProps {
4
4
  locale: string;
5
5
  fallbackLocale: string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-provider.d.ts","sourceRoot":"","sources":["../../../../src/client-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEhG,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,WAAW,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IACxC,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,cAAc,EACd,QAAQ,EACR,aAAa,EACb,WAAW,EACX,aAAa,EACb,QAAQ,GACT,EAAE,uBAAuB,2CAazB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-navigation.d.ts","sourceRoot":"","sources":["../../../../src/create-navigation.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAE9C,YAAY,EAAE,aAAa,EAAE,CAAA;AAE7B,UAAU,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM;IAChF,IAAI,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IACzC,MAAM,CAAC,EAAE,CAAC,CAAA;IACV,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;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"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-runner.d.ts","sourceRoot":"","sources":["../../../../src/dev-runner.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;IAC9B,6EAA6E;IAC7E,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+FAA+F;IAC/F,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,sEAAsE;IACtE,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+DhF;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EACzB,KAAK,SAAM,GACV,MAAM,IAAI,CAiCZ"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-watcher.d.ts","sourceRoot":"","sources":["../../../../src/dev-watcher.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,sEAAsE;IACtE,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAY1E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,IAAI,CAwCtE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-server-module.d.ts","sourceRoot":"","sources":["../../../../src/generate-server-module.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAanD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,oBAAoB,GAC3B,MAAM,CAmTR"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n-config.d.ts","sourceRoot":"","sources":["../../../../src/i18n-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,0EAA0E;AAC1E,eAAO,MAAM,OAAO,EAAE,MAAM,EAAW,CAAA;AAEvC,8EAA8E;AAC9E,eAAO,MAAM,YAAY,EAAE,MAAa,CAAA;AAExC,yFAAyF;AACzF,eAAO,MAAM,UAAU,EAAE,MAAiB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { ReactNode, ReactElement } from 'react';
2
- import { CompileTimeT, FluentiCoreInstanceFull } from '@fluenti/core';
2
+ import { CompileTimeT, FluentiCoreInstanceFull } from '../../core/src/index.ts';
3
+ import { I18nProviderProps } from './types';
3
4
  /**
4
5
  * @fluenti/next — Next.js plugin for Fluenti
5
6
  *
@@ -25,25 +26,15 @@ export { withFluenti } from './with-fluenti';
25
26
  export type { WithFluentConfig, I18nProviderProps } from './types';
26
27
  export { defineRouting } from './routing';
27
28
  export type { RoutingConfig } from './routing';
28
- export { msg } from '@fluenti/react';
29
- /** @see Generated module for the real implementation. */
30
- export declare const setLocale: (locale: string) => void;
31
- /** @see Generated module for the real implementation. */
32
- export declare const getI18n: () => Promise<FluentiCoreInstanceFull & {
33
- locale: string;
34
- }>;
35
- /** @see Generated module for the real implementation. */
36
- export declare const t: CompileTimeT;
37
- /** @see Generated module for the real implementation. */
38
- export declare const Trans: (props: {
29
+ export { msg } from '../../react/src/index.ts';
30
+ interface NextTransProps {
39
31
  children: ReactNode;
40
32
  id?: string;
41
33
  context?: string;
42
34
  comment?: string;
43
35
  render?: (translation: ReactNode) => ReactNode;
44
- }) => Promise<ReactElement>;
45
- /** @see Generated module for the real implementation. */
46
- export declare const Plural: (props: {
36
+ }
37
+ interface NextPluralProps {
47
38
  value: number;
48
39
  id?: string;
49
40
  context?: string;
@@ -55,9 +46,8 @@ export declare const Plural: (props: {
55
46
  many?: ReactNode;
56
47
  other: ReactNode;
57
48
  offset?: number;
58
- }) => Promise<ReactElement>;
59
- /** @see Generated module for the real implementation. */
60
- export declare const Select: (props: {
49
+ }
50
+ interface NextSelectProps {
61
51
  value: string;
62
52
  id?: string;
63
53
  context?: string;
@@ -65,20 +55,33 @@ export declare const Select: (props: {
65
55
  other: ReactNode;
66
56
  options?: Record<string, ReactNode>;
67
57
  [key: string]: ReactNode | Record<string, ReactNode> | string | undefined;
68
- }) => Promise<ReactElement>;
69
- /** @see Generated module for the real implementation. */
70
- export declare const DateTime: (props: {
58
+ }
59
+ interface NextDateTimeProps {
71
60
  value: Date | number;
72
61
  style?: string;
73
- }) => Promise<ReactElement>;
74
- /** @see Generated module for the real implementation. */
75
- export declare const NumberFormat: (props: {
62
+ }
63
+ interface NextNumberFormatProps {
76
64
  value: number;
77
65
  style?: string;
78
- }) => Promise<ReactElement>;
66
+ }
79
67
  /** @see Generated module for the real implementation. */
80
- export declare const I18nProvider: (props: {
81
- locale?: string;
82
- children: ReactNode;
83
- }) => Promise<ReactElement>;
68
+ export declare const setLocale: (locale: string) => void;
69
+ /** @see Generated module for the real implementation. */
70
+ export declare const getI18n: () => Promise<FluentiCoreInstanceFull & {
71
+ locale: string;
72
+ }>;
73
+ /** @see Generated module for the real implementation. */
74
+ export declare const t: CompileTimeT;
75
+ /** @see Generated module for the real implementation. */
76
+ export declare function Trans(_props: NextTransProps): Promise<ReactElement>;
77
+ /** @see Generated module for the real implementation. */
78
+ export declare function Plural(_props: NextPluralProps): Promise<ReactElement>;
79
+ /** @see Generated module for the real implementation. */
80
+ export declare function Select(_props: NextSelectProps): Promise<ReactElement>;
81
+ /** @see Generated module for the real implementation. */
82
+ export declare function DateTime(_props: NextDateTimeProps): Promise<ReactElement>;
83
+ /** @see Generated module for the real implementation. */
84
+ export declare function NumberFormat(_props: NextNumberFormatProps): Promise<ReactElement>;
85
+ /** @see Generated module for the real implementation. */
86
+ export declare function I18nProvider(_props: I18nProviderProps): Promise<ReactElement>;
84
87
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AASpC,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,UAAU,cAAc;IACtB,QAAQ,EAAE,SAAS,CAAA;IACnB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,KAAK,SAAS,CAAA;CAC/C;AAED,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,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/about', 'fr') // → '/fr/about'
26
26
  * getLocalePath('/about', 'en') // → '/about' (source locale, no prefix)
27
- * getLocalePath('/fr/about', 'en') // → '/about'
28
- * getLocalePath('/fr/about', 'ja') // → '/ja/about'
27
+ * getLocalePath('/fr/about', 'en', { locales: ['en', 'fr', 'ja'] }) // → '/about'
28
+ * getLocalePath('/fr/about', 'ja', { locales: ['en', 'fr', 'ja'] }) // → '/ja/about'
29
29
  * getLocalePath('/about', 'en', { localePrefix: 'always' }) // → '/en/about'
30
30
  * ```
31
31
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../../src/navigation.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAA;CAChD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,oBAAoB,GAC7B,MAAM,CA2BR;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE;IAC1C,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gFAAgF;IAChF,YAAY,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAA;CAChD;8BAWkC,MAAM;;;;EAyBxC;AAGD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAC/D,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAI9C,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,OAAO,EAAE;QAAE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;KAAE,CAAA;IAClK,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,GAAG,aAAa,EAAE,CAgDlB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/provider.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACtE,YAAY,EAAE,uBAAuB,IAAI,iBAAiB,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-config.d.ts","sourceRoot":"","sources":["../../../../src/read-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAErE;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,gBAAgB,GAC3B,oBAAoB,CA8BtB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../../../src/routing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,MAAM,WAAW,aAAa,CAC5B,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,MAAM,GAAG,MAAM;I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;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAM1C;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAErD;AAED;;;;GAIG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAcjD;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAEjF"}
@@ -1,4 +1,4 @@
1
- import { FluentiBuildConfig } from '@fluenti/core/internal';
1
+ import { FluentiBuildConfig } from '../../core/src/compiler.ts';
2
2
  /**
3
3
  * Configuration for `withFluenti()`.
4
4
  *
@@ -35,6 +35,15 @@ export interface WithFluentConfig {
35
35
  resolveLocale?: string;
36
36
  /** Cookie name used for locale detection (default: 'locale') */
37
37
  cookieName?: string;
38
+ /**
39
+ * Include full runtime ICU interpolation in the generated Next server/client modules.
40
+ *
41
+ * Enabled by default because Next apps can mix compiled catalogs with runtime
42
+ * `<Plural>` / `<Select>` / server component paths that still need ICU fallback.
43
+ * Set to `false` only when your app is fully compile-only and you want to trim
44
+ * parser/runtime ICU code from the generated modules.
45
+ */
46
+ runtimeInterpolate?: boolean;
38
47
  /**
39
48
  * Webpack loader enforce mode (default: 'pre').
40
49
  *
@@ -53,6 +62,7 @@ export interface ResolvedFluentConfig {
53
62
  serverModuleOutDir: string;
54
63
  resolveLocale?: string;
55
64
  cookieName: string;
65
+ runtimeInterpolate: boolean;
56
66
  }
57
67
  /**
58
68
  * Props for the I18nProvider server component.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAEhE;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;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AU,KAAK,UAAU,CAAA;AACrG,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-locale.d.ts","sourceRoot":"","sources":["../../../../src/with-locale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAChC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACxB,YAAY,CAAC,EAAE;IAAE,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,GACjF,OAAO,CAAC,CAAC,CAAC,CAwBZ"}
package/dist/provider.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./routing-Dy57-Uao.cjs`);let e=require(`@fluenti/react`),t=require(`react/jsx-runtime`);function n({locale:n,fallbackLocale:r,messages:i,fallbackChain:a,dateFormats:o,numberFormats:s,children:c}){return(0,t.jsx)(e.I18nProvider,{locale:n,fallbackLocale:r,messages:i,...a?{fallbackChain:a}:{},...o?{dateFormats:o}:{},...s?{numberFormats:s}:{},children:c})}exports.I18nProvider=n;
2
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@fluenti/react`),t=require(`react/jsx-runtime`);function n({locale:n,fallbackLocale:r,messages:i,fallbackChain:a,dateFormats:o,numberFormats:s,children:c}){return(0,t.jsx)(e.I18nProvider,{locale:n,fallbackLocale:r,messages:i,...a?{fallbackChain:a}:{},...o?{dateFormats:o}:{},...s?{numberFormats:s}:{},children:c})}exports.I18nProvider=n;
3
3
  //# sourceMappingURL=provider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.cjs","names":[],"sources":["../src/client-provider.tsx"],"sourcesContent":["'use client'\n\nimport type { ReactNode } from 'react'\nimport { I18nProvider } from '@fluenti/react'\nimport type { AllMessages, DateFormatOptions, NumberFormatOptions, Locale } from '@fluenti/core'\n\nexport interface ClientI18nProviderProps {\n locale: string\n fallbackLocale: string\n messages: AllMessages\n fallbackChain?: Record<string, Locale[]>\n dateFormats?: DateFormatOptions\n numberFormats?: NumberFormatOptions\n children: ReactNode\n}\n\n/**\n * Client-side I18nProvider wrapper for Next.js App Router.\n *\n * Wraps `@fluenti/react`'s `I18nProvider` with the `'use client'` directive,\n * enabling hydration of client components in a Server Component tree.\n * Re-exported as `I18nProvider` from `@fluenti/next/provider`.\n *\n * @example\n * ```tsx\n * // app/layout.tsx\n * import { I18nProvider } from '@fluenti/next/provider'\n * import en from '../locales/compiled/en.js'\n *\n * export default function RootLayout({ children }: { children: React.ReactNode }) {\n * return (\n * <html>\n * <body>\n * <I18nProvider\n * locale=\"en\"\n * fallbackLocale=\"en\"\n * messages={{ en }}\n * >\n * {children}\n * </I18nProvider>\n * </body>\n * </html>\n * )\n * }\n * ```\n */\nexport function ClientI18nProvider({\n locale,\n fallbackLocale,\n messages,\n fallbackChain,\n dateFormats,\n numberFormats,\n children,\n}: ClientI18nProviderProps) {\n return (\n <I18nProvider\n locale={locale}\n fallbackLocale={fallbackLocale}\n messages={messages}\n {...(fallbackChain ? { fallbackChain } : {})}\n {...(dateFormats ? { dateFormats } : {})}\n {...(numberFormats ? { numberFormats } : {})}\n >\n {children}\n </I18nProvider>\n )\n}\n"],"mappings":"oKA8CA,SAAgB,EAAmB,CACjC,SACA,iBACA,WACA,gBACA,cACA,gBACA,YAC0B,CAC1B,OACE,EAAA,EAAA,KAAC,EAAA,aAAD,CACU,SACQ,iBACN,WACV,GAAK,EAAgB,CAAE,gBAAe,CAAG,EAAE,CAC3C,GAAK,EAAc,CAAE,cAAa,CAAG,EAAE,CACvC,GAAK,EAAgB,CAAE,gBAAe,CAAG,EAAE,CAE1C,WACY,CAAA"}
1
+ {"version":3,"file":"provider.cjs","names":[],"sources":["../src/client-provider.tsx"],"sourcesContent":["'use client'\n\nimport type { ReactNode } from 'react'\nimport { I18nProvider } from '@fluenti/react'\nimport type { AllMessages, DateFormatOptions, NumberFormatOptions, Locale } from '@fluenti/core'\n\nexport interface ClientI18nProviderProps {\n locale: string\n fallbackLocale: string\n messages: AllMessages\n fallbackChain?: Record<string, Locale[]>\n dateFormats?: DateFormatOptions\n numberFormats?: NumberFormatOptions\n children: ReactNode\n}\n\n/**\n * Client-side I18nProvider wrapper for Next.js App Router.\n *\n * Wraps `@fluenti/react`'s `I18nProvider` with the `'use client'` directive,\n * enabling hydration of client components in a Server Component tree.\n * Re-exported as `I18nProvider` from `@fluenti/next/provider`.\n *\n * @example\n * ```tsx\n * // app/layout.tsx\n * import { I18nProvider } from '@fluenti/next/provider'\n * import en from '../locales/compiled/en.js'\n *\n * export default function RootLayout({ children }: { children: React.ReactNode }) {\n * return (\n * <html>\n * <body>\n * <I18nProvider\n * locale=\"en\"\n * fallbackLocale=\"en\"\n * messages={{ en }}\n * >\n * {children}\n * </I18nProvider>\n * </body>\n * </html>\n * )\n * }\n * ```\n */\nexport function ClientI18nProvider({\n locale,\n fallbackLocale,\n messages,\n fallbackChain,\n dateFormats,\n numberFormats,\n children,\n}: ClientI18nProviderProps) {\n return (\n <I18nProvider\n locale={locale}\n fallbackLocale={fallbackLocale}\n messages={messages}\n {...(fallbackChain ? { fallbackChain } : {})}\n {...(dateFormats ? { dateFormats } : {})}\n {...(numberFormats ? { numberFormats } : {})}\n >\n {children}\n </I18nProvider>\n )\n}\n"],"mappings":"kIA8CA,SAAgB,EAAmB,CACjC,SACA,iBACA,WACA,gBACA,cACA,gBACA,YAC0B,CAC1B,OACE,EAAA,EAAA,KAAC,EAAA,aAAD,CACU,SACQ,iBACN,WACV,GAAK,EAAgB,CAAE,gBAAe,CAAG,EAAE,CAC3C,GAAK,EAAc,CAAE,cAAa,CAAG,EAAE,CACvC,GAAK,EAAgB,CAAE,gBAAe,CAAG,EAAE,CAE1C,WACY,CAAA"}
@@ -0,0 +1,65 @@
1
+ //#region src/routing.ts
2
+ function e(e) {
3
+ return e;
4
+ }
5
+ function t(e) {
6
+ return e.split("/").filter(Boolean);
7
+ }
8
+ function n(e) {
9
+ return e ? e.startsWith("[...") && e.endsWith("]") ? 1 : e.startsWith("[") && e.endsWith("]") ? 2 : 3 : 0;
10
+ }
11
+ function r(e, r) {
12
+ let i = t(e), a = t(r), o = Math.max(i.length, a.length);
13
+ for (let e = 0; e < o; e++) {
14
+ let t = n(i[e]), r = n(a[e]);
15
+ if (t !== r) return r - t;
16
+ }
17
+ return i.length === a.length ? e.localeCompare(r) : a.length - i.length;
18
+ }
19
+ function i(e) {
20
+ return Object.entries(e).sort(([e], [t]) => r(e, t));
21
+ }
22
+ function a(e, t) {
23
+ let n = e.split("/").filter(Boolean), r = t.split("/").filter(Boolean), i = {};
24
+ for (let e = 0; e < n.length; e++) {
25
+ let t = n[e];
26
+ if (t.startsWith("[...") && t.endsWith("]")) {
27
+ let n = t.slice(4, -1);
28
+ return i[n] = r.slice(e).join("/"), i;
29
+ }
30
+ if (t.startsWith("[") && t.endsWith("]")) {
31
+ if (e >= r.length) return null;
32
+ i[t.slice(1, -1)] = r[e];
33
+ continue;
34
+ }
35
+ if (e >= r.length || t !== r[e]) return null;
36
+ }
37
+ return n.length === r.length ? i : null;
38
+ }
39
+ function o(e, t) {
40
+ return e.replace(/\[\.\.\.(\w+)\]|\[(\w+)\]/g, (e, n, r) => t[n ?? r] ?? "");
41
+ }
42
+ function s(e, t, n) {
43
+ for (let [r, s] of i(n)) {
44
+ let n = s[t];
45
+ if (!n) continue;
46
+ if (n === e) return r;
47
+ let i = a(n, e);
48
+ if (i) return o(r, i);
49
+ }
50
+ return null;
51
+ }
52
+ function c(e, t, n) {
53
+ for (let [r, s] of i(n)) {
54
+ let n = s[t];
55
+ if (!n) continue;
56
+ if (r === e) return n;
57
+ let i = a(r, e);
58
+ if (i) return o(n, i);
59
+ }
60
+ return null;
61
+ }
62
+ //#endregion
63
+ export { s as n, c as r, e as t };
64
+
65
+ //# sourceMappingURL=routing-CRln5Gw7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing-CRln5Gw7.js","names":[],"sources":["../src/routing.ts"],"sourcesContent":["/**\n * Shared routing configuration for middleware and navigation.\n *\n * Define once, use everywhere:\n *\n * @example\n * ```ts\n * // src/i18n/routing.ts\n * import { defineRouting } from '@fluenti/next'\n *\n * export const routing = defineRouting({\n * locales: ['en', 'fr', 'ja'],\n * sourceLocale: 'en',\n * localePrefix: 'as-needed',\n * pathnames: {\n * '/about': { fr: '/a-propos' },\n * '/blog/[slug]': { fr: '/articles/[slug]' },\n * },\n * })\n * ```\n *\n * Then pass to both middleware and navigation:\n * ```ts\n * // middleware.ts\n * export default createI18nMiddleware({ NextResponse, ...routing })\n *\n * // src/i18n/navigation.ts\n * export const { Link, useRouter } = createNavigation(routing)\n * ```\n */\n\nexport interface RoutingConfig<\n L extends string = string,\n P extends string = string,\n> {\n locales: readonly L[]\n sourceLocale: L\n localePrefix?: 'always' | 'as-needed' | 'never'\n pathnames?: Record<P, Partial<Record<L, string>>>\n}\n\n/**\n * Define a routing configuration for use with both `createI18nMiddleware` and `createNavigation`.\n *\n * This is a type-only helper — it returns the input unchanged but captures\n * the literal types of locales and pathname keys for type-safe navigation.\n */\nexport function defineRouting<\n const L extends string,\n const P extends string,\n>(config: RoutingConfig<L, P>): RoutingConfig<L, P> {\n return config\n}\n\nfunction getPatternSegments(pattern: string): string[] {\n return pattern.split('/').filter(Boolean)\n}\n\nfunction getSegmentPriority(segment: string | undefined): number {\n if (!segment) return 0\n if (segment.startsWith('[...') && segment.endsWith(']')) return 1\n if (segment.startsWith('[') && segment.endsWith(']')) return 2\n return 3\n}\n\nfunction comparePatterns(a: string, b: string): number {\n const aSegments = getPatternSegments(a)\n const bSegments = getPatternSegments(b)\n const maxLength = Math.max(aSegments.length, bSegments.length)\n\n for (let i = 0; i < maxLength; i++) {\n const aPriority = getSegmentPriority(aSegments[i])\n const bPriority = getSegmentPriority(bSegments[i])\n if (aPriority !== bPriority) {\n return bPriority - aPriority\n }\n }\n\n if (aSegments.length !== bSegments.length) {\n return bSegments.length - aSegments.length\n }\n\n return a.localeCompare(b)\n}\n\nfunction getSortedPathnameEntries(\n pathnames: Record<string, Record<string, string>>,\n): Array<[string, Record<string, string>]> {\n return Object.entries(pathnames).sort(([a], [b]) => comparePatterns(a, b))\n}\n\n// ── Shared path resolution utilities ──────────────────────────────────────\n\n/** Match a pathname against a pattern with [param] and [...slug] segments. */\nexport function matchPattern(pattern: string, pathname: string): Record<string, string> | null {\n const patternParts = pattern.split('/').filter(Boolean)\n const pathParts = pathname.split('/').filter(Boolean)\n\n const params: Record<string, string> = {}\n\n for (let i = 0; i < patternParts.length; i++) {\n const pp = patternParts[i]!\n if (pp.startsWith('[...') && pp.endsWith(']')) {\n const key = pp.slice(4, -1)\n params[key] = pathParts.slice(i).join('/')\n return params\n }\n if (pp.startsWith('[') && pp.endsWith(']')) {\n if (i >= pathParts.length) return null\n params[pp.slice(1, -1)] = pathParts[i]!\n continue\n }\n if (i >= pathParts.length || pp !== pathParts[i]) return null\n }\n\n if (patternParts.length !== pathParts.length) return null\n return params\n}\n\n/** Substitute params into a pattern. */\nexport function substituteParams(pattern: string, params: Record<string, string>): string {\n return pattern.replace(/\\[\\.\\.\\.(\\w+)\\]|\\[(\\w+)\\]/g, (_, catchAll, param) => {\n const key = catchAll ?? param\n return params[key] ?? ''\n })\n}\n\n/** Reverse lookup: localized path → internal path. */\nexport function resolveInternalPath(\n localizedPath: string,\n locale: string,\n pathnames: Record<string, Record<string, string>>,\n): string | null {\n for (const [internal, mapping] of getSortedPathnameEntries(pathnames)) {\n const localized = mapping[locale]\n if (!localized) continue\n if (localized === localizedPath) return internal\n const params = matchPattern(localized, localizedPath)\n if (params) return substituteParams(internal, params)\n }\n return null\n}\n\n/** Forward lookup: internal path → localized path. */\nexport function resolveLocalizedPath(\n internalPath: string,\n locale: string,\n pathnames: Record<string, Record<string, string>>,\n): string | null {\n for (const [internal, mapping] of getSortedPathnameEntries(pathnames)) {\n const localized = mapping[locale]\n if (!localized) continue\n if (internal === internalPath) return localized\n const params = matchPattern(internal, internalPath)\n if (params) return substituteParams(localized, params)\n }\n return null\n}\n"],"mappings":";AA+CA,SAAgB,EAGd,GAAkD;AAClD,QAAO;;AAGT,SAAS,EAAmB,GAA2B;AACrD,QAAO,EAAQ,MAAM,IAAI,CAAC,OAAO,QAAQ;;AAG3C,SAAS,EAAmB,GAAqC;AAI/D,QAHK,IACD,EAAQ,WAAW,OAAO,IAAI,EAAQ,SAAS,IAAI,GAAS,IAC5D,EAAQ,WAAW,IAAI,IAAI,EAAQ,SAAS,IAAI,GAAS,IACtD,IAHc;;AAMvB,SAAS,EAAgB,GAAW,GAAmB;CACrD,IAAM,IAAY,EAAmB,EAAE,EACjC,IAAY,EAAmB,EAAE,EACjC,IAAY,KAAK,IAAI,EAAU,QAAQ,EAAU,OAAO;AAE9D,MAAK,IAAI,IAAI,GAAG,IAAI,GAAW,KAAK;EAClC,IAAM,IAAY,EAAmB,EAAU,GAAG,EAC5C,IAAY,EAAmB,EAAU,GAAG;AAClD,MAAI,MAAc,EAChB,QAAO,IAAY;;AAQvB,QAJI,EAAU,WAAW,EAAU,SAI5B,EAAE,cAAc,EAAE,GAHhB,EAAU,SAAS,EAAU;;AAMxC,SAAS,EACP,GACyC;AACzC,QAAO,OAAO,QAAQ,EAAU,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAgB,GAAG,EAAE,CAAC;;AAM5E,SAAgB,EAAa,GAAiB,GAAiD;CAC7F,IAAM,IAAe,EAAQ,MAAM,IAAI,CAAC,OAAO,QAAQ,EACjD,IAAY,EAAS,MAAM,IAAI,CAAC,OAAO,QAAQ,EAE/C,IAAiC,EAAE;AAEzC,MAAK,IAAI,IAAI,GAAG,IAA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&e.endsWith(`]`)?2:3:0}function r(e,r){let i=t(e),a=t(r),o=Math.max(i.length,a.length);for(let e=0;e<o;e++){let t=n(i[e]),r=n(a[e]);if(t!==r)return r-t}return i.length===a.length?e.localeCompare(r):a.length-i.length}function i(e){return Object.entries(e).sort(([e],[t])=>r(e,t))}function a(e,t){let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean),i={};for(let e=0;e<n.length;e++){let t=n[e];if(t.startsWith(`[...`)&&t.endsWith(`]`)){let n=t.slice(4,-1);return i[n]=r.slice(e).join(`/`),i}if(t.startsWith(`[`)&&t.endsWith(`]`)){if(e>=r.length)return null;i[t.slice(1,-1)]=r[e];continue}if(e>=r.length||t!==r[e])return null}return n.length===r.length?i:null}function o(e,t){return e.replace(/\[\.\.\.(\w+)\]|\[(\w+)\]/g,(e,n,r)=>t[n??r]??``)}function s(e,t,n){for(let[r,s]of i(n)){let n=s[t];if(!n)continue;if(n===e)return r;let i=a(n,e);if(i)return o(r,i)}return null}function c(e,t,n){for(let[r,s]of i(n)){let n=s[t];if(!n)continue;if(r===e)return n;let i=a(r,e);if(i)return o(n,i)}return null}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
2
+ //# sourceMappingURL=routing-D4p8HvMH.cjs.map