next-intl 3.16.0 → 3.17.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.
@@ -4,12 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
6
  var core = require('use-intl/core');
7
- var messageFormatCache = require('../shared/messageFormatCache.js');
8
7
 
9
8
  function getTranslatorImpl(config, namespace) {
10
9
  return core.createTranslator({
11
10
  ...config,
12
- messageFormatCache: messageFormatCache.getMessageFormatCache(),
13
11
  namespace
14
12
  });
15
13
  }
@@ -50,9 +50,13 @@ async function receiveRuntimeConfigImpl(getConfig, localeOverride) {
50
50
  };
51
51
  }
52
52
  const receiveRuntimeConfig = React.cache(receiveRuntimeConfigImpl);
53
+ const getFormatters = React.cache(core._createFormatters);
53
54
  async function getConfigImpl(localeOverride) {
54
55
  const runtimeConfig = await receiveRuntimeConfig(getRuntimeConfig__default.default, localeOverride);
55
- return core.initializeConfig(runtimeConfig);
56
+ return {
57
+ ...core.initializeConfig(runtimeConfig),
58
+ _formatters: getFormatters()
59
+ };
56
60
  }
57
61
  const getConfig = React.cache(getConfigImpl);
58
62
 
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
6
  var core = require('use-intl/core');
7
- var messageFormatCache = require('../../shared/messageFormatCache.js');
8
7
  var getConfig = require('./getConfig.js');
9
8
 
10
9
  // Maintainer note: `getTranslations` has two different call signatures.
@@ -28,7 +27,6 @@ async function getTranslations(namespaceOrOpts) {
28
27
  const config = await getConfig.default(locale);
29
28
  return core.createTranslator({
30
29
  ...config,
31
- messageFormatCache: messageFormatCache.getMessageFormatCache(),
32
30
  namespace,
33
31
  messages: config.messages
34
32
  });
@@ -1 +1 @@
1
- import{cache as e}from"react";import{createTranslator as r}from"use-intl/core";import{getMessageFormatCache as a}from"../shared/messageFormatCache.js";var m=e((function(e,m){return r({...e,messageFormatCache:a(),namespace:m})}));export{m as default};
1
+ import{cache as r}from"react";import{createTranslator as e}from"use-intl/core";var t=r((function(r,t){return e({...r,namespace:t})}));export{t as default};
@@ -1 +1 @@
1
- import{cache as t}from"react";import{initializeConfig as e}from"use-intl/core";import{getRequestLocale as o}from"./RequestLocale.js";import n from"next-intl/config";const r=t((function(){return new Date}));const a=t((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const s=t((async function(t,e){let n=!1;const s={get locale(){return n=!0,e||o()}};let i=t(s);return i instanceof Promise&&(i=await i),i.locale&&n&&console.error("\nYou've read the `locale` param that was passed to `getRequestConfig` but have also returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n"),{...i,locale:i.locale||s.locale,now:i.now||r(),timeZone:i.timeZone||a()}}));const i=t((async function(t){const o=await s(n,t);return e(o)}));export{i as default};
1
+ import{cache as t}from"react";import{_createFormatters as e,initializeConfig as o}from"use-intl/core";import{getRequestLocale as n}from"./RequestLocale.js";import r from"next-intl/config";const a=t((function(){return new Date}));const s=t((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const i=t((async function(t,e){let o=!1;const r={get locale(){return o=!0,e||n()}};let i=t(r);return i instanceof Promise&&(i=await i),i.locale&&o&&console.error("\nYou've read the `locale` param that was passed to `getRequestConfig` but have also returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n"),{...i,locale:i.locale||r.locale,now:i.now||a(),timeZone:i.timeZone||s()}})),c=t(e);const l=t((async function(t){const e=await i(r,t);return{...o(e),_formatters:c()}}));export{l as default};
@@ -1 +1 @@
1
- import{cache as e}from"react";import{createTranslator as a}from"use-intl/core";import{getMessageFormatCache as s}from"../../shared/messageFormatCache.js";import r from"./getConfig.js";var t=e((async function(e){let t,o;"string"==typeof e?t=e:e&&(o=e.locale,t=e.namespace);const m=await r(o);return a({...m,messageFormatCache:s(),namespace:t,messages:m.messages})}));export{t as default};
1
+ import{cache as e}from"react";import{createTranslator as t}from"use-intl/core";import a from"./getConfig.js";var s=e((async function(e){let s,o;"string"==typeof e?s=e:e&&(o=e.locale,s=e.namespace);const r=await a(o);return t({...r,namespace:s,messages:r.messages})}));export{s as default};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("use-intl/core"),a=require("../shared/messageFormatCache.js");var t=e.cache((function(e,t){return r.createTranslator({...e,messageFormatCache:a.getMessageFormatCache(),namespace:t})}));exports.default=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("use-intl/core");var t=e.cache((function(e,t){return r.createTranslator({...e,namespace:t})}));exports.default=t;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("use-intl/core"),n=require("./RequestLocale.js");function o(e){return e&&e.__esModule?e:{default:e}}var r=o(require("next-intl/config"));const a=e.cache((function(){return new Date}));const c=e.cache((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const i=e.cache((async function(e,t){let o=!1;const r={get locale(){return o=!0,t||n.getRequestLocale()}};let i=e(r);return i instanceof Promise&&(i=await i),i.locale&&o&&console.error("\nYou've read the `locale` param that was passed to `getRequestConfig` but have also returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n"),{...i,locale:i.locale||r.locale,now:i.now||a(),timeZone:i.timeZone||c()}}));const s=e.cache((async function(e){const n=await i(r.default,e);return t.initializeConfig(n)}));exports.default=s;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("use-intl/core"),n=require("./RequestLocale.js");function o(e){return e&&e.__esModule?e:{default:e}}var r=o(require("next-intl/config"));const a=e.cache((function(){return new Date}));const c=e.cache((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const s=e.cache((async function(e,t){let o=!1;const r={get locale(){return o=!0,t||n.getRequestLocale()}};let s=e(r);return s instanceof Promise&&(s=await s),s.locale&&o&&console.error("\nYou've read the `locale` param that was passed to `getRequestConfig` but have also returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n"),{...s,locale:s.locale||r.locale,now:s.now||a(),timeZone:s.timeZone||c()}})),i=e.cache(t._createFormatters);const u=e.cache((async function(e){const n=await s(r.default,e);return{...t.initializeConfig(n),_formatters:i()}}));exports.default=u;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),a=require("use-intl/core"),r=require("../../shared/messageFormatCache.js"),s=require("./getConfig.js");var t=e.cache((async function(e){let t,c;"string"==typeof e?t=e:e&&(c=e.locale,t=e.namespace);const o=await s.default(c);return a.createTranslator({...o,messageFormatCache:r.getMessageFormatCache(),namespace:t,messages:o.messages})}));exports.default=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("use-intl/core"),a=require("./getConfig.js");var t=e.cache((async function(e){let t,s;"string"==typeof e?t=e:e&&(s=e.locale,t=e.namespace);const c=await a.default(s);return r.createTranslator({...c,namespace:t,messages:c.messages})}));exports.default=t;
@@ -1,9 +1,10 @@
1
- import { IntlConfig } from 'use-intl/core';
1
+ import { IntlConfig, _createFormatters } from 'use-intl/core';
2
2
  declare function getConfigImpl(localeOverride?: string): Promise<IntlConfig & {
3
3
  getMessageFallback: NonNullable<IntlConfig['getMessageFallback']>;
4
4
  now: NonNullable<IntlConfig['now']>;
5
5
  onError: NonNullable<IntlConfig['onError']>;
6
6
  timeZone: NonNullable<IntlConfig['timeZone']>;
7
+ _formatters: ReturnType<typeof _createFormatters>;
7
8
  }>;
8
9
  declare const getConfig: typeof getConfigImpl;
9
10
  export default getConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "3.16.0",
3
+ "version": "3.17.0",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.work>",
6
6
  "funding": [
@@ -87,7 +87,7 @@
87
87
  "dependencies": {
88
88
  "@formatjs/intl-localematcher": "^0.2.32",
89
89
  "negotiator": "^0.6.3",
90
- "use-intl": "^3.16.0"
90
+ "use-intl": "^3.17.0"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
@@ -96,11 +96,11 @@
96
96
  "size-limit": [
97
97
  {
98
98
  "path": "dist/production/index.react-client.js",
99
- "limit": "15.785 KB"
99
+ "limit": "16.055 KB"
100
100
  },
101
101
  {
102
102
  "path": "dist/production/index.react-server.js",
103
- "limit": "16.66 KB"
103
+ "limit": "16.875 KB"
104
104
  },
105
105
  {
106
106
  "path": "dist/production/navigation.react-client.js",
@@ -108,7 +108,7 @@
108
108
  },
109
109
  {
110
110
  "path": "dist/production/navigation.react-server.js",
111
- "limit": "18.075 KB"
111
+ "limit": "18.325 KB"
112
112
  },
113
113
  {
114
114
  "path": "dist/production/server.react-client.js",
@@ -116,7 +116,7 @@
116
116
  },
117
117
  {
118
118
  "path": "dist/production/server.react-server.js",
119
- "limit": "15.84 KB"
119
+ "limit": "16.025 KB"
120
120
  },
121
121
  {
122
122
  "path": "dist/production/middleware.js",
@@ -127,5 +127,5 @@
127
127
  "limit": "0 KB"
128
128
  }
129
129
  ],
130
- "gitHead": "44a87a4ff07e779df8ac929c0edcf22fb398f576"
130
+ "gitHead": "bef3544202e88849646583e63b4751b82d1690a0"
131
131
  }
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
-
7
- function getMessageFormatCacheImpl() {
8
- return new Map();
9
- }
10
- const getMessageFormatCache = React.cache(getMessageFormatCacheImpl);
11
-
12
- exports.getMessageFormatCache = getMessageFormatCache;
@@ -1 +0,0 @@
1
- import{cache as r}from"react";const t=r((function(){return new Map}));export{t as getMessageFormatCache};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("react").cache((function(){return new Map}));exports.getMessageFormatCache=e;
@@ -1,3 +0,0 @@
1
- declare function getMessageFormatCacheImpl(): Map<any, any>;
2
- export declare const getMessageFormatCache: typeof getMessageFormatCacheImpl;
3
- export {};