diff --git a/.gitignore b/.gitignore index aac2fab..6d9d42c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ /coverage /docs /node_modules -*.log \ No newline at end of file +*.log diff --git a/bun.lockb b/bun.lockb index ae2e130..fe449ae 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 1fcf2db..72bc85e 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,6 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.17.0", "@biomejs/biome": "^1.9.2", - "@remix-run/cloudflare": "^2.0.0", - "@remix-run/deno": "^2.0.0", - "@remix-run/dev": "^2.12.1", - "@remix-run/node": "^2.0.0", - "@remix-run/react": "^2.0.0", - "@remix-run/server-runtime": "^2.12.1", "@total-typescript/tsconfig": "^1.0.4", "@types/accept-language-parser": "^1.5.6", "@types/bun": "^1.1.9", @@ -27,15 +21,13 @@ "i18next": "^23.1.0", "react": "^16.8.0 || ^17.0.0 || ^18.0.0", "react-i18next": "^13.0.0 || ^14.0.0 || ^15.0.0", + "react-router": "^7.0.0", "typedoc": "^0.26.7", "typedoc-plugin-mdn-links": "^3.3.0", "typescript": "^5.6.2" }, "peerDependencies": { - "@remix-run/cloudflare": "^2.0.0", - "@remix-run/deno": "^2.0.0", - "@remix-run/node": "^2.0.0", - "@remix-run/react": "^2.0.0", + "react-router": "^7.0.0", "i18next": "^23.1.0", "react": "^16.8.0 || ^17.0.0 || ^18.0.0", "react-i18next": "^13.0.0 || ^14.0.0 || ^15.0.0" @@ -49,31 +41,14 @@ "bugs": { "url": "https://github.com/sergiodxa/remix-i18next/issues" }, - "description": "The easiest way to translate your Remix apps", + "description": "The easiest way to translate your FullStack React Router apps", "engines": { "node": ">=20.0.0" }, "funding": "https://github.com/sponsors/sergiodxa", "homepage": "https://github.com/sergiodxa/remix-i18next#readme", - "keywords": [ - "remix", - "i18n", - "i18next", - "ssr", - "csr" - ], + "keywords": ["remix", "i18n", "i18next", "ssr", "csr"], "license": "MIT", - "peerDependenciesMeta": { - "@remix-run/cloudflare": { - "optional": true - }, - "@remix-run/deno": { - "optional": true - }, - "@remix-run/node": { - "optional": true - } - }, "scripts": { "build": "tsc", "typecheck": "tsc --noEmit", diff --git a/src/client.ts b/src/client.ts index 0681de2..313e732 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,3 +1,11 @@ +import type { UNSAFE_RouteModules } from "react-router"; + +declare global { + interface Window { + __reactRouterRouteModules: UNSAFE_RouteModules; + } +} + /** * Get the list of namespaces used by the application server-side so you could * set it on i18next init options. @@ -8,7 +16,7 @@ * }) */ export function getInitialNamespaces(): string[] { - let namespaces = Object.values(window.__remixRouteModules).flatMap( + let namespaces = Object.values(window.__reactRouterRouteModules).flatMap( (route) => { if (typeof route?.handle !== "object") return []; if (!route.handle) return []; @@ -16,7 +24,7 @@ export function getInitialNamespaces(): string[] { if (typeof route.handle.i18n === "string") return [route.handle.i18n]; if ( Array.isArray(route.handle.i18n) && - route.handle.i18n.every((value) => typeof value === "string") + route.handle.i18n.every((value: unknown) => typeof value === "string") ) { return route.handle.i18n as string[]; } diff --git a/src/react.tsx b/src/react.tsx index 9eea86b..ef2ae0c 100644 --- a/src/react.tsx +++ b/src/react.tsx @@ -1,6 +1,6 @@ -import { useMatches } from "@remix-run/react"; import * as React from "react"; import { useTranslation } from "react-i18next"; +import { useMatches } from "react-router"; /** * Get the locale returned by the root route loader under the `locale` key. diff --git a/src/server.test.ts b/src/server.test.ts index 72c550d..358b0f3 100644 --- a/src/server.test.ts +++ b/src/server.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { createCookie, createMemorySessionStorage } from "@remix-run/node"; import type { BackendModule, FormatterModule } from "i18next"; +import { createCookie, createMemorySessionStorage } from "react-router"; import { RemixI18Next } from "./server.js"; describe(RemixI18Next.name, () => { diff --git a/src/server.ts b/src/server.ts index 38c129e..fb9c273 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,8 +1,3 @@ -import type { - Cookie, - EntryContext, - SessionStorage, -} from "@remix-run/server-runtime"; import { type BackendModule, type DefaultNamespace, @@ -15,6 +10,7 @@ import { type TFunction, createInstance, } from "i18next"; +import type { Cookie, EntryContext, SessionStorage } from "react-router"; import { getClientLocales } from "./lib/get-client-locales.js"; import { pick } from "./lib/parser.js";