@fluenti/vue 0.5.0 → 0.6.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/dist/NumberFormat-Bxim144o.js +239 -0
- package/dist/NumberFormat-Bxim144o.js.map +1 -0
- package/dist/NumberFormat-CgU3BNm8.cjs +2 -0
- package/dist/NumberFormat-CgU3BNm8.cjs.map +1 -0
- package/dist/components-entry.cjs +1 -2
- package/dist/components-entry.js +2 -227
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +59 -59
- package/dist/index.js.map +1 -1
- package/dist/vite-plugin.cjs +1 -1
- package/dist/vite-plugin.cjs.map +1 -1
- package/dist/vite-plugin.js +1 -1
- package/dist/vite-plugin.js.map +1 -1
- package/dist/vue/src/compile-time-t.d.ts +3 -0
- package/dist/vue/src/compile-time-t.d.ts.map +1 -0
- package/dist/vue/src/components/DateTime.d.ts.map +1 -0
- package/dist/vue/src/components/NumberFormat.d.ts.map +1 -0
- package/dist/vue/src/components/Plural.d.ts.map +1 -0
- package/dist/vue/src/components/Select.d.ts.map +1 -0
- package/dist/vue/src/components/Trans.d.ts.map +1 -0
- package/dist/vue/src/components/rich-text.d.ts.map +1 -0
- package/dist/{components-entry.d.ts → vue/src/components-entry.d.ts} +0 -1
- package/dist/vue/src/components-entry.d.ts.map +1 -0
- package/dist/vue/src/hooks/__useI18n.d.ts.map +1 -0
- package/dist/{index.d.ts → vue/src/index.d.ts} +6 -1
- package/dist/vue/src/index.d.ts.map +1 -0
- package/dist/vue/src/injection-key.d.ts.map +1 -0
- package/dist/vue/src/msg.d.ts +2 -0
- package/dist/vue/src/msg.d.ts.map +1 -0
- package/dist/{plugin.d.ts → vue/src/plugin.d.ts} +5 -5
- package/dist/vue/src/plugin.d.ts.map +1 -0
- package/dist/{server.d.ts → vue/src/server.d.ts} +3 -3
- package/dist/vue/src/server.d.ts.map +1 -0
- package/dist/vue/src/use-i18n.d.ts.map +1 -0
- package/dist/{vite-plugin.d.ts → vue/src/vite-plugin.d.ts} +2 -2
- package/dist/vue/src/vite-plugin.d.ts.map +1 -0
- package/dist/vue/src/vue-runtime.d.ts +3 -0
- package/dist/vue/src/vue-runtime.d.ts.map +1 -0
- package/package.json +18 -18
- package/dist/compile-time-t.d.ts +0 -3
- package/dist/compile-time-t.d.ts.map +0 -1
- package/dist/components/DateTime.d.ts.map +0 -1
- package/dist/components/NumberFormat.d.ts.map +0 -1
- package/dist/components/Plural.d.ts.map +0 -1
- package/dist/components/Select.d.ts.map +0 -1
- package/dist/components/Trans.d.ts.map +0 -1
- package/dist/components/rich-text.d.ts.map +0 -1
- package/dist/components-entry.cjs.map +0 -1
- package/dist/components-entry.d.ts.map +0 -1
- package/dist/components-entry.js.map +0 -1
- package/dist/hooks/__useI18n.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/injection-key.d.ts.map +0 -1
- package/dist/msg.d.ts +0 -2
- package/dist/msg.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/use-i18n-D6iu0pGX.cjs +0 -2
- package/dist/use-i18n-D6iu0pGX.cjs.map +0 -1
- package/dist/use-i18n-DV-MXUZc.js +0 -17
- package/dist/use-i18n-DV-MXUZc.js.map +0 -1
- package/dist/use-i18n.d.ts.map +0 -1
- package/dist/vite-plugin.d.ts.map +0 -1
- package/dist/vue-runtime.d.ts +0 -3
- package/dist/vue-runtime.d.ts.map +0 -1
- /package/dist/{components → vue/src/components}/DateTime.d.ts +0 -0
- /package/dist/{components → vue/src/components}/NumberFormat.d.ts +0 -0
- /package/dist/{components → vue/src/components}/Plural.d.ts +0 -0
- /package/dist/{components → vue/src/components}/Select.d.ts +0 -0
- /package/dist/{components → vue/src/components}/Trans.d.ts +0 -0
- /package/dist/{components → vue/src/components}/rich-text.d.ts +0 -0
- /package/dist/{hooks → vue/src/hooks}/__useI18n.d.ts +0 -0
- /package/dist/{injection-key.d.ts → vue/src/injection-key.d.ts} +0 -0
- /package/dist/{use-i18n.d.ts → vue/src/use-i18n.d.ts} +0 -0
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../src/plugin.ts","../src/compile-time-t.ts"],"sourcesContent":["import { type App, type Ref, ref, shallowReactive } from 'vue'\nimport type { AllMessages, Locale, LocalizedString, Messages, CompiledMessage, MessageDescriptor, DiagnosticsConfig, CustomFormatter } from '@fluenti/core'\nimport { createFluentiCore } from '@fluenti/core'\nimport { FLUENTI_KEY } from './injection-key'\n// Components are in @fluenti/vue/components subpath.\n// Global component registration is opt-in via `components` config option.\n\n/** Escape HTML special characters to prevent XSS. @internal */\nfunction escapeHtml(str: string): string {\n return str.replace(/&/g, '&').replace(/\"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>')\n}\n\n/** Compiled message 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.vue.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/** Context object returned by `useI18n()` and available as `$t` etc. on globalProperties */\nexport interface FluentiContext {\n /** Translate a message by id or MessageDescriptor, 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 /** Reactive ref for current locale */\n locale: Readonly<Ref<Locale>>\n /** Change the active locale (async when lazy locale loading is enabled) */\n setLocale(locale: Locale): Promise<void>\n /** Dynamically load messages for a locale */\n loadMessages(locale: Locale, messages: Messages): void\n /** Get all locales that have loaded messages */\n getLocales(): Locale[]\n /** Format a date value according to locale */\n d(value: Date | number, style?: string): LocalizedString\n /** Format a number according to 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: Readonly<Ref<boolean>>\n /** Set of locales whose messages have been loaded */\n loadedLocales: Readonly<Ref<ReadonlySet<string>>>\n /** Preload a locale in the background without switching to it */\n preloadLocale(locale: string): void\n /** Check if a translation key exists in the catalog */\n te(key: string, locale?: string): boolean\n /** Get the raw compiled message without interpolation */\n tm(key: string, locale?: string): CompiledMessage | undefined\n}\n\n/** Injection key for providing/injecting fluenti context */\nexport { FLUENTI_KEY } from './injection-key'\n\n/** Options for creating the Fluenti Vue plugin */\nexport interface FluentiConfig {\n locale: string\n fallbackLocale?: string\n messages: AllMessages\n missing?: (locale: string, id: string) => string | undefined\n dateFormats?: Record<string, Intl.DateTimeFormatOptions | 'relative'>\n numberFormats?: Record<string, Intl.NumberFormatOptions | ((locale: string) => Intl.NumberFormatOptions)>\n fallbackChain?: Record<string, string[]>\n /** Async chunk loader for lazy locale loading */\n chunkLoader?: ChunkLoader\n /** Enable lazy locale loading through chunkLoader */\n lazyLocaleLoading?: boolean\n /**\n * Prefix for globally registered components (Trans, Plural, Select).\n *\n * Set this to avoid naming conflicts with other libraries.\n *\n * @example\n * componentPrefix: 'I18n'\n * // Registers: I18nTrans, I18nPlural, I18nSelect\n *\n * @example\n * componentPrefix: 'Fluenti'\n * // Registers: FluentiTrans, FluentiPlural, FluentiSelect\n *\n * @default '' (no prefix — Trans, Plural, Select)\n */\n componentPrefix?: string\n /**\n * Whether to inject `$t`, `$d`, `$n`, `$vtRich` onto `app.config.globalProperties`.\n *\n * Set to `false` to avoid polluting the global namespace (e.g. when migrating from vue-i18n\n * or when using composition API exclusively via `useI18n()`).\n *\n * @default true\n */\n injectGlobalProperties?: boolean\n /** Runtime diagnostics configuration or pre-created instance */\n diagnostics?: DiagnosticsConfig | { missingKey: (locale: string, id: string) => void; fallbackUsed: (locale: string, fallbackLocale: string, id: string) => void; enabled: boolean }\n /**\n * Custom message interpolation function.\n *\n * By default, the runtime uses a lightweight `{key}` replacer.\n * Pass the full `interpolate` from `@fluenti/core/internal` for\n * runtime ICU MessageFormat parsing (adds ~2.5 KB gzip).\n *\n * @example\n * ```ts\n * import { interpolate } from '@fluenti/core/internal'\n * createFluenti({ interpolate, ... })\n * ```\n */\n interpolate?: (\n message: string,\n values: Record<string, unknown> | undefined,\n locale: string,\n formatters?: Record<string, CustomFormatter>,\n ) => string\n /**\n * Components to register globally via `app.component()`.\n *\n * Import from `@fluenti/vue/components` and pass here to enable global\n * component registration without bloating the default bundle.\n *\n * @example\n * ```ts\n * import * as components from '@fluenti/vue/components'\n * app.use(createFluenti({ components, ... }))\n * ```\n */\n components?: Record<string, unknown>\n}\n\n/** Return value of `createFluenti()` */\nexport interface FluentiPlugin {\n /** Vue plugin install method */\n install(app: App): void\n /** The global fluenti context (same as what useI18n returns) */\n global: FluentiContext\n}\n\n/** Extract the attribute name from v-t modifiers (e.g., v-t.alt → 'alt') */\nfunction getModifierAttr(modifiers: Partial<Record<string, boolean>>): string | undefined {\n const keys = Object.keys(modifiers).filter((k) => k !== 'plural')\n return keys.length > 0 ? keys[0] : undefined\n}\n\n/**\n * Create a Fluenti Vue plugin (SSR-safe, per-request instance).\n *\n * Each invocation creates entirely fresh state — no module-level singletons —\n * so it is safe to call once per SSR request.\n *\n * @example\n * ```ts\n * import { createFluenti } from '@fluenti/vue'\n * import messages from './locales/compiled/en.js'\n *\n * const fluenti = createFluenti({\n * locale: 'en',\n * messages: { en: messages },\n * })\n *\n * app.use(fluenti)\n * ```\n */\nexport function createFluenti(options: FluentiConfig): FluentiPlugin {\n const lazyLocaleLoading = options.lazyLocaleLoading\n ?? (options as FluentiConfig & { splitting?: boolean }).splitting\n ?? false\n\n // Create the core i18n instance — delegates t/d/n/format/loadMessages/getLocales\n // Build config incrementally to satisfy exactOptionalPropertyTypes —\n // optional properties must not receive `undefined` as a value.\n const coreConfig: Parameters<typeof createFluentiCore>[0] = {\n locale: options.locale,\n messages: options.messages ?? {},\n }\n if (options.fallbackLocale !== undefined) coreConfig.fallbackLocale = options.fallbackLocale\n if (options.fallbackChain !== undefined) coreConfig.fallbackChain = options.fallbackChain\n if (options.dateFormats !== undefined) coreConfig.dateFormats = options.dateFormats\n if (options.numberFormats !== undefined) coreConfig.numberFormats = options.numberFormats\n if (options.missing !== undefined) coreConfig.missing = options.missing\n if (options.diagnostics !== undefined) coreConfig.diagnostics = options.diagnostics as Parameters<typeof createFluentiCore>[0]['diagnostics']\n if (options.interpolate !== undefined) coreConfig.interpolate = options.interpolate\n coreConfig.devWarnings = coreConfig.devWarnings ?? (typeof process !== 'undefined' && process.env?.['NODE_ENV'] === 'development')\n const i18n = createFluentiCore(coreConfig)\n\n const locale = ref(options.locale)\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n const catalogs = shallowReactive<AllMessages>({ ...options.messages })\n const isLoading = ref(false)\n const loadedLocalesSet = new Set<string>([options.locale])\n const loadedLocales = ref<ReadonlySet<string>>(new Set(loadedLocalesSet))\n\n /** Local catalog lookup for te/tm (core doesn't expose raw catalog access) */\n function lookup(\n loc: Locale,\n id: string,\n ): CompiledMessage | undefined {\n const msgs = catalogs[loc]\n if (!msgs) return undefined\n return msgs[id]\n }\n\n /** Sync Vue reactive locale to core before delegation */\n function syncLocale(): void {\n if (i18n.locale !== locale.value) {\n i18n.locale = locale.value\n }\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 // Read locale.value and catalogs to register Vue reactive dependencies\n // so components re-render when locale or messages change\n const currentLocale = locale.value\n void catalogs[currentLocale]\n syncLocale()\n // Dispatch to the correct overload based on input type\n if (Array.isArray(idOrStrings) && 'raw' in idOrStrings) {\n return i18n.t(idOrStrings as TemplateStringsArray, ...rest)\n }\n return i18n.t(idOrStrings as string | MessageDescriptor, rest[0] as Record<string, unknown> | undefined)\n }\n\n let _localeRequestId = 0\n\n async function setLocale(newLocale: Locale): Promise<void> {\n if (!lazyLocaleLoading || !options.chunkLoader) {\n i18n.locale = newLocale\n locale.value = newLocale\n return\n }\n\n const splitRuntime = getSplitRuntimeModule()\n\n if (loadedLocalesSet.has(newLocale)) {\n // Already loaded, instant switch\n try {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n } catch (e) {\n console.warn(`[fluenti] split runtime switch failed for locale \"${newLocale}\"`, e)\n }\n i18n.locale = newLocale\n locale.value = newLocale\n return\n }\n\n // Race-condition protection: track request ID\n const thisRequest = ++_localeRequestId\n isLoading.value = true\n try {\n const messages = resolveChunkMessages(await options.chunkLoader(newLocale))\n // Stale request — a newer setLocale call superseded this one\n if (thisRequest !== _localeRequestId) return\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n catalogs[newLocale] = { ...catalogs[newLocale], ...messages }\n i18n.loadMessages(newLocale, messages)\n loadedLocalesSet.add(newLocale)\n loadedLocales.value = new Set(loadedLocalesSet)\n try {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n } catch (e) {\n console.warn(`[fluenti] split runtime switch failed for locale \"${newLocale}\"`, e)\n }\n // Re-check after async __switchLocale — a newer setLocale() may have superseded this one\n if (thisRequest !== _localeRequestId) return\n i18n.locale = newLocale\n locale.value = newLocale\n } finally {\n if (thisRequest === _localeRequestId) {\n isLoading.value = false\n }\n }\n }\n\n function loadMessages(loc: Locale, messages: Messages): void {\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n catalogs[loc] = { ...catalogs[loc], ...messages }\n i18n.loadMessages(loc, messages)\n loadedLocalesSet.add(loc)\n loadedLocales.value = new Set(loadedLocalesSet)\n }\n\n const _preloadInFlight = new Set<string>()\n\n function preloadLocale(loc: string): void {\n if (!lazyLocaleLoading || loadedLocalesSet.has(loc) || !options.chunkLoader || _preloadInFlight.has(loc)) return\n _preloadInFlight.add(loc)\n const splitRuntime = getSplitRuntimeModule()\n options.chunkLoader(loc).then(async (loaded) => {\n const messages = resolveChunkMessages(loaded)\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n catalogs[loc] = { ...catalogs[loc], ...messages }\n i18n.loadMessages(loc, messages)\n loadedLocalesSet.add(loc)\n loadedLocales.value = 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 function getLocales(): Locale[] {\n syncLocale()\n return i18n.getLocales()\n }\n\n function d(value: Date | number, style?: string): LocalizedString {\n // Read locale.value to register a Vue reactive dependency\n void locale.value\n syncLocale()\n return i18n.d(value, style)\n }\n\n function n(value: number, style?: string): LocalizedString {\n // Read locale.value to register a Vue reactive dependency\n void locale.value\n syncLocale()\n return i18n.n(value, style)\n }\n\n function format(message: string, values?: Record<string, unknown>): LocalizedString {\n // Read locale.value to register a Vue reactive dependency\n void locale.value\n syncLocale()\n return i18n.format(message, values)\n }\n\n /**\n * Rich text helper for v-t with child elements.\n * Translates the message (which contains `<0>content</0>` placeholders),\n * then replaces each placeholder with the original HTML element.\n * Used via `v-html=\"$vtRich('msg', elements)\"` in compile-time transforms.\n * @internal\n */\n function vtRich(\n message: string | MessageDescriptor,\n elements: Array<{ tag: string; attrs?: Record<string, string>; rawAttrs?: string }>,\n values?: Record<string, unknown>,\n ): string {\n const translated = values ? t(message, values) : t(message)\n // Escape the entire translated string first to neutralise any injected HTML\n const escaped = escapeHtml(translated)\n\n // Helper to build attribute string from element.\n // Both rawAttrs and attrs are escaped to prevent XSS — even though rawAttrs\n // originates from compile-time transforms, $vtRich is exposed on globalProperties\n // so we apply defence-in-depth.\n function buildAttrs(el: { attrs?: Record<string, string>; rawAttrs?: string }): string {\n if (el.rawAttrs != null && el.rawAttrs !== '') {\n // Parse rawAttrs back into key/value pairs and escape each one.\n // Handles: key=\"val\", key='val', and bare key (boolean attribute).\n const parts: string[] = []\n const attrRe = /([\\w:@.!-]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'))?/g\n let m: RegExpExecArray | null\n while ((m = attrRe.exec(el.rawAttrs)) !== null) {\n const key = escapeHtml(m[1]!)\n const val = m[2] ?? m[3]\n parts.push(val !== undefined ? `${key}=\"${escapeHtml(val)}\"` : key)\n }\n return parts.join(' ')\n }\n if (!el.attrs) return ''\n return Object.entries(el.attrs)\n .map(([k, v]) => v ? `${escapeHtml(k)}=\"${escapeHtml(v)}\"` : escapeHtml(k))\n .join(' ')\n }\n\n // First: handle self-closing <idx/> (escaped as <idx/>)\n let result = escaped.replace(/<(\\d+)\\/>/g, (_match, idxStr: string) => {\n const el = elements[Number(idxStr)]\n if (!el) return ''\n const tag = escapeHtml(el.tag)\n const attrs = buildAttrs(el)\n return `<${tag}${attrs ? ' ' + attrs : ''} />`\n })\n\n // Then: handle paired <idx>content</idx>\n result = result.replace(/<(\\d+)>([\\s\\S]*?)<\\/\\1>/g, (_match, idxStr: string, content: string) => {\n const el = elements[Number(idxStr)]\n if (!el) return content\n const tag = escapeHtml(el.tag)\n const attrs = buildAttrs(el)\n return `<${tag}${attrs ? ' ' + attrs : ''}>${content}</${tag}>`\n })\n\n return result\n }\n\n function te(key: string, loc?: string): boolean {\n const targetLocale = loc ?? locale.value\n return lookup(targetLocale, key) !== undefined\n }\n\n function tm(key: string, loc?: string): CompiledMessage | undefined {\n const targetLocale = loc ?? locale.value\n return lookup(targetLocale, key)\n }\n\n const context: FluentiContext = {\n t,\n locale,\n setLocale,\n loadMessages,\n getLocales,\n d,\n n,\n format,\n isLoading,\n loadedLocales,\n preloadLocale,\n te,\n tm,\n }\n\n return {\n install(app: App) {\n app.provide(FLUENTI_KEY, context)\n // Register components globally if provided via config\n if (options.components) {\n const prefix = options.componentPrefix ?? ''\n const comps = options.components as Record<string, unknown>\n if (comps['Trans']) app.component(`${prefix}Trans`, comps['Trans'] as any)\n if (comps['Plural']) app.component(`${prefix}Plural`, comps['Plural'] as any)\n if (comps['Select']) app.component(`${prefix}Select`, comps['Select'] as any)\n if (comps['DateTime']) app.component(`${prefix}DateTime`, comps['DateTime'] as any)\n if (comps['NumberFormat']) app.component(`${prefix}NumberFormat`, comps['NumberFormat'] as any)\n }\n if (options.injectGlobalProperties !== false) {\n app.config.globalProperties['$t'] = t\n app.config.globalProperties['$d'] = d\n app.config.globalProperties['$n'] = n\n app.config.globalProperties['$vtRich'] = vtRich\n }\n\n // Runtime v-t directive (fallback when compile-time transform is not used)\n const vtOriginalIds = new WeakMap<HTMLElement, string>()\n app.directive('t', {\n mounted(el, binding) {\n const attrName = getModifierAttr(binding.modifiers)\n if (attrName) {\n // v-t.alt, v-t.placeholder, etc. — translate the attribute\n const original = el.getAttribute(attrName) ?? ''\n vtOriginalIds.set(el, original)\n el.setAttribute(attrName, t(original))\n } else {\n // v-t or v-t:id — translate text content\n const id = binding.arg ?? el.textContent ?? ''\n vtOriginalIds.set(el, id.trim())\n el.textContent = t(id.trim(), binding.value != null ? { ...binding.value } : undefined)\n }\n },\n updated(el, binding) {\n const attrName = getModifierAttr(binding.modifiers)\n if (attrName) {\n const original = vtOriginalIds.get(el) ?? el.getAttribute(attrName) ?? ''\n el.setAttribute(attrName, t(original))\n } else {\n const id = binding.arg ?? vtOriginalIds.get(el) ?? ''\n el.textContent = t(id.trim(), binding.value != null ? { ...binding.value } : undefined)\n }\n },\n })\n },\n global: context,\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/vue' is a compile-time API. \" +\n 'Use it only with the Fluenti build transform inside <script setup> or setup(). ' +\n 'For runtime lookups, use useI18n().t(...).',\n )\n}) as CompileTimeT\n"],"mappings":"8JAQA,SAAS,EAAW,EAAqB,CACvC,OAAO,EAAI,QAAQ,KAAM,QAAQ,CAAC,QAAQ,KAAM,SAAS,CAAC,QAAQ,KAAM,QAAQ,CAAC,QAAQ,KAAM,OAAO,CAAC,QAAQ,KAAM,OAAO,CAa9H,IAAM,EAAoB,OAAO,IAAI,yBAAyB,CAE9D,SAAS,GAAmD,CAC1D,IAAM,EAAW,WAA4C,GAC7D,OAAO,OAAO,GAAY,UAAY,EAClC,EACA,KAGN,SAAS,EACP,EACiC,CACjC,OAAO,OAAO,GAAW,UAAY,GAAmB,YAAa,EAChE,EAAwD,QACzD,EAyHN,SAAS,EAAgB,EAAiE,CACxF,IAAM,EAAO,OAAO,KAAK,EAAU,CAAC,OAAQ,GAAM,IAAM,SAAS,CACjE,OAAO,EAAK,OAAS,EAAI,EAAK,GAAK,IAAA,GAsBrC,SAAgB,EAAc,EAAuC,CACnE,IAAM,EAAoB,EAAQ,mBAC5B,EAAoD,WACrD,GAKC,EAAsD,CAC1D,OAAQ,EAAQ,OAChB,SAAU,EAAQ,UAAY,EAAE,CACjC,CACG,EAAQ,iBAAmB,IAAA,KAAW,EAAW,eAAiB,EAAQ,gBAC1E,EAAQ,gBAAkB,IAAA,KAAW,EAAW,cAAgB,EAAQ,eACxE,EAAQ,cAAgB,IAAA,KAAW,EAAW,YAAc,EAAQ,aACpE,EAAQ,gBAAkB,IAAA,KAAW,EAAW,cAAgB,EAAQ,eACxE,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EAAS,CACnB,IAAM,EAAW,EAAgB,EAAQ,UAAU,CACnD,GAAI,EAAU,CAEZ,IAAM,EAAW,EAAG,aAAa,EAAS,EAAI,GAC9C,EAAc,IAAI,EAAI,EAAS,CAC/B,EAAG,aAAa,EAAU,EAAE,EAAS,CAAC,KACjC,CAEL,IAAM,EAAK,EAAQ,KAAO,EAAG,aAAe,GAC5C,EAAc,IAAI,EAAI,EAAG,MAAM,CAAC,CAChC,EAAG,YAAc,EAAE,EAAG,MAAM,CAAE,EAAQ,OAAS,KAA8B,IAAA,GAAvB,CAAE,GAAG,EAAQ,MAAO,CAAa,GAG3F,QAAQ,EAAI,EAAS,CACnB,IAAM,EAAW,EAAgB,EAAQ,UAAU,CACnD,GAAI,EAAU,CACZ,IAAM,EAAW,EAAc,IAAI,EAAG,EAAI,EAAG,aAAa,EAAS,EAAI,GACvE,EAAG,aAAa,EAAU,EAAE,EAAS,CAAC,MAGtC,EAAG,YAAc,GADN,EAAQ,KAAO,EAAc,IAAI,EAAG,EAAI,IAC7B,MAAM,CAAE,EAAQ,OAAS,KAA8B,IAAA,GAAvB,CAAE,GAAG,EAAQ,MAAO,CAAa,EAG5F,CAAC,EAEJ,OAAQ,EACT,CCzeH,IAAa,IAAoB,GAAG,IAAqB,CACvD,MAAU,MACR,8LAGD"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/plugin.ts","../src/compile-time-t.ts"],"sourcesContent":["import { type App, type Ref, ref, shallowReactive } from 'vue'\nimport type { AllMessages, Locale, LocalizedString, Messages, CompiledMessage, MessageDescriptor, DiagnosticsConfig, CustomFormatter } from '@fluenti/core'\nimport { createFluentiCore } from '@fluenti/core'\nimport { FLUENTI_KEY } from './injection-key'\n// Components are in @fluenti/vue subpath.\n// Global component registration is opt-in via `components` config option.\n\n/** Escape HTML special characters to prevent XSS. @internal */\nfunction escapeHtml(str: string): string {\n return str.replace(/&/g, '&').replace(/\"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>')\n}\n\n/** Compiled message 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.vue.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/** Context object returned by `useI18n()` and available as `$t` etc. on globalProperties */\nexport interface FluentiContext {\n /** Translate a message by id or MessageDescriptor, 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 /** Reactive ref for current locale */\n locale: Readonly<Ref<Locale>>\n /** Change the active locale (async when lazy locale loading is enabled) */\n setLocale(locale: Locale): Promise<void>\n /** Dynamically load messages for a locale */\n loadMessages(locale: Locale, messages: Messages): void\n /** Get all locales that have loaded messages */\n getLocales(): Locale[]\n /** Format a date value according to locale */\n d(value: Date | number, style?: string): LocalizedString\n /** Format a number according to 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: Readonly<Ref<boolean>>\n /** Set of locales whose messages have been loaded */\n loadedLocales: Readonly<Ref<ReadonlySet<string>>>\n /** Preload a locale in the background without switching to it */\n preloadLocale(locale: string): void\n /** Check if a translation key exists in the catalog */\n te(key: string, locale?: string): boolean\n /** Get the raw compiled message without interpolation */\n tm(key: string, locale?: string): CompiledMessage | undefined\n}\n\n/** Injection key for providing/injecting fluenti context */\nexport { FLUENTI_KEY } from './injection-key'\n\n/** Options for creating the Fluenti Vue plugin */\nexport interface FluentiConfig {\n locale: string\n fallbackLocale?: string\n messages: AllMessages\n missing?: (locale: string, id: string) => string | undefined\n dateFormats?: Record<string, Intl.DateTimeFormatOptions | 'relative'>\n numberFormats?: Record<string, Intl.NumberFormatOptions | ((locale: string) => Intl.NumberFormatOptions)>\n fallbackChain?: Record<string, string[]>\n /** Async chunk loader for lazy locale loading */\n chunkLoader?: ChunkLoader\n /** Enable lazy locale loading through chunkLoader */\n lazyLocaleLoading?: boolean\n /**\n * Prefix for globally registered components (Trans, Plural, Select).\n *\n * Set this to avoid naming conflicts with other libraries.\n *\n * @example\n * componentPrefix: 'I18n'\n * // Registers: I18nTrans, I18nPlural, I18nSelect\n *\n * @example\n * componentPrefix: 'Fluenti'\n * // Registers: FluentiTrans, FluentiPlural, FluentiSelect\n *\n * @default '' (no prefix — Trans, Plural, Select)\n */\n componentPrefix?: string\n /**\n * Whether to inject `$t`, `$d`, `$n`, `$vtRich` onto `app.config.globalProperties`.\n *\n * Set to `false` to avoid polluting the global namespace (e.g. when migrating from vue-i18n\n * or when using composition API exclusively via `useI18n()`).\n *\n * @default true\n */\n injectGlobalProperties?: boolean\n /** Runtime diagnostics configuration or pre-created instance */\n diagnostics?: DiagnosticsConfig | { missingKey: (locale: string, id: string) => void; fallbackUsed: (locale: string, fallbackLocale: string, id: string) => void; enabled: boolean }\n /**\n * Custom message interpolation function.\n *\n * By default, the runtime uses a lightweight `{key}` replacer.\n * Pass the full `interpolate` from `@fluenti/core/runtime` for\n * runtime ICU MessageFormat parsing (adds ~2.5 KB gzip).\n *\n * @example\n * ```ts\n * import { interpolate } from '@fluenti/core/runtime'\n * createFluenti({ interpolate, ... })\n * ```\n */\n interpolate?: (\n message: string,\n values: Record<string, unknown> | undefined,\n locale: string,\n formatters?: Record<string, CustomFormatter>,\n ) => string\n /**\n * Components to register globally via `app.component()`.\n *\n * Import from `@fluenti/vue` and pass here to enable global\n * component registration without bloating the default bundle.\n *\n * @example\n * ```ts\n * import * as components from '@fluenti/vue'\n * app.use(createFluenti({ components, ... }))\n * ```\n */\n components?: Record<string, unknown>\n}\n\n/** Return value of `createFluenti()` */\nexport interface FluentiPlugin {\n /** Vue plugin install method */\n install(app: App): void\n /** The global fluenti context (same as what useI18n returns) */\n global: FluentiContext\n}\n\n/** Extract the attribute name from v-t modifiers (e.g., v-t.alt → 'alt') */\nfunction getModifierAttr(modifiers: Partial<Record<string, boolean>>): string | undefined {\n const keys = Object.keys(modifiers).filter((k) => k !== 'plural')\n return keys.length > 0 ? keys[0] : undefined\n}\n\n/**\n * Create a Fluenti Vue plugin (SSR-safe, per-request instance).\n *\n * Each invocation creates entirely fresh state — no module-level singletons —\n * so it is safe to call once per SSR request.\n *\n * @example\n * ```ts\n * import { createFluenti } from '@fluenti/vue'\n * import messages from './locales/compiled/en.js'\n *\n * const fluenti = createFluenti({\n * locale: 'en',\n * messages: { en: messages },\n * })\n *\n * app.use(fluenti)\n * ```\n */\nexport function createFluenti(options: FluentiConfig): FluentiPlugin {\n const lazyLocaleLoading = options.lazyLocaleLoading\n ?? (options as FluentiConfig & { splitting?: boolean }).splitting\n ?? false\n\n // Create the core i18n instance — delegates t/d/n/format/loadMessages/getLocales\n // Build config incrementally to satisfy exactOptionalPropertyTypes —\n // optional properties must not receive `undefined` as a value.\n const coreConfig: Parameters<typeof createFluentiCore>[0] = {\n locale: options.locale,\n messages: options.messages ?? {},\n }\n if (options.fallbackLocale !== undefined) coreConfig.fallbackLocale = options.fallbackLocale\n if (options.fallbackChain !== undefined) coreConfig.fallbackChain = options.fallbackChain\n if (options.dateFormats !== undefined) coreConfig.dateFormats = options.dateFormats\n if (options.numberFormats !== undefined) coreConfig.numberFormats = options.numberFormats\n if (options.missing !== undefined) coreConfig.missing = options.missing\n if (options.diagnostics !== undefined) coreConfig.diagnostics = options.diagnostics as Parameters<typeof createFluentiCore>[0]['diagnostics']\n if (options.interpolate !== undefined) coreConfig.interpolate = options.interpolate\n coreConfig.devWarnings = coreConfig.devWarnings ?? (typeof process !== 'undefined' && process.env?.['NODE_ENV'] === 'development')\n const i18n = createFluentiCore(coreConfig)\n\n const locale = ref(options.locale)\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n const catalogs = shallowReactive<AllMessages>({ ...options.messages })\n const isLoading = ref(false)\n const loadedLocalesSet = new Set<string>([options.locale])\n const loadedLocales = ref<ReadonlySet<string>>(new Set(loadedLocalesSet))\n\n /** Local catalog lookup for te/tm (core doesn't expose raw catalog access) */\n function lookup(\n loc: Locale,\n id: string,\n ): CompiledMessage | undefined {\n const msgs = catalogs[loc]\n if (!msgs) return undefined\n return msgs[id]\n }\n\n /** Sync Vue reactive locale to core before delegation */\n function syncLocale(): void {\n if (i18n.locale !== locale.value) {\n i18n.locale = locale.value\n }\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 // Read locale.value and catalogs to register Vue reactive dependencies\n // so components re-render when locale or messages change\n const currentLocale = locale.value\n void catalogs[currentLocale]\n syncLocale()\n // Dispatch to the correct overload based on input type\n if (Array.isArray(idOrStrings) && 'raw' in idOrStrings) {\n return i18n.t(idOrStrings as TemplateStringsArray, ...rest)\n }\n return i18n.t(idOrStrings as string | MessageDescriptor, rest[0] as Record<string, unknown> | undefined)\n }\n\n let _localeRequestId = 0\n\n async function setLocale(newLocale: Locale): Promise<void> {\n if (!lazyLocaleLoading || !options.chunkLoader) {\n i18n.locale = newLocale\n locale.value = newLocale\n return\n }\n\n const splitRuntime = getSplitRuntimeModule()\n\n if (loadedLocalesSet.has(newLocale)) {\n // Already loaded, instant switch\n try {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n } catch (e) {\n console.warn(`[fluenti] split runtime switch failed for locale \"${newLocale}\"`, e)\n }\n i18n.locale = newLocale\n locale.value = newLocale\n return\n }\n\n // Race-condition protection: track request ID\n const thisRequest = ++_localeRequestId\n isLoading.value = true\n try {\n const messages = resolveChunkMessages(await options.chunkLoader(newLocale))\n // Stale request — a newer setLocale call superseded this one\n if (thisRequest !== _localeRequestId) return\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n catalogs[newLocale] = { ...catalogs[newLocale], ...messages }\n i18n.loadMessages(newLocale, messages)\n loadedLocalesSet.add(newLocale)\n loadedLocales.value = new Set(loadedLocalesSet)\n try {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n } catch (e) {\n console.warn(`[fluenti] split runtime switch failed for locale \"${newLocale}\"`, e)\n }\n // Re-check after async __switchLocale — a newer setLocale() may have superseded this one\n if (thisRequest !== _localeRequestId) return\n i18n.locale = newLocale\n locale.value = newLocale\n } finally {\n if (thisRequest === _localeRequestId) {\n isLoading.value = false\n }\n }\n }\n\n function loadMessages(loc: Locale, messages: Messages): void {\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n catalogs[loc] = { ...catalogs[loc], ...messages }\n i18n.loadMessages(loc, messages)\n loadedLocalesSet.add(loc)\n loadedLocales.value = new Set(loadedLocalesSet)\n }\n\n const _preloadInFlight = new Set<string>()\n\n function preloadLocale(loc: string): void {\n if (!lazyLocaleLoading || loadedLocalesSet.has(loc) || !options.chunkLoader || _preloadInFlight.has(loc)) return\n _preloadInFlight.add(loc)\n const splitRuntime = getSplitRuntimeModule()\n options.chunkLoader(loc).then(async (loaded) => {\n const messages = resolveChunkMessages(loaded)\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n catalogs[loc] = { ...catalogs[loc], ...messages }\n i18n.loadMessages(loc, messages)\n loadedLocalesSet.add(loc)\n loadedLocales.value = 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 function getLocales(): Locale[] {\n syncLocale()\n return i18n.getLocales()\n }\n\n function d(value: Date | number, style?: string): LocalizedString {\n // Read locale.value to register a Vue reactive dependency\n void locale.value\n syncLocale()\n return i18n.d(value, style)\n }\n\n function n(value: number, style?: string): LocalizedString {\n // Read locale.value to register a Vue reactive dependency\n void locale.value\n syncLocale()\n return i18n.n(value, style)\n }\n\n function format(message: string, values?: Record<string, unknown>): LocalizedString {\n // Read locale.value to register a Vue reactive dependency\n void locale.value\n syncLocale()\n return i18n.format(message, values)\n }\n\n /**\n * Rich text helper for v-t with child elements.\n * Translates the message (which contains `<0>content</0>` placeholders),\n * then replaces each placeholder with the original HTML element.\n * Used via `v-html=\"$vtRich('msg', elements)\"` in compile-time transforms.\n * @internal\n */\n function vtRich(\n message: string | MessageDescriptor,\n elements: Array<{ tag: string; attrs?: Record<string, string>; rawAttrs?: string }>,\n values?: Record<string, unknown>,\n ): string {\n const translated = values ? t(message, values) : t(message)\n // Escape the entire translated string first to neutralise any injected HTML\n const escaped = escapeHtml(translated)\n\n // Helper to build attribute string from element.\n // Both rawAttrs and attrs are escaped to prevent XSS — even though rawAttrs\n // originates from compile-time transforms, $vtRich is exposed on globalProperties\n // so we apply defence-in-depth.\n function buildAttrs(el: { attrs?: Record<string, string>; rawAttrs?: string }): string {\n if (el.rawAttrs != null && el.rawAttrs !== '') {\n // Parse rawAttrs back into key/value pairs and escape each one.\n // Handles: key=\"val\", key='val', and bare key (boolean attribute).\n const parts: string[] = []\n const attrRe = /([\\w:@.!-]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'))?/g\n let m: RegExpExecArray | null\n while ((m = attrRe.exec(el.rawAttrs)) !== null) {\n const key = escapeHtml(m[1]!)\n const val = m[2] ?? m[3]\n parts.push(val !== undefined ? `${key}=\"${escapeHtml(val)}\"` : key)\n }\n return parts.join(' ')\n }\n if (!el.attrs) return ''\n return Object.entries(el.attrs)\n .map(([k, v]) => v ? `${escapeHtml(k)}=\"${escapeHtml(v)}\"` : escapeHtml(k))\n .join(' ')\n }\n\n // First: handle self-closing <idx/> (escaped as <idx/>)\n let result = escaped.replace(/<(\\d+)\\/>/g, (_match, idxStr: string) => {\n const el = elements[Number(idxStr)]\n if (!el) return ''\n const tag = escapeHtml(el.tag)\n const attrs = buildAttrs(el)\n return `<${tag}${attrs ? ' ' + attrs : ''} />`\n })\n\n // Then: handle paired <idx>content</idx>\n result = result.replace(/<(\\d+)>([\\s\\S]*?)<\\/\\1>/g, (_match, idxStr: string, content: string) => {\n const el = elements[Number(idxStr)]\n if (!el) return content\n const tag = escapeHtml(el.tag)\n const attrs = buildAttrs(el)\n return `<${tag}${attrs ? ' ' + attrs : ''}>${content}</${tag}>`\n })\n\n return result\n }\n\n function te(key: string, loc?: string): boolean {\n const targetLocale = loc ?? locale.value\n return lookup(targetLocale, key) !== undefined\n }\n\n function tm(key: string, loc?: string): CompiledMessage | undefined {\n const targetLocale = loc ?? locale.value\n return lookup(targetLocale, key)\n }\n\n const context: FluentiContext = {\n t,\n locale,\n setLocale,\n loadMessages,\n getLocales,\n d,\n n,\n format,\n isLoading,\n loadedLocales,\n preloadLocale,\n te,\n tm,\n }\n\n return {\n install(app: App) {\n app.provide(FLUENTI_KEY, context)\n // Register components globally if provided via config\n if (options.components) {\n const prefix = options.componentPrefix ?? ''\n const comps = options.components as Record<string, unknown>\n if (comps['Trans']) app.component(`${prefix}Trans`, comps['Trans'] as any)\n if (comps['Plural']) app.component(`${prefix}Plural`, comps['Plural'] as any)\n if (comps['Select']) app.component(`${prefix}Select`, comps['Select'] as any)\n if (comps['DateTime']) app.component(`${prefix}DateTime`, comps['DateTime'] as any)\n if (comps['NumberFormat']) app.component(`${prefix}NumberFormat`, comps['NumberFormat'] as any)\n }\n if (options.injectGlobalProperties !== false) {\n app.config.globalProperties['$t'] = t\n app.config.globalProperties['$d'] = d\n app.config.globalProperties['$n'] = n\n app.config.globalProperties['$vtRich'] = vtRich\n }\n\n // Runtime v-t directive (fallback when compile-time transform is not used)\n const vtOriginalIds = new WeakMap<HTMLElement, string>()\n app.directive('t', {\n mounted(el, binding) {\n const attrName = getModifierAttr(binding.modifiers)\n if (attrName) {\n // v-t.alt, v-t.placeholder, etc. — translate the attribute\n const original = el.getAttribute(attrName) ?? ''\n vtOriginalIds.set(el, original)\n el.setAttribute(attrName, t(original))\n } else {\n // v-t or v-t:id — translate text content\n const id = binding.arg ?? el.textContent ?? ''\n vtOriginalIds.set(el, id.trim())\n el.textContent = t(id.trim(), binding.value != null ? { ...binding.value } : undefined)\n }\n },\n updated(el, binding) {\n const attrName = getModifierAttr(binding.modifiers)\n if (attrName) {\n const original = vtOriginalIds.get(el) ?? el.getAttribute(attrName) ?? ''\n el.setAttribute(attrName, t(original))\n } else {\n const id = binding.arg ?? vtOriginalIds.get(el) ?? ''\n el.textContent = t(id.trim(), binding.value != null ? { ...binding.value } : undefined)\n }\n },\n })\n },\n global: context,\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/vue' is a compile-time API. \" +\n 'Use it only with the Fluenti build transform inside <script setup> or setup(). ' +\n 'For runtime lookups, use useI18n().t(...).',\n )\n}) as CompileTimeT\n"],"mappings":"kKAQA,SAAS,EAAW,EAAqB,CACvC,OAAO,EAAI,QAAQ,KAAM,QAAQ,CAAC,QAAQ,KAAM,SAAS,CAAC,QAAQ,KAAM,QAAQ,CAAC,QAAQ,KAAM,OAAO,CAAC,QAAQ,KAAM,OAAO,CAa9H,IAAM,EAAoB,OAAO,IAAI,yBAAyB,CA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,EAAU,EAAE,EAAS,CAAC,MAGtC,EAAG,YAAc,GADN,EAAQ,KAAO,EAAc,IAAI,EAAG,EAAI,IAC7B,MAAM,CAAE,EAAQ,OAAS,KAA8B,IAAA,GAAvB,CAAE,GAAG,EAAQ,MAAO,CAAa,EAG5F,CAAC,EAEJ,OAAQ,EACT,CCzeH,IAAa,IAAoB,GAAG,IAAqB,CACvD,MAAU,MACR,8LAGD"}
|
package/dist/index.js
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ref as
|
|
3
|
-
import { createFluentiCore as
|
|
1
|
+
import { a as e, c as t, i as n, n as r, o as i, r as a, s as o, t as s } from "./NumberFormat-Bxim144o.js";
|
|
2
|
+
import { ref as c, shallowReactive as l } from "vue";
|
|
3
|
+
import { createFluentiCore as u, msg as d } from "@fluenti/core";
|
|
4
4
|
//#region src/plugin.ts
|
|
5
|
-
function
|
|
5
|
+
function f(e) {
|
|
6
6
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
7
7
|
}
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
let e = globalThis[
|
|
8
|
+
var p = Symbol.for("fluenti.runtime.vue.v1");
|
|
9
|
+
function m() {
|
|
10
|
+
let e = globalThis[p];
|
|
11
11
|
return typeof e == "object" && e ? e : null;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function h(e) {
|
|
14
14
|
return typeof e == "object" && e && "default" in e ? e.default : e;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function g(e) {
|
|
17
17
|
let t = Object.keys(e).filter((e) => e !== "plural");
|
|
18
18
|
return t.length > 0 ? t[0] : void 0;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
let n = e.lazyLocaleLoading ?? e.splitting ?? !1,
|
|
20
|
+
function _(e) {
|
|
21
|
+
let n = e.lazyLocaleLoading ?? e.splitting ?? !1, r = {
|
|
22
22
|
locale: e.locale,
|
|
23
23
|
messages: e.messages ?? {}
|
|
24
24
|
};
|
|
25
|
-
e.fallbackLocale !== void 0 && (
|
|
26
|
-
let
|
|
25
|
+
e.fallbackLocale !== void 0 && (r.fallbackLocale = e.fallbackLocale), e.fallbackChain !== void 0 && (r.fallbackChain = e.fallbackChain), e.dateFormats !== void 0 && (r.dateFormats = e.dateFormats), e.numberFormats !== void 0 && (r.numberFormats = e.numberFormats), e.missing !== void 0 && (r.missing = e.missing), e.diagnostics !== void 0 && (r.diagnostics = e.diagnostics), e.interpolate !== void 0 && (r.interpolate = e.interpolate), r.devWarnings = r.devWarnings ?? (typeof process < "u" && process.env.NODE_ENV === "development");
|
|
26
|
+
let i = u(r), a = c(e.locale), o = l({ ...e.messages }), s = c(!1), d = new Set([e.locale]), p = c(new Set(d));
|
|
27
27
|
function _(e, t) {
|
|
28
|
-
let n =
|
|
28
|
+
let n = o[e];
|
|
29
29
|
if (n) return n[t];
|
|
30
30
|
}
|
|
31
31
|
function v() {
|
|
32
|
-
|
|
32
|
+
i.locale !== a.value && (i.locale = a.value);
|
|
33
33
|
}
|
|
34
34
|
function y(e, ...t) {
|
|
35
|
-
return
|
|
35
|
+
return o[a.value], v(), Array.isArray(e) && "raw" in e ? i.t(e, ...t) : i.t(e, t[0]);
|
|
36
36
|
}
|
|
37
37
|
let b = 0;
|
|
38
38
|
async function x(t) {
|
|
39
39
|
if (!n || !e.chunkLoader) {
|
|
40
|
-
|
|
40
|
+
i.locale = t, a.value = t;
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
let r =
|
|
44
|
-
if (
|
|
43
|
+
let r = m();
|
|
44
|
+
if (d.has(t)) {
|
|
45
45
|
try {
|
|
46
46
|
r?.__switchLocale && await r.__switchLocale(t);
|
|
47
47
|
} catch (e) {
|
|
48
48
|
console.warn(`[fluenti] split runtime switch failed for locale "${t}"`, e);
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
i.locale = t, a.value = t;
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
let
|
|
54
|
-
|
|
53
|
+
let c = ++b;
|
|
54
|
+
s.value = !0;
|
|
55
55
|
try {
|
|
56
|
-
let n =
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
...
|
|
56
|
+
let n = h(await e.chunkLoader(t));
|
|
57
|
+
if (c !== b) return;
|
|
58
|
+
o[t] = {
|
|
59
|
+
...o[t],
|
|
60
60
|
...n
|
|
61
|
-
},
|
|
61
|
+
}, i.loadMessages(t, n), d.add(t), p.value = new Set(d);
|
|
62
62
|
try {
|
|
63
63
|
r?.__switchLocale && await r.__switchLocale(t);
|
|
64
64
|
} catch (e) {
|
|
65
65
|
console.warn(`[fluenti] split runtime switch failed for locale "${t}"`, e);
|
|
66
66
|
}
|
|
67
|
-
if (
|
|
68
|
-
|
|
67
|
+
if (c !== b) return;
|
|
68
|
+
i.locale = t, a.value = t;
|
|
69
69
|
} finally {
|
|
70
|
-
|
|
70
|
+
c === b && (s.value = !1);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
function S(e, t) {
|
|
74
|
-
|
|
75
|
-
...
|
|
74
|
+
o[e] = {
|
|
75
|
+
...o[e],
|
|
76
76
|
...t
|
|
77
|
-
},
|
|
77
|
+
}, i.loadMessages(e, t), d.add(e), p.value = new Set(d);
|
|
78
78
|
}
|
|
79
79
|
let C = /* @__PURE__ */ new Set();
|
|
80
80
|
function w(t) {
|
|
81
|
-
if (!n ||
|
|
81
|
+
if (!n || d.has(t) || !e.chunkLoader || C.has(t)) return;
|
|
82
82
|
C.add(t);
|
|
83
|
-
let r =
|
|
83
|
+
let r = m();
|
|
84
84
|
e.chunkLoader(t).then(async (e) => {
|
|
85
|
-
let n =
|
|
86
|
-
|
|
87
|
-
...
|
|
85
|
+
let n = h(e);
|
|
86
|
+
o[t] = {
|
|
87
|
+
...o[t],
|
|
88
88
|
...n
|
|
89
|
-
},
|
|
89
|
+
}, i.loadMessages(t, n), d.add(t), p.value = new Set(d), r?.__preloadLocale && await r.__preloadLocale(t);
|
|
90
90
|
}).catch((e) => {
|
|
91
91
|
console.warn("[fluenti] preload failed:", t, e);
|
|
92
92
|
}).finally(() => {
|
|
@@ -94,60 +94,60 @@ function f(e) {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
function T() {
|
|
97
|
-
return v(),
|
|
97
|
+
return v(), i.getLocales();
|
|
98
98
|
}
|
|
99
99
|
function E(e, t) {
|
|
100
|
-
return
|
|
100
|
+
return a.value, v(), i.d(e, t);
|
|
101
101
|
}
|
|
102
102
|
function D(e, t) {
|
|
103
|
-
return
|
|
103
|
+
return a.value, v(), i.n(e, t);
|
|
104
104
|
}
|
|
105
105
|
function O(e, t) {
|
|
106
|
-
return
|
|
106
|
+
return a.value, v(), i.format(e, t);
|
|
107
107
|
}
|
|
108
108
|
function k(e, t, n) {
|
|
109
|
-
let r =
|
|
109
|
+
let r = f(n ? y(e, n) : y(e));
|
|
110
110
|
function i(e) {
|
|
111
111
|
if (e.rawAttrs != null && e.rawAttrs !== "") {
|
|
112
112
|
let t = [], n = /([\w:@.!-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'))?/g, r;
|
|
113
113
|
for (; (r = n.exec(e.rawAttrs)) !== null;) {
|
|
114
|
-
let e =
|
|
115
|
-
t.push(n === void 0 ? e : `${e}="${
|
|
114
|
+
let e = f(r[1]), n = r[2] ?? r[3];
|
|
115
|
+
t.push(n === void 0 ? e : `${e}="${f(n)}"`);
|
|
116
116
|
}
|
|
117
117
|
return t.join(" ");
|
|
118
118
|
}
|
|
119
|
-
return e.attrs ? Object.entries(e.attrs).map(([e, t]) => t ? `${
|
|
119
|
+
return e.attrs ? Object.entries(e.attrs).map(([e, t]) => t ? `${f(e)}="${f(t)}"` : f(e)).join(" ") : "";
|
|
120
120
|
}
|
|
121
121
|
let a = r.replace(/<(\d+)\/>/g, (e, n) => {
|
|
122
122
|
let r = t[Number(n)];
|
|
123
123
|
if (!r) return "";
|
|
124
|
-
let a =
|
|
124
|
+
let a = f(r.tag), o = i(r);
|
|
125
125
|
return `<${a}${o ? " " + o : ""} />`;
|
|
126
126
|
});
|
|
127
127
|
return a = a.replace(/<(\d+)>([\s\S]*?)<\/\1>/g, (e, n, r) => {
|
|
128
128
|
let a = t[Number(n)];
|
|
129
129
|
if (!a) return r;
|
|
130
|
-
let o =
|
|
131
|
-
return `<${o}${
|
|
130
|
+
let o = f(a.tag), s = i(a);
|
|
131
|
+
return `<${o}${s ? " " + s : ""}>${r}</${o}>`;
|
|
132
132
|
}), a;
|
|
133
133
|
}
|
|
134
134
|
function A(e, t) {
|
|
135
|
-
return _(t ??
|
|
135
|
+
return _(t ?? a.value, e) !== void 0;
|
|
136
136
|
}
|
|
137
137
|
function j(e, t) {
|
|
138
|
-
return _(t ??
|
|
138
|
+
return _(t ?? a.value, e);
|
|
139
139
|
}
|
|
140
140
|
let M = {
|
|
141
141
|
t: y,
|
|
142
|
-
locale:
|
|
142
|
+
locale: a,
|
|
143
143
|
setLocale: x,
|
|
144
144
|
loadMessages: S,
|
|
145
145
|
getLocales: T,
|
|
146
146
|
d: E,
|
|
147
147
|
n: D,
|
|
148
148
|
format: O,
|
|
149
|
-
isLoading:
|
|
150
|
-
loadedLocales:
|
|
149
|
+
isLoading: s,
|
|
150
|
+
loadedLocales: p,
|
|
151
151
|
preloadLocale: w,
|
|
152
152
|
te: A,
|
|
153
153
|
tm: j
|
|
@@ -162,7 +162,7 @@ function f(e) {
|
|
|
162
162
|
let r = /* @__PURE__ */ new WeakMap();
|
|
163
163
|
n.directive("t", {
|
|
164
164
|
mounted(e, t) {
|
|
165
|
-
let n =
|
|
165
|
+
let n = g(t.modifiers);
|
|
166
166
|
if (n) {
|
|
167
167
|
let t = e.getAttribute(n) ?? "";
|
|
168
168
|
r.set(e, t), e.setAttribute(n, y(t));
|
|
@@ -172,7 +172,7 @@ function f(e) {
|
|
|
172
172
|
}
|
|
173
173
|
},
|
|
174
174
|
updated(e, t) {
|
|
175
|
-
let n =
|
|
175
|
+
let n = g(t.modifiers);
|
|
176
176
|
if (n) {
|
|
177
177
|
let t = r.get(e) ?? e.getAttribute(n) ?? "";
|
|
178
178
|
e.setAttribute(n, y(t));
|
|
@@ -185,10 +185,10 @@ function f(e) {
|
|
|
185
185
|
}
|
|
186
186
|
//#endregion
|
|
187
187
|
//#region src/compile-time-t.ts
|
|
188
|
-
var
|
|
188
|
+
var v = ((...e) => {
|
|
189
189
|
throw Error("[fluenti] `t` imported from '@fluenti/vue' is a compile-time API. Use it only with the Fluenti build transform inside <script setup> or setup(). For runtime lookups, use useI18n().t(...).");
|
|
190
190
|
});
|
|
191
191
|
//#endregion
|
|
192
|
-
export { t as FLUENTI_KEY,
|
|
192
|
+
export { r as DateTime, t as FLUENTI_KEY, s as NumberFormat, n as Plural, a as Select, e as Trans, _ as createFluenti, d as msg, v as t, i as useI18n, o as useLocale };
|
|
193
193
|
|
|
194
194
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/plugin.ts","../src/compile-time-t.ts"],"sourcesContent":["import { type App, type Ref, ref, shallowReactive } from 'vue'\nimport type { AllMessages, Locale, LocalizedString, Messages, CompiledMessage, MessageDescriptor, DiagnosticsConfig, CustomFormatter } from '@fluenti/core'\nimport { createFluentiCore } from '@fluenti/core'\nimport { FLUENTI_KEY } from './injection-key'\n// Components are in @fluenti/vue/components subpath.\n// Global component registration is opt-in via `components` config option.\n\n/** Escape HTML special characters to prevent XSS. @internal */\nfunction escapeHtml(str: string): string {\n return str.replace(/&/g, '&').replace(/\"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>')\n}\n\n/** Compiled message 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.vue.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/** Context object returned by `useI18n()` and available as `$t` etc. on globalProperties */\nexport interface FluentiContext {\n /** Translate a message by id or MessageDescriptor, 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 /** Reactive ref for current locale */\n locale: Readonly<Ref<Locale>>\n /** Change the active locale (async when lazy locale loading is enabled) */\n setLocale(locale: Locale): Promise<void>\n /** Dynamically load messages for a locale */\n loadMessages(locale: Locale, messages: Messages): void\n /** Get all locales that have loaded messages */\n getLocales(): Locale[]\n /** Format a date value according to locale */\n d(value: Date | number, style?: string): LocalizedString\n /** Format a number according to 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: Readonly<Ref<boolean>>\n /** Set of locales whose messages have been loaded */\n loadedLocales: Readonly<Ref<ReadonlySet<string>>>\n /** Preload a locale in the background without switching to it */\n preloadLocale(locale: string): void\n /** Check if a translation key exists in the catalog */\n te(key: string, locale?: string): boolean\n /** Get the raw compiled message without interpolation */\n tm(key: string, locale?: string): CompiledMessage | undefined\n}\n\n/** Injection key for providing/injecting fluenti context */\nexport { FLUENTI_KEY } from './injection-key'\n\n/** Options for creating the Fluenti Vue plugin */\nexport interface FluentiConfig {\n locale: string\n fallbackLocale?: string\n messages: AllMessages\n missing?: (locale: string, id: string) => string | undefined\n dateFormats?: Record<string, Intl.DateTimeFormatOptions | 'relative'>\n numberFormats?: Record<string, Intl.NumberFormatOptions | ((locale: string) => Intl.NumberFormatOptions)>\n fallbackChain?: Record<string, string[]>\n /** Async chunk loader for lazy locale loading */\n chunkLoader?: ChunkLoader\n /** Enable lazy locale loading through chunkLoader */\n lazyLocaleLoading?: boolean\n /**\n * Prefix for globally registered components (Trans, Plural, Select).\n *\n * Set this to avoid naming conflicts with other libraries.\n *\n * @example\n * componentPrefix: 'I18n'\n * // Registers: I18nTrans, I18nPlural, I18nSelect\n *\n * @example\n * componentPrefix: 'Fluenti'\n * // Registers: FluentiTrans, FluentiPlural, FluentiSelect\n *\n * @default '' (no prefix — Trans, Plural, Select)\n */\n componentPrefix?: string\n /**\n * Whether to inject `$t`, `$d`, `$n`, `$vtRich` onto `app.config.globalProperties`.\n *\n * Set to `false` to avoid polluting the global namespace (e.g. when migrating from vue-i18n\n * or when using composition API exclusively via `useI18n()`).\n *\n * @default true\n */\n injectGlobalProperties?: boolean\n /** Runtime diagnostics configuration or pre-created instance */\n diagnostics?: DiagnosticsConfig | { missingKey: (locale: string, id: string) => void; fallbackUsed: (locale: string, fallbackLocale: string, id: string) => void; enabled: boolean }\n /**\n * Custom message interpolation function.\n *\n * By default, the runtime uses a lightweight `{key}` replacer.\n * Pass the full `interpolate` from `@fluenti/core/internal` for\n * runtime ICU MessageFormat parsing (adds ~2.5 KB gzip).\n *\n * @example\n * ```ts\n * import { interpolate } from '@fluenti/core/internal'\n * createFluenti({ interpolate, ... })\n * ```\n */\n interpolate?: (\n message: string,\n values: Record<string, unknown> | undefined,\n locale: string,\n formatters?: Record<string, CustomFormatter>,\n ) => string\n /**\n * Components to register globally via `app.component()`.\n *\n * Import from `@fluenti/vue/components` and pass here to enable global\n * component registration without bloating the default bundle.\n *\n * @example\n * ```ts\n * import * as components from '@fluenti/vue/components'\n * app.use(createFluenti({ components, ... }))\n * ```\n */\n components?: Record<string, unknown>\n}\n\n/** Return value of `createFluenti()` */\nexport interface FluentiPlugin {\n /** Vue plugin install method */\n install(app: App): void\n /** The global fluenti context (same as what useI18n returns) */\n global: FluentiContext\n}\n\n/** Extract the attribute name from v-t modifiers (e.g., v-t.alt → 'alt') */\nfunction getModifierAttr(modifiers: Partial<Record<string, boolean>>): string | undefined {\n const keys = Object.keys(modifiers).filter((k) => k !== 'plural')\n return keys.length > 0 ? keys[0] : undefined\n}\n\n/**\n * Create a Fluenti Vue plugin (SSR-safe, per-request instance).\n *\n * Each invocation creates entirely fresh state — no module-level singletons —\n * so it is safe to call once per SSR request.\n *\n * @example\n * ```ts\n * import { createFluenti } from '@fluenti/vue'\n * import messages from './locales/compiled/en.js'\n *\n * const fluenti = createFluenti({\n * locale: 'en',\n * messages: { en: messages },\n * })\n *\n * app.use(fluenti)\n * ```\n */\nexport function createFluenti(options: FluentiConfig): FluentiPlugin {\n const lazyLocaleLoading = options.lazyLocaleLoading\n ?? (options as FluentiConfig & { splitting?: boolean }).splitting\n ?? false\n\n // Create the core i18n instance — delegates t/d/n/format/loadMessages/getLocales\n // Build config incrementally to satisfy exactOptionalPropertyTypes —\n // optional properties must not receive `undefined` as a value.\n const coreConfig: Parameters<typeof createFluentiCore>[0] = {\n locale: options.locale,\n messages: options.messages ?? {},\n }\n if (options.fallbackLocale !== undefined) coreConfig.fallbackLocale = options.fallbackLocale\n if (options.fallbackChain !== undefined) coreConfig.fallbackChain = options.fallbackChain\n if (options.dateFormats !== undefined) coreConfig.dateFormats = options.dateFormats\n if (options.numberFormats !== undefined) coreConfig.numberFormats = options.numberFormats\n if (options.missing !== undefined) coreConfig.missing = options.missing\n if (options.diagnostics !== undefined) coreConfig.diagnostics = options.diagnostics as Parameters<typeof createFluentiCore>[0]['diagnostics']\n if (options.interpolate !== undefined) coreConfig.interpolate = options.interpolate\n coreConfig.devWarnings = coreConfig.devWarnings ?? (typeof process !== 'undefined' && process.env?.['NODE_ENV'] === 'development')\n const i18n = createFluentiCore(coreConfig)\n\n const locale = ref(options.locale)\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n const catalogs = shallowReactive<AllMessages>({ ...options.messages })\n const isLoading = ref(false)\n const loadedLocalesSet = new Set<string>([options.locale])\n const loadedLocales = ref<ReadonlySet<string>>(new Set(loadedLocalesSet))\n\n /** Local catalog lookup for te/tm (core doesn't expose raw catalog access) */\n function lookup(\n loc: Locale,\n id: string,\n ): CompiledMessage | undefined {\n const msgs = catalogs[loc]\n if (!msgs) return undefined\n return msgs[id]\n }\n\n /** Sync Vue reactive locale to core before delegation */\n function syncLocale(): void {\n if (i18n.locale !== locale.value) {\n i18n.locale = locale.value\n }\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 // Read locale.value and catalogs to register Vue reactive dependencies\n // so components re-render when locale or messages change\n const currentLocale = locale.value\n void catalogs[currentLocale]\n syncLocale()\n // Dispatch to the correct overload based on input type\n if (Array.isArray(idOrStrings) && 'raw' in idOrStrings) {\n return i18n.t(idOrStrings as TemplateStringsArray, ...rest)\n }\n return i18n.t(idOrStrings as string | MessageDescriptor, rest[0] as Record<string, unknown> | undefined)\n }\n\n let _localeRequestId = 0\n\n async function setLocale(newLocale: Locale): Promise<void> {\n if (!lazyLocaleLoading || !options.chunkLoader) {\n i18n.locale = newLocale\n locale.value = newLocale\n return\n }\n\n const splitRuntime = getSplitRuntimeModule()\n\n if (loadedLocalesSet.has(newLocale)) {\n // Already loaded, instant switch\n try {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n } catch (e) {\n console.warn(`[fluenti] split runtime switch failed for locale \"${newLocale}\"`, e)\n }\n i18n.locale = newLocale\n locale.value = newLocale\n return\n }\n\n // Race-condition protection: track request ID\n const thisRequest = ++_localeRequestId\n isLoading.value = true\n try {\n const messages = resolveChunkMessages(await options.chunkLoader(newLocale))\n // Stale request — a newer setLocale call superseded this one\n if (thisRequest !== _localeRequestId) return\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n catalogs[newLocale] = { ...catalogs[newLocale], ...messages }\n i18n.loadMessages(newLocale, messages)\n loadedLocalesSet.add(newLocale)\n loadedLocales.value = new Set(loadedLocalesSet)\n try {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n } catch (e) {\n console.warn(`[fluenti] split runtime switch failed for locale \"${newLocale}\"`, e)\n }\n // Re-check after async __switchLocale — a newer setLocale() may have superseded this one\n if (thisRequest !== _localeRequestId) return\n i18n.locale = newLocale\n locale.value = newLocale\n } finally {\n if (thisRequest === _localeRequestId) {\n isLoading.value = false\n }\n }\n }\n\n function loadMessages(loc: Locale, messages: Messages): void {\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n catalogs[loc] = { ...catalogs[loc], ...messages }\n i18n.loadMessages(loc, messages)\n loadedLocalesSet.add(loc)\n loadedLocales.value = new Set(loadedLocalesSet)\n }\n\n const _preloadInFlight = new Set<string>()\n\n function preloadLocale(loc: string): void {\n if (!lazyLocaleLoading || loadedLocalesSet.has(loc) || !options.chunkLoader || _preloadInFlight.has(loc)) return\n _preloadInFlight.add(loc)\n const splitRuntime = getSplitRuntimeModule()\n options.chunkLoader(loc).then(async (loaded) => {\n const messages = resolveChunkMessages(loaded)\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n catalogs[loc] = { ...catalogs[loc], ...messages }\n i18n.loadMessages(loc, messages)\n loadedLocalesSet.add(loc)\n loadedLocales.value = 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 function getLocales(): Locale[] {\n syncLocale()\n return i18n.getLocales()\n }\n\n function d(value: Date | number, style?: string): LocalizedString {\n // Read locale.value to register a Vue reactive dependency\n void locale.value\n syncLocale()\n return i18n.d(value, style)\n }\n\n function n(value: number, style?: string): LocalizedString {\n // Read locale.value to register a Vue reactive dependency\n void locale.value\n syncLocale()\n return i18n.n(value, style)\n }\n\n function format(message: string, values?: Record<string, unknown>): LocalizedString {\n // Read locale.value to register a Vue reactive dependency\n void locale.value\n syncLocale()\n return i18n.format(message, values)\n }\n\n /**\n * Rich text helper for v-t with child elements.\n * Translates the message (which contains `<0>content</0>` placeholders),\n * then replaces each placeholder with the original HTML element.\n * Used via `v-html=\"$vtRich('msg', elements)\"` in compile-time transforms.\n * @internal\n */\n function vtRich(\n message: string | MessageDescriptor,\n elements: Array<{ tag: string; attrs?: Record<string, string>; rawAttrs?: string }>,\n values?: Record<string, unknown>,\n ): string {\n const translated = values ? t(message, values) : t(message)\n // Escape the entire translated string first to neutralise any injected HTML\n const escaped = escapeHtml(translated)\n\n // Helper to build attribute string from element.\n // Both rawAttrs and attrs are escaped to prevent XSS — even though rawAttrs\n // originates from compile-time transforms, $vtRich is exposed on globalProperties\n // so we apply defence-in-depth.\n function buildAttrs(el: { attrs?: Record<string, string>; rawAttrs?: string }): string {\n if (el.rawAttrs != null && el.rawAttrs !== '') {\n // Parse rawAttrs back into key/value pairs and escape each one.\n // Handles: key=\"val\", key='val', and bare key (boolean attribute).\n const parts: string[] = []\n const attrRe = /([\\w:@.!-]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'))?/g\n let m: RegExpExecArray | null\n while ((m = attrRe.exec(el.rawAttrs)) !== null) {\n const key = escapeHtml(m[1]!)\n const val = m[2] ?? m[3]\n parts.push(val !== undefined ? `${key}=\"${escapeHtml(val)}\"` : key)\n }\n return parts.join(' ')\n }\n if (!el.attrs) return ''\n return Object.entries(el.attrs)\n .map(([k, v]) => v ? `${escapeHtml(k)}=\"${escapeHtml(v)}\"` : escapeHtml(k))\n .join(' ')\n }\n\n // First: handle self-closing <idx/> (escaped as <idx/>)\n let result = escaped.replace(/<(\\d+)\\/>/g, (_match, idxStr: string) => {\n const el = elements[Number(idxStr)]\n if (!el) return ''\n const tag = escapeHtml(el.tag)\n const attrs = buildAttrs(el)\n return `<${tag}${attrs ? ' ' + attrs : ''} />`\n })\n\n // Then: handle paired <idx>content</idx>\n result = result.replace(/<(\\d+)>([\\s\\S]*?)<\\/\\1>/g, (_match, idxStr: string, content: string) => {\n const el = elements[Number(idxStr)]\n if (!el) return content\n const tag = escapeHtml(el.tag)\n const attrs = buildAttrs(el)\n return `<${tag}${attrs ? ' ' + attrs : ''}>${content}</${tag}>`\n })\n\n return result\n }\n\n function te(key: string, loc?: string): boolean {\n const targetLocale = loc ?? locale.value\n return lookup(targetLocale, key) !== undefined\n }\n\n function tm(key: string, loc?: string): CompiledMessage | undefined {\n const targetLocale = loc ?? locale.value\n return lookup(targetLocale, key)\n }\n\n const context: FluentiContext = {\n t,\n locale,\n setLocale,\n loadMessages,\n getLocales,\n d,\n n,\n format,\n isLoading,\n loadedLocales,\n preloadLocale,\n te,\n tm,\n }\n\n return {\n install(app: App) {\n app.provide(FLUENTI_KEY, context)\n // Register components globally if provided via config\n if (options.components) {\n const prefix = options.componentPrefix ?? ''\n const comps = options.components as Record<string, unknown>\n if (comps['Trans']) app.component(`${prefix}Trans`, comps['Trans'] as any)\n if (comps['Plural']) app.component(`${prefix}Plural`, comps['Plural'] as any)\n if (comps['Select']) app.component(`${prefix}Select`, comps['Select'] as any)\n if (comps['DateTime']) app.component(`${prefix}DateTime`, comps['DateTime'] as any)\n if (comps['NumberFormat']) app.component(`${prefix}NumberFormat`, comps['NumberFormat'] as any)\n }\n if (options.injectGlobalProperties !== false) {\n app.config.globalProperties['$t'] = t\n app.config.globalProperties['$d'] = d\n app.config.globalProperties['$n'] = n\n app.config.globalProperties['$vtRich'] = vtRich\n }\n\n // Runtime v-t directive (fallback when compile-time transform is not used)\n const vtOriginalIds = new WeakMap<HTMLElement, string>()\n app.directive('t', {\n mounted(el, binding) {\n const attrName = getModifierAttr(binding.modifiers)\n if (attrName) {\n // v-t.alt, v-t.placeholder, etc. — translate the attribute\n const original = el.getAttribute(attrName) ?? ''\n vtOriginalIds.set(el, original)\n el.setAttribute(attrName, t(original))\n } else {\n // v-t or v-t:id — translate text content\n const id = binding.arg ?? el.textContent ?? ''\n vtOriginalIds.set(el, id.trim())\n el.textContent = t(id.trim(), binding.value != null ? { ...binding.value } : undefined)\n }\n },\n updated(el, binding) {\n const attrName = getModifierAttr(binding.modifiers)\n if (attrName) {\n const original = vtOriginalIds.get(el) ?? el.getAttribute(attrName) ?? ''\n el.setAttribute(attrName, t(original))\n } else {\n const id = binding.arg ?? vtOriginalIds.get(el) ?? ''\n el.textContent = t(id.trim(), binding.value != null ? { ...binding.value } : undefined)\n }\n },\n })\n },\n global: context,\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/vue' is a compile-time API. \" +\n 'Use it only with the Fluenti build transform inside <script setup> or setup(). ' +\n 'For runtime lookups, use useI18n().t(...).',\n )\n}) as CompileTimeT\n"],"mappings":";;;;AAQA,SAAS,EAAW,GAAqB;AACvC,QAAO,EAAI,QAAQ,MAAM,QAAQ,CAAC,QAAQ,MAAM,SAAS,CAAC,QAAQ,MAAM,QAAQ,CAAC,QAAQ,MAAM,OAAO,CAAC,QAAQ,MAAM,OAAO;;AAa9H,IAAM,IAAoB,OAAO,IAAI,yBAAyB;AAE9D,SAAS,IAAmD;CAC1D,IAAM,IAAW,WAA4C;AAC7D,QAAO,OAAO,KAAY,YAAY,IAClC,IACA;;AAGN,SAAS,EACP,GACiC;AACjC,QAAO,OAAO,KAAW,YAAY,KAAmB,aA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EAAG,IAAI,IAC7B,MAAM,EAAE,EAAQ,SAAS,OAA8B,KAAA,IAAvB,EAAE,GAAG,EAAQ,OAAO,CAAa;;IAG5F,CAAC;;EAEJ,QAAQ;EACT;;;;ACzeH,IAAa,MAAoB,GAAG,MAAqB;AACvD,OAAU,MACR,8LAGD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/plugin.ts","../src/compile-time-t.ts"],"sourcesContent":["import { type App, type Ref, ref, shallowReactive } from 'vue'\nimport type { AllMessages, Locale, LocalizedString, Messages, CompiledMessage, MessageDescriptor, DiagnosticsConfig, CustomFormatter } from '@fluenti/core'\nimport { createFluentiCore } from '@fluenti/core'\nimport { FLUENTI_KEY } from './injection-key'\n// Components are in @fluenti/vue subpath.\n// Global component registration is opt-in via `components` config option.\n\n/** Escape HTML special characters to prevent XSS. @internal */\nfunction escapeHtml(str: string): string {\n return str.replace(/&/g, '&').replace(/\"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>')\n}\n\n/** Compiled message 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.vue.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/** Context object returned by `useI18n()` and available as `$t` etc. on globalProperties */\nexport interface FluentiContext {\n /** Translate a message by id or MessageDescriptor, 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 /** Reactive ref for current locale */\n locale: Readonly<Ref<Locale>>\n /** Change the active locale (async when lazy locale loading is enabled) */\n setLocale(locale: Locale): Promise<void>\n /** Dynamically load messages for a locale */\n loadMessages(locale: Locale, messages: Messages): void\n /** Get all locales that have loaded messages */\n getLocales(): Locale[]\n /** Format a date value according to locale */\n d(value: Date | number, style?: string): LocalizedString\n /** Format a number according to 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: Readonly<Ref<boolean>>\n /** Set of locales whose messages have been loaded */\n loadedLocales: Readonly<Ref<ReadonlySet<string>>>\n /** Preload a locale in the background without switching to it */\n preloadLocale(locale: string): void\n /** Check if a translation key exists in the catalog */\n te(key: string, locale?: string): boolean\n /** Get the raw compiled message without interpolation */\n tm(key: string, locale?: string): CompiledMessage | undefined\n}\n\n/** Injection key for providing/injecting fluenti context */\nexport { FLUENTI_KEY } from './injection-key'\n\n/** Options for creating the Fluenti Vue plugin */\nexport interface FluentiConfig {\n locale: string\n fallbackLocale?: string\n messages: AllMessages\n missing?: (locale: string, id: string) => string | undefined\n dateFormats?: Record<string, Intl.DateTimeFormatOptions | 'relative'>\n numberFormats?: Record<string, Intl.NumberFormatOptions | ((locale: string) => Intl.NumberFormatOptions)>\n fallbackChain?: Record<string, string[]>\n /** Async chunk loader for lazy locale loading */\n chunkLoader?: ChunkLoader\n /** Enable lazy locale loading through chunkLoader */\n lazyLocaleLoading?: boolean\n /**\n * Prefix for globally registered components (Trans, Plural, Select).\n *\n * Set this to avoid naming conflicts with other libraries.\n *\n * @example\n * componentPrefix: 'I18n'\n * // Registers: I18nTrans, I18nPlural, I18nSelect\n *\n * @example\n * componentPrefix: 'Fluenti'\n * // Registers: FluentiTrans, FluentiPlural, FluentiSelect\n *\n * @default '' (no prefix — Trans, Plural, Select)\n */\n componentPrefix?: string\n /**\n * Whether to inject `$t`, `$d`, `$n`, `$vtRich` onto `app.config.globalProperties`.\n *\n * Set to `false` to avoid polluting the global namespace (e.g. when migrating from vue-i18n\n * or when using composition API exclusively via `useI18n()`).\n *\n * @default true\n */\n injectGlobalProperties?: boolean\n /** Runtime diagnostics configuration or pre-created instance */\n diagnostics?: DiagnosticsConfig | { missingKey: (locale: string, id: string) => void; fallbackUsed: (locale: string, fallbackLocale: string, id: string) => void; enabled: boolean }\n /**\n * Custom message interpolation function.\n *\n * By default, the runtime uses a lightweight `{key}` replacer.\n * Pass the full `interpolate` from `@fluenti/core/runtime` for\n * runtime ICU MessageFormat parsing (adds ~2.5 KB gzip).\n *\n * @example\n * ```ts\n * import { interpolate } from '@fluenti/core/runtime'\n * createFluenti({ interpolate, ... })\n * ```\n */\n interpolate?: (\n message: string,\n values: Record<string, unknown> | undefined,\n locale: string,\n formatters?: Record<string, CustomFormatter>,\n ) => string\n /**\n * Components to register globally via `app.component()`.\n *\n * Import from `@fluenti/vue` and pass here to enable global\n * component registration without bloating the default bundle.\n *\n * @example\n * ```ts\n * import * as components from '@fluenti/vue'\n * app.use(createFluenti({ components, ... }))\n * ```\n */\n components?: Record<string, unknown>\n}\n\n/** Return value of `createFluenti()` */\nexport interface FluentiPlugin {\n /** Vue plugin install method */\n install(app: App): void\n /** The global fluenti context (same as what useI18n returns) */\n global: FluentiContext\n}\n\n/** Extract the attribute name from v-t modifiers (e.g., v-t.alt → 'alt') */\nfunction getModifierAttr(modifiers: Partial<Record<string, boolean>>): string | undefined {\n const keys = Object.keys(modifiers).filter((k) => k !== 'plural')\n return keys.length > 0 ? keys[0] : undefined\n}\n\n/**\n * Create a Fluenti Vue plugin (SSR-safe, per-request instance).\n *\n * Each invocation creates entirely fresh state — no module-level singletons —\n * so it is safe to call once per SSR request.\n *\n * @example\n * ```ts\n * import { createFluenti } from '@fluenti/vue'\n * import messages from './locales/compiled/en.js'\n *\n * const fluenti = createFluenti({\n * locale: 'en',\n * messages: { en: messages },\n * })\n *\n * app.use(fluenti)\n * ```\n */\nexport function createFluenti(options: FluentiConfig): FluentiPlugin {\n const lazyLocaleLoading = options.lazyLocaleLoading\n ?? (options as FluentiConfig & { splitting?: boolean }).splitting\n ?? false\n\n // Create the core i18n instance — delegates t/d/n/format/loadMessages/getLocales\n // Build config incrementally to satisfy exactOptionalPropertyTypes —\n // optional properties must not receive `undefined` as a value.\n const coreConfig: Parameters<typeof createFluentiCore>[0] = {\n locale: options.locale,\n messages: options.messages ?? {},\n }\n if (options.fallbackLocale !== undefined) coreConfig.fallbackLocale = options.fallbackLocale\n if (options.fallbackChain !== undefined) coreConfig.fallbackChain = options.fallbackChain\n if (options.dateFormats !== undefined) coreConfig.dateFormats = options.dateFormats\n if (options.numberFormats !== undefined) coreConfig.numberFormats = options.numberFormats\n if (options.missing !== undefined) coreConfig.missing = options.missing\n if (options.diagnostics !== undefined) coreConfig.diagnostics = options.diagnostics as Parameters<typeof createFluentiCore>[0]['diagnostics']\n if (options.interpolate !== undefined) coreConfig.interpolate = options.interpolate\n coreConfig.devWarnings = coreConfig.devWarnings ?? (typeof process !== 'undefined' && process.env?.['NODE_ENV'] === 'development')\n const i18n = createFluentiCore(coreConfig)\n\n const locale = ref(options.locale)\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n const catalogs = shallowReactive<AllMessages>({ ...options.messages })\n const isLoading = ref(false)\n const loadedLocalesSet = new Set<string>([options.locale])\n const loadedLocales = ref<ReadonlySet<string>>(new Set(loadedLocalesSet))\n\n /** Local catalog lookup for te/tm (core doesn't expose raw catalog access) */\n function lookup(\n loc: Locale,\n id: string,\n ): CompiledMessage | undefined {\n const msgs = catalogs[loc]\n if (!msgs) return undefined\n return msgs[id]\n }\n\n /** Sync Vue reactive locale to core before delegation */\n function syncLocale(): void {\n if (i18n.locale !== locale.value) {\n i18n.locale = locale.value\n }\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 // Read locale.value and catalogs to register Vue reactive dependencies\n // so components re-render when locale or messages change\n const currentLocale = locale.value\n void catalogs[currentLocale]\n syncLocale()\n // Dispatch to the correct overload based on input type\n if (Array.isArray(idOrStrings) && 'raw' in idOrStrings) {\n return i18n.t(idOrStrings as TemplateStringsArray, ...rest)\n }\n return i18n.t(idOrStrings as string | MessageDescriptor, rest[0] as Record<string, unknown> | undefined)\n }\n\n let _localeRequestId = 0\n\n async function setLocale(newLocale: Locale): Promise<void> {\n if (!lazyLocaleLoading || !options.chunkLoader) {\n i18n.locale = newLocale\n locale.value = newLocale\n return\n }\n\n const splitRuntime = getSplitRuntimeModule()\n\n if (loadedLocalesSet.has(newLocale)) {\n // Already loaded, instant switch\n try {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n } catch (e) {\n console.warn(`[fluenti] split runtime switch failed for locale \"${newLocale}\"`, e)\n }\n i18n.locale = newLocale\n locale.value = newLocale\n return\n }\n\n // Race-condition protection: track request ID\n const thisRequest = ++_localeRequestId\n isLoading.value = true\n try {\n const messages = resolveChunkMessages(await options.chunkLoader(newLocale))\n // Stale request — a newer setLocale call superseded this one\n if (thisRequest !== _localeRequestId) return\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n catalogs[newLocale] = { ...catalogs[newLocale], ...messages }\n i18n.loadMessages(newLocale, messages)\n loadedLocalesSet.add(newLocale)\n loadedLocales.value = new Set(loadedLocalesSet)\n try {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n } catch (e) {\n console.warn(`[fluenti] split runtime switch failed for locale \"${newLocale}\"`, e)\n }\n // Re-check after async __switchLocale — a newer setLocale() may have superseded this one\n if (thisRequest !== _localeRequestId) return\n i18n.locale = newLocale\n locale.value = newLocale\n } finally {\n if (thisRequest === _localeRequestId) {\n isLoading.value = false\n }\n }\n }\n\n function loadMessages(loc: Locale, messages: Messages): void {\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n catalogs[loc] = { ...catalogs[loc], ...messages }\n i18n.loadMessages(loc, messages)\n loadedLocalesSet.add(loc)\n loadedLocales.value = new Set(loadedLocalesSet)\n }\n\n const _preloadInFlight = new Set<string>()\n\n function preloadLocale(loc: string): void {\n if (!lazyLocaleLoading || loadedLocalesSet.has(loc) || !options.chunkLoader || _preloadInFlight.has(loc)) return\n _preloadInFlight.add(loc)\n const splitRuntime = getSplitRuntimeModule()\n options.chunkLoader(loc).then(async (loaded) => {\n const messages = resolveChunkMessages(loaded)\n // Intentional mutation: Vue's shallowReactive API requires in-place property assignment for reactivity\n catalogs[loc] = { ...catalogs[loc], ...messages }\n i18n.loadMessages(loc, messages)\n loadedLocalesSet.add(loc)\n loadedLocales.value = 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 function getLocales(): Locale[] {\n syncLocale()\n return i18n.getLocales()\n }\n\n function d(value: Date | number, style?: string): LocalizedString {\n // Read locale.value to register a Vue reactive dependency\n void locale.value\n syncLocale()\n return i18n.d(value, style)\n }\n\n function n(value: number, style?: string): LocalizedString {\n // Read locale.value to register a Vue reactive dependency\n void locale.value\n syncLocale()\n return i18n.n(value, style)\n }\n\n function format(message: string, values?: Record<string, unknown>): LocalizedString {\n // Read locale.value to register a Vue reactive dependency\n void locale.value\n syncLocale()\n return i18n.format(message, values)\n }\n\n /**\n * Rich text helper for v-t with child elements.\n * Translates the message (which contains `<0>content</0>` placeholders),\n * then replaces each placeholder with the original HTML element.\n * Used via `v-html=\"$vtRich('msg', elements)\"` in compile-time transforms.\n * @internal\n */\n function vtRich(\n message: string | MessageDescriptor,\n elements: Array<{ tag: string; attrs?: Record<string, string>; rawAttrs?: string }>,\n values?: Record<string, unknown>,\n ): string {\n const translated = values ? t(message, values) : t(message)\n // Escape the entire translated string first to neutralise any injected HTML\n const escaped = escapeHtml(translated)\n\n // Helper to build attribute string from element.\n // Both rawAttrs and attrs are escaped to prevent XSS — even though rawAttrs\n // originates from compile-time transforms, $vtRich is exposed on globalProperties\n // so we apply defence-in-depth.\n function buildAttrs(el: { attrs?: Record<string, string>; rawAttrs?: string }): string {\n if (el.rawAttrs != null && el.rawAttrs !== '') {\n // Parse rawAttrs back into key/value pairs and escape each one.\n // Handles: key=\"val\", key='val', and bare key (boolean attribute).\n const parts: string[] = []\n const attrRe = /([\\w:@.!-]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'))?/g\n let m: RegExpExecArray | null\n while ((m = attrRe.exec(el.rawAttrs)) !== null) {\n const key = escapeHtml(m[1]!)\n const val = m[2] ?? m[3]\n parts.push(val !== undefined ? `${key}=\"${escapeHtml(val)}\"` : key)\n }\n return parts.join(' ')\n }\n if (!el.attrs) return ''\n return Object.entries(el.attrs)\n .map(([k, v]) => v ? `${escapeHtml(k)}=\"${escapeHtml(v)}\"` : escapeHtml(k))\n .join(' ')\n }\n\n // First: handle self-closing <idx/> (escaped as <idx/>)\n let result = escaped.replace(/<(\\d+)\\/>/g, (_match, idxStr: string) => {\n const el = elements[Number(idxStr)]\n if (!el) return ''\n const tag = escapeHtml(el.tag)\n const attrs = buildAttrs(el)\n return `<${tag}${attrs ? ' ' + attrs : ''} />`\n })\n\n // Then: handle paired <idx>content</idx>\n result = result.replace(/<(\\d+)>([\\s\\S]*?)<\\/\\1>/g, (_match, idxStr: string, content: string) => {\n const el = elements[Number(idxStr)]\n if (!el) return content\n const tag = escapeHtml(el.tag)\n const attrs = buildAttrs(el)\n return `<${tag}${attrs ? ' ' + attrs : ''}>${content}</${tag}>`\n })\n\n return result\n }\n\n function te(key: string, loc?: string): boolean {\n const targetLocale = loc ?? locale.value\n return lookup(targetLocale, key) !== undefined\n }\n\n function tm(key: string, loc?: string): CompiledMessage | undefined {\n const targetLocale = loc ?? locale.value\n return lookup(targetLocale, key)\n }\n\n const context: FluentiContext = {\n t,\n locale,\n setLocale,\n loadMessages,\n getLocales,\n d,\n n,\n format,\n isLoading,\n loadedLocales,\n preloadLocale,\n te,\n tm,\n }\n\n return {\n install(app: App) {\n app.provide(FLUENTI_KEY, context)\n // Register components globally if provided via config\n if (options.components) {\n const prefix = options.componentPrefix ?? ''\n const comps = options.components as Record<string, unknown>\n if (comps['Trans']) app.component(`${prefix}Trans`, comps['Trans'] as any)\n if (comps['Plural']) app.component(`${prefix}Plural`, comps['Plural'] as any)\n if (comps['Select']) app.component(`${prefix}Select`, comps['Select'] as any)\n if (comps['DateTime']) app.component(`${prefix}DateTime`, comps['DateTime'] as any)\n if (comps['NumberFormat']) app.component(`${prefix}NumberFormat`, comps['NumberFormat'] as any)\n }\n if (options.injectGlobalProperties !== false) {\n app.config.globalProperties['$t'] = t\n app.config.globalProperties['$d'] = d\n app.config.globalProperties['$n'] = n\n app.config.globalProperties['$vtRich'] = vtRich\n }\n\n // Runtime v-t directive (fallback when compile-time transform is not used)\n const vtOriginalIds = new WeakMap<HTMLElement, string>()\n app.directive('t', {\n mounted(el, binding) {\n const attrName = getModifierAttr(binding.modifiers)\n if (attrName) {\n // v-t.alt, v-t.placeholder, etc. — translate the attribute\n const original = el.getAttribute(attrName) ?? ''\n vtOriginalIds.set(el, original)\n el.setAttribute(attrName, t(original))\n } else {\n // v-t or v-t:id — translate text content\n const id = binding.arg ?? el.textContent ?? ''\n vtOriginalIds.set(el, id.trim())\n el.textContent = t(id.trim(), binding.value != null ? { ...binding.value } : undefined)\n }\n },\n updated(el, binding) {\n const attrName = getModifierAttr(binding.modifiers)\n if (attrName) {\n const original = vtOriginalIds.get(el) ?? el.getAttribute(attrName) ?? ''\n el.setAttribute(attrName, t(original))\n } else {\n const id = binding.arg ?? vtOriginalIds.get(el) ?? ''\n el.textContent = t(id.trim(), binding.value != null ? { ...binding.value } : undefined)\n }\n },\n })\n },\n global: context,\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/vue' is a compile-time API. \" +\n 'Use it only with the Fluenti build transform inside <script setup> or setup(). ' +\n 'For runtime lookups, use useI18n().t(...).',\n )\n}) as CompileTimeT\n"],"mappings":";;;;AAQA,SAAS,EAAW,GAAqB;AACvC,QAAO,EAAI,QAAQ,MAAM,QAAQ,CAAC,QAAQ,MAAM,SAAS,CAAC,QAAQ,MAAM,QAAQ,CAAC,QAAQ,MAAM,OAAO,CAAC,QAAQ,MAAM,OAAO;;AAa9H,IAAM,IAAoB,OAAO,IAAI,yBAAyB;AAE9D,SAAS,IAAmD;CAC1D,IAAM,IAAW,WAA4C;AAC7D,QAAO,OAAO,KAAY,YAAY,IAClC,IACA;;AAGN,SAAS,EACP,GACiC;AACjC,QAAO,OAAO,KAAW,YAAY,KAAmB,aAAa,IAChE,EAAwD,UACzD;;AAyHN,SAAS,EAAgB,GAAiE;CACxF,IAAM,IAAO,OAAO,KAAK,EAAU,CAAC,QAAQ,MAAM,MAAM,SAAS;AACjE,QAAO,EAAK,SAAS,IAAI,EAAK,KAAK,KAAA;;AAsBrC,SAAgB,EAAc,GAAuC;CACnE,IAAM,IAAoB,EAAQ,qBAC5B,EAAoD,aACrD,IAKC,IAAsD;EAC1D,QAAQ,EAAQ;EAChB,UAAU,EAAQ,YAAY,EAAE;EACjC;AAQD,CAPI,EAAQ,mBAAmB,KAAA,MAAW,EAAW,iBAAiB,EAAQ,iBAC1E,EAAQ,kBAAkB,KAAA,MAAW,EAAW,gBAAgB,EAAQ,gBACxE,EAAQ,gBAAgB,KAA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AI,OAAO,iBAAiB,KAAQ,GACpC,EAAI,OAAO,iBAAiB,UAAa;GAI3C,IAAM,oBAAgB,IAAI,SAA8B;AACxD,KAAI,UAAU,KAAK;IACjB,QAAQ,GAAI,GAAS;KACnB,IAAM,IAAW,EAAgB,EAAQ,UAAU;AACnD,SAAI,GAAU;MAEZ,IAAM,IAAW,EAAG,aAAa,EAAS,IAAI;AAE9C,MADA,EAAc,IAAI,GAAI,EAAS,EAC/B,EAAG,aAAa,GAAU,EAAE,EAAS,CAAC;YACjC;MAEL,IAAM,IAAK,EAAQ,OAAO,EAAG,eAAe;AAE5C,MADA,EAAc,IAAI,GAAI,EAAG,MAAM,CAAC,EAChC,EAAG,cAAc,EAAE,EAAG,MAAM,EAAE,EAAQ,SAAS,OAA8B,KAAA,IAAvB,EAAE,GAAG,EAAQ,OAAO,CAAa;;;IAG3F,QAAQ,GAAI,GAAS;KACnB,IAAM,IAAW,EAAgB,EAAQ,UAAU;AACnD,SAAI,GAAU;MACZ,IAAM,IAAW,EAAc,IAAI,EAAG,IAAI,EAAG,aAAa,EAAS,IAAI;AACvE,QAAG,aAAa,GAAU,EAAE,EAAS,CAAC;WAGtC,GAAG,cAAc,GADN,EAAQ,OAAO,EAAc,IAAI,EAAG,IAAI,IAC7B,MAAM,EAAE,EAAQ,SAAS,OAA8B,KAAA,IAAvB,EAAE,GAAG,EAAQ,OAAO,CAAa;;IAG5F,CAAC;;EAEJ,QAAQ;EACT;;;;ACzeH,IAAa,MAAoB,GAAG,MAAqB;AACvD,OAAU,MACR,8LAGD"}
|
package/dist/vite-plugin.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require(`@fluenti/vite-plugin`),t=require(`@fluenti/vite-plugin/sfc-transform`);var n=(0,e.createRuntimeGenerator)({imports:`import { shallowReactive, ref } from 'vue'`,catalogInit:`const __catalog = shallowReactive({ ...__defaultMsgs })`,localeInit:e=>`const __currentLocale = ref(
|
|
1
|
+
let e=require(`@fluenti/vite-plugin`),t=require(`@fluenti/vite-plugin/sfc-transform`);var n=(0,e.createRuntimeGenerator)({imports:`import { shallowReactive, ref } from 'vue'`,catalogInit:`const __catalog = shallowReactive({ ...__defaultMsgs })`,localeInit:e=>`const __currentLocale = ref(${JSON.stringify(e)})`,loadingInit:`const __loading = ref(false)`,catalogUpdate:e=>`Object.assign(__catalog, ${e})`,localeUpdate:e=>`__currentLocale.value = ${e}`,loadingUpdate:e=>`__loading.value = ${e}`,localeRead:`__currentLocale.value`,runtimeKey:`fluenti.runtime.vue.v1`});function r(r){let i={name:`fluenti:vue-template`,enforce:`pre`,transform(e,n){if(!n.endsWith(`.vue`)||!/\bv-t\b/.test(e)&&!/<Trans[\s>]/.test(e)&&!/<Plural[\s/>]/.test(e))return;let r=(0,t.transformVtDirectives)(e);if(r!==e)return{code:r,map:null}}};return(0,e.createFluentiPlugins)({...r?.config===void 0?{}:{config:r.config},framework:`vue`},[i],n)}module.exports=r;
|
|
2
2
|
//# sourceMappingURL=vite-plugin.cjs.map
|
package/dist/vite-plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.cjs","names":[],"sources":["../src/vue-runtime.ts","../src/vite-plugin.ts"],"sourcesContent":["import { createRuntimeGenerator } from '@fluenti/vite-plugin'\nimport type { RuntimeGenerator } from '@fluenti/vite-plugin'\n\nexport const vueRuntimeGenerator: RuntimeGenerator = createRuntimeGenerator({\n imports: `import { shallowReactive, ref } from 'vue'`,\n catalogInit: 'const __catalog = shallowReactive({ ...__defaultMsgs })',\n localeInit: (defaultLocale) => `const __currentLocale = ref(
|
|
1
|
+
{"version":3,"file":"vite-plugin.cjs","names":[],"sources":["../src/vue-runtime.ts","../src/vite-plugin.ts"],"sourcesContent":["import { createRuntimeGenerator } from '@fluenti/vite-plugin'\nimport type { RuntimeGenerator } from '@fluenti/vite-plugin'\n\nexport const vueRuntimeGenerator: RuntimeGenerator = createRuntimeGenerator({\n imports: `import { shallowReactive, ref } from 'vue'`,\n catalogInit: 'const __catalog = shallowReactive({ ...__defaultMsgs })',\n localeInit: (defaultLocale) => `const __currentLocale = ref(${JSON.stringify(defaultLocale)})`,\n loadingInit: 'const __loading = ref(false)',\n catalogUpdate: (msgs) => `Object.assign(__catalog, ${msgs})`,\n localeUpdate: (locale) => `__currentLocale.value = ${locale}`,\n loadingUpdate: (value) => `__loading.value = ${value}`,\n localeRead: '__currentLocale.value',\n runtimeKey: 'fluenti.runtime.vue.v1',\n})\n","import type { Plugin } from 'vite'\nimport type { FluentiPluginOptions } from '@fluenti/vite-plugin'\nimport { createFluentiPlugins } from '@fluenti/vite-plugin'\nimport { transformVtDirectives } from '@fluenti/vite-plugin/sfc-transform'\nimport { vueRuntimeGenerator } from './vue-runtime'\n\nexport type { FluentiPluginOptions as FluentiVueOptions } from '@fluenti/vite-plugin'\n\n/**\n * Fluenti Vue 3 Vite plugin.\n *\n * @example Minimal — no fluenti.config.ts needed\n * ```ts\n * // vite.config.ts\n * import fluentiVue from '@fluenti/vue/vite-plugin'\n *\n * export default defineConfig({\n * plugins: [fluentiVue({ config: { locales: ['en', 'ja'] } })],\n * })\n * ```\n *\n * @example With fluenti.config.ts (for advanced options)\n * ```ts\n * export default defineConfig({\n * plugins: [fluentiVue()], // auto-reads fluenti.config.ts\n * })\n * ```\n */\nexport default function fluentiVue(options?: FluentiPluginOptions): Plugin[] {\n const vueTemplatePlugin: Plugin = {\n name: 'fluenti:vue-template',\n enforce: 'pre',\n transform(code, id) {\n if (!id.endsWith('.vue')) return undefined\n if (!/\\bv-t\\b/.test(code) && !/<Trans[\\s>]/.test(code) && !/<Plural[\\s/>]/.test(code)) return undefined\n\n const transformed = transformVtDirectives(code)\n if (transformed === code) return undefined\n\n return { code: transformed, map: null }\n },\n }\n\n return createFluentiPlugins(\n { ...(options?.config !== undefined ? { config: options.config } : {}), framework: 'vue' },\n [vueTemplatePlugin],\n vueRuntimeGenerator,\n )\n}\n"],"mappings":"sFAGA,IAAa,GAAA,EAAA,EAAA,wBAA+D,CAC1E,QAAS,6CACT,YAAa,0DACb,WAAa,GAAkB,+BAA+B,KAAK,UAAU,EAAc,CAAC,GAC5F,YAAa,+BACb,cAAgB,GAAS,4BAA4B,EAAK,GAC1D,aAAe,GAAW,2BAA2B,IACrD,cAAgB,GAAU,qBAAqB,IAC/C,WAAY,wBACZ,WAAY,yBACb,CAAC,CCeF,SAAwB,EAAW,EAA0C,CAC3E,IAAM,EAA4B,CAChC,KAAM,uBACN,QAAS,MACT,UAAU,EAAM,EAAI,CAElB,GADI,CAAC,EAAG,SAAS,OAAO,EACpB,CAAC,UAAU,KAAK,EAAK,EAAI,CAAC,cAAc,KAAK,EAAK,EAAI,CAAC,gBAAgB,KAAK,EAAK,CAAE,OAEvF,IAAM,GAAA,EAAA,EAAA,uBAAoC,EAAK,CAC3C,OAAgB,EAEpB,MAAO,CAAE,KAAM,EAAa,IAAK,KAAM,EAE1C,CAED,OAAA,EAAA,EAAA,sBACE,CAAE,GAAI,GAAS,SAAW,IAAA,GAAyC,EAAE,CAA/B,CAAE,OAAQ,EAAQ,OAAQ,CAAQ,UAAW,MAAO,CAC1F,CAAC,EAAkB,CACnB,EACD"}
|
package/dist/vite-plugin.js
CHANGED
|
@@ -4,7 +4,7 @@ import { transformVtDirectives as n } from "@fluenti/vite-plugin/sfc-transform";
|
|
|
4
4
|
var r = t({
|
|
5
5
|
imports: "import { shallowReactive, ref } from 'vue'",
|
|
6
6
|
catalogInit: "const __catalog = shallowReactive({ ...__defaultMsgs })",
|
|
7
|
-
localeInit: (e) => `const __currentLocale = ref(
|
|
7
|
+
localeInit: (e) => `const __currentLocale = ref(${JSON.stringify(e)})`,
|
|
8
8
|
loadingInit: "const __loading = ref(false)",
|
|
9
9
|
catalogUpdate: (e) => `Object.assign(__catalog, ${e})`,
|
|
10
10
|
localeUpdate: (e) => `__currentLocale.value = ${e}`,
|
package/dist/vite-plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.js","names":[],"sources":["../src/vue-runtime.ts","../src/vite-plugin.ts"],"sourcesContent":["import { createRuntimeGenerator } from '@fluenti/vite-plugin'\nimport type { RuntimeGenerator } from '@fluenti/vite-plugin'\n\nexport const vueRuntimeGenerator: RuntimeGenerator = createRuntimeGenerator({\n imports: `import { shallowReactive, ref } from 'vue'`,\n catalogInit: 'const __catalog = shallowReactive({ ...__defaultMsgs })',\n localeInit: (defaultLocale) => `const __currentLocale = ref(
|
|
1
|
+
{"version":3,"file":"vite-plugin.js","names":[],"sources":["../src/vue-runtime.ts","../src/vite-plugin.ts"],"sourcesContent":["import { createRuntimeGenerator } from '@fluenti/vite-plugin'\nimport type { RuntimeGenerator } from '@fluenti/vite-plugin'\n\nexport const vueRuntimeGenerator: RuntimeGenerator = createRuntimeGenerator({\n imports: `import { shallowReactive, ref } from 'vue'`,\n catalogInit: 'const __catalog = shallowReactive({ ...__defaultMsgs })',\n localeInit: (defaultLocale) => `const __currentLocale = ref(${JSON.stringify(defaultLocale)})`,\n loadingInit: 'const __loading = ref(false)',\n catalogUpdate: (msgs) => `Object.assign(__catalog, ${msgs})`,\n localeUpdate: (locale) => `__currentLocale.value = ${locale}`,\n loadingUpdate: (value) => `__loading.value = ${value}`,\n localeRead: '__currentLocale.value',\n runtimeKey: 'fluenti.runtime.vue.v1',\n})\n","import type { Plugin } from 'vite'\nimport type { FluentiPluginOptions } from '@fluenti/vite-plugin'\nimport { createFluentiPlugins } from '@fluenti/vite-plugin'\nimport { transformVtDirectives } from '@fluenti/vite-plugin/sfc-transform'\nimport { vueRuntimeGenerator } from './vue-runtime'\n\nexport type { FluentiPluginOptions as FluentiVueOptions } from '@fluenti/vite-plugin'\n\n/**\n * Fluenti Vue 3 Vite plugin.\n *\n * @example Minimal — no fluenti.config.ts needed\n * ```ts\n * // vite.config.ts\n * import fluentiVue from '@fluenti/vue/vite-plugin'\n *\n * export default defineConfig({\n * plugins: [fluentiVue({ config: { locales: ['en', 'ja'] } })],\n * })\n * ```\n *\n * @example With fluenti.config.ts (for advanced options)\n * ```ts\n * export default defineConfig({\n * plugins: [fluentiVue()], // auto-reads fluenti.config.ts\n * })\n * ```\n */\nexport default function fluentiVue(options?: FluentiPluginOptions): Plugin[] {\n const vueTemplatePlugin: Plugin = {\n name: 'fluenti:vue-template',\n enforce: 'pre',\n transform(code, id) {\n if (!id.endsWith('.vue')) return undefined\n if (!/\\bv-t\\b/.test(code) && !/<Trans[\\s>]/.test(code) && !/<Plural[\\s/>]/.test(code)) return undefined\n\n const transformed = transformVtDirectives(code)\n if (transformed === code) return undefined\n\n return { code: transformed, map: null }\n },\n }\n\n return createFluentiPlugins(\n { ...(options?.config !== undefined ? { config: options.config } : {}), framework: 'vue' },\n [vueTemplatePlugin],\n vueRuntimeGenerator,\n )\n}\n"],"mappings":";;;AAGA,IAAa,IAAwC,EAAuB;CAC1E,SAAS;CACT,aAAa;CACb,aAAa,MAAkB,+BAA+B,KAAK,UAAU,EAAc,CAAC;CAC5F,aAAa;CACb,gBAAgB,MAAS,4BAA4B,EAAK;CAC1D,eAAe,MAAW,2BAA2B;CACrD,gBAAgB,MAAU,qBAAqB;CAC/C,YAAY;CACZ,YAAY;CACb,CAAC;;;ACeF,SAAwB,EAAW,GAA0C;CAC3E,IAAM,IAA4B;EAChC,MAAM;EACN,SAAS;EACT,UAAU,GAAM,GAAI;AAElB,OADI,CAAC,EAAG,SAAS,OAAO,IACpB,CAAC,UAAU,KAAK,EAAK,IAAI,CAAC,cAAc,KAAK,EAAK,IAAI,CAAC,gBAAgB,KAAK,EAAK,CAAE;GAEvF,IAAM,IAAc,EAAsB,EAAK;AAC3C,aAAgB,EAEpB,QAAO;IAAE,MAAM;IAAa,KAAK;IAAM;;EAE1C;AAED,QAAO,EACL;EAAE,GAAI,GAAS,WAAW,KAAA,IAAyC,EAAE,GAA/B,EAAE,QAAQ,EAAQ,QAAQ;EAAQ,WAAW;EAAO,EAC1F,CAAC,EAAkB,EACnB,EACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-time-t.d.ts","sourceRoot":"","sources":["../../../src/compile-time-t.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,eAAO,MAAM,CAAC,EAAE,YAME,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AAGrD;;;;;;;;;GASG;AACH,QAAA,MAAM,aAAa;;uBACgB,QAAQ,CAAC,IAAI,GAAG,MAAM,CAAC;;;;;;;;;;;CAGhD,CAAA;AAEV,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,gBAAgB,CAAC,OAAO,aAAa,CAAC,CAAC,CAAA;AAEnF,eAAO,MAAM,QAAQ;;uBAPc,QAAQ,CAAC,IAAI,GAAG,MAAM,CAAC;;;;;;;;;;;;;;;uBAAvB,QAAQ,CAAC,IAAI,GAAG,MAAM,CAAC;;;;;;;;;;;;;;4EAcxD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberFormat.d.ts","sourceRoot":"","sources":["../../../../src/components/NumberFormat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAG3C;;;;;;;;;GASG;AACH,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;CAIb,CAAA;AAEV,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC,gBAAgB,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAA;AAE3F,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EAOvB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Plural.d.ts","sourceRoot":"","sources":["../../../../src/components/Plural.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAA4B,MAAM,KAAK,CAAA;AAKrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,QAAA,MAAM,WAAW;IACf,wCAAwC;;;;;IAExC,2DAA2D;;IAE3D,sEAAsE;;IAEtE,8DAA8D;;IAE9D,yCAAyC;;IAEzC,wCAAwC;;IAExC,oCAAoC;;IAEpC,mCAAmC;;IAEnC,qCAAqC;;IAErC,0CAA0C;;;;;IAE1C,8CAA8C;;IAE9C,mEAAmE;;;;;CAE3D,CAAA;AAEV,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,gBAAgB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAA;AAE/E,eAAO,MAAM,MAAM;IA5BjB,wCAAwC;;;;;IAExC,2DAA2D;;IAE3D,sEAAsE;;IAEtE,8DAA8D;;IAE9D,yCAAyC;;IAEzC,wCAAwC;;IAExC,oCAAoC;;IAEpC,mCAAmC;;IAEnC,qCAAqC;;IAErC,0CAA0C;;;;;IAE1C,8CAA8C;;IAE9C,mEAAmE;;;;;;;;IAtBnE,wCAAwC;;;;;IAExC,2DAA2D;;IAE3D,sEAAsE;;IAEtE,8DAA8D;;IAE9D,yCAAyC;;IAEzC,wCAAwC;;IAExC,oCAAoC;;IAEpC,mCAAmC;;IAEnC,qCAAqC;;IAErC,0CAA0C;;;;;IAE1C,8CAA8C;;IAE9C,mEAAmE;;;;;;;4EAwDnE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/Select.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAA4B,MAAM,KAAK,CAAA;AAK/E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,QAAA,MAAM,WAAW;IACf,yDAAyD;;;;;IAEzD,2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sE;;IAEtE,8DAA8D;;IAE9D,mEAAmE;;;;;;;4EA8BnE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text.d.ts","sourceRoot":"","sources":["../../../../src/components/rich-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAA;AAG5E,wBAAgB,cAAc,CAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,EAAE,GAAG,SAAS,GAAG;IAC/E,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,KAAK,EAAE,CAAA;CACpB,CA6BA;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,KAAK,EAAE,GAClB,UAAU,CA+BZ;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EACjD,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC,GAC7E;IACD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,UAAU,EAAE,KAAK,EAAE,CAAA;CACpB,CAoBA"}
|
|
@@ -8,5 +8,4 @@ export { DateTime } from './components/DateTime';
|
|
|
8
8
|
export type { FluentiDateTimeProps } from './components/DateTime';
|
|
9
9
|
export { NumberFormat } from './components/NumberFormat';
|
|
10
10
|
export type { FluentiNumberFormatProps } from './components/NumberFormat';
|
|
11
|
-
export { interpolate } from '@fluenti/core/internal';
|
|
12
11
|
//# sourceMappingURL=components-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-entry.d.ts","sourceRoot":"","sources":["../../../src/components-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,YAAY,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA"}
|