@verbaly/react 0.76.0 → 0.78.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/README.md +3 -3
- package/dist/index.cjs +3 -4
- package/dist/index.d.cts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +3 -4
- package/dist/{render-CY-uLpA6.cjs → render-4doKDlxH.cjs} +1 -2
- package/dist/{render-D1J3Qbqg.d.cts → render-CKhXoteq.d.cts} +0 -2
- package/dist/{render-D1J3Qbqg.d.ts → render-CKhXoteq.d.ts} +0 -2
- package/dist/{render-CyRz_srQ.js → render-DitbbbzJ.js} +1 -2
- package/dist/server.cjs +2 -3
- package/dist/server.d.cts +1 -3
- package/dist/server.d.ts +1 -3
- package/dist/server.js +2 -3
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ pnpm add verbaly @verbaly/react
|
|
|
23
23
|
|
|
24
24
|
```tsx
|
|
25
25
|
import { VerbalyProvider, useT, useLocale } from '@verbaly/react';
|
|
26
|
-
import { verbaly } from '
|
|
26
|
+
import { verbaly } from 'verbaly/app';
|
|
27
27
|
|
|
28
28
|
<VerbalyProvider instance={verbaly}>
|
|
29
29
|
<App />
|
|
@@ -35,9 +35,9 @@ function Inbox() {
|
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
**The provider is optional in the browser.** With none above it, a hook reads the instance `
|
|
38
|
+
**The provider is optional in the browser.** With none above it, a hook reads the instance `verbaly/app` creates, so a single-page app can skip it and a component test renders with no wrapper, as with react-i18next. On a server it is required, since every request has its own instance.
|
|
39
39
|
|
|
40
|
-
**Keys are typed.** `useT()` checks every key and its params against your source catalog, through the types Verbaly generates (`src/verbaly.d.ts` in a Vite app): a key no catalog has does not compile. A key that comes from data, like `t(item.key)` or a variable typed as a union of keys, passes as it is, and its params are left open; declare it with `defineKeys` from `
|
|
40
|
+
**Keys are typed.** `useT()` checks every key and its params against your source catalog, through the types Verbaly generates (`src/verbaly.d.ts` in a Vite app): a key no catalog has does not compile. A key that comes from data, like `t(item.key)` or a variable typed as a union of keys, passes as it is, and its params are left open; declare it with `defineKeys` from `verbaly/app` when you want `check` to verify it exists.
|
|
41
41
|
|
|
42
42
|
`useT()` hands out a new `t` whenever the language changes or a catalog arrives, so a `useMemo`, `useCallback` or effect keyed on `t` runs again in the new language. While nothing changes it stays the same function.
|
|
43
43
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_render = require("./render-
|
|
2
|
+
const require_render = require("./render-4doKDlxH.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
|
-
|
|
4
|
+
// src/index.ts
|
|
5
5
|
const VerbalyContext = (0, react.createContext)(null);
|
|
6
6
|
const APP_INSTANCE = Symbol.for("verbaly.app");
|
|
7
7
|
function appInstance() {
|
|
@@ -13,7 +13,7 @@ function VerbalyProvider(props) {
|
|
|
13
13
|
}
|
|
14
14
|
function useVerbaly() {
|
|
15
15
|
const instance = (0, react.useContext)(VerbalyContext) ?? appInstance();
|
|
16
|
-
if (!instance) throw new Error("[verbaly] useVerbaly requires a <VerbalyProvider>: on a server, or before
|
|
16
|
+
if (!instance) throw new Error("[verbaly] useVerbaly requires a <VerbalyProvider>: on a server, or before verbaly/app loads");
|
|
17
17
|
return instance;
|
|
18
18
|
}
|
|
19
19
|
function useT() {
|
|
@@ -42,7 +42,6 @@ function Trans(props) {
|
|
|
42
42
|
useVersion(instance);
|
|
43
43
|
return require_render.renderTrans(instance, props);
|
|
44
44
|
}
|
|
45
|
-
//#endregion
|
|
46
45
|
exports.Trans = Trans;
|
|
47
46
|
exports.VerbalyProvider = VerbalyProvider;
|
|
48
47
|
exports.useLocale = useLocale;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { n as TransProps, t as TransOptions } from "./render-
|
|
1
|
+
import { n as TransProps, t as TransOptions } from "./render-CKhXoteq.cjs";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
3
|
import { DictionaryInput, Params, TFunction, Verbaly } from "verbaly";
|
|
4
|
-
//#region src/index.d.ts
|
|
5
4
|
export interface VerbalyProviderProps<D extends DictionaryInput> {
|
|
6
5
|
instance: Verbaly<D>;
|
|
7
6
|
children?: ReactNode;
|
|
@@ -11,5 +10,4 @@ export declare function useVerbaly<D extends DictionaryInput = DictionaryInput>(
|
|
|
11
10
|
export declare function useT<D extends DictionaryInput = DictionaryInput>(): Verbaly<D>['t'];
|
|
12
11
|
export declare function useLocale(): [string, (locale: string) => void];
|
|
13
12
|
export declare function Trans(props: TransProps): ReactElement;
|
|
14
|
-
//#endregion
|
|
15
13
|
export type { Params, TFunction, TransOptions, TransProps, Verbaly };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { n as TransProps, t as TransOptions } from "./render-
|
|
1
|
+
import { n as TransProps, t as TransOptions } from "./render-CKhXoteq.js";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
3
|
import { DictionaryInput, Params, TFunction, Verbaly } from "verbaly";
|
|
4
|
-
//#region src/index.d.ts
|
|
5
4
|
export interface VerbalyProviderProps<D extends DictionaryInput> {
|
|
6
5
|
instance: Verbaly<D>;
|
|
7
6
|
children?: ReactNode;
|
|
@@ -11,5 +10,4 @@ export declare function useVerbaly<D extends DictionaryInput = DictionaryInput>(
|
|
|
11
10
|
export declare function useT<D extends DictionaryInput = DictionaryInput>(): Verbaly<D>['t'];
|
|
12
11
|
export declare function useLocale(): [string, (locale: string) => void];
|
|
13
12
|
export declare function Trans(props: TransProps): ReactElement;
|
|
14
|
-
//#endregion
|
|
15
13
|
export type { Params, TFunction, TransOptions, TransProps, Verbaly };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as renderTrans } from "./render-
|
|
1
|
+
import { t as renderTrans } from "./render-DitbbbzJ.js";
|
|
2
2
|
import { createContext, createElement, useContext, useMemo, useSyncExternalStore } from "react";
|
|
3
|
-
|
|
3
|
+
// src/index.ts
|
|
4
4
|
const VerbalyContext = createContext(null);
|
|
5
5
|
const APP_INSTANCE = Symbol.for("verbaly.app");
|
|
6
6
|
function appInstance() {
|
|
@@ -12,7 +12,7 @@ function VerbalyProvider(props) {
|
|
|
12
12
|
}
|
|
13
13
|
function useVerbaly() {
|
|
14
14
|
const instance = useContext(VerbalyContext) ?? appInstance();
|
|
15
|
-
if (!instance) throw new Error("[verbaly] useVerbaly requires a <VerbalyProvider>: on a server, or before
|
|
15
|
+
if (!instance) throw new Error("[verbaly] useVerbaly requires a <VerbalyProvider>: on a server, or before verbaly/app loads");
|
|
16
16
|
return instance;
|
|
17
17
|
}
|
|
18
18
|
function useT() {
|
|
@@ -41,5 +41,4 @@ function Trans(props) {
|
|
|
41
41
|
useVersion(instance);
|
|
42
42
|
return renderTrans(instance, props);
|
|
43
43
|
}
|
|
44
|
-
//#endregion
|
|
45
44
|
export { Trans, VerbalyProvider, useLocale, useT, useVerbaly };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
let react = require("react");
|
|
2
2
|
let verbaly = require("verbaly");
|
|
3
|
-
|
|
3
|
+
// src/render.ts
|
|
4
4
|
function renderTrans(instance, props) {
|
|
5
5
|
if (props.id === void 0) return (0, react.createElement)(react.Fragment, null, props.children);
|
|
6
6
|
const text = instance.t(props.id, props.values);
|
|
@@ -28,7 +28,6 @@ function toNodes(nodes, components, links, richTags) {
|
|
|
28
28
|
return (0, react.createElement)(react.Fragment, { key: i }, ...children);
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
//#endregion
|
|
32
31
|
Object.defineProperty(exports, "renderTrans", {
|
|
33
32
|
enumerable: true,
|
|
34
33
|
get: function() {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { Params, RichLink, Verbaly } from "verbaly";
|
|
3
|
-
//#region src/render.d.ts
|
|
4
3
|
interface TransOptions {
|
|
5
4
|
values?: Params;
|
|
6
5
|
instance?: Verbaly;
|
|
@@ -16,5 +15,4 @@ type TransProps = TransOptions & ({
|
|
|
16
15
|
children: ReactNode;
|
|
17
16
|
});
|
|
18
17
|
declare function renderTrans(instance: Verbaly, props: TransProps): ReactElement;
|
|
19
|
-
//#endregion
|
|
20
18
|
export { TransProps as n, renderTrans as r, TransOptions as t };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { Params, RichLink, Verbaly } from "verbaly";
|
|
3
|
-
//#region src/render.d.ts
|
|
4
3
|
interface TransOptions {
|
|
5
4
|
values?: Params;
|
|
6
5
|
instance?: Verbaly;
|
|
@@ -16,5 +15,4 @@ type TransProps = TransOptions & ({
|
|
|
16
15
|
children: ReactNode;
|
|
17
16
|
});
|
|
18
17
|
declare function renderTrans(instance: Verbaly, props: TransProps): ReactElement;
|
|
19
|
-
//#endregion
|
|
20
18
|
export { TransProps as n, renderTrans as r, TransOptions as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, cloneElement, createElement } from "react";
|
|
2
2
|
import { RICH_TAGS, VOID_TAGS, normalizeLink, parseTags } from "verbaly";
|
|
3
|
-
|
|
3
|
+
// src/render.ts
|
|
4
4
|
function renderTrans(instance, props) {
|
|
5
5
|
if (props.id === void 0) return createElement(Fragment, null, props.children);
|
|
6
6
|
const text = instance.t(props.id, props.values);
|
|
@@ -28,5 +28,4 @@ function toNodes(nodes, components, links, richTags) {
|
|
|
28
28
|
return createElement(Fragment, { key: i }, ...children);
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
//#endregion
|
|
32
31
|
export { renderTrans as t };
|
package/dist/server.cjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_render = require("./render-
|
|
3
|
-
|
|
2
|
+
const require_render = require("./render-4doKDlxH.cjs");
|
|
3
|
+
// src/server.ts
|
|
4
4
|
function Trans(props) {
|
|
5
5
|
return require_render.renderTrans(props.instance, props);
|
|
6
6
|
}
|
|
7
|
-
//#endregion
|
|
8
7
|
exports.Trans = Trans;
|
|
9
8
|
exports.renderTrans = require_render.renderTrans;
|
package/dist/server.d.cts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { n as TransProps, r as renderTrans, t as TransOptions } from "./render-
|
|
1
|
+
import { n as TransProps, r as renderTrans, t as TransOptions } from "./render-CKhXoteq.cjs";
|
|
2
2
|
import { ReactElement } from "react";
|
|
3
3
|
import { Verbaly } from "verbaly";
|
|
4
|
-
//#region src/server.d.ts
|
|
5
4
|
export declare function Trans(props: TransProps & {
|
|
6
5
|
instance: Verbaly;
|
|
7
6
|
}): ReactElement;
|
|
8
|
-
//#endregion
|
|
9
7
|
export { type TransOptions, type TransProps, renderTrans };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { n as TransProps, r as renderTrans, t as TransOptions } from "./render-
|
|
1
|
+
import { n as TransProps, r as renderTrans, t as TransOptions } from "./render-CKhXoteq.js";
|
|
2
2
|
import { ReactElement } from "react";
|
|
3
3
|
import { Verbaly } from "verbaly";
|
|
4
|
-
//#region src/server.d.ts
|
|
5
4
|
export declare function Trans(props: TransProps & {
|
|
6
5
|
instance: Verbaly;
|
|
7
6
|
}): ReactElement;
|
|
8
|
-
//#endregion
|
|
9
7
|
export { type TransOptions, type TransProps, renderTrans };
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as renderTrans } from "./render-
|
|
2
|
-
|
|
1
|
+
import { t as renderTrans } from "./render-DitbbbzJ.js";
|
|
2
|
+
// src/server.ts
|
|
3
3
|
function Trans(props) {
|
|
4
4
|
return renderTrans(props.instance, props);
|
|
5
5
|
}
|
|
6
|
-
//#endregion
|
|
7
6
|
export { Trans, renderTrans };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbaly/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.78.0",
|
|
4
4
|
"description": "React bindings for Verbaly: hooks over the reactive core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"bugs": {
|
|
20
20
|
"url": "https://github.com/AronSoto/verbaly/issues"
|
|
21
21
|
},
|
|
22
|
+
"funding": {
|
|
23
|
+
"type": "github",
|
|
24
|
+
"url": "https://github.com/sponsors/AronSoto"
|
|
25
|
+
},
|
|
22
26
|
"type": "module",
|
|
23
27
|
"main": "./dist/index.cjs",
|
|
24
28
|
"module": "./dist/index.js",
|
|
@@ -58,17 +62,17 @@
|
|
|
58
62
|
},
|
|
59
63
|
"peerDependencies": {
|
|
60
64
|
"react": "^18.0.0 || ^19.0.0",
|
|
61
|
-
"verbaly": "^0.
|
|
65
|
+
"verbaly": "^0.78.0"
|
|
62
66
|
},
|
|
63
67
|
"devDependencies": {
|
|
64
68
|
"@types/react": "^19.3.0",
|
|
65
69
|
"@types/react-dom": "^19.3.0",
|
|
66
70
|
"happy-dom": "^21.0.4",
|
|
67
|
-
"preact": "^11.
|
|
68
|
-
"preact-render-to-string": "^6.8.
|
|
71
|
+
"preact": "^11.1.1",
|
|
72
|
+
"preact-render-to-string": "^6.8.2",
|
|
69
73
|
"react": "^19.3.1",
|
|
70
74
|
"react-dom": "^19.3.1",
|
|
71
|
-
"verbaly": "^0.
|
|
75
|
+
"verbaly": "^0.78.0"
|
|
72
76
|
},
|
|
73
77
|
"scripts": {
|
|
74
78
|
"build": "tsdown",
|