@verbaly/next 0.45.0 → 0.46.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.
- package/dist/client.js +2 -2
- package/dist/client.js.map +1 -1
- package/package.json +7 -7
package/dist/client.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createElement, useCallback, useEffect, useState } from "react";
|
|
3
3
|
import { switchLocale } from "verbaly";
|
|
4
|
-
import { createInstance, requestOptions
|
|
4
|
+
import { createInstance, requestOptions } from "virtual:verbaly";
|
|
5
5
|
import { useRouter } from "next/navigation.js";
|
|
6
6
|
import { Trans, VerbalyProvider as VerbalyProvider$1, useLocale, useT, useVerbaly, useVerbaly as useVerbaly$1 } from "@verbaly/react";
|
|
7
7
|
//#region src/client.ts
|
|
8
8
|
function VerbalyProvider(props) {
|
|
9
9
|
const [instance] = useState(() => {
|
|
10
10
|
const created = createInstance({ locale: props.locale });
|
|
11
|
-
if (props.messages
|
|
11
|
+
if (props.messages) created.addMessages(props.locale, props.messages);
|
|
12
12
|
return created;
|
|
13
13
|
});
|
|
14
14
|
useEffect(() => {
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["ReactVerbalyProvider","useVerbaly"],"sources":["../src/client.ts"],"sourcesContent":["'use client';\n\nimport { useRouter } from 'next/navigation';\nimport {\n createElement,\n useCallback,\n useEffect,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { VerbalyProvider as ReactVerbalyProvider, useVerbaly } from '@verbaly/react';\nimport { switchLocale, type SwitchLocaleOptions } from 'verbaly';\nimport { createInstance, requestOptions
|
|
1
|
+
{"version":3,"file":"client.js","names":["ReactVerbalyProvider","useVerbaly"],"sources":["../src/client.ts"],"sourcesContent":["'use client';\n\nimport { useRouter } from 'next/navigation';\nimport {\n createElement,\n useCallback,\n useEffect,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { VerbalyProvider as ReactVerbalyProvider, useVerbaly } from '@verbaly/react';\nimport { switchLocale, type SwitchLocaleOptions } from 'verbaly';\nimport { createInstance, requestOptions } from 'virtual:verbaly';\nimport type { VerbalyProviderProps as SerializableProps } from './server';\n\nexport { Trans, useLocale, useT, useVerbaly } from '@verbaly/react';\n\n// the serializable props getVerbalyProps() produces, plus the client-side children\nexport interface VerbalyProviderProps extends SerializableProps {\n children?: ReactNode;\n}\n\nexport function VerbalyProvider(props: VerbalyProviderProps): ReactElement {\n // getVerbalyProps omits them for the source locale, so messages here were passed on purpose\n const [instance] = useState(() => {\n const created = createInstance({ locale: props.locale });\n if (props.messages) created.addMessages(props.locale, props.messages);\n return created;\n });\n\n // server changed the locale out-of-band (cookie edit + refresh): follow it\n useEffect(() => {\n if (props.locale === instance.locale) return;\n if (props.messages) {\n instance.addMessages(props.locale, props.messages);\n instance.setLocale(props.locale);\n } else {\n void instance.loadLocale(props.locale).then(() => instance.setLocale(props.locale));\n }\n }, [props.locale, props.messages, instance]);\n\n return createElement(ReactVerbalyProvider, { instance }, props.children);\n}\n\n// core switchLocale in whichever mode the app is in, with the app router as the navigation\nexport function useSwitchLocale(): (\n locale: string,\n options?: SwitchLocaleOptions,\n) => Promise<void> {\n const instance = useVerbaly();\n const router = useRouter();\n return useCallback(\n async (locale, options) => {\n const routed = options?.routing !== undefined && options.routing !== 'no-prefix';\n await switchLocale(instance, locale, {\n cookie: requestOptions?.cookie,\n // a full load would throw away the react tree the app router exists to keep\n navigate: (path) => router.push(path),\n ...options,\n });\n // the navigation already re-rendered the tree, so refreshing on top of it is a second render\n if (!routed) router.refresh();\n },\n [instance, router],\n );\n}\n"],"mappings":";;;;;;;AAuBA,SAAgB,gBAAgB,OAA2C;CAEzE,MAAM,CAAC,YAAY,eAAe;EAChC,MAAM,UAAU,eAAe,EAAE,QAAQ,MAAM,OAAO,CAAC;EACvD,IAAI,MAAM,UAAU,QAAQ,YAAY,MAAM,QAAQ,MAAM,QAAQ;EACpE,OAAO;CACT,CAAC;CAGD,gBAAgB;EACd,IAAI,MAAM,WAAW,SAAS,QAAQ;EACtC,IAAI,MAAM,UAAU;GAClB,SAAS,YAAY,MAAM,QAAQ,MAAM,QAAQ;GACjD,SAAS,UAAU,MAAM,MAAM;EACjC,OACE,SAAc,WAAW,MAAM,MAAM,CAAC,CAAC,WAAW,SAAS,UAAU,MAAM,MAAM,CAAC;CAEtF,GAAG;EAAC,MAAM;EAAQ,MAAM;EAAU;CAAQ,CAAC;CAE3C,OAAO,cAAcA,mBAAsB,EAAE,SAAS,GAAG,MAAM,QAAQ;AACzE;AAGA,SAAgB,kBAGG;CACjB,MAAM,WAAWC,aAAW;CAC5B,MAAM,SAAS,UAAU;CACzB,OAAO,YACL,OAAO,QAAQ,YAAY;EACzB,MAAM,SAAS,SAAS,YAAY,KAAA,KAAa,QAAQ,YAAY;EACrE,MAAM,aAAa,UAAU,QAAQ;GACnC,QAAQ,gBAAgB;GAExB,WAAW,SAAS,OAAO,KAAK,IAAI;GACpC,GAAG;EACL,CAAC;EAED,IAAI,CAAC,QAAQ,OAAO,QAAQ;CAC9B,GACA,CAAC,UAAU,MAAM,CACnB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbaly/next",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"description": "Next.js integration for Verbaly: App Router/RSC with per-request locale negotiation, Turbopack and webpack support, flash-free hydration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -64,23 +64,23 @@
|
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@verbaly/compiler": "^0.
|
|
67
|
+
"@verbaly/compiler": "^0.46.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"next": "^15.0.0 || ^16.0.0",
|
|
71
71
|
"react": "^18.0.0 || ^19.0.0",
|
|
72
|
-
"@verbaly/react": "^0.
|
|
73
|
-
"verbaly": "^0.
|
|
72
|
+
"@verbaly/react": "^0.46.0",
|
|
73
|
+
"verbaly": "^0.46.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/react": "^19.2.18",
|
|
77
77
|
"@types/react-dom": "^19.2.5",
|
|
78
|
-
"happy-dom": "^20.
|
|
78
|
+
"happy-dom": "^20.12.0",
|
|
79
79
|
"next": "^16.3.3",
|
|
80
80
|
"react": "^19.2.8",
|
|
81
81
|
"react-dom": "^19.2.8",
|
|
82
|
-
"
|
|
83
|
-
"verbaly": "^0.
|
|
82
|
+
"verbaly": "^0.46.0",
|
|
83
|
+
"@verbaly/react": "^0.46.0"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"build": "tsdown",
|