@intlayer/react-intl 9.5.3 → 9.5.4-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <p align="center">
2
2
  <a href="https://intlayer.org" rel="">
3
- <img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.png" width="60%" alt="Intlayer Logo" />
3
+ <img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.webp" width="60%" alt="Intlayer Logo" />
4
4
  </a>
5
5
  </p>
6
6
 
@@ -49,10 +49,10 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
49
49
 
50
50
  | Feature | Description |
51
51
  | --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
52
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.webp?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
53
53
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
54
54
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
55
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.jpg?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
55
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.webp?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
56
56
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
57
57
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
58
58
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
@@ -60,12 +60,12 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
60
60
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
61
61
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
62
62
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
63
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.png?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
64
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.png?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
65
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.png?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
63
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.webp?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
64
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.webp?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
65
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.webp?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
66
66
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
67
67
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
68
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.png?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
68
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.webp?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
69
69
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
70
70
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
71
71
 
@@ -262,7 +262,7 @@ Intlayer connects **developers**, **copywriters**, and **AI agents** in one work
262
262
  - Feature flags
263
263
  - Headless CMSs (e.g. Contentful, Strapi, Sanity)
264
264
 
265
- ![CMS Preview](https://github.com/aymericzip/intlayer/blob/main/docs/assets/CMS.png?raw=true)
265
+ ![CMS Preview](https://github.com/aymericzip/intlayer/blob/main/docs/assets/CMS.webp?raw=true)
266
266
 
267
267
  ## 🌐 Readme in other languages
268
268
 
@@ -1,12 +1,12 @@
1
1
  'use client';
2
2
 
3
+ import { InvalidConfigError, MessageFormatError, MissingDataError, MissingTranslationError, ReactIntlError, ReactIntlErrorCode, UnsupportedFormatterError } from "./errors.mjs";
3
4
  import { IntlContext, RawIntlProvider } from "./context.mjs";
4
5
  import { IntlProvider } from "./IntlProvider.mjs";
5
6
  import { useIntl } from "./useIntl.mjs";
6
7
  import { FormattedDate, FormattedDateParts, FormattedDateTimeRange, FormattedDisplayName, FormattedList, FormattedListParts, FormattedNumber, FormattedNumberParts, FormattedPlural, FormattedRelativeTime, FormattedTime, FormattedTimeParts } from "./FormattedComponents.mjs";
7
- import { InvalidConfigError, MessageFormatError, MissingDataError, MissingTranslationError, ReactIntlError, ReactIntlErrorCode, UnsupportedFormatterError } from "./errors.mjs";
8
- import { defineMessage, defineMessages } from "./defineMessages.mjs";
9
8
  import { createIntl, createIntlCache } from "./createIntl.mjs";
9
+ import { defineMessage, defineMessages } from "./defineMessages.mjs";
10
10
  import { FormattedMessage } from "./FormattedMessage.mjs";
11
11
  import { useDictionary } from "./useDictionary.mjs";
12
12
  import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/react-intl",
3
- "version": "9.5.3",
3
+ "version": "9.5.4-canary.0",
4
4
  "private": false,
5
5
  "description": "react-intl API adapter for intlayer — drop-in compatibility layer",
6
6
  "keywords": [
@@ -68,19 +68,20 @@
68
68
  "prepublish": "cp -f ../../README.md ./README.md",
69
69
  "publish": "bun publish || true",
70
70
  "publish:canary": "bun publish --access public --tag canary || true",
71
+ "publish:ci": "bun ../../scripts/publish-package.mjs",
71
72
  "publish:latest": "bun publish --access public --tag latest || true",
72
73
  "test": "bun --bun vitest run",
73
74
  "test:watch": "bun --bun vitest",
74
75
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
75
76
  },
76
77
  "dependencies": {
77
- "@intlayer/config": "9.5.3",
78
- "@intlayer/core": "9.5.3",
79
- "@intlayer/dictionaries-entry": "9.5.3",
80
- "@intlayer/engine": "9.5.3",
81
- "@intlayer/types": "9.5.3",
82
- "react-intlayer": "9.5.3",
83
- "vite-intlayer": "9.5.3"
78
+ "@intlayer/config": "9.5.4-canary.0",
79
+ "@intlayer/core": "9.5.4-canary.0",
80
+ "@intlayer/dictionaries-entry": "9.5.4-canary.0",
81
+ "@intlayer/engine": "9.5.4-canary.0",
82
+ "@intlayer/types": "9.5.4-canary.0",
83
+ "react-intlayer": "9.5.4-canary.0",
84
+ "vite-intlayer": "9.5.4-canary.0"
84
85
  },
85
86
  "devDependencies": {
86
87
  "@types/node": "^22",
@@ -88,12 +89,12 @@
88
89
  "@utils/ts-config": "1.0.4",
89
90
  "@utils/ts-config-types": "1.0.4",
90
91
  "@utils/tsdown-config": "1.0.4",
91
- "react-intl": "^10.1.18",
92
+ "react-intl": "^12.1.0",
92
93
  "rimraf": "6.1.3",
93
94
  "tsdown": "0.23.0",
94
95
  "typescript": "7.0.2",
95
96
  "vite": "8.3.0",
96
- "vitest": "5.0.0"
97
+ "vitest": "5.0.1"
97
98
  },
98
99
  "peerDependencies": {
99
100
  "react": ">=16.0.0",
@@ -1,131 +0,0 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_useIntl = require('./useIntl.cjs');
5
- let react_jsx_runtime = require("react/jsx-runtime");
6
-
7
- //#region src/FormattedComponents.tsx
8
- /**
9
- * Drop-in for react-intl's `<FormattedDate>`.
10
- * Renders a locale-aware date string using `Intl.DateTimeFormat`.
11
- */
12
- const FormattedDate = ({ value, children, format: _format, ...options }) => {
13
- const formatted = require_useIntl.useIntl().formatDate(value, options);
14
- if (typeof children === "function") return children(formatted) ?? null;
15
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: formatted });
16
- };
17
- /**
18
- * Drop-in for react-intl's `<FormattedTime>`.
19
- * Renders a locale-aware time string using `Intl.DateTimeFormat`.
20
- */
21
- const FormattedTime = ({ value, children, format: _format, ...options }) => {
22
- const formatted = require_useIntl.useIntl().formatTime(value, options);
23
- if (typeof children === "function") return children(formatted) ?? null;
24
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: formatted });
25
- };
26
- /**
27
- * Drop-in for react-intl's `<FormattedNumber>`.
28
- * Renders a locale-aware number string using `Intl.NumberFormat`.
29
- */
30
- const FormattedNumber = ({ value, children, format: _format, ...options }) => {
31
- const formatted = require_useIntl.useIntl().formatNumber(value, options);
32
- if (typeof children === "function") return children(formatted) ?? null;
33
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: formatted });
34
- };
35
- /**
36
- * Drop-in for react-intl's `<FormattedList>`.
37
- * Renders a locale-aware list string using `Intl.ListFormat`.
38
- */
39
- const FormattedList = ({ value, ...options }) => {
40
- const intl = require_useIntl.useIntl();
41
- const strings = value.filter((item) => typeof item === "string");
42
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: intl.formatList(strings, options) });
43
- };
44
- /**
45
- * Drop-in for react-intl's `<FormattedDisplayName>`.
46
- * Renders a locale-aware display name using `Intl.DisplayNames`.
47
- */
48
- const FormattedDisplayName = ({ value, ...options }) => {
49
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: require_useIntl.useIntl().formatDisplayName(value, options) ?? value });
50
- };
51
- /**
52
- * Drop-in for react-intl's `<FormattedRelativeTime>`.
53
- * Renders a locale-aware relative time string using `Intl.RelativeTimeFormat`.
54
- * Auto-update (`updateIntervalInSeconds`) is not implemented.
55
- */
56
- const FormattedRelativeTime = ({ value = 0, unit = "second", children, updateIntervalInSeconds: _updateIntervalInSeconds, ...options }) => {
57
- const formatted = require_useIntl.useIntl().formatRelativeTime(value, unit, options);
58
- if (typeof children === "function") return children(formatted) ?? null;
59
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: formatted });
60
- };
61
- /**
62
- * Drop-in for react-intl's `<FormattedPlural>`.
63
- * Selects the matching plural slot using `Intl.PluralRules`.
64
- */
65
- const FormattedPlural = ({ value, other, zero, one, two, few, many, children, ...options }) => {
66
- const rule = require_useIntl.useIntl().formatPlural(value, options);
67
- const selected = {
68
- zero,
69
- one,
70
- two,
71
- few,
72
- many,
73
- other
74
- }[rule] ?? other;
75
- if (typeof children === "function") return children(selected) ?? null;
76
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: selected });
77
- };
78
- /**
79
- * Drop-in for react-intl's `<FormattedDateTimeRange>`.
80
- * Renders a locale-aware date range string using `Intl.DateTimeFormat#formatRange`.
81
- */
82
- const FormattedDateTimeRange = ({ from, to, children, ...options }) => {
83
- const formatted = require_useIntl.useIntl().formatDateTimeRange(from, to, options);
84
- if (typeof children === "function") return children(formatted) ?? null;
85
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: formatted });
86
- };
87
- /**
88
- * Drop-in for react-intl's `<FormattedDateParts>`.
89
- * Renders format parts via a `children` render-prop.
90
- */
91
- const FormattedDateParts = ({ value, children, format: _format, ...options }) => {
92
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: children(require_useIntl.useIntl().formatDateToParts(value, options)) });
93
- };
94
- /**
95
- * Drop-in for react-intl's `<FormattedTimeParts>`.
96
- * Renders format parts via a `children` render-prop.
97
- */
98
- const FormattedTimeParts = ({ value, children, format: _format, ...options }) => {
99
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: children(require_useIntl.useIntl().formatTimeToParts(value, options)) });
100
- };
101
- /**
102
- * Drop-in for react-intl's `<FormattedNumberParts>`.
103
- * Renders format parts via a `children` render-prop.
104
- */
105
- const FormattedNumberParts = ({ value, children, format: _format, ...options }) => {
106
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: children(require_useIntl.useIntl().formatNumberToParts(value, options)) });
107
- };
108
- /**
109
- * Drop-in for react-intl's `<FormattedListParts>`.
110
- * Renders list format parts via a `children` render-prop.
111
- */
112
- const FormattedListParts = ({ value, children, ...options }) => {
113
- const intl = require_useIntl.useIntl();
114
- const strings = Array.from(value).filter((item) => typeof item === "string");
115
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: children(intl.formatListToParts(strings, options)) });
116
- };
117
-
118
- //#endregion
119
- exports.FormattedDate = FormattedDate;
120
- exports.FormattedDateParts = FormattedDateParts;
121
- exports.FormattedDateTimeRange = FormattedDateTimeRange;
122
- exports.FormattedDisplayName = FormattedDisplayName;
123
- exports.FormattedList = FormattedList;
124
- exports.FormattedListParts = FormattedListParts;
125
- exports.FormattedNumber = FormattedNumber;
126
- exports.FormattedNumberParts = FormattedNumberParts;
127
- exports.FormattedPlural = FormattedPlural;
128
- exports.FormattedRelativeTime = FormattedRelativeTime;
129
- exports.FormattedTime = FormattedTime;
130
- exports.FormattedTimeParts = FormattedTimeParts;
131
- //# sourceMappingURL=FormattedComponents.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormattedComponents.cjs","names":["useIntl"],"sources":["../../src/FormattedComponents.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactElement } from 'react';\nimport type {\n FormattedDate as _FormattedDate,\n FormattedDateParts as _FormattedDateParts,\n FormattedDateTimeRange as _FormattedDateTimeRange,\n FormattedDisplayName as _FormattedDisplayName,\n FormattedList as _FormattedList,\n FormattedListParts as _FormattedListParts,\n FormattedNumber as _FormattedNumber,\n FormattedNumberParts as _FormattedNumberParts,\n FormattedPlural as _FormattedPlural,\n FormattedRelativeTime as _FormattedRelativeTime,\n FormattedTime as _FormattedTime,\n FormattedTimeParts as _FormattedTimeParts,\n} from 'react-intl';\nimport { useIntl } from './useIntl';\n\nconst toDate = (value: Date | number | string | undefined): Date =>\n value instanceof Date\n ? value\n : typeof value === 'undefined'\n ? new Date()\n : new Date(value);\n\n/**\n * Drop-in for react-intl's `<FormattedDate>`.\n * Renders a locale-aware date string using `Intl.DateTimeFormat`.\n */\nexport const FormattedDate: typeof _FormattedDate = ({\n value,\n children,\n format: _format,\n ...options\n}) => {\n const intl = useIntl();\n const formatted = intl.formatDate(value, options);\n if (typeof children === 'function') {\n return (children(formatted) ?? null) as ReactElement | null;\n }\n return <>{formatted}</>;\n};\n\n/**\n * Drop-in for react-intl's `<FormattedTime>`.\n * Renders a locale-aware time string using `Intl.DateTimeFormat`.\n */\nexport const FormattedTime: typeof _FormattedTime = ({\n value,\n children,\n format: _format,\n ...options\n}) => {\n const intl = useIntl();\n const formatted = intl.formatTime(value, options);\n if (typeof children === 'function') {\n return (children(formatted) ?? null) as ReactElement | null;\n }\n return <>{formatted}</>;\n};\n\n/**\n * Drop-in for react-intl's `<FormattedNumber>`.\n * Renders a locale-aware number string using `Intl.NumberFormat`.\n */\nexport const FormattedNumber: typeof _FormattedNumber = ({\n value,\n children,\n format: _format,\n ...options\n}) => {\n const intl = useIntl();\n const formatted = intl.formatNumber(value, options);\n if (typeof children === 'function') {\n return (children(formatted) ?? null) as ReactElement | null;\n }\n return <>{formatted}</>;\n};\n\n/**\n * Drop-in for react-intl's `<FormattedList>`.\n * Renders a locale-aware list string using `Intl.ListFormat`.\n */\nexport const FormattedList: typeof _FormattedList = ({ value, ...options }) => {\n const intl = useIntl();\n const strings = (value as unknown[]).filter(\n (item): item is string => typeof item === 'string'\n );\n const formatted = intl.formatList(strings, options);\n return <>{formatted}</>;\n};\n\n/**\n * Drop-in for react-intl's `<FormattedDisplayName>`.\n * Renders a locale-aware display name using `Intl.DisplayNames`.\n */\nexport const FormattedDisplayName: typeof _FormattedDisplayName = ({\n value,\n ...options\n}) => {\n const intl = useIntl();\n const formatted = intl.formatDisplayName(\n value,\n options as Intl.DisplayNamesOptions\n );\n return <>{formatted ?? value}</>;\n};\n\n/**\n * Drop-in for react-intl's `<FormattedRelativeTime>`.\n * Renders a locale-aware relative time string using `Intl.RelativeTimeFormat`.\n * Auto-update (`updateIntervalInSeconds`) is not implemented.\n */\nexport const FormattedRelativeTime: typeof _FormattedRelativeTime = ({\n value = 0,\n unit = 'second',\n children,\n updateIntervalInSeconds: _updateIntervalInSeconds,\n ...options\n}) => {\n const intl = useIntl();\n const formatted = intl.formatRelativeTime(value, unit, options);\n if (typeof children === 'function') {\n return (children(formatted) ?? null) as ReactElement | null;\n }\n return <>{formatted}</>;\n};\n\n/**\n * Drop-in for react-intl's `<FormattedPlural>`.\n * Selects the matching plural slot using `Intl.PluralRules`.\n */\nexport const FormattedPlural: typeof _FormattedPlural = ({\n value,\n other,\n zero,\n one,\n two,\n few,\n many,\n children,\n ...options\n}) => {\n const intl = useIntl();\n const rule = intl.formatPlural(value, options);\n const slots: Record<Intl.LDMLPluralRule, unknown> = {\n zero,\n one,\n two,\n few,\n many,\n other,\n };\n const selected = slots[rule] ?? other;\n\n if (typeof children === 'function') {\n return (children(selected as import('react').ReactNode) ??\n null) as ReactElement | null;\n }\n\n return <>{selected}</>;\n};\n\n/**\n * Drop-in for react-intl's `<FormattedDateTimeRange>`.\n * Renders a locale-aware date range string using `Intl.DateTimeFormat#formatRange`.\n */\nexport const FormattedDateTimeRange: typeof _FormattedDateTimeRange = ({\n from,\n to,\n children,\n ...options\n}) => {\n const intl = useIntl();\n const formatted = intl.formatDateTimeRange(from, to, options);\n if (typeof children === 'function') {\n return (children(formatted) ?? null) as ReactElement | null;\n }\n return <>{formatted}</>;\n};\n\n/**\n * Drop-in for react-intl's `<FormattedDateParts>`.\n * Renders format parts via a `children` render-prop.\n */\nexport const FormattedDateParts: typeof _FormattedDateParts = ({\n value,\n children,\n format: _format,\n ...options\n}) => {\n const intl = useIntl();\n const parts = intl.formatDateToParts(\n value as Parameters<Intl.DateTimeFormat['format']>[0],\n options\n );\n return <>{children(parts)}</>;\n};\n\n/**\n * Drop-in for react-intl's `<FormattedTimeParts>`.\n * Renders format parts via a `children` render-prop.\n */\nexport const FormattedTimeParts: typeof _FormattedTimeParts = ({\n value,\n children,\n format: _format,\n ...options\n}) => {\n const intl = useIntl();\n const parts = intl.formatTimeToParts(\n value as Parameters<Intl.DateTimeFormat['format']>[0],\n options\n );\n return <>{children(parts)}</>;\n};\n\n/**\n * Drop-in for react-intl's `<FormattedNumberParts>`.\n * Renders format parts via a `children` render-prop.\n */\nexport const FormattedNumberParts: typeof _FormattedNumberParts = ({\n value,\n children,\n format: _format,\n ...options\n}) => {\n const intl = useIntl();\n const parts = intl.formatNumberToParts(value, options);\n return <>{children(parts)}</>;\n};\n\n/**\n * Drop-in for react-intl's `<FormattedListParts>`.\n * Renders list format parts via a `children` render-prop.\n */\nexport const FormattedListParts: typeof _FormattedListParts = ({\n value,\n children,\n ...options\n}) => {\n const intl = useIntl();\n const strings = Array.from(value).filter(\n (item): item is string => typeof item === 'string'\n );\n const parts = intl.formatListToParts(strings, options);\n return <>{children(parts)}</>;\n};\n"],"mappings":"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"}
@@ -1,45 +0,0 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_useIntl = require('./useIntl.cjs');
5
- let react = require("react");
6
- let react_jsx_runtime = require("react/jsx-runtime");
7
-
8
- //#region src/FormattedMessage.tsx
9
- /**
10
- * Drop-in for react-intl's `<FormattedMessage>`.
11
- *
12
- * Translates the message identified by `id` using the active intl context.
13
- * Full ICU MessageFormat syntax is supported.
14
- *
15
- * When `values` contains render functions, rich text tags
16
- * (`<b>chunks</b>`) are mapped through them. When a `tagName` is provided,
17
- * the output is wrapped in that element; otherwise a fragment is used.
18
- * A `children` render-prop receives the resolved nodes.
19
- *
20
- * @example
21
- * ```tsx
22
- * <FormattedMessage id="home.title" />
23
- * <FormattedMessage id="home.greeting" values={{ name: 'Alice' }} />
24
- * <FormattedMessage
25
- * id="terms.agreement"
26
- * values={{ b: (chunks) => <strong>{chunks}</strong> }}
27
- * />
28
- * ```
29
- */
30
- const FormattedMessage = ({ id = "", description: _description, defaultMessage, values, tagName: TagName, children, ignoreTag: _ignoreTag }) => {
31
- const intl = require_useIntl.useIntl();
32
- const stringDefaultMessage = typeof defaultMessage === "string" ? defaultMessage : void 0;
33
- const result = intl.formatMessage({
34
- id,
35
- defaultMessage: stringDefaultMessage
36
- }, values);
37
- const nodes = Array.isArray(result) ? result : [result];
38
- if (typeof children === "function") return children(nodes) ?? null;
39
- if (TagName && TagName !== react.Fragment) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TagName, { children: nodes });
40
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: nodes });
41
- };
42
-
43
- //#endregion
44
- exports.FormattedMessage = FormattedMessage;
45
- //# sourceMappingURL=FormattedMessage.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormattedMessage.cjs","names":["useIntl","Fragment"],"sources":["../../src/FormattedMessage.tsx"],"sourcesContent":["'use client';\n\nimport { Fragment, type ReactElement, type ReactNode } from 'react';\nimport type { FormattedMessage as _FormattedMessage } from 'react-intl';\nimport { useIntl } from './useIntl';\n\n/**\n * Drop-in for react-intl's `<FormattedMessage>`.\n *\n * Translates the message identified by `id` using the active intl context.\n * Full ICU MessageFormat syntax is supported.\n *\n * When `values` contains render functions, rich text tags\n * (`<b>chunks</b>`) are mapped through them. When a `tagName` is provided,\n * the output is wrapped in that element; otherwise a fragment is used.\n * A `children` render-prop receives the resolved nodes.\n *\n * @example\n * ```tsx\n * <FormattedMessage id=\"home.title\" />\n * <FormattedMessage id=\"home.greeting\" values={{ name: 'Alice' }} />\n * <FormattedMessage\n * id=\"terms.agreement\"\n * values={{ b: (chunks) => <strong>{chunks}</strong> }}\n * />\n * ```\n */\nexport const FormattedMessage: typeof _FormattedMessage = ({\n id = '',\n description: _description,\n defaultMessage,\n values,\n tagName: TagName,\n children,\n ignoreTag: _ignoreTag,\n}) => {\n const intl = useIntl();\n const stringDefaultMessage =\n typeof defaultMessage === 'string' ? defaultMessage : undefined;\n const result = (\n intl.formatMessage as (\n descriptor: { id: string; defaultMessage?: string },\n values?: Record<string, unknown>\n ) => string | ReactNode[]\n )(\n { id, defaultMessage: stringDefaultMessage },\n values as Record<string, unknown>\n );\n const nodes: ReactNode[] = Array.isArray(result) ? result : [result];\n\n if (typeof children === 'function') {\n return (children(nodes) ?? null) as ReactElement | null;\n }\n\n if (TagName && TagName !== Fragment) {\n return <TagName>{nodes}</TagName>;\n }\n\n return <>{nodes}</>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,oBAA8C,EACzD,KAAK,IACL,aAAa,cACb,gBACA,QACA,SAAS,SACT,UACA,WAAW,iBACP;CACJ,MAAM,OAAOA,wBAAQ;CACrB,MAAM,uBACJ,OAAO,mBAAmB,WAAW,iBAAiB;CACxD,MAAM,SACJ,KAAK,cAKL;EAAE;EAAI,gBAAgB;CAAqB,GAC3C,MACF;CACA,MAAM,QAAqB,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;CAEnE,IAAI,OAAO,aAAa,YACtB,OAAQ,SAAS,KAAK,KAAK;CAG7B,IAAI,WAAW,YAAYC,gBACzB,OAAO,2CAAC,SAAD,YAAU,MAAe;CAGlC,OAAO,mFAAG,MAAQ;AACpB"}
@@ -1,38 +0,0 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_context = require('./context.cjs');
5
- const require_createIntlObject = require('./createIntlObject.cjs');
6
- let _intlayer_config_built = require("@intlayer/config/built");
7
- let _intlayer_config_colors = require("@intlayer/config/colors");
8
- let _intlayer_config_logger = require("@intlayer/config/logger");
9
- let react = require("react");
10
- let react_intlayer = require("react-intlayer");
11
- let react_jsx_runtime = require("react/jsx-runtime");
12
-
13
- //#region src/IntlProvider.tsx
14
- /**
15
- * Drop-in for react-intl's `IntlProvider`.
16
- *
17
- * `messages`, `formats`, `timeZone`, `now`, `defaultRichTextElements`,
18
- * and `onError`/`onWarn` are accepted for API compatibility but have no
19
- * effect — Intlayer uses its own compiled dictionaries.
20
- *
21
- * The `locale` prop is forwarded to `IntlayerClientProvider`.
22
- */
23
- const IntlProvider = ({ locale, children, messages: _messages, formats: _formats, timeZone: _timeZone, defaultRichTextElements: _defaultRichTextElements, onError: _onError, ...rest }) => {
24
- const intlObject = (0, react.useMemo)(() => require_createIntlObject.createIntlObject(locale), [locale]);
25
- if (process.env.NODE_ENV === "development" && typeof _messages !== "undefined") (0, _intlayer_config_logger.getAppLogger)({ log: _intlayer_config_built.log })(`${(0, _intlayer_config_logger.colorize)("IntlProvider", _intlayer_config_colors.CYAN)} do not pass the messages prop with intlayer. Messages are loaded automatically under the hood for bundle optimization reasons.`);
26
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_context.IntlContext.Provider, {
27
- value: intlObject,
28
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_intlayer.IntlayerProvider, {
29
- locale,
30
- ...rest,
31
- children
32
- })
33
- });
34
- };
35
-
36
- //#endregion
37
- exports.IntlProvider = IntlProvider;
38
- //# sourceMappingURL=IntlProvider.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlProvider.cjs","names":["createIntlObject","CYAN","IntlContext","IntlayerProvider"],"sources":["../../src/IntlProvider.tsx"],"sourcesContent":["'use client';\n\nimport { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useMemo } from 'react';\nimport type { IntlProvider as _IntlProvider } from 'react-intl';\nimport { IntlayerProvider } from 'react-intlayer';\nimport { IntlContext } from './context';\nimport { createIntlObject } from './createIntlObject';\n\n/**\n * Drop-in for react-intl's `IntlProvider`.\n *\n * `messages`, `formats`, `timeZone`, `now`, `defaultRichTextElements`,\n * and `onError`/`onWarn` are accepted for API compatibility but have no\n * effect — Intlayer uses its own compiled dictionaries.\n *\n * The `locale` prop is forwarded to `IntlayerClientProvider`.\n */\nexport const IntlProvider: typeof _IntlProvider = ({\n locale,\n children,\n messages: _messages,\n formats: _formats,\n timeZone: _timeZone,\n defaultRichTextElements: _defaultRichTextElements,\n onError: _onError,\n ...rest\n}) => {\n const intlObject = useMemo(\n () => createIntlObject(locale as LocalesValues),\n [locale]\n );\n\n if (\n process.env.NODE_ENV === 'development' &&\n typeof _messages !== 'undefined'\n ) {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('IntlProvider', CYAN)} do not pass the messages prop with intlayer. Messages are loaded automatically under the hood for bundle optimization reasons.`\n );\n }\n\n return (\n <IntlContext.Provider value={intlObject}>\n <IntlayerProvider locale={locale as LocalesValues} {...(rest as object)}>\n {children}\n </IntlayerProvider>\n </IntlContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,gBAAsC,EACjD,QACA,UACA,UAAU,WACV,SAAS,UACT,UAAU,WACV,yBAAyB,0BACzB,SAAS,UACT,GAAG,WACC;CACJ,MAAM,sCACEA,0CAAiB,MAAuB,GAC9C,CAAC,MAAM,CACT;CAEA,IACE,QAAQ,IAAI,aAAa,iBACzB,OAAO,cAAc,aAGrB,0CAD+B,EAAE,gCAAI,CAC7B,CAAC,CACP,yCAAY,gBAAgBC,4BAAI,EAAE,gIACpC;CAGF,OACE,2CAACC,4BAAY,UAAb;EAAsB,OAAO;YAC3B,2CAACC,iCAAD;GAA0B;GAAyB,GAAK;GACrD;EACe;CACE;AAE1B"}
@@ -1,29 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
- value: mod,
24
- enumerable: true
25
- }) : target, mod));
26
-
27
- //#endregion
28
-
29
- exports.__toESM = __toESM;
@@ -1,16 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- let react = require("react");
3
-
4
- //#region src/context.tsx
5
- /**
6
- * React context holding the active intlayer-backed `IntlShape` instance.
7
- * Populated by {@link IntlProvider}; consumed by {@link useIntl}.
8
- */
9
- const IntlContext = (0, react.createContext)(null);
10
- /** The raw `React.Provider<IntlShape>` — same as `IntlContext.Provider`. */
11
- const RawIntlProvider = IntlContext.Provider;
12
-
13
- //#endregion
14
- exports.IntlContext = IntlContext;
15
- exports.RawIntlProvider = RawIntlProvider;
16
- //# sourceMappingURL=context.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.cjs","names":[],"sources":["../../src/context.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport type { IntlShape } from 'react-intl';\n\n/**\n * React context holding the active intlayer-backed `IntlShape` instance.\n * Populated by {@link IntlProvider}; consumed by {@link useIntl}.\n */\nexport const IntlContext = createContext<IntlShape>(\n null as unknown as IntlShape\n);\n\n/** The raw `React.Provider<IntlShape>` — same as `IntlContext.Provider`. */\nexport const RawIntlProvider = IntlContext.Provider;\n"],"mappings":";;;;;;;;AAOA,MAAa,uCACX,IACF;;AAGA,MAAa,kBAAkB,YAAY"}
@@ -1,46 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_createIntlObject = require('./createIntlObject.cjs');
3
-
4
- //#region src/createIntl.ts
5
- /**
6
- * Drop-in for react-intl's `createIntlCache`.
7
- *
8
- * Returns an empty cache token. In the intlayer compat adapter, formatter
9
- * instances are not pooled (all backed by native `Intl.*` constructors), so
10
- * the cache object serves only as an API-compatibility token.
11
- *
12
- * @deprecated
13
- * Has no practical effect with intlayer — no formatter pooling is needed.
14
- */
15
- const createIntlCache = () => ({
16
- dateTime: {},
17
- number: {},
18
- message: {},
19
- relativeTime: {},
20
- pluralRules: {},
21
- list: {},
22
- displayNames: {}
23
- });
24
- /**
25
- * Drop-in for react-intl's `createIntl`.
26
- *
27
- * Creates an `IntlShape` instance backed by intlayer compiled dictionaries
28
- * for the given `locale`. Use this in non-React contexts (e.g. server-side
29
- * route handlers).
30
- *
31
- * `messages`, `formats`, `timeZone`, `onError`, and `cache` are accepted for
32
- * API compatibility but have no effect — Intlayer uses its own compiled
33
- * dictionaries.
34
- *
35
- * @example
36
- * ```ts
37
- * const intl = createIntl({ locale: 'en' });
38
- * intl.formatMessage({ id: 'home.title' });
39
- * ```
40
- */
41
- const createIntl = ({ locale }, _cache) => require_createIntlObject.createIntlObject(locale);
42
-
43
- //#endregion
44
- exports.createIntl = createIntl;
45
- exports.createIntlCache = createIntlCache;
46
- //# sourceMappingURL=createIntl.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createIntl.cjs","names":["createIntlObject"],"sources":["../../src/createIntl.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type {\n createIntl as _createIntl,\n createIntlCache as _createIntlCache,\n IntlCache,\n IntlConfig,\n IntlShape,\n} from 'react-intl';\nimport { createIntlObject } from './createIntlObject';\n\n/**\n * Drop-in for react-intl's `createIntlCache`.\n *\n * Returns an empty cache token. In the intlayer compat adapter, formatter\n * instances are not pooled (all backed by native `Intl.*` constructors), so\n * the cache object serves only as an API-compatibility token.\n *\n * @deprecated\n * Has no practical effect with intlayer — no formatter pooling is needed.\n */\nexport const createIntlCache: typeof _createIntlCache = (): IntlCache =>\n ({\n dateTime: {},\n number: {},\n message: {},\n relativeTime: {},\n pluralRules: {},\n list: {},\n displayNames: {},\n }) as IntlCache;\n\n/**\n * Drop-in for react-intl's `createIntl`.\n *\n * Creates an `IntlShape` instance backed by intlayer compiled dictionaries\n * for the given `locale`. Use this in non-React contexts (e.g. server-side\n * route handlers).\n *\n * `messages`, `formats`, `timeZone`, `onError`, and `cache` are accepted for\n * API compatibility but have no effect — Intlayer uses its own compiled\n * dictionaries.\n *\n * @example\n * ```ts\n * const intl = createIntl({ locale: 'en' });\n * intl.formatMessage({ id: 'home.title' });\n * ```\n */\nexport const createIntl: typeof _createIntl = (\n { locale }: IntlConfig,\n _cache?: IntlCache\n): IntlShape => createIntlObject(locale as LocalesValues);\n"],"mappings":";;;;;;;;;;;;;;AAoBA,MAAa,yBACV;CACC,UAAU,CAAC;CACX,QAAQ,CAAC;CACT,SAAS,CAAC;CACV,cAAc,CAAC;CACf,aAAa,CAAC;CACd,MAAM,CAAC;CACP,cAAc,CAAC;AACjB;;;;;;;;;;;;;;;;;;AAmBF,MAAa,cACX,EAAE,UACF,WACcA,0CAAiB,MAAuB"}
@@ -1,132 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- let react = require("react");
3
- let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
4
- let _intlayer_core_messageFormat = require("@intlayer/core/messageFormat");
5
- let react_jsx_runtime = require("react/jsx-runtime");
6
-
7
- //#region src/createIntlObject.tsx
8
- /** Splits a full dotted id into the dictionary key and remaining path. */
9
- const splitId = (id) => {
10
- const dotIndex = id.indexOf(".");
11
- if (dotIndex === -1) return {
12
- dictionaryKey: id,
13
- path: ""
14
- };
15
- return {
16
- dictionaryKey: id.slice(0, dotIndex),
17
- path: id.slice(dotIndex + 1)
18
- };
19
- };
20
- const navigatePath = (object, path) => {
21
- if (!path) return object;
22
- const parts = path.split(".");
23
- let current = object;
24
- for (const part of parts) {
25
- if (current === null || current === void 0 || typeof current !== "object") return;
26
- current = current[part];
27
- }
28
- return current;
29
- };
30
- /** Looks up a message value by full dotted id; first segment = dictionary key. */
31
- const lookupMessage = (id, locale) => {
32
- const { dictionaryKey, path } = splitId(id);
33
- if (!dictionaryKey) return void 0;
34
- try {
35
- return navigatePath((0, _intlayer_core_interpreter.getIntlayer)(dictionaryKey, locale), path);
36
- } catch {
37
- return;
38
- }
39
- };
40
- /** Maps tagged tokens to React nodes using the provided renderer functions. */
41
- const renderRichTokens = (tokens, renderers) => tokens.map((token, tokenIndex) => {
42
- if (typeof token === "string") return token;
43
- const children = renderRichTokens(token.children, renderers);
44
- const renderer = renderers[token.tag];
45
- if (typeof renderer === "function") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: renderer(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children })) }, tokenIndex);
46
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children }, tokenIndex);
47
- });
48
- /** Partitions values into scalar interpolation params and tag renderers. */
49
- const splitRichValues = (values) => {
50
- const scalarValues = {};
51
- const renderers = {};
52
- for (const [key, value] of Object.entries(values)) if (typeof value === "function") renderers[key] = value;
53
- else scalarValues[key] = value;
54
- return {
55
- scalarValues,
56
- renderers
57
- };
58
- };
59
- const isRichValues = (values) => Object.values(values).some((value) => typeof value === "function");
60
- /**
61
- * Builds an intlayer-backed `IntlShape` object for the given locale.
62
- *
63
- * - Translation ids use the first dot-path segment as the dictionary key.
64
- * - Full ICU MessageFormat syntax is supported via `@intlayer/core/messageFormat`.
65
- * - Rich text tags (`<b>chunks</b>`) are resolved through render functions in `values`.
66
- */
67
- const createIntlObject = (locale) => {
68
- const localeString = locale;
69
- const formatMessage = (descriptor, values) => {
70
- const { id = "", defaultMessage } = descriptor;
71
- const rawValue = lookupMessage(id, locale);
72
- const messageTemplate = rawValue !== void 0 && rawValue !== null ? rawValue : typeof defaultMessage === "string" ? defaultMessage : id;
73
- if (!values || !isRichValues(values)) return (0, _intlayer_core_messageFormat.resolveMessage)(messageTemplate, values ?? {}, locale, "icu") ?? id;
74
- const { scalarValues, renderers } = splitRichValues(values);
75
- return renderRichTokens((0, _intlayer_core_messageFormat.parseTaggedMessage)((0, _intlayer_core_messageFormat.resolveMessage)(messageTemplate, scalarValues, locale, "icu") ?? id), renderers);
76
- };
77
- const toDate = (value) => value instanceof Date ? value : new Date(value);
78
- const formatDate = (value, options) => {
79
- if (value === void 0 || value === null) return "";
80
- return new Intl.DateTimeFormat(localeString, options).format(toDate(value));
81
- };
82
- const formatNumber = (value, options) => new Intl.NumberFormat(localeString, options).format(value);
83
- const formatPlural = (value, options) => new Intl.PluralRules(localeString, options).select(value);
84
- const formatList = (list, options) => {
85
- const strings = Array.from(list).filter((item) => typeof item === "string");
86
- return new Intl.ListFormat(localeString, options).format(strings);
87
- };
88
- const formatListToParts = (list, options) => {
89
- const strings = Array.from(list).filter((item) => typeof item === "string");
90
- return new Intl.ListFormat(localeString, options).formatToParts(strings);
91
- };
92
- const formatDisplayName = (value, options) => new Intl.DisplayNames([localeString], options ?? { type: "language" }).of(value);
93
- const formatRelativeTime = (value, unit, options) => new Intl.RelativeTimeFormat(localeString, {
94
- numeric: "auto",
95
- ...options
96
- }).format(value, unit ?? "second");
97
- const formatDateTimeRange = (from, to, options) => new Intl.DateTimeFormat(localeString, options).formatRange(toDate(from), toDate(to));
98
- const formatDateToParts = (value, options) => new Intl.DateTimeFormat(localeString, options).formatToParts(typeof value === "string" ? new Date(value) : value);
99
- const formatNumberToParts = (value, options) => new Intl.NumberFormat(localeString, options).formatToParts(value);
100
- return {
101
- locale: localeString,
102
- defaultLocale: localeString,
103
- messages: {},
104
- formats: {},
105
- defaultFormats: {},
106
- timeZone: void 0,
107
- textComponent: react.Fragment,
108
- wrapRichTextChunksInFragment: false,
109
- fallbackOnEmptyString: true,
110
- onError: () => {},
111
- onWarn: () => {},
112
- formatters: {},
113
- formatMessage,
114
- $t: formatMessage,
115
- formatDate,
116
- formatTime: formatDate,
117
- formatNumber,
118
- formatPlural,
119
- formatList,
120
- formatListToParts,
121
- formatDisplayName,
122
- formatRelativeTime,
123
- formatDateTimeRange,
124
- formatDateToParts,
125
- formatTimeToParts: formatDateToParts,
126
- formatNumberToParts
127
- };
128
- };
129
-
130
- //#endregion
131
- exports.createIntlObject = createIntlObject;
132
- //# sourceMappingURL=createIntlObject.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createIntlObject.cjs","names":["Fragment"],"sources":["../../src/createIntlObject.tsx"],"sourcesContent":["import { getIntlayer } from '@intlayer/core/interpreter';\nimport {\n type MessageValues,\n parseTaggedMessage,\n resolveMessage,\n type TaggedMessageToken,\n} from '@intlayer/core/messageFormat';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { Fragment, type ReactNode } from 'react';\nimport type { IntlShape, MessageDescriptor } from 'react-intl';\n\ntype RichRenderer = (chunks: ReactNode) => ReactNode;\n\n/** Splits a full dotted id into the dictionary key and remaining path. */\nconst splitId = (id: string): { dictionaryKey: string; path: string } => {\n const dotIndex = id.indexOf('.');\n if (dotIndex === -1) return { dictionaryKey: id, path: '' };\n return {\n dictionaryKey: id.slice(0, dotIndex),\n path: id.slice(dotIndex + 1),\n };\n};\n\nconst navigatePath = (object: unknown, path: string): unknown => {\n if (!path) return object;\n const parts = path.split('.');\n let current: unknown = object;\n for (const part of parts) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== 'object'\n ) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n};\n\n/** Looks up a message value by full dotted id; first segment = dictionary key. */\nconst lookupMessage = (id: string, locale: LocalesValues): unknown => {\n const { dictionaryKey, path } = splitId(id);\n if (!dictionaryKey) return undefined;\n try {\n const dictionary = getIntlayer(dictionaryKey as DictionaryKeys, locale);\n return navigatePath(dictionary, path);\n } catch {\n return undefined;\n }\n};\n\n/** Maps tagged tokens to React nodes using the provided renderer functions. */\nconst renderRichTokens = (\n tokens: TaggedMessageToken[],\n renderers: Record<string, unknown>\n): ReactNode[] =>\n tokens.map((token, tokenIndex) => {\n if (typeof token === 'string') return token;\n const children = renderRichTokens(token.children, renderers);\n const renderer = renderers[token.tag];\n if (typeof renderer === 'function') {\n return (\n <Fragment key={tokenIndex}>\n {(renderer as RichRenderer)(<>{children}</>)}\n </Fragment>\n );\n }\n return <Fragment key={tokenIndex}>{children}</Fragment>;\n });\n\n/** Partitions values into scalar interpolation params and tag renderers. */\nconst splitRichValues = (\n values: Record<string, unknown>\n): { scalarValues: MessageValues; renderers: Record<string, unknown> } => {\n const scalarValues: MessageValues = {};\n const renderers: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(values)) {\n if (typeof value === 'function') renderers[key] = value;\n else scalarValues[key] = value as MessageValues[string];\n }\n return { scalarValues, renderers };\n};\n\nconst isRichValues = (values: Record<string, unknown>): boolean =>\n Object.values(values).some((value) => typeof value === 'function');\n\n/**\n * Builds an intlayer-backed `IntlShape` object for the given locale.\n *\n * - Translation ids use the first dot-path segment as the dictionary key.\n * - Full ICU MessageFormat syntax is supported via `@intlayer/core/messageFormat`.\n * - Rich text tags (`<b>chunks</b>`) are resolved through render functions in `values`.\n */\nexport const createIntlObject = (locale: LocalesValues): IntlShape => {\n const localeString = locale as string;\n\n const formatMessage = (\n descriptor: MessageDescriptor,\n values?: Record<string, unknown>\n ): string | ReactNode[] => {\n const { id = '', defaultMessage } = descriptor;\n const rawValue = lookupMessage(id, locale);\n const messageTemplate =\n rawValue !== undefined && rawValue !== null\n ? (rawValue as string)\n : typeof defaultMessage === 'string'\n ? defaultMessage\n : id;\n\n if (!values || !isRichValues(values)) {\n return (\n resolveMessage(\n messageTemplate,\n (values ?? {}) as MessageValues,\n locale,\n 'icu'\n ) ?? id\n );\n }\n\n const { scalarValues, renderers } = splitRichValues(values);\n const message =\n resolveMessage(messageTemplate, scalarValues, locale, 'icu') ?? id;\n return renderRichTokens(parseTaggedMessage(message), renderers);\n };\n\n const toDate = (value: Date | number | string): Date =>\n value instanceof Date ? value : new Date(value);\n\n const formatDate = (\n value: string | number | Date | undefined,\n options?: Intl.DateTimeFormatOptions\n ): string => {\n if (value === undefined || value === null) return '';\n return new Intl.DateTimeFormat(localeString, options).format(toDate(value));\n };\n\n const formatNumber = (\n value: number | bigint,\n options?: Intl.NumberFormatOptions\n ): string => new Intl.NumberFormat(localeString, options).format(value);\n\n const formatPlural = (\n value: number,\n options?: Intl.PluralRulesOptions\n ): Intl.LDMLPluralRule =>\n new Intl.PluralRules(localeString, options).select(value);\n\n const formatList = (\n list: Iterable<unknown> | readonly unknown[],\n options?: Intl.ListFormatOptions\n ): string => {\n const strings = Array.from(list).filter(\n (item): item is string => typeof item === 'string'\n );\n return new Intl.ListFormat(localeString, options).format(strings);\n };\n\n const formatListToParts = (\n list: Iterable<unknown> | readonly unknown[],\n options?: Intl.ListFormatOptions\n ): ReturnType<Intl.ListFormat['formatToParts']> => {\n const strings = Array.from(list).filter(\n (item): item is string => typeof item === 'string'\n );\n return new Intl.ListFormat(localeString, options).formatToParts(strings);\n };\n\n const formatDisplayName = (\n value: string,\n options?: Intl.DisplayNamesOptions\n ): string | undefined =>\n new Intl.DisplayNames([localeString], options ?? { type: 'language' }).of(\n value\n );\n\n const formatRelativeTime = (\n value: number,\n unit?: Intl.RelativeTimeFormatUnit,\n options?: Intl.RelativeTimeFormatOptions\n ): string =>\n new Intl.RelativeTimeFormat(localeString, {\n numeric: 'auto',\n ...options,\n }).format(value, unit ?? 'second');\n\n const formatDateTimeRange = (\n from: Date | number,\n to: Date | number,\n options?: Intl.DateTimeFormatOptions\n ): string =>\n new Intl.DateTimeFormat(localeString, options).formatRange(\n toDate(from),\n toDate(to)\n );\n\n const formatDateToParts = (\n value: Parameters<Intl.DateTimeFormat['format']>[0] | string,\n options?: Intl.DateTimeFormatOptions\n ): Intl.DateTimeFormatPart[] =>\n new Intl.DateTimeFormat(localeString, options).formatToParts(\n typeof value === 'string' ? new Date(value) : value\n );\n\n const formatNumberToParts = (\n value: number | bigint,\n options?: Intl.NumberFormatOptions\n ): Intl.NumberFormatPart[] =>\n new Intl.NumberFormat(localeString, options).formatToParts(value);\n\n /** Alias of `formatMessage` — provided for `@formatjs/intl` v4 compatibility. */\n const $t = formatMessage as IntlShape['$t'];\n\n return {\n locale: localeString,\n defaultLocale: localeString,\n messages: {},\n formats: {},\n defaultFormats: {},\n timeZone: undefined,\n textComponent: Fragment,\n wrapRichTextChunksInFragment: false,\n fallbackOnEmptyString: true,\n onError: () => {},\n onWarn: () => {},\n formatters: {} as IntlShape['formatters'],\n formatMessage: formatMessage as IntlShape['formatMessage'],\n $t,\n formatDate,\n formatTime: formatDate,\n formatNumber,\n formatPlural,\n formatList: formatList as IntlShape['formatList'],\n formatListToParts: formatListToParts as IntlShape['formatListToParts'],\n formatDisplayName: formatDisplayName as IntlShape['formatDisplayName'],\n formatRelativeTime,\n formatDateTimeRange,\n formatDateToParts: formatDateToParts as IntlShape['formatDateToParts'],\n formatTimeToParts: formatDateToParts as IntlShape['formatTimeToParts'],\n formatNumberToParts:\n formatNumberToParts as IntlShape['formatNumberToParts'],\n } as unknown as IntlShape;\n};\n"],"mappings":"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"}
@@ -1,20 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- //#region src/defineMessages.ts
4
- /**
5
- * Drop-in for react-intl's `defineMessages`.
6
- * Identity function — returns the map unchanged.
7
- * Exists so that IDEs and the intlayer analyzer can locate message ids
8
- * at source-analysis time.
9
- */
10
- const defineMessages = (messages) => messages;
11
- /**
12
- * Drop-in for react-intl's `defineMessage`.
13
- * Identity function — returns the descriptor unchanged.
14
- */
15
- const defineMessage = (message) => message;
16
-
17
- //#endregion
18
- exports.defineMessage = defineMessage;
19
- exports.defineMessages = defineMessages;
20
- //# sourceMappingURL=defineMessages.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defineMessages.cjs","names":[],"sources":["../../src/defineMessages.ts"],"sourcesContent":["import type {\n defineMessage as _defineMessage,\n defineMessages as _defineMessages,\n} from 'react-intl';\n\n/**\n * Drop-in for react-intl's `defineMessages`.\n * Identity function — returns the map unchanged.\n * Exists so that IDEs and the intlayer analyzer can locate message ids\n * at source-analysis time.\n */\nexport const defineMessages: typeof _defineMessages = (messages) => messages;\n\n/**\n * Drop-in for react-intl's `defineMessage`.\n * Identity function — returns the descriptor unchanged.\n */\nexport const defineMessage: typeof _defineMessage = (message) => message;\n"],"mappings":";;;;;;;;;AAWA,MAAa,kBAA0C,aAAa;;;;;AAMpE,MAAa,iBAAwC,YAAY"}
@@ -1,85 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- //#region src/errors.ts
4
- /**
5
- * Error code enum matching react-intl's `ReactIntlErrorCode`.
6
- *
7
- * @deprecated These error codes are not raised by the intlayer compat adapter.
8
- * Exported for API compatibility only.
9
- */
10
- let ReactIntlErrorCode = /* @__PURE__ */ function(ReactIntlErrorCode) {
11
- ReactIntlErrorCode["FORMAT_ERROR"] = "FORMAT_ERROR";
12
- ReactIntlErrorCode["UNSUPPORTED_FORMATTER"] = "UNSUPPORTED_FORMATTER";
13
- ReactIntlErrorCode["INVALID_CONFIG"] = "INVALID_CONFIG";
14
- ReactIntlErrorCode["MISSING_DATA"] = "MISSING_DATA";
15
- ReactIntlErrorCode["MISSING_TRANSLATION"] = "MISSING_TRANSLATION";
16
- return ReactIntlErrorCode;
17
- }({});
18
- /**
19
- * Base error class matching react-intl's `ReactIntlError` shape.
20
- *
21
- * @deprecated Not raised by the intlayer compat adapter. Exported for API compatibility only.
22
- */
23
- var ReactIntlError = class extends Error {
24
- code;
25
- constructor(code, message) {
26
- super(message);
27
- this.name = "ReactIntlError";
28
- this.code = code;
29
- }
30
- };
31
- /**
32
- * @deprecated Not raised by the intlayer compat adapter. Exported for API compatibility only.
33
- */
34
- var InvalidConfigError = class extends ReactIntlError {
35
- constructor(message) {
36
- super("INVALID_CONFIG", message);
37
- this.name = "InvalidConfigError";
38
- }
39
- };
40
- /**
41
- * @deprecated Not raised by the intlayer compat adapter. Exported for API compatibility only.
42
- */
43
- var MessageFormatError = class extends ReactIntlError {
44
- constructor(message) {
45
- super("FORMAT_ERROR", message);
46
- this.name = "MessageFormatError";
47
- }
48
- };
49
- /**
50
- * @deprecated Not raised by the intlayer compat adapter. Exported for API compatibility only.
51
- */
52
- var MissingDataError = class extends ReactIntlError {
53
- constructor(message) {
54
- super("MISSING_DATA", message);
55
- this.name = "MissingDataError";
56
- }
57
- };
58
- /**
59
- * @deprecated Not raised by the intlayer compat adapter. Exported for API compatibility only.
60
- */
61
- var MissingTranslationError = class extends ReactIntlError {
62
- constructor(message) {
63
- super("MISSING_TRANSLATION", message);
64
- this.name = "MissingTranslationError";
65
- }
66
- };
67
- /**
68
- * @deprecated Not raised by the intlayer compat adapter. Exported for API compatibility only.
69
- */
70
- var UnsupportedFormatterError = class extends ReactIntlError {
71
- constructor(message) {
72
- super("UNSUPPORTED_FORMATTER", message);
73
- this.name = "UnsupportedFormatterError";
74
- }
75
- };
76
-
77
- //#endregion
78
- exports.InvalidConfigError = InvalidConfigError;
79
- exports.MessageFormatError = MessageFormatError;
80
- exports.MissingDataError = MissingDataError;
81
- exports.MissingTranslationError = MissingTranslationError;
82
- exports.ReactIntlError = ReactIntlError;
83
- exports.ReactIntlErrorCode = ReactIntlErrorCode;
84
- exports.UnsupportedFormatterError = UnsupportedFormatterError;
85
- //# sourceMappingURL=errors.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.cjs","names":[],"sources":["../../src/errors.ts"],"sourcesContent":["/**\n * Error code enum matching react-intl's `ReactIntlErrorCode`.\n *\n * @deprecated These error codes are not raised by the intlayer compat adapter.\n * Exported for API compatibility only.\n */\nexport enum ReactIntlErrorCode {\n FORMAT_ERROR = 'FORMAT_ERROR',\n UNSUPPORTED_FORMATTER = 'UNSUPPORTED_FORMATTER',\n INVALID_CONFIG = 'INVALID_CONFIG',\n MISSING_DATA = 'MISSING_DATA',\n MISSING_TRANSLATION = 'MISSING_TRANSLATION',\n}\n\n/**\n * Base error class matching react-intl's `ReactIntlError` shape.\n *\n * @deprecated Not raised by the intlayer compat adapter. Exported for API compatibility only.\n */\nexport class ReactIntlError extends Error {\n public readonly code: ReactIntlErrorCode;\n\n constructor(code: ReactIntlErrorCode, message: string) {\n super(message);\n this.name = 'ReactIntlError';\n this.code = code;\n }\n}\n\n/**\n * @deprecated Not raised by the intlayer compat adapter. Exported for API compatibility only.\n */\nexport class InvalidConfigError extends ReactIntlError {\n constructor(message: string) {\n super(ReactIntlErrorCode.INVALID_CONFIG, message);\n this.name = 'InvalidConfigError';\n }\n}\n\n/**\n * @deprecated Not raised by the intlayer compat adapter. Exported for API compatibility only.\n */\nexport class MessageFormatError extends ReactIntlError {\n constructor(message: string) {\n super(ReactIntlErrorCode.FORMAT_ERROR, message);\n this.name = 'MessageFormatError';\n }\n}\n\n/**\n * @deprecated Not raised by the intlayer compat adapter. Exported for API compatibility only.\n */\nexport class MissingDataError extends ReactIntlError {\n constructor(message: string) {\n super(ReactIntlErrorCode.MISSING_DATA, message);\n this.name = 'MissingDataError';\n }\n}\n\n/**\n * @deprecated Not raised by the intlayer compat adapter. Exported for API compatibility only.\n */\nexport class MissingTranslationError extends ReactIntlError {\n constructor(message: string) {\n super(ReactIntlErrorCode.MISSING_TRANSLATION, message);\n this.name = 'MissingTranslationError';\n }\n}\n\n/**\n * @deprecated Not raised by the intlayer compat adapter. Exported for API compatibility only.\n */\nexport class UnsupportedFormatterError extends ReactIntlError {\n constructor(message: string) {\n super(ReactIntlErrorCode.UNSUPPORTED_FORMATTER, message);\n this.name = 'UnsupportedFormatterError';\n }\n}\n"],"mappings":";;;;;;;;;AAMA,IAAY,qBAAL;CACL;CACA;CACA;CACA;CACA;;AACF;;;;;;AAOA,IAAa,iBAAb,cAAoC,MAAM;CACxC,AAAgB;CAEhB,YAAY,MAA0B,SAAiB;EACrD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF;;;;AAKA,IAAa,qBAAb,cAAwC,eAAe;CACrD,YAAY,SAAiB;EAC3B,wBAAyC,OAAO;EAChD,KAAK,OAAO;CACd;AACF;;;;AAKA,IAAa,qBAAb,cAAwC,eAAe;CACrD,YAAY,SAAiB;EAC3B,sBAAuC,OAAO;EAC9C,KAAK,OAAO;CACd;AACF;;;;AAKA,IAAa,mBAAb,cAAsC,eAAe;CACnD,YAAY,SAAiB;EAC3B,sBAAuC,OAAO;EAC9C,KAAK,OAAO;CACd;AACF;;;;AAKA,IAAa,0BAAb,cAA6C,eAAe;CAC1D,YAAY,SAAiB;EAC3B,6BAA8C,OAAO;EACrD,KAAK,OAAO;CACd;AACF;;;;AAKA,IAAa,4BAAb,cAA+C,eAAe;CAC5D,YAAY,SAAiB;EAC3B,+BAAgD,OAAO;EACvD,KAAK,OAAO;CACd;AACF"}
@@ -1,40 +0,0 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_context = require('./context.cjs');
5
- const require_IntlProvider = require('./IntlProvider.cjs');
6
- const require_useIntl = require('./useIntl.cjs');
7
- const require_FormattedComponents = require('./FormattedComponents.cjs');
8
- const require_errors = require('./errors.cjs');
9
- const require_defineMessages = require('./defineMessages.cjs');
10
- const require_createIntl = require('./createIntl.cjs');
11
- const require_FormattedMessage = require('./FormattedMessage.cjs');
12
-
13
- exports.FormattedDate = require_FormattedComponents.FormattedDate;
14
- exports.FormattedDateParts = require_FormattedComponents.FormattedDateParts;
15
- exports.FormattedDateTimeRange = require_FormattedComponents.FormattedDateTimeRange;
16
- exports.FormattedDisplayName = require_FormattedComponents.FormattedDisplayName;
17
- exports.FormattedList = require_FormattedComponents.FormattedList;
18
- exports.FormattedListParts = require_FormattedComponents.FormattedListParts;
19
- exports.FormattedMessage = require_FormattedMessage.FormattedMessage;
20
- exports.FormattedNumber = require_FormattedComponents.FormattedNumber;
21
- exports.FormattedNumberParts = require_FormattedComponents.FormattedNumberParts;
22
- exports.FormattedPlural = require_FormattedComponents.FormattedPlural;
23
- exports.FormattedRelativeTime = require_FormattedComponents.FormattedRelativeTime;
24
- exports.FormattedTime = require_FormattedComponents.FormattedTime;
25
- exports.FormattedTimeParts = require_FormattedComponents.FormattedTimeParts;
26
- exports.IntlContext = require_context.IntlContext;
27
- exports.IntlProvider = require_IntlProvider.IntlProvider;
28
- exports.InvalidConfigError = require_errors.InvalidConfigError;
29
- exports.MessageFormatError = require_errors.MessageFormatError;
30
- exports.MissingDataError = require_errors.MissingDataError;
31
- exports.MissingTranslationError = require_errors.MissingTranslationError;
32
- exports.RawIntlProvider = require_context.RawIntlProvider;
33
- exports.ReactIntlError = require_errors.ReactIntlError;
34
- exports.ReactIntlErrorCode = require_errors.ReactIntlErrorCode;
35
- exports.UnsupportedFormatterError = require_errors.UnsupportedFormatterError;
36
- exports.createIntl = require_createIntl.createIntl;
37
- exports.createIntlCache = require_createIntl.createIntlCache;
38
- exports.defineMessage = require_defineMessages.defineMessage;
39
- exports.defineMessages = require_defineMessages.defineMessages;
40
- exports.useIntl = require_useIntl.useIntl;
@@ -1,81 +0,0 @@
1
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_config_colors = require("@intlayer/config/colors");
4
- _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
5
- let _intlayer_config_logger = require("@intlayer/config/logger");
6
- let node_path = require("node:path");
7
- let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
8
- let _intlayer_config_node = require("@intlayer/config/node");
9
- let vite_intlayer = require("vite-intlayer");
10
-
11
- //#region src/plugin/index.ts
12
- /**
13
- * Caller configurations for react-intl's two message APIs.
14
- *
15
- * react-intl encodes both the dictionary key and the field path in a single
16
- * dotted id string, so the `path-first-segment` namespace source extracts the
17
- * first segment as the dictionary key and `translationFunction: 'self'` records
18
- * the second segment as the consumed field:
19
- *
20
- * `'home.title'` → dictionaryKey='home', field='title'
21
- * `'greeting'` → dictionaryKey='greeting', field='all' (single segment)
22
- * dynamic id → unresolvable → skipped (all fields kept)
23
- *
24
- * Both call sites are tracked:
25
- * - `intl.formatMessage({ id })` — matched as a method on any object.
26
- * - `<FormattedMessage id />` — matched as a JSX element (import-gated).
27
- *
28
- * The JSX form is mandatory: the prune context is shared across all files, so
29
- * tracking only `formatMessage` would let a field referenced solely from
30
- * `<FormattedMessage>` be pruned away whenever the same dictionary is also read
31
- * through `formatMessage`.
32
- */
33
- const REACT_INTL_COMPAT_CALLERS = [{
34
- callerName: "formatMessage",
35
- importSources: ["react-intl", "@intlayer/react-intl"],
36
- matchAsMethod: true,
37
- namespace: { from: "path-first-segment" },
38
- translationFunction: "self"
39
- }, {
40
- callerName: "FormattedMessage",
41
- importSources: ["react-intl", "@intlayer/react-intl"],
42
- jsxIdAttribute: "id",
43
- namespace: { from: "path-first-segment" },
44
- translationFunction: "self"
45
- }];
46
- /**
47
- * A Vite plugin for react-intl compat that wraps vite-intlayer
48
- * and injects a resolve alias mapping `react-intl` to
49
- * `@intlayer/react-intl`.
50
- *
51
- * @example
52
- * ```ts
53
- * // vite.config.ts
54
- * import reactIntlVitePlugin from '@intlayer/react-intl/plugin';
55
- *
56
- * export default defineConfig({
57
- * plugins: [reactIntlVitePlugin()],
58
- * });
59
- * ```
60
- */
61
- const reactIntlVitePlugin = (options) => {
62
- const intlayerConfig = (0, _intlayer_config_node.getConfiguration)();
63
- const appLogger = (0, _intlayer_config_logger.getAppLogger)(intlayerConfig);
64
- (0, _intlayer_chokidar_utils.runOnce)((0, node_path.join)(intlayerConfig.system.baseDir, ".intlayer", "cache", "intlayer-issues-invitation.lock"), () => {
65
- appLogger([(0, _intlayer_config_logger.colorize)("Please report any issues you met on GitHub:", _intlayer_config_colors.GREY), (0, _intlayer_config_logger.colorize)("https://github.com/aymericzip/intlayer/issues", _intlayer_config_colors.GREY_LIGHT)]);
66
- }, { cacheTimeoutMs: 1e3 * 60 * 60 });
67
- const basePlugins = (0, vite_intlayer.intlayer)({
68
- ...options,
69
- compatCallers: [...options?.compatCallers ?? [], ...REACT_INTL_COMPAT_CALLERS]
70
- });
71
- const compatPlugin = {
72
- name: "vite-react-intl-compat-plugin",
73
- config: () => ({ resolve: { alias: { "react-intl": "@intlayer/react-intl" } } })
74
- };
75
- return [...Array.isArray(basePlugins) ? basePlugins : [basePlugins], compatPlugin];
76
- };
77
-
78
- //#endregion
79
- exports.default = reactIntlVitePlugin;
80
- exports.reactIntlVitePlugin = reactIntlVitePlugin;
81
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["ANSIColors"],"sources":["../../../src/plugin/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { runOnce } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { PluginOption } from 'vite';\nimport { type CompatCallerConfig, intlayer } from 'vite-intlayer';\n\n/**\n * Caller configurations for react-intl's two message APIs.\n *\n * react-intl encodes both the dictionary key and the field path in a single\n * dotted id string, so the `path-first-segment` namespace source extracts the\n * first segment as the dictionary key and `translationFunction: 'self'` records\n * the second segment as the consumed field:\n *\n * `'home.title'` → dictionaryKey='home', field='title'\n * `'greeting'` → dictionaryKey='greeting', field='all' (single segment)\n * dynamic id → unresolvable → skipped (all fields kept)\n *\n * Both call sites are tracked:\n * - `intl.formatMessage({ id })` — matched as a method on any object.\n * - `<FormattedMessage id />` — matched as a JSX element (import-gated).\n *\n * The JSX form is mandatory: the prune context is shared across all files, so\n * tracking only `formatMessage` would let a field referenced solely from\n * `<FormattedMessage>` be pruned away whenever the same dictionary is also read\n * through `formatMessage`.\n */\nconst REACT_INTL_COMPAT_CALLERS: CompatCallerConfig[] = [\n {\n callerName: 'formatMessage',\n importSources: ['react-intl', '@intlayer/react-intl'],\n matchAsMethod: true,\n namespace: { from: 'path-first-segment' },\n translationFunction: 'self',\n },\n // `<FormattedMessage id=\"home.title\" />` — the dominant react-intl API. This\n // JSX form MUST be tracked alongside `formatMessage`: the prune context is\n // global across files, so a field referenced only from JSX would otherwise be\n // pruned away when the same dictionary is also read via `formatMessage`.\n {\n callerName: 'FormattedMessage',\n importSources: ['react-intl', '@intlayer/react-intl'],\n jsxIdAttribute: 'id',\n namespace: { from: 'path-first-segment' },\n translationFunction: 'self',\n },\n];\n\n/**\n * A Vite plugin for react-intl compat that wraps vite-intlayer\n * and injects a resolve alias mapping `react-intl` to\n * `@intlayer/react-intl`.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import reactIntlVitePlugin from '@intlayer/react-intl/plugin';\n *\n * export default defineConfig({\n * plugins: [reactIntlVitePlugin()],\n * });\n * ```\n */\nexport const reactIntlVitePlugin = (\n options?: Parameters<typeof intlayer>[0]\n): PluginOption[] => {\n const intlayerConfig = getConfiguration();\n const appLogger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(\n intlayerConfig.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-issues-invitation.lock'\n ),\n () => {\n appLogger([\n colorize(\n 'Please report any issues you met on GitHub:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://github.com/aymericzip/intlayer/issues',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n },\n {\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n }\n );\n\n const basePlugins = intlayer({\n ...options,\n compatCallers: [\n ...(options?.compatCallers ?? []),\n ...REACT_INTL_COMPAT_CALLERS,\n ],\n });\n\n const compatPlugin: PluginOption = {\n name: 'vite-react-intl-compat-plugin',\n config: () => ({\n resolve: {\n alias: {\n 'react-intl': '@intlayer/react-intl',\n },\n },\n }),\n };\n\n return [\n ...(Array.isArray(basePlugins) ? basePlugins : [basePlugins]),\n compatPlugin,\n ];\n};\n\nexport default reactIntlVitePlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,4BAAkD,CACtD;CACE,YAAY;CACZ,eAAe,CAAC,cAAc,sBAAsB;CACpD,eAAe;CACf,WAAW,EAAE,MAAM,qBAAqB;CACxC,qBAAqB;AACvB,GAKA;CACE,YAAY;CACZ,eAAe,CAAC,cAAc,sBAAsB;CACpD,gBAAgB;CAChB,WAAW,EAAE,MAAM,qBAAqB;CACxC,qBAAqB;AACvB,CACF;;;;;;;;;;;;;;;;AAiBA,MAAa,uBACX,YACmB;CACnB,MAAM,6DAAkC;CACxC,MAAM,sDAAyB,cAAc;CAE7C,0DAEI,eAAe,OAAO,SACtB,aACA,SACA,iCACF,SACM;EACJ,UAAU,uCAEN,+CACAA,wBAAW,IACb,yCAEE,iDACAA,wBAAW,UACb,CACF,CAAC;CACH,GACA,EACE,gBAAgB,MAAO,KAAK,GAC9B,CACF;CAEA,MAAM,0CAAuB;EAC3B,GAAG;EACH,eAAe,CACb,GAAI,SAAS,iBAAiB,CAAC,GAC/B,GAAG,yBACL;CACF,CAAC;CAED,MAAM,eAA6B;EACjC,MAAM;EACN,eAAe,EACb,SAAS,EACP,OAAO,EACL,cAAc,uBAChB,EACF,EACF;CACF;CAEA,OAAO,CACL,GAAI,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW,GAC3D,YACF;AACF"}
@@ -1,33 +0,0 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_context = require('./context.cjs');
5
- const require_createIntlObject = require('./createIntlObject.cjs');
6
- let react = require("react");
7
- let react_intlayer = require("react-intlayer");
8
-
9
- //#region src/useIntl.ts
10
- /**
11
- * Drop-in for react-intl's `useIntl`.
12
- *
13
- * Returns the active `IntlShape` instance. When used inside an
14
- * {@link IntlProvider} the instance comes from context; otherwise it is
15
- * derived from `react-intlayer`'s locale context on the fly.
16
- *
17
- * @example
18
- * ```tsx
19
- * const intl = useIntl();
20
- * intl.formatMessage({ id: 'home.title' });
21
- * intl.formatNumber(42, { style: 'currency', currency: 'USD' });
22
- * ```
23
- */
24
- const useIntl = () => {
25
- const contextIntl = (0, react.useContext)(require_context.IntlContext);
26
- const { locale } = (0, react_intlayer.useLocale)();
27
- const derivedIntl = (0, react.useMemo)(() => require_createIntlObject.createIntlObject(locale), [locale]);
28
- return contextIntl ?? derivedIntl;
29
- };
30
-
31
- //#endregion
32
- exports.useIntl = useIntl;
33
- //# sourceMappingURL=useIntl.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIntl.cjs","names":["IntlContext","createIntlObject"],"sources":["../../src/useIntl.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport type { useIntl as _useIntl } from 'react-intl';\nimport { useLocale } from 'react-intlayer';\nimport { IntlContext } from './context';\nimport { createIntlObject } from './createIntlObject';\n\n/**\n * Drop-in for react-intl's `useIntl`.\n *\n * Returns the active `IntlShape` instance. When used inside an\n * {@link IntlProvider} the instance comes from context; otherwise it is\n * derived from `react-intlayer`'s locale context on the fly.\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n * intl.formatMessage({ id: 'home.title' });\n * intl.formatNumber(42, { style: 'currency', currency: 'USD' });\n * ```\n */\nexport const useIntl: typeof _useIntl = () => {\n const contextIntl = useContext(IntlContext);\n const { locale } = useLocale();\n\n const derivedIntl = useMemo(\n () => createIntlObject(locale as LocalesValues),\n [locale]\n );\n\n return contextIntl ?? derivedIntl;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,gBAAiC;CAC5C,MAAM,oCAAyBA,2BAAW;CAC1C,MAAM,EAAE,yCAAqB;CAE7B,MAAM,uCACEC,0CAAiB,MAAuB,GAC9C,CAAC,MAAM,CACT;CAEA,OAAO,eAAe;AACxB"}
@@ -1,15 +0,0 @@
1
- import { createMessageResolver, icuToIntlayerFormatter } from "@intlayer/core/messageFormat";
2
-
3
- //#region src/resolveMessage.ts
4
- /**
5
- * ICU-bound `resolveMessage`.
6
- *
7
- * Binding the converter here, instead of selecting it by dialect at runtime,
8
- * leaves the other message-format parsers unreferenced so they tree-shake out
9
- * of the app bundle.
10
- */
11
- const resolveMessage = createMessageResolver(icuToIntlayerFormatter);
12
-
13
- //#endregion
14
- export { resolveMessage };
15
- //# sourceMappingURL=resolveMessage.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveMessage.mjs","names":[],"sources":["../../src/resolveMessage.ts"],"sourcesContent":["import {\n createMessageResolver,\n icuToIntlayerFormatter,\n} from '@intlayer/core/messageFormat';\n\n/**\n * ICU-bound `resolveMessage`.\n *\n * Binding the converter here, instead of selecting it by dialect at runtime,\n * leaves the other message-format parsers unreferenced so they tree-shake out\n * of the app bundle.\n */\nexport const resolveMessage = createMessageResolver(icuToIntlayerFormatter);\n"],"mappings":";;;;;;;;;;AAYA,MAAa,iBAAiB,sBAAsB,sBAAsB"}
@@ -1,11 +0,0 @@
1
- //#region src/resolveMessage.d.ts
2
- /**
3
- * ICU-bound `resolveMessage`.
4
- *
5
- * Binding the converter here, instead of selecting it by dialect at runtime,
6
- * leaves the other message-format parsers unreferenced so they tree-shake out
7
- * of the app bundle.
8
- */
9
- export declare const resolveMessage: import("@intlayer/core/messageFormat").MessageResolver;
10
- //#endregion
11
- //# sourceMappingURL=resolveMessage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveMessage.d.ts","names":[],"sources":["../../src/resolveMessage.ts"],"mappings":";;;;;;;;qBAYa,uDAAc"}