Comparing version 3.16.0 to 3.17.0
@@ -6,4 +6,6 @@ 'use strict'; | ||
var React = require('react'); | ||
var initializeConfig = require('./initializeConfig-BnOiVylt.js'); | ||
var initializeConfig = require('./initializeConfig-SCqxwrIu.js'); | ||
var IntlContext = require('./IntlContext-BKfsnzBx.js'); | ||
require('@formatjs/fast-memoize'); | ||
require('intl-messageformat'); | ||
@@ -26,3 +28,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } | ||
} = _ref; | ||
const [messageFormatCache] = React.useState(() => new Map()); | ||
// The formatter cache is released when the locale changes. For | ||
// long-running apps with a persistent `IntlProvider` at the root, | ||
// this can reduce the memory footprint (e.g. in React Native). | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
const formatters = React.useMemo(() => initializeConfig.createFormatters(), [locale]); | ||
@@ -48,4 +54,4 @@ // Memoizing this value helps to avoid triggering a re-render of all | ||
}), | ||
messageFormatCache | ||
}), [defaultTranslationValues, formats, getMessageFallback, locale, messageFormatCache, messages, now, onError, timeZone]); | ||
formatters | ||
}), [defaultTranslationValues, formats, formatters, getMessageFallback, locale, messages, now, onError, timeZone]); | ||
return /*#__PURE__*/React__default.default.createElement(IntlContext.IntlContext.Provider, { | ||
@@ -52,0 +58,0 @@ value: value |
@@ -5,4 +5,5 @@ 'use strict'; | ||
var initializeConfig = require('./initializeConfig-BnOiVylt.js'); | ||
var createFormatter = require('./createFormatter-ZTUVkKlh.js'); | ||
var initializeConfig = require('./initializeConfig-SCqxwrIu.js'); | ||
var createFormatter = require('./createFormatter-DMm1DTAO.js'); | ||
require('@formatjs/fast-memoize'); | ||
require('intl-messageformat'); | ||
@@ -13,6 +14,4 @@ require('react'); | ||
let { | ||
getMessageFallback, | ||
messages, | ||
namespace, | ||
onError, | ||
...rest | ||
@@ -26,4 +25,2 @@ } = _ref; | ||
...rest, | ||
onError, | ||
getMessageFallback, | ||
messages, | ||
@@ -44,2 +41,3 @@ namespace | ||
let { | ||
_formatters = initializeConfig.createFormatters(), | ||
getMessageFallback = initializeConfig.defaultGetMessageFallback, | ||
@@ -57,2 +55,3 @@ messages, | ||
onError, | ||
formatters: _formatters, | ||
getMessageFallback, | ||
@@ -69,4 +68,5 @@ // @ts-expect-error `messages` is allowed to be `undefined` here and will be handled internally | ||
exports.IntlErrorCode = initializeConfig.IntlErrorCode; | ||
exports._createFormatters = initializeConfig.createFormatters; | ||
exports.initializeConfig = initializeConfig.initializeConfig; | ||
exports.createFormatter = createFormatter.createFormatter; | ||
exports.createTranslator = createTranslator; |
@@ -5,8 +5,9 @@ 'use strict'; | ||
var initializeConfig = require('./initializeConfig-BnOiVylt.js'); | ||
var initializeConfig = require('./initializeConfig-SCqxwrIu.js'); | ||
var core = require('./core.js'); | ||
var createFormatter = require('./createFormatter-ZTUVkKlh.js'); | ||
var createFormatter = require('./createFormatter-DMm1DTAO.js'); | ||
var _IntlProvider = require('./_IntlProvider.js'); | ||
var react = require('./react.js'); | ||
var _useLocale = require('./_useLocale-0Rl9uR82.js'); | ||
require('@formatjs/fast-memoize'); | ||
require('intl-messageformat'); | ||
@@ -20,2 +21,3 @@ require('react'); | ||
exports.IntlErrorCode = initializeConfig.IntlErrorCode; | ||
exports._createFormatters = initializeConfig.createFormatters; | ||
exports.initializeConfig = initializeConfig.initializeConfig; | ||
@@ -22,0 +24,0 @@ exports.createTranslator = core.createTranslator; |
@@ -8,6 +8,7 @@ 'use strict'; | ||
var React = require('react'); | ||
var createFormatter = require('./createFormatter-ZTUVkKlh.js'); | ||
var initializeConfig = require('./initializeConfig-BnOiVylt.js'); | ||
var createFormatter = require('./createFormatter-DMm1DTAO.js'); | ||
var initializeConfig = require('./initializeConfig-SCqxwrIu.js'); | ||
require('./IntlContext-BKfsnzBx.js'); | ||
require('intl-messageformat'); | ||
require('@formatjs/fast-memoize'); | ||
@@ -20,5 +21,5 @@ let hasWarnedForMissingTimezone = false; | ||
formats: globalFormats, | ||
formatters, | ||
getMessageFallback, | ||
locale, | ||
messageFormatCache, | ||
onError, | ||
@@ -37,3 +38,3 @@ timeZone | ||
const translate = React.useMemo(() => createFormatter.createBaseTranslator({ | ||
messageFormatCache, | ||
formatters, | ||
getMessageFallback, | ||
@@ -47,3 +48,3 @@ messages: allMessages, | ||
timeZone | ||
}), [messageFormatCache, getMessageFallback, allMessages, namespace, onError, defaultTranslationValues, globalFormats, locale, timeZone]); | ||
}), [formatters, getMessageFallback, allMessages, defaultTranslationValues, namespace, onError, globalFormats, locale, timeZone]); | ||
return translate; | ||
@@ -129,2 +130,3 @@ } | ||
formats, | ||
formatters, | ||
locale, | ||
@@ -140,4 +142,5 @@ now: globalNow, | ||
onError, | ||
timeZone | ||
}), [formats, globalNow, locale, onError, timeZone]); | ||
timeZone, | ||
_formatters: formatters | ||
}), [formats, formatters, globalNow, locale, onError, timeZone]); | ||
} | ||
@@ -144,0 +147,0 @@ |
@@ -1,1 +0,1 @@ | ||
import e,{useState as a,useMemo as o}from"react";import{i as t}from"./initializeConfig-CeCQBa_L.js";import{I as r}from"./IntlContext-DoS4CDM3.js";function s(s){let{children:n,defaultTranslationValues:l,formats:i,getMessageFallback:m,locale:c,messages:f,now:g,onError:u,timeZone:p}=s;const[d]=a((()=>new Map)),w=o((()=>({...t({locale:c,defaultTranslationValues:l,formats:i,getMessageFallback:m,messages:f,now:g,onError:u,timeZone:p}),messageFormatCache:d})),[l,i,m,c,d,f,g,u,p]);return e.createElement(r.Provider,{value:w},n)}export{s as IntlProvider}; | ||
import e,{useMemo as t}from"react";import{c as a,i as o}from"./initializeConfig-BB2Ue6Z9.js";import{I as r}from"./IntlContext-DoS4CDM3.js";import"@formatjs/fast-memoize";import"intl-messageformat";function s(s){let{children:l,defaultTranslationValues:m,formats:n,getMessageFallback:i,locale:f,messages:c,now:g,onError:u,timeZone:p}=s;const d=t((()=>a()),[f]),j=t((()=>({...o({locale:f,defaultTranslationValues:m,formats:n,getMessageFallback:i,messages:c,now:g,onError:u,timeZone:p}),formatters:d})),[m,n,d,i,f,c,g,u,p]);return e.createElement(r.Provider,{value:j},l)}export{s as IntlProvider}; |
@@ -1,1 +0,1 @@ | ||
import{b as e,d as r}from"./initializeConfig-CeCQBa_L.js";export{I as IntlError,a as IntlErrorCode,i as initializeConfig}from"./initializeConfig-CeCQBa_L.js";import{r as s,a as t}from"./createFormatter-D7emvAET.js";export{c as createFormatter}from"./createFormatter-D7emvAET.js";import"intl-messageformat";import"react";function o(a){let{getMessageFallback:o=e,messages:n,namespace:i,onError:m=r,...c}=a;return function(e,a){let{getMessageFallback:r,messages:o,namespace:n,onError:i,...m}=e;return o=o[a],n=s(n,a),t({...m,onError:i,getMessageFallback:r,messages:o,namespace:n})}({...c,onError:m,getMessageFallback:o,messages:{"!":n},namespace:i?"!.".concat(i):"!"},"!")}export{o as createTranslator}; | ||
import{c as e,b as r,d as t}from"./initializeConfig-BB2Ue6Z9.js";export{I as IntlError,a as IntlErrorCode,i as initializeConfig}from"./initializeConfig-BB2Ue6Z9.js";import{r as s,a as o}from"./createFormatter-C4S7xHL_.js";export{c as createFormatter}from"./createFormatter-C4S7xHL_.js";import"@formatjs/fast-memoize";import"intl-messageformat";import"react";function m(a){let{_formatters:m=e(),getMessageFallback:i=r,messages:n,namespace:c,onError:f=t,...g}=a;return function(e,a){let{messages:r,namespace:t,...m}=e;return r=r[a],t=s(t,a),o({...m,messages:r,namespace:t})}({...g,onError:f,formatters:m,getMessageFallback:i,messages:{"!":n},namespace:c?"!.".concat(c):"!"},"!")}export{e as _createFormatters,m as createTranslator}; |
@@ -1,1 +0,1 @@ | ||
export{I as IntlError,a as IntlErrorCode,i as initializeConfig}from"./initializeConfig-CeCQBa_L.js";export{createTranslator}from"./core.js";export{c as createFormatter}from"./createFormatter-D7emvAET.js";export{IntlProvider}from"./_IntlProvider.js";export{useFormatter,useMessages,useNow,useTimeZone,useTranslations}from"./react.js";export{u as useLocale}from"./_useLocale-v-ZT5JoE.js";import"intl-messageformat";import"react";import"./IntlContext-DoS4CDM3.js"; | ||
export{I as IntlError,a as IntlErrorCode,c as _createFormatters,i as initializeConfig}from"./initializeConfig-BB2Ue6Z9.js";export{createTranslator}from"./core.js";export{c as createFormatter}from"./createFormatter-C4S7xHL_.js";export{IntlProvider}from"./_IntlProvider.js";export{useFormatter,useMessages,useNow,useTimeZone,useTranslations}from"./react.js";export{u as useLocale}from"./_useLocale-v-ZT5JoE.js";import"@formatjs/fast-memoize";import"intl-messageformat";import"react";import"./IntlContext-DoS4CDM3.js"; |
@@ -1,1 +0,1 @@ | ||
export{IntlProvider}from"./_IntlProvider.js";import{a as e}from"./_useLocale-v-ZT5JoE.js";export{u as useLocale}from"./_useLocale-v-ZT5JoE.js";import{useMemo as o,useState as t,useEffect as n}from"react";import{r,a,c as s}from"./createFormatter-D7emvAET.js";import{I as i,a as c}from"./initializeConfig-CeCQBa_L.js";import"./IntlContext-DoS4CDM3.js";import"intl-messageformat";let l=!1;const m="undefined"==typeof window;function f(t){return function(t,n,s){const{defaultTranslationValues:u,formats:f,getMessageFallback:d,locale:g,messageFormatCache:p,onError:v,timeZone:h}=e();return t=t[s],n=r(n,s),h||l||!m||(l=!0,v(new i(c.ENVIRONMENT_FALLBACK,"There is no `timeZone` configured, this can lead to markup mismatches caused by environment differences. Consider adding a global default: https://next-intl-docs.vercel.app/docs/configuration#time-zone"))),o((()=>a({messageFormatCache:p,getMessageFallback:d,messages:t,defaultTranslationValues:u,namespace:n,onError:v,formats:f,locale:g,timeZone:h})),[p,d,t,n,v,u,f,g,h])}({"!":e().messages},t?"!.".concat(t):"!","!")}function d(){return new Date}function g(o){const r=null==o?void 0:o.updateInterval,{now:a}=e(),[s,i]=t(a||d());return n((()=>{if(!r)return;const e=setInterval((()=>{i(d())}),r);return()=>{clearInterval(e)}}),[a,r]),null==r&&a?a:s}function p(){return e().timeZone}function v(){const o=e();if(!o.messages)throw new Error("No messages found. Have you configured them correctly? See https://next-intl-docs.vercel.app/docs/configuration#messages");return o.messages}function h(){const{formats:t,locale:n,now:r,onError:a,timeZone:i}=e();return o((()=>s({formats:t,locale:n,now:r,onError:a,timeZone:i})),[t,r,n,a,i])}export{h as useFormatter,v as useMessages,g as useNow,p as useTimeZone,f as useTranslations}; | ||
export{IntlProvider}from"./_IntlProvider.js";import{a as e}from"./_useLocale-v-ZT5JoE.js";export{u as useLocale}from"./_useLocale-v-ZT5JoE.js";import{useMemo as t,useState as o,useEffect as r}from"react";import{r as n,a,c as s}from"./createFormatter-C4S7xHL_.js";import{I as i,a as m}from"./initializeConfig-BB2Ue6Z9.js";import"./IntlContext-DoS4CDM3.js";import"intl-messageformat";import"@formatjs/fast-memoize";let c=!1;const l="undefined"==typeof window;function f(o){return function(o,r,s){const{defaultTranslationValues:f,formats:u,formatters:d,getMessageFallback:p,locale:g,onError:v,timeZone:w}=e();return o=o[s],r=n(r,s),w||c||!l||(c=!0,v(new i(m.ENVIRONMENT_FALLBACK,"There is no `timeZone` configured, this can lead to markup mismatches caused by environment differences. Consider adding a global default: https://next-intl-docs.vercel.app/docs/configuration#time-zone"))),t((()=>a({formatters:d,getMessageFallback:p,messages:o,defaultTranslationValues:f,namespace:r,onError:v,formats:u,locale:g,timeZone:w})),[d,p,o,f,r,v,u,g,w])}({"!":e().messages},o?"!.".concat(o):"!","!")}function d(){return new Date}function p(t){const n=null==t?void 0:t.updateInterval,{now:a}=e(),[s,i]=o(a||d());return r((()=>{if(!n)return;const e=setInterval((()=>{i(d())}),n);return()=>{clearInterval(e)}}),[a,n]),null==n&&a?a:s}function g(){return e().timeZone}function v(){const t=e();if(!t.messages)throw new Error("No messages found. Have you configured them correctly? See https://next-intl-docs.vercel.app/docs/configuration#messages");return t.messages}function w(){const{formats:o,formatters:r,locale:n,now:a,onError:i,timeZone:m}=e();return t((()=>s({formats:o,locale:n,now:a,onError:i,timeZone:m,_formatters:r})),[o,r,a,n,i,m])}export{w as useFormatter,v as useMessages,p as useNow,g as useTimeZone,f as useTranslations}; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("./initializeConfig-iVzvEYey.js"),a=require("./IntlContext-DcFt0tgW.js");function r(e){return e&&e.__esModule?e:{default:e}}var n=r(e);exports.IntlProvider=function(r){let{children:o,defaultTranslationValues:s,formats:l,getMessageFallback:i,locale:u,messages:c,now:f,onError:d,timeZone:m}=r;const[g]=e.useState((()=>new Map)),v=e.useMemo((()=>({...t.initializeConfig({locale:u,defaultTranslationValues:s,formats:l,getMessageFallback:i,messages:c,now:f,onError:d,timeZone:m}),messageFormatCache:g})),[s,l,i,u,g,c,f,d,m]);return n.default.createElement(a.IntlContext.Provider,{value:v},o)}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./initializeConfig-BLiF0aUh.js"),t=require("./IntlContext-DcFt0tgW.js");function a(e){return e&&e.__esModule?e:{default:e}}require("@formatjs/fast-memoize"),require("intl-messageformat");var o=a(e);exports.IntlProvider=function(a){let{children:s,defaultTranslationValues:n,formats:l,getMessageFallback:i,locale:u,messages:m,now:f,onError:c,timeZone:d}=a;const g=e.useMemo((()=>r.createFormatters()),[u]),v=e.useMemo((()=>({...r.initializeConfig({locale:u,defaultTranslationValues:n,formats:l,getMessageFallback:i,messages:m,now:f,onError:c,timeZone:d}),formatters:g})),[n,l,g,i,u,m,f,c,d]);return o.default.createElement(t.IntlContext.Provider,{value:v},s)}; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./createFormatter-DY1vgx2z.js"),r=require("./initializeConfig-iVzvEYey.js");require("intl-messageformat"),require("react"),exports.IntlError=e.IntlError,exports.IntlErrorCode=e.IntlErrorCode,exports.createFormatter=e.createFormatter,exports.initializeConfig=r.initializeConfig,exports.createTranslator=function(a){let{getMessageFallback:t=r.defaultGetMessageFallback,messages:s,namespace:o,onError:n=r.defaultOnError,...l}=a;return function(r,a){let{getMessageFallback:t,messages:s,namespace:o,onError:n,...l}=r;return s=s[a],o=e.resolveNamespace(o,a),e.createBaseTranslator({...l,onError:n,getMessageFallback:t,messages:s,namespace:o})}({...l,onError:n,getMessageFallback:t,messages:{"!":s},namespace:o?"!.".concat(o):"!"},"!")}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./createFormatter-DdXLo8F4.js"),r=require("./initializeConfig-BLiF0aUh.js");require("react"),require("intl-messageformat"),require("@formatjs/fast-memoize"),exports.IntlError=e.IntlError,exports.IntlErrorCode=e.IntlErrorCode,exports.createFormatter=e.createFormatter,exports._createFormatters=r.createFormatters,exports.initializeConfig=r.initializeConfig,exports.createTranslator=function(t){let{_formatters:a=r.createFormatters(),getMessageFallback:s=r.defaultGetMessageFallback,messages:o,namespace:n,onError:i=r.defaultOnError,...c}=t;return function(r,t){let{messages:a,namespace:s,...o}=r;return a=a[t],s=e.resolveNamespace(s,t),e.createBaseTranslator({...o,messages:a,namespace:s})}({...c,onError:i,formatters:a,getMessageFallback:s,messages:{"!":o},namespace:n?"!.".concat(n):"!"},"!")}; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./createFormatter-DY1vgx2z.js"),r=require("./core.js"),t=require("./initializeConfig-iVzvEYey.js"),s=require("./_IntlProvider.js"),o=require("./react.js"),i=require("./_useLocale-CpTrqBDt.js");require("intl-messageformat"),require("react"),require("./IntlContext-DcFt0tgW.js"),exports.IntlError=e.IntlError,exports.IntlErrorCode=e.IntlErrorCode,exports.createFormatter=e.createFormatter,exports.createTranslator=r.createTranslator,exports.initializeConfig=t.initializeConfig,exports.IntlProvider=s.IntlProvider,exports.useFormatter=o.useFormatter,exports.useMessages=o.useMessages,exports.useNow=o.useNow,exports.useTimeZone=o.useTimeZone,exports.useTranslations=o.useTranslations,exports.useLocale=i.useLocale; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./createFormatter-DdXLo8F4.js"),r=require("./core.js"),t=require("./initializeConfig-BLiF0aUh.js"),s=require("./_IntlProvider.js"),o=require("./react.js"),a=require("./_useLocale-CpTrqBDt.js");require("react"),require("intl-messageformat"),require("@formatjs/fast-memoize"),require("./IntlContext-DcFt0tgW.js"),exports.IntlError=e.IntlError,exports.IntlErrorCode=e.IntlErrorCode,exports.createFormatter=e.createFormatter,exports.createTranslator=r.createTranslator,exports._createFormatters=t.createFormatters,exports.initializeConfig=t.initializeConfig,exports.IntlProvider=s.IntlProvider,exports.useFormatter=o.useFormatter,exports.useMessages=o.useMessages,exports.useNow=o.useNow,exports.useTimeZone=o.useTimeZone,exports.useTranslations=o.useTranslations,exports.useLocale=a.useLocale; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./_IntlProvider.js"),t=require("./_useLocale-CpTrqBDt.js"),r=require("react"),o=require("./createFormatter-DY1vgx2z.js");require("./initializeConfig-iVzvEYey.js"),require("./IntlContext-DcFt0tgW.js"),require("intl-messageformat");let n=!1;const s="undefined"==typeof window;function a(){return new Date}exports.IntlProvider=e.IntlProvider,exports.useLocale=t.useLocale,exports.useFormatter=function(){const{formats:e,locale:n,now:s,onError:a,timeZone:u}=t.useIntlContext();return r.useMemo((()=>o.createFormatter({formats:e,locale:n,now:s,onError:a,timeZone:u})),[e,s,n,a,u])},exports.useMessages=function(){const e=t.useIntlContext();if(!e.messages)throw new Error(void 0);return e.messages},exports.useNow=function(e){const o=null==e?void 0:e.updateInterval,{now:n}=t.useIntlContext(),[s,u]=r.useState(n||a());return r.useEffect((()=>{if(!o)return;const e=setInterval((()=>{u(a())}),o);return()=>{clearInterval(e)}}),[n,o]),null==o&&n?n:s},exports.useTimeZone=function(){return t.useIntlContext().timeZone},exports.useTranslations=function(e){return function(e,a,u){const{defaultTranslationValues:l,formats:i,getMessageFallback:c,locale:m,messageFormatCache:f,onError:I,timeZone:d}=t.useIntlContext();return e=e[u],a=o.resolveNamespace(a,u),d||n||!s||(n=!0,I(new o.IntlError(o.IntlErrorCode.ENVIRONMENT_FALLBACK,void 0))),r.useMemo((()=>o.createBaseTranslator({messageFormatCache:f,getMessageFallback:c,messages:e,defaultTranslationValues:l,namespace:a,onError:I,formats:i,locale:m,timeZone:d})),[f,c,e,a,I,l,i,m,d])}({"!":t.useIntlContext().messages},e?"!.".concat(e):"!","!")}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./_IntlProvider.js"),t=require("./_useLocale-CpTrqBDt.js"),r=require("react"),o=require("./createFormatter-DdXLo8F4.js");require("./initializeConfig-BLiF0aUh.js"),require("@formatjs/fast-memoize"),require("intl-messageformat"),require("./IntlContext-DcFt0tgW.js");let n=!1;const s="undefined"==typeof window;function a(){return new Date}exports.IntlProvider=e.IntlProvider,exports.useLocale=t.useLocale,exports.useFormatter=function(){const{formats:e,formatters:n,locale:s,now:a,onError:u,timeZone:l}=t.useIntlContext();return r.useMemo((()=>o.createFormatter({formats:e,locale:s,now:a,onError:u,timeZone:l,_formatters:n})),[e,n,a,s,u,l])},exports.useMessages=function(){const e=t.useIntlContext();if(!e.messages)throw new Error(void 0);return e.messages},exports.useNow=function(e){const o=null==e?void 0:e.updateInterval,{now:n}=t.useIntlContext(),[s,u]=r.useState(n||a());return r.useEffect((()=>{if(!o)return;const e=setInterval((()=>{u(a())}),o);return()=>{clearInterval(e)}}),[n,o]),null==o&&n?n:s},exports.useTimeZone=function(){return t.useIntlContext().timeZone},exports.useTranslations=function(e){return function(e,a,u){const{defaultTranslationValues:l,formats:i,formatters:c,getMessageFallback:m,locale:f,onError:I,timeZone:d}=t.useIntlContext();return e=e[u],a=o.resolveNamespace(a,u),d||n||!s||(n=!0,I(new o.IntlError(o.IntlErrorCode.ENVIRONMENT_FALLBACK,void 0))),r.useMemo((()=>o.createBaseTranslator({formatters:c,getMessageFallback:m,messages:e,defaultTranslationValues:l,namespace:a,onError:I,formats:i,locale:f,timeZone:d})),[c,m,e,l,a,I,i,f,d])}({"!":t.useIntlContext().messages},e?"!.".concat(e):"!","!")}; |
@@ -6,4 +6,4 @@ import { ReactElement, ReactNodeArray } from 'react'; | ||
import IntlError from './IntlError'; | ||
import MessageFormatCache from './MessageFormatCache'; | ||
import TranslationValues, { MarkupTranslationValues, RichTranslationValues } from './TranslationValues'; | ||
import { Formatters } from './formatters'; | ||
import MessageKeys from './utils/MessageKeys'; | ||
@@ -13,3 +13,3 @@ import NestedKeyOf from './utils/NestedKeyOf'; | ||
export type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & { | ||
messageFormatCache?: MessageFormatCache; | ||
formatters: Formatters; | ||
defaultTranslationValues?: RichTranslationValues; | ||
@@ -16,0 +16,0 @@ namespace?: string; |
@@ -8,2 +8,3 @@ import { ReactElement } from 'react'; | ||
import TimeZone from './TimeZone'; | ||
import { Formatters } from './formatters'; | ||
type Props = { | ||
@@ -15,4 +16,6 @@ locale: string; | ||
now?: Date; | ||
/** @private */ | ||
_formatters?: Formatters; | ||
}; | ||
export default function createFormatter({ formats, locale, now: globalNow, onError, timeZone: globalTimeZone }: Props): { | ||
export default function createFormatter({ _formatters: formatters, formats, locale, now: globalNow, onError, timeZone: globalTimeZone }: Props): { | ||
dateTime: (value: Date | number, formatOrOptions?: string | DateTimeFormatOptions) => string; | ||
@@ -19,0 +22,0 @@ number: (value: number | bigint, formatOrOptions?: string | NumberFormatOptions) => string; |
import { ReactElement, ReactNodeArray } from 'react'; | ||
import Formats from './Formats'; | ||
import IntlConfig from './IntlConfig'; | ||
import MessageFormatCache from './MessageFormatCache'; | ||
import TranslationValues, { MarkupTranslationValues, RichTranslationValues } from './TranslationValues'; | ||
import { Formatters } from './formatters'; | ||
import MessageKeys from './utils/MessageKeys'; | ||
@@ -18,7 +18,7 @@ import NamespaceKeys from './utils/NamespaceKeys'; | ||
*/ | ||
export default function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & { | ||
export default function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ _formatters, getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & { | ||
messages?: IntlConfig<IntlMessages>['messages']; | ||
namespace?: NestedKey; | ||
/** @private */ | ||
messageFormatCache?: MessageFormatCache; | ||
_formatters?: Formatters; | ||
}): { | ||
@@ -25,0 +25,0 @@ <TargetKey extends MessageKeys<NestedValueOf<{ |
/// <reference types="react" /> | ||
import AbstractIntlMessages from './AbstractIntlMessages'; | ||
import { InitializedIntlConfig } from './IntlConfig'; | ||
import MessageFormatCache from './MessageFormatCache'; | ||
import { Formatters } from './formatters'; | ||
import NestedKeyOf from './utils/NestedKeyOf'; | ||
@@ -9,5 +9,5 @@ export type CreateTranslatorImplProps<Messages> = Omit<InitializedIntlConfig, 'messages'> & { | ||
messages: Messages; | ||
messageFormatCache?: MessageFormatCache; | ||
formatters: Formatters; | ||
}; | ||
export default function createTranslatorImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ getMessageFallback, messages, namespace, onError, ...rest }: CreateTranslatorImplProps<Messages>, namespacePrefix: string): { | ||
export default function createTranslatorImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ messages, namespace, ...rest }: CreateTranslatorImplProps<Messages>, namespacePrefix: string): { | ||
<TargetKey extends import(".").MessageKeys<import(".").NestedValueOf<Messages, NestedKey>, NestedKeyOf<import(".").NestedValueOf<Messages, NestedKey>>>>(key: TargetKey, values?: import("./TranslationValues").default | undefined, formats?: Partial<import("./Formats").default> | undefined): string; | ||
@@ -14,0 +14,0 @@ rich: (key: string, values?: import("./TranslationValues").RichTranslationValues | undefined, formats?: Partial<import("./Formats").default> | undefined) => string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNodeArray; |
@@ -15,1 +15,2 @@ export type { default as AbstractIntlMessages } from './AbstractIntlMessages'; | ||
export type { default as NestedValueOf } from './utils/NestedValueOf'; | ||
export { createFormatters as _createFormatters } from './formatters'; |
/// <reference types="react" /> | ||
import MessageFormatCache from '../core/MessageFormatCache'; | ||
declare const IntlContext: import("react").Context<(import("../core/IntlConfig").default<import("..").AbstractIntlMessages> & { | ||
onError: (error: import("..").IntlError) => void; | ||
getMessageFallback: (info: { | ||
error: import("..").IntlError; | ||
key: string; | ||
namespace?: string | undefined; | ||
}) => string; | ||
} & { | ||
messageFormatCache?: MessageFormatCache | undefined; | ||
}) | undefined>; | ||
import type { InitializedIntlConfig } from '../core/IntlConfig'; | ||
import type { Formatters } from '../core/formatters'; | ||
export type IntlContextValue = InitializedIntlConfig & { | ||
formatters: Formatters; | ||
}; | ||
declare const IntlContext: import("react").Context<IntlContextValue | undefined>; | ||
export default IntlContext; |
@@ -1,10 +0,2 @@ | ||
export default function useIntlContext(): import("..").IntlConfig<import("..").AbstractIntlMessages> & { | ||
onError: (error: import("..").IntlError) => void; | ||
getMessageFallback: (info: { | ||
error: import("..").IntlError; | ||
key: string; | ||
namespace?: string | undefined; | ||
}) => string; | ||
} & { | ||
messageFormatCache?: import("../core/MessageFormatCache").default | undefined; | ||
}; | ||
import { IntlContextValue } from './IntlContext'; | ||
export default function useIntlContext(): IntlContextValue; |
{ | ||
"name": "use-intl", | ||
"version": "3.16.0", | ||
"version": "3.17.0", | ||
"sideEffects": false, | ||
@@ -66,2 +66,3 @@ "author": "Jan Amann <jan@amann.work>", | ||
"dependencies": { | ||
"@formatjs/fast-memoize": "^2.2.0", | ||
"intl-messageformat": "^10.5.14" | ||
@@ -75,6 +76,6 @@ }, | ||
"path": "dist/production/index.js", | ||
"limit": "15.28 kB" | ||
"limit": "15.545 kB" | ||
} | ||
], | ||
"gitHead": "44a87a4ff07e779df8ac929c0edcf22fb398f576" | ||
"gitHead": "bef3544202e88849646583e63b4751b82d1690a0" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances in 1 package
106164
92
1693
3
6