gt-next 11.4.2 → 11.4.4

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # gt-next
2
2
 
3
+ ## 11.4.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2330](https://github.com/generaltranslation/gt/pull/2330) [`9ee7dc3`](https://github.com/generaltranslation/gt/commit/9ee7dc3ae792cd81ce7edb5c6e43c963f7055261) Thanks [@eoinest](https://github.com/eoinest)! - Use server-provided locale and condition props as the only rendered state in server-rendered apps. Condition setters write cookies for middleware and request a reload; provider-free SPA apps keep their cookie-backed behavior.
8
+
9
+ - Updated dependencies [[`5d75eb4`](https://github.com/generaltranslation/gt/commit/5d75eb475a9e36a61845f0368566a9d40466251c), [`9ee7dc3`](https://github.com/generaltranslation/gt/commit/9ee7dc3ae792cd81ce7edb5c6e43c963f7055261)]:
10
+ - generaltranslation@9.5.1
11
+ - @generaltranslation/react-core@11.4.4
12
+ - gt-react@11.4.4
13
+ - @generaltranslation/compiler@1.3.57
14
+ - gt-i18n@1.0.32
15
+
16
+ ## 11.4.3
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [[`87fa5b1`](https://github.com/generaltranslation/gt/commit/87fa5b17cc2dcd265bc96ab77259e4bc4a6c987f), [`78e3a57`](https://github.com/generaltranslation/gt/commit/78e3a57c19caffe8fbce2e9bc74e573071d662e8), [`0e87e42`](https://github.com/generaltranslation/gt/commit/0e87e42ac5d93a1c9ee1f5993d074d4c9a4ae387), [`370c31f`](https://github.com/generaltranslation/gt/commit/370c31f975cd1d2bfa9609ea1827c2900f812665), [`c734b08`](https://github.com/generaltranslation/gt/commit/c734b084f0a50d1b2787c86ec790403f88803650), [`322e927`](https://github.com/generaltranslation/gt/commit/322e9279b7efb17faf220e626a5a3696efc5d863), [`052d499`](https://github.com/generaltranslation/gt/commit/052d499556f3dcf7c6801d2ba91399783608e70b), [`d5649a4`](https://github.com/generaltranslation/gt/commit/d5649a4d9711c3f752a1706348398935bf44e8e1), [`abc7fea`](https://github.com/generaltranslation/gt/commit/abc7feaeb8be41709178d34db550d7af36c809af)]:
21
+ - generaltranslation@9.5.0
22
+ - @generaltranslation/compiler@1.3.56
23
+ - gt-i18n@1.0.31
24
+ - gt-react@11.4.3
25
+ - @generaltranslation/react-core@11.4.3
26
+
3
27
  ## 11.4.2
4
28
 
5
29
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMtD,wBAAsB,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,eAAe,oDAiC7D"}
1
+ {"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMtD,wBAAsB,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,eAAe,oDAmC7D"}
@@ -20,11 +20,9 @@ async function GTProvider({ children }) {
20
20
  const dictionariesSnapshot = await dictionariesSnapshotPromise;
21
21
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___utils_client_boundary_js.Client_GTProvider, {
22
22
  supportsLocaleRefresh: process.env._GENERALTRANSLATION_LOCALE_REFRESH_SUPPORTED === "true",
23
- conditions: {
24
- locale,
25
- region,
26
- enableI18n
27
- },
23
+ locale,
24
+ region,
25
+ enableI18n,
28
26
  translations: translationsSnapshot,
29
27
  dictionaries: dictionariesSnapshot,
30
28
  children
@@ -1 +1 @@
1
- {"version":3,"file":"GTProvider.js","names":["getNextI18nCache","getLocale","getRegion","getEnableI18n","Client_GTProvider"],"sources":["../../src/provider/GTProvider.tsx"],"sourcesContent":["import { getLocale } from '../request/getLocale';\nimport { getRegion } from '../request/getRegion';\nimport type { GTProviderProps } from '../utils/types';\nimport { Client_GTProvider } from '../utils/client-boundary';\nimport { getNextI18nCache } from '../i18n-cache/NextI18nCache';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport { getEnableI18n } from '../request/getEnableI18n';\n\nexport async function GTProvider({ children }: GTProviderProps) {\n // ---------- SETUP ---------- //\n const i18nCache = getNextI18nCache();\n const i18nConfig = getI18nConfig();\n const locale = await getLocale();\n const region = await getRegion();\n const enableI18n = await getEnableI18n();\n const translationRequired = i18nConfig.requiresTranslation(locale);\n\n // ----- FETCH TRANSLATIONS FROM CACHE ----- //\n\n const translationsSnapshotPromise = translationRequired\n ? i18nCache.loadTranslations(locale)\n : Promise.resolve({});\n\n const dictionariesSnapshotPromise = i18nCache.loadDictionaries(locale);\n\n // Block until cache check resolves\n const translationsSnapshot = { [locale]: await translationsSnapshotPromise };\n const dictionariesSnapshot = await dictionariesSnapshotPromise;\n\n return (\n <Client_GTProvider\n supportsLocaleRefresh={\n process.env._GENERALTRANSLATION_LOCALE_REFRESH_SUPPORTED === 'true'\n }\n conditions={{ locale, region, enableI18n }}\n translations={translationsSnapshot}\n dictionaries={dictionariesSnapshot}\n >\n {children}\n </Client_GTProvider>\n );\n}\n"],"mappings":";;;;;;;;;;AAQA,eAAsB,WAAW,EAAE,YAA6B;CAE9D,MAAM,YAAYA,iCAAAA,kBAAkB;CACpC,MAAM,cAAA,GAAA,iBAAA,gBAA4B;CAClC,MAAM,SAAS,MAAMC,0BAAAA,WAAW;CAChC,MAAM,SAAS,MAAMC,0BAAAA,WAAW;CAChC,MAAM,aAAa,MAAMC,8BAAAA,eAAe;CAKxC,MAAM,8BAJsB,WAAW,oBAAoB,OAIJ,GACnD,UAAU,iBAAiB,OAAO,GAClC,QAAQ,QAAQ,EAAE,CAAC;CAEvB,MAAM,8BAA8B,UAAU,iBAAiB,OAAO;CAGtE,MAAM,uBAAuB,GAAG,SAAS,MAAM,6BAA6B;CAC5E,MAAM,uBAAuB,MAAM;AAEnC,QACE,iBAAA,GAAA,kBAAA,KAACC,4BAAAA,mBAAD;EACE,uBACE,QAAQ,IAAI,iDAAiD;EAE/D,YAAY;GAAE;GAAQ;GAAQ;GAAY;EAC1C,cAAc;EACd,cAAc;EAEb;EACiB,CAAA"}
1
+ {"version":3,"file":"GTProvider.js","names":["getNextI18nCache","getLocale","getRegion","getEnableI18n","Client_GTProvider"],"sources":["../../src/provider/GTProvider.tsx"],"sourcesContent":["import { getLocale } from '../request/getLocale';\nimport { getRegion } from '../request/getRegion';\nimport type { GTProviderProps } from '../utils/types';\nimport { Client_GTProvider } from '../utils/client-boundary';\nimport { getNextI18nCache } from '../i18n-cache/NextI18nCache';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport { getEnableI18n } from '../request/getEnableI18n';\n\nexport async function GTProvider({ children }: GTProviderProps) {\n // ---------- SETUP ---------- //\n const i18nCache = getNextI18nCache();\n const i18nConfig = getI18nConfig();\n const locale = await getLocale();\n const region = await getRegion();\n const enableI18n = await getEnableI18n();\n const translationRequired = i18nConfig.requiresTranslation(locale);\n\n // ----- FETCH TRANSLATIONS FROM CACHE ----- //\n\n const translationsSnapshotPromise = translationRequired\n ? i18nCache.loadTranslations(locale)\n : Promise.resolve({});\n\n const dictionariesSnapshotPromise = i18nCache.loadDictionaries(locale);\n\n // Block until cache check resolves\n const translationsSnapshot = { [locale]: await translationsSnapshotPromise };\n const dictionariesSnapshot = await dictionariesSnapshotPromise;\n\n return (\n <Client_GTProvider\n supportsLocaleRefresh={\n process.env._GENERALTRANSLATION_LOCALE_REFRESH_SUPPORTED === 'true'\n }\n locale={locale}\n region={region}\n enableI18n={enableI18n}\n translations={translationsSnapshot}\n dictionaries={dictionariesSnapshot}\n >\n {children}\n </Client_GTProvider>\n );\n}\n"],"mappings":";;;;;;;;;;AAQA,eAAsB,WAAW,EAAE,YAA6B;CAE9D,MAAM,YAAYA,iCAAAA,kBAAkB;CACpC,MAAM,cAAA,GAAA,iBAAA,gBAA4B;CAClC,MAAM,SAAS,MAAMC,0BAAAA,WAAW;CAChC,MAAM,SAAS,MAAMC,0BAAAA,WAAW;CAChC,MAAM,aAAa,MAAMC,8BAAAA,eAAe;CAKxC,MAAM,8BAJsB,WAAW,oBAAoB,OAIJ,GACnD,UAAU,iBAAiB,OAAO,GAClC,QAAQ,QAAQ,EAAE,CAAC;CAEvB,MAAM,8BAA8B,UAAU,iBAAiB,OAAO;CAGtE,MAAM,uBAAuB,GAAG,SAAS,MAAM,6BAA6B;CAC5E,MAAM,uBAAuB,MAAM;AAEnC,QACE,iBAAA,GAAA,kBAAA,KAACC,4BAAAA,mBAAD;EACE,uBACE,QAAQ,IAAI,iDAAiD;EAEvD;EACA;EACI;EACZ,cAAc;EACd,cAAc;EAEb;EACiB,CAAA"}
@@ -18,11 +18,9 @@ async function GTProvider({ children }) {
18
18
  const dictionariesSnapshot = await dictionariesSnapshotPromise;
19
19
  return /* @__PURE__ */ jsx(Client_GTProvider, {
20
20
  supportsLocaleRefresh: process.env._GENERALTRANSLATION_LOCALE_REFRESH_SUPPORTED === "true",
21
- conditions: {
22
- locale,
23
- region,
24
- enableI18n
25
- },
21
+ locale,
22
+ region,
23
+ enableI18n,
26
24
  translations: translationsSnapshot,
27
25
  dictionaries: dictionariesSnapshot,
28
26
  children
@@ -1 +1 @@
1
- {"version":3,"file":"GTProvider.mjs","names":[],"sources":["../../src/provider/GTProvider.tsx"],"sourcesContent":["import { getLocale } from '../request/getLocale';\nimport { getRegion } from '../request/getRegion';\nimport type { GTProviderProps } from '../utils/types';\nimport { Client_GTProvider } from '../utils/client-boundary';\nimport { getNextI18nCache } from '../i18n-cache/NextI18nCache';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport { getEnableI18n } from '../request/getEnableI18n';\n\nexport async function GTProvider({ children }: GTProviderProps) {\n // ---------- SETUP ---------- //\n const i18nCache = getNextI18nCache();\n const i18nConfig = getI18nConfig();\n const locale = await getLocale();\n const region = await getRegion();\n const enableI18n = await getEnableI18n();\n const translationRequired = i18nConfig.requiresTranslation(locale);\n\n // ----- FETCH TRANSLATIONS FROM CACHE ----- //\n\n const translationsSnapshotPromise = translationRequired\n ? i18nCache.loadTranslations(locale)\n : Promise.resolve({});\n\n const dictionariesSnapshotPromise = i18nCache.loadDictionaries(locale);\n\n // Block until cache check resolves\n const translationsSnapshot = { [locale]: await translationsSnapshotPromise };\n const dictionariesSnapshot = await dictionariesSnapshotPromise;\n\n return (\n <Client_GTProvider\n supportsLocaleRefresh={\n process.env._GENERALTRANSLATION_LOCALE_REFRESH_SUPPORTED === 'true'\n }\n conditions={{ locale, region, enableI18n }}\n translations={translationsSnapshot}\n dictionaries={dictionariesSnapshot}\n >\n {children}\n </Client_GTProvider>\n );\n}\n"],"mappings":";;;;;;;;AAQA,eAAsB,WAAW,EAAE,YAA6B;CAE9D,MAAM,YAAY,kBAAkB;CACpC,MAAM,aAAa,eAAe;CAClC,MAAM,SAAS,MAAM,WAAW;CAChC,MAAM,SAAS,MAAM,WAAW;CAChC,MAAM,aAAa,MAAM,eAAe;CAKxC,MAAM,8BAJsB,WAAW,oBAAoB,OAIJ,GACnD,UAAU,iBAAiB,OAAO,GAClC,QAAQ,QAAQ,EAAE,CAAC;CAEvB,MAAM,8BAA8B,UAAU,iBAAiB,OAAO;CAGtE,MAAM,uBAAuB,GAAG,SAAS,MAAM,6BAA6B;CAC5E,MAAM,uBAAuB,MAAM;AAEnC,QACE,oBAAC,mBAAD;EACE,uBACE,QAAQ,IAAI,iDAAiD;EAE/D,YAAY;GAAE;GAAQ;GAAQ;GAAY;EAC1C,cAAc;EACd,cAAc;EAEb;EACiB,CAAA"}
1
+ {"version":3,"file":"GTProvider.mjs","names":[],"sources":["../../src/provider/GTProvider.tsx"],"sourcesContent":["import { getLocale } from '../request/getLocale';\nimport { getRegion } from '../request/getRegion';\nimport type { GTProviderProps } from '../utils/types';\nimport { Client_GTProvider } from '../utils/client-boundary';\nimport { getNextI18nCache } from '../i18n-cache/NextI18nCache';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport { getEnableI18n } from '../request/getEnableI18n';\n\nexport async function GTProvider({ children }: GTProviderProps) {\n // ---------- SETUP ---------- //\n const i18nCache = getNextI18nCache();\n const i18nConfig = getI18nConfig();\n const locale = await getLocale();\n const region = await getRegion();\n const enableI18n = await getEnableI18n();\n const translationRequired = i18nConfig.requiresTranslation(locale);\n\n // ----- FETCH TRANSLATIONS FROM CACHE ----- //\n\n const translationsSnapshotPromise = translationRequired\n ? i18nCache.loadTranslations(locale)\n : Promise.resolve({});\n\n const dictionariesSnapshotPromise = i18nCache.loadDictionaries(locale);\n\n // Block until cache check resolves\n const translationsSnapshot = { [locale]: await translationsSnapshotPromise };\n const dictionariesSnapshot = await dictionariesSnapshotPromise;\n\n return (\n <Client_GTProvider\n supportsLocaleRefresh={\n process.env._GENERALTRANSLATION_LOCALE_REFRESH_SUPPORTED === 'true'\n }\n locale={locale}\n region={region}\n enableI18n={enableI18n}\n translations={translationsSnapshot}\n dictionaries={dictionariesSnapshot}\n >\n {children}\n </Client_GTProvider>\n );\n}\n"],"mappings":";;;;;;;;AAQA,eAAsB,WAAW,EAAE,YAA6B;CAE9D,MAAM,YAAY,kBAAkB;CACpC,MAAM,aAAa,eAAe;CAClC,MAAM,SAAS,MAAM,WAAW;CAChC,MAAM,SAAS,MAAM,WAAW;CAChC,MAAM,aAAa,MAAM,eAAe;CAKxC,MAAM,8BAJsB,WAAW,oBAAoB,OAIJ,GACnD,UAAU,iBAAiB,OAAO,GAClC,QAAQ,QAAQ,EAAE,CAAC;CAEvB,MAAM,8BAA8B,UAAU,iBAAiB,OAAO;CAGtE,MAAM,uBAAuB,GAAG,SAAS,MAAM,6BAA6B;CAC5E,MAAM,uBAAuB,MAAM;AAEnC,QACE,oBAAC,mBAAD;EACE,uBACE,QAAQ,IAAI,iDAAiD;EAEvD;EACA;EACI;EACZ,cAAc;EACd,cAAc;EAEb;EACiB,CAAA"}
@@ -12,8 +12,7 @@ import { type SharedGTProviderProps } from 'gt-react';
12
12
  /**
13
13
  * Small wrapper to embed nextjs app router behavior
14
14
  */
15
- export declare function Client_GTProvider({ conditions, supportsLocaleRefresh, ...props }: Omit<SharedGTProviderProps, 'locale' | 'region' | 'enableI18n' | '_serverConditions'> & {
16
- conditions: NonNullable<SharedGTProviderProps['_serverConditions']>;
15
+ export declare function Client_GTProvider({ supportsLocaleRefresh, ...props }: SharedGTProviderProps & {
17
16
  supportsLocaleRefresh: boolean;
18
17
  }): import("react/jsx-runtime").JSX.Element;
19
18
  //# sourceMappingURL=client-boundary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-boundary.d.ts","sourceRoot":"","sources":["../../src/utils/client-boundary.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGnE,OAAO,EAAc,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAsBlE;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,UAAU,EACV,qBAAqB,EACrB,GAAG,KAAK,EACT,EAAE,IAAI,CACL,qBAAqB,EACrB,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,mBAAmB,CACzD,GAAG;IACF,UAAU,EAAE,WAAW,CAAC,qBAAqB,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACpE,qBAAqB,EAAE,OAAO,CAAC;CAChC,2CA+DA"}
1
+ {"version":3,"file":"client-boundary.d.ts","sourceRoot":"","sources":["../../src/utils/client-boundary.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGnE,OAAO,EAAc,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAsBlE;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,qBAAqB,EACrB,GAAG,KAAK,EACT,EAAE,qBAAqB,GAAG;IACzB,qBAAqB,EAAE,OAAO,CAAC;CAChC,2CAoDA"}
@@ -20,7 +20,7 @@ if (typeof window !== "undefined") require_setup_initGT_client.initializeGTClien
20
20
  /**
21
21
  * Small wrapper to embed nextjs app router behavior
22
22
  */
23
- function Client_GTProvider({ conditions, supportsLocaleRefresh, ...props }) {
23
+ function Client_GTProvider({ supportsLocaleRefresh, ...props }) {
24
24
  const router = (0, next_navigation_js.useRouter)();
25
25
  const refreshServerComponents = (0, react.useCallback)(() => {
26
26
  if (!supportsLocaleRefresh) {
@@ -49,12 +49,10 @@ function Client_GTProvider({ conditions, supportsLocaleRefresh, ...props }) {
49
49
  usePathCheck({
50
50
  reloadBrowserPage,
51
51
  refreshServerComponents,
52
- locale: conditions.locale
52
+ locale: props.locale
53
53
  });
54
54
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(gt_react.GTProvider, {
55
55
  ...props,
56
- ...conditions,
57
- _serverConditions: conditions,
58
56
  _reload: syncServerContent
59
57
  });
60
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client-boundary.js","names":["compilePathRegex","defaultLocaleRoutingEnabledCookieName","pathnameMatchesRegex","GTProvider","defaultReferrerLocaleCookieName"],"sources":["../../src/utils/client-boundary.tsx"],"sourcesContent":["'use client';\n\n/**\n * This is a small boundary for RSC consumption of client components\n * Cannot be consumed through gt-react/index.rsc as deciding btwn\n * gt-react/index.server and gt-react/index.client can only happen\n * here. This matters for GTProvider, but not for LocaleSelector.\n * This pattern is just good to follow for carrying over different\n * behaviors between client and server from gt-react.\n */\n\nexport { LocaleSelector as Client_LocaleSelector } from 'gt-react';\nexport { RegionSelector as Client_RegionSelector } from 'gt-react';\n\nimport { getCookieValue, getI18nConfig, I18nConfig } from 'gt-i18n/internal';\nimport { GTProvider, type SharedGTProviderProps } from 'gt-react';\nimport { usePathname, useRouter } from 'next/navigation';\nimport { useCallback, useEffect } from 'react';\nimport { initializeGTClient } from '../setup/initGT.client';\nimport {\n defaultLocaleRoutingEnabledCookieName,\n defaultReferrerLocaleCookieName,\n} from './cookies';\nimport { compilePathRegex, pathnameMatchesRegex } from './pathRegex';\n\n// withGTConfig exposes this build-time value to both middleware and client code.\nconst pathRegex = compilePathRegex(process.env._GENERALTRANSLATION_PATH_REGEX);\n\n/**\n * Only need to initalize client. We know server was already\n * inialaized by index.rsc.ts. We do not know yet if client\n * has been initialized by index.client.ts.\n */\nif (typeof window !== 'undefined') {\n initializeGTClient();\n}\n\n/**\n * Small wrapper to embed nextjs app router behavior\n */\nexport function Client_GTProvider({\n conditions,\n supportsLocaleRefresh,\n ...props\n}: Omit<\n SharedGTProviderProps,\n 'locale' | 'region' | 'enableI18n' | '_serverConditions'\n> & {\n conditions: NonNullable<SharedGTProviderProps['_serverConditions']>;\n supportsLocaleRefresh: boolean;\n}) {\n const router = useRouter();\n const refreshServerComponents = useCallback(() => {\n // Older Next versions can retain a stale layout/provider after a redirect.\n if (!supportsLocaleRefresh) {\n globalThis.location.reload();\n return;\n }\n // The server supplies a fresh conditions object even when its accepted\n // locale is unchanged. For example, switching /en/careers to excluded 'fr'\n // returns another 'en' snapshot, which resets the browser store to 'en'\n // without discarding client state through a document reload.\n router.refresh();\n }, [router, supportsLocaleRefresh]);\n const reloadBrowserPage = useCallback(() => {\n globalThis.location.reload();\n }, []);\n const syncServerContent = useCallback<\n NonNullable<SharedGTProviderProps['_reload']>\n >(\n ({ locale }) => {\n const i18nConfig = getI18nConfig();\n const localeRoutingEnabled =\n getCookieValue(\n document.cookie,\n defaultLocaleRoutingEnabledCookieName\n ) === 'true';\n const defaultLocale = i18nConfig.getDefaultLocale();\n const locales = i18nConfig.getLocales();\n const currentPathname = globalThis.location.pathname;\n const localeRoutingApplies =\n localeRoutingEnabled &&\n pathnameMatchesRegex(currentPathname, pathRegex);\n if (localeRoutingApplies && locale === defaultLocale) {\n const currentPathLocale = resolvePathLocale(\n currentPathname,\n i18nConfig,\n defaultLocale,\n locales\n );\n if (currentPathLocale !== defaultLocale) {\n reloadBrowserPage();\n return;\n }\n }\n\n refreshServerComponents();\n },\n [refreshServerComponents, reloadBrowserPage]\n );\n usePathCheck({\n reloadBrowserPage,\n refreshServerComponents,\n locale: conditions.locale,\n });\n return (\n <GTProvider\n {...props}\n {...conditions}\n _serverConditions={conditions}\n _reload={syncServerContent}\n />\n );\n}\n\n/**\n * Synchronizes server content if the URL locale does not match the selected\n * locale.\n * TODO: optimize this hook\n */\nfunction usePathCheck({\n reloadBrowserPage,\n refreshServerComponents,\n locale,\n referrerLocaleCookieName = defaultReferrerLocaleCookieName,\n localeRoutingEnabledCookieName = defaultLocaleRoutingEnabledCookieName,\n}: {\n reloadBrowserPage: () => void;\n refreshServerComponents: () => void;\n locale: string;\n referrerLocaleCookieName?: string;\n localeRoutingEnabledCookieName?: string;\n}) {\n const pathname = usePathname();\n\n useEffect(() => {\n // Track the referrer locale for middleware\n const i18nConfig = getI18nConfig();\n document.cookie = `${referrerLocaleCookieName}=${locale};path=/`;\n\n // Synchronize server content if the pathname changes\n const locales = i18nConfig.getLocales();\n const defaultLocale = i18nConfig.getDefaultLocale();\n const localeRoutingEnabled =\n getCookieValue(document.cookie, localeRoutingEnabledCookieName) ===\n 'true';\n if (localeRoutingEnabled && pathnameMatchesRegex(pathname, pathRegex)) {\n // Extract locale from pathname\n const currentPathLocale = resolvePathLocale(\n pathname,\n i18nConfig,\n defaultLocale,\n locales\n );\n\n // Both values are resolved to configured identities before comparison.\n if (\n currentPathLocale &&\n locales.includes(currentPathLocale) &&\n currentPathLocale !== locale\n ) {\n // clear cookie (avoids infinite loop when there is no middleware)\n document.cookie = `${localeRoutingEnabledCookieName}=;path=/`;\n\n if (locale === defaultLocale) {\n // A browser navigation follows the middleware redirect that removes\n // the default locale prefix. Next.js router.refresh() does not.\n reloadBrowserPage();\n } else {\n refreshServerComponents();\n }\n }\n }\n }, [\n pathname,\n locale,\n referrerLocaleCookieName,\n localeRoutingEnabledCookieName,\n reloadBrowserPage,\n refreshServerComponents,\n ]);\n}\n\nfunction resolvePathLocale(\n pathname: string,\n i18nConfig: I18nConfig,\n defaultLocale: string,\n locales: string[]\n): string {\n const extractedLocale = extractLocale(pathname);\n if (!extractedLocale) {\n return defaultLocale;\n }\n\n return (\n i18nConfig.determineLocale([extractedLocale], locales) ?? defaultLocale\n );\n}\n\nfunction extractLocale(pathname: string): string | null {\n return pathname.match(/^\\/([^/]+)(?:\\/|$)/)?.[1] ?? null;\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,YAAYA,wBAAAA,iBAAiB,QAAQ,IAAI,+BAA+B;;;;;;AAO9E,IAAI,OAAO,WAAW,YACpB,6BAAA,oBAAoB;;;;AAMtB,SAAgB,kBAAkB,EAChC,YACA,uBACA,GAAG,SAOF;CACD,MAAM,UAAA,GAAA,mBAAA,YAAoB;CAC1B,MAAM,2BAAA,GAAA,MAAA,mBAA4C;AAEhD,MAAI,CAAC,uBAAuB;AAC1B,cAAW,SAAS,QAAQ;AAC5B;;AAMF,SAAO,SAAS;IACf,CAAC,QAAQ,sBAAsB,CAAC;CACnC,MAAM,qBAAA,GAAA,MAAA,mBAAsC;AAC1C,aAAW,SAAS,QAAQ;IAC3B,EAAE,CAAC;CACN,MAAM,qBAAA,GAAA,MAAA,cAGH,EAAE,aAAa;EACd,MAAM,cAAA,GAAA,iBAAA,gBAA4B;EAClC,MAAM,wBAAA,GAAA,iBAAA,gBAEF,SAAS,QACTC,sBAAAA,sCACD,KAAK;EACR,MAAM,gBAAgB,WAAW,kBAAkB;EACnD,MAAM,UAAU,WAAW,YAAY;EACvC,MAAM,kBAAkB,WAAW,SAAS;AAI5C,MAFE,wBACAC,wBAAAA,qBAAqB,iBAAiB,UAAU,IACtB,WAAW;OACX,kBACxB,iBACA,YACA,eACA,QAEmB,KAAK,eAAe;AACvC,uBAAmB;AACnB;;;AAIJ,2BAAyB;IAE3B,CAAC,yBAAyB,kBAAkB,CAC7C;AACD,cAAa;EACX;EACA;EACA,QAAQ,WAAW;EACpB,CAAC;AACF,QACE,iBAAA,GAAA,kBAAA,KAACC,SAAAA,YAAD;EACE,GAAI;EACJ,GAAI;EACJ,mBAAmB;EACnB,SAAS;EACT,CAAA;;;;;;;AASN,SAAS,aAAa,EACpB,mBACA,yBACA,QACA,2BAA2BC,sBAAAA,iCAC3B,iCAAiCH,sBAAAA,yCAOhC;CACD,MAAM,YAAA,GAAA,mBAAA,cAAwB;AAE9B,EAAA,GAAA,MAAA,iBAAgB;EAEd,MAAM,cAAA,GAAA,iBAAA,gBAA4B;AAClC,WAAS,SAAS,GAAG,yBAAyB,GAAG,OAAO;EAGxD,MAAM,UAAU,WAAW,YAAY;EACvC,MAAM,gBAAgB,WAAW,kBAAkB;AAInD,OAAA,GAAA,iBAAA,gBAFiB,SAAS,QAAQ,+BAA+B,KAC/D,UAC0BC,wBAAAA,qBAAqB,UAAU,UAAU,EAAE;GAErE,MAAM,oBAAoB,kBACxB,UACA,YACA,eACA,QACD;AAGD,OACE,qBACA,QAAQ,SAAS,kBAAkB,IACnC,sBAAsB,QACtB;AAEA,aAAS,SAAS,GAAG,+BAA+B;AAEpD,QAAI,WAAW,cAGb,oBAAmB;QAEnB,0BAAyB;;;IAI9B;EACD;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;;AAGJ,SAAS,kBACP,UACA,YACA,eACA,SACQ;CACR,MAAM,kBAAkB,cAAc,SAAS;AAC/C,KAAI,CAAC,gBACH,QAAO;AAGT,QACE,WAAW,gBAAgB,CAAC,gBAAgB,EAAE,QAAQ,IAAI;;AAI9D,SAAS,cAAc,UAAiC;AACtD,QAAO,SAAS,MAAM,qBAAqB,GAAG,MAAM"}
1
+ {"version":3,"file":"client-boundary.js","names":["compilePathRegex","defaultLocaleRoutingEnabledCookieName","pathnameMatchesRegex","GTProvider","defaultReferrerLocaleCookieName"],"sources":["../../src/utils/client-boundary.tsx"],"sourcesContent":["'use client';\n\n/**\n * This is a small boundary for RSC consumption of client components\n * Cannot be consumed through gt-react/index.rsc as deciding btwn\n * gt-react/index.server and gt-react/index.client can only happen\n * here. This matters for GTProvider, but not for LocaleSelector.\n * This pattern is just good to follow for carrying over different\n * behaviors between client and server from gt-react.\n */\n\nexport { LocaleSelector as Client_LocaleSelector } from 'gt-react';\nexport { RegionSelector as Client_RegionSelector } from 'gt-react';\n\nimport { getCookieValue, getI18nConfig, I18nConfig } from 'gt-i18n/internal';\nimport { GTProvider, type SharedGTProviderProps } from 'gt-react';\nimport { usePathname, useRouter } from 'next/navigation';\nimport { useCallback, useEffect } from 'react';\nimport { initializeGTClient } from '../setup/initGT.client';\nimport {\n defaultLocaleRoutingEnabledCookieName,\n defaultReferrerLocaleCookieName,\n} from './cookies';\nimport { compilePathRegex, pathnameMatchesRegex } from './pathRegex';\n\n// withGTConfig exposes this build-time value to both middleware and client code.\nconst pathRegex = compilePathRegex(process.env._GENERALTRANSLATION_PATH_REGEX);\n\n/**\n * Only need to initalize client. We know server was already\n * inialaized by index.rsc.ts. We do not know yet if client\n * has been initialized by index.client.ts.\n */\nif (typeof window !== 'undefined') {\n initializeGTClient();\n}\n\n/**\n * Small wrapper to embed nextjs app router behavior\n */\nexport function Client_GTProvider({\n supportsLocaleRefresh,\n ...props\n}: SharedGTProviderProps & {\n supportsLocaleRefresh: boolean;\n}) {\n const router = useRouter();\n const refreshServerComponents = useCallback(() => {\n // Older Next versions can retain a stale layout/provider after a redirect.\n if (!supportsLocaleRefresh) {\n globalThis.location.reload();\n return;\n }\n router.refresh();\n }, [router, supportsLocaleRefresh]);\n const reloadBrowserPage = useCallback(() => {\n globalThis.location.reload();\n }, []);\n const syncServerContent = useCallback<\n NonNullable<SharedGTProviderProps['_reload']>\n >(\n ({ locale }) => {\n const i18nConfig = getI18nConfig();\n const localeRoutingEnabled =\n getCookieValue(\n document.cookie,\n defaultLocaleRoutingEnabledCookieName\n ) === 'true';\n const defaultLocale = i18nConfig.getDefaultLocale();\n const locales = i18nConfig.getLocales();\n const currentPathname = globalThis.location.pathname;\n const localeRoutingApplies =\n localeRoutingEnabled &&\n pathnameMatchesRegex(currentPathname, pathRegex);\n if (localeRoutingApplies && locale === defaultLocale) {\n const currentPathLocale = resolvePathLocale(\n currentPathname,\n i18nConfig,\n defaultLocale,\n locales\n );\n if (currentPathLocale !== defaultLocale) {\n reloadBrowserPage();\n return;\n }\n }\n\n refreshServerComponents();\n },\n [refreshServerComponents, reloadBrowserPage]\n );\n usePathCheck({\n reloadBrowserPage,\n refreshServerComponents,\n locale: props.locale,\n });\n return <GTProvider {...props} _reload={syncServerContent} />;\n}\n\n/**\n * Synchronizes server content if the URL locale does not match the selected\n * locale.\n * TODO: optimize this hook\n */\nfunction usePathCheck({\n reloadBrowserPage,\n refreshServerComponents,\n locale,\n referrerLocaleCookieName = defaultReferrerLocaleCookieName,\n localeRoutingEnabledCookieName = defaultLocaleRoutingEnabledCookieName,\n}: {\n reloadBrowserPage: () => void;\n refreshServerComponents: () => void;\n locale: string;\n referrerLocaleCookieName?: string;\n localeRoutingEnabledCookieName?: string;\n}) {\n const pathname = usePathname();\n\n useEffect(() => {\n // Track the referrer locale for middleware\n const i18nConfig = getI18nConfig();\n document.cookie = `${referrerLocaleCookieName}=${locale};path=/`;\n\n // Synchronize server content if the pathname changes\n const locales = i18nConfig.getLocales();\n const defaultLocale = i18nConfig.getDefaultLocale();\n const localeRoutingEnabled =\n getCookieValue(document.cookie, localeRoutingEnabledCookieName) ===\n 'true';\n if (localeRoutingEnabled && pathnameMatchesRegex(pathname, pathRegex)) {\n // Extract locale from pathname\n const currentPathLocale = resolvePathLocale(\n pathname,\n i18nConfig,\n defaultLocale,\n locales\n );\n\n // Both values are resolved to configured identities before comparison.\n if (\n currentPathLocale &&\n locales.includes(currentPathLocale) &&\n currentPathLocale !== locale\n ) {\n // clear cookie (avoids infinite loop when there is no middleware)\n document.cookie = `${localeRoutingEnabledCookieName}=;path=/`;\n\n if (locale === defaultLocale) {\n // A browser navigation follows the middleware redirect that removes\n // the default locale prefix. Next.js router.refresh() does not.\n reloadBrowserPage();\n } else {\n refreshServerComponents();\n }\n }\n }\n }, [\n pathname,\n locale,\n referrerLocaleCookieName,\n localeRoutingEnabledCookieName,\n reloadBrowserPage,\n refreshServerComponents,\n ]);\n}\n\nfunction resolvePathLocale(\n pathname: string,\n i18nConfig: I18nConfig,\n defaultLocale: string,\n locales: string[]\n): string {\n const extractedLocale = extractLocale(pathname);\n if (!extractedLocale) {\n return defaultLocale;\n }\n\n return (\n i18nConfig.determineLocale([extractedLocale], locales) ?? defaultLocale\n );\n}\n\nfunction extractLocale(pathname: string): string | null {\n return pathname.match(/^\\/([^/]+)(?:\\/|$)/)?.[1] ?? null;\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,YAAYA,wBAAAA,iBAAiB,QAAQ,IAAI,+BAA+B;;;;;;AAO9E,IAAI,OAAO,WAAW,YACpB,6BAAA,oBAAoB;;;;AAMtB,SAAgB,kBAAkB,EAChC,uBACA,GAAG,SAGF;CACD,MAAM,UAAA,GAAA,mBAAA,YAAoB;CAC1B,MAAM,2BAAA,GAAA,MAAA,mBAA4C;AAEhD,MAAI,CAAC,uBAAuB;AAC1B,cAAW,SAAS,QAAQ;AAC5B;;AAEF,SAAO,SAAS;IACf,CAAC,QAAQ,sBAAsB,CAAC;CACnC,MAAM,qBAAA,GAAA,MAAA,mBAAsC;AAC1C,aAAW,SAAS,QAAQ;IAC3B,EAAE,CAAC;CACN,MAAM,qBAAA,GAAA,MAAA,cAGH,EAAE,aAAa;EACd,MAAM,cAAA,GAAA,iBAAA,gBAA4B;EAClC,MAAM,wBAAA,GAAA,iBAAA,gBAEF,SAAS,QACTC,sBAAAA,sCACD,KAAK;EACR,MAAM,gBAAgB,WAAW,kBAAkB;EACnD,MAAM,UAAU,WAAW,YAAY;EACvC,MAAM,kBAAkB,WAAW,SAAS;AAI5C,MAFE,wBACAC,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of window !== "undefined") initializeGTClient();
18
18
  /**
19
19
  * Small wrapper to embed nextjs app router behavior
20
20
  */
21
- function Client_GTProvider({ conditions, supportsLocaleRefresh, ...props }) {
21
+ function Client_GTProvider({ supportsLocaleRefresh, ...props }) {
22
22
  const router = useRouter();
23
23
  const refreshServerComponents = useCallback(() => {
24
24
  if (!supportsLocaleRefresh) {
@@ -47,12 +47,10 @@ function Client_GTProvider({ conditions, supportsLocaleRefresh, ...props }) {
47
47
  usePathCheck({
48
48
  reloadBrowserPage,
49
49
  refreshServerComponents,
50
- locale: conditions.locale
50
+ locale: props.locale
51
51
  });
52
52
  return /* @__PURE__ */ jsx(GTProvider, {
53
53
  ...props,
54
- ...conditions,
55
- _serverConditions: conditions,
56
54
  _reload: syncServerContent
57
55
  });
58
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client-boundary.mjs","names":[],"sources":["../../src/utils/client-boundary.tsx"],"sourcesContent":["'use client';\n\n/**\n * This is a small boundary for RSC consumption of client components\n * Cannot be consumed through gt-react/index.rsc as deciding btwn\n * gt-react/index.server and gt-react/index.client can only happen\n * here. This matters for GTProvider, but not for LocaleSelector.\n * This pattern is just good to follow for carrying over different\n * behaviors between client and server from gt-react.\n */\n\nexport { LocaleSelector as Client_LocaleSelector } from 'gt-react';\nexport { RegionSelector as Client_RegionSelector } from 'gt-react';\n\nimport { getCookieValue, getI18nConfig, I18nConfig } from 'gt-i18n/internal';\nimport { GTProvider, type SharedGTProviderProps } from 'gt-react';\nimport { usePathname, useRouter } from 'next/navigation';\nimport { useCallback, useEffect } from 'react';\nimport { initializeGTClient } from '../setup/initGT.client';\nimport {\n defaultLocaleRoutingEnabledCookieName,\n defaultReferrerLocaleCookieName,\n} from './cookies';\nimport { compilePathRegex, pathnameMatchesRegex } from './pathRegex';\n\n// withGTConfig exposes this build-time value to both middleware and client code.\nconst pathRegex = compilePathRegex(process.env._GENERALTRANSLATION_PATH_REGEX);\n\n/**\n * Only need to initalize client. We know server was already\n * inialaized by index.rsc.ts. We do not know yet if client\n * has been initialized by index.client.ts.\n */\nif (typeof window !== 'undefined') {\n initializeGTClient();\n}\n\n/**\n * Small wrapper to embed nextjs app router behavior\n */\nexport function Client_GTProvider({\n conditions,\n supportsLocaleRefresh,\n ...props\n}: Omit<\n SharedGTProviderProps,\n 'locale' | 'region' | 'enableI18n' | '_serverConditions'\n> & {\n conditions: NonNullable<SharedGTProviderProps['_serverConditions']>;\n supportsLocaleRefresh: boolean;\n}) {\n const router = useRouter();\n const refreshServerComponents = useCallback(() => {\n // Older Next versions can retain a stale layout/provider after a redirect.\n if (!supportsLocaleRefresh) {\n globalThis.location.reload();\n return;\n }\n // The server supplies a fresh conditions object even when its accepted\n // locale is unchanged. For example, switching /en/careers to excluded 'fr'\n // returns another 'en' snapshot, which resets the browser store to 'en'\n // without discarding client state through a document reload.\n router.refresh();\n }, [router, supportsLocaleRefresh]);\n const reloadBrowserPage = useCallback(() => {\n globalThis.location.reload();\n }, []);\n const syncServerContent = useCallback<\n NonNullable<SharedGTProviderProps['_reload']>\n >(\n ({ locale }) => {\n const i18nConfig = getI18nConfig();\n const localeRoutingEnabled =\n getCookieValue(\n document.cookie,\n defaultLocaleRoutingEnabledCookieName\n ) === 'true';\n const defaultLocale = i18nConfig.getDefaultLocale();\n const locales = i18nConfig.getLocales();\n const currentPathname = globalThis.location.pathname;\n const localeRoutingApplies =\n localeRoutingEnabled &&\n pathnameMatchesRegex(currentPathname, pathRegex);\n if (localeRoutingApplies && locale === defaultLocale) {\n const currentPathLocale = resolvePathLocale(\n currentPathname,\n i18nConfig,\n defaultLocale,\n locales\n );\n if (currentPathLocale !== defaultLocale) {\n reloadBrowserPage();\n return;\n }\n }\n\n refreshServerComponents();\n },\n [refreshServerComponents, reloadBrowserPage]\n );\n usePathCheck({\n reloadBrowserPage,\n refreshServerComponents,\n locale: conditions.locale,\n });\n return (\n <GTProvider\n {...props}\n {...conditions}\n _serverConditions={conditions}\n _reload={syncServerContent}\n />\n );\n}\n\n/**\n * Synchronizes server content if the URL locale does not match the selected\n * locale.\n * TODO: optimize this hook\n */\nfunction usePathCheck({\n reloadBrowserPage,\n refreshServerComponents,\n locale,\n referrerLocaleCookieName = defaultReferrerLocaleCookieName,\n localeRoutingEnabledCookieName = defaultLocaleRoutingEnabledCookieName,\n}: {\n reloadBrowserPage: () => void;\n refreshServerComponents: () => void;\n locale: string;\n referrerLocaleCookieName?: string;\n localeRoutingEnabledCookieName?: string;\n}) {\n const pathname = usePathname();\n\n useEffect(() => {\n // Track the referrer locale for middleware\n const i18nConfig = getI18nConfig();\n document.cookie = `${referrerLocaleCookieName}=${locale};path=/`;\n\n // Synchronize server content if the pathname changes\n const locales = i18nConfig.getLocales();\n const defaultLocale = i18nConfig.getDefaultLocale();\n const localeRoutingEnabled =\n getCookieValue(document.cookie, localeRoutingEnabledCookieName) ===\n 'true';\n if (localeRoutingEnabled && pathnameMatchesRegex(pathname, pathRegex)) {\n // Extract locale from pathname\n const currentPathLocale = resolvePathLocale(\n pathname,\n i18nConfig,\n defaultLocale,\n locales\n );\n\n // Both values are resolved to configured identities before comparison.\n if (\n currentPathLocale &&\n locales.includes(currentPathLocale) &&\n currentPathLocale !== locale\n ) {\n // clear cookie (avoids infinite loop when there is no middleware)\n document.cookie = `${localeRoutingEnabledCookieName}=;path=/`;\n\n if (locale === defaultLocale) {\n // A browser navigation follows the middleware redirect that removes\n // the default locale prefix. Next.js router.refresh() does not.\n reloadBrowserPage();\n } else {\n refreshServerComponents();\n }\n }\n }\n }, [\n pathname,\n locale,\n referrerLocaleCookieName,\n localeRoutingEnabledCookieName,\n reloadBrowserPage,\n refreshServerComponents,\n ]);\n}\n\nfunction resolvePathLocale(\n pathname: string,\n i18nConfig: I18nConfig,\n defaultLocale: string,\n locales: string[]\n): string {\n const extractedLocale = extractLocale(pathname);\n if (!extractedLocale) {\n return defaultLocale;\n }\n\n return (\n i18nConfig.determineLocale([extractedLocale], locales) ?? defaultLocale\n );\n}\n\nfunction extractLocale(pathname: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W,kBAAkB;AAInD,MAFE,eAAe,SAAS,QAAQ,+BAA+B,KAC/D,UAC0B,qBAAqB,UAAU,UAAU,EAAE;GAErE,MAAM,oBAAoB,kBACxB,UACA,YACA,eACA,QACD;AAGD,OACE,qBACA,QAAQ,SAAS,kBAAkB,IACnC,sBAAsB,QACtB;AAEA,aAAS,SAAS,GAAG,+BAA+B;AAEpD,QAAI,WAAW,cAGb,oBAAmB;QAEnB,0BAAyB;;;IAI9B;EACD;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;;AAGJ,SAAS,kBACP,UACA,YACA,eACA,SACQ;CACR,MAAM,kBAAkB,cAAc,SAAS;AAC/C,KAAI,CAAC,gBACH,QAAO;AAGT,QACE,WAAW,gBAAgB,CAAC,gBAAgB,EAAE,QAAQ,IAAI;;AAI9D,SAAS,cAAc,UAAiC;AACtD,QAAO,SAAS,MAAM,qBAAqB,GAAG,MAAM"}
1
+ {"version":3,"file":"client-boundary.mjs","names":[],"sources":["../../src/utils/client-boundary.tsx"],"sourcesContent":["'use client';\n\n/**\n * This is a small boundary for RSC consumption of client components\n * Cannot be consumed through gt-react/index.rsc as deciding btwn\n * gt-react/index.server and gt-react/index.client can only happen\n * here. This matters for GTProvider, but not for LocaleSelector.\n * This pattern is just good to follow for carrying over different\n * behaviors between client and server from gt-react.\n */\n\nexport { LocaleSelector as Client_LocaleSelector } from 'gt-react';\nexport { RegionSelector as Client_RegionSelector } from 'gt-react';\n\nimport { getCookieValue, getI18nConfig, I18nConfig } from 'gt-i18n/internal';\nimport { GTProvider, type SharedGTProviderProps } from 'gt-react';\nimport { usePathname, useRouter } from 'next/navigation';\nimport { useCallback, useEffect } from 'react';\nimport { initializeGTClient } from '../setup/initGT.client';\nimport {\n defaultLocaleRoutingEnabledCookieName,\n defaultReferrerLocaleCookieName,\n} from './cookies';\nimport { compilePathRegex, pathnameMatchesRegex } from './pathRegex';\n\n// withGTConfig exposes this build-time value to both middleware and client code.\nconst pathRegex = compilePathRegex(process.env._GENERALTRANSLATION_PATH_REGEX);\n\n/**\n * Only need to initalize client. We know server was already\n * inialaized by index.rsc.ts. We do not know yet if client\n * has been initialized by index.client.ts.\n */\nif (typeof window !== 'undefined') {\n initializeGTClient();\n}\n\n/**\n * Small wrapper to embed nextjs app router behavior\n */\nexport function Client_GTProvider({\n supportsLocaleRefresh,\n ...props\n}: SharedGTProviderProps & {\n supportsLocaleRefresh: boolean;\n}) {\n const router = useRouter();\n const refreshServerComponents = useCallback(() => {\n // Older Next versions can retain a stale layout/provider after a redirect.\n if (!supportsLocaleRefresh) {\n globalThis.location.reload();\n return;\n }\n router.refresh();\n }, [router, supportsLocaleRefresh]);\n const reloadBrowserPage = useCallback(() => {\n globalThis.location.reload();\n }, []);\n const syncServerContent = useCallback<\n NonNullable<SharedGTProviderProps['_reload']>\n >(\n ({ locale }) => {\n const i18nConfig = getI18nConfig();\n const localeRoutingEnabled =\n getCookieValue(\n document.cookie,\n defaultLocaleRoutingEnabledCookieName\n ) === 'true';\n const defaultLocale = i18nConfig.getDefaultLocale();\n const locales = i18nConfig.getLocales();\n const currentPathname = globalThis.location.pathname;\n const localeRoutingApplies =\n localeRoutingEnabled &&\n pathnameMatchesRegex(currentPathname, pathRegex);\n if (localeRoutingApplies && locale === defaultLocale) {\n const currentPathLocale = resolvePathLocale(\n currentPathname,\n i18nConfig,\n defaultLocale,\n locales\n );\n if (currentPathLocale !== defaultLocale) {\n reloadBrowserPage();\n return;\n }\n }\n\n refreshServerComponents();\n },\n [refreshServerComponents, reloadBrowserPage]\n );\n usePathCheck({\n reloadBrowserPage,\n refreshServerComponents,\n locale: props.locale,\n });\n return <GTProvider {...props} _reload={syncServerContent} />;\n}\n\n/**\n * Synchronizes server content if the URL locale does not match the selected\n * locale.\n * TODO: optimize this hook\n */\nfunction usePathCheck({\n reloadBrowserPage,\n refreshServerComponents,\n locale,\n referrerLocaleCookieName = defaultReferrerLocaleCookieName,\n localeRoutingEnabledCookieName = defaultLocaleRoutingEnabledCookieName,\n}: {\n reloadBrowserPage: () => void;\n refreshServerComponents: () => void;\n locale: string;\n referrerLocaleCookieName?: string;\n localeRoutingEnabledCookieName?: string;\n}) {\n const pathname = usePathname();\n\n useEffect(() => {\n // Track the referrer locale for middleware\n const i18nConfig = getI18nConfig();\n document.cookie = `${referrerLocaleCookieName}=${locale};path=/`;\n\n // Synchronize server content if the pathname changes\n const locales = i18nConfig.getLocales();\n const defaultLocale = i18nConfig.getDefaultLocale();\n const localeRoutingEnabled =\n getCookieValue(document.cookie, localeRoutingEnabledCookieName) ===\n 'true';\n if (localeRoutingEnabled && pathnameMatchesRegex(pathname, pathRegex)) {\n // Extract locale from pathname\n const currentPathLocale = resolvePathLocale(\n pathname,\n i18nConfig,\n defaultLocale,\n locales\n );\n\n // Both values are resolved to configured identities before comparison.\n if (\n currentPathLocale &&\n locales.includes(currentPathLocale) &&\n currentPathLocale !== locale\n ) {\n // clear cookie (avoids infinite loop when there is no middleware)\n document.cookie = `${localeRoutingEnabledCookieName}=;path=/`;\n\n if (locale === defaultLocale) {\n // A browser navigation follows the middleware redirect that removes\n // the default locale prefix. Next.js router.refresh() does not.\n reloadBrowserPage();\n } else {\n refreshServerComponents();\n }\n }\n }\n }, [\n pathname,\n locale,\n referrerLocaleCookieName,\n localeRoutingEnabledCookieName,\n reloadBrowserPage,\n refreshServerComponents,\n ]);\n}\n\nfunction resolvePathLocale(\n pathname: string,\n i18nConfig: I18nConfig,\n defaultLocale: string,\n locales: string[]\n): string {\n const extractedLocale = extractLocale(pathname);\n if (!extractedLocale) {\n return defaultLocale;\n }\n\n return (\n i18nConfig.determineLocale([extractedLocale], locales) ?? defaultLocale\n );\n}\n\nfunction extractLocale(pathname: string): string | null {\n return pathname.match(/^\\/([^/]+)(?:\\/|$)/)?.[1] ?? null;\n}\n"],"mappings":";;;;;;;;;;AA0BA,MAAM,YAAY,iBAAiB,QAAQ,IAAI,+BAA+B;;;;;;AAO9E,IAAI,OAAO,WAAW,YACpB,qBAAoB;;;;AAMtB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AS,GAAG,+BAA+B;AAEpD,QAAI,WAAW,cAGb,oBAAmB;QAEnB,0BAAyB;;;IAI9B;EACD;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;;AAGJ,SAAS,kBACP,UACA,YACA,eACA,SACQ;CACR,MAAM,kBAAkB,cAAc,SAAS;AAC/C,KAAI,CAAC,gBACH,QAAO;AAGT,QACE,WAAW,gBAAgB,CAAC,gBAAgB,EAAE,QAAQ,IAAI;;AAI9D,SAAS,cAAc,UAAiC;AACtD,QAAO,SAAS,MAAM,qBAAqB,GAAG,MAAM"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "gt-next",
3
- "version": "11.4.2",
3
+ "version": "11.4.4",
4
4
  "description": "A Next.js library for automatic internationalization.",
5
5
  "main": "dist/index.server.js",
6
6
  "peerDependencies": {
7
- "@generaltranslation/compiler": "^1.3.55",
7
+ "@generaltranslation/compiler": "^1.3.57",
8
8
  "next": ">=13.0.0 <15.2.1 || >15.2.2",
9
9
  "react": ">=16.8.0 <20.0.0",
10
10
  "react-dom": ">=16.8.0 <20.0.0"
@@ -29,10 +29,10 @@
29
29
  ],
30
30
  "dependencies": {
31
31
  "@generaltranslation/format": "0.1.9",
32
- "@generaltranslation/react-core": "11.4.2",
33
- "generaltranslation": "9.4.3",
34
- "gt-react": "11.4.2",
35
- "gt-i18n": "1.0.30"
32
+ "@generaltranslation/react-core": "11.4.4",
33
+ "generaltranslation": "9.5.1",
34
+ "gt-react": "11.4.4",
35
+ "gt-i18n": "1.0.32"
36
36
  },
37
37
  "repository": {
38
38
  "type": "git",
@@ -52,7 +52,7 @@
52
52
  "next": "15.2.3",
53
53
  "tsdown": "^0.21.10",
54
54
  "typescript": "^5.9.2",
55
- "@generaltranslation/compiler": "1.3.55"
55
+ "@generaltranslation/compiler": "1.3.57"
56
56
  },
57
57
  "exports": {
58
58
  ".": {