verbaly 0.41.0 → 0.43.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.
@@ -1,3 +1,21 @@
1
+ //#region src/parse.d.ts
2
+ type MessageNode = {
3
+ kind: 'text';
4
+ value: string;
5
+ } | {
6
+ kind: 'hash';
7
+ } | ParamNode;
8
+ interface ParamNode {
9
+ kind: 'param';
10
+ name: string;
11
+ format?: string;
12
+ arg?: string;
13
+ ordinal?: boolean;
14
+ variants?: [string, MessageNode[]][];
15
+ }
16
+ type IcuParser = (message: string) => MessageNode[];
17
+ declare function parse(message: string, icu?: IcuParser): MessageNode[];
18
+ //#endregion
1
19
  //#region src/types.d.ts
2
20
  type MessageValue = string | MessageTree;
3
21
  interface MessageTree {
@@ -5,7 +23,11 @@ interface MessageTree {
5
23
  }
6
24
  type DictionaryInput = Record<string, MessageTree>;
7
25
  type Params = Record<string, unknown>;
8
- type Formatter = (value: unknown, locale: string, arg?: string) => string;
26
+ interface FormatInfo {
27
+ param: string;
28
+ key?: string;
29
+ }
30
+ type Formatter = (value: unknown, locale: string, arg?: string, info?: FormatInfo) => string;
9
31
  type LocaleLoader = () => Promise<MessageTree | {
10
32
  default: MessageTree;
11
33
  }>;
@@ -40,6 +62,7 @@ interface VerbalyOptions<D extends DictionaryInput = DictionaryInput> {
40
62
  messages?: D;
41
63
  loaders?: Record<string, LocaleLoader>;
42
64
  formatters?: Record<string, Formatter>;
65
+ icu?: IcuParser;
43
66
  onMissing?: (key: string, locale: string) => string | void;
44
67
  onResolve?: (info: ResolveInfo) => void;
45
68
  }
@@ -59,5 +82,5 @@ interface Verbaly<D extends DictionaryInput = DictionaryInput> {
59
82
  } | undefined;
60
83
  }
61
84
  //#endregion
62
- export { LocaleLoader as a, MessageValue as c, ResolveInfo as d, ResolveStatus as f, VerbalyOptions as g, Verbaly as h, KeysOf as i, ParamNames as l, TFunction as m, FlatKeys as n, MessageAt as o, TArgs as p, Formatter as r, MessageTree as s, DictionaryInput as t, Params as u };
63
- //# sourceMappingURL=types-BTWCYu7Y.d.cts.map
85
+ export { VerbalyOptions as _, KeysOf as a, ParamNode as b, MessageTree as c, Params as d, ResolveInfo as f, Verbaly as g, TFunction as h, Formatter as i, MessageValue as l, TArgs as m, FlatKeys as n, LocaleLoader as o, ResolveStatus as p, FormatInfo as r, MessageAt as s, DictionaryInput as t, ParamNames as u, IcuParser as v, parse as x, MessageNode as y };
86
+ //# sourceMappingURL=types-DvDwMDB-.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verbaly",
3
- "version": "0.41.0",
3
+ "version": "0.43.0",
4
4
  "description": "Effortless i18n: write natural text, ship type-safe, tree-shakeable translations.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -69,7 +69,7 @@
69
69
  "devDependencies": {
70
70
  "esbuild": "^0.28.2",
71
71
  "fast-check": "^4.9.0",
72
- "happy-dom": "^20.11.6",
72
+ "happy-dom": "^20.11.8",
73
73
  "i18next": "^26.4.0"
74
74
  },
75
75
  "scripts": {