@lingo.dev/react 1.0.1 → 1.0.3
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 +343 -0
- package/dist/index.d.cts +395 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +395 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +313 -0
- package/dist/index.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region ../spec/dist/index.d.ts
|
|
5
|
+
|
|
6
|
+
//#region src/hash.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Deterministic key generation from (source text, context) pairs.
|
|
9
|
+
* Shared between runtime (message lookup) and build tools (extraction, JSONC generation).
|
|
10
|
+
*
|
|
11
|
+
* Uses MurmurHash3 x86_128 on NFC-normalized UTF-8 bytes.
|
|
12
|
+
* Outputs an 8-character base62 string (e.g., "aB3dEf9x").
|
|
13
|
+
*
|
|
14
|
+
* Cross-platform deterministic: JS, Rust, Go, Python produce identical keys
|
|
15
|
+
* when given the same (source, context) pair.
|
|
16
|
+
*
|
|
17
|
+
* 1% collision probability at ~2.4 million messages (48-bit effective entropy).
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Computes a deterministic short key from source text and optional context.
|
|
21
|
+
*
|
|
22
|
+
* Same source + same context = same key (deterministic).
|
|
23
|
+
* Same source + different context = different key (disambiguation).
|
|
24
|
+
*/
|
|
25
|
+
declare function computeKey(source: string, context?: string): string;
|
|
26
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/icu.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* Canonical ICU MessageFormat expression builders.
|
|
31
|
+
* Shared between runtime (l.plural/l.select) and build tools (extraction).
|
|
32
|
+
*
|
|
33
|
+
* These must produce identical output everywhere so that computeKey()
|
|
34
|
+
* generates matching hash keys at build time and runtime.
|
|
35
|
+
*/
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/format.d.ts
|
|
38
|
+
/**
|
|
39
|
+
* Locale-aware formatting methods wrapping native Intl APIs.
|
|
40
|
+
* Near-zero bundle cost - each method delegates to built-in browser/Node Intl formatters.
|
|
41
|
+
* All methods are pure functions that take a locale string and return formatted strings.
|
|
42
|
+
*/
|
|
43
|
+
type FormatMethods = {
|
|
44
|
+
/**
|
|
45
|
+
* Format a number with locale-aware grouping and decimals.
|
|
46
|
+
* @example l.num(1234567) // "1,234,567" (en) / "1.234.567" (de)
|
|
47
|
+
*/
|
|
48
|
+
readonly num: (value: number, options?: Intl.NumberFormatOptions) => string;
|
|
49
|
+
/**
|
|
50
|
+
* Format a currency value with locale-aware symbol placement and decimals.
|
|
51
|
+
* @example l.currency(29.99, "USD") // "$29.99" (en) / "29,99 $US" (fr)
|
|
52
|
+
*/
|
|
53
|
+
readonly currency: (value: number, currency: string, options?: Intl.NumberFormatOptions) => string;
|
|
54
|
+
/**
|
|
55
|
+
* Format a decimal as a percentage.
|
|
56
|
+
* @example l.percent(0.156) // "16%" (en) / "16 %" (fr)
|
|
57
|
+
*/
|
|
58
|
+
readonly percent: (value: number, options?: Intl.NumberFormatOptions) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Format a value with a measurement unit.
|
|
61
|
+
* @example l.unit(32, "celsius") // "32°C" (en) / "32 °C" (de)
|
|
62
|
+
*/
|
|
63
|
+
readonly unit: (value: number, unit: string, options?: Intl.NumberFormatOptions) => string;
|
|
64
|
+
/**
|
|
65
|
+
* Format a number in compact notation.
|
|
66
|
+
* @example l.compact(1234567) // "1.2M" (en) / "123万" (ja)
|
|
67
|
+
*/
|
|
68
|
+
readonly compact: (value: number, options?: Intl.NumberFormatOptions) => string;
|
|
69
|
+
/**
|
|
70
|
+
* Format a date.
|
|
71
|
+
* @example l.date(new Date()) // "3/16/2026" (en) / "16.03.2026" (de)
|
|
72
|
+
*/
|
|
73
|
+
readonly date: (value: Date | number, options?: Intl.DateTimeFormatOptions) => string;
|
|
74
|
+
/**
|
|
75
|
+
* Format a time.
|
|
76
|
+
* @example l.time(new Date()) // "3:45 PM" (en) / "15:45" (de)
|
|
77
|
+
*/
|
|
78
|
+
readonly time: (value: Date | number, options?: Intl.DateTimeFormatOptions) => string;
|
|
79
|
+
/**
|
|
80
|
+
* Format a date and time together.
|
|
81
|
+
* @example l.datetime(new Date()) // "3/16/2026, 3:45 PM" (en)
|
|
82
|
+
*/
|
|
83
|
+
readonly datetime: (value: Date | number, options?: Intl.DateTimeFormatOptions) => string;
|
|
84
|
+
/**
|
|
85
|
+
* Format a relative time span.
|
|
86
|
+
* @example l.relative(-3, "day") // "3 days ago" (en) / "vor 3 Tagen" (de)
|
|
87
|
+
*/
|
|
88
|
+
readonly relative: (value: number, unit: Intl.RelativeTimeFormatUnit, options?: Intl.RelativeTimeFormatOptions) => string;
|
|
89
|
+
/**
|
|
90
|
+
* Format a list of items with locale-aware conjunction.
|
|
91
|
+
* @example l.list(["A", "B", "C"]) // "A, B, and C" (en) / "A, B y C" (es)
|
|
92
|
+
*/
|
|
93
|
+
readonly list: (items: string[], options?: Intl.ListFormatOptions) => string;
|
|
94
|
+
/**
|
|
95
|
+
* Get the localized display name for a language, region, script, or currency code.
|
|
96
|
+
* @example l.displayName("en", "language") // "English" (en) / "Englisch" (de)
|
|
97
|
+
*/
|
|
98
|
+
readonly displayName: (code: string, type: "language" | "region" | "script" | "currency") => string | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Sort an array of strings using locale-aware collation rules.
|
|
101
|
+
* Returns a new sorted array. Does not mutate the input.
|
|
102
|
+
* @example l.sort(["ä", "z", "a"]) // ["a", "ä", "z"] (de) vs ["a", "z", "ä"] (sv)
|
|
103
|
+
*/
|
|
104
|
+
readonly sort: (items: string[], options?: Intl.CollatorOptions) => string[];
|
|
105
|
+
/**
|
|
106
|
+
* Segment text into graphemes, words, or sentences using locale-aware rules.
|
|
107
|
+
* Essential for CJK text where spaces don't separate words.
|
|
108
|
+
* @example l.segment("Hello world", "word") // ["Hello", " ", "world"]
|
|
109
|
+
*/
|
|
110
|
+
readonly segment: (text: string, granularity?: "grapheme" | "word" | "sentence") => string[];
|
|
111
|
+
/**
|
|
112
|
+
* Format a byte count as a human-readable file size with locale-aware number formatting.
|
|
113
|
+
* @example l.fileSize(1073741824) // "1 GB" (en) / "1 Go" (fr)
|
|
114
|
+
*/
|
|
115
|
+
readonly fileSize: (bytes: number) => string;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Creates all formatting methods bound to a specific locale.
|
|
119
|
+
*/
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/text.d.ts
|
|
122
|
+
/**
|
|
123
|
+
* Options for `l.text()` translation calls.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* l.text("Welcome, {name}!", { values: { name: "Max" }, context: "Dashboard" })
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
type TextOptions = {
|
|
131
|
+
/** Interpolation values for `{placeholder}` substitution. */
|
|
132
|
+
values?: Record<string, string | number>;
|
|
133
|
+
/** Required context describing where/how this text is used. Improves translation quality and enables disambiguation. */
|
|
134
|
+
context: string;
|
|
135
|
+
};
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/rich.d.ts
|
|
138
|
+
/**
|
|
139
|
+
* Options for `l.rich()` rich text translation calls.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```tsx
|
|
143
|
+
* l.rich("Click <link>here</link> for {topic}", {
|
|
144
|
+
* tags: { link: (children) => <a href="/help">{children}</a> },
|
|
145
|
+
* values: { topic: "details" },
|
|
146
|
+
* context: "Footer",
|
|
147
|
+
* })
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
type RichOptions = {
|
|
151
|
+
/** Map tag names to React component renderers. `<tag>children</tag>` and `<tag/>` supported. */
|
|
152
|
+
tags?: Record<string, (children: ReactNode) => ReactNode>;
|
|
153
|
+
/** Interpolation values for `{placeholder}` substitution in text segments. */
|
|
154
|
+
values?: Record<string, string | number>;
|
|
155
|
+
/** Required context describing where/how this text is used. Improves translation quality and enables disambiguation. */
|
|
156
|
+
context: string;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Resolves a translated string with rich text tag interpolation.
|
|
160
|
+
* Parses <tag>children</tag> and <tag/> patterns, mapping them to React components.
|
|
161
|
+
*/
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/types.d.ts
|
|
164
|
+
/**
|
|
165
|
+
* Map of hash keys to translated message strings (ICU MessageFormat syntax).
|
|
166
|
+
* Loaded from JSONC locale files at runtime.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* const messages: Messages = {
|
|
171
|
+
* "TT6OR9Mc": "Hola", // translation for "Hello"
|
|
172
|
+
* "DX4rMVco": "Hola, {name}!", // translation for "Hello, {name}!"
|
|
173
|
+
* };
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
type Messages = Record<string, string>;
|
|
177
|
+
/**
|
|
178
|
+
* Augment this interface via `declare module "@lingo.dev/react"` in a
|
|
179
|
+
* generated .d.ts to get autocomplete, value validation, and context enforcement
|
|
180
|
+
* on l.text() and l.rich().
|
|
181
|
+
*
|
|
182
|
+
* When empty (default): l.text() accepts any string, context required as `string`.
|
|
183
|
+
* When populated (after `lingo extract`): l.text() only accepts listed source strings,
|
|
184
|
+
* and context is narrowed to exact union of extracted values.
|
|
185
|
+
*
|
|
186
|
+
* @example Generated .d.ts:
|
|
187
|
+
* ```ts
|
|
188
|
+
* declare module "@lingo.dev/react" {
|
|
189
|
+
* interface LingoMessages {
|
|
190
|
+
* "Hello": { context: "Hero heading" };
|
|
191
|
+
* "Welcome, {name}": { values: { name: string | number }; context: "Dashboard greeting" };
|
|
192
|
+
* "Save": { context: "Form button" | "Toolbar action" };
|
|
193
|
+
* }
|
|
194
|
+
* }
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
interface LingoMessages {}
|
|
198
|
+
/** When LingoMessages is empty: any string. When populated: only listed source strings. */
|
|
199
|
+
type MessageKey = [keyof LingoMessages] extends [never] ? string : Extract<keyof LingoMessages, string>;
|
|
200
|
+
/**
|
|
201
|
+
* Rest args for l.text(): context is always required.
|
|
202
|
+
* Before extraction: accepts any string for context.
|
|
203
|
+
* After extraction: narrows to exact context union from LingoMessages.
|
|
204
|
+
*/
|
|
205
|
+
type TextCallArgs<K extends string> = K extends keyof LingoMessages ? [options: LingoMessages[K]] : [options: TextOptions];
|
|
206
|
+
/**
|
|
207
|
+
* Rest args for l.rich(): context is always required, tags optional.
|
|
208
|
+
* Before extraction: accepts any string for context.
|
|
209
|
+
* After extraction: narrows to exact context union + optional tags.
|
|
210
|
+
*/
|
|
211
|
+
type RichCallArgs<K extends string> = K extends keyof LingoMessages ? [options: LingoMessages[K] & {
|
|
212
|
+
tags?: Record<string, (children: ReactNode) => ReactNode>;
|
|
213
|
+
}] : [options: RichOptions];
|
|
214
|
+
/**
|
|
215
|
+
* CLDR plural category forms for `l.plural()`.
|
|
216
|
+
* `other` is required as the fallback. All other categories are optional
|
|
217
|
+
* and selected based on locale rules via `Intl.PluralRules`.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```ts
|
|
221
|
+
* l.plural(count, { one: "# item", other: "# items" })
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
type PluralForms = {
|
|
225
|
+
other: string;
|
|
226
|
+
zero?: string;
|
|
227
|
+
one?: string;
|
|
228
|
+
two?: string;
|
|
229
|
+
few?: string;
|
|
230
|
+
many?: string;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* String forms for `l.select()`. Exact match on value, with `other` as required fallback.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* l.select(role, { admin: "Admin panel", user: "Dashboard", other: "Home" })
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
type SelectForms = {
|
|
241
|
+
other: string;
|
|
242
|
+
[key: string]: string;
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* The localization object returned by `useLingo()` and `createLingo()`.
|
|
246
|
+
* Provides text translation, rich text interpolation, plural/select formatting,
|
|
247
|
+
* and locale identity (direction, script, region).
|
|
248
|
+
*
|
|
249
|
+
* Context is required on every translation call for better translation quality.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```tsx
|
|
253
|
+
* const l = useLingo();
|
|
254
|
+
* l.text("Hello", { context: "Hero greeting" });
|
|
255
|
+
* l.text("Welcome, {name}", { context: "Dashboard", values: { name: "Max" } });
|
|
256
|
+
* l.rich("Click <link>here</link>", {
|
|
257
|
+
* context: "Help banner",
|
|
258
|
+
* tags: { link: (c) => <a href="/help">{c}</a> },
|
|
259
|
+
* });
|
|
260
|
+
* l.plural(5, { one: "# item", other: "# items" }, { context: "Cart count" });
|
|
261
|
+
* l.select("admin", { admin: "Admin", other: "User" }, { context: "Nav label" });
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
type Lingo = {
|
|
265
|
+
/** Current BCP-47 locale string (e.g., "en", "es", "ar-SA") */
|
|
266
|
+
readonly locale: string;
|
|
267
|
+
/** Text direction derived from locale: "ltr" or "rtl" */
|
|
268
|
+
readonly direction: "ltr" | "rtl";
|
|
269
|
+
/** Script subtag from Intl.Locale (e.g., "Latn", "Arab"). Undefined if locale is invalid. */
|
|
270
|
+
readonly script: string | undefined;
|
|
271
|
+
/** Region subtag from Intl.Locale (e.g., "US", "DE"). Undefined if locale is invalid. */
|
|
272
|
+
readonly region: string | undefined;
|
|
273
|
+
/**
|
|
274
|
+
* Translate plain text. Falls back to source when no translation found.
|
|
275
|
+
* Context is always required.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* l.text("Hello", { context: "Hero greeting" })
|
|
280
|
+
* l.text("Welcome, {name}", { context: "Dashboard", values: { name: "Max" } })
|
|
281
|
+
* l.text("Save", { context: "Form button" })
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
readonly text: <K extends MessageKey>(source: K, ...args: TextCallArgs<K>) => string;
|
|
285
|
+
/**
|
|
286
|
+
* Translate rich text with tag interpolation. Returns ReactNode.
|
|
287
|
+
* Context is always required.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```tsx
|
|
291
|
+
* l.rich("Click <link>here</link>", {
|
|
292
|
+
* context: "Help banner",
|
|
293
|
+
* tags: { link: (children) => <a href="/help">{children}</a> },
|
|
294
|
+
* })
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
readonly rich: <K extends MessageKey>(source: K, ...args: RichCallArgs<K>) => ReactNode;
|
|
298
|
+
/**
|
|
299
|
+
* Format a count using locale-aware CLDR plural rules.
|
|
300
|
+
* `#` in form strings is replaced with the formatted count.
|
|
301
|
+
* Context is always required.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```ts
|
|
305
|
+
* l.plural(1, { one: "# item", other: "# items" }, { context: "Cart count" })
|
|
306
|
+
* l.plural(5, { one: "# item", other: "# items" }, { context: "Cart count" })
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
readonly plural: (count: number, forms: PluralForms, options: {
|
|
310
|
+
context: string;
|
|
311
|
+
}) => string;
|
|
312
|
+
/**
|
|
313
|
+
* Select a string form by exact value match with `other` fallback.
|
|
314
|
+
* Context is always required.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```ts
|
|
318
|
+
* l.select("admin", { admin: "Admin panel", other: "Home" }, { context: "Nav label" })
|
|
319
|
+
* l.select("guest", { admin: "Admin panel", other: "Home" }, { context: "Nav label" })
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
readonly select: (value: string, forms: SelectForms, options: {
|
|
323
|
+
context: string;
|
|
324
|
+
}) => string;
|
|
325
|
+
} & FormatMethods;
|
|
326
|
+
//# sourceMappingURL=types.d.ts.map
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region src/lingo.d.ts
|
|
329
|
+
/**
|
|
330
|
+
* Creates a `Lingo` object for translating text outside of React context.
|
|
331
|
+
* Used by `@lingo.dev/react-next` for Server Components and internally by `LingoProvider`.
|
|
332
|
+
*
|
|
333
|
+
* @param locale - BCP-47 locale string (e.g., "en", "es", "ar-SA")
|
|
334
|
+
* @param messages - Hash-keyed translations from JSONC locale files
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```ts
|
|
338
|
+
* const l = createLingo("es", messages);
|
|
339
|
+
* l.text("Hello", { context: "Hero greeting" });
|
|
340
|
+
* l.direction; // "ltr"
|
|
341
|
+
* l.script; // "Latn"
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
declare function createLingo(locale: string, messages?: Messages): Lingo;
|
|
345
|
+
//# sourceMappingURL=lingo.d.ts.map
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/provider.d.ts
|
|
348
|
+
type LingoProviderProps = {
|
|
349
|
+
/** BCP-47 locale string (e.g., "en", "es", "ar-SA") */
|
|
350
|
+
locale: string;
|
|
351
|
+
/** Hash-keyed translations loaded from JSONC/JSON locale files */
|
|
352
|
+
messages?: Messages;
|
|
353
|
+
children: ReactNode;
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Provides locale and translations to all descendant components via `useLingo()`.
|
|
357
|
+
*
|
|
358
|
+
* Nested providers with the **same locale** merge messages (child overrides parent,
|
|
359
|
+
* missing keys fall through). Nested providers with **different locales** are standalone.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```tsx
|
|
363
|
+
* // Root layout: shared messages
|
|
364
|
+
* <LingoProvider locale="es" messages={sharedMessages}>
|
|
365
|
+
* {/* Dashboard: adds route-specific messages */}
|
|
366
|
+
* <LingoProvider locale="es" messages={dashboardMessages}>
|
|
367
|
+
* <App />
|
|
368
|
+
* </LingoProvider>
|
|
369
|
+
* </LingoProvider>
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
declare function LingoProvider({
|
|
373
|
+
locale,
|
|
374
|
+
messages,
|
|
375
|
+
children
|
|
376
|
+
}: LingoProviderProps): react_jsx_runtime0.JSX.Element;
|
|
377
|
+
/**
|
|
378
|
+
* Access the `Lingo` translation object from the nearest `LingoProvider`.
|
|
379
|
+
*
|
|
380
|
+
* @throws If called outside a `<LingoProvider>`.
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```tsx
|
|
384
|
+
* function Greeting() {
|
|
385
|
+
* const l = useLingo();
|
|
386
|
+
* return <h1>{l.text("Hello")}</h1>;
|
|
387
|
+
* }
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
declare function useLingo(): Lingo;
|
|
391
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
392
|
+
|
|
393
|
+
//#endregion
|
|
394
|
+
export { type FormatMethods, type Lingo, type LingoMessages, LingoProvider, type LingoProviderProps, type MessageKey, type Messages, type PluralForms, type RichOptions, type SelectForms, type TextOptions, computeKey, createLingo, useLingo };
|
|
395
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["computeKey","buildIcuPlural","Record","buildIcuSelect","EntryMetadata","LocaleEntry","LocaleFile","getActiveEntries","readLocaleFile"],"sources":["../../spec/dist/index.d.ts","../src/format.ts","../src/text.ts","../src/rich.ts","../src/types.ts","../src/lingo.ts","../src/provider.tsx"],"sourcesContent":["//#region src/hash.d.ts\n/**\n * Deterministic key generation from (source text, context) pairs.\n * Shared between runtime (message lookup) and build tools (extraction, JSONC generation).\n *\n * Uses MurmurHash3 x86_128 on NFC-normalized UTF-8 bytes.\n * Outputs an 8-character base62 string (e.g., \"aB3dEf9x\").\n *\n * Cross-platform deterministic: JS, Rust, Go, Python produce identical keys\n * when given the same (source, context) pair.\n *\n * 1% collision probability at ~2.4 million messages (48-bit effective entropy).\n */\n/**\n * Computes a deterministic short key from source text and optional context.\n *\n * Same source + same context = same key (deterministic).\n * Same source + different context = different key (disambiguation).\n */\ndeclare function computeKey(source: string, context?: string): string;\n//# sourceMappingURL=hash.d.ts.map\n//#endregion\n//#region src/icu.d.ts\n/**\n * Canonical ICU MessageFormat expression builders.\n * Shared between runtime (l.plural/l.select) and build tools (extraction).\n *\n * These must produce identical output everywhere so that computeKey()\n * generates matching hash keys at build time and runtime.\n */\ndeclare function buildIcuPlural(forms: Record<string, string>): string;\ndeclare function buildIcuSelect(forms: Record<string, string>): string;\n//# sourceMappingURL=icu.d.ts.map\n\n//#endregion\n//#region src/jsonc.d.ts\n/**\n * JSONC locale file reader with structured metadata comments.\n * Lives in @lingo.dev/spec so framework adapters can parse locale files\n * without depending on @lingo.dev/cli.\n *\n * File format:\n * ```jsonc\n * {\n * /*\n * * @context Hero heading\n * * @src app/hero.tsx:12\n * */\n * \"mK9xqZ\": \"Welcome to Acme\"\n * }\n * ```\n */\ntype EntryMetadata = {\n context?: string;\n src?: string;\n orphan?: boolean;\n};\ntype LocaleEntry = {\n key: string;\n value: string;\n metadata: EntryMetadata;\n};\ntype LocaleFile = {\n entries: LocaleEntry[];\n};\n/** Filters out orphaned entries, returning only active (non-orphaned) ones. */\ndeclare function getActiveEntries(entries: LocaleEntry[]): LocaleEntry[];\n/**\n * Parses a JSONC string into structured locale entries with metadata.\n * Extracts @context, @src, and @orphan from block comments preceding each key.\n * Pure function - no filesystem access. Works in Node.js and edge runtimes.\n */\ndeclare function readLocaleFile(content: string): LocaleFile;\n//# sourceMappingURL=jsonc.d.ts.map\n//#endregion\nexport { type EntryMetadata, type LocaleEntry, type LocaleFile, buildIcuPlural, buildIcuSelect,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