@fluenti/solid 0.3.4 → 0.4.0-rc.1

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.
Files changed (42) hide show
  1. package/dist/components-entry.cjs +2 -0
  2. package/dist/components-entry.cjs.map +1 -0
  3. package/dist/components-entry.d.ts +12 -0
  4. package/dist/components-entry.d.ts.map +1 -0
  5. package/dist/components-entry.js +283 -0
  6. package/dist/components-entry.js.map +1 -0
  7. package/dist/context.d.ts +23 -1
  8. package/dist/context.d.ts.map +1 -1
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.ts +1 -6
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +4 -414
  14. package/dist/index.js.map +1 -1
  15. package/dist/plural.d.ts +9 -0
  16. package/dist/plural.d.ts.map +1 -1
  17. package/dist/provider.d.ts +19 -1
  18. package/dist/provider.d.ts.map +1 -1
  19. package/dist/rich-dom.d.ts.map +1 -1
  20. package/dist/select.d.ts +15 -0
  21. package/dist/select.d.ts.map +1 -1
  22. package/dist/solid-runtime.d.ts.map +1 -1
  23. package/dist/trans.d.ts.map +1 -1
  24. package/dist/use-i18n-DPb98Dw1.js +201 -0
  25. package/dist/use-i18n-DPb98Dw1.js.map +1 -0
  26. package/dist/use-i18n-oAO3vYS7.cjs +2 -0
  27. package/dist/use-i18n-oAO3vYS7.cjs.map +1 -0
  28. package/dist/vite-plugin.cjs +1 -1
  29. package/dist/vite-plugin.cjs.map +1 -1
  30. package/dist/vite-plugin.js +0 -1
  31. package/dist/vite-plugin.js.map +1 -1
  32. package/llms.txt +44 -0
  33. package/package.json +18 -3
  34. package/src/components-entry.ts +13 -0
  35. package/src/context.ts +110 -148
  36. package/src/index.ts +5 -6
  37. package/src/plural.tsx +9 -0
  38. package/src/provider.tsx +19 -1
  39. package/src/rich-dom.tsx +10 -0
  40. package/src/select.tsx +15 -0
  41. package/src/solid-runtime.ts +0 -1
  42. package/src/trans.tsx +8 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["createContext","ParentComponent","createFluentiContext","FluentiConfig","FluentiContext","I18nCtx","I18nProvider","props","ctx","_$createComponent","Provider","value","children","JSX","isNodeLike","value","Node","resolveValue","length","offsetIndices","extractMessage","message","components","visit","node","resolved","undefined","Array","isArray","child","String","nodeType","TEXT_NODE","textContent","DOCUMENT_FRAGMENT_NODE","from","childNodes","idx","inner","push","Element","cloneNode","appendChild","parent","entry","document","createTextNode","reconstruct","translated","combinedRe","result","lastIndex","match","RegExpExecArray","exec","index","slice","Number","isSelfClosing","template","clone","serializeRichForms","keys","T","forms","Partial","Record","messages","key","extracted","Object","entries","includes","Dynamic","children","resolveChildren","createMemo","Component","JSX","useI18n","extractMessage","extractDomMessage","reconstruct","reconstructDomMessage","RichComponent","Element","FluentiTransProps","id","context","comment","tag","message","components","Record","__message","__components","TextToken","type","value","TagToken","name","Token","parseTokens","input","tokens","pos","length","openIdx","indexOf","push","slice","selfCloseMatch","match","openMatch","tagName","contentStart","innerEnd","findClosingTag","innerContent","closingTag","startPos","openTag","closeTag","depth","nextOpen","nextClose","renderTokens","elements","map","token","Comp","undefined","_$createComponent","component","Trans","props","t","resolvedChildren","raw","msg","comps","translated","toArray","extracted","result","Array","isArray","Dynamic","Component","JSX","hashMessage","buildICUPluralMessage","PLURAL_CATEGORIES","PluralCategory","useI18n","reconstruct","serializeRichForms","FluentiPluralProps","value","id","context","comment","offset","zero","Element","one","two","few","many","other","tag","Plural","props","t","resolveProp","val","resolvedValues","Partial","Record","cat","resolved","undefined","messages","components","icuMessage","translated","message","count","result","length","_$createComponent","component","children","Component","JSX","Dynamic","hashMessage","buildICUSelectMessage","normalizeSelectForms","useI18n","reconstruct","serializeRichForms","FluentiSelectProps","value","id","context","comment","other","Element","options","Record","tag","key","SelectComp","props","t","content","forms","undefined","Object","fromEntries","entries","filter","includes","orderedKeys","keys","const","messages","components","normalized","map","translated","message","valueMap","length","_$createComponent","component","children","_$memo","useI18n","DateTimeProps","value","Date","format","FluentiDateTimeProps","DateTime","props","d","_$memo","useI18n","NumberProps","value","format","FluentiNumberFormatProps","NumberFormat","props","n","_$memo"],"sources":["../src/context.ts","../src/provider.tsx","../src/use-i18n.ts","../src/compile-time-t.ts","../src/rich-dom.tsx","../src/trans.tsx","../src/plural.tsx","../src/select.tsx","../src/components/DateTime.tsx","../src/components/NumberFormat.tsx"],"sourcesContent":["import { createSignal, type Accessor } from 'solid-js'\nimport { createDiagnostics, formatDate, formatNumber } from '@fluenti/core'\nimport type { FluentiCoreConfig, Locale, LocalizedString, Messages, CompiledMessage, MessageDescriptor, DateFormatOptions, NumberFormatOptions, DiagnosticsConfig } from '@fluenti/core'\nimport { interpolate as coreInterpolate, buildICUMessage, resolveDescriptorId } from '@fluenti/core/internal'\n\n/** Chunk loader for lazy locale loading */\nexport type ChunkLoader = (\n locale: string,\n) => Promise<Record<string, CompiledMessage> | { default: Record<string, CompiledMessage> }>\n\ninterface SplitRuntimeModule {\n __switchLocale?: (locale: string) => Promise<void>\n __preloadLocale?: (locale: string) => Promise<void>\n}\n\nconst SPLIT_RUNTIME_KEY = Symbol.for('fluenti.runtime.solid.v1')\n\nfunction getSplitRuntimeModule(): SplitRuntimeModule | null {\n const runtime = (globalThis as Record<PropertyKey, unknown>)[SPLIT_RUNTIME_KEY]\n return typeof runtime === 'object' && runtime !== null\n ? runtime as SplitRuntimeModule\n : null\n}\n\nfunction resolveChunkMessages(\n loaded: Record<string, CompiledMessage> | { default: Record<string, CompiledMessage> },\n): Record<string, CompiledMessage> {\n return typeof loaded === 'object' && loaded !== null && 'default' in loaded\n ? (loaded as { default: Record<string, CompiledMessage> }).default\n : loaded\n}\n\n/** Extended config with lazy locale loading support */\nexport interface FluentiConfig extends FluentiCoreConfig {\n /** Async chunk loader for lazy locale loading */\n chunkLoader?: ChunkLoader\n /** Enable lazy locale loading through chunkLoader */\n lazyLocaleLoading?: boolean\n /** Locale-specific fallback chains */\n fallbackChain?: Record<string, Locale[]>\n /** Named date format styles */\n dateFormats?: DateFormatOptions\n /** Named number format styles */\n numberFormats?: NumberFormatOptions\n /** Runtime diagnostics configuration */\n diagnostics?: DiagnosticsConfig\n}\n\n/** Reactive i18n context holding locale signal and translation utilities */\nexport interface FluentiContext {\n /** Reactive accessor for the current locale */\n locale(): Locale\n /** Set the active locale (async when lazy locale loading is enabled) */\n setLocale(locale: Locale): Promise<void>\n /** Translate a message by id with optional interpolation values */\n t(id: string | MessageDescriptor, values?: Record<string, unknown>): LocalizedString\n /** Tagged template form: t`Hello ${name}` */\n t(strings: TemplateStringsArray, ...exprs: unknown[]): LocalizedString\n /** Merge additional messages into a locale catalog at runtime */\n loadMessages(locale: Locale, messages: Messages): void\n /** Return all locale codes that have loaded messages */\n getLocales(): Locale[]\n /** Format a date value for the current locale */\n d(value: Date | number, style?: string): LocalizedString\n /** Format a number value for the current locale */\n n(value: number, style?: string): LocalizedString\n /** Format an ICU message string directly (no catalog lookup) */\n format(message: string, values?: Record<string, unknown>): LocalizedString\n /** Whether a locale chunk is currently being loaded */\n isLoading: Accessor<boolean>\n /** Set of locales whose messages have been loaded */\n loadedLocales: Accessor<Set<string>>\n /** Preload a locale in the background without switching to it */\n preloadLocale(locale: string): void\n /** Check if a translation key exists for the given or current locale */\n te(key: string, loc?: string): boolean\n /** Get the raw compiled message for a key without interpolation */\n tm(key: string, loc?: string): CompiledMessage | undefined\n}\n\n/**\n * Create a reactive i18n context backed by Solid signals.\n *\n * The returned `t()` reads the internal `locale()` signal, so any\n * Solid computation that calls `t()` will re-run when the locale changes.\n */\nexport function createFluentiContext(config: FluentiCoreConfig | FluentiConfig): FluentiContext {\n const [locale, setLocaleSignal] = createSignal<Locale>(config.locale)\n const [isLoading, setIsLoading] = createSignal(false)\n const loadedLocalesSet = new Set<string>([config.locale])\n const [loadedLocales, setLoadedLocales] = createSignal(new Set(loadedLocalesSet))\n const messages: Record<string, Messages> = { ...config.messages }\n const i18nConfig = config as FluentiConfig\n const diagnostics = i18nConfig.diagnostics ? createDiagnostics(i18nConfig.diagnostics) : undefined\n const lazyLocaleLoading = i18nConfig.lazyLocaleLoading\n ?? (config as FluentiConfig & { splitting?: boolean }).splitting\n ?? false\n\n function lookupCatalog(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString | undefined {\n const catalog = messages[loc]\n if (!catalog) {\n return undefined\n }\n\n const msg = catalog[id]\n if (msg === undefined) {\n return undefined\n }\n\n if (typeof msg === 'function') {\n return msg(values) as LocalizedString\n }\n\n if (typeof msg === 'string' && values) {\n return coreInterpolate(msg, values, loc) as LocalizedString\n }\n\n return String(msg) as LocalizedString\n }\n\n function lookupWithFallbacks(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString | undefined {\n const localesToTry: Locale[] = [loc]\n const seen = new Set(localesToTry)\n\n if (config.fallbackLocale && !seen.has(config.fallbackLocale)) {\n localesToTry.push(config.fallbackLocale)\n seen.add(config.fallbackLocale)\n }\n\n const chainLocales = i18nConfig.fallbackChain?.[loc] ?? i18nConfig.fallbackChain?.['*']\n if (chainLocales) {\n for (const chainLocale of chainLocales) {\n if (!seen.has(chainLocale)) {\n localesToTry.push(chainLocale)\n seen.add(chainLocale)\n }\n }\n }\n\n for (const targetLocale of localesToTry) {\n const result = lookupCatalog(id, targetLocale, values)\n if (result !== undefined) {\n if (targetLocale !== loc) {\n diagnostics?.fallbackUsed(loc, targetLocale, id)\n }\n return result\n }\n }\n\n return undefined\n }\n\n function resolveMissing(\n id: string,\n loc: Locale,\n ): LocalizedString | undefined {\n if (!config.missing) {\n return undefined\n }\n\n try {\n const result = config.missing(loc, id)\n if (result !== undefined) {\n return result as LocalizedString\n }\n } catch {\n // Missing handler threw — fall through to next resolution path\n }\n return undefined\n }\n\n function resolveMessage(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString {\n const catalogResult = lookupWithFallbacks(id, loc, values)\n if (catalogResult !== undefined) {\n return catalogResult\n }\n\n diagnostics?.missingKey(loc, id)\n\n const missingResult = resolveMissing(id, loc)\n if (missingResult !== undefined) {\n return missingResult\n }\n\n if (id.includes('{')) {\n return coreInterpolate(id, values, loc) as LocalizedString\n }\n\n return id as LocalizedString\n }\n\n function t(strings: TemplateStringsArray, ...exprs: unknown[]): LocalizedString\n function t(id: string | MessageDescriptor, values?: Record<string, unknown>): LocalizedString\n function t(idOrStrings: string | MessageDescriptor | TemplateStringsArray, ...rest: unknown[]): LocalizedString {\n // Tagged template form: t`Hello ${name}`\n if (Array.isArray(idOrStrings) && 'raw' in idOrStrings) {\n const strings = idOrStrings as TemplateStringsArray\n const icu = buildICUMessage(strings, rest)\n const values = Object.fromEntries(rest.map((v, i) => [`arg${i}`, v]))\n return resolveMessage(icu, locale(), values)\n }\n\n const id = idOrStrings as string | MessageDescriptor\n const values = rest[0] as Record<string, unknown> | undefined\n const currentLocale = locale() // reactive dependency\n if (typeof id === 'object' && id !== null) {\n const messageId = resolveDescriptorId(id)\n if (messageId) {\n const catalogResult = lookupWithFallbacks(messageId, currentLocale, values)\n if (catalogResult !== undefined) {\n return catalogResult\n }\n\n const missingResult = resolveMissing(messageId, currentLocale)\n if (missingResult !== undefined) {\n return missingResult\n }\n }\n\n if (id.message !== undefined) {\n return coreInterpolate(id.message, values, currentLocale) as LocalizedString\n }\n\n return (messageId ?? '') as LocalizedString\n }\n\n return resolveMessage(id, currentLocale, values)\n }\n\n const loadMessages = (loc: Locale, msgs: Messages): void => {\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[loc] = { ...messages[loc], ...msgs }\n loadedLocalesSet.add(loc)\n setLoadedLocales(new Set(loadedLocalesSet))\n }\n\n let _localeRequestId = 0\n\n const setLocale = async (newLocale: Locale): Promise<void> => {\n if (!lazyLocaleLoading || !i18nConfig.chunkLoader) {\n setLocaleSignal(newLocale)\n return\n }\n\n const splitRuntime = getSplitRuntimeModule()\n\n if (loadedLocalesSet.has(newLocale)) {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n setLocaleSignal(newLocale)\n return\n }\n\n // Race-condition protection: track request ID\n const thisRequest = ++_localeRequestId\n setIsLoading(true)\n try {\n const loaded = resolveChunkMessages(await i18nConfig.chunkLoader(newLocale))\n // Always store loaded messages — they may be needed if locale is switched back\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[newLocale] = { ...messages[newLocale], ...loaded }\n loadedLocalesSet.add(newLocale)\n setLoadedLocales(new Set(loadedLocalesSet))\n // Stale request — a newer setLocale call superseded this one; don't switch locale\n if (thisRequest !== _localeRequestId) return\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n // Re-check after async __switchLocale — a newer setLocale() may have superseded this one\n if (thisRequest !== _localeRequestId) return\n setLocaleSignal(newLocale)\n } finally {\n if (thisRequest === _localeRequestId) {\n setIsLoading(false)\n }\n }\n }\n\n const _preloadInFlight = new Set<string>()\n\n const preloadLocale = (loc: string): void => {\n if (!lazyLocaleLoading || loadedLocalesSet.has(loc) || !i18nConfig.chunkLoader || _preloadInFlight.has(loc)) return\n _preloadInFlight.add(loc)\n const splitRuntime = getSplitRuntimeModule()\n i18nConfig.chunkLoader(loc).then(async (loaded) => {\n const resolved = resolveChunkMessages(loaded)\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[loc] = { ...messages[loc], ...resolved }\n loadedLocalesSet.add(loc)\n setLoadedLocales(new Set(loadedLocalesSet))\n if (splitRuntime?.__preloadLocale) {\n await splitRuntime.__preloadLocale(loc)\n }\n }).catch((e: unknown) => {\n console.warn('[fluenti] preload failed:', loc, e)\n }).finally(() => {\n _preloadInFlight.delete(loc)\n })\n }\n\n const getLocales = (): Locale[] => Object.keys(messages)\n\n const d = (value: Date | number, style?: string): LocalizedString =>\n formatDate(value, locale(), style, i18nConfig.dateFormats) as LocalizedString\n\n const n = (value: number, style?: string): LocalizedString =>\n formatNumber(value, locale(), style, i18nConfig.numberFormats) as LocalizedString\n\n const format = (message: string, values?: Record<string, unknown>): LocalizedString => {\n return coreInterpolate(message, values, locale()) as LocalizedString\n }\n\n const te = (key: string, loc?: string): boolean => {\n const msgs = messages[loc ?? locale()]\n return msgs !== undefined && key in msgs\n }\n\n const tm = (key: string, loc?: string): CompiledMessage | undefined => {\n const msgs = messages[loc ?? locale()]\n return msgs ? msgs[key] : undefined\n }\n\n return { locale, setLocale, t, loadMessages, getLocales, d, n, format, isLoading, loadedLocales, preloadLocale, te, tm }\n}\n","import { createContext } from 'solid-js'\nimport type { ParentComponent } from 'solid-js'\nimport { createFluentiContext } from './context'\nimport type { FluentiConfig, FluentiContext } from './context'\n\n/** Solid context object for i18n — used internally by useI18n() */\nexport const I18nCtx = createContext<FluentiContext>()\n\n/**\n * Provide i18n context to the component tree.\n *\n */\nexport const I18nProvider: ParentComponent<FluentiConfig> = (props) => {\n const ctx = createFluentiContext(props)\n return <I18nCtx.Provider value={ctx}>{props.children}</I18nCtx.Provider>\n}\n","import { useContext } from 'solid-js'\nimport { I18nCtx } from './provider'\nimport type { FluentiContext } from './context'\n\n/**\n * Access the i18n context from the nearest `<I18nProvider>`.\n *\n * Throws if no provider is found in the component tree.\n */\nexport function useI18n(): FluentiContext {\n const ctx = useContext(I18nCtx)\n if (ctx) {\n return ctx\n }\n\n throw new Error(\n 'useI18n() must be used inside an <I18nProvider>.',\n )\n}\n","import type { CompileTimeT } from '@fluenti/core'\n\nexport const t: CompileTimeT = ((..._args: unknown[]) => {\n throw new Error(\n \"[fluenti] `t` imported from '@fluenti/solid' is a compile-time API. \" +\n 'Use it only with the Fluenti build transform inside a component or custom hook. ' +\n 'For runtime lookups, use useI18n().t(...).',\n )\n}) as CompileTimeT\n","import type { JSX } from 'solid-js'\n\nfunction isNodeLike(value: unknown): value is Node {\n return typeof Node !== 'undefined' && value instanceof Node\n}\n\nfunction resolveValue(value: unknown): unknown {\n if (typeof value === 'function' && !(value as { length?: number }).length) {\n return (value as () => unknown)()\n }\n return value\n}\n\nimport { offsetIndices } from '@fluenti/core/internal'\n\nexport function extractMessage(value: unknown): {\n message: string\n components: Node[]\n} {\n const components: Node[] = []\n let message = ''\n\n function visit(node: unknown): void {\n const resolved = resolveValue(node)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const child of resolved) visit(child)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n message += String(resolved)\n return\n }\n if (!isNodeLike(resolved)) return\n if (resolved.nodeType === Node.TEXT_NODE) {\n message += resolved.textContent ?? ''\n return\n }\n if (resolved.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n visit(Array.from(resolved.childNodes))\n return\n }\n\n const idx = components.length\n const inner = extractMessage(Array.from(resolved.childNodes))\n components.push((resolved as Element).cloneNode(false))\n components.push(...inner.components)\n if (inner.message === '' && inner.components.length === 0) {\n message += `<${idx}/>`\n } else {\n message += `<${idx}>${offsetIndices(inner.message, idx + 1)}</${idx}>`\n }\n }\n\n visit(value)\n return { message, components }\n}\n\nfunction appendChild(parent: Node, child: unknown): void {\n const resolved = resolveValue(child)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const entry of resolved) appendChild(parent, entry)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n parent.appendChild(document.createTextNode(String(resolved)))\n return\n }\n if (isNodeLike(resolved)) {\n parent.appendChild(resolved)\n }\n}\n\nexport function reconstruct(\n translated: string,\n components: Node[],\n): JSX.Element {\n const combinedRe = /<(\\d+)(?:\\/>|(>)([\\s\\S]*?)<\\/\\1>)/g\n const result: unknown[] = []\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n combinedRe.lastIndex = 0\n match = combinedRe.exec(translated)\n while (match !== null) {\n if (match.index > lastIndex) {\n result.push(translated.slice(lastIndex, match.index))\n }\n\n const idx = Number(match[1])\n const isSelfClosing = match[2] === undefined\n const template = components[idx]\n\n if (isSelfClosing) {\n if (template) {\n result.push(template.cloneNode(false))\n }\n } else {\n const inner = reconstruct(match[2] !== undefined ? match[3]! : '', components)\n if (template) {\n const clone = template.cloneNode(false)\n appendChild(clone, inner)\n result.push(clone)\n } else {\n result.push(match[3] ?? '')\n }\n }\n\n lastIndex = combinedRe.lastIndex\n match = combinedRe.exec(translated)\n }\n\n if (lastIndex < translated.length) {\n result.push(translated.slice(lastIndex))\n }\n\n return (result.length <= 1 ? result[0] ?? '' : result) as JSX.Element\n}\n\nexport function serializeRichForms<T extends string>(\n keys: readonly T[],\n forms: Partial<Record<T, unknown>> & Record<string, unknown>,\n): {\n messages: Record<string, string>\n components: Node[]\n} {\n const messages: Record<string, string> = {}\n const components: Node[] = []\n\n for (const key of keys) {\n const value = forms[key]\n if (value === undefined) continue\n const extracted = extractMessage(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n for (const [key, value] of Object.entries(forms)) {\n if (keys.includes(key as T) || value === undefined) continue\n const extracted = extractMessage(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n return { messages, components }\n}\n\n","import { Dynamic } from 'solid-js/web'\nimport { children as resolveChildren, createMemo } from 'solid-js'\nimport type { Component, JSX } from 'solid-js'\nimport { useI18n } from './use-i18n'\nimport { extractMessage as extractDomMessage, reconstruct as reconstructDomMessage } from './rich-dom'\n\n/** A Solid component that accepts children */\nexport type RichComponent = Component<{ children?: JSX.Element }>\n\n/** Props for the `<Trans>` component */\nexport interface FluentiTransProps {\n /** Override auto-generated hash ID */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n /** Children — the content to translate (legacy API) */\n children?: JSX.Element\n /** Translated message string with XML-like tags (e.g. `<bold>text</bold>`) */\n message?: string\n /** Map of tag names to Solid components */\n components?: Record<string, RichComponent>\n /** @internal Pre-computed message from build plugin */\n __message?: string\n /** @internal Pre-computed component map from build plugin */\n __components?: Record<string, RichComponent>\n}\n\n/**\n * A token from parsing the message string.\n * Either a plain text segment or a tag with inner content.\n */\ninterface TextToken {\n readonly type: 'text'\n readonly value: string\n}\n\ninterface TagToken {\n readonly type: 'tag'\n readonly name: string\n readonly children: readonly Token[]\n}\n\ntype Token = TextToken | TagToken\n\n/**\n * Parse a message string containing XML-like tags into a token tree.\n *\n * Supports:\n * - Named tags: `<bold>content</bold>`\n * - Self-closing tags: `<br/>`\n * - Nested tags: `<bold>hello <italic>world</italic></bold>`\n */\nfunction parseTokens(input: string): readonly Token[] {\n const tokens: Token[] = []\n let pos = 0\n\n while (pos < input.length) {\n const openIdx = input.indexOf('<', pos)\n\n if (openIdx === -1) {\n // No more tags — rest is plain text\n tokens.push({ type: 'text', value: input.slice(pos) })\n break\n }\n\n // Push any text before this tag\n if (openIdx > pos) {\n tokens.push({ type: 'text', value: input.slice(pos, openIdx) })\n }\n\n // Check for self-closing tag: <tagName/>\n const selfCloseMatch = input.slice(openIdx).match(/^<(\\w+)\\s*\\/>/)\n if (selfCloseMatch) {\n tokens.push({ type: 'tag', name: selfCloseMatch[1]!, children: [] })\n pos = openIdx + selfCloseMatch[0].length\n continue\n }\n\n // Check for opening tag: <tagName>\n const openMatch = input.slice(openIdx).match(/^<(\\w+)>/)\n if (!openMatch) {\n // Not a valid tag — treat '<' as text\n tokens.push({ type: 'text', value: '<' })\n pos = openIdx + 1\n continue\n }\n\n const tagName = openMatch[1]!\n const contentStart = openIdx + openMatch[0].length\n\n // Find the matching closing tag, respecting nesting\n const innerEnd = findClosingTag(input, tagName, contentStart)\n if (innerEnd === -1) {\n // No closing tag found — treat as plain text\n tokens.push({ type: 'text', value: input.slice(openIdx, contentStart) })\n pos = contentStart\n continue\n }\n\n const innerContent = input.slice(contentStart, innerEnd)\n const closingTag = `</${tagName}>`\n tokens.push({\n type: 'tag',\n name: tagName,\n children: parseTokens(innerContent),\n })\n pos = innerEnd + closingTag.length\n }\n\n return tokens\n}\n\n/**\n * Find the position of the matching closing tag, accounting for nesting\n * of the same tag name.\n *\n * Returns the index of the start of the closing tag, or -1 if not found.\n */\nfunction findClosingTag(input: string, tagName: string, startPos: number): number {\n const openTag = `<${tagName}>`\n const closeTag = `</${tagName}>`\n let depth = 1\n let pos = startPos\n\n while (pos < input.length && depth > 0) {\n const nextOpen = input.indexOf(openTag, pos)\n const nextClose = input.indexOf(closeTag, pos)\n\n if (nextClose === -1) return -1\n\n if (nextOpen !== -1 && nextOpen < nextClose) {\n depth++\n pos = nextOpen + openTag.length\n } else {\n depth--\n if (depth === 0) return nextClose\n pos = nextClose + closeTag.length\n }\n }\n\n return -1\n}\n\n/**\n * Render a token tree into Solid JSX elements using the components map.\n */\nfunction renderTokens(\n tokens: readonly Token[],\n components: Record<string, RichComponent>,\n): JSX.Element {\n const elements = tokens.map((token): JSX.Element => {\n if (token.type === 'text') {\n return token.value as unknown as JSX.Element\n }\n\n const Comp = components[token.name]\n if (!Comp) {\n // Unknown component — render inner content as plain text\n return renderTokens(token.children, components)\n }\n\n const innerContent = token.children.length > 0\n ? renderTokens(token.children, components)\n : undefined\n\n return (<Dynamic component={Comp}>{innerContent}</Dynamic>) as JSX.Element\n })\n\n if (elements.length === 1) return elements[0]!\n return (<>{elements}</>) as JSX.Element\n}\n\n/**\n * Render translated content with inline components.\n *\n * Supports two APIs:\n *\n * 1. **message + components** (recommended for rich text):\n * ```tsx\n * <Trans\n * message={t`Welcome to <bold>Fluenti</bold>!`}\n * components={{ bold: (props) => <strong>{props.children}</strong> }}\n * />\n * ```\n *\n * 2. **children** (legacy / simple passthrough):\n * ```tsx\n * <Trans>Click <a href=\"/next\">here</a> to continue</Trans>\n * ```\n */\nexport const Trans: Component<FluentiTransProps> = (props) => {\n const { t } = useI18n()\n const resolvedChildren = resolveChildren(() => props.children)\n // message + components API (including build-time __message/__components)\n // Note: the vite-plugin tagged-template transform wraps Solid expressions in\n // createMemo(), so props.message may be a memo accessor (function) instead of\n // a string. We unwrap it here to handle both cases.\n const message = createMemo(() => {\n const raw = props.__message ?? props.message\n return typeof raw === 'function' ? (raw as () => string)() : raw\n })\n const components = createMemo(() => props.__components ?? props.components)\n\n return (() => {\n const msg = message()\n const comps = components()\n\n if (msg !== undefined && comps) {\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: msg,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const tokens = parseTokens(translated)\n return renderTokens(tokens, comps)\n }\n\n // Fallback: children-only API with runtime extraction/reconstruction\n const children = resolvedChildren.toArray()\n if (children.length === 0) return null\n const extracted = extractDomMessage(children)\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: extracted.message,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const result = extracted.components.length > 0\n ? reconstructDomMessage(translated, extracted.components)\n : translated\n\n if (Array.isArray(result) && result.length > 1) {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }\n\n return result as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { Dynamic } from 'solid-js/web'\nimport type { Component, JSX } from 'solid-js'\nimport { hashMessage, buildICUPluralMessage, PLURAL_CATEGORIES, type PluralCategory } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Plural>` component */\nexport interface FluentiPluralProps {\n /** The numeric value to pluralise */\n value: number\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Offset from value before selecting form */\n offset?: number\n /** Message for the \"zero\" plural category */\n zero?: string | JSX.Element\n /** Message for the \"one\" plural category */\n one?: string | JSX.Element\n /** Message for the \"two\" plural category */\n two?: string | JSX.Element\n /** Message for the \"few\" plural category */\n few?: string | JSX.Element\n /** Message for the \"many\" plural category */\n many?: string | JSX.Element\n /** Fallback message when no category-specific prop matches */\n other: string | JSX.Element\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n}\n\n/**\n * `<Plural>` component — shorthand for ICU plural patterns.\n *\n * Plural form props (`zero`, `one`, `two`, `few`, `many`, `other`) are treated\n * as source-language messages. The component builds an ICU plural message,\n * looks it up via `t()` in the catalog, and interpolates the translated result.\n *\n * When no catalog translation exists, the component falls back to interpolating\n * the source-language ICU message directly via core's `interpolate`.\n *\n * Rich text is supported via JSX element props:\n * ```tsx\n * <Plural\n * value={count()}\n * zero={<>No <strong>items</strong> left</>}\n * one={<><em>1</em> item remaining</>}\n * other={<><strong>{count()}</strong> items remaining</>}\n * />\n * ```\n *\n * String props still work (backward compatible):\n * ```tsx\n * <Plural value={count()} zero=\"No items\" one=\"# item\" other=\"# items\" />\n * ```\n */\nexport const Plural: Component<FluentiPluralProps> = (props) => {\n const { t } = useI18n()\n\n /** Resolve a category prop value — handles string, accessor function, and JSX */\n function resolveProp(val: string | JSX.Element | undefined): string | JSX.Element | undefined {\n if (typeof val === 'function') return (val as () => string | JSX.Element)()\n return val\n }\n\n return (() => {\n // Resolve all category values (handles Solid accessors from createMemo)\n const resolvedValues: Partial<Record<PluralCategory, string | JSX.Element>> = {}\n for (const cat of PLURAL_CATEGORIES) {\n const resolved = resolveProp(props[cat])\n if (resolved !== undefined) {\n resolvedValues[cat] = resolved\n }\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, resolvedValues)\n const icuMessage = buildICUPluralMessage(\n {\n ...(messages['zero'] !== undefined && { zero: messages['zero'] }),\n ...(messages['one'] !== undefined && { one: messages['one'] }),\n ...(messages['two'] !== undefined && { two: messages['two'] }),\n ...(messages['few'] !== undefined && { few: messages['few'] }),\n ...(messages['many'] !== undefined && { many: messages['many'] }),\n other: messages['other'] ?? '',\n },\n props.offset,\n )\n\n const translated = t(\n {\n id: props.id ?? (props.context === undefined ? icuMessage : hashMessage(icuMessage, props.context)),\n message: icuMessage,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { count: props.value },\n )\n\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (props.tag) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import type { Component, JSX } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { hashMessage, buildICUSelectMessage, normalizeSelectForms } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Select>` component */\nexport interface FluentiSelectProps {\n /** The value to match against prop keys */\n value: string\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Fallback message when no key matches */\n other: string | JSX.Element\n /**\n * Named options map. Keys are match values, values are display strings or JSX.\n * Takes precedence over dynamic attrs when both are provided.\n *\n * @example `{ male: 'He', female: 'She' }`\n */\n options?: Record<string, string | JSX.Element>\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n /** Additional key/message pairs for matching (attrs fallback) */\n [key: string]: unknown\n}\n\n/**\n * Render a message selected by matching `value` against prop keys.\n *\n * Options can be provided via the type-safe `options` prop (recommended)\n * or as direct attrs (convenience). When both are present, `options` takes\n * precedence.\n *\n * Rich text is supported via JSX element values in the `options` prop or\n * as direct JSX element props:\n * ```tsx\n * <Select\n * value={gender()}\n * options={{\n * male: <><strong>He</strong> liked this</>,\n * female: <><strong>She</strong> liked this</>,\n * }}\n * other={<><em>They</em> liked this</>}\n * />\n * ```\n *\n * Falls back to the `other` prop when no key matches.\n */\nexport const SelectComp: Component<FluentiSelectProps> = (props) => {\n const { t } = useI18n()\n\n const content = () => {\n const forms: Record<string, unknown> = props.options !== undefined\n ? { ...props.options, other: props.other }\n : {\n ...Object.fromEntries(\n Object.entries(props).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other', 'tag'].includes(key)),\n ),\n other: props.other,\n }\n\n const orderedKeys = [...Object.keys(forms).filter(key => key !== 'other'), 'other'] as const\n const { messages, components } = serializeRichForms(orderedKeys, forms)\n const normalized = normalizeSelectForms(\n Object.fromEntries([...orderedKeys].map((key) => [key, messages[key] ?? ''])),\n )\n const translated = t(\n {\n id: props.id ?? (props.context === undefined\n ? buildICUSelectMessage(normalized.forms)\n : hashMessage(buildICUSelectMessage(normalized.forms), props.context)),\n message: buildICUSelectMessage(normalized.forms),\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { value: normalized.valueMap[props.value] ?? 'other' },\n )\n\n return components.length > 0 ? reconstruct(translated, components) : translated\n }\n\n return (() => {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{content()}</Dynamic>) as JSX.Element\n }\n return (<>{content()}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface DateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\n/** @alias DateTimeProps */\nexport type FluentiDateTimeProps = DateTimeProps\n\n/**\n * `<DateTime>` — date formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\nexport function DateTime(props: DateTimeProps) {\n const { d } = useI18n()\n return <>{d(props.value, props.format)}</>\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface NumberProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n/** @alias NumberProps */\nexport type FluentiNumberFormatProps = NumberProps\n\n/**\n * `<NumberFormat>` — number formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} format=\"currency\" />\n * ```\n */\nexport function NumberFormat(props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,CAAC,CACKmB,EAAahB,EACjB,CACEX,GAAIU,EAAMV,KAAOU,EAAMT,UAAYa,IAAAA,IAAAA,EAAAA,EAAAA,uBACTW,EAAWZ,MAAM,EAAA,EAAA,EAAA,cAAA,EAAA,EAAA,uBACLY,EAAWZ,MAAM,CAAEH,EAAMT,QAAQ,EACvE2B,SAAAA,EAAAA,EAAAA,uBAA+BH,EAAWZ,MAAM,CAChD,GAAIH,EAAMT,UAAYa,IAAAA,GAAyC,EAAE,CAA/B,CAAEb,QAASS,EAAMT,QAAS,CAC5D,GAAIS,EAAMR,UAAYY,IAAAA,GAAyC,EAAE,CAA/B,CAAEZ,QAASQ,EAAMR,QAAS,CAC7D,CACD,CAAEH,MAAO0B,EAAWI,SAASnB,EAAMX,QAAU,QAC/C,CAAC,CAED,OAAOyB,EAAWM,OAAS,EAAIlC,EAAY+B,EAAYH,EAAW,CAAGG,GAGvE,WACMjB,EAAMH,KACR,EAAA,EAAA,iBAAShB,EAAAA,QAAO,CAAA,IAACyC,WAAS,CAAA,OAAEtB,EAAMH,KAAG,IAAA0B,UAAA,CAAA,OAAGrB,GAAS,EAAA,CAAA,EAEnD,EAAA,EAAA,MAAWA,EAAO,GCtEtB,SAAgB6B,EAASC,EAAsB,CAC7C,GAAM,CAAEC,KAAMR,GAAS,CACvB,OAAA,EAAA,EAAA,UAAUQ,EAAED,EAAML,MAAOK,EAAMH,OAAO,CAAA,CCFxC,SAAgBW,EAAaC,EAAoB,CAC/C,GAAM,CAAEC,KAAMP,GAAS,CACvB,OAAA,EAAA,EAAA,UAAUO,EAAED,EAAMJ,MAAOI,EAAMH,OAAO,CAAA"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/compile-time-t.ts"],"sourcesContent":["import type { CompileTimeT } from '@fluenti/core'\n\nexport const t: CompileTimeT = ((..._args: unknown[]) => {\n throw new Error(\n \"[fluenti] `t` imported from '@fluenti/solid' is a compile-time API. \" +\n 'Use it only with the Fluenti build transform inside a component or custom hook. ' +\n 'For runtime lookups, use useI18n().t(...).',\n )\n}) as CompileTimeT\n"],"mappings":"6IAEA,IAAa,IAAoB,GAAG,IAAqB,CACvD,MAAU,MACR,iMAGD"}
package/dist/index.d.ts CHANGED
@@ -3,15 +3,10 @@ export type { FluentiContext, FluentiConfig } from './context';
3
3
  export { I18nProvider } from './provider';
4
4
  export { useI18n } from './use-i18n';
5
5
  export { t } from './compile-time-t';
6
- export { Trans } from './trans';
6
+ export { msg } from './msg';
7
7
  export type { FluentiTransProps } from './trans';
8
- export { Plural } from './plural';
9
8
  export type { FluentiPluralProps } from './plural';
10
- export { SelectComp as Select } from './select';
11
9
  export type { FluentiSelectProps } from './select';
12
- export { msg } from './msg';
13
- export { DateTime } from './components/DateTime';
14
10
  export type { DateTimeProps, FluentiDateTimeProps } from './components/DateTime';
15
- export { NumberFormat } from './components/NumberFormat';
16
11
  export type { NumberProps, FluentiNumberFormatProps } from './components/NumberFormat';
17
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,YAAY,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAA;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAI3B,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAChF,YAAY,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA"}
package/dist/index.js CHANGED
@@ -1,420 +1,10 @@
1
- import { children as e, createContext as t, createMemo as n, createSignal as r, useContext as i } from "solid-js";
2
- import { createDiagnostics as a, formatDate as o, formatNumber as s, msg as c } from "@fluenti/core";
3
- import { PLURAL_CATEGORIES as l, buildICUMessage as u, buildICUPluralMessage as d, buildICUSelectMessage as f, hashMessage as p, interpolate as m, normalizeSelectForms as h, offsetIndices as g, resolveDescriptorId as _ } from "@fluenti/core/internal";
4
- import { Dynamic as v, createComponent as y, memo as b } from "solid-js/web";
5
- //#region src/context.ts
6
- var x = Symbol.for("fluenti.runtime.solid.v1");
7
- function S() {
8
- let e = globalThis[x];
9
- return typeof e == "object" && e ? e : null;
10
- }
11
- function C(e) {
12
- return typeof e == "object" && e && "default" in e ? e.default : e;
13
- }
14
- function w(e) {
15
- let [t, n] = r(e.locale), [i, c] = r(!1), l = new Set([e.locale]), [d, f] = r(new Set(l)), p = { ...e.messages }, h = e, g = h.diagnostics ? a(h.diagnostics) : void 0, v = h.lazyLocaleLoading ?? e.splitting ?? !1;
16
- function y(e, t, n) {
17
- let r = p[t];
18
- if (!r) return;
19
- let i = r[e];
20
- if (i !== void 0) return typeof i == "function" ? i(n) : typeof i == "string" && n ? m(i, n, t) : String(i);
21
- }
22
- function b(t, n, r) {
23
- let i = [n], a = new Set(i);
24
- e.fallbackLocale && !a.has(e.fallbackLocale) && (i.push(e.fallbackLocale), a.add(e.fallbackLocale));
25
- let o = h.fallbackChain?.[n] ?? h.fallbackChain?.["*"];
26
- if (o) for (let e of o) a.has(e) || (i.push(e), a.add(e));
27
- for (let e of i) {
28
- let i = y(t, e, r);
29
- if (i !== void 0) return e !== n && g?.fallbackUsed(n, e, t), i;
30
- }
31
- }
32
- function x(t, n) {
33
- if (e.missing) try {
34
- let r = e.missing(n, t);
35
- if (r !== void 0) return r;
36
- } catch {}
37
- }
38
- function w(e, t, n) {
39
- let r = b(e, t, n);
40
- if (r !== void 0) return r;
41
- g?.missingKey(t, e);
42
- let i = x(e, t);
43
- return i === void 0 ? e.includes("{") ? m(e, n, t) : e : i;
44
- }
45
- function T(e, ...n) {
46
- if (Array.isArray(e) && "raw" in e) {
47
- let r = u(e, n), i = Object.fromEntries(n.map((e, t) => [`arg${t}`, e]));
48
- return w(r, t(), i);
49
- }
50
- let r = e, i = n[0], a = t();
51
- if (typeof r == "object" && r) {
52
- let e = _(r);
53
- if (e) {
54
- let t = b(e, a, i);
55
- if (t !== void 0) return t;
56
- let n = x(e, a);
57
- if (n !== void 0) return n;
58
- }
59
- return r.message === void 0 ? e ?? "" : m(r.message, i, a);
60
- }
61
- return w(r, a, i);
62
- }
63
- let E = (e, t) => {
64
- p[e] = {
65
- ...p[e],
66
- ...t
67
- }, l.add(e), f(new Set(l));
68
- }, D = 0, O = async (e) => {
69
- if (!v || !h.chunkLoader) {
70
- n(e);
71
- return;
72
- }
73
- let t = S();
74
- if (l.has(e)) {
75
- t?.__switchLocale && await t.__switchLocale(e), n(e);
76
- return;
77
- }
78
- let r = ++D;
79
- c(!0);
80
- try {
81
- let i = C(await h.chunkLoader(e));
82
- if (p[e] = {
83
- ...p[e],
84
- ...i
85
- }, l.add(e), f(new Set(l)), r !== D || (t?.__switchLocale && await t.__switchLocale(e), r !== D)) return;
86
- n(e);
87
- } finally {
88
- r === D && c(!1);
89
- }
90
- }, k = /* @__PURE__ */ new Set();
91
- return {
92
- locale: t,
93
- setLocale: O,
94
- t: T,
95
- loadMessages: E,
96
- getLocales: () => Object.keys(p),
97
- d: (e, n) => o(e, t(), n, h.dateFormats),
98
- n: (e, n) => s(e, t(), n, h.numberFormats),
99
- format: (e, n) => m(e, n, t()),
100
- isLoading: i,
101
- loadedLocales: d,
102
- preloadLocale: (e) => {
103
- if (!v || l.has(e) || !h.chunkLoader || k.has(e)) return;
104
- k.add(e);
105
- let t = S();
106
- h.chunkLoader(e).then(async (n) => {
107
- let r = C(n);
108
- p[e] = {
109
- ...p[e],
110
- ...r
111
- }, l.add(e), f(new Set(l)), t?.__preloadLocale && await t.__preloadLocale(e);
112
- }).catch((t) => {
113
- console.warn("[fluenti] preload failed:", e, t);
114
- }).finally(() => {
115
- k.delete(e);
116
- });
117
- },
118
- te: (e, n) => {
119
- let r = p[n ?? t()];
120
- return r !== void 0 && e in r;
121
- },
122
- tm: (e, n) => {
123
- let r = p[n ?? t()];
124
- return r ? r[e] : void 0;
125
- }
126
- };
127
- }
128
- //#endregion
129
- //#region src/provider.tsx
130
- var T = t(), E = (e) => {
131
- let t = w(e);
132
- return y(T.Provider, {
133
- value: t,
134
- get children() {
135
- return e.children;
136
- }
137
- });
138
- };
139
- //#endregion
140
- //#region src/use-i18n.ts
141
- function D() {
142
- let e = i(T);
143
- if (e) return e;
144
- throw Error("useI18n() must be used inside an <I18nProvider>.");
145
- }
146
- //#endregion
1
+ import { n as e, r as t, t as n } from "./use-i18n-DPb98Dw1.js";
2
+ import { msg as r } from "@fluenti/core";
147
3
  //#region src/compile-time-t.ts
148
- var O = ((...e) => {
4
+ var i = ((...e) => {
149
5
  throw Error("[fluenti] `t` imported from '@fluenti/solid' is a compile-time API. Use it only with the Fluenti build transform inside a component or custom hook. For runtime lookups, use useI18n().t(...).");
150
6
  });
151
7
  //#endregion
152
- //#region src/rich-dom.tsx
153
- function k(e) {
154
- return typeof Node < "u" && e instanceof Node;
155
- }
156
- function A(e) {
157
- return typeof e == "function" && !e.length ? e() : e;
158
- }
159
- function j(e) {
160
- let t = [], n = "";
161
- function r(e) {
162
- let i = A(e);
163
- if (i == null || typeof i == "boolean") return;
164
- if (Array.isArray(i)) {
165
- for (let e of i) r(e);
166
- return;
167
- }
168
- if (typeof i == "string" || typeof i == "number") {
169
- n += String(i);
170
- return;
171
- }
172
- if (!k(i)) return;
173
- if (i.nodeType === Node.TEXT_NODE) {
174
- n += i.textContent ?? "";
175
- return;
176
- }
177
- if (i.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
178
- r(Array.from(i.childNodes));
179
- return;
180
- }
181
- let a = t.length, o = j(Array.from(i.childNodes));
182
- t.push(i.cloneNode(!1)), t.push(...o.components), o.message === "" && o.components.length === 0 ? n += `<${a}/>` : n += `<${a}>${g(o.message, a + 1)}</${a}>`;
183
- }
184
- return r(e), {
185
- message: n,
186
- components: t
187
- };
188
- }
189
- function M(e, t) {
190
- let n = A(t);
191
- if (!(n == null || typeof n == "boolean")) {
192
- if (Array.isArray(n)) {
193
- for (let t of n) M(e, t);
194
- return;
195
- }
196
- if (typeof n == "string" || typeof n == "number") {
197
- e.appendChild(document.createTextNode(String(n)));
198
- return;
199
- }
200
- k(n) && e.appendChild(n);
201
- }
202
- }
203
- function N(e, t) {
204
- let n = /<(\d+)(?:\/>|(>)([\s\S]*?)<\/\1>)/g, r = [], i = 0, a;
205
- for (n.lastIndex = 0, a = n.exec(e); a !== null;) {
206
- a.index > i && r.push(e.slice(i, a.index));
207
- let o = Number(a[1]), s = a[2] === void 0, c = t[o];
208
- if (s) c && r.push(c.cloneNode(!1));
209
- else {
210
- let e = N(a[2] === void 0 ? "" : a[3], t);
211
- if (c) {
212
- let t = c.cloneNode(!1);
213
- M(t, e), r.push(t);
214
- } else r.push(a[3] ?? "");
215
- }
216
- i = n.lastIndex, a = n.exec(e);
217
- }
218
- return i < e.length && r.push(e.slice(i)), r.length <= 1 ? r[0] ?? "" : r;
219
- }
220
- function P(e, t) {
221
- let n = {}, r = [];
222
- for (let i of e) {
223
- let e = t[i];
224
- if (e === void 0) continue;
225
- let a = j(e);
226
- n[i] = g(a.message, r.length), r.push(...a.components);
227
- }
228
- for (let [i, a] of Object.entries(t)) {
229
- if (e.includes(i) || a === void 0) continue;
230
- let t = j(a);
231
- n[i] = g(t.message, r.length), r.push(...t.components);
232
- }
233
- return {
234
- messages: n,
235
- components: r
236
- };
237
- }
238
- //#endregion
239
- //#region src/trans.tsx
240
- function F(e) {
241
- let t = [], n = 0;
242
- for (; n < e.length;) {
243
- let r = e.indexOf("<", n);
244
- if (r === -1) {
245
- t.push({
246
- type: "text",
247
- value: e.slice(n)
248
- });
249
- break;
250
- }
251
- r > n && t.push({
252
- type: "text",
253
- value: e.slice(n, r)
254
- });
255
- let i = e.slice(r).match(/^<(\w+)\s*\/>/);
256
- if (i) {
257
- t.push({
258
- type: "tag",
259
- name: i[1],
260
- children: []
261
- }), n = r + i[0].length;
262
- continue;
263
- }
264
- let a = e.slice(r).match(/^<(\w+)>/);
265
- if (!a) {
266
- t.push({
267
- type: "text",
268
- value: "<"
269
- }), n = r + 1;
270
- continue;
271
- }
272
- let o = a[1], s = r + a[0].length, c = I(e, o, s);
273
- if (c === -1) {
274
- t.push({
275
- type: "text",
276
- value: e.slice(r, s)
277
- }), n = s;
278
- continue;
279
- }
280
- let l = e.slice(s, c), u = `</${o}>`;
281
- t.push({
282
- type: "tag",
283
- name: o,
284
- children: F(l)
285
- }), n = c + u.length;
286
- }
287
- return t;
288
- }
289
- function I(e, t, n) {
290
- let r = `<${t}>`, i = `</${t}>`, a = 1, o = n;
291
- for (; o < e.length && a > 0;) {
292
- let t = e.indexOf(r, o), n = e.indexOf(i, o);
293
- if (n === -1) return -1;
294
- if (t !== -1 && t < n) a++, o = t + r.length;
295
- else {
296
- if (a--, a === 0) return n;
297
- o = n + i.length;
298
- }
299
- }
300
- return -1;
301
- }
302
- function L(e, t) {
303
- let n = e.map((e) => {
304
- if (e.type === "text") return e.value;
305
- let n = t[e.name];
306
- return n ? y(v, {
307
- component: n,
308
- children: e.children.length > 0 ? L(e.children, t) : void 0
309
- }) : L(e.children, t);
310
- });
311
- return n.length === 1 ? n[0] : n;
312
- }
313
- var R = (t) => {
314
- let { t: r } = D(), i = e(() => t.children), a = n(() => {
315
- let e = t.__message ?? t.message;
316
- return typeof e == "function" ? e() : e;
317
- }), o = n(() => t.__components ?? t.components);
318
- return (() => {
319
- let e = a(), n = o();
320
- if (e !== void 0 && n) return L(F(r({
321
- ...t.id === void 0 ? {} : { id: t.id },
322
- message: e,
323
- ...t.context === void 0 ? {} : { context: t.context },
324
- ...t.comment === void 0 ? {} : { comment: t.comment }
325
- })), n);
326
- let s = i.toArray();
327
- if (s.length === 0) return null;
328
- let c = j(s), l = r({
329
- ...t.id === void 0 ? {} : { id: t.id },
330
- message: c.message,
331
- ...t.context === void 0 ? {} : { context: t.context },
332
- ...t.comment === void 0 ? {} : { comment: t.comment }
333
- }), u = c.components.length > 0 ? N(l, c.components) : l;
334
- return Array.isArray(u) && u.length > 1 && t.tag ? y(v, {
335
- get component() {
336
- return t.tag;
337
- },
338
- children: u
339
- }) : u;
340
- });
341
- }, z = (e) => {
342
- let { t } = D();
343
- function n(e) {
344
- return typeof e == "function" ? e() : e;
345
- }
346
- return (() => {
347
- let r = {};
348
- for (let t of l) {
349
- let i = n(e[t]);
350
- i !== void 0 && (r[t] = i);
351
- }
352
- let { messages: i, components: a } = P(l, r), o = d({
353
- ...i.zero !== void 0 && { zero: i.zero },
354
- ...i.one !== void 0 && { one: i.one },
355
- ...i.two !== void 0 && { two: i.two },
356
- ...i.few !== void 0 && { few: i.few },
357
- ...i.many !== void 0 && { many: i.many },
358
- other: i.other ?? ""
359
- }, e.offset), s = t({
360
- id: e.id ?? (e.context === void 0 ? o : p(o, e.context)),
361
- message: o,
362
- ...e.context === void 0 ? {} : { context: e.context },
363
- ...e.comment === void 0 ? {} : { comment: e.comment }
364
- }, { count: e.value }), c = a.length > 0 ? N(s, a) : s;
365
- return e.tag ? y(v, {
366
- get component() {
367
- return e.tag;
368
- },
369
- children: c
370
- }) : c;
371
- });
372
- }, B = (e) => {
373
- let { t } = D(), n = () => {
374
- let n = e.options === void 0 ? {
375
- ...Object.fromEntries(Object.entries(e).filter(([e]) => ![
376
- "value",
377
- "id",
378
- "context",
379
- "comment",
380
- "options",
381
- "other",
382
- "tag"
383
- ].includes(e))),
384
- other: e.other
385
- } : {
386
- ...e.options,
387
- other: e.other
388
- }, r = [...Object.keys(n).filter((e) => e !== "other"), "other"], { messages: i, components: a } = P(r, n), o = h(Object.fromEntries([...r].map((e) => [e, i[e] ?? ""]))), s = t({
389
- id: e.id ?? (e.context === void 0 ? f(o.forms) : p(f(o.forms), e.context)),
390
- message: f(o.forms),
391
- ...e.context === void 0 ? {} : { context: e.context },
392
- ...e.comment === void 0 ? {} : { comment: e.comment }
393
- }, { value: o.valueMap[e.value] ?? "other" });
394
- return a.length > 0 ? N(s, a) : s;
395
- };
396
- return (() => e.tag ? y(v, {
397
- get component() {
398
- return e.tag;
399
- },
400
- get children() {
401
- return n();
402
- }
403
- }) : b(n));
404
- };
405
- //#endregion
406
- //#region src/components/DateTime.tsx
407
- function V(e) {
408
- let { d: t } = D();
409
- return b(() => t(e.value, e.format));
410
- }
411
- //#endregion
412
- //#region src/components/NumberFormat.tsx
413
- function H(e) {
414
- let { n: t } = D();
415
- return b(() => t(e.value, e.format));
416
- }
417
- //#endregion
418
- export { V as DateTime, E as I18nProvider, H as NumberFormat, z as Plural, B as Select, R as Trans, w as createFluentiContext, c as msg, O as t, D as useI18n };
8
+ export { e as I18nProvider, t as createFluentiContext, r as msg, i as t, n as useI18n };
419
9
 
420
10
  //# sourceMappingURL=index.js.map