@fluentic/i18n 0.1.0-beta.1 → 0.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +9 -1
  3. package/dist/adapter.d.ts +6 -4
  4. package/dist/adapter.js +4 -3
  5. package/dist/compiled.d.ts +26 -24
  6. package/dist/compiled.js +4 -2
  7. package/dist/compiled.js.map +1 -1
  8. package/dist/compiler-support.d.ts +4 -0
  9. package/dist/compiler-support.js +4 -0
  10. package/dist/core/format.d.ts +11 -0
  11. package/dist/core/i18n.d.ts +26 -0
  12. package/dist/core/index.d.ts +1 -5
  13. package/dist/core/index.js +3 -2
  14. package/dist/core/types.d.ts +79 -0
  15. package/dist/hash-VJlyT31Z.js +90 -0
  16. package/dist/hash-VJlyT31Z.js.map +1 -0
  17. package/dist/hydration-store-BK6UxrtJ.js +13 -0
  18. package/dist/hydration-store-BK6UxrtJ.js.map +1 -0
  19. package/dist/hydration-store.d.ts +29 -0
  20. package/dist/hydration.d.ts +7 -0
  21. package/dist/hydration.js +35 -0
  22. package/dist/hydration.js.map +1 -0
  23. package/dist/index.d.ts +6 -6
  24. package/dist/index.js +3 -2
  25. package/dist/{interpreter-Dld8QyOI.js → interpreter-BfzvLLrD.js} +4 -3
  26. package/dist/interpreter-BfzvLLrD.js.map +1 -0
  27. package/dist/{manager-BW778X1Y.js → manager-BgMJWXWY.js} +21 -31
  28. package/dist/manager-BgMJWXWY.js.map +1 -0
  29. package/dist/manager.d.ts +62 -0
  30. package/dist/message-D4jK2Lzc.js +9 -0
  31. package/dist/message-D4jK2Lzc.js.map +1 -0
  32. package/dist/react.d.ts +41 -46
  33. package/dist/react.js +12 -8
  34. package/dist/react.js.map +1 -1
  35. package/dist/registry-manager.d.ts +7 -0
  36. package/dist/runtime-DXnGeCBw.js +110 -0
  37. package/dist/runtime-DXnGeCBw.js.map +1 -0
  38. package/dist/shared/compact.d.ts +5 -0
  39. package/dist/shared/formatting.d.ts +11 -0
  40. package/dist/shared/hash.d.ts +7 -0
  41. package/dist/shared/interpreter.d.ts +2 -0
  42. package/dist/shared/message.d.ts +2 -0
  43. package/dist/shared/runtime.d.ts +49 -0
  44. package/dist/{src-BovRx-mX.js → src-ON68XIog.js} +9 -7
  45. package/dist/src-ON68XIog.js.map +1 -0
  46. package/dist/state-manager.d.ts +6 -0
  47. package/dist/state.d.ts +8 -0
  48. package/dist/storage-manager.d.ts +14 -0
  49. package/dist/{translation-manager-C79eKu2K.js → translation-manager-BkmFnlb_.js} +5 -104
  50. package/dist/translation-manager-BkmFnlb_.js.map +1 -0
  51. package/dist/translation-manager.d.ts +34 -0
  52. package/dist/translation.d.ts +20 -0
  53. package/dist/types-BkDsJfVD.js.map +1 -1
  54. package/dist/types.d.ts +3 -2
  55. package/package.json +20 -54
  56. package/dist/adapter-CWC8rng-.d.ts +0 -178
  57. package/dist/analyze-CdXCxQDg.d.ts +0 -14
  58. package/dist/compact-CJ0OWoIv.d.ts +0 -7
  59. package/dist/compiler-BZtB9WLi.js +0 -365
  60. package/dist/compiler-BZtB9WLi.js.map +0 -1
  61. package/dist/compiler.d.ts +0 -35
  62. package/dist/compiler.js +0 -3
  63. package/dist/i18n-CfYNwubL.d.ts +0 -25
  64. package/dist/interpreter-Dld8QyOI.js.map +0 -1
  65. package/dist/manager-BW778X1Y.js.map +0 -1
  66. package/dist/options-DE7vYj0e.d.ts +0 -7
  67. package/dist/options-Dxxx0aOz.js +0 -23
  68. package/dist/options-Dxxx0aOz.js.map +0 -1
  69. package/dist/plugin/babel.d.ts +0 -11
  70. package/dist/plugin/babel.js +0 -31
  71. package/dist/plugin/babel.js.map +0 -1
  72. package/dist/plugin/esbuild.d.ts +0 -7
  73. package/dist/plugin/esbuild.js +0 -37
  74. package/dist/plugin/esbuild.js.map +0 -1
  75. package/dist/plugin/rollup.d.ts +0 -30
  76. package/dist/plugin/rollup.js +0 -34
  77. package/dist/plugin/rollup.js.map +0 -1
  78. package/dist/plugin/vite.d.ts +0 -31
  79. package/dist/plugin/vite.js +0 -11
  80. package/dist/plugin/vite.js.map +0 -1
  81. package/dist/plugin/webpack-loader.d.ts +0 -3
  82. package/dist/plugin/webpack-loader.js +0 -21
  83. package/dist/plugin/webpack-loader.js.map +0 -1
  84. package/dist/plugin/webpack.d.ts +0 -8
  85. package/dist/plugin/webpack.js +0 -22
  86. package/dist/plugin/webpack.js.map +0 -1
  87. package/dist/src-BovRx-mX.js.map +0 -1
  88. package/dist/translation-manager-C79eKu2K.js.map +0 -1
  89. package/dist/types-BuGoCU3P.d.ts +0 -75
  90. package/dist-cjs/babel.cjs +0 -379
  91. package/dist-cjs/babel.cjs.map +0 -1
  92. package/src/adapter.ts +0 -6
  93. package/src/compiled.ts +0 -116
  94. package/src/compiler/analyze.ts +0 -182
  95. package/src/compiler/index.ts +0 -208
  96. package/src/compiler/message.ts +0 -74
  97. package/src/core/format.ts +0 -40
  98. package/src/core/i18n.ts +0 -124
  99. package/src/core/index.ts +0 -1
  100. package/src/core/types.ts +0 -121
  101. package/src/index.ts +0 -9
  102. package/src/manager.ts +0 -175
  103. package/src/plugin/babel.ts +0 -34
  104. package/src/plugin/esbuild.ts +0 -45
  105. package/src/plugin/options.ts +0 -24
  106. package/src/plugin/rollup.ts +0 -29
  107. package/src/plugin/vite.ts +0 -6
  108. package/src/plugin/webpack-loader.ts +0 -22
  109. package/src/plugin/webpack.ts +0 -15
  110. package/src/react.ts +0 -97
  111. package/src/registry-manager.ts +0 -3
  112. package/src/shared/compact.ts +0 -51
  113. package/src/shared/formatting.ts +0 -121
  114. package/src/shared/interpreter.ts +0 -128
  115. package/src/shared/runtime.ts +0 -131
  116. package/src/state-manager.ts +0 -29
  117. package/src/state.ts +0 -20
  118. package/src/storage-manager.ts +0 -47
  119. package/src/translation-manager.ts +0 -82
  120. package/src/translation.ts +0 -106
  121. package/src/types.ts +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @fluentic/i18n
2
2
 
3
+ ## 0.1.0-beta.2
4
+
5
+ ### Additional beta.2 changes
6
+
7
+ - Notify loader lifecycle hooks after successful language selections so persistent caches can track selected languages.
8
+
9
+ ### Patch Changes
10
+
11
+ - Add `t.jsx(() => element)` as a fine-grained React boundary that refreshes one element's translated string props without rerendering its parent component.
12
+ - Move server snapshot transfer out of the SPA manager and into the explicit `@fluentic/i18n/hydration` entry point.
13
+ - Harden lazy catalog loading, compiled catalog validation, locale fallback, and concurrent language switching.
14
+ - Generate and publish declaration files from TypeScript 7 instead of exposing package source files as types.
15
+
3
16
  ## 0.1.0-beta.1
4
17
 
5
18
  ### Minor Changes
package/README.md CHANGED
@@ -17,6 +17,14 @@ t.text(greeting, { name: 'Ada' });
17
17
 
18
18
  `t.msg` is inert and safe at module scope. `t.text` returns a string; `t.jsx` returns JSX synchronously. Initialize before rendering. Persistence is opt-in.
19
19
 
20
- The default runtime uses cached `intl-messageformat`. Set `compiled: true` in your CLI configuration and add `@fluentic/i18n/plugin/{vite,rollup,esbuild,webpack,babel}` to compile messages. The plugin rewrites universal imports to `/compiled`, which interprets compact messages without an ICU parser. Auto/manual files stay unchanged; compiled merged catalogs start with `{"compiled":true}` followed by `[hash, compactMessage]` rows.
20
+ For a fine-grained React update boundary, wrap one element whose string props use `t.text`:
21
+
22
+ ```tsx
23
+ t.jsx(() => <input placeholder={t.text('Search')} />);
24
+ ```
25
+
26
+ Only that wrapper reruns when the language changes. Use `I18nState.use()` instead when rerendering the whole component is more convenient.
27
+
28
+ The default runtime uses cached `intl-messageformat`. Install the separate Node-only `@fluentic/i18n-compiler` package, set `compiled: true` or `compiled: { hashLength: 8 }` for the CLI, and add its `/vite`, `/rollup`, `/esbuild`, `/webpack`, `/babel`, or `/nextjs` integration. Adding a compiler integration always compiles source; its only compilation option is `hashLength`, which defaults to the value in shared CLI config. Compiled merged catalogs start with `{"compiled":true}` followed by short base64url-keyed compact messages.
21
29
 
22
30
  See [platforms](../../docs/docs/runtime/platforms.md), [compiler](../../docs/docs/runtime/compilation.md), [API](../../docs/docs/api.md), and the projects under `examples/`.
package/dist/adapter.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { i as validateCompact, n as CompactMessage, r as CompactPart, t as COMPACT_VERSION } from "./compact-CJ0OWoIv.js";
2
- import { A as isMessageDescriptor, C as MessageTagHandler, D as TextRenderer, E as PrimitiveType, M as isMessageTagHandler, N as I18nJsxConfig, O as TranslationGetter, S as MessageSchemaValue, T as MessageValueFactory, _ as MessageMeta, a as I18nJsxOutput, b as MessageRuntimeValue, c as InferMessageSchema, d as JsxRenderer, f as LanguageId, g as MessageInput, h as MessageFormatOptions, i as GetJsxHandler, j as isMessageSchemaValue, k as TryRenderArgs, l as InferRuntimeParams, m as MessageDescriptor, n as CompiledTranslation, o as I18nTagElement, p as MessageContext, r as DescriptorRenderArgs, s as I18nTagValue, t as AnyMessageDescriptor, u as JsonValue, v as MessageParam, w as MessageValueContext, x as MessageSchema, y as MessageParams } from "./types-BuGoCU3P.js";
3
- import { $ as createStateManager, A as StoredState, B as createRuntime, C as TranslationData, D as normalizeCatalog, E as TranslationRow, F as Formats, G as noTranslate, H as defaultRuntime, I as I18nRegistry, J as setLanguageId, K as setFormats, L as PartsRenderer, M as createStorageManager, N as FormatContext, O as parseCatalog, P as FormatFactory, Q as StateManager, R as RegistryConfig, S as CompiledTranslationItem, T as TranslationJsonl, U as getFormats, V as createTagHandler, W as getRuntime, X as setTranslationGetter, Y as setRuntimeResolver, Z as withRuntime, _ as TranslationSource, a as I18nSnapshot, b as Catalog, c as createI18nManager, d as TranslationLoader, f as TranslationLoaderArgs, g as TranslationModule, h as TranslationLookupArgs, i as I18nManagerOptions, j as createLocalStorage, k as I18nStorage, l as defaultI18nState, m as TranslationLoaderMap, n as GetTranslationArgs, o as ManagedI18n, p as TranslationLoaderEntry, q as setGetJsxHandler, r as I18nManager, s as StateData, t as CreateI18nManagerOptions, u as defaultManaged, v as createTranslationManager, w as TranslationItem, x as CompiledCatalogHeader, y as defineTranslationLoader, z as Runtime } from "./adapter-CWC8rng-.js";
4
- export { type AnyMessageDescriptor, COMPACT_VERSION, type Catalog, CompactMessage, CompactPart, type CompiledCatalogHeader, type CompiledTranslation, type CompiledTranslationItem, CreateI18nManagerOptions, type DescriptorRenderArgs, FormatContext, FormatFactory, Formats, type GetJsxHandler, GetTranslationArgs, type I18nJsxConfig, type I18nJsxOutput, I18nManager, I18nManagerOptions, I18nRegistry, I18nSnapshot, I18nStorage, type I18nTagElement, type I18nTagValue, type InferMessageSchema, type InferRuntimeParams, type JsonValue, type JsxRenderer, type LanguageId, ManagedI18n, type MessageContext, type MessageDescriptor, type MessageFormatOptions, type MessageInput, type MessageMeta, type MessageParam, type MessageParams, type MessageRuntimeValue, type MessageSchema, type MessageSchemaValue, type MessageTagHandler, type MessageValueContext, type MessageValueFactory, PartsRenderer, type PrimitiveType, RegistryConfig, Runtime, StateData, StateManager, StoredState, type TextRenderer, type TranslationData, type TranslationGetter, type TranslationItem, type TranslationJsonl, type TranslationLoader, type TranslationLoaderArgs, type TranslationLoaderEntry, type TranslationLoaderMap, type TranslationLookupArgs, type TranslationModule, type TranslationRow, type TranslationSource, type TryRenderArgs, createI18nManager, createLocalStorage, createRuntime, createStateManager, createStorageManager, createTagHandler, type createTranslationManager, defaultI18nState, defaultManaged, defaultRuntime, defineTranslationLoader, getFormats, getRuntime, type isMessageDescriptor, type isMessageSchemaValue, type isMessageTagHandler, noTranslate, type normalizeCatalog, type parseCatalog, setFormats, setGetJsxHandler, setLanguageId, setRuntimeResolver, setTranslationGetter, validateCompact, withRuntime };
1
+ export type * from './core/types';
2
+ export * from './manager';
3
+ export * from './shared/compact';
4
+ export * from './shared/runtime';
5
+ export * from './state-manager';
6
+ export * from './storage-manager';
package/dist/adapter.js CHANGED
@@ -1,4 +1,5 @@
1
- import { a as createTagHandler, c as getRuntime, d as setGetJsxHandler, f as setLanguageId, h as withRuntime, i as createRuntime, l as noTranslate, m as setTranslationGetter, n as defineTranslationLoader, o as defaultRuntime, p as setRuntimeResolver, r as I18nRegistry, s as getFormats, u as setFormats } from "./translation-manager-C79eKu2K.js";
1
+ import { a as getFormats, c as renderJsxCallback, d as setLanguageId, f as setRuntimeResolver, i as defaultRuntime, l as setFormats, m as withRuntime, n as createRuntime, o as getRuntime, p as setTranslationGetter, r as createTagHandler, s as noTranslate, t as I18nRegistry, u as setGetJsxHandler } from "./runtime-DXnGeCBw.js";
2
2
  import { n as validateCompact, t as COMPACT_VERSION } from "./compact-E3zj3Z8d.js";
3
- import { a as createLocalStorage, i as defaultManaged, n as createI18nManager, o as createStorageManager, r as defaultI18nState, s as createStateManager, t as I18nManager } from "./manager-BW778X1Y.js";
4
- export { COMPACT_VERSION, I18nManager, I18nRegistry, createI18nManager, createLocalStorage, createRuntime, createStateManager, createStorageManager, createTagHandler, defaultI18nState, defaultManaged, defaultRuntime, defineTranslationLoader, getFormats, getRuntime, noTranslate, setFormats, setGetJsxHandler, setLanguageId, setRuntimeResolver, setTranslationGetter, validateCompact, withRuntime };
3
+ import { n as defineTranslationLoader } from "./translation-manager-BkmFnlb_.js";
4
+ import { a as createLocalStorage, i as defaultManaged, n as createI18nManager, o as createStorageManager, r as defaultI18nState, s as createStateManager, t as I18nManager } from "./manager-BgMJWXWY.js";
5
+ export { COMPACT_VERSION, I18nManager, I18nRegistry, createI18nManager, createLocalStorage, createRuntime, createStateManager, createStorageManager, createTagHandler, defaultI18nState, defaultManaged, defaultRuntime, defineTranslationLoader, getFormats, getRuntime, noTranslate, renderJsxCallback, setFormats, setGetJsxHandler, setLanguageId, setRuntimeResolver, setTranslationGetter, validateCompact, withRuntime };
@@ -1,27 +1,29 @@
1
- import { n as CompactMessage, r as CompactPart } from "./compact-CJ0OWoIv.js";
2
- import { A as isMessageDescriptor, C as MessageTagHandler, D as TextRenderer, E as PrimitiveType, M as isMessageTagHandler, N as I18nJsxConfig, O as TranslationGetter, S as MessageSchemaValue, T as MessageValueFactory, _ as MessageMeta, a as I18nJsxOutput, b as MessageRuntimeValue, c as InferMessageSchema, d as JsxRenderer, f as LanguageId, g as MessageInput, h as MessageFormatOptions, i as GetJsxHandler, j as isMessageSchemaValue, k as TryRenderArgs, l as InferRuntimeParams, m as MessageDescriptor, n as CompiledTranslation, o as I18nTagElement, p as MessageContext, r as DescriptorRenderArgs, s as I18nTagValue, t as AnyMessageDescriptor, u as JsonValue, v as MessageParam, w as MessageValueContext, x as MessageSchema, y as MessageParams } from "./types-BuGoCU3P.js";
3
- import { G as noTranslate, I as I18nRegistry, K as setFormats, y as defineTranslationLoader } from "./adapter-CWC8rng-.js";
4
- import { n as TApi } from "./i18n-CfYNwubL.js";
5
- type CompiledPayload = readonly [id: string, fallback: CompactMessage];
6
- type CompiledTextRenderer = {
7
- (message: CompiledPayload, params?: MessageParams): string;
8
- <Text extends string, Schema extends MessageSchema | undefined>(message: MessageDescriptor<Text, Schema>, ...args: DescriptorRenderArgs<Schema>): string;
1
+ import { type TApi } from './core/i18n';
2
+ import type { DescriptorRenderArgs, I18nJsxOutput, I18nTagElement, I18nTagValue, MessageDescriptor, MessageParams, MessageSchema, TryRenderArgs } from './core/types';
3
+ import type { CompactMessage } from './shared/compact';
4
+ export type CompiledPayload = readonly [id: string, fallback: CompactMessage];
5
+ export type CompiledTextRenderer = {
6
+ (message: CompiledPayload, params?: MessageParams): string;
7
+ <Text extends string, Schema extends MessageSchema | undefined>(message: MessageDescriptor<Text, Schema>, ...args: DescriptorRenderArgs<Schema>): string;
9
8
  };
10
- type CompiledJsxRenderer = {
11
- (message: CompiledPayload, params?: MessageParams): I18nJsxOutput;
12
- <Text extends string, Schema extends MessageSchema | undefined>(message: MessageDescriptor<Text, Schema>, ...args: DescriptorRenderArgs<Schema>): I18nJsxOutput;
9
+ export type CompiledJsxRenderer = {
10
+ (render: () => I18nTagElement): I18nJsxOutput;
11
+ (message: CompiledPayload, params?: MessageParams): I18nJsxOutput;
12
+ <Text extends string, Schema extends MessageSchema | undefined>(message: MessageDescriptor<Text, Schema>, ...args: DescriptorRenderArgs<Schema>): I18nJsxOutput;
13
13
  };
14
- type CompiledTApi = Omit<TApi<I18nJsxOutput, I18nTagValue>, 'msg' | 'text' | 'jsx' | 'try' | 'context' | 'note' | 'meta'> & {
15
- msg<Schema extends MessageSchema | undefined = undefined>(message: CompiledPayload, schema?: Schema): MessageDescriptor<string, Schema>;
16
- text: CompiledTextRenderer;
17
- jsx: CompiledJsxRenderer;
18
- try<T>(renderer: CompiledTextRenderer, value: T, ...args: TryRenderArgs<T>): T extends {
19
- readonly __fluenticMessage: true;
20
- } ? string : T;
21
- try<T>(renderer: CompiledJsxRenderer, value: T, ...args: TryRenderArgs<T>): T extends {
22
- readonly __fluenticMessage: true;
23
- } ? I18nJsxOutput : T;
14
+ export type CompiledTApi = Omit<TApi<I18nJsxOutput, I18nTagValue>, 'msg' | 'text' | 'jsx' | 'try' | 'context' | 'note' | 'meta'> & {
15
+ msg<Schema extends MessageSchema | undefined = undefined>(message: CompiledPayload, schema?: Schema): MessageDescriptor<string, Schema>;
16
+ text: CompiledTextRenderer;
17
+ jsx: CompiledJsxRenderer;
18
+ try<T>(renderer: CompiledTextRenderer, value: T, ...args: TryRenderArgs<T>): T extends {
19
+ readonly __fluenticMessage: true;
20
+ } ? string : T;
21
+ try<T>(renderer: CompiledJsxRenderer, value: T, ...args: TryRenderArgs<T>): T extends {
22
+ readonly __fluenticMessage: true;
23
+ } ? I18nJsxOutput : T;
24
24
  };
25
- declare const t: CompiledTApi;
26
- export { AnyMessageDescriptor, type CompactMessage, type CompactPart, CompiledJsxRenderer, CompiledPayload, CompiledTApi, CompiledTextRenderer, CompiledTranslation, DescriptorRenderArgs, GetJsxHandler, type I18nJsxConfig, I18nJsxOutput, I18nRegistry, I18nTagElement, I18nTagValue, InferMessageSchema, InferRuntimeParams, JsonValue, JsxRenderer, LanguageId, MessageContext, MessageDescriptor, MessageFormatOptions, MessageInput, MessageMeta, MessageParam, MessageParams, MessageRuntimeValue, MessageSchema, MessageSchemaValue, MessageTagHandler, MessageValueContext, MessageValueFactory, PrimitiveType, TextRenderer, TranslationGetter, TryRenderArgs, defineTranslationLoader, isMessageDescriptor, isMessageSchemaValue, isMessageTagHandler, noTranslate, setFormats, t };
27
- //# sourceMappingURL=compiled.d.ts.map
25
+ export declare const t: CompiledTApi;
26
+ export * from './core/types';
27
+ export type { CompactMessage, CompactPart } from './shared/compact';
28
+ export { I18nRegistry, noTranslate, setFormats } from './shared/runtime';
29
+ export { defineTranslationLoader } from './translation-manager';
package/dist/compiled.js CHANGED
@@ -1,6 +1,7 @@
1
- import { a as createTagHandler, c as getRuntime, l as noTranslate, n as defineTranslationLoader, r as I18nRegistry, u as setFormats } from "./translation-manager-C79eKu2K.js";
1
+ import { c as renderJsxCallback, l as setFormats, o as getRuntime, r as createTagHandler, s as noTranslate, t as I18nRegistry } from "./runtime-DXnGeCBw.js";
2
2
  import { n as isMessageSchemaValue, r as isMessageTagHandler, t as isMessageDescriptor } from "./types-BkDsJfVD.js";
3
- import { n as createFormatting, t as interpret } from "./interpreter-Dld8QyOI.js";
3
+ import { n as createFormatting, t as interpret } from "./interpreter-BfzvLLrD.js";
4
+ import { n as defineTranslationLoader } from "./translation-manager-BkmFnlb_.js";
4
5
  // src/compiled.ts
5
6
  const formatting = /* @__PURE__ */ createFormatting(interpret, true);
6
7
  function descriptor(payload, schema) {
@@ -27,6 +28,7 @@ const t = {
27
28
  return formatting.getText(options(message, params));
28
29
  },
29
30
  jsx(message, params) {
31
+ if (typeof message === "function") return renderJsxCallback(message);
30
32
  return formatting.getJsx(options(message, params));
31
33
  },
32
34
  clone(message) {
@@ -1 +1 @@
1
- {"version":3,"file":"compiled.js","names":[],"sources":["../src/compiled.ts"],"sourcesContent":["import { type TApi } from './core/i18n';\nimport { isMessageDescriptor } from './core/types';\nimport type {\n DescriptorRenderArgs,\n I18nJsxOutput,\n I18nTagValue,\n MessageDescriptor,\n MessageParams,\n MessageSchema,\n TryRenderArgs,\n} from './core/types';\nimport type { CompactMessage } from './shared/compact';\nimport { createFormatting } from './shared/formatting';\nimport { interpret } from './shared/interpreter';\nimport { createTagHandler, getRuntime, noTranslate } from './shared/runtime';\n\nexport type CompiledPayload = readonly [id: string, fallback: CompactMessage];\n\nexport type CompiledTextRenderer = {\n (message: CompiledPayload, params?: MessageParams): string;\n <Text extends string, Schema extends MessageSchema | undefined>(\n message: MessageDescriptor<Text, Schema>,\n ...args: DescriptorRenderArgs<Schema>\n ): string;\n};\n\nexport type CompiledJsxRenderer = {\n (message: CompiledPayload, params?: MessageParams): I18nJsxOutput;\n <Text extends string, Schema extends MessageSchema | undefined>(\n message: MessageDescriptor<Text, Schema>,\n ...args: DescriptorRenderArgs<Schema>\n ): I18nJsxOutput;\n};\n\nexport type CompiledTApi =\n & Omit<TApi<I18nJsxOutput, I18nTagValue>, 'msg' | 'text' | 'jsx' | 'try' | 'context' | 'note' | 'meta'>\n & {\n msg<Schema extends MessageSchema | undefined = undefined>(\n message: CompiledPayload,\n schema?: Schema,\n ): MessageDescriptor<string, Schema>;\n text: CompiledTextRenderer;\n jsx: CompiledJsxRenderer;\n try<T>(\n renderer: CompiledTextRenderer,\n value: T,\n ...args: TryRenderArgs<T>\n ): T extends { readonly __fluenticMessage: true; } ? string\n : T;\n try<T>(\n renderer: CompiledJsxRenderer,\n value: T,\n ...args: TryRenderArgs<T>\n ): T extends { readonly __fluenticMessage: true; } ? I18nJsxOutput : T;\n };\n\nconst formatting = /* @__PURE__ */ createFormatting(interpret, true);\n\nfunction descriptor<Schema extends MessageSchema | undefined = undefined>(\n payload: CompiledPayload,\n schema?: Schema,\n): MessageDescriptor<string, Schema> {\n if (!Array.isArray(payload) || payload.length !== 2 || typeof payload[0] !== 'string') {\n throw new TypeError('[i18n] compiled runtime requires compiled messages; enable the Fluentic plugin');\n }\n\n return Object.freeze({\n __fluenticMessage: true,\n text: payload[0],\n compiled: payload,\n context: null,\n schema: schema ?? {},\n notes: [],\n meta: undefined,\n }) as unknown as MessageDescriptor<string, Schema>;\n}\n\nfunction options(\n message: CompiledPayload | MessageDescriptor<string, MessageSchema | undefined>,\n params?: MessageParams,\n) {\n return { msg: isMessageDescriptor(message) ? message : descriptor(message), params };\n}\n\nexport const t = {\n msg: descriptor,\n text(message: CompiledPayload | MessageDescriptor<string, MessageSchema | undefined>, params?: MessageParams) {\n return formatting.getText(options(message, params));\n },\n jsx(message: CompiledPayload | MessageDescriptor<string, MessageSchema | undefined>, params?: MessageParams) {\n return formatting.getJsx(options(message, params));\n },\n clone(message: MessageDescriptor) {\n return Object.freeze({ ...message });\n },\n params(params: MessageParams | null = {}) {\n return params ?? {};\n },\n tag(value: unknown) {\n if (typeof value === 'function') return createTagHandler(value as (chunks: unknown[]) => unknown);\n\n const adapt = getRuntime().tagElement;\n\n if (!adapt) throw new Error('[i18n] element tags require a platform adapter');\n\n return createTagHandler(adapt(value));\n },\n try(renderer: (message: unknown, params?: MessageParams) => unknown, value: unknown, params?: MessageParams) {\n return isMessageDescriptor(value) ? renderer(value, params) : value;\n },\n notranslate: noTranslate,\n} as unknown as CompiledTApi;\nexport * from './core/types';\nexport type { CompactMessage, CompactPart } from './shared/compact';\nexport { I18nRegistry, noTranslate, setFormats } from './shared/runtime';\nexport { defineTranslationLoader } from './translation-manager';\n"],"mappings":";;;;AAwDA,MAAM,aAA6B,iCAAiB,WAAW,IAAI;AAEnE,SAAS,WACP,SACA,QACmC;CACnC,IAAI,CAAC,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,KAAK,OAAO,QAAQ,OAAO,UAC3E,MAAM,IAAI,UAAU,gFAAgF;CAGtG,OAAO,OAAO,OAAO;EACnB,mBAAmB;EACnB,MAAM,QAAQ;EACd,UAAU;EACV,SAAS;EACT,QAAQ,UAAU,CAAC;EACnB,OAAO,CAAC;EACR,MAAM,KAAA;CACR,CAAC;AACH;AAEA,SAAS,QACP,SACA,QACA;CACA,OAAO;EAAE,KAAK,oBAAoB,OAAO,IAAI,UAAU,WAAW,OAAO;EAAG;CAAO;AACrF;AAEA,MAAa,IAAI;CACf,KAAK;CACL,KAAK,SAAiF,QAAwB;EAC5G,OAAO,WAAW,QAAQ,QAAQ,SAAS,MAAM,CAAC;CACpD;CACA,IAAI,SAAiF,QAAwB;EAC3G,OAAO,WAAW,OAAO,QAAQ,SAAS,MAAM,CAAC;CACnD;CACA,MAAM,SAA4B;EAChC,OAAO,OAAO,OAAO,EAAE,GAAG,QAAQ,CAAC;CACrC;CACA,OAAO,SAA+B,CAAC,GAAG;EACxC,OAAO,UAAU,CAAC;CACpB;CACA,IAAI,OAAgB;EAClB,IAAI,OAAO,UAAU,YAAY,OAAO,iBAAiB,KAAuC;EAEhG,MAAM,QAAQ,WAAW,CAAC,CAAC;EAE3B,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,gDAAgD;EAE5E,OAAO,iBAAiB,MAAM,KAAK,CAAC;CACtC;CACA,IAAI,UAAiE,OAAgB,QAAwB;EAC3G,OAAO,oBAAoB,KAAK,IAAI,SAAS,OAAO,MAAM,IAAI;CAChE;CACA,aAAa;AACf"}
1
+ {"version":3,"file":"compiled.js","names":[],"sources":["../src/compiled.ts"],"sourcesContent":["import { type TApi } from './core/i18n';\nimport { isMessageDescriptor } from './core/types';\nimport type {\n DescriptorRenderArgs,\n I18nJsxOutput,\n I18nTagElement,\n I18nTagValue,\n MessageDescriptor,\n MessageParams,\n MessageSchema,\n TryRenderArgs,\n} from './core/types';\nimport type { CompactMessage } from './shared/compact';\nimport { createFormatting } from './shared/formatting';\nimport { interpret } from './shared/interpreter';\nimport { createTagHandler, getRuntime, noTranslate, renderJsxCallback } from './shared/runtime';\n\nexport type CompiledPayload = readonly [id: string, fallback: CompactMessage];\n\nexport type CompiledTextRenderer = {\n (message: CompiledPayload, params?: MessageParams): string;\n <Text extends string, Schema extends MessageSchema | undefined>(\n message: MessageDescriptor<Text, Schema>,\n ...args: DescriptorRenderArgs<Schema>\n ): string;\n};\n\nexport type CompiledJsxRenderer = {\n (render: () => I18nTagElement): I18nJsxOutput;\n (message: CompiledPayload, params?: MessageParams): I18nJsxOutput;\n <Text extends string, Schema extends MessageSchema | undefined>(\n message: MessageDescriptor<Text, Schema>,\n ...args: DescriptorRenderArgs<Schema>\n ): I18nJsxOutput;\n};\n\nexport type CompiledTApi =\n & Omit<TApi<I18nJsxOutput, I18nTagValue>, 'msg' | 'text' | 'jsx' | 'try' | 'context' | 'note' | 'meta'>\n & {\n msg<Schema extends MessageSchema | undefined = undefined>(\n message: CompiledPayload,\n schema?: Schema,\n ): MessageDescriptor<string, Schema>;\n text: CompiledTextRenderer;\n jsx: CompiledJsxRenderer;\n try<T>(\n renderer: CompiledTextRenderer,\n value: T,\n ...args: TryRenderArgs<T>\n ): T extends { readonly __fluenticMessage: true; } ? string\n : T;\n try<T>(\n renderer: CompiledJsxRenderer,\n value: T,\n ...args: TryRenderArgs<T>\n ): T extends { readonly __fluenticMessage: true; } ? I18nJsxOutput : T;\n };\n\nconst formatting = /* @__PURE__ */ createFormatting(interpret, true);\n\nfunction descriptor<Schema extends MessageSchema | undefined = undefined>(\n payload: CompiledPayload,\n schema?: Schema,\n): MessageDescriptor<string, Schema> {\n if (!Array.isArray(payload) || payload.length !== 2 || typeof payload[0] !== 'string') {\n throw new TypeError('[i18n] compiled runtime requires compiled messages; enable the Fluentic plugin');\n }\n\n return Object.freeze({\n __fluenticMessage: true,\n text: payload[0],\n compiled: payload,\n context: null,\n schema: schema ?? {},\n notes: [],\n meta: undefined,\n }) as unknown as MessageDescriptor<string, Schema>;\n}\n\nfunction options(\n message: CompiledPayload | MessageDescriptor<string, MessageSchema | undefined>,\n params?: MessageParams,\n) {\n return { msg: isMessageDescriptor(message) ? message : descriptor(message), params };\n}\n\nexport const t = {\n msg: descriptor,\n text(message: CompiledPayload | MessageDescriptor<string, MessageSchema | undefined>, params?: MessageParams) {\n return formatting.getText(options(message, params));\n },\n jsx(\n message: CompiledPayload | MessageDescriptor<string, MessageSchema | undefined> | (() => I18nTagElement),\n params?: MessageParams,\n ) {\n if (typeof message === 'function') return renderJsxCallback(message);\n\n return formatting.getJsx(options(message, params));\n },\n clone(message: MessageDescriptor) {\n return Object.freeze({ ...message });\n },\n params(params: MessageParams | null = {}) {\n return params ?? {};\n },\n tag(value: unknown) {\n if (typeof value === 'function') return createTagHandler(value as (chunks: unknown[]) => unknown);\n\n const adapt = getRuntime().tagElement;\n\n if (!adapt) throw new Error('[i18n] element tags require a platform adapter');\n\n return createTagHandler(adapt(value));\n },\n try(renderer: (message: unknown, params?: MessageParams) => unknown, value: unknown, params?: MessageParams) {\n return isMessageDescriptor(value) ? renderer(value, params) : value;\n },\n notranslate: noTranslate,\n} as unknown as CompiledTApi;\nexport * from './core/types';\nexport type { CompactMessage, CompactPart } from './shared/compact';\nexport { I18nRegistry, noTranslate, setFormats } from './shared/runtime';\nexport { defineTranslationLoader } from './translation-manager';\n"],"mappings":";;;;;AA0DA,MAAM,aAA6B,iCAAiB,WAAW,IAAI;AAEnE,SAAS,WACP,SACA,QACmC;CACnC,IAAI,CAAC,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,KAAK,OAAO,QAAQ,OAAO,UAC3E,MAAM,IAAI,UAAU,gFAAgF;CAGtG,OAAO,OAAO,OAAO;EACnB,mBAAmB;EACnB,MAAM,QAAQ;EACd,UAAU;EACV,SAAS;EACT,QAAQ,UAAU,CAAC;EACnB,OAAO,CAAC;EACR,MAAM,KAAA;CACR,CAAC;AACH;AAEA,SAAS,QACP,SACA,QACA;CACA,OAAO;EAAE,KAAK,oBAAoB,OAAO,IAAI,UAAU,WAAW,OAAO;EAAG;CAAO;AACrF;AAEA,MAAa,IAAI;CACf,KAAK;CACL,KAAK,SAAiF,QAAwB;EAC5G,OAAO,WAAW,QAAQ,QAAQ,SAAS,MAAM,CAAC;CACpD;CACA,IACE,SACA,QACA;EACA,IAAI,OAAO,YAAY,YAAY,OAAO,kBAAkB,OAAO;EAEnE,OAAO,WAAW,OAAO,QAAQ,SAAS,MAAM,CAAC;CACnD;CACA,MAAM,SAA4B;EAChC,OAAO,OAAO,OAAO,EAAE,GAAG,QAAQ,CAAC;CACrC;CACA,OAAO,SAA+B,CAAC,GAAG;EACxC,OAAO,UAAU,CAAC;CACpB;CACA,IAAI,OAAgB;EAClB,IAAI,OAAO,UAAU,YAAY,OAAO,iBAAiB,KAAuC;EAEhG,MAAM,QAAQ,WAAW,CAAC,CAAC;EAE3B,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,gDAAgD;EAE5E,OAAO,iBAAiB,MAAM,KAAK,CAAC;CACtC;CACA,IAAI,UAAiE,OAAgB,QAAwB;EAC3G,OAAO,oBAAoB,KAAK,IAAI,SAAS,OAAO,MAAM,IAAI;CAChE;CACA,aAAa;AACf"}
@@ -0,0 +1,4 @@
1
+ export type { CompactMessage, CompactPart } from './shared/compact';
2
+ export { COMPACT_VERSION } from './shared/compact';
3
+ export { DEFAULT_HASH_LENGTH, MAX_HASH_LENGTH, messageHash, MIN_HASH_LENGTH, normalizeHashLength } from './shared/hash';
4
+ export { normalizeMessage } from './shared/message';
@@ -0,0 +1,4 @@
1
+ import { t as normalizeMessage } from "./message-D4jK2Lzc.js";
2
+ import { t as COMPACT_VERSION } from "./compact-E3zj3Z8d.js";
3
+ import { a as normalizeHashLength, i as messageHash, n as MAX_HASH_LENGTH, r as MIN_HASH_LENGTH, t as DEFAULT_HASH_LENGTH } from "./hash-VJlyT31Z.js";
4
+ export { COMPACT_VERSION, DEFAULT_HASH_LENGTH, MAX_HASH_LENGTH, MIN_HASH_LENGTH, messageHash, normalizeHashLength, normalizeMessage };
@@ -0,0 +1,11 @@
1
+ declare const formatting: {
2
+ getText: (options: import("./types").MessageFormatOptions, runtime?: import("./format").Runtime) => string;
3
+ getJsx: (options: import("./types").MessageFormatOptions) => unknown;
4
+ getMessageParts: (options: import("./types").MessageFormatOptions, runtime?: import("./format").Runtime, jsx?: boolean) => unknown[];
5
+ formatMessage: (options: import("./types").MessageFormatOptions, runtime?: import("./format").Runtime) => string;
6
+ };
7
+ export * from '../shared/runtime';
8
+ export declare const getText: (...args: Parameters<typeof formatting.getText>) => string;
9
+ export declare const getJsx: (...args: Parameters<typeof formatting.getJsx>) => unknown;
10
+ export declare const getMessageParts: (...args: Parameters<typeof formatting.getMessageParts>) => unknown[];
11
+ export declare const formatMessage: typeof getText;
@@ -0,0 +1,26 @@
1
+ import type { Formatting } from '../shared/formatting';
2
+ import { noTranslate } from '../shared/runtime';
3
+ import type { I18nJsxOutput, I18nTagElement, I18nTagValue } from './types';
4
+ import type { JsxRenderer, MessageDescriptor, MessageMeta, MessageParams, MessageSchema, MessageTagHandler, TextRenderer, TryRenderArgs } from './types';
5
+ export type MessageApi<JsxOutput = unknown> = {
6
+ context(name: string): MessageApi<JsxOutput>;
7
+ note(note: string): MessageApi<JsxOutput>;
8
+ meta(meta: MessageMeta): MessageApi<JsxOutput>;
9
+ msg<const Text extends string, const Schema extends MessageSchema | undefined = undefined>(message: Text, schema?: Schema): MessageDescriptor<Text, Schema>;
10
+ text: TextRenderer;
11
+ jsx: JsxRenderer<JsxOutput>;
12
+ };
13
+ export type TApi<JsxOutput = unknown, TagValue = unknown> = MessageApi<JsxOutput> & {
14
+ clone<const Text extends string, const Schema extends MessageSchema | undefined>(message: MessageDescriptor<Text, Schema>): MessageDescriptor<Text, Schema>;
15
+ params<Params extends MessageParams>(params?: Params | null): Params;
16
+ tag(element: I18nTagElement): MessageTagHandler<I18nTagValue, I18nTagElement>;
17
+ tag<T = TagValue, R = TagValue>(handler: (chunks: Array<string | T>) => R): MessageTagHandler<T, R>;
18
+ try<T>(renderer: TextRenderer, value: T, ...args: TryRenderArgs<T>): T extends {
19
+ readonly __fluenticMessage: true;
20
+ } ? string : T;
21
+ try<T>(renderer: JsxRenderer<JsxOutput>, value: T, ...args: TryRenderArgs<T>): T extends {
22
+ readonly __fluenticMessage: true;
23
+ } ? JsxOutput : T;
24
+ notranslate: typeof noTranslate;
25
+ };
26
+ export declare function createT({ getText, getJsx }: Formatting): TApi<I18nJsxOutput, I18nTagValue>;
@@ -1,5 +1 @@
1
- import { A as isMessageDescriptor, C as MessageTagHandler, D as TextRenderer, E as PrimitiveType, M as isMessageTagHandler, N as I18nJsxConfig, O as TranslationGetter, S as MessageSchemaValue, T as MessageValueFactory, _ as MessageMeta, a as I18nJsxOutput, b as MessageRuntimeValue, c as InferMessageSchema, d as JsxRenderer, f as LanguageId, g as MessageInput, h as MessageFormatOptions, i as GetJsxHandler, j as isMessageSchemaValue, k as TryRenderArgs, l as InferRuntimeParams, m as MessageDescriptor, n as CompiledTranslation, o as I18nTagElement, p as MessageContext, r as DescriptorRenderArgs, s as I18nTagValue, t as AnyMessageDescriptor, u as JsonValue, v as MessageParam, w as MessageValueContext, x as MessageSchema, y as MessageParams } from "../types-BuGoCU3P.js";
2
- import { C as TranslationData, G as noTranslate, I as I18nRegistry, K as setFormats, d as TranslationLoader, m as TranslationLoaderMap, w as TranslationItem, y as defineTranslationLoader } from "../adapter-CWC8rng-.js";
3
- import { n as TApi, t as MessageApi } from "../i18n-CfYNwubL.js";
4
- import { t } from "../index.js";
5
- export { AnyMessageDescriptor, CompiledTranslation, DescriptorRenderArgs, GetJsxHandler, type I18nJsxConfig, I18nJsxOutput, I18nRegistry, I18nTagElement, I18nTagValue, InferMessageSchema, InferRuntimeParams, JsonValue, JsxRenderer, LanguageId, type MessageApi, MessageContext, MessageDescriptor, MessageFormatOptions, MessageInput, MessageMeta, MessageParam, MessageParams, MessageRuntimeValue, MessageSchema, MessageSchemaValue, MessageTagHandler, MessageValueContext, MessageValueFactory, PrimitiveType, type TApi, TextRenderer, type TranslationData, TranslationGetter, type TranslationItem, type TranslationLoader, type TranslationLoaderMap, TryRenderArgs, defineTranslationLoader, isMessageDescriptor, isMessageSchemaValue, isMessageTagHandler, noTranslate, setFormats, t };
1
+ export * from '../index';
@@ -1,4 +1,5 @@
1
- import { t } from "../src-BovRx-mX.js";
2
- import { l as noTranslate, n as defineTranslationLoader, r as I18nRegistry, u as setFormats } from "../translation-manager-C79eKu2K.js";
1
+ import { t } from "../src-ON68XIog.js";
2
+ import { l as setFormats, s as noTranslate, t as I18nRegistry } from "../runtime-DXnGeCBw.js";
3
3
  import { n as isMessageSchemaValue, r as isMessageTagHandler, t as isMessageDescriptor } from "../types-BkDsJfVD.js";
4
+ import { n as defineTranslationLoader } from "../translation-manager-BkmFnlb_.js";
4
5
  export { I18nRegistry, defineTranslationLoader, isMessageDescriptor, isMessageSchemaValue, isMessageTagHandler, noTranslate, setFormats, t };
@@ -0,0 +1,79 @@
1
+ import type { CompactMessage } from '../shared/compact';
2
+ import type { I18nJsxConfig } from '../types';
3
+ export type { I18nJsxConfig } from '../types';
4
+ export type I18nJsxOutput = I18nJsxConfig extends {
5
+ JSX: infer Output;
6
+ } ? NonNullable<Output> : unknown;
7
+ export type I18nTagElement = I18nJsxConfig extends {
8
+ Element: infer Element;
9
+ } ? Element : never;
10
+ export type I18nTagValue = I18nJsxConfig extends {
11
+ Value: infer Value;
12
+ } ? Value : unknown;
13
+ export type PrimitiveType = string | number | boolean | null | undefined;
14
+ export type LanguageId = string;
15
+ export type JsonValue = string | number | boolean | null | JsonValue[] | {
16
+ [key: string]: JsonValue;
17
+ };
18
+ export type MessageMeta = JsonValue;
19
+ export type MessageContext = string;
20
+ export type MessageSchemaValue = StringConstructor | NumberConstructor | BooleanConstructor | DateConstructor;
21
+ export type MessageSchema = Partial<Record<string, MessageSchemaValue>>;
22
+ export type InferMessageSchema<Schema extends MessageSchema> = {
23
+ [Key in keyof Schema]: Schema[Key] extends StringConstructor ? string : Schema[Key] extends NumberConstructor ? number : Schema[Key] extends BooleanConstructor ? boolean : Schema[Key] extends DateConstructor ? Date : never;
24
+ };
25
+ export type MessageDescriptor<Text extends string = string, Schema extends MessageSchema | undefined = MessageSchema> = {
26
+ readonly __fluenticMessage: true;
27
+ readonly text: Text;
28
+ readonly compiled?: readonly [string, CompactMessage];
29
+ readonly context: MessageContext | null;
30
+ readonly schema: Schema extends MessageSchema ? Schema : MessageSchema;
31
+ readonly notes: readonly string[];
32
+ readonly meta: MessageMeta | undefined;
33
+ };
34
+ export type AnyMessageDescriptor = MessageDescriptor<string, MessageSchema | undefined>;
35
+ export type MessageValueContext = {
36
+ languageId: LanguageId;
37
+ };
38
+ export type MessageValueFactory<T = unknown> = (context: MessageValueContext) => T;
39
+ export type MessageTagHandler<T = unknown, R = unknown> = ((chunks: Array<string | T>) => R) & {
40
+ readonly __fluenticTagHandler: true;
41
+ };
42
+ export type MessageRuntimeValue = PrimitiveType | Date | AnyMessageDescriptor | MessageValueFactory | Pick<MessageTagHandler, '__fluenticTagHandler'>;
43
+ export type MessageParam = MessageRuntimeValue;
44
+ export type MessageParams = Record<string, MessageParam>;
45
+ export type MessageInput = string | AnyMessageDescriptor;
46
+ export type InferRuntimeParams<Schema extends MessageSchema> = {
47
+ [Key in keyof InferMessageSchema<Schema>]: InferMessageSchema<Schema>[Key] | MessageValueFactory<InferMessageSchema<Schema>[Key]>;
48
+ };
49
+ export type DescriptorRenderArgs<Schema extends MessageSchema | undefined> = Schema extends undefined ? [params?: MessageParams] : keyof Schema extends never ? [] : Schema extends MessageSchema ? [params: InferRuntimeParams<Schema>] : never;
50
+ export type TryRenderArgs<Value> = Value extends {
51
+ readonly __fluenticMessage: true;
52
+ } ? Value extends MessageDescriptor<string, infer Schema> ? Schema extends MessageSchema | undefined ? DescriptorRenderArgs<Schema> : [params: MessageParams] : [params: MessageParams] : [params?: MessageParams];
53
+ export type TextRenderer = {
54
+ <Text extends string>(message: Text, params?: MessageParams): string;
55
+ <Text extends string, Schema extends MessageSchema | undefined>(message: MessageDescriptor<Text, Schema>, ...args: DescriptorRenderArgs<Schema>): string;
56
+ };
57
+ export type JsxRenderer<Output = unknown> = {
58
+ (render: () => I18nTagElement): Output;
59
+ <Text extends string>(message: Text, params?: MessageParams): Output;
60
+ <Text extends string, Schema extends MessageSchema | undefined>(message: MessageDescriptor<Text, Schema>, ...args: DescriptorRenderArgs<Schema>): Output;
61
+ };
62
+ export type MessageFormatOptions = {
63
+ msg: MessageInput;
64
+ params?: MessageParams;
65
+ languageId?: LanguageId;
66
+ };
67
+ export type GetJsxHandler<Output = unknown> = (options: MessageFormatOptions) => Output;
68
+ export type CompiledTranslation = {
69
+ compiled: CompactMessage;
70
+ };
71
+ export type TranslationGetter = (args: {
72
+ languageId: LanguageId;
73
+ context: MessageContext | null;
74
+ message: string;
75
+ getCompiledId?: () => string;
76
+ }) => CompactMessage | CompiledTranslation | null;
77
+ export declare function isMessageDescriptor(value: unknown): value is AnyMessageDescriptor;
78
+ export declare function isMessageTagHandler(value: unknown): value is MessageTagHandler;
79
+ export declare function isMessageSchemaValue(value: unknown): value is MessageSchemaValue;
@@ -0,0 +1,90 @@
1
+ // src/shared/hash.ts
2
+ const MASK_64 = 18446744073709551615n;
3
+ const C1 = 9782798678568883157n;
4
+ const C2 = 5545529020109919103n;
5
+ const BASE64URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
6
+ const DEFAULT_HASH_LENGTH = 8;
7
+ const MIN_HASH_LENGTH = 6;
8
+ const MAX_HASH_LENGTH = 22;
9
+ function normalizeHashLength(length = 8) {
10
+ if (!Number.isInteger(length) || length < 6 || length > 22) throw new RangeError(`[i18n] compiled.hashLength must be an integer from 6 to 22`);
11
+ return length;
12
+ }
13
+ function rotateLeft(value, bits) {
14
+ return (value << bits | value >> 64n - bits) & MASK_64;
15
+ }
16
+ function mixFinal(value) {
17
+ value ^= value >> 33n;
18
+ value = value * 18397679294719823053n & MASK_64;
19
+ value ^= value >> 33n;
20
+ value = value * 14181476777654086739n & MASK_64;
21
+ return (value ^ value >> 33n) & MASK_64;
22
+ }
23
+ function read64(bytes, offset) {
24
+ let value = 0n;
25
+ for (let index = 0; index < 8; index += 1) value |= BigInt(bytes[offset + index]) << BigInt(index * 8);
26
+ return value;
27
+ }
28
+ function encodeBase64Url(bytes) {
29
+ let result = "";
30
+ for (let index = 0; index < bytes.length; index += 3) {
31
+ const a = bytes[index];
32
+ const b = bytes[index + 1];
33
+ const c = bytes[index + 2];
34
+ result += BASE64URL[a >> 2];
35
+ result += BASE64URL[(a & 3) << 4 | (b ?? 0) >> 4];
36
+ if (b !== void 0) result += BASE64URL[(b & 15) << 2 | (c ?? 0) >> 6];
37
+ if (c !== void 0) result += BASE64URL[c & 63];
38
+ }
39
+ return result;
40
+ }
41
+ /** MurmurHash3 x64 128-bit, encoded as unpadded base64url. */
42
+ function murmurHash128(value) {
43
+ const bytes = new TextEncoder().encode(value);
44
+ const blocks = Math.floor(bytes.length / 16);
45
+ let h1 = 0n;
46
+ let h2 = 0n;
47
+ for (let block = 0; block < blocks; block += 1) {
48
+ let k1 = read64(bytes, block * 16);
49
+ let k2 = read64(bytes, block * 16 + 8);
50
+ k1 = rotateLeft(k1 * C1 & MASK_64, 31n) * C2 & MASK_64;
51
+ h1 ^= k1;
52
+ h1 = (rotateLeft(h1, 27n) + h2) * 5n + 1390208809n & MASK_64;
53
+ k2 = rotateLeft(k2 * C2 & MASK_64, 33n) * C1 & MASK_64;
54
+ h2 ^= k2;
55
+ h2 = (rotateLeft(h2, 31n) + h1) * 5n + 944331445n & MASK_64;
56
+ }
57
+ const tail = blocks * 16;
58
+ let k1 = 0n;
59
+ let k2 = 0n;
60
+ for (let index = bytes.length - 1; index >= tail + 8; index -= 1) k2 = k2 << 8n | BigInt(bytes[index]);
61
+ for (let index = Math.min(bytes.length, tail + 8) - 1; index >= tail; index -= 1) k1 = k1 << 8n | BigInt(bytes[index]);
62
+ if (k2) {
63
+ k2 = rotateLeft(k2 * C2 & MASK_64, 33n) * C1 & MASK_64;
64
+ h2 ^= k2;
65
+ }
66
+ if (k1) {
67
+ k1 = rotateLeft(k1 * C1 & MASK_64, 31n) * C2 & MASK_64;
68
+ h1 ^= k1;
69
+ }
70
+ h1 ^= BigInt(bytes.length);
71
+ h2 ^= BigInt(bytes.length);
72
+ h1 = h1 + h2 & MASK_64;
73
+ h2 = h2 + h1 & MASK_64;
74
+ h1 = mixFinal(h1);
75
+ h2 = mixFinal(h2);
76
+ h1 = h1 + h2 & MASK_64;
77
+ h2 = h2 + h1 & MASK_64;
78
+ const output = /* @__PURE__ */ new Uint8Array(16);
79
+ for (let index = 0; index < 8; index += 1) {
80
+ output[index] = Number(h1 >> BigInt(index * 8) & 255n);
81
+ output[index + 8] = Number(h2 >> BigInt(index * 8) & 255n);
82
+ }
83
+ return encodeBase64Url(output);
84
+ }
85
+ function messageHash(identity, length = 8) {
86
+ return murmurHash128(identity).slice(0, normalizeHashLength(length));
87
+ }
88
+ export { normalizeHashLength as a, messageHash as i, MAX_HASH_LENGTH as n, MIN_HASH_LENGTH as r, DEFAULT_HASH_LENGTH as t };
89
+
90
+ //# sourceMappingURL=hash-VJlyT31Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash-VJlyT31Z.js","names":[],"sources":["../src/shared/hash.ts"],"sourcesContent":["const MASK_64 = 0xffffffffffffffffn;\nconst C1 = 0x87c37b91114253d5n;\nconst C2 = 0x4cf5ad432745937fn;\nconst BASE64URL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';\n\nexport const DEFAULT_HASH_LENGTH = 8;\nexport const MIN_HASH_LENGTH = 6;\nexport const MAX_HASH_LENGTH = 22;\n\nexport function normalizeHashLength(length = DEFAULT_HASH_LENGTH): number {\n if (!Number.isInteger(length) || length < MIN_HASH_LENGTH || length > MAX_HASH_LENGTH) {\n throw new RangeError(`[i18n] compiled.hashLength must be an integer from ${MIN_HASH_LENGTH} to ${MAX_HASH_LENGTH}`);\n }\n return length;\n}\n\nfunction rotateLeft(value: bigint, bits: bigint): bigint {\n return ((value << bits) | (value >> (64n - bits))) & MASK_64;\n}\n\nfunction mixFinal(value: bigint): bigint {\n value ^= value >> 33n;\n value = value * 0xff51afd7ed558ccdn & MASK_64;\n value ^= value >> 33n;\n value = value * 0xc4ceb9fe1a85ec53n & MASK_64;\n return (value ^ value >> 33n) & MASK_64;\n}\n\nfunction read64(bytes: Uint8Array, offset: number): bigint {\n let value = 0n;\n for (let index = 0; index < 8; index += 1) value |= BigInt(bytes[offset + index]) << BigInt(index * 8);\n return value;\n}\n\nfunction encodeBase64Url(bytes: Uint8Array): string {\n let result = '';\n for (let index = 0; index < bytes.length; index += 3) {\n const a = bytes[index];\n const b = bytes[index + 1];\n const c = bytes[index + 2];\n result += BASE64URL[a >> 2];\n result += BASE64URL[(a & 3) << 4 | (b ?? 0) >> 4];\n if (b !== undefined) result += BASE64URL[(b & 15) << 2 | (c ?? 0) >> 6];\n if (c !== undefined) result += BASE64URL[c & 63];\n }\n return result;\n}\n\n/** MurmurHash3 x64 128-bit, encoded as unpadded base64url. */\nexport function murmurHash128(value: string): string {\n const bytes = new TextEncoder().encode(value);\n const blocks = Math.floor(bytes.length / 16);\n let h1 = 0n;\n let h2 = 0n;\n\n for (let block = 0; block < blocks; block += 1) {\n let k1 = read64(bytes, block * 16);\n let k2 = read64(bytes, block * 16 + 8);\n k1 = rotateLeft(k1 * C1 & MASK_64, 31n) * C2 & MASK_64;\n h1 ^= k1;\n h1 = (rotateLeft(h1, 27n) + h2) * 5n + 0x52dce729n & MASK_64;\n k2 = rotateLeft(k2 * C2 & MASK_64, 33n) * C1 & MASK_64;\n h2 ^= k2;\n h2 = (rotateLeft(h2, 31n) + h1) * 5n + 0x38495ab5n & MASK_64;\n }\n\n const tail = blocks * 16;\n let k1 = 0n;\n let k2 = 0n;\n for (let index = bytes.length - 1; index >= tail + 8; index -= 1) {\n k2 = k2 << 8n | BigInt(bytes[index]);\n }\n for (let index = Math.min(bytes.length, tail + 8) - 1; index >= tail; index -= 1) {\n k1 = k1 << 8n | BigInt(bytes[index]);\n }\n if (k2) {\n k2 = rotateLeft(k2 * C2 & MASK_64, 33n) * C1 & MASK_64;\n h2 ^= k2;\n }\n if (k1) {\n k1 = rotateLeft(k1 * C1 & MASK_64, 31n) * C2 & MASK_64;\n h1 ^= k1;\n }\n\n h1 ^= BigInt(bytes.length);\n h2 ^= BigInt(bytes.length);\n h1 = h1 + h2 & MASK_64;\n h2 = h2 + h1 & MASK_64;\n h1 = mixFinal(h1);\n h2 = mixFinal(h2);\n h1 = h1 + h2 & MASK_64;\n h2 = h2 + h1 & MASK_64;\n const output = new Uint8Array(16);\n for (let index = 0; index < 8; index += 1) {\n output[index] = Number(h1 >> BigInt(index * 8) & 0xffn);\n output[index + 8] = Number(h2 >> BigInt(index * 8) & 0xffn);\n }\n return encodeBase64Url(output);\n}\n\nexport function messageHash(identity: string, length = DEFAULT_HASH_LENGTH): string {\n return murmurHash128(identity).slice(0, normalizeHashLength(length));\n}\n"],"mappings":";AAAA,MAAM,UAAU;AAChB,MAAM,KAAK;AACX,MAAM,KAAK;AACX,MAAM,YAAY;AAElB,MAAa,sBAAsB;AACnC,MAAa,kBAAkB;AAC/B,MAAa,kBAAkB;AAE/B,SAAgB,oBAAoB,SAAA,GAAsC;CACxE,IAAI,CAAC,OAAO,UAAU,MAAM,KAAK,SAAA,KAA4B,SAAA,IAC3D,MAAM,IAAI,WAAW,4DAA6F;CAEpH,OAAO;AACT;AAEA,SAAS,WAAW,OAAe,MAAsB;CACvD,QAAS,SAAS,OAAS,SAAU,MAAM,QAAU;AACvD;AAEA,SAAS,SAAS,OAAuB;CACvC,SAAS,SAAS;CAClB,QAAQ,QAAQ,wBAAsB;CACtC,SAAS,SAAS;CAClB,QAAQ,QAAQ,wBAAsB;CACtC,QAAQ,QAAQ,SAAS,OAAO;AAClC;AAEA,SAAS,OAAO,OAAmB,QAAwB;CACzD,IAAI,QAAQ;CACZ,KAAK,IAAI,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,OAAO,MAAM,SAAS,MAAM,KAAK,OAAO,QAAQ,CAAC;CACrG,OAAO;AACT;AAEA,SAAS,gBAAgB,OAA2B;CAClD,IAAI,SAAS;CACb,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS,GAAG;EACpD,MAAM,IAAI,MAAM;EAChB,MAAM,IAAI,MAAM,QAAQ;EACxB,MAAM,IAAI,MAAM,QAAQ;EACxB,UAAU,UAAU,KAAK;EACzB,UAAU,WAAW,IAAI,MAAM,KAAK,KAAK,MAAM;EAC/C,IAAI,MAAM,KAAA,GAAW,UAAU,WAAW,IAAI,OAAO,KAAK,KAAK,MAAM;EACrE,IAAI,MAAM,KAAA,GAAW,UAAU,UAAU,IAAI;CAC/C;CACA,OAAO;AACT;;AAGA,SAAgB,cAAc,OAAuB;CACnD,MAAM,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;CAC5C,MAAM,SAAS,KAAK,MAAM,MAAM,SAAS,EAAE;CAC3C,IAAI,KAAK;CACT,IAAI,KAAK;CAET,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,SAAS,GAAG;EAC9C,IAAI,KAAK,OAAO,OAAO,QAAQ,EAAE;EACjC,IAAI,KAAK,OAAO,OAAO,QAAQ,KAAK,CAAC;EACrC,KAAK,WAAW,KAAK,KAAK,SAAS,GAAG,IAAI,KAAK;EAC/C,MAAM;EACN,MAAM,WAAW,IAAI,GAAG,IAAI,MAAM,KAAK,cAAc;EACrD,KAAK,WAAW,KAAK,KAAK,SAAS,GAAG,IAAI,KAAK;EAC/C,MAAM;EACN,MAAM,WAAW,IAAI,GAAG,IAAI,MAAM,KAAK,aAAc;CACvD;CAEA,MAAM,OAAO,SAAS;CACtB,IAAI,KAAK;CACT,IAAI,KAAK;CACT,KAAK,IAAI,QAAQ,MAAM,SAAS,GAAG,SAAS,OAAO,GAAG,SAAS,GAC7D,KAAK,MAAM,KAAK,OAAO,MAAM,MAAM;CAErC,KAAK,IAAI,QAAQ,KAAK,IAAI,MAAM,QAAQ,OAAO,CAAC,IAAI,GAAG,SAAS,MAAM,SAAS,GAC7E,KAAK,MAAM,KAAK,OAAO,MAAM,MAAM;CAErC,IAAI,IAAI;EACN,KAAK,WAAW,KAAK,KAAK,SAAS,GAAG,IAAI,KAAK;EAC/C,MAAM;CACR;CACA,IAAI,IAAI;EACN,KAAK,WAAW,KAAK,KAAK,SAAS,GAAG,IAAI,KAAK;EAC/C,MAAM;CACR;CAEA,MAAM,OAAO,MAAM,MAAM;CACzB,MAAM,OAAO,MAAM,MAAM;CACzB,KAAK,KAAK,KAAK;CACf,KAAK,KAAK,KAAK;CACf,KAAK,SAAS,EAAE;CAChB,KAAK,SAAS,EAAE;CAChB,KAAK,KAAK,KAAK;CACf,KAAK,KAAK,KAAK;CACf,MAAM,yBAAS,IAAI,WAAW,EAAE;CAChC,KAAK,IAAI,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG;EACzC,OAAO,SAAS,OAAO,MAAM,OAAO,QAAQ,CAAC,IAAI,IAAK;EACtD,OAAO,QAAQ,KAAK,OAAO,MAAM,OAAO,QAAQ,CAAC,IAAI,IAAK;CAC5D;CACA,OAAO,gBAAgB,MAAM;AAC/B;AAEA,SAAgB,YAAY,UAAkB,SAAA,GAAsC;CAClF,OAAO,cAAc,QAAQ,CAAC,CAAC,MAAM,GAAG,oBAAoB,MAAM,CAAC;AACrE"}
@@ -0,0 +1,13 @@
1
+ // src/hydration-store.ts
2
+ const controllers = /* @__PURE__ */ new WeakMap();
3
+ function registerHydration(target, controller) {
4
+ controllers.set(target, controller);
5
+ }
6
+ function getHydration(target) {
7
+ const controller = controllers.get(target);
8
+ if (!controller) throw new TypeError("[i18n] hydration requires an i18n manager instance");
9
+ return controller;
10
+ }
11
+ export { registerHydration as n, getHydration as t };
12
+
13
+ //# sourceMappingURL=hydration-store-BK6UxrtJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydration-store-BK6UxrtJ.js","names":[],"sources":["../src/hydration-store.ts"],"sourcesContent":["import type { Formats, Runtime } from './shared/runtime';\nimport type { Catalog } from './translation-manager';\n\nexport type I18nSnapshot = {\n languageId: string;\n fallbackLanguageId?: string;\n translations: Record<string, Catalog>;\n formats?: Partial<Formats>;\n compiledLanguages?: string[];\n};\n\ntype HydrationController = {\n runtime: Runtime;\n state: {\n set(value: Partial<{ languageId: string; isLoading: boolean; ready: boolean; }>): void;\n };\n translations: {\n catalogs: Record<string, Catalog>;\n compiledCatalogs: Record<string, boolean>;\n };\n getFallbackLanguageId(): string | undefined;\n setFallbackLanguageId(languageId: string | undefined): void;\n invalidate(): void;\n};\n\nconst controllers = new WeakMap<object, HydrationController>();\n\nexport function registerHydration(target: object, controller: HydrationController): void {\n controllers.set(target, controller);\n}\n\nexport function getHydration(target: object): HydrationController {\n const controller = controllers.get(target);\n\n if (!controller) throw new TypeError('[i18n] hydration requires an i18n manager instance');\n\n return controller;\n}\n"],"mappings":";AAyBA,MAAM,8BAAc,IAAI,QAAqC;AAE7D,SAAgB,kBAAkB,QAAgB,YAAuC;CACvF,YAAY,IAAI,QAAQ,UAAU;AACpC;AAEA,SAAgB,aAAa,QAAqC;CAChE,MAAM,aAAa,YAAY,IAAI,MAAM;CAEzC,IAAI,CAAC,YAAY,MAAM,IAAI,UAAU,oDAAoD;CAEzF,OAAO;AACT"}
@@ -0,0 +1,29 @@
1
+ import type { Formats, Runtime } from './shared/runtime';
2
+ import type { Catalog } from './translation-manager';
3
+ export type I18nSnapshot = {
4
+ languageId: string;
5
+ fallbackLanguageId?: string;
6
+ translations: Record<string, Catalog>;
7
+ formats?: Partial<Formats>;
8
+ compiledLanguages?: string[];
9
+ };
10
+ type HydrationController = {
11
+ runtime: Runtime;
12
+ state: {
13
+ set(value: Partial<{
14
+ languageId: string;
15
+ isLoading: boolean;
16
+ ready: boolean;
17
+ }>): void;
18
+ };
19
+ translations: {
20
+ catalogs: Record<string, Catalog>;
21
+ compiledCatalogs: Record<string, boolean>;
22
+ };
23
+ getFallbackLanguageId(): string | undefined;
24
+ setFallbackLanguageId(languageId: string | undefined): void;
25
+ invalidate(): void;
26
+ };
27
+ export declare function registerHydration(target: object, controller: HydrationController): void;
28
+ export declare function getHydration(target: object): HydrationController;
29
+ export {};
@@ -0,0 +1,7 @@
1
+ import { type I18nSnapshot } from './hydration-store';
2
+ import type { ManagedI18n } from './manager';
3
+ export type { I18nSnapshot } from './hydration-store';
4
+ /** Capture loaded catalogs and locale state for transfer to another runtime. */
5
+ export declare function getSnapshot(instance: ManagedI18n): I18nSnapshot;
6
+ /** Initialize a runtime from a server-produced snapshot without loading catalogs. */
7
+ export declare function hydrate(instance: ManagedI18n, snapshot: I18nSnapshot): void;
@@ -0,0 +1,35 @@
1
+ import { a as getFormats } from "./runtime-DXnGeCBw.js";
2
+ import { t as getHydration } from "./hydration-store-BK6UxrtJ.js";
3
+ // src/hydration.ts
4
+ /** Capture loaded catalogs and locale state for transfer to another runtime. */
5
+ function getSnapshot(instance) {
6
+ const { runtime, translations, getFallbackLanguageId } = getHydration(instance);
7
+ return {
8
+ languageId: runtime.languageId,
9
+ fallbackLanguageId: getFallbackLanguageId(),
10
+ translations: Object.fromEntries(Object.entries(translations.catalogs).map(([id, catalog]) => [id, { ...catalog }])),
11
+ formats: getFormats(runtime, runtime.languageId),
12
+ compiledLanguages: Object.keys(translations.compiledCatalogs).filter((id) => translations.compiledCatalogs[id])
13
+ };
14
+ }
15
+ /** Initialize a runtime from a server-produced snapshot without loading catalogs. */
16
+ function hydrate(instance, snapshot) {
17
+ const { runtime, state, translations, setFallbackLanguageId, invalidate } = getHydration(instance);
18
+ invalidate();
19
+ for (const id of Object.keys(translations.catalogs)) delete translations.catalogs[id];
20
+ for (const id of Object.keys(translations.compiledCatalogs)) delete translations.compiledCatalogs[id];
21
+ for (const [id, catalog] of Object.entries(snapshot.translations)) translations.catalogs[id] = Object.assign(Object.create(null), catalog);
22
+ for (const id of snapshot.compiledLanguages ?? []) translations.compiledCatalogs[id] = true;
23
+ runtime.formats = snapshot.formats ?? {};
24
+ runtime.languageId = snapshot.languageId;
25
+ setFallbackLanguageId(snapshot.fallbackLanguageId);
26
+ runtime.ready = true;
27
+ state.set({
28
+ languageId: snapshot.languageId,
29
+ ready: true,
30
+ isLoading: false
31
+ });
32
+ }
33
+ export { getSnapshot, hydrate };
34
+
35
+ //# sourceMappingURL=hydration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydration.js","names":[],"sources":["../src/hydration.ts"],"sourcesContent":["import { getHydration, type I18nSnapshot } from './hydration-store';\nimport type { ManagedI18n } from './manager';\nimport { getFormats } from './shared/runtime';\n\nexport type { I18nSnapshot } from './hydration-store';\n\n/** Capture loaded catalogs and locale state for transfer to another runtime. */\nexport function getSnapshot(instance: ManagedI18n): I18nSnapshot {\n const { runtime, translations, getFallbackLanguageId } = getHydration(instance);\n\n return {\n languageId: runtime.languageId,\n fallbackLanguageId: getFallbackLanguageId(),\n translations: Object.fromEntries(\n Object.entries(translations.catalogs).map(([id, catalog]) => [id, { ...catalog }]),\n ),\n formats: getFormats(runtime, runtime.languageId),\n compiledLanguages: Object.keys(translations.compiledCatalogs).filter(\n (id) => translations.compiledCatalogs[id],\n ),\n };\n}\n\n/** Initialize a runtime from a server-produced snapshot without loading catalogs. */\nexport function hydrate(instance: ManagedI18n, snapshot: I18nSnapshot): void {\n const { runtime, state, translations, setFallbackLanguageId, invalidate } = getHydration(instance);\n invalidate();\n\n for (const id of Object.keys(translations.catalogs)) delete translations.catalogs[id];\n for (const id of Object.keys(translations.compiledCatalogs)) delete translations.compiledCatalogs[id];\n for (const [id, catalog] of Object.entries(snapshot.translations)) {\n translations.catalogs[id] = Object.assign(Object.create(null), catalog);\n }\n\n for (const id of snapshot.compiledLanguages ?? []) translations.compiledCatalogs[id] = true;\n\n runtime.formats = snapshot.formats ?? {};\n runtime.languageId = snapshot.languageId;\n setFallbackLanguageId(snapshot.fallbackLanguageId);\n runtime.ready = true;\n state.set({ languageId: snapshot.languageId, ready: true, isLoading: false });\n}\n"],"mappings":";;;;AAOA,SAAgB,YAAY,UAAqC;CAC/D,MAAM,EAAE,SAAS,cAAc,0BAA0B,aAAa,QAAQ;CAE9E,OAAO;EACL,YAAY,QAAQ;EACpB,oBAAoB,sBAAsB;EAC1C,cAAc,OAAO,YACnB,OAAO,QAAQ,aAAa,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC,CACnF;EACA,SAAS,WAAW,SAAS,QAAQ,UAAU;EAC/C,mBAAmB,OAAO,KAAK,aAAa,gBAAgB,CAAC,CAAC,QAC3D,OAAO,aAAa,iBAAiB,GACxC;CACF;AACF;;AAGA,SAAgB,QAAQ,UAAuB,UAA8B;CAC3E,MAAM,EAAE,SAAS,OAAO,cAAc,uBAAuB,eAAe,aAAa,QAAQ;CACjG,WAAW;CAEX,KAAK,MAAM,MAAM,OAAO,KAAK,aAAa,QAAQ,GAAG,OAAO,aAAa,SAAS;CAClF,KAAK,MAAM,MAAM,OAAO,KAAK,aAAa,gBAAgB,GAAG,OAAO,aAAa,iBAAiB;CAClG,KAAK,MAAM,CAAC,IAAI,YAAY,OAAO,QAAQ,SAAS,YAAY,GAC9D,aAAa,SAAS,MAAM,OAAO,OAAO,OAAO,OAAO,IAAI,GAAG,OAAO;CAGxE,KAAK,MAAM,MAAM,SAAS,qBAAqB,CAAC,GAAG,aAAa,iBAAiB,MAAM;CAEvF,QAAQ,UAAU,SAAS,WAAW,CAAC;CACvC,QAAQ,aAAa,SAAS;CAC9B,sBAAsB,SAAS,kBAAkB;CACjD,QAAQ,QAAQ;CAChB,MAAM,IAAI;EAAE,YAAY,SAAS;EAAY,OAAO;EAAM,WAAW;CAAM,CAAC;AAC9E"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { A as isMessageDescriptor, C as MessageTagHandler, D as TextRenderer, E as PrimitiveType, M as isMessageTagHandler, N as I18nJsxConfig, O as TranslationGetter, S as MessageSchemaValue, T as MessageValueFactory, _ as MessageMeta, a as I18nJsxOutput, b as MessageRuntimeValue, c as InferMessageSchema, d as JsxRenderer, f as LanguageId, g as MessageInput, h as MessageFormatOptions, i as GetJsxHandler, j as isMessageSchemaValue, k as TryRenderArgs, l as InferRuntimeParams, m as MessageDescriptor, n as CompiledTranslation, o as I18nTagElement, p as MessageContext, r as DescriptorRenderArgs, s as I18nTagValue, t as AnyMessageDescriptor, u as JsonValue, v as MessageParam, w as MessageValueContext, x as MessageSchema, y as MessageParams } from "./types-BuGoCU3P.js";
2
- import { C as TranslationData, G as noTranslate, I as I18nRegistry, K as setFormats, d as TranslationLoader, m as TranslationLoaderMap, w as TranslationItem, y as defineTranslationLoader } from "./adapter-CWC8rng-.js";
3
- import { n as TApi, t as MessageApi } from "./i18n-CfYNwubL.js";
4
- declare const t: TApi<import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>, import("react").ReactNode>;
5
- export { AnyMessageDescriptor, CompiledTranslation, DescriptorRenderArgs, GetJsxHandler, type I18nJsxConfig, I18nJsxOutput, I18nRegistry, I18nTagElement, I18nTagValue, InferMessageSchema, InferRuntimeParams, JsonValue, JsxRenderer, LanguageId, type MessageApi, MessageContext, MessageDescriptor, MessageFormatOptions, MessageInput, MessageMeta, MessageParam, MessageParams, MessageRuntimeValue, MessageSchema, MessageSchemaValue, MessageTagHandler, MessageValueContext, MessageValueFactory, PrimitiveType, type TApi, TextRenderer, type TranslationData, TranslationGetter, type TranslationItem, type TranslationLoader, type TranslationLoaderMap, TryRenderArgs, defineTranslationLoader, isMessageDescriptor, isMessageSchemaValue, isMessageTagHandler, noTranslate, setFormats, t };
6
- //# sourceMappingURL=index.d.ts.map
1
+ export declare const t: import(".").TApi<import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>, import("react").ReactNode>;
2
+ export type { MessageApi, TApi } from './core/i18n';
3
+ export * from './core/types';
4
+ export { I18nRegistry, noTranslate, setFormats } from './shared/runtime';
5
+ export { defineTranslationLoader } from './translation-manager';
6
+ export type { TranslationData, TranslationItem, TranslationLoader, TranslationLoaderMap } from './translation-manager';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import { t } from "./src-BovRx-mX.js";
2
- import { l as noTranslate, n as defineTranslationLoader, r as I18nRegistry, u as setFormats } from "./translation-manager-C79eKu2K.js";
1
+ import { t } from "./src-ON68XIog.js";
2
+ import { l as setFormats, s as noTranslate, t as I18nRegistry } from "./runtime-DXnGeCBw.js";
3
3
  import { n as isMessageSchemaValue, r as isMessageTagHandler, t as isMessageDescriptor } from "./types-BkDsJfVD.js";
4
+ import { n as defineTranslationLoader } from "./translation-manager-BkmFnlb_.js";
4
5
  export { I18nRegistry, defineTranslationLoader, isMessageDescriptor, isMessageSchemaValue, isMessageTagHandler, noTranslate, setFormats, t };
@@ -1,4 +1,5 @@
1
- import { c as getRuntime, s as getFormats } from "./translation-manager-C79eKu2K.js";
1
+ import { t as normalizeMessage } from "./message-D4jK2Lzc.js";
2
+ import { a as getFormats, o as getRuntime } from "./runtime-DXnGeCBw.js";
2
3
  import { n as isMessageSchemaValue, r as isMessageTagHandler, t as isMessageDescriptor } from "./types-BkDsJfVD.js";
3
4
  // src/shared/formatting.ts
4
5
  function createFormatting(engine, compiled = false, getCompiledId) {
@@ -41,7 +42,7 @@ function createFormatting(engine, compiled = false, getCompiledId) {
41
42
  const value = values[key];
42
43
  if (!(expected === String ? typeof value === "string" : expected === Number ? typeof value === "number" : expected === Boolean ? typeof value === "boolean" : expected === Date ? value instanceof Date && !Number.isNaN(value.getTime()) : true)) throw new Error("[i18n] Message parameter \"" + key + "\" must be a " + expected.name);
43
44
  }
44
- return engine(message, languageId, getFormats(runtime, languageId), values, isCompiled);
45
+ return engine(typeof message === "string" ? normalizeMessage(message) : message, languageId, getFormats(runtime, languageId), values, isCompiled);
45
46
  };
46
47
  const getText = (options, runtime = getRuntime()) => {
47
48
  const parts = getMessageParts(options, runtime);
@@ -183,4 +184,4 @@ const interpret = (message, locale, formats, values) => {
183
184
  };
184
185
  export { createFormatting as n, interpret as t };
185
186
 
186
- //# sourceMappingURL=interpreter-Dld8QyOI.js.map
187
+ //# sourceMappingURL=interpreter-BfzvLLrD.js.map