verbaly 0.46.0 → 0.48.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 +21 -3
- package/dist/index.cjs +59 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +57 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -111,12 +111,30 @@ localeDirection('ar'); // 'rtl': switchLocale/persistLocale already apply it to
|
|
|
111
111
|
|
|
112
112
|
```ts
|
|
113
113
|
// server-side (SSR): one instance per request, locale from the request itself
|
|
114
|
-
import { createVerbaly,
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
import { createVerbaly, resolveRequestLocale } from 'verbaly';
|
|
115
|
+
|
|
116
|
+
// the address wins when it carries the language: a url is public, a cookie is one visitor
|
|
117
|
+
const locale = resolveRequestLocale({
|
|
118
|
+
supported: ['en', 'es', 'pt'],
|
|
119
|
+
path: url.pathname,
|
|
120
|
+
routing: 'prefix-except-source',
|
|
121
|
+
cookie: cookies.get('verbaly-locale'),
|
|
122
|
+
header: request.headers.get('accept-language'),
|
|
123
|
+
fallback: 'en',
|
|
124
|
+
});
|
|
117
125
|
const v = createVerbaly({ locale, fallback: 'en', messages });
|
|
118
126
|
```
|
|
119
127
|
|
|
128
|
+
```ts
|
|
129
|
+
// the url helpers, all pure and safe on a server
|
|
130
|
+
import { alternateLinks, localePath, stripLocalePath } from 'verbaly';
|
|
131
|
+
|
|
132
|
+
localePath('pt', { supported, sourceLocale: 'en', path: '/es/docs' }); // '/pt/docs'
|
|
133
|
+
stripLocalePath({ supported, path: '/es/docs' }); // '/docs', the route behind the url
|
|
134
|
+
alternateLinks({ supported, sourceLocale: 'en', path: '/docs', baseUrl: 'https://x.dev' });
|
|
135
|
+
// one hreflang entry per locale plus x-default, the same set `verbaly render` writes
|
|
136
|
+
```
|
|
137
|
+
|
|
120
138
|
## ✨ What you get
|
|
121
139
|
|
|
122
140
|
- **Hybrid compiler + runtime**: static text compiled (types + tree-shaking), dynamic content via a real runtime path.
|
package/dist/index.cjs
CHANGED
|
@@ -218,14 +218,24 @@ function localePath(locale, options) {
|
|
|
218
218
|
const sourceLocale = options.sourceLocale;
|
|
219
219
|
if (routing === "prefix-except-source" && sourceLocale === void 0) warnOnce("localePath needs sourceLocale: \"prefix-except-source\" prefixed every locale");
|
|
220
220
|
const base = normalizeBase(options.base);
|
|
221
|
+
const parts = splitLocalePath(full, supported, base);
|
|
222
|
+
if (routing === "prefix-all" || locale !== sourceLocale) parts.segments.unshift(locale);
|
|
223
|
+
return joinLocalePath(base, parts);
|
|
224
|
+
}
|
|
225
|
+
function splitLocalePath(full, supported, base) {
|
|
221
226
|
const cut = full.search(/[?#]/);
|
|
222
227
|
const path = stripBase(cut < 0 ? full : full.slice(0, cut), base);
|
|
223
|
-
const rest = cut < 0 ? "" : full.slice(cut);
|
|
224
228
|
const segments = path.split("/").filter(Boolean);
|
|
225
229
|
if (segments[0] && matchPathSegment(segments[0], supported)) segments.shift();
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
230
|
+
return {
|
|
231
|
+
segments,
|
|
232
|
+
rest: cut < 0 ? "" : full.slice(cut),
|
|
233
|
+
trailingSlash: path.endsWith("/")
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function joinLocalePath(base, parts) {
|
|
237
|
+
const trailing = parts.segments.length && parts.trailingSlash ? "/" : "";
|
|
238
|
+
return `${base}/${parts.segments.join("/")}${trailing}${parts.rest}`;
|
|
229
239
|
}
|
|
230
240
|
function localeFromPath(options) {
|
|
231
241
|
const path = options.path ?? currentPath();
|
|
@@ -233,6 +243,38 @@ function localeFromPath(options) {
|
|
|
233
243
|
const segment = stripBase(path, normalizeBase(options.base)).split("/").find(Boolean);
|
|
234
244
|
return segment ? matchPathSegment(segment, options.supported) : void 0;
|
|
235
245
|
}
|
|
246
|
+
function stripLocalePath(options) {
|
|
247
|
+
const full = options.path ?? currentPath() ?? "/";
|
|
248
|
+
const base = normalizeBase(options.base);
|
|
249
|
+
return joinLocalePath(base, splitLocalePath(full, options.supported, base));
|
|
250
|
+
}
|
|
251
|
+
function alternateLinks(options) {
|
|
252
|
+
const { supported, sourceLocale, path, baseUrl = "" } = options;
|
|
253
|
+
const routing = options.routing ?? "prefix-except-source";
|
|
254
|
+
if (routing === "no-prefix") return [];
|
|
255
|
+
const base = options.base;
|
|
256
|
+
const href = (locale) => baseUrl + localePath(locale, routing === "prefix-all" ? {
|
|
257
|
+
supported,
|
|
258
|
+
routing,
|
|
259
|
+
path,
|
|
260
|
+
base
|
|
261
|
+
} : {
|
|
262
|
+
supported,
|
|
263
|
+
routing,
|
|
264
|
+
sourceLocale,
|
|
265
|
+
path,
|
|
266
|
+
base
|
|
267
|
+
});
|
|
268
|
+
const links = supported.map((locale) => ({
|
|
269
|
+
hreflang: locale,
|
|
270
|
+
href: href(locale)
|
|
271
|
+
}));
|
|
272
|
+
links.push({
|
|
273
|
+
hreflang: "x-default",
|
|
274
|
+
href: href(sourceLocale)
|
|
275
|
+
});
|
|
276
|
+
return links;
|
|
277
|
+
}
|
|
236
278
|
function resolveLocale(options) {
|
|
237
279
|
const { supported, fallback = supported[0] ?? "en", storageKey = LOCALE_STORAGE_KEY } = options;
|
|
238
280
|
if (options.path !== false) {
|
|
@@ -306,7 +348,16 @@ function matchSupportedLoose(lang, supported) {
|
|
|
306
348
|
}
|
|
307
349
|
}
|
|
308
350
|
function resolveRequestLocale(options) {
|
|
309
|
-
const { supported, cookie, header, fallback = supported[0] ?? "en" } = options;
|
|
351
|
+
const { supported, path, routing, cookie, header, fallback = supported[0] ?? "en" } = options;
|
|
352
|
+
if (routing !== void 0 && routing !== "no-prefix" && path != null) {
|
|
353
|
+
const match = localeFromPath({
|
|
354
|
+
supported,
|
|
355
|
+
path,
|
|
356
|
+
base: options.base
|
|
357
|
+
});
|
|
358
|
+
if (match) return match;
|
|
359
|
+
if (routing === "prefix-except-source") return fallback;
|
|
360
|
+
}
|
|
310
361
|
if (cookie) {
|
|
311
362
|
const match = negotiateLocale(cookie, supported, "");
|
|
312
363
|
if (match) return match;
|
|
@@ -1120,6 +1171,7 @@ const relativeFormatter = (value, locale, arg, info) => {
|
|
|
1120
1171
|
exports.LOCALE_STORAGE_KEY = LOCALE_STORAGE_KEY;
|
|
1121
1172
|
exports.RICH_TAGS = RICH_TAGS;
|
|
1122
1173
|
exports.VOID_TAGS = VOID_TAGS;
|
|
1174
|
+
exports.alternateLinks = alternateLinks;
|
|
1123
1175
|
exports.bindDom = bindDom;
|
|
1124
1176
|
exports.createVerbaly = createVerbaly;
|
|
1125
1177
|
exports.flatten = flatten;
|
|
@@ -1138,6 +1190,8 @@ exports.resolveLocale = resolveLocale;
|
|
|
1138
1190
|
exports.resolveRequestLocale = resolveRequestLocale;
|
|
1139
1191
|
exports.safeAttribute = safeAttribute;
|
|
1140
1192
|
exports.safeHref = safeHref;
|
|
1193
|
+
exports.stripLocalePath = stripLocalePath;
|
|
1141
1194
|
exports.switchLocale = switchLocale;
|
|
1195
|
+
exports.warnOnce = warnOnce;
|
|
1142
1196
|
|
|
1143
1197
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\nexport function flatten(\n tree: MessageTree,\n prefix = '',\n out: 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","const 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>(cache: Map<string, T>, key: string, make: () => T): 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 hit = make();\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, () => new Intl.NumberFormat(locale, 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, () => new Intl.DateTimeFormat(locale, options));\n}\n\nexport function pluralRules(\n locale: string,\n type: Intl.PluralRuleType = 'cardinal',\n): Intl.PluralRules {\n return cached(prCache, locale + type, () => new Intl.PluralRules(locale, { type }));\n}\n\nexport function relativeTimeFormat(locale: string): Intl.RelativeTimeFormat {\n return cached(rtfCache, locale, () => new Intl.RelativeTimeFormat(locale, { numeric: 'auto' }));\n}\n\nexport function listFormat(locale: string, type: Intl.ListFormatType): Intl.ListFormat {\n return cached(lfCache, locale + type, () => new Intl.ListFormat(locale, { type }));\n}\n\nexport function displayNames(locale: string): Intl.DisplayNames {\n return cached(dnCache, locale, () => new Intl.DisplayNames(locale, { 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 const value = ctx.params?.[node.name];\n if (value === undefined) {\n warnOnce(`missing param \"${node.name}\"${where(ctx)}`);\n return `{${node.name}}`;\n }\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 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 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\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 // 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(value);\n };\n\n switch (format) {\n case 'number':\n return numberFormat(locale).format(Number(value));\n case 'integer':\n return numberFormat(locale, { maximumFractionDigits: 0 }).format(Number(value));\n case 'percent':\n return numberFormat(locale, { style: 'percent' }).format(Number(value));\n case 'currency':\n if (!arg) return degrade('needs an argument like /USD');\n try {\n return numberFormat(locale, { style: 'currency', currency: arg }).format(Number(value));\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(Number(value));\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 if (typeof value === 'number') return numberFormat(locale).format(value);\n if (value instanceof Date) {\n // an invalid Date makes Intl throw: degrade like every other bad format input\n if (Number.isNaN(value.getTime())) {\n warnOnce(`an invalid Date${ctx ? where(ctx) : ''} renders as plain text`);\n return String(value);\n }\n return dateTimeFormat(locale).format(value);\n }\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 const loc = new Intl.Locale(locale) 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 const full = options.path ?? currentPath() ?? '/';\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 cut = full.search(/[?#]/);\n const path = stripBase(cut < 0 ? full : full.slice(0, cut), base);\n const rest = cut < 0 ? '' : full.slice(cut);\n\n const segments = path.split('/').filter(Boolean);\n if (segments[0] && matchPathSegment(segments[0], supported)) segments.shift();\n if (routing === 'prefix-all' || locale !== sourceLocale) segments.unshift(locale);\n const trailing = segments.length && path.endsWith('/') ? '/' : '';\n return `${base}/${segments.join('/')}${trailing}${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 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 && matchSupported(stored, supported);\n if (match) return match;\n }\n\n for (const lang of preferredLanguages()) {\n const match = matchSupported(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 = matchSupportedLoose(tag, supported);\n if (match) return match;\n }\n return fallback;\n}\n\n// case-insensitive matchSupported (headers arrive as en-US; configs as en)\nfunction matchSupportedLoose(lang: string, supported: string[]): string | undefined {\n for (const candidate of narrowLocales(lang.toLowerCase())) {\n const match = supported.find((s) => s.toLowerCase() === candidate);\n if (match) return match;\n }\n return undefined;\n}\n\n// per-request negotiation shared by SSR integrations: cookie value → Accept-Language → fallback\nexport interface RequestLocaleOptions {\n supported: string[];\n cookie?: string | null;\n header?: string | null;\n fallback?: string;\n}\n\nexport function resolveRequestLocale(options: RequestLocaleOptions): string {\n const { supported, cookie, header, fallback = supported[0] ?? 'en' } = options;\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'>,\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 supported: options.supported ?? [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 if (storageKey) getStorage()?.setItem(storageKey, locale);\n if (typeof document !== 'undefined') {\n document.documentElement.lang = locale;\n document.documentElement.dir = localeDirection(locale);\n }\n}\n\nfunction currentPath(): 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\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\nconst ICU_ARG = /\\{\\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\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(astCache.keys().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 but no ICU parser is loaded: pass icu to createVerbaly (the ' +\n 'compiler wires it when a catalog needs it, so this means it arrived after the build)',\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\nfunction findClose(input: string, open: number): number {\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] === '}') {\n i += 2;\n continue;\n }\n depth -= 1;\n if (depth === 0) return i;\n }\n i += 1;\n }\n return -1;\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] === '}') {\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 } from './format';\nimport { narrowLocales } from './locale';\nimport { parse } from './parse';\nimport { warnOnce } from './warn';\nimport type {\n DictionaryInput,\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 const dict: Record<string, Record<string, string>> = {};\n const listeners = new Set<() => void>();\n const formatters = options.formatters ?? {};\n const loaders = options.loaders ?? {};\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 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 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(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 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): void {\n dict[loc] = { ...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 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-]*)(\\/?)>/g;\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 if (selfClose) {\n 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\nconst UNSAFE_HREF = /^\\s*(javascript|data|vbscript):/i;\nconst URL_ATTR = /^(href|src|xlink:href|action|formaction)$/;\nconst BLOCKED_ATTR = /^(style|srcdoc)$/;\n\nexport function safeHref(href: string): string | undefined {\n if (UNSAFE_HREF.test(href)) {\n warnOnce(`blocked unsafe href: ${href}`);\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 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 const globalLinks = 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 ? (globalLinks ? { ...globalLinks, ...own } : 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 // pre-rendered html wins until this locale resolves: repainting it is the flash render kills\n let trustServerHtml = true;\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 function holdBack(key: string, current: string | null): 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 trustServerHtml && hit.from !== instance.locale;\n }\n\n function render(el: Element): void {\n const args = cachedArgs(el);\n const key = el.getAttribute(attr);\n if (key && !holdBack(key, el.textContent)) {\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))) 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): void {\n if (scope instanceof Element && scope.matches(selector)) render(scope);\n for (const el of scope.querySelectorAll(selector)) render(el);\n }\n\n warnOnLangMismatch(instance.locale);\n warnOnUnboundHead(root, selector);\n renderAll(root);\n // from here the dom is ours: a stale value from a previous locale must not survive a switch\n trustServerHtml = false;\n const unsubscribe = instance.subscribe(() => renderAll(root));\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);\n } else if (record.type === 'childList') {\n for (const node of record.addedNodes) {\n if (node instanceof Element) renderAll(node);\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}\", so bindDom is about to ` +\n `translate it away: read the url with localeFromPath when it carries the locale, and call ` +\n `persistLocale first when it does not`,\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 warnOnce(`invalid args JSON: ${raw}`);\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;;;ACJA,SAAgB,QACd,MACA,SAAS,IACT,MAA8B,CAAC,GACP;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,OAAO;AACT;AAEA,SAAS,QAAQ,OAAsC;CACrD,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;;ACrBA,MAAM,YAAY;AAElB,MAAM,0BAAU,IAAI,IAA+B;AACnD,MAAM,2BAAW,IAAI,IAAiC;AACtD,MAAM,0BAAU,IAAI,IAA8B;AAClD,MAAM,2BAAW,IAAI,IAAqC;AAC1D,MAAM,0BAAU,IAAI,IA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AAK,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"}
|
|
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\nexport function flatten(\n tree: MessageTree,\n prefix = '',\n out: 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","const 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>(cache: Map<string, T>, key: string, make: () => T): 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 hit = make();\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, () => new Intl.NumberFormat(locale, 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, () => new Intl.DateTimeFormat(locale, options));\n}\n\nexport function pluralRules(\n locale: string,\n type: Intl.PluralRuleType = 'cardinal',\n): Intl.PluralRules {\n return cached(prCache, locale + type, () => new Intl.PluralRules(locale, { type }));\n}\n\nexport function relativeTimeFormat(locale: string): Intl.RelativeTimeFormat {\n return cached(rtfCache, locale, () => new Intl.RelativeTimeFormat(locale, { numeric: 'auto' }));\n}\n\nexport function listFormat(locale: string, type: Intl.ListFormatType): Intl.ListFormat {\n return cached(lfCache, locale + type, () => new Intl.ListFormat(locale, { type }));\n}\n\nexport function displayNames(locale: string): Intl.DisplayNames {\n return cached(dnCache, locale, () => new Intl.DisplayNames(locale, { 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 const value = ctx.params?.[node.name];\n if (value === undefined) {\n warnOnce(`missing param \"${node.name}\"${where(ctx)}`);\n return `{${node.name}}`;\n }\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 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 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\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 // 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(value);\n };\n\n switch (format) {\n case 'number':\n return numberFormat(locale).format(Number(value));\n case 'integer':\n return numberFormat(locale, { maximumFractionDigits: 0 }).format(Number(value));\n case 'percent':\n return numberFormat(locale, { style: 'percent' }).format(Number(value));\n case 'currency':\n if (!arg) return degrade('needs an argument like /USD');\n try {\n return numberFormat(locale, { style: 'currency', currency: arg }).format(Number(value));\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(Number(value));\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 if (typeof value === 'number') return numberFormat(locale).format(value);\n if (value instanceof Date) {\n // an invalid Date makes Intl throw: degrade like every other bad format input\n if (Number.isNaN(value.getTime())) {\n warnOnce(`an invalid Date${ctx ? where(ctx) : ''} renders as plain text`);\n return String(value);\n }\n return dateTimeFormat(locale).format(value);\n }\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 const loc = new Intl.Locale(locale) 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 const full = options.path ?? currentPath() ?? '/';\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() ?? '/';\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 && matchSupported(stored, supported);\n if (match) return match;\n }\n\n for (const lang of preferredLanguages()) {\n const match = matchSupported(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 = matchSupportedLoose(tag, supported);\n if (match) return match;\n }\n return fallback;\n}\n\n// case-insensitive matchSupported (headers arrive as en-US; configs as en)\nfunction matchSupportedLoose(lang: string, supported: string[]): string | undefined {\n for (const candidate of narrowLocales(lang.toLowerCase())) {\n const match = supported.find((s) => s.toLowerCase() === candidate);\n if (match) return match;\n }\n return undefined;\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'>,\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 supported: options.supported ?? [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 if (storageKey) getStorage()?.setItem(storageKey, locale);\n if (typeof document !== 'undefined') {\n document.documentElement.lang = locale;\n document.documentElement.dir = localeDirection(locale);\n }\n}\n\nfunction currentPath(): 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\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\nconst ICU_ARG = /\\{\\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\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(astCache.keys().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 but no ICU parser is loaded: pass icu to createVerbaly (the ' +\n 'compiler wires it when a catalog needs it, so this means it arrived after the build)',\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\nfunction findClose(input: string, open: number): number {\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] === '}') {\n i += 2;\n continue;\n }\n depth -= 1;\n if (depth === 0) return i;\n }\n i += 1;\n }\n return -1;\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] === '}') {\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 } from './format';\nimport { narrowLocales } from './locale';\nimport { parse } from './parse';\nimport { warnOnce } from './warn';\nimport type {\n DictionaryInput,\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 const dict: Record<string, Record<string, string>> = {};\n const listeners = new Set<() => void>();\n const formatters = options.formatters ?? {};\n const loaders = options.loaders ?? {};\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 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 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(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 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): void {\n dict[loc] = { ...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 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-]*)(\\/?)>/g;\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 if (selfClose) {\n 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\nconst UNSAFE_HREF = /^\\s*(javascript|data|vbscript):/i;\nconst URL_ATTR = /^(href|src|xlink:href|action|formaction)$/;\nconst BLOCKED_ATTR = /^(style|srcdoc)$/;\n\nexport function safeHref(href: string): string | undefined {\n if (UNSAFE_HREF.test(href)) {\n warnOnce(`blocked unsafe href: ${href}`);\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 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 const globalLinks = 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 ? (globalLinks ? { ...globalLinks, ...own } : 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 // pre-rendered html wins until this locale resolves: repainting it is the flash render kills\n let trustServerHtml = true;\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 function holdBack(key: string, current: string | null): 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 trustServerHtml && hit.from !== instance.locale;\n }\n\n function render(el: Element): void {\n const args = cachedArgs(el);\n const key = el.getAttribute(attr);\n if (key && !holdBack(key, el.textContent)) {\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))) 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): void {\n if (scope instanceof Element && scope.matches(selector)) render(scope);\n for (const el of scope.querySelectorAll(selector)) render(el);\n }\n\n warnOnLangMismatch(instance.locale);\n warnOnUnboundHead(root, selector);\n renderAll(root);\n // from here the dom is ours: a stale value from a previous locale must not survive a switch\n trustServerHtml = false;\n const unsubscribe = instance.subscribe(() => renderAll(root));\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);\n } else if (record.type === 'childList') {\n for (const node of record.addedNodes) {\n if (node instanceof Element) renderAll(node);\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}\", so bindDom is about to ` +\n `translate it away: read the url with localeFromPath when it carries the locale, and call ` +\n `persistLocale first when it does not`,\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 warnOnce(`invalid args JSON: ${raw}`);\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;;;ACJA,SAAgB,QACd,MACA,SAAS,IACT,MAA8B,CAAC,GACP;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,OAAO;AACT;AAEA,SAAS,QAAQ,OA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
56
56
|
});
|
|
57
57
|
declare function localePath(locale: string, options: LocalePathOptions): string;
|
|
58
58
|
declare function localeFromPath(options: LocaleFromPathOptions): string | undefined;
|
|
59
|
+
interface StripLocalePathOptions {
|
|
60
|
+
supported: string[];
|
|
61
|
+
path?: string;
|
|
62
|
+
base?: string;
|
|
63
|
+
}
|
|
64
|
+
declare function stripLocalePath(options: StripLocalePathOptions): string;
|
|
65
|
+
interface AlternateLink {
|
|
66
|
+
hreflang: string;
|
|
67
|
+
href: string;
|
|
68
|
+
}
|
|
69
|
+
interface AlternateLinksOptions {
|
|
70
|
+
supported: string[];
|
|
71
|
+
sourceLocale: string;
|
|
72
|
+
path: string;
|
|
73
|
+
routing?: Routing;
|
|
74
|
+
base?: string;
|
|
75
|
+
baseUrl?: string;
|
|
76
|
+
}
|
|
77
|
+
declare function alternateLinks(options: AlternateLinksOptions): AlternateLink[];
|
|
59
78
|
declare function resolveLocale(options: ResolveLocaleOptions): string;
|
|
60
79
|
declare function negotiateLocale(header: string | null | undefined, supported: string[], fallback?: string): string;
|
|
61
80
|
interface RequestLocaleOptions {
|
|
62
81
|
supported: string[];
|
|
82
|
+
path?: string | null;
|
|
83
|
+
routing?: Routing;
|
|
84
|
+
base?: string;
|
|
63
85
|
cookie?: string | null;
|
|
64
86
|
header?: string | null;
|
|
65
87
|
fallback?: string;
|
|
@@ -94,5 +116,8 @@ type TagNode = string | {
|
|
|
94
116
|
};
|
|
95
117
|
declare function parseTags(text: string): TagNode[];
|
|
96
118
|
//#endregion
|
|
97
|
-
|
|
119
|
+
//#region src/warn.d.ts
|
|
120
|
+
declare function warnOnce(message: string): void;
|
|
121
|
+
//#endregion
|
|
122
|
+
export { type AlternateLink, type AlternateLinksOptions, type BindDomOptions, type DictionaryInput, type FlatKeys, type FormatInfo, type Formatter, type IcuParser, type KeysOf, LOCALE_STORAGE_KEY, type LocaleFromPathOptions, type LocaleLoader, type LocalePathOptions, type MessageAt, type MessageNode, type MessageTree, type MessageValue, type ParamNames, type ParamNode, type Params, RICH_TAGS, type RequestLocaleOptions, type ResolveInfo, type ResolveLocaleOptions, type ResolveStatus, type RichLink, type Routing, type StripLocalePathOptions, type SwitchLocaleOptions, type TArgs, type TFunction, type TagNode, VOID_TAGS, type Verbaly, type VerbalyOptions, alternateLinks, bindDom, createVerbaly, flatten, localeDirection, localeFromPath, localeName, localePath, negotiateLocale, normalizeLink, parse, parseIcu, parseTags, persistLocale, relativeFormatter, resolveLocale, resolveRequestLocale, safeAttribute, safeHref, stripLocalePath, switchLocale, warnOnce };
|
|
98
123
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -56,10 +56,32 @@ type LocalePathOptions = LocalePathBase & ({
|
|
|
56
56
|
});
|
|
57
57
|
declare function localePath(locale: string, options: LocalePathOptions): string;
|
|
58
58
|
declare function localeFromPath(options: LocaleFromPathOptions): string | undefined;
|
|
59
|
+
interface StripLocalePathOptions {
|
|
60
|
+
supported: string[];
|
|
61
|
+
path?: string;
|
|
62
|
+
base?: string;
|
|
63
|
+
}
|
|
64
|
+
declare function stripLocalePath(options: StripLocalePathOptions): string;
|
|
65
|
+
interface AlternateLink {
|
|
66
|
+
hreflang: string;
|
|
67
|
+
href: string;
|
|
68
|
+
}
|
|
69
|
+
interface AlternateLinksOptions {
|
|
70
|
+
supported: string[];
|
|
71
|
+
sourceLocale: string;
|
|
72
|
+
path: string;
|
|
73
|
+
routing?: Routing;
|
|
74
|
+
base?: string;
|
|
75
|
+
baseUrl?: string;
|
|
76
|
+
}
|
|
77
|
+
declare function alternateLinks(options: AlternateLinksOptions): AlternateLink[];
|
|
59
78
|
declare function resolveLocale(options: ResolveLocaleOptions): string;
|
|
60
79
|
declare function negotiateLocale(header: string | null | undefined, supported: string[], fallback?: string): string;
|
|
61
80
|
interface RequestLocaleOptions {
|
|
62
81
|
supported: string[];
|
|
82
|
+
path?: string | null;
|
|
83
|
+
routing?: Routing;
|
|
84
|
+
base?: string;
|
|
63
85
|
cookie?: string | null;
|
|
64
86
|
header?: string | null;
|
|
65
87
|
fallback?: string;
|
|
@@ -94,5 +116,8 @@ type TagNode = string | {
|
|
|
94
116
|
};
|
|
95
117
|
declare function parseTags(text: string): TagNode[];
|
|
96
118
|
//#endregion
|
|
97
|
-
|
|
119
|
+
//#region src/warn.d.ts
|
|
120
|
+
declare function warnOnce(message: string): void;
|
|
121
|
+
//#endregion
|
|
122
|
+
export { type AlternateLink, type AlternateLinksOptions, type BindDomOptions, type DictionaryInput, type FlatKeys, type FormatInfo, type Formatter, type IcuParser, type KeysOf, LOCALE_STORAGE_KEY, type LocaleFromPathOptions, type LocaleLoader, type LocalePathOptions, type MessageAt, type MessageNode, type MessageTree, type MessageValue, type ParamNames, type ParamNode, type Params, RICH_TAGS, type RequestLocaleOptions, type ResolveInfo, type ResolveLocaleOptions, type ResolveStatus, type RichLink, type Routing, type StripLocalePathOptions, type SwitchLocaleOptions, type TArgs, type TFunction, type TagNode, VOID_TAGS, type Verbaly, type VerbalyOptions, alternateLinks, bindDom, createVerbaly, flatten, localeDirection, localeFromPath, localeName, localePath, negotiateLocale, normalizeLink, parse, parseIcu, parseTags, persistLocale, relativeFormatter, resolveLocale, resolveRequestLocale, safeAttribute, safeHref, stripLocalePath, switchLocale, warnOnce };
|
|
98
123
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -217,14 +217,24 @@ function localePath(locale, options) {
|
|
|
217
217
|
const sourceLocale = options.sourceLocale;
|
|
218
218
|
if (routing === "prefix-except-source" && sourceLocale === void 0) warnOnce("localePath needs sourceLocale: \"prefix-except-source\" prefixed every locale");
|
|
219
219
|
const base = normalizeBase(options.base);
|
|
220
|
+
const parts = splitLocalePath(full, supported, base);
|
|
221
|
+
if (routing === "prefix-all" || locale !== sourceLocale) parts.segments.unshift(locale);
|
|
222
|
+
return joinLocalePath(base, parts);
|
|
223
|
+
}
|
|
224
|
+
function splitLocalePath(full, supported, base) {
|
|
220
225
|
const cut = full.search(/[?#]/);
|
|
221
226
|
const path = stripBase(cut < 0 ? full : full.slice(0, cut), base);
|
|
222
|
-
const rest = cut < 0 ? "" : full.slice(cut);
|
|
223
227
|
const segments = path.split("/").filter(Boolean);
|
|
224
228
|
if (segments[0] && matchPathSegment(segments[0], supported)) segments.shift();
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
229
|
+
return {
|
|
230
|
+
segments,
|
|
231
|
+
rest: cut < 0 ? "" : full.slice(cut),
|
|
232
|
+
trailingSlash: path.endsWith("/")
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function joinLocalePath(base, parts) {
|
|
236
|
+
const trailing = parts.segments.length && parts.trailingSlash ? "/" : "";
|
|
237
|
+
return `${base}/${parts.segments.join("/")}${trailing}${parts.rest}`;
|
|
228
238
|
}
|
|
229
239
|
function localeFromPath(options) {
|
|
230
240
|
const path = options.path ?? currentPath();
|
|
@@ -232,6 +242,38 @@ function localeFromPath(options) {
|
|
|
232
242
|
const segment = stripBase(path, normalizeBase(options.base)).split("/").find(Boolean);
|
|
233
243
|
return segment ? matchPathSegment(segment, options.supported) : void 0;
|
|
234
244
|
}
|
|
245
|
+
function stripLocalePath(options) {
|
|
246
|
+
const full = options.path ?? currentPath() ?? "/";
|
|
247
|
+
const base = normalizeBase(options.base);
|
|
248
|
+
return joinLocalePath(base, splitLocalePath(full, options.supported, base));
|
|
249
|
+
}
|
|
250
|
+
function alternateLinks(options) {
|
|
251
|
+
const { supported, sourceLocale, path, baseUrl = "" } = options;
|
|
252
|
+
const routing = options.routing ?? "prefix-except-source";
|
|
253
|
+
if (routing === "no-prefix") return [];
|
|
254
|
+
const base = options.base;
|
|
255
|
+
const href = (locale) => baseUrl + localePath(locale, routing === "prefix-all" ? {
|
|
256
|
+
supported,
|
|
257
|
+
routing,
|
|
258
|
+
path,
|
|
259
|
+
base
|
|
260
|
+
} : {
|
|
261
|
+
supported,
|
|
262
|
+
routing,
|
|
263
|
+
sourceLocale,
|
|
264
|
+
path,
|
|
265
|
+
base
|
|
266
|
+
});
|
|
267
|
+
const links = supported.map((locale) => ({
|
|
268
|
+
hreflang: locale,
|
|
269
|
+
href: href(locale)
|
|
270
|
+
}));
|
|
271
|
+
links.push({
|
|
272
|
+
hreflang: "x-default",
|
|
273
|
+
href: href(sourceLocale)
|
|
274
|
+
});
|
|
275
|
+
return links;
|
|
276
|
+
}
|
|
235
277
|
function resolveLocale(options) {
|
|
236
278
|
const { supported, fallback = supported[0] ?? "en", storageKey = LOCALE_STORAGE_KEY } = options;
|
|
237
279
|
if (options.path !== false) {
|
|
@@ -305,7 +347,16 @@ function matchSupportedLoose(lang, supported) {
|
|
|
305
347
|
}
|
|
306
348
|
}
|
|
307
349
|
function resolveRequestLocale(options) {
|
|
308
|
-
const { supported, cookie, header, fallback = supported[0] ?? "en" } = options;
|
|
350
|
+
const { supported, path, routing, cookie, header, fallback = supported[0] ?? "en" } = options;
|
|
351
|
+
if (routing !== void 0 && routing !== "no-prefix" && path != null) {
|
|
352
|
+
const match = localeFromPath({
|
|
353
|
+
supported,
|
|
354
|
+
path,
|
|
355
|
+
base: options.base
|
|
356
|
+
});
|
|
357
|
+
if (match) return match;
|
|
358
|
+
if (routing === "prefix-except-source") return fallback;
|
|
359
|
+
}
|
|
309
360
|
if (cookie) {
|
|
310
361
|
const match = negotiateLocale(cookie, supported, "");
|
|
311
362
|
if (match) return match;
|
|
@@ -1116,6 +1167,6 @@ const relativeFormatter = (value, locale, arg, info) => {
|
|
|
1116
1167
|
}
|
|
1117
1168
|
};
|
|
1118
1169
|
//#endregion
|
|
1119
|
-
export { LOCALE_STORAGE_KEY, RICH_TAGS, VOID_TAGS, bindDom, createVerbaly, flatten, localeDirection, localeFromPath, localeName, localePath, negotiateLocale, normalizeLink, parse, parseIcu, parseTags, persistLocale, relativeFormatter, resolveLocale, resolveRequestLocale, safeAttribute, safeHref, switchLocale };
|
|
1170
|
+
export { LOCALE_STORAGE_KEY, RICH_TAGS, VOID_TAGS, alternateLinks, bindDom, createVerbaly, flatten, localeDirection, localeFromPath, localeName, localePath, negotiateLocale, normalizeLink, parse, parseIcu, parseTags, persistLocale, relativeFormatter, resolveLocale, resolveRequestLocale, safeAttribute, safeHref, stripLocalePath, switchLocale, warnOnce };
|
|
1120
1171
|
|
|
1121
1172
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\nexport function flatten(\n tree: MessageTree,\n prefix = '',\n out: 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","const 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>(cache: Map<string, T>, key: string, make: () => T): 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 hit = make();\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, () => new Intl.NumberFormat(locale, 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, () => new Intl.DateTimeFormat(locale, options));\n}\n\nexport function pluralRules(\n locale: string,\n type: Intl.PluralRuleType = 'cardinal',\n): Intl.PluralRules {\n return cached(prCache, locale + type, () => new Intl.PluralRules(locale, { type }));\n}\n\nexport function relativeTimeFormat(locale: string): Intl.RelativeTimeFormat {\n return cached(rtfCache, locale, () => new Intl.RelativeTimeFormat(locale, { numeric: 'auto' }));\n}\n\nexport function listFormat(locale: string, type: Intl.ListFormatType): Intl.ListFormat {\n return cached(lfCache, locale + type, () => new Intl.ListFormat(locale, { type }));\n}\n\nexport function displayNames(locale: string): Intl.DisplayNames {\n return cached(dnCache, locale, () => new Intl.DisplayNames(locale, { 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 const value = ctx.params?.[node.name];\n if (value === undefined) {\n warnOnce(`missing param \"${node.name}\"${where(ctx)}`);\n return `{${node.name}}`;\n }\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 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 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\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 // 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(value);\n };\n\n switch (format) {\n case 'number':\n return numberFormat(locale).format(Number(value));\n case 'integer':\n return numberFormat(locale, { maximumFractionDigits: 0 }).format(Number(value));\n case 'percent':\n return numberFormat(locale, { style: 'percent' }).format(Number(value));\n case 'currency':\n if (!arg) return degrade('needs an argument like /USD');\n try {\n return numberFormat(locale, { style: 'currency', currency: arg }).format(Number(value));\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(Number(value));\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 if (typeof value === 'number') return numberFormat(locale).format(value);\n if (value instanceof Date) {\n // an invalid Date makes Intl throw: degrade like every other bad format input\n if (Number.isNaN(value.getTime())) {\n warnOnce(`an invalid Date${ctx ? where(ctx) : ''} renders as plain text`);\n return String(value);\n }\n return dateTimeFormat(locale).format(value);\n }\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 const loc = new Intl.Locale(locale) 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 const full = options.path ?? currentPath() ?? '/';\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 cut = full.search(/[?#]/);\n const path = stripBase(cut < 0 ? full : full.slice(0, cut), base);\n const rest = cut < 0 ? '' : full.slice(cut);\n\n const segments = path.split('/').filter(Boolean);\n if (segments[0] && matchPathSegment(segments[0], supported)) segments.shift();\n if (routing === 'prefix-all' || locale !== sourceLocale) segments.unshift(locale);\n const trailing = segments.length && path.endsWith('/') ? '/' : '';\n return `${base}/${segments.join('/')}${trailing}${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 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 && matchSupported(stored, supported);\n if (match) return match;\n }\n\n for (const lang of preferredLanguages()) {\n const match = matchSupported(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 = matchSupportedLoose(tag, supported);\n if (match) return match;\n }\n return fallback;\n}\n\n// case-insensitive matchSupported (headers arrive as en-US; configs as en)\nfunction matchSupportedLoose(lang: string, supported: string[]): string | undefined {\n for (const candidate of narrowLocales(lang.toLowerCase())) {\n const match = supported.find((s) => s.toLowerCase() === candidate);\n if (match) return match;\n }\n return undefined;\n}\n\n// per-request negotiation shared by SSR integrations: cookie value → Accept-Language → fallback\nexport interface RequestLocaleOptions {\n supported: string[];\n cookie?: string | null;\n header?: string | null;\n fallback?: string;\n}\n\nexport function resolveRequestLocale(options: RequestLocaleOptions): string {\n const { supported, cookie, header, fallback = supported[0] ?? 'en' } = options;\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'>,\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 supported: options.supported ?? [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 if (storageKey) getStorage()?.setItem(storageKey, locale);\n if (typeof document !== 'undefined') {\n document.documentElement.lang = locale;\n document.documentElement.dir = localeDirection(locale);\n }\n}\n\nfunction currentPath(): 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\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\nconst ICU_ARG = /\\{\\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\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(astCache.keys().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 but no ICU parser is loaded: pass icu to createVerbaly (the ' +\n 'compiler wires it when a catalog needs it, so this means it arrived after the build)',\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\nfunction findClose(input: string, open: number): number {\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] === '}') {\n i += 2;\n continue;\n }\n depth -= 1;\n if (depth === 0) return i;\n }\n i += 1;\n }\n return -1;\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] === '}') {\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 } from './format';\nimport { narrowLocales } from './locale';\nimport { parse } from './parse';\nimport { warnOnce } from './warn';\nimport type {\n DictionaryInput,\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 const dict: Record<string, Record<string, string>> = {};\n const listeners = new Set<() => void>();\n const formatters = options.formatters ?? {};\n const loaders = options.loaders ?? {};\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 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 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(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 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): void {\n dict[loc] = { ...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 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-]*)(\\/?)>/g;\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 if (selfClose) {\n 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\nconst UNSAFE_HREF = /^\\s*(javascript|data|vbscript):/i;\nconst URL_ATTR = /^(href|src|xlink:href|action|formaction)$/;\nconst BLOCKED_ATTR = /^(style|srcdoc)$/;\n\nexport function safeHref(href: string): string | undefined {\n if (UNSAFE_HREF.test(href)) {\n warnOnce(`blocked unsafe href: ${href}`);\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 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 const globalLinks = 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 ? (globalLinks ? { ...globalLinks, ...own } : 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 // pre-rendered html wins until this locale resolves: repainting it is the flash render kills\n let trustServerHtml = true;\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 function holdBack(key: string, current: string | null): 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 trustServerHtml && hit.from !== instance.locale;\n }\n\n function render(el: Element): void {\n const args = cachedArgs(el);\n const key = el.getAttribute(attr);\n if (key && !holdBack(key, el.textContent)) {\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))) 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): void {\n if (scope instanceof Element && scope.matches(selector)) render(scope);\n for (const el of scope.querySelectorAll(selector)) render(el);\n }\n\n warnOnLangMismatch(instance.locale);\n warnOnUnboundHead(root, selector);\n renderAll(root);\n // from here the dom is ours: a stale value from a previous locale must not survive a switch\n trustServerHtml = false;\n const unsubscribe = instance.subscribe(() => renderAll(root));\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);\n } else if (record.type === 'childList') {\n for (const node of record.addedNodes) {\n if (node instanceof Element) renderAll(node);\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}\", so bindDom is about to ` +\n `translate it away: read the url with localeFromPath when it carries the locale, and call ` +\n `persistLocale first when it does not`,\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 warnOnce(`invalid args JSON: ${raw}`);\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,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,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"}
|
|
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\nexport function flatten(\n tree: MessageTree,\n prefix = '',\n out: 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","const 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>(cache: Map<string, T>, key: string, make: () => T): 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 hit = make();\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, () => new Intl.NumberFormat(locale, 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, () => new Intl.DateTimeFormat(locale, options));\n}\n\nexport function pluralRules(\n locale: string,\n type: Intl.PluralRuleType = 'cardinal',\n): Intl.PluralRules {\n return cached(prCache, locale + type, () => new Intl.PluralRules(locale, { type }));\n}\n\nexport function relativeTimeFormat(locale: string): Intl.RelativeTimeFormat {\n return cached(rtfCache, locale, () => new Intl.RelativeTimeFormat(locale, { numeric: 'auto' }));\n}\n\nexport function listFormat(locale: string, type: Intl.ListFormatType): Intl.ListFormat {\n return cached(lfCache, locale + type, () => new Intl.ListFormat(locale, { type }));\n}\n\nexport function displayNames(locale: string): Intl.DisplayNames {\n return cached(dnCache, locale, () => new Intl.DisplayNames(locale, { 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 const value = ctx.params?.[node.name];\n if (value === undefined) {\n warnOnce(`missing param \"${node.name}\"${where(ctx)}`);\n return `{${node.name}}`;\n }\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 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 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\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 // 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(value);\n };\n\n switch (format) {\n case 'number':\n return numberFormat(locale).format(Number(value));\n case 'integer':\n return numberFormat(locale, { maximumFractionDigits: 0 }).format(Number(value));\n case 'percent':\n return numberFormat(locale, { style: 'percent' }).format(Number(value));\n case 'currency':\n if (!arg) return degrade('needs an argument like /USD');\n try {\n return numberFormat(locale, { style: 'currency', currency: arg }).format(Number(value));\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(Number(value));\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 if (typeof value === 'number') return numberFormat(locale).format(value);\n if (value instanceof Date) {\n // an invalid Date makes Intl throw: degrade like every other bad format input\n if (Number.isNaN(value.getTime())) {\n warnOnce(`an invalid Date${ctx ? where(ctx) : ''} renders as plain text`);\n return String(value);\n }\n return dateTimeFormat(locale).format(value);\n }\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 const loc = new Intl.Locale(locale) 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 const full = options.path ?? currentPath() ?? '/';\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() ?? '/';\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 && matchSupported(stored, supported);\n if (match) return match;\n }\n\n for (const lang of preferredLanguages()) {\n const match = matchSupported(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 = matchSupportedLoose(tag, supported);\n if (match) return match;\n }\n return fallback;\n}\n\n// case-insensitive matchSupported (headers arrive as en-US; configs as en)\nfunction matchSupportedLoose(lang: string, supported: string[]): string | undefined {\n for (const candidate of narrowLocales(lang.toLowerCase())) {\n const match = supported.find((s) => s.toLowerCase() === candidate);\n if (match) return match;\n }\n return undefined;\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'>,\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 supported: options.supported ?? [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 if (storageKey) getStorage()?.setItem(storageKey, locale);\n if (typeof document !== 'undefined') {\n document.documentElement.lang = locale;\n document.documentElement.dir = localeDirection(locale);\n }\n}\n\nfunction currentPath(): 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\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\nconst ICU_ARG = /\\{\\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\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(astCache.keys().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 but no ICU parser is loaded: pass icu to createVerbaly (the ' +\n 'compiler wires it when a catalog needs it, so this means it arrived after the build)',\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\nfunction findClose(input: string, open: number): number {\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] === '}') {\n i += 2;\n continue;\n }\n depth -= 1;\n if (depth === 0) return i;\n }\n i += 1;\n }\n return -1;\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] === '}') {\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 } from './format';\nimport { narrowLocales } from './locale';\nimport { parse } from './parse';\nimport { warnOnce } from './warn';\nimport type {\n DictionaryInput,\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 const dict: Record<string, Record<string, string>> = {};\n const listeners = new Set<() => void>();\n const formatters = options.formatters ?? {};\n const loaders = options.loaders ?? {};\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 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 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(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 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): void {\n dict[loc] = { ...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 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-]*)(\\/?)>/g;\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 if (selfClose) {\n 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\nconst UNSAFE_HREF = /^\\s*(javascript|data|vbscript):/i;\nconst URL_ATTR = /^(href|src|xlink:href|action|formaction)$/;\nconst BLOCKED_ATTR = /^(style|srcdoc)$/;\n\nexport function safeHref(href: string): string | undefined {\n if (UNSAFE_HREF.test(href)) {\n warnOnce(`blocked unsafe href: ${href}`);\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 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 const globalLinks = 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 ? (globalLinks ? { ...globalLinks, ...own } : 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 // pre-rendered html wins until this locale resolves: repainting it is the flash render kills\n let trustServerHtml = true;\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 function holdBack(key: string, current: string | null): 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 trustServerHtml && hit.from !== instance.locale;\n }\n\n function render(el: Element): void {\n const args = cachedArgs(el);\n const key = el.getAttribute(attr);\n if (key && !holdBack(key, el.textContent)) {\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))) 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): void {\n if (scope instanceof Element && scope.matches(selector)) render(scope);\n for (const el of scope.querySelectorAll(selector)) render(el);\n }\n\n warnOnLangMismatch(instance.locale);\n warnOnUnboundHead(root, selector);\n renderAll(root);\n // from here the dom is ours: a stale value from a previous locale must not survive a switch\n trustServerHtml = false;\n const unsubscribe = instance.subscribe(() => renderAll(root));\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);\n } else if (record.type === 'childList') {\n for (const node of record.addedNodes) {\n if (node instanceof Element) renderAll(node);\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}\", so bindDom is about to ` +\n `translate it away: read the url with localeFromPath when it carries the locale, and call ` +\n `persistLocale first when it does not`,\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 warnOnce(`invalid args JSON: ${raw}`);\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;;;ACJA,SAAgB,QACd,MACA,SAAS,IACT,MAA8B,CAAC,GACP;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,OAAO;AACT;AAEA,SAAS,QAAQ,OAAsC;CACrD,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;;ACrBA,MAAM,YAAY;AAElB,MAAM,0BAAU,IAAI,IAA+B;AACnD,MAAM,2BAAW,IAAI,IAAiC;AACtD,MAAM,0BAAU,IAAI,IAA8B;AAClD,MAAM,2BAAW,IAAI,IAAqC;AAC1D,MAAM,0BAAU,IAAI,IAA6B;AACjD,MAAM,0BAAU,IAAI,IAA+B;AAEnD,SAAS,OAAU,OAAuB,KAAa,MAAkB;CACvE,IAAI,MAAM,MAAM,IAAI,GAAG;CACvB,IAAI,CAAC,KAAK;EACR,IAAI,MAAM,QAAQ,WAAW,MAAM,OAAO,MAAM,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAe;EAC7E,MAAM,KAAK;EACX,MAAM,IAAI,KAAK,GAAG;CACpB;CACA,OAAO;AACT;AAEA,SAAgB,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B,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "verbaly",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.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.9.0",
|
|
72
|
-
"happy-dom": "^20.12.
|
|
73
|
-
"i18next": "^26.4.
|
|
72
|
+
"happy-dom": "^20.12.1",
|
|
73
|
+
"i18next": "^26.4.1"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"build": "tsdown",
|