verbaly 0.74.0 → 0.76.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 CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  <p align="center">
10
10
  <a href="https://www.npmjs.com/package/verbaly"><img src="https://img.shields.io/npm/v/verbaly?logo=npm&color=cb3837" alt="npm version" /></a>
11
- <img src="https://img.shields.io/badge/gzip-3.33KB-3fb950" alt="3.33KB gzip" />
11
+ <img src="https://img.shields.io/badge/gzip-3.35KB-3fb950" alt="3.35KB gzip" />
12
12
  <img src="https://img.shields.io/badge/dependencies-0-3fb950" alt="zero dependencies" />
13
13
  <img src="https://img.shields.io/badge/types-included-3178C6?logo=typescript&logoColor=white" alt="TypeScript" />
14
14
  <a href="https://github.com/AronSoto/verbaly/blob/develop/LICENSE"><img src="https://img.shields.io/npm/l/verbaly?color=blue" alt="MIT" /></a>
@@ -16,7 +16,7 @@
16
16
 
17
17
  ---
18
18
 
19
- Most i18n tools make you maintain key files by hand: keys drift from the code, no type-safety, heavy setup. **Verbaly inverts the flow:** write the source text in your code, a build plugin extracts stable keys, types and per-locale modules. Compiler-grade safety, a **3.33 KB** runtime, zero dependencies. That is `createVerbaly` on its own; a site with no framework, which also pulls the DOM interpreter and the url helpers, ships **6.15 KB**. Both are measured on every release by `pnpm --filter verbaly size`, never estimated.
19
+ Most i18n tools make you maintain key files by hand: keys drift from the code, no type-safety, heavy setup. **Verbaly inverts the flow:** write the source text in your code, a build plugin extracts stable keys, types and per-locale modules. Compiler-grade safety, a **3.35 KB** runtime, zero dependencies. That is `createVerbaly` on its own; a site with no framework, which also pulls the DOM interpreter and the url helpers, ships **6.18 KB**. Both are measured on every release by `pnpm --filter verbaly size`, never estimated.
20
20
 
21
21
  ```ts
22
22
  // You write this:
@@ -35,13 +35,20 @@ Missing a translation? **Every build says which ones**, and `verbaly check` stop
35
35
 
36
36
  ```bash
37
37
  pnpm add verbaly @verbaly/vite
38
+ pnpm add -D @verbaly/compiler # the verbaly command: init, extract, check
39
+ npx verbaly init
38
40
  ```
39
41
 
40
42
  ```ts
41
43
  // vite.config.ts
42
44
  import verbaly from '@verbaly/vite';
43
45
 
44
- export default { plugins: [verbaly({ locales: ['en', 'es', 'pt'] })] };
46
+ export default { plugins: [verbaly()] };
47
+ ```
48
+
49
+ ```ts
50
+ // verbaly.config.ts, created by npx verbaly init: list your languages, the build and `verbaly check` read them
51
+ export default { sourceLocale: 'en', locales: ['en', 'es', 'pt'] };
45
52
  ```
46
53
 
47
54
  ```ts
@@ -132,6 +139,8 @@ const v = createVerbaly({ locale, fallback: 'en', messages });
132
139
  import { alternateLinks, localePath, stripLocalePath } from 'verbaly';
133
140
 
134
141
  localePath('pt', { supported, sourceLocale: 'en', path: '/es/docs' }); // '/pt/docs'
142
+ // your framework's own trailing slash, which the Astro and Next integrations pass for you
143
+ localePath('es', { supported, sourceLocale: 'en', path: '/', trailingSlash: 'never' }); // '/es'
135
144
  stripLocalePath({ supported, path: '/es/docs' }); // '/docs', the route behind the url
136
145
  alternateLinks({ supported, sourceLocale: 'en', path: '/docs', baseUrl: 'https://x.dev' });
137
146
  // one hreflang entry per locale plus x-default, the same set `verbaly render` writes
package/dist/devtools.cjs CHANGED
@@ -111,5 +111,3 @@ const CSS = `
111
111
  `;
112
112
  //#endregion
113
113
  exports.attachDevtools = attachDevtools;
114
-
115
- //# sourceMappingURL=devtools.cjs.map
@@ -7,5 +7,4 @@ export interface DevtoolsOptions {
7
7
  catalogDir?: string;
8
8
  }
9
9
  export declare function attachDevtools(instance: Verbaly, options?: DevtoolsOptions): () => void;
10
- //#endregion
11
- //# sourceMappingURL=devtools.d.cts.map
10
+ //#endregion
@@ -7,5 +7,4 @@ export interface DevtoolsOptions {
7
7
  catalogDir?: string;
8
8
  }
9
9
  export declare function attachDevtools(instance: Verbaly, options?: DevtoolsOptions): () => void;
10
- //#endregion
11
- //# sourceMappingURL=devtools.d.ts.map
10
+ //#endregion
package/dist/devtools.js CHANGED
@@ -110,5 +110,3 @@ const CSS = `
110
110
  `;
111
111
  //#endregion
112
112
  export { attachDevtools };
113
-
114
- //# sourceMappingURL=devtools.js.map
package/dist/index.cjs CHANGED
@@ -249,7 +249,7 @@ function localePath(locale, options) {
249
249
  const base = normalizeBase(options.base);
250
250
  const parts = splitLocalePath(full, supported, base);
251
251
  if (routing === "prefix-all" || locale !== sourceLocale) parts.segments.unshift(locale);
252
- return joinLocalePath(base, parts);
252
+ return joinLocalePath(base, parts, options.trailingSlash);
253
253
  }
254
254
  function splitLocalePath(full, supported, base) {
255
255
  const cut = full.search(/[?#]/);
@@ -262,9 +262,10 @@ function splitLocalePath(full, supported, base) {
262
262
  trailingSlash: path.endsWith("/")
263
263
  };
264
264
  }
265
- function joinLocalePath(base, parts) {
266
- const trailing = parts.segments.length && parts.trailingSlash ? "/" : "";
267
- return `${base}/${parts.segments.join("/")}${trailing}${parts.rest}`;
265
+ function joinLocalePath(base, parts, slash) {
266
+ const path = parts.segments.join("/");
267
+ const trailing = path ? slash === "always" || slash !== "never" && parts.trailingSlash : slash !== "never" || !base;
268
+ return base + (path && "/" + path) + (trailing ? "/" : "") + parts.rest;
268
269
  }
269
270
  function localeFromPath(options) {
270
271
  const path = options.path ?? currentPath();
@@ -281,18 +282,20 @@ function alternateLinks(options) {
281
282
  const { supported, sourceLocale, path, baseUrl = "" } = options;
282
283
  const routing = options.routing ?? "prefix-except-source";
283
284
  if (routing === "no-prefix") return [];
284
- const base = options.base;
285
+ const { base, trailingSlash } = options;
285
286
  const href = (locale) => baseUrl + localePath(locale, routing === "prefix-all" ? {
286
287
  supported,
287
288
  routing,
288
289
  path,
289
- base
290
+ base,
291
+ trailingSlash
290
292
  } : {
291
293
  supported,
292
294
  routing,
293
295
  sourceLocale,
294
296
  path,
295
- base
297
+ base,
298
+ trailingSlash
296
299
  });
297
300
  const links = supported.map((locale) => ({
298
301
  hreflang: locale,
@@ -423,10 +426,8 @@ async function switchLocale(instance, locale, options = {}) {
423
426
  persistLocale(locale, storageKey);
424
427
  if (!routed) return;
425
428
  const target = localePath(locale, {
426
- supported: options.supported ?? instance.locales ?? [locale],
427
- sourceLocale: options.sourceLocale,
428
- base: options.base,
429
- routing: options.routing
429
+ ...options,
430
+ supported: options.supported ?? instance.locales ?? [locale]
430
431
  });
431
432
  await (options.navigate ?? assign)(target);
432
433
  }
@@ -692,7 +693,7 @@ function findClose(input, open, pairs) {
692
693
  }
693
694
  depth += 1;
694
695
  } else if (ch === "}") {
695
- if (input[i + 1] === "}" && !(pairs && depth > 1)) {
696
+ if (input[i + 1] === "}" && !(pairs && depth > 1) && (depth > 1 || input[i + 2] !== "}" || input.lastIndexOf("|", i) > open)) {
696
697
  i += 2;
697
698
  continue;
698
699
  }
@@ -1270,5 +1271,3 @@ exports.safeHref = safeHref;
1270
1271
  exports.stripLocalePath = stripLocalePath;
1271
1272
  exports.switchLocale = switchLocale;
1272
1273
  exports.warnOnce = warnOnce;
1273
-
1274
- //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -44,10 +44,12 @@ export declare const LOCALE_STORAGE_KEY = "verbaly-locale";
44
44
  export declare function localeDirection(locale: string): 'ltr' | 'rtl';
45
45
  export declare function localeName(locale: string, displayIn?: string): string;
46
46
  type Routing = 'prefix-except-source' | 'no-prefix' | 'prefix-all';
47
+ type TrailingSlash = 'always' | 'never' | 'ignore';
47
48
  interface LocalePathBase {
48
49
  supported: string[];
49
50
  path?: string;
50
51
  base?: string;
52
+ trailingSlash?: TrailingSlash;
51
53
  }
52
54
  type LocalePathOptions = LocalePathBase & ({
53
55
  routing?: 'prefix-except-source';
@@ -75,6 +77,7 @@ interface AlternateLinksOptions {
75
77
  routing?: Routing;
76
78
  base?: string;
77
79
  baseUrl?: string;
80
+ trailingSlash?: TrailingSlash;
78
81
  }
79
82
  export declare function alternateLinks(options: AlternateLinksOptions): AlternateLink[];
80
83
  export declare function resolveLocale(options: ResolveLocaleOptions): string;
@@ -97,6 +100,7 @@ interface SwitchLocaleOptions {
97
100
  supported?: string[];
98
101
  sourceLocale?: string;
99
102
  base?: string;
103
+ trailingSlash?: TrailingSlash;
100
104
  navigate?: (path: string) => void | Promise<void>;
101
105
  }
102
106
  export declare function switchLocale(instance: Pick<Verbaly, 'loadLocale' | 'setLocale'> & Partial<Pick<Verbaly, 'locales'>>, locale: string, options?: SwitchLocaleOptions): Promise<void>;
@@ -121,5 +125,4 @@ export declare function parseTags(text: string): TagNode[];
121
125
  //#region src/warn.d.ts
122
126
  export declare function warnOnce(message: string): void;
123
127
  //#endregion
124
- export { type AddMessagesOptions, type AlternateLink, type AlternateLinksOptions, type BindDomOptions, type DictionaryInput, type FlatKeys, type FormatInfo, type Formatter, type IcuParser, type KeysOf, type Locale, type LocaleFromPathOptions, type LocaleLoader, type LocalePathOptions, type MessageAt, type MessageNode, type MessageTree, type MessageValue, type ParamNames, type ParamNode, type Params, type Register, type RequestLocaleOptions, type ResolveInfo, type ResolveLocaleOptions, type ResolveStatus, type RichLink, type Routing, type StripLocalePathOptions, type SwitchLocaleOptions, type TArgs, type TFunction, type TagNode, type Translate, type Verbaly, type VerbalyOptions, parse };
125
- //# sourceMappingURL=index.d.cts.map
128
+ export { type AddMessagesOptions, type AlternateLink, type AlternateLinksOptions, type BindDomOptions, type DictionaryInput, type FlatKeys, type FormatInfo, type Formatter, type IcuParser, type KeysOf, type Locale, type LocaleFromPathOptions, type LocaleLoader, type LocalePathOptions, type MessageAt, type MessageNode, type MessageTree, type MessageValue, type ParamNames, type ParamNode, type Params, type Register, type RequestLocaleOptions, type ResolveInfo, type ResolveLocaleOptions, type ResolveStatus, type RichLink, type Routing, type StripLocalePathOptions, type SwitchLocaleOptions, type TArgs, type TFunction, type TagNode, type TrailingSlash, type Translate, type Verbaly, type VerbalyOptions, parse };
package/dist/index.d.ts CHANGED
@@ -44,10 +44,12 @@ export declare const LOCALE_STORAGE_KEY = "verbaly-locale";
44
44
  export declare function localeDirection(locale: string): 'ltr' | 'rtl';
45
45
  export declare function localeName(locale: string, displayIn?: string): string;
46
46
  type Routing = 'prefix-except-source' | 'no-prefix' | 'prefix-all';
47
+ type TrailingSlash = 'always' | 'never' | 'ignore';
47
48
  interface LocalePathBase {
48
49
  supported: string[];
49
50
  path?: string;
50
51
  base?: string;
52
+ trailingSlash?: TrailingSlash;
51
53
  }
52
54
  type LocalePathOptions = LocalePathBase & ({
53
55
  routing?: 'prefix-except-source';
@@ -75,6 +77,7 @@ interface AlternateLinksOptions {
75
77
  routing?: Routing;
76
78
  base?: string;
77
79
  baseUrl?: string;
80
+ trailingSlash?: TrailingSlash;
78
81
  }
79
82
  export declare function alternateLinks(options: AlternateLinksOptions): AlternateLink[];
80
83
  export declare function resolveLocale(options: ResolveLocaleOptions): string;
@@ -97,6 +100,7 @@ interface SwitchLocaleOptions {
97
100
  supported?: string[];
98
101
  sourceLocale?: string;
99
102
  base?: string;
103
+ trailingSlash?: TrailingSlash;
100
104
  navigate?: (path: string) => void | Promise<void>;
101
105
  }
102
106
  export declare function switchLocale(instance: Pick<Verbaly, 'loadLocale' | 'setLocale'> & Partial<Pick<Verbaly, 'locales'>>, locale: string, options?: SwitchLocaleOptions): Promise<void>;
@@ -121,5 +125,4 @@ export declare function parseTags(text: string): TagNode[];
121
125
  //#region src/warn.d.ts
122
126
  export declare function warnOnce(message: string): void;
123
127
  //#endregion
124
- export { type AddMessagesOptions, type AlternateLink, type AlternateLinksOptions, type BindDomOptions, type DictionaryInput, type FlatKeys, type FormatInfo, type Formatter, type IcuParser, type KeysOf, type Locale, type LocaleFromPathOptions, type LocaleLoader, type LocalePathOptions, type MessageAt, type MessageNode, type MessageTree, type MessageValue, type ParamNames, type ParamNode, type Params, type Register, type RequestLocaleOptions, type ResolveInfo, type ResolveLocaleOptions, type ResolveStatus, type RichLink, type Routing, type StripLocalePathOptions, type SwitchLocaleOptions, type TArgs, type TFunction, type TagNode, type Translate, type Verbaly, type VerbalyOptions, parse };
125
- //# sourceMappingURL=index.d.ts.map
128
+ export { type AddMessagesOptions, type AlternateLink, type AlternateLinksOptions, type BindDomOptions, type DictionaryInput, type FlatKeys, type FormatInfo, type Formatter, type IcuParser, type KeysOf, type Locale, type LocaleFromPathOptions, type LocaleLoader, type LocalePathOptions, type MessageAt, type MessageNode, type MessageTree, type MessageValue, type ParamNames, type ParamNode, type Params, type Register, type RequestLocaleOptions, type ResolveInfo, type ResolveLocaleOptions, type ResolveStatus, type RichLink, type Routing, type StripLocalePathOptions, type SwitchLocaleOptions, type TArgs, type TFunction, type TagNode, type TrailingSlash, type Translate, type Verbaly, type VerbalyOptions, parse };
package/dist/index.js CHANGED
@@ -248,7 +248,7 @@ function localePath(locale, options) {
248
248
  const base = normalizeBase(options.base);
249
249
  const parts = splitLocalePath(full, supported, base);
250
250
  if (routing === "prefix-all" || locale !== sourceLocale) parts.segments.unshift(locale);
251
- return joinLocalePath(base, parts);
251
+ return joinLocalePath(base, parts, options.trailingSlash);
252
252
  }
253
253
  function splitLocalePath(full, supported, base) {
254
254
  const cut = full.search(/[?#]/);
@@ -261,9 +261,10 @@ function splitLocalePath(full, supported, base) {
261
261
  trailingSlash: path.endsWith("/")
262
262
  };
263
263
  }
264
- function joinLocalePath(base, parts) {
265
- const trailing = parts.segments.length && parts.trailingSlash ? "/" : "";
266
- return `${base}/${parts.segments.join("/")}${trailing}${parts.rest}`;
264
+ function joinLocalePath(base, parts, slash) {
265
+ const path = parts.segments.join("/");
266
+ const trailing = path ? slash === "always" || slash !== "never" && parts.trailingSlash : slash !== "never" || !base;
267
+ return base + (path && "/" + path) + (trailing ? "/" : "") + parts.rest;
267
268
  }
268
269
  function localeFromPath(options) {
269
270
  const path = options.path ?? currentPath();
@@ -280,18 +281,20 @@ function alternateLinks(options) {
280
281
  const { supported, sourceLocale, path, baseUrl = "" } = options;
281
282
  const routing = options.routing ?? "prefix-except-source";
282
283
  if (routing === "no-prefix") return [];
283
- const base = options.base;
284
+ const { base, trailingSlash } = options;
284
285
  const href = (locale) => baseUrl + localePath(locale, routing === "prefix-all" ? {
285
286
  supported,
286
287
  routing,
287
288
  path,
288
- base
289
+ base,
290
+ trailingSlash
289
291
  } : {
290
292
  supported,
291
293
  routing,
292
294
  sourceLocale,
293
295
  path,
294
- base
296
+ base,
297
+ trailingSlash
295
298
  });
296
299
  const links = supported.map((locale) => ({
297
300
  hreflang: locale,
@@ -422,10 +425,8 @@ async function switchLocale(instance, locale, options = {}) {
422
425
  persistLocale(locale, storageKey);
423
426
  if (!routed) return;
424
427
  const target = localePath(locale, {
425
- supported: options.supported ?? instance.locales ?? [locale],
426
- sourceLocale: options.sourceLocale,
427
- base: options.base,
428
- routing: options.routing
428
+ ...options,
429
+ supported: options.supported ?? instance.locales ?? [locale]
429
430
  });
430
431
  await (options.navigate ?? assign)(target);
431
432
  }
@@ -691,7 +692,7 @@ function findClose(input, open, pairs) {
691
692
  }
692
693
  depth += 1;
693
694
  } else if (ch === "}") {
694
- if (input[i + 1] === "}" && !(pairs && depth > 1)) {
695
+ if (input[i + 1] === "}" && !(pairs && depth > 1) && (depth > 1 || input[i + 2] !== "}" || input.lastIndexOf("|", i) > open)) {
695
696
  i += 2;
696
697
  continue;
697
698
  }
@@ -1243,5 +1244,3 @@ const relativeFormatter = (value, locale, arg, info) => {
1243
1244
  };
1244
1245
  //#endregion
1245
1246
  export { CATALOG_SCRIPT, LOCALE_STORAGE_KEY, RICH_TAGS, VOID_TAGS, alternateLinks, bindDom, createVerbaly, flatten, inlineMessages, localeDirection, localeFromPath, localeName, localePath, negotiateLocale, normalizeLink, parse, parseIcu, parseTags, persistLocale, relativeFormatter, resolveLocale, resolveRequestLocale, safeAttribute, safeHref, stripLocalePath, switchLocale, warnOnce };
1246
-
1247
- //# sourceMappingURL=index.js.map
@@ -95,5 +95,4 @@ interface Verbaly<D extends DictionaryInput = DictionaryInput> {
95
95
  } | undefined;
96
96
  }
97
97
  //#endregion
98
- export { MessageNode as C, IcuParser as S, parse as T, TArgs as _, Formatter as a, Verbaly as b, LocaleLoader as c, MessageValue as d, ParamNames as f, ResolveStatus as g, ResolveInfo as h, FormatInfo as i, MessageAt as l, Register as m, DictionaryInput as n, KeysOf as o, Params as p, FlatKeys as r, Locale as s, AddMessagesOptions as t, MessageTree as u, TFunction as v, ParamNode as w, VerbalyOptions as x, Translate as y };
99
- //# sourceMappingURL=types-DtKybAU-.d.cts.map
98
+ export { MessageNode as C, IcuParser as S, parse as T, TArgs as _, Formatter as a, Verbaly as b, LocaleLoader as c, MessageValue as d, ParamNames as f, ResolveStatus as g, ResolveInfo as h, FormatInfo as i, MessageAt as l, Register as m, DictionaryInput as n, KeysOf as o, Params as p, FlatKeys as r, Locale as s, AddMessagesOptions as t, MessageTree as u, TFunction as v, ParamNode as w, VerbalyOptions as x, Translate as y };
@@ -95,5 +95,4 @@ interface Verbaly<D extends DictionaryInput = DictionaryInput> {
95
95
  } | undefined;
96
96
  }
97
97
  //#endregion
98
- export { MessageNode as C, IcuParser as S, parse as T, TArgs as _, Formatter as a, Verbaly as b, LocaleLoader as c, MessageValue as d, ParamNames as f, ResolveStatus as g, ResolveInfo as h, FormatInfo as i, MessageAt as l, Register as m, DictionaryInput as n, KeysOf as o, Params as p, FlatKeys as r, Locale as s, AddMessagesOptions as t, MessageTree as u, TFunction as v, ParamNode as w, VerbalyOptions as x, Translate as y };
99
- //# sourceMappingURL=types-DtKybAU-.d.ts.map
98
+ export { MessageNode as C, IcuParser as S, parse as T, TArgs as _, Formatter as a, Verbaly as b, LocaleLoader as c, MessageValue as d, ParamNames as f, ResolveStatus as g, ResolveInfo as h, FormatInfo as i, MessageAt as l, Register as m, DictionaryInput as n, KeysOf as o, Params as p, FlatKeys as r, Locale as s, AddMessagesOptions as t, MessageTree as u, TFunction as v, ParamNode as w, VerbalyOptions as x, Translate as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verbaly",
3
- "version": "0.74.0",
3
+ "version": "0.76.0",
4
4
  "description": "Effortless i18n: write natural text, ship type-safe, tree-shakeable translations.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -69,8 +69,8 @@
69
69
  "devDependencies": {
70
70
  "esbuild": "^0.28.2",
71
71
  "fast-check": "^4.10.2",
72
- "happy-dom": "^21.0.3",
73
- "i18next": "^26.5.2",
72
+ "happy-dom": "^21.0.4",
73
+ "i18next": "^26.5.4",
74
74
  "tinybench": "^6.2.2"
75
75
  },
76
76
  "scripts": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"devtools.cjs","names":[],"sources":["../src/devtools.ts"],"sourcesContent":["import type { ResolveStatus, Verbaly } from './types';\n\nexport interface DevtoolsOptions {\n root?: ParentNode;\n attribute?: string;\n hotkey?: 'alt' | 'ctrl' | 'shift' | 'meta';\n catalogDir?: string;\n}\n\ninterface Bound {\n key: string;\n status: ResolveStatus;\n}\n\nconst HOTKEY: Record<NonNullable<DevtoolsOptions['hotkey']>, keyof MouseEvent> = {\n alt: 'altKey',\n ctrl: 'ctrlKey',\n shift: 'shiftKey',\n meta: 'metaKey',\n};\n\nfunction statusOf(info: { from: string } | undefined, currentLocale: string): ResolveStatus {\n return !info ? 'miss' : info.from === currentLocale ? 'hit' : 'fallback';\n}\n\n// dev-only inspector: \"what key is this text?\" in the browser (opt-in, tree-shakeable)\nexport function attachDevtools(instance: Verbaly, options: DevtoolsOptions = {}): () => void {\n if (typeof document === 'undefined') throw new Error('[verbaly] devtools requires a DOM');\n const root = options.root ?? document.body;\n const attr = options.attribute ?? 'data-verbaly';\n const modifier = HOTKEY[options.hotkey ?? 'alt'];\n const dir = options.catalogDir ?? 'locales';\n\n const style = document.createElement('style');\n style.textContent = CSS;\n document.head.appendChild(style);\n\n const panel = document.createElement('div');\n panel.className = 'verbaly-dt';\n root.appendChild(panel);\n\n const tip = document.createElement('div');\n tip.className = 'verbaly-dt-tip';\n tip.hidden = true;\n root.appendChild(tip);\n\n function scan(): Bound[] {\n const out: Bound[] = [];\n for (const el of root.querySelectorAll(`[${attr}]`)) {\n const key = el.getAttribute(attr);\n if (!key) continue;\n const info = instance.inspect(key);\n out.push({ key, status: statusOf(info, instance.locale) });\n }\n return out;\n }\n\n function render(): void {\n const bound = scan();\n const miss = bound.filter((b) => b.status === 'miss');\n const fb = bound.filter((b) => b.status === 'fallback');\n const rows = miss\n .map(\n (b) =>\n `<li><code>${esc(b.key)}</code><span>add to <code>${esc(dir)}/${esc(instance.locale)}.json</code></span></li>`,\n )\n .join('');\n panel.innerHTML =\n `<div class=\"verbaly-dt-hd\"><b>verbaly</b> · ${esc(instance.locale)}</div>` +\n `<div class=\"verbaly-dt-stats\">` +\n `<span class=\"ok\">${bound.length - miss.length - fb.length} ok</span>` +\n `<span class=\"fb\">${fb.length} fallback</span>` +\n `<span class=\"miss\">${miss.length} missing</span></div>` +\n (rows ? `<ul class=\"verbaly-dt-miss\">${rows}</ul>` : '') +\n `<div class=\"verbaly-dt-hint\">hold <kbd>${options.hotkey ?? 'Alt'}</kbd> + hover to inspect</div>`;\n }\n\n function onMove(e: MouseEvent): void {\n if (!e[modifier]) {\n tip.hidden = true;\n return;\n }\n const el = (e.target as Element | null)?.closest?.(`[${attr}]`);\n if (!el) {\n tip.hidden = true;\n return;\n }\n const key = el.getAttribute(attr)!;\n const info = instance.inspect(key);\n const status = statusOf(info, instance.locale);\n tip.innerHTML =\n `<div class=\"verbaly-dt-key\">${esc(key)}</div>` +\n `<div class=\"verbaly-dt-row ${status}\">${status}${info && info.from !== instance.locale ? ` · from ${esc(info.from)}` : ''}</div>` +\n (info ? `<div class=\"verbaly-dt-src\">${esc(info.source)}</div>` : '');\n tip.hidden = false;\n tip.style.left = `${Math.min(e.clientX + 14, window.innerWidth - 320)}px`;\n tip.style.top = `${e.clientY + 14}px`;\n }\n\n const unsub = instance.subscribe(render);\n // own panel/tip writes must not re-trigger render (infinite microtask loop)\n const observer = new MutationObserver((records) => {\n if (records.every((r) => panel.contains(r.target) || tip.contains(r.target))) return;\n render();\n });\n observer.observe(root, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [attr],\n });\n document.addEventListener('mousemove', onMove);\n render();\n\n return () => {\n unsub();\n observer.disconnect();\n document.removeEventListener('mousemove', onMove);\n panel.remove();\n tip.remove();\n style.remove();\n };\n}\n\nfunction esc(text: string): string {\n return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n}\n\nconst CSS = `\n.verbaly-dt{position:fixed;bottom:12px;right:12px;z-index:2147483646;max-width:300px;font:12px/1.4 ui-monospace,monospace;color:#e6f0e0;background:#0b120c;border:1px solid #2a3a2c;border-radius:10px;padding:10px;box-shadow:0 8px 30px rgba(0,0,0,.4)}\n.verbaly-dt-hd{font-size:11px;opacity:.85;margin-bottom:6px}\n.verbaly-dt-stats{display:flex;gap:8px;margin-bottom:6px}\n.verbaly-dt-stats span{padding:2px 6px;border-radius:6px;background:#152016}\n.verbaly-dt-stats .ok{color:#bef12d}\n.verbaly-dt-stats .fb{color:#f1c40f}\n.verbaly-dt-stats .miss{color:#ff6b6b}\n.verbaly-dt-miss{list-style:none;margin:0 0 6px;padding:0;max-height:180px;overflow:auto}\n.verbaly-dt-miss li{display:flex;flex-direction:column;gap:2px;padding:4px 0;border-top:1px solid #1c281d}\n.verbaly-dt-miss span{opacity:.6;font-size:11px}\n.verbaly-dt-hint{opacity:.55;font-size:11px}\n.verbaly-dt-hint kbd{background:#152016;border-radius:4px;padding:0 4px}\n.verbaly-dt-tip{position:fixed;z-index:2147483647;max-width:300px;font:12px/1.4 ui-monospace,monospace;color:#e6f0e0;background:#0b120c;border:1px solid #2a3a2c;border-radius:8px;padding:8px;pointer-events:none;box-shadow:0 8px 30px rgba(0,0,0,.4)}\n.verbaly-dt-key{color:#bef12d;font-weight:600;margin-bottom:4px}\n.verbaly-dt-row{margin-bottom:4px}\n.verbaly-dt-row.miss{color:#ff6b6b}\n.verbaly-dt-row.fallback{color:#f1c40f}\n.verbaly-dt-row.hit{color:#7bd88f}\n.verbaly-dt-src{opacity:.75;white-space:pre-wrap;word-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iB,aAAa,MAAM;CAC7C,OAAO;CAEP,aAAa;EACX,MAAM;EACN,SAAS,WAAW;EACpB,SAAS,oBAAoB,aAAa,MAAM;EAChD,MAAM,OAAO;EACb,IAAI,OAAO;EACX,MAAM,OAAO;CACf;AACF;AAEA,SAAS,IAAI,MAAsB;CACjC,OAAO,KAAK,QAAQ,MAAM,OAAO,CAAC,CAAC,QAAQ,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAM;AAC/E;AAEA,MAAM,MAAM"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"devtools.js","names":[],"sources":["../src/devtools.ts"],"sourcesContent":["import type { ResolveStatus, Verbaly } from './types';\n\nexport interface DevtoolsOptions {\n root?: ParentNode;\n attribute?: string;\n hotkey?: 'alt' | 'ctrl' | 'shift' | 'meta';\n catalogDir?: string;\n}\n\ninterface Bound {\n key: string;\n status: ResolveStatus;\n}\n\nconst HOTKEY: Record<NonNullable<DevtoolsOptions['hotkey']>, keyof MouseEvent> = {\n alt: 'altKey',\n ctrl: 'ctrlKey',\n shift: 'shiftKey',\n meta: 'metaKey',\n};\n\nfunction statusOf(info: { from: string } | undefined, currentLocale: string): ResolveStatus {\n return !info ? 'miss' : info.from === currentLocale ? 'hit' : 'fallback';\n}\n\n// dev-only inspector: \"what key is this text?\" in the browser (opt-in, tree-shakeable)\nexport function attachDevtools(instance: Verbaly, options: DevtoolsOptions = {}): () => void {\n if (typeof document === 'undefined') throw new Error('[verbaly] devtools requires a DOM');\n const root = options.root ?? document.body;\n const attr = options.attribute ?? 'data-verbaly';\n const modifier = HOTKEY[options.hotkey ?? 'alt'];\n const dir = options.catalogDir ?? 'locales';\n\n const style = document.createElement('style');\n style.textContent = CSS;\n document.head.appendChild(style);\n\n const panel = document.createElement('div');\n panel.className = 'verbaly-dt';\n root.appendChild(panel);\n\n const tip = document.createElement('div');\n tip.className = 'verbaly-dt-tip';\n tip.hidden = true;\n root.appendChild(tip);\n\n function scan(): Bound[] {\n const out: Bound[] = [];\n for (const el of root.querySelectorAll(`[${attr}]`)) {\n const key = el.getAttribute(attr);\n if (!key) continue;\n const info = instance.inspect(key);\n out.push({ key, status: statusOf(info, instance.locale) });\n }\n return out;\n }\n\n function render(): void {\n const bound = scan();\n const miss = bound.filter((b) => b.status === 'miss');\n const fb = bound.filter((b) => b.status === 'fallback');\n const rows = miss\n .map(\n (b) =>\n `<li><code>${esc(b.key)}</code><span>add to <code>${esc(dir)}/${esc(instance.locale)}.json</code></span></li>`,\n )\n .join('');\n panel.innerHTML =\n `<div class=\"verbaly-dt-hd\"><b>verbaly</b> · ${esc(instance.locale)}</div>` +\n `<div class=\"verbaly-dt-stats\">` +\n `<span class=\"ok\">${bound.length - miss.length - fb.length} ok</span>` +\n `<span class=\"fb\">${fb.length} fallback</span>` +\n `<span class=\"miss\">${miss.length} missing</span></div>` +\n (rows ? `<ul class=\"verbaly-dt-miss\">${rows}</ul>` : '') +\n `<div class=\"verbaly-dt-hint\">hold <kbd>${options.hotkey ?? 'Alt'}</kbd> + hover to inspect</div>`;\n }\n\n function onMove(e: MouseEvent): void {\n if (!e[modifier]) {\n tip.hidden = true;\n return;\n }\n const el = (e.target as Element | null)?.closest?.(`[${attr}]`);\n if (!el) {\n tip.hidden = true;\n return;\n }\n const key = el.getAttribute(attr)!;\n const info = instance.inspect(key);\n const status = statusOf(info, instance.locale);\n tip.innerHTML =\n `<div class=\"verbaly-dt-key\">${esc(key)}</div>` +\n `<div class=\"verbaly-dt-row ${status}\">${status}${info && info.from !== instance.locale ? ` · from ${esc(info.from)}` : ''}</div>` +\n (info ? `<div class=\"verbaly-dt-src\">${esc(info.source)}</div>` : '');\n tip.hidden = false;\n tip.style.left = `${Math.min(e.clientX + 14, window.innerWidth - 320)}px`;\n tip.style.top = `${e.clientY + 14}px`;\n }\n\n const unsub = instance.subscribe(render);\n // own panel/tip writes must not re-trigger render (infinite microtask loop)\n const observer = new MutationObserver((records) => {\n if (records.every((r) => panel.contains(r.target) || tip.contains(r.target))) return;\n render();\n });\n observer.observe(root, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [attr],\n });\n document.addEventListener('mousemove', onMove);\n render();\n\n return () => {\n unsub();\n observer.disconnect();\n document.removeEventListener('mousemove', onMove);\n panel.remove();\n tip.remove();\n style.remove();\n };\n}\n\nfunction esc(text: string): string {\n return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n}\n\nconst CSS = `\n.verbaly-dt{position:fixed;bottom:12px;right:12px;z-index:2147483646;max-width:300px;font:12px/1.4 ui-monospace,monospace;color:#e6f0e0;background:#0b120c;border:1px solid #2a3a2c;border-radius:10px;padding:10px;box-shadow:0 8px 30px rgba(0,0,0,.4)}\n.verbaly-dt-hd{font-size:11px;opacity:.85;margin-bottom:6px}\n.verbaly-dt-stats{display:flex;gap:8px;margin-bottom:6px}\n.verbaly-dt-stats span{padding:2px 6px;border-radius:6px;background:#152016}\n.verbaly-dt-stats .ok{color:#bef12d}\n.verbaly-dt-stats .fb{color:#f1c40f}\n.verbaly-dt-stats .miss{color:#ff6b6b}\n.verbaly-dt-miss{list-style:none;margin:0 0 6px;padding:0;max-height:180px;overflow:auto}\n.verbaly-dt-miss li{display:flex;flex-direction:column;gap:2px;padding:4px 0;border-top:1px solid #1c281d}\n.verbaly-dt-miss span{opacity:.6;font-size:11px}\n.verbaly-dt-hint{opacity:.55;font-size:11px}\n.verbaly-dt-hint kbd{background:#152016;border-radius:4px;padding:0 4px}\n.verbaly-dt-tip{position:fixed;z-index:2147483647;max-width:300px;font:12px/1.4 ui-monospace,monospace;color:#e6f0e0;background:#0b120c;border:1px solid #2a3a2c;border-radius:8px;padding:8px;pointer-events:none;box-shadow:0 8px 30px rgba(0,0,0,.4)}\n.verbaly-dt-key{color:#bef12d;font-weight:600;margin-bottom:4px}\n.verbaly-dt-row{margin-bottom:4px}\n.verbaly-dt-row.miss{color:#ff6b6b}\n.verbaly-dt-row.fallback{color:#f1c40f}\n.verbaly-dt-row.hit{color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iBAAiB,CAAC,IAAI;CACxB,CAAC;CACD,SAAS,iBAAiB,aAAa,MAAM;CAC7C,OAAO;CAEP,aAAa;EACX,MAAM;EACN,SAAS,WAAW;EACpB,SAAS,oBAAoB,aAAa,MAAM;EAChD,MAAM,OAAO;EACb,IAAI,OAAO;EACX,MAAM,OAAO;CACf;AACF;AAEA,SAAS,IAAI,MAAsB;CACjC,OAAO,KAAK,QAAQ,MAAM,OAAO,CAAC,CAAC,QAAQ,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAM;AAC/E;AAEA,MAAM,MAAM"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["describe"],"sources":["../src/warn.ts","../src/flatten.ts","../src/intl.ts","../src/format.ts","../src/locale.ts","../src/icu.ts","../src/parse.ts","../src/instance.ts","../src/tags.ts","../src/dom.ts","../src/relative.ts"],"sourcesContent":["// one warn-once for the whole runtime: the set is unbounded, so a message never carries a value\nconst warned = new Set<string>();\n\nexport function warnOnce(message: string): void {\n if (warned.has(message)) return;\n warned.add(message);\n console.warn(`[verbaly] ${message}`);\n}\n","import type { MessageTree } from './types';\nimport { warnOnce } from './warn';\n\n// null-prototype: lookup reads dict[loc][key], and a plain object answers toString\nexport function flatten(\n tree: MessageTree,\n prefix = '',\n out: Record<string, string> = Object.create(null) as Record<string, string>,\n): Record<string, string> {\n // a catalog is untrusted input: a lazy loader, addMessages or a CMS never crosses the build gate\n if (!isGroup(tree)) return out;\n for (const [key, value] of Object.entries(tree)) {\n const path = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'string') out[path] = value;\n else if (isGroup(value)) flatten(value, path, out);\n else warnOnce(`catalog value at \"${path}\" is not text, so the key renders as itself`);\n }\n return out;\n}\n\nfunction isGroup(value: unknown): value is MessageTree {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n","import { warnOnce } from './warn';\n\nconst CACHE_CAP = 200; // dynamic locales/options can't grow unbounded\n\nconst nfCache = new Map<string, Intl.NumberFormat>();\nconst dtfCache = new Map<string, Intl.DateTimeFormat>();\nconst prCache = new Map<string, Intl.PluralRules>();\nconst rtfCache = new Map<string, Intl.RelativeTimeFormat>();\nconst lfCache = new Map<string, Intl.ListFormat>();\nconst dnCache = new Map<string, Intl.DisplayNames>();\n\nfunction cached<T>(\n cache: Map<string, T>,\n key: string,\n locale: string,\n make: (tag?: string) => T,\n): T {\n let hit = cache.get(key);\n if (!hit) {\n if (cache.size >= CACHE_CAP) cache.delete(cache.keys().next().value as string);\n try {\n hit = make(locale);\n } catch {\n // a bad option throws on every retry, so only a tag Intl cannot read ever reaches the warn\n let tag: string | undefined = locale.replace(/_/g, '-');\n try {\n hit = make(tag);\n } catch {\n hit = make((tag = undefined));\n }\n warnOnce(\n `\"${locale}\" is not a locale tag, so Intl reads it as ${tag ?? 'its default locale'}`,\n );\n }\n cache.set(key, hit);\n }\n return hit;\n}\n\nexport function numberFormat(\n locale: string,\n options?: Intl.NumberFormatOptions,\n): Intl.NumberFormat {\n const key = locale + (options ? JSON.stringify(options) : '');\n return cached(nfCache, key, locale, (tag) => new Intl.NumberFormat(tag, options));\n}\n\nexport function dateTimeFormat(\n locale: string,\n options?: Intl.DateTimeFormatOptions,\n): Intl.DateTimeFormat {\n const key = locale + (options ? JSON.stringify(options) : '');\n return cached(dtfCache, key, locale, (tag) => new Intl.DateTimeFormat(tag, options));\n}\n\nexport function pluralRules(\n locale: string,\n type: Intl.PluralRuleType = 'cardinal',\n): Intl.PluralRules {\n return cached(prCache, locale + type, locale, (tag) => new Intl.PluralRules(tag, { type }));\n}\n\nexport function relativeTimeFormat(locale: string): Intl.RelativeTimeFormat {\n return cached(\n rtfCache,\n locale,\n locale,\n (tag) => new Intl.RelativeTimeFormat(tag, { numeric: 'auto' }),\n );\n}\n\nexport function listFormat(locale: string, type: Intl.ListFormatType): Intl.ListFormat {\n return cached(lfCache, locale + type, locale, (tag) => new Intl.ListFormat(tag, { type }));\n}\n\nexport function displayNames(locale: string): Intl.DisplayNames {\n return cached(dnCache, locale, locale, (tag) => new Intl.DisplayNames(tag, { type: 'language' }));\n}\n","import { dateTimeFormat, listFormat, numberFormat, pluralRules } from './intl';\nimport type { MessageNode, ParamNode } from './parse';\nimport type { Formatter, Params } from './types';\nimport { warnOnce } from './warn';\n\ninterface FormatContext {\n locale: string;\n params: Params | undefined;\n formatters: Record<string, Formatter>;\n hashValue?: unknown;\n key?: string;\n}\n\nexport function formatNodes(nodes: MessageNode[], ctx: FormatContext): string {\n let out = '';\n for (const node of nodes) {\n if (node.kind === 'text') out += node.value;\n else if (node.kind === 'hash') out += autoFormat(ctx.hashValue, ctx.locale, ctx);\n else out += formatParam(node, ctx);\n }\n return out;\n}\n\n// every warn names its message: keying on the param alone silenced the second message with the gap\nfunction where(ctx?: FormatContext): string {\n return ctx?.key ? ` in \"${ctx.key}\"` : '';\n}\n\nfunction formatParam(node: ParamNode, ctx: FormatContext): string {\n let value = ctx.params?.[node.name];\n if (value === undefined) {\n warnOnce(`missing param \"${node.name}\"${where(ctx)}`);\n return `{${node.name}}`;\n }\n // the one door: every path below coerces, so a value that cannot be coerced never gets there\n value = usable(value, ctx);\n\n if (node.variants) {\n const chosen = pickVariant(node.variants, value, ctx.locale, node.ordinal);\n // the value is left out of the warn on purpose: a counter walking 0..N must not grow the dedupe\n if (!chosen) {\n warnOnce(`no case matched for {${node.name}}${where(ctx)}, add an \"other\" case`);\n return '';\n }\n return formatNodes(chosen, { ...ctx, hashValue: value });\n }\n if (node.format) return applyFormat(value, node, ctx);\n return autoFormat(value, ctx.locale, ctx);\n}\n\n// the door a value passes before anything coerces it: a param, or a tagged template's ${…}\nexport function usable(value: unknown, ctx?: FormatContext): unknown {\n if (coercible(value)) return value;\n // the suffix is built here and not by the caller: every param of every call passes this door\n warnOnce(`cannot format ${describe(value)}${where(ctx)}`);\n return '';\n}\n\n// String() and Number() both throw on an object with no callable toString, and a param can be one\nfunction coercible(value: unknown): boolean {\n try {\n return typeof `${value}` === 'string';\n } catch {\n return false;\n }\n}\n\n// the type of the offending value, never the value: the dedupe set must stay bounded\nfunction describe(value: unknown): string {\n if (value instanceof Date) return Number.isNaN(value.getTime()) ? 'an invalid Date' : 'a Date';\n // NaN is typeof number, and \"cannot format a number as a number\" names nothing\n if (typeof value === 'number' && Number.isNaN(value)) return 'NaN';\n if (Array.isArray(value)) return 'an array';\n if (value === null) return 'null';\n if (value === undefined) return 'undefined';\n const type = typeof value;\n return type === 'object' ? 'an object' : `a ${type}`;\n}\n\nfunction pickVariant(\n variants: [string, MessageNode[]][],\n value: unknown,\n locale: string,\n ordinal?: boolean,\n): MessageNode[] | undefined {\n const raw = String(value);\n if (typeof value === 'number') {\n for (const [key, nodes] of variants) if (key === `=${raw}`) return nodes;\n const category = pluralRules(locale, ordinal ? 'ordinal' : 'cardinal').select(value);\n for (const [key, nodes] of variants) if (key === category) return nodes;\n } else {\n for (const [key, nodes] of variants) if (key === raw) return nodes;\n }\n for (const [key, nodes] of variants) if (key === 'other') return nodes;\n return undefined;\n}\n\nconst NUMERIC = /^(number|integer|percent|currency|unit)$/;\n\nfunction applyFormat(value: unknown, node: ParamNode, ctx: FormatContext): string {\n const { name, arg } = node;\n const format = node.format!;\n const custom = ctx.formatters[format];\n if (custom) return custom(value, ctx.locale, arg, { param: name, key: ctx.key });\n\n const { locale } = ctx;\n // what arrived, kept because the numeric guard below replaces value with the parsed number\n const raw = value;\n // a format missing its argument degrades like an invalid one: with a warn, never in silence\n const degrade = (problem: string): string => {\n warnOnce(`{${name}:${format}}${where(ctx)} ${problem}`);\n return String(raw);\n };\n // what a number is gets decided once: Intl prints NaN instead of throwing, and Number(null) is 0\n if (NUMERIC.test(format)) {\n const n = value === null || value === '' ? NaN : Number(value);\n if (Number.isNaN(n)) return degrade(`cannot format ${describe(value)} as a number`);\n value = n;\n }\n\n switch (format) {\n case 'number':\n return numberFormat(locale).format(value as number);\n case 'integer':\n return numberFormat(locale, { maximumFractionDigits: 0 }).format(value as number);\n case 'percent':\n return numberFormat(locale, { style: 'percent' }).format(value as number);\n case 'currency':\n if (!arg) return degrade('needs an argument like /USD');\n try {\n return numberFormat(locale, { style: 'currency', currency: arg }).format(value as number);\n } catch {\n return degrade(`does not know the currency \"${arg}\"`);\n }\n case 'date':\n try {\n return dateTimeFormat(\n locale,\n arg ? { dateStyle: arg as Intl.DateTimeFormatOptions['dateStyle'] } : undefined,\n ).format(toDate(value));\n } catch {\n return degrade(`cannot format ${describe(value)}${arg ? ` with style \"${arg}\"` : ''}`);\n }\n case 'time':\n try {\n return dateTimeFormat(locale, {\n timeStyle: (arg ?? 'short') as Intl.DateTimeFormatOptions['timeStyle'],\n }).format(toDate(value));\n } catch {\n return degrade(`cannot format ${describe(value)} with style \"${arg ?? 'short'}\"`);\n }\n case 'list': {\n if (!Array.isArray(value)) return degrade('needs an array');\n const type = arg === 'or' ? 'disjunction' : arg === 'unit' ? 'unit' : 'conjunction';\n return listFormat(locale, type).format(value.map((item) => autoFormat(item, locale, ctx)));\n }\n case 'unit':\n if (!arg) return degrade('needs an argument like /kilometer');\n try {\n return numberFormat(locale, { style: 'unit', unit: arg }).format(value as number);\n } catch {\n return degrade(`does not know the unit \"${arg}\"`);\n }\n // known but not loaded reads nothing like unknown, and the fix is not the reader's to guess\n case 'relative':\n return degrade('is not loaded: the compiler wires it when a catalog message uses it');\n default:\n return degrade('is not a format verbaly knows');\n }\n}\n\nexport function autoFormat(value: unknown, locale: string, ctx?: FormatContext): string {\n if (value === null || value === undefined) return '';\n // an invalid Date makes Intl throw and NaN makes it print \"NaN\": one degradation, one report\n if (Number.isNaN(value instanceof Date ? value.getTime() : value)) {\n warnOnce(`${describe(value)}${where(ctx)} renders as plain text`);\n return String(value);\n }\n if (typeof value === 'number') return numberFormat(locale).format(value);\n if (value instanceof Date) return dateTimeFormat(locale).format(value);\n return String(value);\n}\n\nfunction toDate(value: unknown): Date {\n return value instanceof Date ? value : new Date(value as string | number);\n}\n","import { displayNames } from './intl';\nimport type { Verbaly } from './types';\nimport { warnOnce } from './warn';\n\nexport interface ResolveLocaleOptions {\n supported: string[];\n fallback?: string;\n storageKey?: string | false;\n path?: string | false;\n base?: string;\n}\n\nexport interface LocaleFromPathOptions {\n supported: string[];\n path?: string;\n base?: string;\n}\n\n// shared identity: localStorage key (browser) + cookie name (SSR integrations)\nexport const LOCALE_STORAGE_KEY = 'verbaly-locale';\n\n// zh-Hant-TW → [zh-Hant-TW, zh-Hant, zh]\nexport function narrowLocales(lang: string): string[] {\n const out: string[] = [];\n const parts = lang.split('-');\n while (parts.length > 0) {\n out.push(parts.join('-'));\n parts.pop();\n }\n return out;\n}\n\n// fallback tables for engines without Intl.Locale getTextInfo (Firefox)\nconst RTL_SCRIPTS = /^(Arab|Aran|Hebr|Thaa|Nkoo|Syrc|Samr|Mand|Adlm|Rohg|Yezi)$/;\nconst RTL_LANGS = /^(ar|he|fa|ur|ps|sd|ug|yi|dv|ckb)$/;\n\ninterface TextInfoLocale extends Intl.Locale {\n getTextInfo?(): { direction?: string };\n textInfo?: { direction?: string };\n}\n\nexport function localeDirection(locale: string): 'ltr' | 'rtl' {\n try {\n // ar_EG is how gettext writes ar-EG, and Intl.Locale throws on it: the fallback read it ltr\n const loc = new Intl.Locale(locale.replace(/_/g, '-')) as TextInfoLocale;\n const direction = (loc.getTextInfo?.() ?? loc.textInfo)?.direction;\n if (direction === 'rtl' || direction === 'ltr') return direction;\n const script = loc.script ?? loc.maximize().script;\n if (script) return RTL_SCRIPTS.test(script) ? 'rtl' : 'ltr';\n return RTL_LANGS.test(loc.language) ? 'rtl' : 'ltr';\n } catch {\n // malformed tag: best effort on the primary subtag, never throw\n return RTL_LANGS.test(locale.split('-')[0]!.toLowerCase()) ? 'rtl' : 'ltr';\n }\n}\n\n// localized language name for locale switchers; defaults to the endonym\nexport function localeName(locale: string, displayIn: string = locale): string {\n try {\n return displayNames(displayIn).of(locale) ?? locale;\n } catch {\n return locale; // unknown tag or missing Intl data: the code beats a crash\n }\n}\n\n// how the language shows in the url, the one decision every other url answer follows from\nexport type Routing = 'prefix-except-source' | 'no-prefix' | 'prefix-all';\n\ninterface LocalePathBase {\n supported: string[];\n path?: string;\n base?: string;\n}\n\n// sourceLocale is required exactly where it decides the answer, so the old silent default cannot\nexport type LocalePathOptions = LocalePathBase &\n (\n | { routing?: 'prefix-except-source'; sourceLocale: string }\n | { routing: 'no-prefix' | 'prefix-all'; sourceLocale?: string }\n );\n\n// the inverse of what render writes: /es/docs → /pt/docs, under the routing mode you chose\nexport function localePath(locale: string, options: LocalePathOptions): string {\n const { supported } = options;\n const routing = options.routing ?? 'prefix-except-source';\n // the whole address: a language switch on a search page keeps the search and the anchor\n const full = options.path ?? currentPath(true) ?? '/';\n\n // the identity, so one switcher works in both modes: no-prefix changes the text, never the url\n if (routing === 'no-prefix') return full;\n\n const sourceLocale = options.sourceLocale;\n if (routing === 'prefix-except-source' && sourceLocale === undefined) {\n warnOnce('localePath needs sourceLocale: \"prefix-except-source\" prefixed every locale');\n }\n\n const base = normalizeBase(options.base);\n const parts = splitLocalePath(full, supported, base);\n if (routing === 'prefix-all' || locale !== sourceLocale) parts.segments.unshift(locale);\n return joinLocalePath(base, parts);\n}\n\ninterface PathParts {\n segments: string[];\n rest: string;\n trailingSlash: boolean;\n}\n\n// one decomposition for both directions: base out front, query behind, locale segment dropped\nfunction splitLocalePath(full: string, supported: string[], base: string): PathParts {\n const cut = full.search(/[?#]/);\n const path = stripBase(cut < 0 ? full : full.slice(0, cut), base);\n const segments = path.split('/').filter(Boolean);\n if (segments[0] && matchPathSegment(segments[0], supported)) segments.shift();\n return { segments, rest: cut < 0 ? '' : full.slice(cut), trailingSlash: path.endsWith('/') };\n}\n\nfunction joinLocalePath(base: string, parts: PathParts): string {\n const trailing = parts.segments.length && parts.trailingSlash ? '/' : '';\n return `${base}/${parts.segments.join('/')}${trailing}${parts.rest}`;\n}\n\n// which tree this page belongs to: a fact of the url, so it answers undefined instead of guessing\nexport function localeFromPath(options: LocaleFromPathOptions): string | undefined {\n const path = options.path ?? currentPath();\n if (path === undefined) return undefined;\n const segment = stripBase(path, normalizeBase(options.base)).split('/').find(Boolean);\n return segment ? matchPathSegment(segment, options.supported) : undefined;\n}\n\nexport interface StripLocalePathOptions {\n supported: string[];\n path?: string;\n base?: string;\n}\n\n// the canonical route behind a localized url: /es/docs → /docs, so a router matches one tree\nexport function stripLocalePath(options: StripLocalePathOptions): string {\n const full = options.path ?? currentPath(true) ?? '/';\n const base = normalizeBase(options.base);\n return joinLocalePath(base, splitLocalePath(full, options.supported, base));\n}\n\nexport interface AlternateLink {\n hreflang: string;\n href: string;\n}\n\nexport interface AlternateLinksOptions {\n supported: string[];\n sourceLocale: string;\n path: string;\n routing?: Routing;\n base?: string;\n baseUrl?: string;\n}\n\n// the reciprocal hreflang set for one page, the same one render writes, for a server that renders\nexport function alternateLinks(options: AlternateLinksOptions): AlternateLink[] {\n const { supported, sourceLocale, path, baseUrl = '' } = options;\n const routing = options.routing ?? 'prefix-except-source';\n\n // no-prefix means every locale answers on this url, and one href under many hreflangs is a lie\n if (routing === 'no-prefix') return [];\n\n // the union is what makes sourceLocale required exactly where it decides, so the call branches\n const base = options.base;\n const href = (locale: string): string =>\n baseUrl +\n localePath(\n locale,\n routing === 'prefix-all'\n ? { supported, routing, path, base }\n : { supported, routing, sourceLocale, path, base },\n );\n\n const links = supported.map((locale) => ({ hreflang: locale, href: href(locale) }));\n links.push({ hreflang: 'x-default', href: href(sourceLocale) });\n return links;\n}\n\nexport function resolveLocale(options: ResolveLocaleOptions): string {\n const { supported, fallback = supported[0] ?? 'en', storageKey = LOCALE_STORAGE_KEY } = options;\n\n // the document you are looking at wins: render put the page under that prefix already translated\n if (options.path !== false) {\n const match = localeFromPath({ supported, path: options.path, base: options.base });\n if (match) return match;\n }\n\n if (storageKey) {\n const stored = getStorage()?.getItem(storageKey);\n const match = stored && matchPreferred(stored, supported);\n if (match) return match;\n }\n\n for (const lang of preferredLanguages()) {\n const match = matchPreferred(lang, supported);\n if (match) return match;\n }\n\n return fallback;\n}\n\n// 'app', '/app' and '/app/' all read as '/app'; nothing means the site sits at the root\nfunction normalizeBase(base: string | undefined): string {\n const trimmed = base?.replace(/^\\/+/, '').replace(/\\/+$/, '');\n return trimmed ? `/${trimmed}` : '';\n}\n\n// the boundary check is what keeps base /app from swallowing /application\nfunction stripBase(path: string, base: string): string {\n if (!base || !path.startsWith(base)) return path;\n const rest = path.slice(base.length);\n if (rest === '') return '/';\n return rest.startsWith('/') ? rest : path;\n}\n\n// language, optional script, optional region: what render writes, never a slug like pt-and-friends\nconst LOCALE_SEGMENT = /^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|\\d{3}))?$/i;\n\n// a segment is narrowed only when it is shaped like a tag: a slug must never become a locale\nfunction matchPathSegment(segment: string, supported: string[]): string | undefined {\n if (supported.includes(segment)) return segment;\n return LOCALE_SEGMENT.test(segment) ? matchSupported(segment, supported) : undefined;\n}\n\n// exact, then progressive BCP-47 narrowing (zh-Hant-TW → zh-Hant → zh)\nfunction matchSupported(lang: string, supported: string[]): string | undefined {\n for (const candidate of narrowLocales(lang)) {\n if (supported.includes(candidate)) return candidate;\n }\n return undefined;\n}\n\n// server-side Accept-Language negotiation (q-values, case-insensitive, BCP-47 base)\nexport function negotiateLocale(\n header: string | null | undefined,\n supported: string[],\n fallback: string = supported[0] ?? 'en',\n): string {\n if (!header) return fallback;\n\n const ranges: { tag: string; q: number }[] = [];\n for (const part of header.split(',')) {\n const [rawTag, ...params] = part.trim().split(';');\n const tag = rawTag?.trim();\n if (!tag || tag === '*') continue;\n let q = 1;\n for (const param of params) {\n const [name, value] = param.split('=');\n if (name?.trim().toLowerCase() === 'q') {\n const parsed = Number(value?.trim());\n q = Number.isFinite(parsed) ? parsed : 1;\n }\n }\n if (q > 0) ranges.push({ tag, q });\n }\n // stable sort: ties keep header order\n ranges.sort((a, b) => b.q - a.q);\n\n for (const { tag } of ranges) {\n const match = matchPreferred(tag, supported);\n if (match) return match;\n }\n return fallback;\n}\n\n// a preference, not an address: what a reader of lang reads best (a url segment stays exact)\nfunction matchPreferred(lang: string, supported: string[]): string | undefined {\n const tags = narrowLocales(lang);\n const max = likely(lang);\n // zh-TW reads zh-Hant before a bare zh, and pt reads pt-BR: script and region, then the language\n const candidates = [...tags.slice(0, -1)];\n if (max) candidates.push(`${max.language}-${max.script}`, `${max.language}-${max.region}`);\n candidates.push(tags[tags.length - 1]!);\n for (const candidate of candidates) {\n // headers arrive as en-US and configs as en\n const match = supported.find((tag) => tag.toLowerCase() === candidate.toLowerCase());\n if (match) return match;\n }\n // a sibling in the same script: pt-PT reads pt-BR, and zh-HK never lands on zh-Hans\n return max\n ? supported.find((tag) => {\n const other = likely(tag);\n return other?.language === max.language && other.script === max.script;\n })\n : undefined;\n}\n\n// the subtags a tag implies (zh-HK is zh-Hant-HK, pt is pt-Latn-BR); none for a malformed tag\nfunction likely(tag: string): Intl.Locale | undefined {\n try {\n return new Intl.Locale(tag.replace(/_/g, '-')).maximize();\n } catch {\n return undefined;\n }\n}\n\n// per-request negotiation for SSR: url → cookie → Accept-Language → fallback\nexport interface RequestLocaleOptions {\n supported: string[];\n path?: string | null;\n routing?: Routing;\n base?: string;\n cookie?: string | null;\n header?: string | null;\n fallback?: string;\n}\n\nexport function resolveRequestLocale(options: RequestLocaleOptions): string {\n const { supported, path, routing, cookie, header, fallback = supported[0] ?? 'en' } = options;\n\n // an address is public, a cookie is one visitor: where the url carries the locale, it wins\n if (routing !== undefined && routing !== 'no-prefix' && path != null) {\n const match = localeFromPath({ supported, path, base: options.base });\n if (match) return match;\n // under prefix-except-source no prefix means the source tree, so negotiating would translate it\n if (routing === 'prefix-except-source') return fallback;\n }\n\n if (cookie) {\n // '' sentinel = no match → fall through to the header\n const match = negotiateLocale(cookie, supported, '');\n if (match) return match;\n }\n return negotiateLocale(header, supported, fallback);\n}\n\nexport interface SwitchLocaleOptions {\n cookie?: string | false;\n storageKey?: string | false;\n maxAge?: number;\n routing?: Routing;\n supported?: string[];\n sourceLocale?: string;\n base?: string;\n navigate?: (path: string) => void | Promise<void>;\n}\n\nconst YEAR = 31536000;\n\n// the whole switch, both modes: the url decides which half runs, never the caller\nexport async function switchLocale(\n instance: Pick<Verbaly, 'loadLocale' | 'setLocale'> & Partial<Pick<Verbaly, 'locales'>>,\n locale: string,\n options: SwitchLocaleOptions = {},\n): Promise<void> {\n const { cookie = LOCALE_STORAGE_KEY, maxAge = YEAR } = options;\n // one name for one choice: naming the cookie names the storage too, or the two drift in silence\n const storageKey = options.storageKey ?? (cookie === false ? LOCALE_STORAGE_KEY : cookie);\n // absent means the caller never asked for url behavior, as every caller before this one did\n const routed = options.routing !== undefined && options.routing !== 'no-prefix';\n\n // the destination document is already in the target language, so its catalog is not this page's\n if (!routed) {\n await instance.loadLocale(locale);\n instance.setLocale(locale);\n }\n\n if (typeof document === 'undefined') return; // SSR-safe no-op\n // both channels: a server reads the cookie, render's pre-paint script reads storage\n if (cookie) {\n document.cookie = `${cookie}=${encodeURIComponent(locale)}; path=/; max-age=${maxAge}; samesite=lax`;\n }\n persistLocale(locale, storageKey);\n\n if (!routed) return;\n const target = localePath(locale, {\n // the current segment has to be known to be stripped: /pt/docs must not become /es/pt/docs\n supported: options.supported ?? instance.locales ?? [locale],\n sourceLocale: options.sourceLocale,\n base: options.base,\n routing: options.routing,\n } as LocalePathOptions);\n await (options.navigate ?? assign)(target);\n}\n\n// a full load is the floor, not the goal: a framework passes its own router and keeps the app alive\nfunction assign(path: string): void {\n if (typeof location !== 'undefined') location.assign(path);\n}\n\nexport function persistLocale(\n locale: string,\n storageKey: string | false = LOCALE_STORAGE_KEY,\n): void {\n try {\n if (storageKey) getStorage()?.setItem(storageKey, locale);\n } catch {\n // a full storage throws on write, and a switch must still reach <html lang> and the navigation\n }\n if (typeof document !== 'undefined') {\n document.documentElement.lang = locale;\n document.documentElement.dir = localeDirection(locale);\n }\n}\n\nfunction currentPath(full?: boolean): string | undefined {\n // require document like every other browser check: a server has no page to read a prefix from\n return typeof document !== 'undefined' && typeof location !== 'undefined'\n ? location.pathname + (full ? location.search + location.hash : '')\n : undefined;\n}\n\nfunction preferredLanguages(): readonly string[] {\n // require document: Node 21+ has a global navigator whose language is the OS, not a user\n if (typeof document === 'undefined' || typeof navigator === 'undefined') return [];\n return navigator.languages?.length ? navigator.languages : [navigator.language];\n}\n\nfunction getStorage(): Storage | null {\n try {\n return typeof localStorage === 'undefined' ? null : localStorage;\n } catch {\n return null; // blocked storage (privacy mode)\n }\n}\n","import type { MessageNode, ParamNode } from './parse';\n\n// ICU escape-hatch → native MessageNode AST\n\n// a brace right after a brace is an escaped {{, not ICU; no lookbehind, Safari 16.3 cannot parse it\nconst ICU_ARG =\n /(^|[^{])\\{\\s*[a-zA-Z0-9_]+\\s*,\\s*(?:plural|selectordinal|select|number|date|time)\\b/;\n\nexport function isIcu(message: string): boolean {\n return ICU_ARG.test(message);\n}\n\nexport function parseIcu(message: string): MessageNode[] {\n let i = 0;\n const at = (): string => message.charAt(i);\n const skipWs = (): void => {\n while (i < message.length && /\\s/.test(at())) i++;\n };\n const readIdent = (): string => {\n let s = '';\n while (i < message.length && /[a-zA-Z0-9_]/.test(at())) s += message[i++];\n return s;\n };\n\n function parseBody(inPlural: boolean): MessageNode[] {\n const nodes: MessageNode[] = [];\n let buf = '';\n const flush = (): void => {\n if (buf) nodes.push({ kind: 'text', value: buf });\n buf = '';\n };\n while (i < message.length) {\n const ch = at();\n if (ch === '}') break;\n if (ch === '{') {\n flush();\n nodes.push(parseArg());\n } else if (ch === '#' && inPlural) {\n flush();\n nodes.push({ kind: 'hash' });\n i++;\n } else if (ch === \"'\") {\n buf += readQuoted();\n } else {\n buf += ch;\n i++;\n }\n }\n flush();\n return nodes;\n }\n\n // ICU apostrophe quoting\n function readQuoted(): string {\n i++; // opening '\n if (at() === \"'\") {\n i++;\n return \"'\";\n }\n const next = at();\n if (next !== '{' && next !== '}' && next !== '#') return \"'\"; // lone apostrophe\n let out = '';\n while (i < message.length) {\n if (at() === \"'\") {\n if (message.charAt(i + 1) === \"'\") {\n out += \"'\";\n i += 2;\n continue;\n }\n i++; // closing '\n return out;\n }\n out += message[i++];\n }\n return out; // unterminated\n }\n\n function parseArg(): MessageNode {\n i++; // {\n skipWs();\n const name = readIdent();\n skipWs();\n if (at() === '}') {\n i++;\n return { kind: 'param', name };\n }\n if (at() === ',') i++;\n skipWs();\n const type = readIdent();\n const node: ParamNode = { kind: 'param', name };\n\n if (type === 'number' || type === 'date' || type === 'time') {\n skipWs();\n let style = '';\n if (at() === ',') {\n i++;\n skipWs();\n while (i < message.length && at() !== '}' && at() !== ',') style += message[i++];\n style = style.trim();\n }\n if (type === 'number') {\n node.format =\n style === 'integer' || style === 'percent' || style === 'currency' ? style : 'number';\n } else {\n node.format = type;\n if (style) node.arg = style;\n }\n skipToClose();\n return node;\n }\n\n if (type === 'plural' || type === 'selectordinal' || type === 'select') {\n if (type === 'selectordinal') node.ordinal = true;\n const variants: [string, MessageNode[]][] = [];\n skipWs();\n if (at() === ',') i++; // comma after the keyword\n skipWs();\n if (type !== 'select' && message.startsWith('offset:', i)) {\n i += 7;\n skipWs();\n while (i < message.length && /[0-9]/.test(at())) i++; // offset parsed, not applied (v1)\n skipWs();\n }\n while (i < message.length && at() !== '}') {\n const selector = readSelector();\n skipWs();\n if (at() !== '{') break;\n i++; // {\n const body = parseBody(type !== 'select');\n if (at() === '}') i++;\n variants.push([selector, body]);\n skipWs();\n }\n if (at() === '}') i++;\n node.variants = variants;\n return node;\n }\n\n // unknown type → simple param\n skipToClose();\n return node;\n }\n\n function readSelector(): string {\n if (at() === '=') {\n let s = '=';\n i++;\n while (i < message.length && /[0-9]/.test(at())) s += message[i++];\n return s;\n }\n let s = '';\n while (i < message.length && !/[\\s{]/.test(at())) s += message[i++];\n return s;\n }\n\n function skipToClose(): void {\n while (i < message.length && at() !== '}') i++;\n if (at() === '}') i++;\n }\n\n return parseBody(false);\n}\n","import { isIcu } from './icu';\nimport { warnOnce } from './warn';\n\nexport type MessageNode = { kind: 'text'; value: string } | { kind: 'hash' } | ParamNode;\n\nexport interface ParamNode {\n kind: 'param';\n name: string;\n format?: string;\n arg?: string;\n ordinal?: boolean;\n variants?: [string, MessageNode[]][];\n}\n\nconst astCache = new Map<string, MessageNode[]>();\nconst AST_CACHE_MAX = 5000; // dynamic/CMS messages can't grow it unbounded\n// one live iterator, and the drop below the only delete: a new one walks every hole at the front\nconst oldest = astCache.keys();\n\n// ICU is the escape hatch, so its parser is a passenger the app opts into rather than always ships\nexport type IcuParser = (message: string) => MessageNode[];\n\nexport function parse(message: string, icu?: IcuParser): MessageNode[] {\n let cached = astCache.get(message);\n if (!cached) {\n if (isIcu(message)) {\n // an unparsed ICU message is not cached: the app is misconfigured, not settled\n if (!icu) return unparsedIcu(message);\n cached = icu(message);\n } else {\n cached = parseMessage(message, false);\n }\n // drop the oldest, never the whole map: clearing threw away the hot set on every overflow\n if (astCache.size >= AST_CACHE_MAX) astCache.delete(oldest.next().value as string);\n astCache.set(message, cached);\n }\n return cached;\n}\n\n// visible and named, never a plausible-looking wrong render: the source shows and the warn says why\nfunction unparsedIcu(message: string): MessageNode[] {\n warnOnce(\n 'a message uses ICU syntax and no ICU parser is loaded: set icu: true in your verbaly ' +\n 'config, or pass icu to createVerbaly',\n );\n return [{ kind: 'text', value: message }];\n}\n\nfunction parseMessage(input: string, inVariant: boolean): MessageNode[] {\n const nodes: MessageNode[] = [];\n let buf = '';\n let i = 0;\n\n const flush = () => {\n if (buf) nodes.push({ kind: 'text', value: buf });\n buf = '';\n };\n\n while (i < input.length) {\n const ch = input[i];\n if (ch === '{') {\n if (input[i + 1] === '{') {\n buf += '{';\n i += 2;\n continue;\n }\n const close = findClose(input, i);\n if (close < 0) {\n buf += input.slice(i);\n break;\n }\n flush();\n nodes.push(parsePlaceholder(input.slice(i + 1, close)));\n i = close + 1;\n } else if (ch === '}' && input[i + 1] === '}') {\n buf += '}';\n i += 2;\n } else if (inVariant && ch === '#') {\n if (input[i + 1] === '#') {\n buf += '#';\n i += 2;\n } else {\n flush();\n nodes.push({ kind: 'hash' });\n i += 1;\n }\n } else {\n buf += ch;\n i += 1;\n }\n }\n flush();\n return nodes;\n}\n\n// how the last findClose read }}: splitTop runs on that block right after and reads it alike\nlet closedPairs: boolean | undefined;\n\n// }} is an escape unless that leaves the block open; then it closes both where two are open\nfunction findClose(input: string, open: number, pairs?: boolean): number {\n closedPairs = pairs;\n let depth = 0;\n let i = open;\n while (i < input.length) {\n const ch = input[i];\n if (ch === '{') {\n if (input[i + 1] === '{') {\n i += 2;\n continue;\n }\n depth += 1;\n } else if (ch === '}') {\n if (input[i + 1] === '}' && !(pairs && depth > 1)) {\n i += 2;\n continue;\n }\n depth -= 1;\n if (depth === 0) return i;\n }\n i += 1;\n }\n return pairs ? -1 : findClose(input, open, true);\n}\n\nfunction parsePlaceholder(inner: string): MessageNode {\n const segments = splitTop(inner);\n const head = (segments[0] ?? '').trim();\n if (!head) return { kind: 'text', value: `{${inner}}` };\n\n const colon = head.indexOf(':');\n const name = (colon < 0 ? head : head.slice(0, colon)).trim();\n if (!name) return { kind: 'text', value: `{${inner}}` };\n\n const node: ParamNode = { kind: 'param', name };\n\n if (colon >= 0) {\n const fmtRaw = head.slice(colon + 1).trim();\n const slash = fmtRaw.indexOf('/');\n node.format = (slash < 0 ? fmtRaw : fmtRaw.slice(0, slash)).trim();\n if (slash >= 0) node.arg = fmtRaw.slice(slash + 1).trim();\n }\n\n if (segments.length > 1) {\n node.variants = [];\n for (const seg of segments.slice(1)) {\n const sep = seg.indexOf(':');\n if (sep < 0) continue;\n const key = seg.slice(0, sep).trim();\n const body = seg.slice(sep + 1).trim();\n if (key) node.variants.push([key, parseMessage(body, true)]);\n }\n }\n return node;\n}\n\nfunction splitTop(input: string): string[] {\n const parts: string[] = [];\n let buf = '';\n let depth = 0;\n let i = 0;\n while (i < input.length) {\n const ch = input[i];\n if (ch === '{') {\n if (input[i + 1] === '{') {\n buf += '{{';\n i += 2;\n continue;\n }\n depth += 1;\n buf += ch;\n } else if (ch === '}') {\n if (input[i + 1] === '}' && !(closedPairs && depth > 0)) {\n buf += '}}';\n i += 2;\n continue;\n }\n depth -= 1;\n buf += ch;\n } else if (ch === '|' && depth === 0) {\n if (input[i + 1] === '|') {\n buf += '|';\n i += 2;\n continue;\n }\n parts.push(buf);\n buf = '';\n } else {\n buf += ch;\n }\n i += 1;\n }\n parts.push(buf);\n return parts;\n}\n","import { flatten } from './flatten';\nimport { autoFormat, formatNodes, usable } from './format';\nimport { narrowLocales } from './locale';\nimport { parse } from './parse';\nimport { warnOnce } from './warn';\nimport type {\n AddMessagesOptions,\n DictionaryInput,\n Formatter,\n LocaleLoader,\n MessageTree,\n Params,\n TFunction,\n Verbaly,\n VerbalyOptions,\n} from './types';\n\nexport function createVerbaly<const D extends DictionaryInput = DictionaryInput>(\n options: VerbalyOptions<D> = {},\n): Verbaly<D> {\n // no prototype, so a name like toString is a miss; setPrototypeOf keeps them fast objects\n const dict: Record<string, Record<string, string>> = Object.setPrototypeOf({}, null);\n const listeners = new Set<() => void>();\n const formatters: Record<string, Formatter> = Object.assign(\n Object.setPrototypeOf({}, null),\n options.formatters,\n );\n const loaders: Record<string, LocaleLoader> = Object.assign(\n Object.setPrototypeOf({}, null),\n options.loaders,\n );\n const loaded = new Set<string>();\n const inFlight = new Map<string, Promise<void>>();\n const fallbacks = options.fallback\n ? Array.isArray(options.fallback)\n ? options.fallback\n : [options.fallback]\n : [];\n\n let locale = options.locale ?? detectLocale();\n let version = 0;\n let chainCache: string[] | null = null;\n\n if (options.messages) {\n for (const [loc, tree] of Object.entries(options.messages)) {\n dict[loc] = flatten(tree);\n }\n }\n\n // a page carrying its own slice must not also fetch the catalog it already has enough of\n const partial = new Set(options.partial ?? []);\n for (const loc of partial) loaded.add(loc);\n\n function chain(): string[] {\n if (chainCache) return chainCache;\n const result = narrowLocales(locale);\n for (const fb of fallbacks) if (!result.includes(fb)) result.push(fb);\n chainCache = result;\n return result;\n }\n\n function lookup(key: string): { msg: string; from: string } | undefined {\n for (const loc of chain()) {\n const msg = dict[loc]?.[key];\n // '' = untranslated (extract scaffolds it) → keep falling back\n if (msg) return { msg, from: loc };\n }\n return undefined;\n }\n\n function translate(key: string, params: Params | undefined): string {\n const hit = lookup(key);\n // a fallback hides a short slice: the source catalog answers for a key the page never got\n if (partial.size > 0 && (hit === undefined || !partial.has(hit.from))) completePartial(key);\n if (hit === undefined) {\n const replacement = options.onMissing?.(key, locale);\n const value = typeof replacement === 'string' ? replacement : key;\n if (typeof replacement !== 'string' && !options.onMissing) {\n warnOnce(`missing key \"${key}\" (${locale})`);\n }\n options.onResolve?.({ key, locale, value, status: 'miss' });\n return value;\n }\n const value = formatNodes(parse(hit.msg, options.icu), { locale, params, formatters, key });\n options.onResolve?.({\n key,\n locale,\n value,\n status: hit.from === locale ? 'hit' : 'fallback',\n from: hit.from,\n });\n return value;\n }\n\n function tagged(strings: TemplateStringsArray, values: unknown[]): string {\n let out = strings[0] ?? '';\n for (let i = 0; i < values.length; i++) {\n out += autoFormat(usable(values[i]), locale) + (strings[i + 1] ?? '');\n }\n return out;\n }\n\n function notify(): void {\n version += 1;\n for (const fn of listeners) fn();\n }\n\n autoLoad(locale);\n\n const t = ((first: unknown, ...rest: unknown[]): string => {\n if (isTemplateStrings(first)) return tagged(first, rest);\n return translate(first as string, rest[0] as Params | undefined);\n }) as TFunction<D>;\n\n t.id =\n () =>\n (strings: TemplateStringsArray, ...values: unknown[]) =>\n tagged(strings, values);\n\n // fire and forget: the UI re-renders when it lands, and a failure reports instead of rejecting\n function autoLoad(target: string): void {\n void loadLocale(target).catch(() => {\n warnOnce(`failed to load catalog for \"${target}\"`);\n });\n }\n\n // the slice lacked it, so the full catalog is worth fetching: once per locale, then repaint\n function completePartial(key: string): void {\n for (const candidate of chain()) {\n if (!partial.has(candidate)) continue;\n // '' is an answer: the slice carried the key and this locale simply has no message for it\n if (dict[candidate]?.[key] !== undefined) return;\n partial.delete(candidate);\n loaded.delete(candidate);\n autoLoad(candidate);\n return;\n }\n }\n\n function pendingLoader(target: string): string | undefined {\n for (const candidate of narrowLocales(target)) {\n if (loaders[candidate]) return loaded.has(candidate) ? undefined : candidate;\n }\n return undefined;\n }\n\n function loadLocale(target: string): Promise<void> {\n const pending = pendingLoader(target);\n if (!pending) return Promise.resolve();\n const running = inFlight.get(pending);\n if (running) return running;\n const load = loaders[pending]!()\n .then((mod) => {\n loaded.add(pending);\n inFlight.delete(pending);\n addMessages(\n pending,\n 'default' in mod ? (mod.default as MessageTree) : (mod as MessageTree),\n );\n })\n .catch((error: unknown) => {\n inFlight.delete(pending);\n throw error;\n });\n inFlight.set(pending, load);\n return load;\n }\n\n function addMessages(loc: string, messages: MessageTree, opts?: AddMessagesOptions): void {\n // a slice is not the catalog, so the locale stays incomplete and never demotes a loaded one\n if (opts?.partial && !loaded.has(loc) && !inFlight.has(loc)) {\n partial.add(loc);\n loaded.add(loc);\n }\n // a spread would hand the merge Object.prototype back, and toString would answer as a message\n dict[loc] = Object.assign(Object.create(null), dict[loc], flatten(messages));\n notify();\n }\n\n return {\n get locale() {\n return locale;\n },\n get locales() {\n return [...new Set([...Object.keys(dict), ...Object.keys(loaders)])];\n },\n get version() {\n return version;\n },\n // the generic is still open in here, so the conditional type cannot pick a side yet\n t: t as Verbaly<D>['t'],\n setLocale(next: string) {\n autoLoad(next);\n if (next === locale) return;\n locale = next;\n chainCache = null;\n notify();\n },\n loadLocale,\n addMessages,\n subscribe(listener: () => void) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n has(key: string) {\n return lookup(key) !== undefined;\n },\n inspect(key: string) {\n const hit = lookup(key);\n return hit ? { from: hit.from, source: hit.msg } : undefined;\n },\n };\n}\n\nfunction isTemplateStrings(value: unknown): value is TemplateStringsArray {\n return Array.isArray(value) && 'raw' in value;\n}\n\nfunction detectLocale(): string {\n // gate on document, not navigator: Node 21+ exposes a global navigator (OS locale)\n return typeof document !== 'undefined' && typeof navigator !== 'undefined' && navigator.language\n ? navigator.language\n : 'en';\n}\n","// Named-tag tokenizer for <Trans>\nexport type TagNode = string | { name: string; children: TagNode[] };\n\nconst TAG = /<(\\/?)([a-zA-Z][\\w-]*)\\s*(\\/?)>/g;\n// the void tags a message renders; <link> stays a name for a link, so it still pairs\nconst BREAK = /^(?:br|wbr)$/;\n\n// text runs only, post-tokenize: decoded braces/angles never re-enter a parser\nconst ENTITY = /&(?:(lt|gt|amp)|#(\\d+)|#[xX]([0-9a-fA-F]+));/g;\nconst ENTITY_MAP: Record<string, string> = { lt: '<', gt: '>', amp: '&' };\nconst decodeEntities = (s: string): string =>\n s.replace(ENTITY, (full, name?: string, dec?: string, hex?: string) => {\n if (name) return ENTITY_MAP[name]!;\n const code = dec ? parseInt(dec, 10) : parseInt(hex!, 16);\n return code <= 0x10ffff ? String.fromCodePoint(code) : full;\n });\n\nexport function parseTags(text: string): TagNode[] {\n TAG.lastIndex = 0;\n const root: TagNode[] = [];\n const stack: { name: string; children: TagNode[] }[] = [];\n const top = (): TagNode[] => (stack.length ? stack[stack.length - 1]!.children : root);\n const pushText = (s: string): void => {\n if (s) top().push(decodeEntities(s));\n };\n\n let last = 0;\n let m: RegExpExecArray | null;\n while ((m = TAG.exec(text)) !== null) {\n const [full, closing, name, selfClose] = m;\n pushText(text.slice(last, m.index));\n last = m.index + full.length;\n\n // a break is whole on its own: <br>, <br/> and <br /> are one break, and </br> adds none\n if (selfClose || BREAK.test(name!)) {\n if (!closing) top().push({ name: name!, children: [] });\n } else if (closing) {\n if (stack.length && stack[stack.length - 1]!.name === name) {\n const node = stack.pop()!;\n top().push(node);\n } else {\n pushText(full); // stray closing tag → literal\n }\n } else {\n stack.push({ name: name!, children: [] });\n }\n }\n pushText(text.slice(last));\n\n // unclosed opens: drop wrapper\n while (stack.length) {\n const node = stack.pop()!;\n top().push(...node.children);\n }\n return root;\n}\n","import { narrowLocales } from './locale';\nimport { parseTags, type TagNode } from './tags';\nimport type { DictionaryInput, Params, Verbaly } from './types';\nimport { warnOnce } from './warn';\n\n// hrefs come from the caller, never from messages\nexport type RichLink = string | { href: string; target?: string; rel?: string };\n\nexport interface BindDomOptions {\n root?: ParentNode;\n attribute?: string;\n richTags?: string[];\n richLinks?: Record<string, RichLink>;\n}\n\n// eslint-disable-next-line no-control-regex\nconst UNSAFE_HREF = /^[\\u0000-\\u0020]*(javascript|data|vbscript):/i;\nconst URL_ATTR = /^(href|src|xlink:href|action|formaction)$/;\nconst BLOCKED_ATTR = /^(style|srcdoc)$/;\n// a browser drops tab, LF and CR anywhere in a url and trims leading C0 before reading the scheme\nconst URL_NOISE = /[\\t\\n\\r]/g;\n\nexport function safeHref(href: string): string | undefined {\n const unsafe = UNSAFE_HREF.exec(href.replace(URL_NOISE, ''));\n if (unsafe) {\n // the scheme and never the href: warnOnce dedupes on its text and a catalog value is unbounded\n warnOnce(`blocked an unsafe href, it resolves to \"${unsafe[1]!.toLowerCase()}:\"`);\n return undefined;\n }\n return href;\n}\n\n// one link normalization for core + every adapter (applies safeHref)\nexport function normalizeLink(link: RichLink): { href?: string; target?: string; rel?: string } {\n const { href, target, rel } = typeof link === 'string' ? { href: link } : link;\n return { href: safeHref(href), target, rel };\n}\n\n// one attribute guard for bindDom + render, a catalog is untrusted input: undefined = skip\nexport function safeAttribute(name: string, value: string): string | undefined {\n const lower = name.toLowerCase();\n if (lower.startsWith('on') || BLOCKED_ATTR.test(lower)) return undefined;\n if (URL_ATTR.test(lower)) return safeHref(value);\n return value;\n}\n\n// children never reach a void element: a browser parses <br></br> as two <br>, hydration as one\nexport const VOID_TAGS = [\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n];\n\n// phrasing-only, attribute-less → XSS-safe\nexport const RICH_TAGS = [\n 'em',\n 'strong',\n 'code',\n 'b',\n 'i',\n 'u',\n 's',\n 'small',\n 'mark',\n 'sub',\n 'sup',\n 'span',\n 'kbd',\n 'abbr',\n 'br',\n 'wbr',\n];\n\nexport const CATALOG_SCRIPT = 'data-verbaly-catalog';\n\n// the slice `verbaly render` inlined here, so a mirrored page needs no catalog over the network\nexport function inlineMessages(root?: ParentNode): Record<string, string> | undefined {\n const scope = root ?? (typeof document === 'undefined' ? undefined : document);\n if (!scope) return undefined;\n const node = scope.querySelector(`script[${CATALOG_SCRIPT}]`);\n if (!node?.textContent) return undefined;\n try {\n const parsed: unknown = JSON.parse(node.textContent);\n if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {\n return parsed as Record<string, string>;\n }\n } catch {\n // one message for both breakages: the remedy is the same, fix the blob or drop it\n }\n warnOnce('inline catalog is not a usable object, so the page loads its locale instead');\n return undefined;\n}\n\nexport function bindDom<D extends DictionaryInput>(\n instance: Verbaly<D>,\n options: BindDomOptions = {},\n): () => void {\n if (typeof document === 'undefined') {\n throw new Error('[verbaly] bindDom requires a DOM');\n }\n const t = instance.t as unknown as (key: string, params?: Params) => string;\n const root = options.root ?? document.body;\n const attr = options.attribute ?? 'data-verbaly';\n const argsAttr = `${attr}-args`;\n const attrsAttr = `${attr}-attr`;\n const richAttr = `${attr}-rich`;\n const linksAttr = `${attr}-links`;\n const richTags = new Set(options.richTags ?? RICH_TAGS);\n\n // null prototype: a tag named constructor in a message is unknown, never Object's own function\n const globalLinks: Record<string, RichLink> | undefined =\n options.richLinks && Object.assign(Object.create(null), options.richLinks);\n const argsCache = new WeakMap<Element, { raw: string | null; value: Params | undefined }>();\n const linksCache = new WeakMap<\n Element,\n { raw: string | null; value: Record<string, RichLink> | undefined }\n >();\n const attrsCache = new WeakMap<Element, { raw: string | null; value: Params | undefined }>();\n\n function fromCache<T>(\n cache: WeakMap<Element, { raw: string | null; value: T }>,\n el: Element,\n raw: string | null,\n compute: () => T,\n ): T {\n const hit = cache.get(el);\n if (hit && hit.raw === raw) return hit.value;\n const value = compute();\n cache.set(el, { raw, value });\n return value;\n }\n\n function cachedArgs(el: Element): Params | undefined {\n const raw = el.getAttribute(argsAttr);\n return fromCache(argsCache, el, raw, () => parseArgs(raw));\n }\n\n function cachedLinks(el: Element): Record<string, RichLink> | undefined {\n const raw = el.getAttribute(linksAttr);\n if (!raw) return globalLinks;\n return fromCache(linksCache, el, raw, () => {\n const own = parseArgs(raw) as Record<string, RichLink> | undefined;\n return own ? Object.assign(Object.create(null), globalLinks, own) : globalLinks;\n });\n }\n\n function renderRich(\n el: Element,\n nodes: TagNode[],\n links: Record<string, RichLink> | undefined,\n ): void {\n for (const node of nodes) {\n if (typeof node === 'string') {\n el.append(node);\n continue;\n }\n const link = links?.[node.name];\n if (link !== undefined) {\n const { href, target, rel } = normalizeLink(link);\n const a = el.ownerDocument.createElement('a');\n if (href !== undefined) a.setAttribute('href', href);\n if (target) a.setAttribute('target', target);\n if (rel) a.setAttribute('rel', rel);\n renderRich(a, node.children, links);\n el.append(a);\n } else if (richTags.has(node.name)) {\n const child = el.ownerDocument.createElement(node.name);\n if (!VOID_TAGS.includes(node.name)) renderRich(child, node.children, links);\n el.append(child);\n } else {\n renderRich(el, node.children, links); // unknown tag → unwrap\n }\n }\n }\n\n // one sample per bind: a build-only group is a normal setup and it can hold hundreds of keys\n let reportedKept = false;\n\n // trusted = text this bind never wrote (server render, router swap): only this locale beats it\n function holdBack(key: string, current: string | null, trusted: boolean): boolean {\n if (!current?.trim()) return false;\n const hit = instance.inspect(key);\n // resolves nowhere: the raw key is never an improvement on the text the node already carries\n if (!hit) {\n if (!reportedKept) {\n reportedKept = true;\n warnOnce(`kept the pre-rendered text where no catalog has the key, first: \"${key}\"`);\n }\n return true;\n }\n return trusted && hit.from !== instance.locale;\n }\n\n function render(el: Element, trusted: boolean): void {\n const args = cachedArgs(el);\n const key = el.getAttribute(attr);\n if (key && !holdBack(key, el.textContent, trusted)) {\n const text = t(key, args);\n if (el.hasAttribute(richAttr)) {\n el.textContent = '';\n renderRich(el, parseTags(text), cachedLinks(el));\n } else {\n el.textContent = text;\n }\n }\n\n const rawAttrs = el.getAttribute(attrsAttr);\n const attrMap = fromCache(attrsCache, el, rawAttrs, () => parseArgs(rawAttrs));\n if (attrMap) {\n for (const [name, attrKey] of Object.entries(attrMap)) {\n if (typeof attrKey !== 'string') continue;\n if (holdBack(attrKey, el.getAttribute(name), trusted)) continue;\n const value = safeAttribute(name, t(attrKey, args));\n if (value !== undefined) el.setAttribute(name, value);\n }\n }\n }\n\n const selector = `[${attr}], [${attrsAttr}]`;\n\n function renderAll(scope: ParentNode | Element, trusted: boolean): void {\n if (scope instanceof Element && scope.matches(selector)) render(scope, trusted);\n for (const el of scope.querySelectorAll(selector)) render(el, trusted);\n }\n\n warnOnLangMismatch(instance.locale);\n warnOnUnboundHead(root, selector);\n renderAll(root, true);\n // the catalog moved, so the whole dom is ours: a stale locale must not survive a switch\n const unsubscribe = instance.subscribe(() => renderAll(root, false));\n\n const observer = new MutationObserver((records) => {\n for (const record of records) {\n if (record.type === 'attributes' && record.target instanceof Element) {\n render(record.target, false);\n } else if (record.type === 'childList') {\n // a node arrives carrying text someone else wrote, same standing as the first paint\n for (const node of record.addedNodes) {\n if (node instanceof Element) renderAll(node, true);\n }\n }\n }\n });\n\n observer.observe(root instanceof Document ? root.documentElement : (root as Node), {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [attr, argsAttr, attrsAttr, richAttr, linksAttr],\n });\n\n return () => {\n unsubscribe();\n observer.disconnect();\n };\n}\n\n// the head is the half a search result shows, and the default body root never reaches it\nfunction warnOnUnboundHead(root: ParentNode, selector: string): void {\n if (root === document || root === document.documentElement) return;\n if (!document.head?.querySelector(selector)) return;\n warnOnce('the <head> has bound elements this root never reaches: pass { root: document }');\n}\n\n// render writes <html lang>, so a disagreement here means the page is about to be translated away\nfunction warnOnLangMismatch(locale: string): void {\n const lang = document.documentElement.lang;\n if (!lang || narrowLocales(lang).includes(locale) || narrowLocales(locale).includes(lang)) return;\n warnOnce(\n `the page is <html lang=\"${lang}\"> and this instance is in \"${locale}\": read the url with ` +\n `localeFromPath, or call persistLocale first`,\n );\n}\n\nfunction parseArgs(raw: string | null): Params | undefined {\n if (!raw) return undefined;\n try {\n return JSON.parse(raw) as Params;\n } catch {\n // the value stays out: the dedupe set is unbounded, and an attribute can be built at runtime\n warnOnce('invalid args JSON');\n return undefined;\n }\n}\n","import { relativeTimeFormat } from './intl';\nimport type { Formatter } from './types';\nimport { warnOnce } from './warn';\n\n// seconds per unit, largest first (auto pick)\nconst REL_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 31536000],\n ['month', 2592000],\n ['week', 604800],\n ['day', 86400],\n ['hour', 3600],\n ['minute', 60],\n ['second', 1],\n];\n\n// the type and never the value (the warn set must stay bounded); only number|Date reaches here\nfunction describe(value: unknown): string {\n if (!(value instanceof Date)) return `a ${typeof value}`;\n return Number.isNaN(value.getTime()) ? 'an invalid Date' : 'a Date';\n}\n\n// the one format that ships only where a message asks for it: it is 318 B and most apps never do\nexport const relativeFormatter: Formatter = (value, locale, arg, info) => {\n const where = info?.key ? ` in \"${info.key}\"` : '';\n const degrade = (problem: string): string => {\n warnOnce(`{${info?.param ?? '…'}:relative}${where} ${problem}`);\n return String(value);\n };\n\n if (typeof value === 'number' && !arg) return degrade('needs an argument like /day');\n if (typeof value !== 'number' && !(value instanceof Date)) {\n return degrade('needs a number or a Date');\n }\n\n try {\n const fmt = relativeTimeFormat(locale);\n if (typeof value === 'number') return fmt.format(value, arg as Intl.RelativeTimeFormatUnit);\n const diffSec = (value.getTime() - Date.now()) / 1000;\n if (arg) {\n const per = REL_UNITS.find(([unit]) => unit === arg)?.[1];\n if (!per) throw new RangeError(arg);\n return fmt.format(Math.round(diffSec / per), arg as Intl.RelativeTimeFormatUnit);\n }\n const [unit, per] = REL_UNITS.find(([, s]) => Math.abs(diffSec) >= s) ?? ['second', 1];\n return fmt.format(Math.round(diffSec / per), unit);\n } catch {\n // an invalid Date lands here too, so the warn names both suspects instead of blaming the unit\n return degrade(`cannot format ${describe(value)} as \"${arg}\"`);\n }\n};\n"],"m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OAAO;CACjD,OAAO,OAAO,MAAM,MAAM,QAAQ,CAAC,IAAI,oBAAoB;AAC7D;AAGA,MAAa,qBAAgC,OAAO,QAAQ,KAAK,SAAS;CACxE,MAAM,QAAQ,MAAM,MAAM,QAAQ,KAAK,IAAI,KAAK;CAChD,MAAM,WAAW,YAA4B;EAC3C,SAAS,IAAI,MAAM,SAAS,IAAI,YAAY,MAAM,GAAG,SAAS;EAC9D,OAAO,OAAO,KAAK;CACrB;CAEA,IAAI,OAAO,UAAU,YAAY,CAAC,KAAK,OAAO,QAAQ,6BAA6B;CACnF,IAAI,OAAO,UAAU,YAAY,EAAE,iBAAiB,OAClD,OAAO,QAAQ,0BAA0B;CAG3C,IAAI;EACF,MAAM,MAAM,mBAAmB,MAAM;EACrC,IAAI,OAAO,UAAU,UAAU,OAAO,IAAI,OAAO,OAAO,GAAkC;EAC1F,MAAM,WAAW,MAAM,QAAQ,IAAI,KAAK,IAAI,KAAK;EACjD,IAAI,KAAK;GACP,MAAM,MAAM,UAAU,MAAM,CAAC,UAAU,SAAS,GAAG,CAAC,GAAG;GACvD,IAAI,CAAC,KAAK,MAAM,IAAI,WAAW,GAAG;GAClC,OAAO,IAAI,OAAO,KAAK,MAAM,UAAU,GAAG,GAAG,GAAkC;EACjF;EACA,MAAM,CAAC,MAAM,OAAO,UAAU,MAAM,GAAG,OAAO,KAAK,IAAI,OAAO,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC;EACrF,OAAO,IAAI,OAAO,KAAK,MAAM,UAAU,GAAG,GAAG,IAAI;CACnD,QAAQ;EAEN,OAAO,QAAQ,iBAAiB,SAAS,KAAK,EAAE,OAAO,IAAI,EAAE;CAC/D;AACF"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["describe"],"sources":["../src/warn.ts","../src/flatten.ts","../src/intl.ts","../src/format.ts","../src/locale.ts","../src/icu.ts","../src/parse.ts","../src/instance.ts","../src/tags.ts","../src/dom.ts","../src/relative.ts"],"sourcesContent":["// one warn-once for the whole runtime: the set is unbounded, so a message never carries a value\nconst warned = new Set<string>();\n\nexport function warnOnce(message: string): void {\n if (warned.has(message)) return;\n warned.add(message);\n console.warn(`[verbaly] ${message}`);\n}\n","import type { MessageTree } from './types';\nimport { warnOnce } from './warn';\n\n// null-prototype: lookup reads dict[loc][key], and a plain object answers toString\nexport function flatten(\n tree: MessageTree,\n prefix = '',\n out: Record<string, string> = Object.create(null) as Record<string, string>,\n): Record<string, string> {\n // a catalog is untrusted input: a lazy loader, addMessages or a CMS never crosses the build gate\n if (!isGroup(tree)) return out;\n for (const [key, value] of Object.entries(tree)) {\n const path = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'string') out[path] = value;\n else if (isGroup(value)) flatten(value, path, out);\n else warnOnce(`catalog value at \"${path}\" is not text, so the key renders as itself`);\n }\n return out;\n}\n\nfunction isGroup(value: unknown): value is MessageTree {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n","import { warnOnce } from './warn';\n\nconst CACHE_CAP = 200; // dynamic locales/options can't grow unbounded\n\nconst nfCache = new Map<string, Intl.NumberFormat>();\nconst dtfCache = new Map<string, Intl.DateTimeFormat>();\nconst prCache = new Map<string, Intl.PluralRules>();\nconst rtfCache = new Map<string, Intl.RelativeTimeFormat>();\nconst lfCache = new Map<string, Intl.ListFormat>();\nconst dnCache = new Map<string, Intl.DisplayNames>();\n\nfunction cached<T>(\n cache: Map<string, T>,\n key: string,\n locale: string,\n make: (tag?: string) => T,\n): T {\n let hit = cache.get(key);\n if (!hit) {\n if (cache.size >= CACHE_CAP) cache.delete(cache.keys().next().value as string);\n try {\n hit = make(locale);\n } catch {\n // a bad option throws on every retry, so only a tag Intl cannot read ever reaches the warn\n let tag: string | undefined = locale.replace(/_/g, '-');\n try {\n hit = make(tag);\n } catch {\n hit = make((tag = undefined));\n }\n warnOnce(\n `\"${locale}\" is not a locale tag, so Intl reads it as ${tag ?? 'its default locale'}`,\n );\n }\n cache.set(key, hit);\n }\n return hit;\n}\n\nexport function numberFormat(\n locale: string,\n options?: Intl.NumberFormatOptions,\n): Intl.NumberFormat {\n const key = locale + (options ? JSON.stringify(options) : '');\n return cached(nfCache, key, locale, (tag) => new Intl.NumberFormat(tag, options));\n}\n\nexport function dateTimeFormat(\n locale: string,\n options?: Intl.DateTimeFormatOptions,\n): Intl.DateTimeFormat {\n const key = locale + (options ? JSON.stringify(options) : '');\n return cached(dtfCache, key, locale, (tag) => new Intl.DateTimeFormat(tag, options));\n}\n\nexport function pluralRules(\n locale: string,\n type: Intl.PluralRuleType = 'cardinal',\n): Intl.PluralRules {\n return cached(prCache, locale + type, locale, (tag) => new Intl.PluralRules(tag, { type }));\n}\n\nexport function relativeTimeFormat(locale: string): Intl.RelativeTimeFormat {\n return cached(\n rtfCache,\n locale,\n locale,\n (tag) => new Intl.RelativeTimeFormat(tag, { numeric: 'auto' }),\n );\n}\n\nexport function listFormat(locale: string, type: Intl.ListFormatType): Intl.ListFormat {\n return cached(lfCache, locale + type, locale, (tag) => new Intl.ListFormat(tag, { type }));\n}\n\nexport function displayNames(locale: string): Intl.DisplayNames {\n return cached(dnCache, locale, locale, (tag) => new Intl.DisplayNames(tag, { type: 'language' }));\n}\n","import { dateTimeFormat, listFormat, numberFormat, pluralRules } from './intl';\nimport type { MessageNode, ParamNode } from './parse';\nimport type { Formatter, Params } from './types';\nimport { warnOnce } from './warn';\n\ninterface FormatContext {\n locale: string;\n params: Params | undefined;\n formatters: Record<string, Formatter>;\n hashValue?: unknown;\n key?: string;\n}\n\nexport function formatNodes(nodes: MessageNode[], ctx: FormatContext): string {\n let out = '';\n for (const node of nodes) {\n if (node.kind === 'text') out += node.value;\n else if (node.kind === 'hash') out += autoFormat(ctx.hashValue, ctx.locale, ctx);\n else out += formatParam(node, ctx);\n }\n return out;\n}\n\n// every warn names its message: keying on the param alone silenced the second message with the gap\nfunction where(ctx?: FormatContext): string {\n return ctx?.key ? ` in \"${ctx.key}\"` : '';\n}\n\nfunction formatParam(node: ParamNode, ctx: FormatContext): string {\n let value = ctx.params?.[node.name];\n if (value === undefined) {\n warnOnce(`missing param \"${node.name}\"${where(ctx)}`);\n return `{${node.name}}`;\n }\n // the one door: every path below coerces, so a value that cannot be coerced never gets there\n value = usable(value, ctx);\n\n if (node.variants) {\n const chosen = pickVariant(node.variants, value, ctx.locale, node.ordinal);\n // the value is left out of the warn on purpose: a counter walking 0..N must not grow the dedupe\n if (!chosen) {\n warnOnce(`no case matched for {${node.name}}${where(ctx)}, add an \"other\" case`);\n return '';\n }\n return formatNodes(chosen, { ...ctx, hashValue: value });\n }\n if (node.format) return applyFormat(value, node, ctx);\n return autoFormat(value, ctx.locale, ctx);\n}\n\n// the door a value passes before anything coerces it: a param, or a tagged template's ${…}\nexport function usable(value: unknown, ctx?: FormatContext): unknown {\n if (coercible(value)) return value;\n // the suffix is built here and not by the caller: every param of every call passes this door\n warnOnce(`cannot format ${describe(value)}${where(ctx)}`);\n return '';\n}\n\n// String() and Number() both throw on an object with no callable toString, and a param can be one\nfunction coercible(value: unknown): boolean {\n try {\n return typeof `${value}` === 'string';\n } catch {\n return false;\n }\n}\n\n// the type of the offending value, never the value: the dedupe set must stay bounded\nfunction describe(value: unknown): string {\n if (value instanceof Date) return Number.isNaN(value.getTime()) ? 'an invalid Date' : 'a Date';\n // NaN is typeof number, and \"cannot format a number as a number\" names nothing\n if (typeof value === 'number' && Number.isNaN(value)) return 'NaN';\n if (Array.isArray(value)) return 'an array';\n if (value === null) return 'null';\n if (value === undefined) return 'undefined';\n const type = typeof value;\n return type === 'object' ? 'an object' : `a ${type}`;\n}\n\nfunction pickVariant(\n variants: [string, MessageNode[]][],\n value: unknown,\n locale: string,\n ordinal?: boolean,\n): MessageNode[] | undefined {\n const raw = String(value);\n if (typeof value === 'number') {\n for (const [key, nodes] of variants) if (key === `=${raw}`) return nodes;\n const category = pluralRules(locale, ordinal ? 'ordinal' : 'cardinal').select(value);\n for (const [key, nodes] of variants) if (key === category) return nodes;\n } else {\n for (const [key, nodes] of variants) if (key === raw) return nodes;\n }\n for (const [key, nodes] of variants) if (key === 'other') return nodes;\n return undefined;\n}\n\nconst NUMERIC = /^(number|integer|percent|currency|unit)$/;\n\nfunction applyFormat(value: unknown, node: ParamNode, ctx: FormatContext): string {\n const { name, arg } = node;\n const format = node.format!;\n const custom = ctx.formatters[format];\n if (custom) return custom(value, ctx.locale, arg, { param: name, key: ctx.key });\n\n const { locale } = ctx;\n // what arrived, kept because the numeric guard below replaces value with the parsed number\n const raw = value;\n // a format missing its argument degrades like an invalid one: with a warn, never in silence\n const degrade = (problem: string): string => {\n warnOnce(`{${name}:${format}}${where(ctx)} ${problem}`);\n return String(raw);\n };\n // what a number is gets decided once: Intl prints NaN instead of throwing, and Number(null) is 0\n if (NUMERIC.test(format)) {\n const n = value === null || value === '' ? NaN : Number(value);\n if (Number.isNaN(n)) return degrade(`cannot format ${describe(value)} as a number`);\n value = n;\n }\n\n switch (format) {\n case 'number':\n return numberFormat(locale).format(value as number);\n case 'integer':\n return numberFormat(locale, { maximumFractionDigits: 0 }).format(value as number);\n case 'percent':\n return numberFormat(locale, { style: 'percent' }).format(value as number);\n case 'currency':\n if (!arg) return degrade('needs an argument like /USD');\n try {\n return numberFormat(locale, { style: 'currency', currency: arg }).format(value as number);\n } catch {\n return degrade(`does not know the currency \"${arg}\"`);\n }\n case 'date':\n try {\n return dateTimeFormat(\n locale,\n arg ? { dateStyle: arg as Intl.DateTimeFormatOptions['dateStyle'] } : undefined,\n ).format(toDate(value));\n } catch {\n return degrade(`cannot format ${describe(value)}${arg ? ` with style \"${arg}\"` : ''}`);\n }\n case 'time':\n try {\n return dateTimeFormat(locale, {\n timeStyle: (arg ?? 'short') as Intl.DateTimeFormatOptions['timeStyle'],\n }).format(toDate(value));\n } catch {\n return degrade(`cannot format ${describe(value)} with style \"${arg ?? 'short'}\"`);\n }\n case 'list': {\n if (!Array.isArray(value)) return degrade('needs an array');\n const type = arg === 'or' ? 'disjunction' : arg === 'unit' ? 'unit' : 'conjunction';\n return listFormat(locale, type).format(value.map((item) => autoFormat(item, locale, ctx)));\n }\n case 'unit':\n if (!arg) return degrade('needs an argument like /kilometer');\n try {\n return numberFormat(locale, { style: 'unit', unit: arg }).format(value as number);\n } catch {\n return degrade(`does not know the unit \"${arg}\"`);\n }\n // known but not loaded reads nothing like unknown, and the fix is not the reader's to guess\n case 'relative':\n return degrade('is not loaded: the compiler wires it when a catalog message uses it');\n default:\n return degrade('is not a format verbaly knows');\n }\n}\n\nexport function autoFormat(value: unknown, locale: string, ctx?: FormatContext): string {\n if (value === null || value === undefined) return '';\n // an invalid Date makes Intl throw and NaN makes it print \"NaN\": one degradation, one report\n if (Number.isNaN(value instanceof Date ? value.getTime() : value)) {\n warnOnce(`${describe(value)}${where(ctx)} renders as plain text`);\n return String(value);\n }\n if (typeof value === 'number') return numberFormat(locale).format(value);\n if (value instanceof Date) return dateTimeFormat(locale).format(value);\n return String(value);\n}\n\nfunction toDate(value: unknown): Date {\n return value instanceof Date ? value : new Date(value as string | number);\n}\n","import { displayNames } from './intl';\nimport type { Verbaly } from './types';\nimport { warnOnce } from './warn';\n\nexport interface ResolveLocaleOptions {\n supported: string[];\n fallback?: string;\n storageKey?: string | false;\n path?: string | false;\n base?: string;\n}\n\nexport interface LocaleFromPathOptions {\n supported: string[];\n path?: string;\n base?: string;\n}\n\n// shared identity: localStorage key (browser) + cookie name (SSR integrations)\nexport const LOCALE_STORAGE_KEY = 'verbaly-locale';\n\n// zh-Hant-TW → [zh-Hant-TW, zh-Hant, zh]\nexport function narrowLocales(lang: string): string[] {\n const out: string[] = [];\n const parts = lang.split('-');\n while (parts.length > 0) {\n out.push(parts.join('-'));\n parts.pop();\n }\n return out;\n}\n\n// fallback tables for engines without Intl.Locale getTextInfo (Firefox)\nconst RTL_SCRIPTS = /^(Arab|Aran|Hebr|Thaa|Nkoo|Syrc|Samr|Mand|Adlm|Rohg|Yezi)$/;\nconst RTL_LANGS = /^(ar|he|fa|ur|ps|sd|ug|yi|dv|ckb)$/;\n\ninterface TextInfoLocale extends Intl.Locale {\n getTextInfo?(): { direction?: string };\n textInfo?: { direction?: string };\n}\n\nexport function localeDirection(locale: string): 'ltr' | 'rtl' {\n try {\n // ar_EG is how gettext writes ar-EG, and Intl.Locale throws on it: the fallback read it ltr\n const loc = new Intl.Locale(locale.replace(/_/g, '-')) as TextInfoLocale;\n const direction = (loc.getTextInfo?.() ?? loc.textInfo)?.direction;\n if (direction === 'rtl' || direction === 'ltr') return direction;\n const script = loc.script ?? loc.maximize().script;\n if (script) return RTL_SCRIPTS.test(script) ? 'rtl' : 'ltr';\n return RTL_LANGS.test(loc.language) ? 'rtl' : 'ltr';\n } catch {\n // malformed tag: best effort on the primary subtag, never throw\n return RTL_LANGS.test(locale.split('-')[0]!.toLowerCase()) ? 'rtl' : 'ltr';\n }\n}\n\n// localized language name for locale switchers; defaults to the endonym\nexport function localeName(locale: string, displayIn: string = locale): string {\n try {\n return displayNames(displayIn).of(locale) ?? locale;\n } catch {\n return locale; // unknown tag or missing Intl data: the code beats a crash\n }\n}\n\n// how the language shows in the url, the one decision every other url answer follows from\nexport type Routing = 'prefix-except-source' | 'no-prefix' | 'prefix-all';\n\ninterface LocalePathBase {\n supported: string[];\n path?: string;\n base?: string;\n}\n\n// sourceLocale is required exactly where it decides the answer, so the old silent default cannot\nexport type LocalePathOptions = LocalePathBase &\n (\n | { routing?: 'prefix-except-source'; sourceLocale: string }\n | { routing: 'no-prefix' | 'prefix-all'; sourceLocale?: string }\n );\n\n// the inverse of what render writes: /es/docs → /pt/docs, under the routing mode you chose\nexport function localePath(locale: string, options: LocalePathOptions): string {\n const { supported } = options;\n const routing = options.routing ?? 'prefix-except-source';\n // the whole address: a language switch on a search page keeps the search and the anchor\n const full = options.path ?? currentPath(true) ?? '/';\n\n // the identity, so one switcher works in both modes: no-prefix changes the text, never the url\n if (routing === 'no-prefix') return full;\n\n const sourceLocale = options.sourceLocale;\n if (routing === 'prefix-except-source' && sourceLocale === undefined) {\n warnOnce('localePath needs sourceLocale: \"prefix-except-source\" prefixed every locale');\n }\n\n const base = normalizeBase(options.base);\n const parts = splitLocalePath(full, supported, base);\n if (routing === 'prefix-all' || locale !== sourceLocale) parts.segments.unshift(locale);\n return joinLocalePath(base, parts);\n}\n\ninterface PathParts {\n segments: string[];\n rest: string;\n trailingSlash: boolean;\n}\n\n// one decomposition for both directions: base out front, query behind, locale segment dropped\nfunction splitLocalePath(full: string, supported: string[], base: string): PathParts {\n const cut = full.search(/[?#]/);\n const path = stripBase(cut < 0 ? full : full.slice(0, cut), base);\n const segments = path.split('/').filter(Boolean);\n if (segments[0] && matchPathSegment(segments[0], supported)) segments.shift();\n return { segments, rest: cut < 0 ? '' : full.slice(cut), trailingSlash: path.endsWith('/') };\n}\n\nfunction joinLocalePath(base: string, parts: PathParts): string {\n const trailing = parts.segments.length && parts.trailingSlash ? '/' : '';\n return `${base}/${parts.segments.join('/')}${trailing}${parts.rest}`;\n}\n\n// which tree this page belongs to: a fact of the url, so it answers undefined instead of guessing\nexport function localeFromPath(options: LocaleFromPathOptions): string | undefined {\n const path = options.path ?? currentPath();\n if (path === undefined) return undefined;\n const segment = stripBase(path, normalizeBase(options.base)).split('/').find(Boolean);\n return segment ? matchPathSegment(segment, options.supported) : undefined;\n}\n\nexport interface StripLocalePathOptions {\n supported: string[];\n path?: string;\n base?: string;\n}\n\n// the canonical route behind a localized url: /es/docs → /docs, so a router matches one tree\nexport function stripLocalePath(options: StripLocalePathOptions): string {\n const full = options.path ?? currentPath(true) ?? '/';\n const base = normalizeBase(options.base);\n return joinLocalePath(base, splitLocalePath(full, options.supported, base));\n}\n\nexport interface AlternateLink {\n hreflang: string;\n href: string;\n}\n\nexport interface AlternateLinksOptions {\n supported: string[];\n sourceLocale: string;\n path: string;\n routing?: Routing;\n base?: string;\n baseUrl?: string;\n}\n\n// the reciprocal hreflang set for one page, the same one render writes, for a server that renders\nexport function alternateLinks(options: AlternateLinksOptions): AlternateLink[] {\n const { supported, sourceLocale, path, baseUrl = '' } = options;\n const routing = options.routing ?? 'prefix-except-source';\n\n // no-prefix means every locale answers on this url, and one href under many hreflangs is a lie\n if (routing === 'no-prefix') return [];\n\n // the union is what makes sourceLocale required exactly where it decides, so the call branches\n const base = options.base;\n const href = (locale: string): string =>\n baseUrl +\n localePath(\n locale,\n routing === 'prefix-all'\n ? { supported, routing, path, base }\n : { supported, routing, sourceLocale, path, base },\n );\n\n const links = supported.map((locale) => ({ hreflang: locale, href: href(locale) }));\n links.push({ hreflang: 'x-default', href: href(sourceLocale) });\n return links;\n}\n\nexport function resolveLocale(options: ResolveLocaleOptions): string {\n const { supported, fallback = supported[0] ?? 'en', storageKey = LOCALE_STORAGE_KEY } = options;\n\n // the document you are looking at wins: render put the page under that prefix already translated\n if (options.path !== false) {\n const match = localeFromPath({ supported, path: options.path, base: options.base });\n if (match) return match;\n }\n\n if (storageKey) {\n const stored = getStorage()?.getItem(storageKey);\n const match = stored && matchPreferred(stored, supported);\n if (match) return match;\n }\n\n for (const lang of preferredLanguages()) {\n const match = matchPreferred(lang, supported);\n if (match) return match;\n }\n\n return fallback;\n}\n\n// 'app', '/app' and '/app/' all read as '/app'; nothing means the site sits at the root\nfunction normalizeBase(base: string | undefined): string {\n const trimmed = base?.replace(/^\\/+/, '').replace(/\\/+$/, '');\n return trimmed ? `/${trimmed}` : '';\n}\n\n// the boundary check is what keeps base /app from swallowing /application\nfunction stripBase(path: string, base: string): string {\n if (!base || !path.startsWith(base)) return path;\n const rest = path.slice(base.length);\n if (rest === '') return '/';\n return rest.startsWith('/') ? rest : path;\n}\n\n// language, optional script, optional region: what render writes, never a slug like pt-and-friends\nconst LOCALE_SEGMENT = /^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|\\d{3}))?$/i;\n\n// a segment is narrowed only when it is shaped like a tag: a slug must never become a locale\nfunction matchPathSegment(segment: string, supported: string[]): string | undefined {\n if (supported.includes(segment)) return segment;\n return LOCALE_SEGMENT.test(segment) ? matchSupported(segment, supported) : undefined;\n}\n\n// exact, then progressive BCP-47 narrowing (zh-Hant-TW → zh-Hant → zh)\nfunction matchSupported(lang: string, supported: string[]): string | undefined {\n for (const candidate of narrowLocales(lang)) {\n if (supported.includes(candidate)) return candidate;\n }\n return undefined;\n}\n\n// server-side Accept-Language negotiation (q-values, case-insensitive, BCP-47 base)\nexport function negotiateLocale(\n header: string | null | undefined,\n supported: string[],\n fallback: string = supported[0] ?? 'en',\n): string {\n if (!header) return fallback;\n\n const ranges: { tag: string; q: number }[] = [];\n for (const part of header.split(',')) {\n const [rawTag, ...params] = part.trim().split(';');\n const tag = rawTag?.trim();\n if (!tag || tag === '*') continue;\n let q = 1;\n for (const param of params) {\n const [name, value] = param.split('=');\n if (name?.trim().toLowerCase() === 'q') {\n const parsed = Number(value?.trim());\n q = Number.isFinite(parsed) ? parsed : 1;\n }\n }\n if (q > 0) ranges.push({ tag, q });\n }\n // stable sort: ties keep header order\n ranges.sort((a, b) => b.q - a.q);\n\n for (const { tag } of ranges) {\n const match = matchPreferred(tag, supported);\n if (match) return match;\n }\n return fallback;\n}\n\n// a preference, not an address: what a reader of lang reads best (a url segment stays exact)\nfunction matchPreferred(lang: string, supported: string[]): string | undefined {\n const tags = narrowLocales(lang);\n const max = likely(lang);\n // zh-TW reads zh-Hant before a bare zh, and pt reads pt-BR: script and region, then the language\n const candidates = [...tags.slice(0, -1)];\n if (max) candidates.push(`${max.language}-${max.script}`, `${max.language}-${max.region}`);\n candidates.push(tags[tags.length - 1]!);\n for (const candidate of candidates) {\n // headers arrive as en-US and configs as en\n const match = supported.find((tag) => tag.toLowerCase() === candidate.toLowerCase());\n if (match) return match;\n }\n // a sibling in the same script: pt-PT reads pt-BR, and zh-HK never lands on zh-Hans\n return max\n ? supported.find((tag) => {\n const other = likely(tag);\n return other?.language === max.language && other.script === max.script;\n })\n : undefined;\n}\n\n// the subtags a tag implies (zh-HK is zh-Hant-HK, pt is pt-Latn-BR); none for a malformed tag\nfunction likely(tag: string): Intl.Locale | undefined {\n try {\n return new Intl.Locale(tag.replace(/_/g, '-')).maximize();\n } catch {\n return undefined;\n }\n}\n\n// per-request negotiation for SSR: url → cookie → Accept-Language → fallback\nexport interface RequestLocaleOptions {\n supported: string[];\n path?: string | null;\n routing?: Routing;\n base?: string;\n cookie?: string | null;\n header?: string | null;\n fallback?: string;\n}\n\nexport function resolveRequestLocale(options: RequestLocaleOptions): string {\n const { supported, path, routing, cookie, header, fallback = supported[0] ?? 'en' } = options;\n\n // an address is public, a cookie is one visitor: where the url carries the locale, it wins\n if (routing !== undefined && routing !== 'no-prefix' && path != null) {\n const match = localeFromPath({ supported, path, base: options.base });\n if (match) return match;\n // under prefix-except-source no prefix means the source tree, so negotiating would translate it\n if (routing === 'prefix-except-source') return fallback;\n }\n\n if (cookie) {\n // '' sentinel = no match → fall through to the header\n const match = negotiateLocale(cookie, supported, '');\n if (match) return match;\n }\n return negotiateLocale(header, supported, fallback);\n}\n\nexport interface SwitchLocaleOptions {\n cookie?: string | false;\n storageKey?: string | false;\n maxAge?: number;\n routing?: Routing;\n supported?: string[];\n sourceLocale?: string;\n base?: string;\n navigate?: (path: string) => void | Promise<void>;\n}\n\nconst YEAR = 31536000;\n\n// the whole switch, both modes: the url decides which half runs, never the caller\nexport async function switchLocale(\n instance: Pick<Verbaly, 'loadLocale' | 'setLocale'> & Partial<Pick<Verbaly, 'locales'>>,\n locale: string,\n options: SwitchLocaleOptions = {},\n): Promise<void> {\n const { cookie = LOCALE_STORAGE_KEY, maxAge = YEAR } = options;\n // one name for one choice: naming the cookie names the storage too, or the two drift in silence\n const storageKey = options.storageKey ?? (cookie === false ? LOCALE_STORAGE_KEY : cookie);\n // absent means the caller never asked for url behavior, as every caller before this one did\n const routed = options.routing !== undefined && options.routing !== 'no-prefix';\n\n // the destination document is already in the target language, so its catalog is not this page's\n if (!routed) {\n await instance.loadLocale(locale);\n instance.setLocale(locale);\n }\n\n if (typeof document === 'undefined') return; // SSR-safe no-op\n // both channels: a server reads the cookie, render's pre-paint script reads storage\n if (cookie) {\n document.cookie = `${cookie}=${encodeURIComponent(locale)}; path=/; max-age=${maxAge}; samesite=lax`;\n }\n persistLocale(locale, storageKey);\n\n if (!routed) return;\n const target = localePath(locale, {\n // the current segment has to be known to be stripped: /pt/docs must not become /es/pt/docs\n supported: options.supported ?? instance.locales ?? [locale],\n sourceLocale: options.sourceLocale,\n base: options.base,\n routing: options.routing,\n } as LocalePathOptions);\n await (options.navigate ?? assign)(target);\n}\n\n// a full load is the floor, not the goal: a framework passes its own router and keeps the app alive\nfunction assign(path: string): void {\n if (typeof location !== 'undefined') location.assign(path);\n}\n\nexport function persistLocale(\n locale: string,\n storageKey: string | false = LOCALE_STORAGE_KEY,\n): void {\n try {\n if (storageKey) getStorage()?.setItem(storageKey, locale);\n } catch {\n // a full storage throws on write, and a switch must still reach <html lang> and the navigation\n }\n if (typeof document !== 'undefined') {\n document.documentElement.lang = locale;\n document.documentElement.dir = localeDirection(locale);\n }\n}\n\nfunction currentPath(full?: boolean): string | undefined {\n // require document like every other browser check: a server has no page to read a prefix from\n return typeof document !== 'undefined' && typeof location !== 'undefined'\n ? location.pathname + (full ? location.search + location.hash : '')\n : undefined;\n}\n\nfunction preferredLanguages(): readonly string[] {\n // require document: Node 21+ has a global navigator whose language is the OS, not a user\n if (typeof document === 'undefined' || typeof navigator === 'undefined') return [];\n return navigator.languages?.length ? navigator.languages : [navigator.language];\n}\n\nfunction getStorage(): Storage | null {\n try {\n return typeof localStorage === 'undefined' ? null : localStorage;\n } catch {\n return null; // blocked storage (privacy mode)\n }\n}\n","import type { MessageNode, ParamNode } from './parse';\n\n// ICU escape-hatch → native MessageNode AST\n\n// a brace right after a brace is an escaped {{, not ICU; no lookbehind, Safari 16.3 cannot parse it\nconst ICU_ARG =\n /(^|[^{])\\{\\s*[a-zA-Z0-9_]+\\s*,\\s*(?:plural|selectordinal|select|number|date|time)\\b/;\n\nexport function isIcu(message: string): boolean {\n return ICU_ARG.test(message);\n}\n\nexport function parseIcu(message: string): MessageNode[] {\n let i = 0;\n const at = (): string => message.charAt(i);\n const skipWs = (): void => {\n while (i < message.length && /\\s/.test(at())) i++;\n };\n const readIdent = (): string => {\n let s = '';\n while (i < message.length && /[a-zA-Z0-9_]/.test(at())) s += message[i++];\n return s;\n };\n\n function parseBody(inPlural: boolean): MessageNode[] {\n const nodes: MessageNode[] = [];\n let buf = '';\n const flush = (): void => {\n if (buf) nodes.push({ kind: 'text', value: buf });\n buf = '';\n };\n while (i < message.length) {\n const ch = at();\n if (ch === '}') break;\n if (ch === '{') {\n flush();\n nodes.push(parseArg());\n } else if (ch === '#' && inPlural) {\n flush();\n nodes.push({ kind: 'hash' });\n i++;\n } else if (ch === \"'\") {\n buf += readQuoted();\n } else {\n buf += ch;\n i++;\n }\n }\n flush();\n return nodes;\n }\n\n // ICU apostrophe quoting\n function readQuoted(): string {\n i++; // opening '\n if (at() === \"'\") {\n i++;\n return \"'\";\n }\n const next = at();\n if (next !== '{' && next !== '}' && next !== '#') return \"'\"; // lone apostrophe\n let out = '';\n while (i < message.length) {\n if (at() === \"'\") {\n if (message.charAt(i + 1) === \"'\") {\n out += \"'\";\n i += 2;\n continue;\n }\n i++; // closing '\n return out;\n }\n out += message[i++];\n }\n return out; // unterminated\n }\n\n function parseArg(): MessageNode {\n i++; // {\n skipWs();\n const name = readIdent();\n skipWs();\n if (at() === '}') {\n i++;\n return { kind: 'param', name };\n }\n if (at() === ',') i++;\n skipWs();\n const type = readIdent();\n const node: ParamNode = { kind: 'param', name };\n\n if (type === 'number' || type === 'date' || type === 'time') {\n skipWs();\n let style = '';\n if (at() === ',') {\n i++;\n skipWs();\n while (i < message.length && at() !== '}' && at() !== ',') style += message[i++];\n style = style.trim();\n }\n if (type === 'number') {\n node.format =\n style === 'integer' || style === 'percent' || style === 'currency' ? style : 'number';\n } else {\n node.format = type;\n if (style) node.arg = style;\n }\n skipToClose();\n return node;\n }\n\n if (type === 'plural' || type === 'selectordinal' || type === 'select') {\n if (type === 'selectordinal') node.ordinal = true;\n const variants: [string, MessageNode[]][] = [];\n skipWs();\n if (at() === ',') i++; // comma after the keyword\n skipWs();\n if (type !== 'select' && message.startsWith('offset:', i)) {\n i += 7;\n skipWs();\n while (i < message.length && /[0-9]/.test(at())) i++; // offset parsed, not applied (v1)\n skipWs();\n }\n while (i < message.length && at() !== '}') {\n const selector = readSelector();\n skipWs();\n if (at() !== '{') break;\n i++; // {\n const body = parseBody(type !== 'select');\n if (at() === '}') i++;\n variants.push([selector, body]);\n skipWs();\n }\n if (at() === '}') i++;\n node.variants = variants;\n return node;\n }\n\n // unknown type → simple param\n skipToClose();\n return node;\n }\n\n function readSelector(): string {\n if (at() === '=') {\n let s = '=';\n i++;\n while (i < message.length && /[0-9]/.test(at())) s += message[i++];\n return s;\n }\n let s = '';\n while (i < message.length && !/[\\s{]/.test(at())) s += message[i++];\n return s;\n }\n\n function skipToClose(): void {\n while (i < message.length && at() !== '}') i++;\n if (at() === '}') i++;\n }\n\n return parseBody(false);\n}\n","import { isIcu } from './icu';\nimport { warnOnce } from './warn';\n\nexport type MessageNode = { kind: 'text'; value: string } | { kind: 'hash' } | ParamNode;\n\nexport interface ParamNode {\n kind: 'param';\n name: string;\n format?: string;\n arg?: string;\n ordinal?: boolean;\n variants?: [string, MessageNode[]][];\n}\n\nconst astCache = new Map<string, MessageNode[]>();\nconst AST_CACHE_MAX = 5000; // dynamic/CMS messages can't grow it unbounded\n// one live iterator, and the drop below the only delete: a new one walks every hole at the front\nconst oldest = astCache.keys();\n\n// ICU is the escape hatch, so its parser is a passenger the app opts into rather than always ships\nexport type IcuParser = (message: string) => MessageNode[];\n\nexport function parse(message: string, icu?: IcuParser): MessageNode[] {\n let cached = astCache.get(message);\n if (!cached) {\n if (isIcu(message)) {\n // an unparsed ICU message is not cached: the app is misconfigured, not settled\n if (!icu) return unparsedIcu(message);\n cached = icu(message);\n } else {\n cached = parseMessage(message, false);\n }\n // drop the oldest, never the whole map: clearing threw away the hot set on every overflow\n if (astCache.size >= AST_CACHE_MAX) astCache.delete(oldest.next().value as string);\n astCache.set(message, cached);\n }\n return cached;\n}\n\n// visible and named, never a plausible-looking wrong render: the source shows and the warn says why\nfunction unparsedIcu(message: string): MessageNode[] {\n warnOnce(\n 'a message uses ICU syntax and no ICU parser is loaded: set icu: true in your verbaly ' +\n 'config, or pass icu to createVerbaly',\n );\n return [{ kind: 'text', value: message }];\n}\n\nfunction parseMessage(input: string, inVariant: boolean): MessageNode[] {\n const nodes: MessageNode[] = [];\n let buf = '';\n let i = 0;\n\n const flush = () => {\n if (buf) nodes.push({ kind: 'text', value: buf });\n buf = '';\n };\n\n while (i < input.length) {\n const ch = input[i];\n if (ch === '{') {\n if (input[i + 1] === '{') {\n buf += '{';\n i += 2;\n continue;\n }\n const close = findClose(input, i);\n if (close < 0) {\n buf += input.slice(i);\n break;\n }\n flush();\n nodes.push(parsePlaceholder(input.slice(i + 1, close)));\n i = close + 1;\n } else if (ch === '}' && input[i + 1] === '}') {\n buf += '}';\n i += 2;\n } else if (inVariant && ch === '#') {\n if (input[i + 1] === '#') {\n buf += '#';\n i += 2;\n } else {\n flush();\n nodes.push({ kind: 'hash' });\n i += 1;\n }\n } else {\n buf += ch;\n i += 1;\n }\n }\n flush();\n return nodes;\n}\n\n// how the last findClose read }}: splitTop runs on that block right after and reads it alike\nlet closedPairs: boolean | undefined;\n\n// }} is an escape unless that leaves the block open; then it closes both where two are open\nfunction findClose(input: string, open: number, pairs?: boolean): number {\n closedPairs = pairs;\n let depth = 0;\n let i = open;\n while (i < input.length) {\n const ch = input[i];\n if (ch === '{') {\n if (input[i + 1] === '{') {\n i += 2;\n continue;\n }\n depth += 1;\n } else if (ch === '}') {\n if (input[i + 1] === '}' && !(pairs && depth > 1)) {\n i += 2;\n continue;\n }\n depth -= 1;\n if (depth === 0) return i;\n }\n i += 1;\n }\n return pairs ? -1 : findClose(input, open, true);\n}\n\nfunction parsePlaceholder(inner: string): MessageNode {\n const segments = splitTop(inner);\n const head = (segments[0] ?? '').trim();\n if (!head) return { kind: 'text', value: `{${inner}}` };\n\n const colon = head.indexOf(':');\n const name = (colon < 0 ? head : head.slice(0, colon)).trim();\n if (!name) return { kind: 'text', value: `{${inner}}` };\n\n const node: ParamNode = { kind: 'param', name };\n\n if (colon >= 0) {\n const fmtRaw = head.slice(colon + 1).trim();\n const slash = fmtRaw.indexOf('/');\n node.format = (slash < 0 ? fmtRaw : fmtRaw.slice(0, slash)).trim();\n if (slash >= 0) node.arg = fmtRaw.slice(slash + 1).trim();\n }\n\n if (segments.length > 1) {\n node.variants = [];\n for (const seg of segments.slice(1)) {\n const sep = seg.indexOf(':');\n if (sep < 0) continue;\n const key = seg.slice(0, sep).trim();\n const body = seg.slice(sep + 1).trim();\n if (key) node.variants.push([key, parseMessage(body, true)]);\n }\n }\n return node;\n}\n\nfunction splitTop(input: string): string[] {\n const parts: string[] = [];\n let buf = '';\n let depth = 0;\n let i = 0;\n while (i < input.length) {\n const ch = input[i];\n if (ch === '{') {\n if (input[i + 1] === '{') {\n buf += '{{';\n i += 2;\n continue;\n }\n depth += 1;\n buf += ch;\n } else if (ch === '}') {\n if (input[i + 1] === '}' && !(closedPairs && depth > 0)) {\n buf += '}}';\n i += 2;\n continue;\n }\n depth -= 1;\n buf += ch;\n } else if (ch === '|' && depth === 0) {\n if (input[i + 1] === '|') {\n buf += '|';\n i += 2;\n continue;\n }\n parts.push(buf);\n buf = '';\n } else {\n buf += ch;\n }\n i += 1;\n }\n parts.push(buf);\n return parts;\n}\n","import { flatten } from './flatten';\nimport { autoFormat, formatNodes, usable } from './format';\nimport { narrowLocales } from './locale';\nimport { parse } from './parse';\nimport { warnOnce } from './warn';\nimport type {\n AddMessagesOptions,\n DictionaryInput,\n Formatter,\n LocaleLoader,\n MessageTree,\n Params,\n TFunction,\n Verbaly,\n VerbalyOptions,\n} from './types';\n\nexport function createVerbaly<const D extends DictionaryInput = DictionaryInput>(\n options: VerbalyOptions<D> = {},\n): Verbaly<D> {\n // no prototype, so a name like toString is a miss; setPrototypeOf keeps them fast objects\n const dict: Record<string, Record<string, string>> = Object.setPrototypeOf({}, null);\n const listeners = new Set<() => void>();\n const formatters: Record<string, Formatter> = Object.assign(\n Object.setPrototypeOf({}, null),\n options.formatters,\n );\n const loaders: Record<string, LocaleLoader> = Object.assign(\n Object.setPrototypeOf({}, null),\n options.loaders,\n );\n const loaded = new Set<string>();\n const inFlight = new Map<string, Promise<void>>();\n const fallbacks = options.fallback\n ? Array.isArray(options.fallback)\n ? options.fallback\n : [options.fallback]\n : [];\n\n let locale = options.locale ?? detectLocale();\n let version = 0;\n let chainCache: string[] | null = null;\n\n if (options.messages) {\n for (const [loc, tree] of Object.entries(options.messages)) {\n dict[loc] = flatten(tree);\n }\n }\n\n // a page carrying its own slice must not also fetch the catalog it already has enough of\n const partial = new Set(options.partial ?? []);\n for (const loc of partial) loaded.add(loc);\n\n function chain(): string[] {\n if (chainCache) return chainCache;\n const result = narrowLocales(locale);\n for (const fb of fallbacks) if (!result.includes(fb)) result.push(fb);\n chainCache = result;\n return result;\n }\n\n function lookup(key: string): { msg: string; from: string } | undefined {\n for (const loc of chain()) {\n const msg = dict[loc]?.[key];\n // '' = untranslated (extract scaffolds it) → keep falling back\n if (msg) return { msg, from: loc };\n }\n return undefined;\n }\n\n function translate(key: string, params: Params | undefined): string {\n const hit = lookup(key);\n // a fallback hides a short slice: the source catalog answers for a key the page never got\n if (partial.size > 0 && (hit === undefined || !partial.has(hit.from))) completePartial(key);\n if (hit === undefined) {\n const replacement = options.onMissing?.(key, locale);\n const value = typeof replacement === 'string' ? replacement : key;\n if (typeof replacement !== 'string' && !options.onMissing) {\n warnOnce(`missing key \"${key}\" (${locale})`);\n }\n options.onResolve?.({ key, locale, value, status: 'miss' });\n return value;\n }\n const value = formatNodes(parse(hit.msg, options.icu), { locale, params, formatters, key });\n options.onResolve?.({\n key,\n locale,\n value,\n status: hit.from === locale ? 'hit' : 'fallback',\n from: hit.from,\n });\n return value;\n }\n\n function tagged(strings: TemplateStringsArray, values: unknown[]): string {\n let out = strings[0] ?? '';\n for (let i = 0; i < values.length; i++) {\n out += autoFormat(usable(values[i]), locale) + (strings[i + 1] ?? '');\n }\n return out;\n }\n\n function notify(): void {\n version += 1;\n for (const fn of listeners) fn();\n }\n\n autoLoad(locale);\n\n const t = ((first: unknown, ...rest: unknown[]): string => {\n if (isTemplateStrings(first)) return tagged(first, rest);\n return translate(first as string, rest[0] as Params | undefined);\n }) as TFunction<D>;\n\n t.id =\n () =>\n (strings: TemplateStringsArray, ...values: unknown[]) =>\n tagged(strings, values);\n\n // fire and forget: the UI re-renders when it lands, and a failure reports instead of rejecting\n function autoLoad(target: string): void {\n void loadLocale(target).catch(() => {\n warnOnce(`failed to load catalog for \"${target}\"`);\n });\n }\n\n // the slice lacked it, so the full catalog is worth fetching: once per locale, then repaint\n function completePartial(key: string): void {\n for (const candidate of chain()) {\n if (!partial.has(candidate)) continue;\n // '' is an answer: the slice carried the key and this locale simply has no message for it\n if (dict[candidate]?.[key] !== undefined) return;\n partial.delete(candidate);\n loaded.delete(candidate);\n autoLoad(candidate);\n return;\n }\n }\n\n function pendingLoader(target: string): string | undefined {\n for (const candidate of narrowLocales(target)) {\n if (loaders[candidate]) return loaded.has(candidate) ? undefined : candidate;\n }\n return undefined;\n }\n\n function loadLocale(target: string): Promise<void> {\n const pending = pendingLoader(target);\n if (!pending) return Promise.resolve();\n const running = inFlight.get(pending);\n if (running) return running;\n const load = loaders[pending]!()\n .then((mod) => {\n loaded.add(pending);\n inFlight.delete(pending);\n addMessages(\n pending,\n 'default' in mod ? (mod.default as MessageTree) : (mod as MessageTree),\n );\n })\n .catch((error: unknown) => {\n inFlight.delete(pending);\n throw error;\n });\n inFlight.set(pending, load);\n return load;\n }\n\n function addMessages(loc: string, messages: MessageTree, opts?: AddMessagesOptions): void {\n // a slice is not the catalog, so the locale stays incomplete and never demotes a loaded one\n if (opts?.partial && !loaded.has(loc) && !inFlight.has(loc)) {\n partial.add(loc);\n loaded.add(loc);\n }\n // a spread would hand the merge Object.prototype back, and toString would answer as a message\n dict[loc] = Object.assign(Object.create(null), dict[loc], flatten(messages));\n notify();\n }\n\n return {\n get locale() {\n return locale;\n },\n get locales() {\n return [...new Set([...Object.keys(dict), ...Object.keys(loaders)])];\n },\n get version() {\n return version;\n },\n // the generic is still open in here, so the conditional type cannot pick a side yet\n t: t as Verbaly<D>['t'],\n setLocale(next: string) {\n autoLoad(next);\n if (next === locale) return;\n locale = next;\n chainCache = null;\n notify();\n },\n loadLocale,\n addMessages,\n subscribe(listener: () => void) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n has(key: string) {\n return lookup(key) !== undefined;\n },\n inspect(key: string) {\n const hit = lookup(key);\n return hit ? { from: hit.from, source: hit.msg } : undefined;\n },\n };\n}\n\nfunction isTemplateStrings(value: unknown): value is TemplateStringsArray {\n return Array.isArray(value) && 'raw' in value;\n}\n\nfunction detectLocale(): string {\n // gate on document, not navigator: Node 21+ exposes a global navigator (OS locale)\n return typeof document !== 'undefined' && typeof navigator !== 'undefined' && navigator.language\n ? navigator.language\n : 'en';\n}\n","// Named-tag tokenizer for <Trans>\nexport type TagNode = string | { name: string; children: TagNode[] };\n\nconst TAG = /<(\\/?)([a-zA-Z][\\w-]*)\\s*(\\/?)>/g;\n// the void tags a message renders; <link> stays a name for a link, so it still pairs\nconst BREAK = /^(?:br|wbr)$/;\n\n// text runs only, post-tokenize: decoded braces/angles never re-enter a parser\nconst ENTITY = /&(?:(lt|gt|amp)|#(\\d+)|#[xX]([0-9a-fA-F]+));/g;\nconst ENTITY_MAP: Record<string, string> = { lt: '<', gt: '>', amp: '&' };\nconst decodeEntities = (s: string): string =>\n s.replace(ENTITY, (full, name?: string, dec?: string, hex?: string) => {\n if (name) return ENTITY_MAP[name]!;\n const code = dec ? parseInt(dec, 10) : parseInt(hex!, 16);\n return code <= 0x10ffff ? String.fromCodePoint(code) : full;\n });\n\nexport function parseTags(text: string): TagNode[] {\n TAG.lastIndex = 0;\n const root: TagNode[] = [];\n const stack: { name: string; children: TagNode[] }[] = [];\n const top = (): TagNode[] => (stack.length ? stack[stack.length - 1]!.children : root);\n const pushText = (s: string): void => {\n if (s) top().push(decodeEntities(s));\n };\n\n let last = 0;\n let m: RegExpExecArray | null;\n while ((m = TAG.exec(text)) !== null) {\n const [full, closing, name, selfClose] = m;\n pushText(text.slice(last, m.index));\n last = m.index + full.length;\n\n // a break is whole on its own: <br>, <br/> and <br /> are one break, and </br> adds none\n if (selfClose || BREAK.test(name!)) {\n if (!closing) top().push({ name: name!, children: [] });\n } else if (closing) {\n if (stack.length && stack[stack.length - 1]!.name === name) {\n const node = stack.pop()!;\n top().push(node);\n } else {\n pushText(full); // stray closing tag → literal\n }\n } else {\n stack.push({ name: name!, children: [] });\n }\n }\n pushText(text.slice(last));\n\n // unclosed opens: drop wrapper\n while (stack.length) {\n const node = stack.pop()!;\n top().push(...node.children);\n }\n return root;\n}\n","import { narrowLocales } from './locale';\nimport { parseTags, type TagNode } from './tags';\nimport type { DictionaryInput, Params, Verbaly } from './types';\nimport { warnOnce } from './warn';\n\n// hrefs come from the caller, never from messages\nexport type RichLink = string | { href: string; target?: string; rel?: string };\n\nexport interface BindDomOptions {\n root?: ParentNode;\n attribute?: string;\n richTags?: string[];\n richLinks?: Record<string, RichLink>;\n}\n\n// eslint-disable-next-line no-control-regex\nconst UNSAFE_HREF = /^[\\u0000-\\u0020]*(javascript|data|vbscript):/i;\nconst URL_ATTR = /^(href|src|xlink:href|action|formaction)$/;\nconst BLOCKED_ATTR = /^(style|srcdoc)$/;\n// a browser drops tab, LF and CR anywhere in a url and trims leading C0 before reading the scheme\nconst URL_NOISE = /[\\t\\n\\r]/g;\n\nexport function safeHref(href: string): string | undefined {\n const unsafe = UNSAFE_HREF.exec(href.replace(URL_NOISE, ''));\n if (unsafe) {\n // the scheme and never the href: warnOnce dedupes on its text and a catalog value is unbounded\n warnOnce(`blocked an unsafe href, it resolves to \"${unsafe[1]!.toLowerCase()}:\"`);\n return undefined;\n }\n return href;\n}\n\n// one link normalization for core + every adapter (applies safeHref)\nexport function normalizeLink(link: RichLink): { href?: string; target?: string; rel?: string } {\n const { href, target, rel } = typeof link === 'string' ? { href: link } : link;\n return { href: safeHref(href), target, rel };\n}\n\n// one attribute guard for bindDom + render, a catalog is untrusted input: undefined = skip\nexport function safeAttribute(name: string, value: string): string | undefined {\n const lower = name.toLowerCase();\n if (lower.startsWith('on') || BLOCKED_ATTR.test(lower)) return undefined;\n if (URL_ATTR.test(lower)) return safeHref(value);\n return value;\n}\n\n// children never reach a void element: a browser parses <br></br> as two <br>, hydration as one\nexport const VOID_TAGS = [\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n];\n\n// phrasing-only, attribute-less → XSS-safe\nexport const RICH_TAGS = [\n 'em',\n 'strong',\n 'code',\n 'b',\n 'i',\n 'u',\n 's',\n 'small',\n 'mark',\n 'sub',\n 'sup',\n 'span',\n 'kbd',\n 'abbr',\n 'br',\n 'wbr',\n];\n\nexport const CATALOG_SCRIPT = 'data-verbaly-catalog';\n\n// the slice `verbaly render` inlined here, so a mirrored page needs no catalog over the network\nexport function inlineMessages(root?: ParentNode): Record<string, string> | undefined {\n const scope = root ?? (typeof document === 'undefined' ? undefined : document);\n if (!scope) return undefined;\n const node = scope.querySelector(`script[${CATALOG_SCRIPT}]`);\n if (!node?.textContent) return undefined;\n try {\n const parsed: unknown = JSON.parse(node.textContent);\n if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {\n return parsed as Record<string, string>;\n }\n } catch {\n // one message for both breakages: the remedy is the same, fix the blob or drop it\n }\n warnOnce('inline catalog is not a usable object, so the page loads its locale instead');\n return undefined;\n}\n\nexport function bindDom<D extends DictionaryInput>(\n instance: Verbaly<D>,\n options: BindDomOptions = {},\n): () => void {\n if (typeof document === 'undefined') {\n throw new Error('[verbaly] bindDom requires a DOM');\n }\n const t = instance.t as unknown as (key: string, params?: Params) => string;\n const root = options.root ?? document.body;\n const attr = options.attribute ?? 'data-verbaly';\n const argsAttr = `${attr}-args`;\n const attrsAttr = `${attr}-attr`;\n const richAttr = `${attr}-rich`;\n const linksAttr = `${attr}-links`;\n const richTags = new Set(options.richTags ?? RICH_TAGS);\n\n // null prototype: a tag named constructor in a message is unknown, never Object's own function\n const globalLinks: Record<string, RichLink> | undefined =\n options.richLinks && Object.assign(Object.create(null), options.richLinks);\n const argsCache = new WeakMap<Element, { raw: string | null; value: Params | undefined }>();\n const linksCache = new WeakMap<\n Element,\n { raw: string | null; value: Record<string, RichLink> | undefined }\n >();\n const attrsCache = new WeakMap<Element, { raw: string | null; value: Params | undefined }>();\n\n function fromCache<T>(\n cache: WeakMap<Element, { raw: string | null; value: T }>,\n el: Element,\n raw: string | null,\n compute: () => T,\n ): T {\n const hit = cache.get(el);\n if (hit && hit.raw === raw) return hit.value;\n const value = compute();\n cache.set(el, { raw, value });\n return value;\n }\n\n function cachedArgs(el: Element): Params | undefined {\n const raw = el.getAttribute(argsAttr);\n return fromCache(argsCache, el, raw, () => parseArgs(raw));\n }\n\n function cachedLinks(el: Element): Record<string, RichLink> | undefined {\n const raw = el.getAttribute(linksAttr);\n if (!raw) return globalLinks;\n return fromCache(linksCache, el, raw, () => {\n const own = parseArgs(raw) as Record<string, RichLink> | undefined;\n return own ? Object.assign(Object.create(null), globalLinks, own) : globalLinks;\n });\n }\n\n function renderRich(\n el: Element,\n nodes: TagNode[],\n links: Record<string, RichLink> | undefined,\n ): void {\n for (const node of nodes) {\n if (typeof node === 'string') {\n el.append(node);\n continue;\n }\n const link = links?.[node.name];\n if (link !== undefined) {\n const { href, target, rel } = normalizeLink(link);\n const a = el.ownerDocument.createElement('a');\n if (href !== undefined) a.setAttribute('href', href);\n if (target) a.setAttribute('target', target);\n if (rel) a.setAttribute('rel', rel);\n renderRich(a, node.children, links);\n el.append(a);\n } else if (richTags.has(node.name)) {\n const child = el.ownerDocument.createElement(node.name);\n if (!VOID_TAGS.includes(node.name)) renderRich(child, node.children, links);\n el.append(child);\n } else {\n renderRich(el, node.children, links); // unknown tag → unwrap\n }\n }\n }\n\n // one sample per bind: a build-only group is a normal setup and it can hold hundreds of keys\n let reportedKept = false;\n\n // trusted = text this bind never wrote (server render, router swap): only this locale beats it\n function holdBack(key: string, current: string | null, trusted: boolean): boolean {\n if (!current?.trim()) return false;\n const hit = instance.inspect(key);\n // resolves nowhere: the raw key is never an improvement on the text the node already carries\n if (!hit) {\n if (!reportedKept) {\n reportedKept = true;\n warnOnce(`kept the pre-rendered text where no catalog has the key, first: \"${key}\"`);\n }\n return true;\n }\n return trusted && hit.from !== instance.locale;\n }\n\n function render(el: Element, trusted: boolean): void {\n const args = cachedArgs(el);\n const key = el.getAttribute(attr);\n if (key && !holdBack(key, el.textContent, trusted)) {\n const text = t(key, args);\n if (el.hasAttribute(richAttr)) {\n el.textContent = '';\n renderRich(el, parseTags(text), cachedLinks(el));\n } else {\n el.textContent = text;\n }\n }\n\n const rawAttrs = el.getAttribute(attrsAttr);\n const attrMap = fromCache(attrsCache, el, rawAttrs, () => parseArgs(rawAttrs));\n if (attrMap) {\n for (const [name, attrKey] of Object.entries(attrMap)) {\n if (typeof attrKey !== 'string') continue;\n if (holdBack(attrKey, el.getAttribute(name), trusted)) continue;\n const value = safeAttribute(name, t(attrKey, args));\n if (value !== undefined) el.setAttribute(name, value);\n }\n }\n }\n\n const selector = `[${attr}], [${attrsAttr}]`;\n\n function renderAll(scope: ParentNode | Element, trusted: boolean): void {\n if (scope instanceof Element && scope.matches(selector)) render(scope, trusted);\n for (const el of scope.querySelectorAll(selector)) render(el, trusted);\n }\n\n warnOnLangMismatch(instance.locale);\n warnOnUnboundHead(root, selector);\n renderAll(root, true);\n // the catalog moved, so the whole dom is ours: a stale locale must not survive a switch\n const unsubscribe = instance.subscribe(() => renderAll(root, false));\n\n const observer = new MutationObserver((records) => {\n for (const record of records) {\n if (record.type === 'attributes' && record.target instanceof Element) {\n render(record.target, false);\n } else if (record.type === 'childList') {\n // a node arrives carrying text someone else wrote, same standing as the first paint\n for (const node of record.addedNodes) {\n if (node instanceof Element) renderAll(node, true);\n }\n }\n }\n });\n\n observer.observe(root instanceof Document ? root.documentElement : (root as Node), {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [attr, argsAttr, attrsAttr, richAttr, linksAttr],\n });\n\n return () => {\n unsubscribe();\n observer.disconnect();\n };\n}\n\n// the head is the half a search result shows, and the default body root never reaches it\nfunction warnOnUnboundHead(root: ParentNode, selector: string): void {\n if (root === document || root === document.documentElement) return;\n if (!document.head?.querySelector(selector)) return;\n warnOnce('the <head> has bound elements this root never reaches: pass { root: document }');\n}\n\n// render writes <html lang>, so a disagreement here means the page is about to be translated away\nfunction warnOnLangMismatch(locale: string): void {\n const lang = document.documentElement.lang;\n if (!lang || narrowLocales(lang).includes(locale) || narrowLocales(locale).includes(lang)) return;\n warnOnce(\n `the page is <html lang=\"${lang}\"> and this instance is in \"${locale}\": read the url with ` +\n `localeFromPath, or call persistLocale first`,\n );\n}\n\nfunction parseArgs(raw: string | null): Params | undefined {\n if (!raw) return undefined;\n try {\n return JSON.parse(raw) as Params;\n } catch {\n // the value stays out: the dedupe set is unbounded, and an attribute can be built at runtime\n warnOnce('invalid args JSON');\n return undefined;\n }\n}\n","import { relativeTimeFormat } from './intl';\nimport type { Formatter } from './types';\nimport { warnOnce } from './warn';\n\n// seconds per unit, largest first (auto pick)\nconst REL_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 31536000],\n ['month', 2592000],\n ['week', 604800],\n ['day', 86400],\n ['hour', 3600],\n ['minute', 60],\n ['second', 1],\n];\n\n// the type and never the value (the warn set must stay bounded); only number|Date reaches here\nfunction describe(value: unknown): string {\n if (!(value instanceof Date)) return `a ${typeof value}`;\n return Number.isNaN(value.getTime()) ? 'an invalid Date' : 'a Date';\n}\n\n// the one format that ships only where a message asks for it: it is 318 B and most apps never do\nexport const relativeFormatter: Formatter = (value, locale, arg, info) => {\n const where = info?.key ? ` in \"${info.key}\"` : '';\n const degrade = (problem: string): string => {\n warnOnce(`{${info?.param ?? '…'}:relative}${where} ${problem}`);\n return String(value);\n };\n\n if (typeof value === 'number' && !arg) return degrade('needs an argument like /day');\n if (typeof value !== 'number' && !(value instanceof Date)) {\n return degrade('needs a number or a Date');\n }\n\n try {\n const fmt = relativeTimeFormat(locale);\n if (typeof value === 'number') return fmt.format(value, arg as Intl.RelativeTimeFormatUnit);\n const diffSec = (value.getTime() - Date.now()) / 1000;\n if (arg) {\n const per = REL_UNITS.find(([unit]) => unit === arg)?.[1];\n if (!per) throw new RangeError(arg);\n return fmt.format(Math.round(diffSec / per), arg as Intl.RelativeTimeFormatUnit);\n }\n const [unit, per] = REL_UNITS.find(([, s]) => Math.abs(diffSec) >= s) ?? ['second', 1];\n return fmt.format(Math.round(diffSec / per), unit);\n } catch {\n // an invalid Date lands here too, so the warn names both suspects instead of blaming the unit\n return degrade(`cannot format ${describe(value)} as \"${arg}\"`);\n }\n};\n"],"mappings":";AACA,MAAM,yBAAS,IAAI,IAAY;AAE/B,SAAgB,SAAS,SAAuB;CAC9C,IAAI,OAAO,IAAI,OAAO,GAAG;CACzB,OAAO,IAAI,OAAO;CAClB,QAAQ,KAAK,aAAa,SAAS;AACrC;;;ACHA,SAAgB,QACd,MACA,SAAS,IACT,MAA8B,OAAO,OAAO,IAAI,GACxB;CAExB,IAAI,CAAC,QAAQ,IAAI,GAAG,OAAO;CAC3B,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,GAAG;EAC/C,MAAM,OAAO,SAAS,GAAG,OAAO,GAAG,QAAQ;EAC3C,IAAI,OAAO,UAAU,UAAU,IAAI,QAAQ;OACtC,IAAI,QAAQ,KAAK,GAAG,QAAQ,OAAO,MAAM,GAAG;OAC5C,SAAS,qBAAqB,KAAK,4CAA4C;CACtF;CACA,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