@verbaly/react 0.75.0 → 0.77.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/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_render = require("./render-CY-uLpA6.cjs");
2
+ const require_render = require("./render-4doKDlxH.cjs");
3
3
  let react = require("react");
4
- //#region src/index.ts
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() {
@@ -42,11 +42,8 @@ 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;
49
48
  exports.useT = useT;
50
49
  exports.useVerbaly = useVerbaly;
51
-
52
- //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -1,7 +1,6 @@
1
- import { n as TransProps, t as TransOptions } from "./render-D1J3Qbqg.cjs";
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,6 +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
- export type { Params, TFunction, TransOptions, TransProps, Verbaly };
16
- //# sourceMappingURL=index.d.cts.map
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-D1J3Qbqg.js";
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,6 +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
- export type { Params, TFunction, TransOptions, TransProps, Verbaly };
16
- //# sourceMappingURL=index.d.ts.map
13
+ export type { Params, TFunction, TransOptions, TransProps, Verbaly };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { t as renderTrans } from "./render-CyRz_srQ.js";
1
+ import { t as renderTrans } from "./render-DitbbbzJ.js";
2
2
  import { createContext, createElement, useContext, useMemo, useSyncExternalStore } from "react";
3
- //#region src/index.ts
3
+ // src/index.ts
4
4
  const VerbalyContext = createContext(null);
5
5
  const APP_INSTANCE = Symbol.for("verbaly.app");
6
6
  function appInstance() {
@@ -41,7 +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 };
46
-
47
- //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  let react = require("react");
2
2
  let verbaly = require("verbaly");
3
- //#region src/render.ts
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,12 +28,9 @@ 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() {
35
34
  return renderTrans;
36
35
  }
37
36
  });
38
-
39
- //# sourceMappingURL=render-CY-uLpA6.cjs.map
@@ -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,6 +15,4 @@ type TransProps = TransOptions & ({
16
15
  children: ReactNode;
17
16
  });
18
17
  declare function renderTrans(instance: Verbaly, props: TransProps): ReactElement;
19
- //#endregion
20
- export { TransProps as n, renderTrans as r, TransOptions as t };
21
- //# sourceMappingURL=render-D1J3Qbqg.d.ts.map
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,6 +15,4 @@ type TransProps = TransOptions & ({
16
15
  children: ReactNode;
17
16
  });
18
17
  declare function renderTrans(instance: Verbaly, props: TransProps): ReactElement;
19
- //#endregion
20
- export { TransProps as n, renderTrans as r, TransOptions as t };
21
- //# sourceMappingURL=render-D1J3Qbqg.d.cts.map
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
- //#region src/render.ts
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,7 +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 };
33
-
34
- //# sourceMappingURL=render-CyRz_srQ.js.map
package/dist/server.cjs CHANGED
@@ -1,11 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_render = require("./render-CY-uLpA6.cjs");
3
- //#region src/server.ts
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;
10
-
11
- //# sourceMappingURL=server.cjs.map
package/dist/server.d.cts CHANGED
@@ -1,10 +1,7 @@
1
- import { n as TransProps, r as renderTrans, t as TransOptions } from "./render-D1J3Qbqg.cjs";
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
- export { type TransOptions, type TransProps, renderTrans };
10
- //# sourceMappingURL=server.d.cts.map
7
+ export { type TransOptions, type TransProps, renderTrans };
package/dist/server.d.ts CHANGED
@@ -1,10 +1,7 @@
1
- import { n as TransProps, r as renderTrans, t as TransOptions } from "./render-D1J3Qbqg.js";
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
- export { type TransOptions, type TransProps, renderTrans };
10
- //# sourceMappingURL=server.d.ts.map
7
+ export { type TransOptions, type TransProps, renderTrans };
package/dist/server.js CHANGED
@@ -1,9 +1,6 @@
1
- import { t as renderTrans } from "./render-CyRz_srQ.js";
2
- //#region src/server.ts
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 };
8
-
9
- //# sourceMappingURL=server.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbaly/react",
3
- "version": "0.75.0",
3
+ "version": "0.77.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.75.0"
65
+ "verbaly": "^0.77.0"
62
66
  },
63
67
  "devDependencies": {
64
68
  "@types/react": "^19.3.0",
65
69
  "@types/react-dom": "^19.3.0",
66
- "happy-dom": "^21.0.3",
67
- "preact": "^11.0.1",
68
- "preact-render-to-string": "^6.8.1",
70
+ "happy-dom": "^21.0.4",
71
+ "preact": "^11.1.0",
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.0"
75
+ "verbaly": "^0.77.0"
72
76
  },
73
77
  "scripts": {
74
78
  "build": "tsdown",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["createContext","createElement","useContext","useMemo","useSyncExternalStore","renderTrans"],"sources":["../src/index.ts"],"sourcesContent":["import {\n createContext,\n createElement,\n useContext,\n useMemo,\n useSyncExternalStore,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport type { DictionaryInput, Params, TFunction, Verbaly } from 'verbaly';\nimport { renderTrans, type TransProps } from './render';\n\nexport type { TransOptions, TransProps } from './render';\n\nconst VerbalyContext = createContext<Verbaly | null>(null);\n\n// what virtual:verbaly registers in a browser; a server holds one instance per request instead\nconst APP_INSTANCE = Symbol.for('verbaly.app');\n\nfunction appInstance(): Verbaly | null {\n if (typeof document === 'undefined') return null;\n return ((globalThis as Record<symbol, unknown>)[APP_INSTANCE] as Verbaly | undefined) ?? null;\n}\n\nexport interface VerbalyProviderProps<D extends DictionaryInput> {\n instance: Verbaly<D>;\n children?: ReactNode;\n}\n\nexport function VerbalyProvider<D extends DictionaryInput>(\n props: VerbalyProviderProps<D>,\n): ReactElement {\n return createElement(\n VerbalyContext.Provider,\n { value: props.instance as unknown as Verbaly },\n props.children,\n );\n}\n\n// a provider wins; without one, a browser or a test reads the app's own, as react-i18next does\nexport function useVerbaly<D extends DictionaryInput = DictionaryInput>(): Verbaly<D> {\n const instance = useContext(VerbalyContext) ?? appInstance();\n if (!instance) {\n throw new Error(\n '[verbaly] useVerbaly requires a <VerbalyProvider>: on a server, or before virtual:verbaly loads',\n );\n }\n return instance as unknown as Verbaly<D>;\n}\n\n// typed by the project's catalog once verbaly.d.ts exists, by a dictionary when one is named\nexport function useT<D extends DictionaryInput = DictionaryInput>(): Verbaly<D>['t'] {\n const instance = useVerbaly<D>();\n const version = useVersion(instance);\n // a new t per locale or catalog: a memo or an effect keyed on t would keep the old language\n return useMemo(() => bound(instance.t), [instance, version]);\n}\n\nfunction bound<T extends Pick<TFunction, 'id'>>(t: T): T {\n const call = t as unknown as (...args: unknown[]) => string;\n const fresh = ((...args: unknown[]) => call(...args)) as unknown as T;\n fresh.id = t.id;\n return fresh;\n}\n\nexport function useLocale(): [string, (locale: string) => void] {\n const instance = useVerbaly();\n useVersion(instance);\n return [instance.locale, instance.setLocale];\n}\n\nfunction useVersion<D extends DictionaryInput>(instance: Verbaly<D>): number {\n return useSyncExternalStore(\n instance.subscribe,\n () => instance.version,\n () => instance.version,\n );\n}\n\n// translated message + element interpolation\nexport function Trans(props: TransProps): ReactElement {\n const ctx = useContext(VerbalyContext);\n const instance = props.instance ?? ctx ?? appInstance();\n if (!instance) {\n throw new Error('[verbaly] <Trans> requires an instance prop or a <VerbalyProvider>');\n }\n useVersion(instance);\n return renderTrans(instance, props);\n}\n\nexport type { Params, TFunction, Verbaly };\n"],"mappings":";;;;AAcA,MAAM,kBAAA,GAAiBA,MAAAA,cAAAA,CAA8B,IAAI;AAGzD,MAAM,eAAe,OAAO,IAAI,aAAa;AAE7C,SAAS,cAA8B;CACrC,IAAI,OAAO,aAAa,aAAa,OAAO;CAC5C,OAAS,WAAuC,iBAAyC;AAC3F;AAOA,SAAgB,gBACd,OACc;CACd,QAAA,GAAOC,MAAAA,cAAAA,CACL,eAAe,UACf,EAAE,OAAO,MAAM,SAA+B,GAC9C,MAAM,QACR;AACF;AAGA,SAAgB,aAAsE;CACpF,MAAM,YAAA,GAAWC,MAAAA,WAAAA,CAAW,cAAc,KAAK,YAAY;CAC3D,IAAI,CAAC,UACH,MAAM,IAAI,MACR,iGACF;CAEF,OAAO;AACT;AAGA,SAAgB,OAAqE;CACnF,MAAM,WAAW,WAAc;CAC/B,MAAM,UAAU,WAAW,QAAQ;CAEnC,QAAA,GAAOC,MAAAA,QAAAA,OAAc,MAAM,SAAS,CAAC,GAAG,CAAC,UAAU,OAAO,CAAC;AAC7D;AAEA,SAAS,MAAuC,GAAS;CACvD,MAAM,OAAO;CACb,MAAM,UAAU,GAAG,SAAoB,KAAK,GAAG,IAAI;CACnD,MAAM,KAAK,EAAE;CACb,OAAO;AACT;AAEA,SAAgB,YAAgD;CAC9D,MAAM,WAAW,WAAW;CAC5B,WAAW,QAAQ;CACnB,OAAO,CAAC,SAAS,QAAQ,SAAS,SAAS;AAC7C;AAEA,SAAS,WAAsC,UAA8B;CAC3E,QAAA,GAAOC,MAAAA,qBAAAA,CACL,SAAS,iBACH,SAAS,eACT,SAAS,OACjB;AACF;AAGA,SAAgB,MAAM,OAAiC;CACrD,MAAM,OAAA,GAAMF,MAAAA,WAAAA,CAAW,cAAc;CACrC,MAAM,WAAW,MAAM,YAAY,OAAO,YAAY;CACtD,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,oEAAoE;CAEtF,WAAW,QAAQ;CACnB,OAAOG,eAAAA,YAAY,UAAU,KAAK;AACpC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n createContext,\n createElement,\n useContext,\n useMemo,\n useSyncExternalStore,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport type { DictionaryInput, Params, TFunction, Verbaly } from 'verbaly';\nimport { renderTrans, type TransProps } from './render';\n\nexport type { TransOptions, TransProps } from './render';\n\nconst VerbalyContext = createContext<Verbaly | null>(null);\n\n// what virtual:verbaly registers in a browser; a server holds one instance per request instead\nconst APP_INSTANCE = Symbol.for('verbaly.app');\n\nfunction appInstance(): Verbaly | null {\n if (typeof document === 'undefined') return null;\n return ((globalThis as Record<symbol, unknown>)[APP_INSTANCE] as Verbaly | undefined) ?? null;\n}\n\nexport interface VerbalyProviderProps<D extends DictionaryInput> {\n instance: Verbaly<D>;\n children?: ReactNode;\n}\n\nexport function VerbalyProvider<D extends DictionaryInput>(\n props: VerbalyProviderProps<D>,\n): ReactElement {\n return createElement(\n VerbalyContext.Provider,\n { value: props.instance as unknown as Verbaly },\n props.children,\n );\n}\n\n// a provider wins; without one, a browser or a test reads the app's own, as react-i18next does\nexport function useVerbaly<D extends DictionaryInput = DictionaryInput>(): Verbaly<D> {\n const instance = useContext(VerbalyContext) ?? appInstance();\n if (!instance) {\n throw new Error(\n '[verbaly] useVerbaly requires a <VerbalyProvider>: on a server, or before virtual:verbaly loads',\n );\n }\n return instance as unknown as Verbaly<D>;\n}\n\n// typed by the project's catalog once verbaly.d.ts exists, by a dictionary when one is named\nexport function useT<D extends DictionaryInput = DictionaryInput>(): Verbaly<D>['t'] {\n const instance = useVerbaly<D>();\n const version = useVersion(instance);\n // a new t per locale or catalog: a memo or an effect keyed on t would keep the old language\n return useMemo(() => bound(instance.t), [instance, version]);\n}\n\nfunction bound<T extends Pick<TFunction, 'id'>>(t: T): T {\n const call = t as unknown as (...args: unknown[]) => string;\n const fresh = ((...args: unknown[]) => call(...args)) as unknown as T;\n fresh.id = t.id;\n return fresh;\n}\n\nexport function useLocale(): [string, (locale: string) => void] {\n const instance = useVerbaly();\n useVersion(instance);\n return [instance.locale, instance.setLocale];\n}\n\nfunction useVersion<D extends DictionaryInput>(instance: Verbaly<D>): number {\n return useSyncExternalStore(\n instance.subscribe,\n () => instance.version,\n () => instance.version,\n );\n}\n\n// translated message + element interpolation\nexport function Trans(props: TransProps): ReactElement {\n const ctx = useContext(VerbalyContext);\n const instance = props.instance ?? ctx ?? appInstance();\n if (!instance) {\n throw new Error('[verbaly] <Trans> requires an instance prop or a <VerbalyProvider>');\n }\n useVersion(instance);\n return renderTrans(instance, props);\n}\n\nexport type { Params, TFunction, Verbaly };\n"],"mappings":";;;AAcA,MAAM,iBAAiB,cAA8B,IAAI;AAGzD,MAAM,eAAe,OAAO,IAAI,aAAa;AAE7C,SAAS,cAA8B;CACrC,IAAI,OAAO,aAAa,aAAa,OAAO;CAC5C,OAAS,WAAuC,iBAAyC;AAC3F;AAOA,SAAgB,gBACd,OACc;CACd,OAAO,cACL,eAAe,UACf,EAAE,OAAO,MAAM,SAA+B,GAC9C,MAAM,QACR;AACF;AAGA,SAAgB,aAAsE;CACpF,MAAM,WAAW,WAAW,cAAc,KAAK,YAAY;CAC3D,IAAI,CAAC,UACH,MAAM,IAAI,MACR,iGACF;CAEF,OAAO;AACT;AAGA,SAAgB,OAAqE;CACnF,MAAM,WAAW,WAAc;CAC/B,MAAM,UAAU,WAAW,QAAQ;CAEnC,OAAO,cAAc,MAAM,SAAS,CAAC,GAAG,CAAC,UAAU,OAAO,CAAC;AAC7D;AAEA,SAAS,MAAuC,GAAS;CACvD,MAAM,OAAO;CACb,MAAM,UAAU,GAAG,SAAoB,KAAK,GAAG,IAAI;CACnD,MAAM,KAAK,EAAE;CACb,OAAO;AACT;AAEA,SAAgB,YAAgD;CAC9D,MAAM,WAAW,WAAW;CAC5B,WAAW,QAAQ;CACnB,OAAO,CAAC,SAAS,QAAQ,SAAS,SAAS;AAC7C;AAEA,SAAS,WAAsC,UAA8B;CAC3E,OAAO,qBACL,SAAS,iBACH,SAAS,eACT,SAAS,OACjB;AACF;AAGA,SAAgB,MAAM,OAAiC;CACrD,MAAM,MAAM,WAAW,cAAc;CACrC,MAAM,WAAW,MAAM,YAAY,OAAO,YAAY;CACtD,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,oEAAoE;CAEtF,WAAW,QAAQ;CACnB,OAAO,YAAY,UAAU,KAAK;AACpC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"render-CY-uLpA6.cjs","names":["createElement","Fragment","parseTags","RICH_TAGS","VOID_TAGS","cloneElement","normalizeLink"],"sources":["../src/render.ts"],"sourcesContent":["import { cloneElement, createElement, Fragment, type ReactElement, type ReactNode } from 'react';\nimport {\n normalizeLink,\n parseTags,\n RICH_TAGS,\n VOID_TAGS,\n type Params,\n type RichLink,\n type TagNode,\n type Verbaly,\n} from 'verbaly';\n\n// everything a <Trans> takes besides its message: one contract for the client and the server\nexport interface TransOptions {\n values?: Params;\n instance?: Verbaly;\n components?: Record<string, ReactElement>;\n richTags?: string[];\n links?: Record<string, RichLink>;\n}\n\n// an id at runtime; children in the source, which the compiler turns into an id and its props\nexport type TransProps = TransOptions &\n ({ id: string; children?: undefined } | { id?: undefined; children: ReactNode });\n\n// no hook and no context in here, so a Server Component renders it as well as a client one\nexport function renderTrans(instance: Verbaly, props: TransProps): ReactElement {\n // never compiled (no plugin, or a file outside include): the source text, like an uncompiled t`…`\n if (props.id === undefined) return createElement(Fragment, null, props.children);\n const text = (instance.t as unknown as (id: string, values?: Params) => string)(\n props.id,\n props.values,\n );\n return createElement(\n Fragment,\n null,\n ...toNodes(\n parseTags(text),\n props.components ?? {},\n props.links ?? {},\n new Set(props.richTags ?? RICH_TAGS),\n ),\n );\n}\n\nconst VOID = new Set(VOID_TAGS);\n\n// own entries only: a tag named constructor in a message must never find the one on Object\nfunction own<T>(map: Record<string, T>, name: string): T | undefined {\n return Object.prototype.hasOwnProperty.call(map, name) ? map[name] : undefined;\n}\n\nfunction toNodes(\n nodes: TagNode[],\n components: Record<string, ReactElement>,\n links: Record<string, RichLink>,\n richTags: Set<string>,\n): ReactNode[] {\n return nodes.map((node, i) => {\n if (typeof node === 'string') return node;\n const children = toNodes(node.children, components, links, richTags);\n const el = own(components, node.name);\n if (el) return cloneElement(el, { key: i }, ...children);\n const link = own(links, node.name);\n if (link !== undefined) {\n return createElement('a', { key: i, ...normalizeLink(link) }, ...children);\n }\n if (richTags.has(node.name)) {\n if (VOID.has(node.name)) return createElement(node.name, { key: i });\n return createElement(node.name, { key: i }, ...children);\n }\n return createElement(Fragment, { key: i }, ...children);\n });\n}\n"],"mappings":";;;AA0BA,SAAgB,YAAY,UAAmB,OAAiC;CAE9E,IAAI,MAAM,OAAO,KAAA,GAAW,QAAA,GAAOA,MAAAA,cAAAA,CAAcC,MAAAA,UAAU,MAAM,MAAM,QAAQ;CAC/E,MAAM,OAAQ,SAAS,EACrB,MAAM,IACN,MAAM,MACR;CACA,QAAA,GAAOD,MAAAA,cAAAA,CACLC,MAAAA,UACA,MACA,GAAG,SAAA,GACDC,QAAAA,UAAAA,CAAU,IAAI,GACd,MAAM,cAAc,CAAC,GACrB,MAAM,SAAS,CAAC,GAChB,IAAI,IAAI,MAAM,YAAYC,QAAAA,SAAS,CACrC,CACF;AACF;AAEA,MAAM,OAAO,IAAI,IAAIC,QAAAA,SAAS;AAG9B,SAAS,IAAO,KAAwB,MAA6B;CACnE,OAAO,OAAO,UAAU,eAAe,KAAK,KAAK,IAAI,IAAI,IAAI,QAAQ,KAAA;AACvE;AAEA,SAAS,QACP,OACA,YACA,OACA,UACa;CACb,OAAO,MAAM,KAAK,MAAM,MAAM;EAC5B,IAAI,OAAO,SAAS,UAAU,OAAO;EACrC,MAAM,WAAW,QAAQ,KAAK,UAAU,YAAY,OAAO,QAAQ;EACnE,MAAM,KAAK,IAAI,YAAY,KAAK,IAAI;EACpC,IAAI,IAAI,QAAA,GAAOC,MAAAA,aAAAA,CAAa,IAAI,EAAE,KAAK,EAAE,GAAG,GAAG,QAAQ;EACvD,MAAM,OAAO,IAAI,OAAO,KAAK,IAAI;EACjC,IAAI,SAAS,KAAA,GACX,QAAA,GAAOL,MAAAA,cAAAA,CAAc,KAAK;GAAE,KAAK;GAAG,IAAA,GAAGM,QAAAA,cAAAA,CAAc,IAAI;EAAE,GAAG,GAAG,QAAQ;EAE3E,IAAI,SAAS,IAAI,KAAK,IAAI,GAAG;GAC3B,IAAI,KAAK,IAAI,KAAK,IAAI,GAAG,QAAA,GAAON,MAAAA,cAAAA,CAAc,KAAK,MAAM,EAAE,KAAK,EAAE,CAAC;GACnE,QAAA,GAAOA,MAAAA,cAAAA,CAAc,KAAK,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,QAAQ;EACzD;EACA,QAAA,GAAOA,MAAAA,cAAAA,CAAcC,MAAAA,UAAU,EAAE,KAAK,EAAE,GAAG,GAAG,QAAQ;CACxD,CAAC;AACH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"render-CyRz_srQ.js","names":[],"sources":["../src/render.ts"],"sourcesContent":["import { cloneElement, createElement, Fragment, type ReactElement, type ReactNode } from 'react';\nimport {\n normalizeLink,\n parseTags,\n RICH_TAGS,\n VOID_TAGS,\n type Params,\n type RichLink,\n type TagNode,\n type Verbaly,\n} from 'verbaly';\n\n// everything a <Trans> takes besides its message: one contract for the client and the server\nexport interface TransOptions {\n values?: Params;\n instance?: Verbaly;\n components?: Record<string, ReactElement>;\n richTags?: string[];\n links?: Record<string, RichLink>;\n}\n\n// an id at runtime; children in the source, which the compiler turns into an id and its props\nexport type TransProps = TransOptions &\n ({ id: string; children?: undefined } | { id?: undefined; children: ReactNode });\n\n// no hook and no context in here, so a Server Component renders it as well as a client one\nexport function renderTrans(instance: Verbaly, props: TransProps): ReactElement {\n // never compiled (no plugin, or a file outside include): the source text, like an uncompiled t`…`\n if (props.id === undefined) return createElement(Fragment, null, props.children);\n const text = (instance.t as unknown as (id: string, values?: Params) => string)(\n props.id,\n props.values,\n );\n return createElement(\n Fragment,\n null,\n ...toNodes(\n parseTags(text),\n props.components ?? {},\n props.links ?? {},\n new Set(props.richTags ?? RICH_TAGS),\n ),\n );\n}\n\nconst VOID = new Set(VOID_TAGS);\n\n// own entries only: a tag named constructor in a message must never find the one on Object\nfunction own<T>(map: Record<string, T>, name: string): T | undefined {\n return Object.prototype.hasOwnProperty.call(map, name) ? map[name] : undefined;\n}\n\nfunction toNodes(\n nodes: TagNode[],\n components: Record<string, ReactElement>,\n links: Record<string, RichLink>,\n richTags: Set<string>,\n): ReactNode[] {\n return nodes.map((node, i) => {\n if (typeof node === 'string') return node;\n const children = toNodes(node.children, components, links, richTags);\n const el = own(components, node.name);\n if (el) return cloneElement(el, { key: i }, ...children);\n const link = own(links, node.name);\n if (link !== undefined) {\n return createElement('a', { key: i, ...normalizeLink(link) }, ...children);\n }\n if (richTags.has(node.name)) {\n if (VOID.has(node.name)) return createElement(node.name, { key: i });\n return createElement(node.name, { key: i }, ...children);\n }\n return createElement(Fragment, { key: i }, ...children);\n });\n}\n"],"mappings":";;;AA0BA,SAAgB,YAAY,UAAmB,OAAiC;CAE9E,IAAI,MAAM,OAAO,KAAA,GAAW,OAAO,cAAc,UAAU,MAAM,MAAM,QAAQ;CAC/E,MAAM,OAAQ,SAAS,EACrB,MAAM,IACN,MAAM,MACR;CACA,OAAO,cACL,UACA,MACA,GAAG,QACD,UAAU,IAAI,GACd,MAAM,cAAc,CAAC,GACrB,MAAM,SAAS,CAAC,GAChB,IAAI,IAAI,MAAM,YAAY,SAAS,CACrC,CACF;AACF;AAEA,MAAM,OAAO,IAAI,IAAI,SAAS;AAG9B,SAAS,IAAO,KAAwB,MAA6B;CACnE,OAAO,OAAO,UAAU,eAAe,KAAK,KAAK,IAAI,IAAI,IAAI,QAAQ,KAAA;AACvE;AAEA,SAAS,QACP,OACA,YACA,OACA,UACa;CACb,OAAO,MAAM,KAAK,MAAM,MAAM;EAC5B,IAAI,OAAO,SAAS,UAAU,OAAO;EACrC,MAAM,WAAW,QAAQ,KAAK,UAAU,YAAY,OAAO,QAAQ;EACnE,MAAM,KAAK,IAAI,YAAY,KAAK,IAAI;EACpC,IAAI,IAAI,OAAO,aAAa,IAAI,EAAE,KAAK,EAAE,GAAG,GAAG,QAAQ;EACvD,MAAM,OAAO,IAAI,OAAO,KAAK,IAAI;EACjC,IAAI,SAAS,KAAA,GACX,OAAO,cAAc,KAAK;GAAE,KAAK;GAAG,GAAG,cAAc,IAAI;EAAE,GAAG,GAAG,QAAQ;EAE3E,IAAI,SAAS,IAAI,KAAK,IAAI,GAAG;GAC3B,IAAI,KAAK,IAAI,KAAK,IAAI,GAAG,OAAO,cAAc,KAAK,MAAM,EAAE,KAAK,EAAE,CAAC;GACnE,OAAO,cAAc,KAAK,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,QAAQ;EACzD;EACA,OAAO,cAAc,UAAU,EAAE,KAAK,EAAE,GAAG,GAAG,QAAQ;CACxD,CAAC;AACH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.cjs","names":["renderTrans"],"sources":["../src/server.ts"],"sourcesContent":["import type { ReactElement } from 'react';\nimport type { Verbaly } from 'verbaly';\nimport { renderTrans, type TransProps } from './render';\n\nexport { renderTrans } from './render';\nexport type { TransOptions, TransProps } from './render';\n\n// a Server Component has no provider to read and no hooks to call, so the instance is a prop\nexport function Trans(props: TransProps & { instance: Verbaly }): ReactElement {\n return renderTrans(props.instance, props);\n}\n"],"mappings":";;;AAQA,SAAgB,MAAM,OAAyD;CAC7E,OAAOA,eAAAA,YAAY,MAAM,UAAU,KAAK;AAC1C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import type { ReactElement } from 'react';\nimport type { Verbaly } from 'verbaly';\nimport { renderTrans, type TransProps } from './render';\n\nexport { renderTrans } from './render';\nexport type { TransOptions, TransProps } from './render';\n\n// a Server Component has no provider to read and no hooks to call, so the instance is a prop\nexport function Trans(props: TransProps & { instance: Verbaly }): ReactElement {\n return renderTrans(props.instance, props);\n}\n"],"mappings":";;AAQA,SAAgB,MAAM,OAAyD;CAC7E,OAAO,YAAY,MAAM,UAAU,KAAK;AAC1C"}