next-intl 3.5.2 → 3.5.4

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.
@@ -10,7 +10,7 @@ var constants = require('../../shared/constants.js');
10
10
  * See https://github.com/amannn/next-intl/issues/786.
11
11
  */
12
12
  function syncLocaleCookie(pathname, locale, nextLocale) {
13
- const isSwitchingLocale = nextLocale !== locale;
13
+ const isSwitchingLocale = nextLocale !== locale && nextLocale != null;
14
14
  if (!isSwitchingLocale ||
15
15
  // Theoretical case, we always have a pathname in a real app,
16
16
  // only not when running e.g. in a simulated test environment
@@ -4,15 +4,12 @@ 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');
7
8
 
8
- function getMessageFormatCacheImpl() {
9
- return new Map();
10
- }
11
- const getMessageFormatCache = React.cache(getMessageFormatCacheImpl);
12
9
  function getTranslatorImpl(config, namespace) {
13
10
  return core.createTranslator({
14
11
  ...config,
15
- messageFormatCache: getMessageFormatCache(),
12
+ messageFormatCache: messageFormatCache.getMessageFormatCache(),
16
13
  namespace
17
14
  });
18
15
  }
@@ -4,6 +4,7 @@ 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');
7
8
  var getConfig = require('./getConfig.js');
8
9
  var getLocale = require('./getLocale.js');
9
10
 
@@ -26,6 +27,7 @@ async function getTranslations(namespaceOrOpts) {
26
27
  const config = await getConfig.default(locale || (await getLocale.default()));
27
28
  return core.createTranslator({
28
29
  ...config,
30
+ messageFormatCache: messageFormatCache.getMessageFormatCache(),
29
31
  namespace,
30
32
  messages: config.messages
31
33
  });
@@ -0,0 +1,12 @@
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 +1 @@
1
- import{COOKIE_LOCALE_NAME as t,COOKIE_MAX_AGE as a,COOKIE_SAME_SITE as c}from"../../shared/constants.js";function o(o,n,e){if(!(e!==n)||!o)return;const i=window.location.pathname.replace(o,""),r=""!==i?i:"/";document.cookie="".concat(t,"=").concat(e,"; path=").concat(r,"; max-age=").concat(a,"; sameSite=").concat(c)}export{o as default};
1
+ import{COOKIE_LOCALE_NAME as t,COOKIE_MAX_AGE as a,COOKIE_SAME_SITE as c}from"../../shared/constants.js";function o(o,n,e){if(!(e!==n&&null!=e)||!o)return;const i=window.location.pathname.replace(o,""),r=""!==i?i:"/";document.cookie="".concat(t,"=").concat(e,"; path=").concat(r,"; max-age=").concat(a,"; sameSite=").concat(c)}export{o as default};
@@ -1 +1 @@
1
- import{cache as e}from"react";import{createTranslator as r}from"use-intl/core";const t=e((function(){return new Map}));var a=e((function(e,a){return r({...e,messageFormatCache:t(),namespace:a})}));export{a as default};
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 +1 @@
1
- import{cache as e}from"react";import{createTranslator as t}from"use-intl/core";import a from"./getConfig.js";import o from"./getLocale.js";var r=e((async function(e){let r,s;"string"==typeof e?r=e:e&&(s=e.locale,r=e.namespace);const m=await a(s||await o());return t({...m,namespace:r,messages:m.messages})}));export{r as default};
1
+ import{cache as e}from"react";import{createTranslator as a}from"use-intl/core";import{getMessageFormatCache as s}from"../../shared/messageFormatCache.js";import t from"./getConfig.js";import o from"./getLocale.js";var r=e((async function(e){let r,m;"string"==typeof e?r=e:e&&(m=e.locale,r=e.namespace);const c=await t(m||await o());return a({...c,messageFormatCache:s(),namespace:r,messages:c.messages})}));export{r as default};
@@ -0,0 +1 @@
1
+ import{cache as r}from"react";const t=r((function(){return new Map}));export{t as getMessageFormatCache};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../shared/constants.js");exports.default=function(t,c,a){if(!(a!==c)||!t)return;const o=window.location.pathname.replace(t,""),n=""!==o?o:"/";document.cookie="".concat(e.COOKIE_LOCALE_NAME,"=").concat(a,"; path=").concat(n,"; max-age=").concat(e.COOKIE_MAX_AGE,"; sameSite=").concat(e.COOKIE_SAME_SITE)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../shared/constants.js");exports.default=function(t,c,a){if(!(a!==c&&null!=a)||!t)return;const o=window.location.pathname.replace(t,""),n=""!==o?o:"/";document.cookie="".concat(e.COOKIE_LOCALE_NAME,"=").concat(a,"; path=").concat(n,"; max-age=").concat(e.COOKIE_MAX_AGE,"; sameSite=").concat(e.COOKIE_SAME_SITE)};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("use-intl/core");const t=e.cache((function(){return new Map}));var a=e.cache((function(e,a){return r.createTranslator({...e,messageFormatCache:t(),namespace:a})}));exports.default=a;
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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),a=require("use-intl/core"),r=require("./getConfig.js"),t=require("./getLocale.js");var s=e.cache((async function(e){let s,c;"string"==typeof e?s=e:e&&(c=e.locale,s=e.namespace);const u=await r.default(c||await t.default());return a.createTranslator({...u,namespace:s,messages:u.messages})}));exports.default=s;
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"),t=require("./getLocale.js");var c=e.cache((async function(e){let c,o;"string"==typeof e?c=e:e&&(o=e.locale,c=e.namespace);const u=await s.default(o||await t.default());return a.createTranslator({...u,messageFormatCache:r.getMessageFormatCache(),namespace:c,messages:u.messages})}));exports.default=c;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("react").cache((function(){return new Map}));exports.getMessageFormatCache=e;
@@ -3,7 +3,7 @@ export { default } from 'react';
3
3
  export declare function use(promise: Promise<unknown> & {
4
4
  value?: unknown;
5
5
  }): {};
6
- export declare function cache(fn: (...args: Array<unknown>) => unknown): (...args: Array<unknown>) => unknown;
6
+ export declare function cache(fn: (...args: Array<unknown>) => unknown): (...args: Array<unknown>) => any;
7
7
  export declare namespace cache {
8
8
  var reset: () => void;
9
9
  }
@@ -0,0 +1,3 @@
1
+ declare function getMessageFormatCacheImpl(): Map<any, any>;
2
+ export declare const getMessageFormatCache: typeof getMessageFormatCacheImpl;
3
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "3.5.2",
3
+ "version": "3.5.4",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.work>",
6
6
  "funding": [
@@ -82,7 +82,7 @@
82
82
  "dependencies": {
83
83
  "@formatjs/intl-localematcher": "^0.2.32",
84
84
  "negotiator": "^0.6.3",
85
- "use-intl": "^3.5.2"
85
+ "use-intl": "^3.5.4"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
@@ -122,11 +122,11 @@
122
122
  },
123
123
  {
124
124
  "path": "dist/production/navigation.react-client.js",
125
- "limit": "2.83 KB"
125
+ "limit": "2.84 KB"
126
126
  },
127
127
  {
128
128
  "path": "dist/production/navigation.react-server.js",
129
- "limit": "2.94 KB"
129
+ "limit": "2.95 KB"
130
130
  },
131
131
  {
132
132
  "path": "dist/production/server.react-client.js",
@@ -141,5 +141,5 @@
141
141
  "limit": "5.81 KB"
142
142
  }
143
143
  ],
144
- "gitHead": "6aec1c0f1f944fa97730f3564831d039b4b059a8"
144
+ "gitHead": "94fb953d13b883eff3e1b2f5fd2b0e08823be2a2"
145
145
  }