use-intl 2.17.1 → 2.17.2-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/core/createBaseTranslator.mjs +1 -1
  2. package/dist/core/createFormatter.js +1 -1
  3. package/dist/core/createFormatter.mjs +1 -1
  4. package/dist/core/createIntl.mjs +1 -1
  5. package/dist/core/createTranslator.mjs +1 -1
  6. package/dist/core/createTranslatorImpl.mjs +1 -1
  7. package/dist/core/index.mjs +1 -1
  8. package/dist/core/validateMessages.mjs +1 -1
  9. package/dist/index.mjs +1 -1
  10. package/dist/react/IntlProvider.mjs +1 -1
  11. package/dist/react/getInitializedConfig.mjs +1 -1
  12. package/dist/react/index.mjs +1 -1
  13. package/dist/react/useFormatter.mjs +1 -1
  14. package/dist/react/useIntl.mjs +1 -1
  15. package/dist/react/useIntlContext.mjs +1 -1
  16. package/dist/react/useLocale.mjs +1 -1
  17. package/dist/react/useMessages.mjs +1 -1
  18. package/dist/react/useNow.mjs +1 -1
  19. package/dist/react/useTimeZone.mjs +1 -1
  20. package/dist/react/useTranslations.mjs +1 -1
  21. package/dist/react/useTranslationsImpl.mjs +1 -1
  22. package/dist/src/core/createBaseTranslator.mjs +1 -1
  23. package/dist/src/core/createFormatter.js +1 -1
  24. package/dist/src/core/createFormatter.mjs +1 -1
  25. package/dist/src/core/createIntl.mjs +1 -1
  26. package/dist/src/core/createTranslator.mjs +1 -1
  27. package/dist/src/core/createTranslatorImpl.mjs +1 -1
  28. package/dist/src/core/index.mjs +1 -1
  29. package/dist/src/core/validateMessages.mjs +1 -1
  30. package/dist/src/index.mjs +1 -1
  31. package/dist/src/react/IntlProvider.mjs +1 -1
  32. package/dist/src/react/getInitializedConfig.mjs +1 -1
  33. package/dist/src/react/index.mjs +1 -1
  34. package/dist/src/react/useFormatter.mjs +1 -1
  35. package/dist/src/react/useIntl.mjs +1 -1
  36. package/dist/src/react/useIntlContext.mjs +1 -1
  37. package/dist/src/react/useLocale.mjs +1 -1
  38. package/dist/src/react/useMessages.mjs +1 -1
  39. package/dist/src/react/useNow.mjs +1 -1
  40. package/dist/src/react/useTimeZone.mjs +1 -1
  41. package/dist/src/react/useTranslations.mjs +1 -1
  42. package/dist/src/react/useTranslationsImpl.mjs +1 -1
  43. package/package.json +7 -9
@@ -1,2 +1,2 @@
1
- import y from"intl-messageformat";import{cloneElement as R,isValidElement as v}from"react";import I,{IntlErrorCode as u}from"./IntlError";import w from"./convertFormatsToIntlMessageFormat";import{defaultGetMessageFallback as O,defaultOnError as _}from"./defaults";function A(t,i,f){if(!t)throw new Error(process.env.NODE_ENV!=="production"?`No messages available at \`${f}\`.`:void 0);let n=t;return i.split(".").forEach(s=>{const a=n[s];if(s==null||a==null)throw new Error(process.env.NODE_ENV!=="production"?`Could not resolve \`${i}\` in ${f?`\`${f}\``:"messages"}.`:void 0);n=a}),n}function $(t){if(Object.keys(t).length===0)return;const i={};return Object.keys(t).forEach(f=>{let n=0;const s=t[f];let a;typeof s=="function"?a=o=>{const E=s(o);return v(E)?R(E,{key:f+n++}):E}:a=s,i[f]=a}),i}function tr({messages:t,namespace:i,onError:f=_}){try{if(!t)throw new Error(process.env.NODE_ENV!=="production"?"No messages were configured on the provider.":void 0);const n=i?A(t,i):t;if(!n)throw new Error(process.env.NODE_ENV!=="production"?`No messages for namespace \`${i}\` found.`:void 0);return n}catch(n){const s=new I(u.MISSING_MESSAGE,n.message);return f(s),s}}function b({cachedFormatsByLocale:t,defaultTranslationValues:i,formats:f,getMessageFallback:n=O,locale:s,messagesOrError:a,namespace:o,onError:E,timeZone:T}){function c(r,l,d){const g=new I(l,d);return E(g),n({error:g,key:r,namespace:o})}function S(r,l,d){if(a instanceof I)return n({error:a,key:r,namespace:o});const g=a;let m;try{m=A(g,r,o)}catch(e){return c(r,u.MISSING_MESSAGE,e.message)}function V(e){return e.filter(N=>N!=null).join(".")}const h=V([o,r,String(m)]);let p;if(t?.[s]?.[h])p=t?.[s][h];else{if(typeof m=="object"){let e,N;return Array.isArray(m)?(e=u.INVALID_MESSAGE,process.env.NODE_ENV!=="production"&&(N=`Message at \`${V([o,r])}\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`)):(e=u.INSUFFICIENT_PATH,process.env.NODE_ENV!=="production"&&(N=`Message at \`${V([o,r])}\` resolved to an object, but only strings are supported. Use a \`.\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`)),c(r,e,N)}try{p=new y(m,s,w({...f,...d},T))}catch(e){return c(r,u.INVALID_MESSAGE,e.message)}t&&(t[s]||(t[s]={}),t[s][h]=p)}try{const e=p.format($({...i,...l}));if(e==null)throw new Error(process.env.NODE_ENV!=="production"?`Unable to format \`${r}\` in ${o?`namespace \`${o}\``:"messages"}`:void 0);return v(e)||Array.isArray(e)||typeof e=="string"?e:String(e)}catch(e){return c(r,u.FORMATTING_ERROR,e.message)}}function M(r,l,d){const g=S(r,l,d);return typeof g!="string"?c(r,u.INVALID_MESSAGE,process.env.NODE_ENV!=="production"?`The message \`${r}\` in ${o?`namespace \`${o}\``:"messages"} didn't resolve to a string. If you want to format rich text, use \`t.rich\` instead.`:void 0):g}return M.rich=S,M.raw=r=>{if(a instanceof I)return n({error:a,key:r,namespace:o});const l=a;try{return A(l,r,o)}catch(d){return c(r,u.MISSING_MESSAGE,d.message)}},M}export{b as default,tr as getMessagesOrError};
1
+ import y from"intl-messageformat";import{cloneElement as R,isValidElement as v}from"react";import I,{IntlErrorCode as u}from"./IntlError.mjs";import w from"./convertFormatsToIntlMessageFormat.mjs";import{defaultGetMessageFallback as O,defaultOnError as _}from"./defaults.mjs";function A(t,i,f){if(!t)throw new Error(process.env.NODE_ENV!=="production"?`No messages available at \`${f}\`.`:void 0);let n=t;return i.split(".").forEach(s=>{const a=n[s];if(s==null||a==null)throw new Error(process.env.NODE_ENV!=="production"?`Could not resolve \`${i}\` in ${f?`\`${f}\``:"messages"}.`:void 0);n=a}),n}function $(t){if(Object.keys(t).length===0)return;const i={};return Object.keys(t).forEach(f=>{let n=0;const s=t[f];let a;typeof s=="function"?a=o=>{const E=s(o);return v(E)?R(E,{key:f+n++}):E}:a=s,i[f]=a}),i}function tr({messages:t,namespace:i,onError:f=_}){try{if(!t)throw new Error(process.env.NODE_ENV!=="production"?"No messages were configured on the provider.":void 0);const n=i?A(t,i):t;if(!n)throw new Error(process.env.NODE_ENV!=="production"?`No messages for namespace \`${i}\` found.`:void 0);return n}catch(n){const s=new I(u.MISSING_MESSAGE,n.message);return f(s),s}}function b({cachedFormatsByLocale:t,defaultTranslationValues:i,formats:f,getMessageFallback:n=O,locale:s,messagesOrError:a,namespace:o,onError:E,timeZone:T}){function c(r,l,d){const g=new I(l,d);return E(g),n({error:g,key:r,namespace:o})}function S(r,l,d){if(a instanceof I)return n({error:a,key:r,namespace:o});const g=a;let m;try{m=A(g,r,o)}catch(e){return c(r,u.MISSING_MESSAGE,e.message)}function V(e){return e.filter(N=>N!=null).join(".")}const h=V([o,r,String(m)]);let p;if(t?.[s]?.[h])p=t?.[s][h];else{if(typeof m=="object"){let e,N;return Array.isArray(m)?(e=u.INVALID_MESSAGE,process.env.NODE_ENV!=="production"&&(N=`Message at \`${V([o,r])}\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`)):(e=u.INSUFFICIENT_PATH,process.env.NODE_ENV!=="production"&&(N=`Message at \`${V([o,r])}\` resolved to an object, but only strings are supported. Use a \`.\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`)),c(r,e,N)}try{p=new y(m,s,w({...f,...d},T))}catch(e){return c(r,u.INVALID_MESSAGE,e.message)}t&&(t[s]||(t[s]={}),t[s][h]=p)}try{const e=p.format($({...i,...l}));if(e==null)throw new Error(process.env.NODE_ENV!=="production"?`Unable to format \`${r}\` in ${o?`namespace \`${o}\``:"messages"}`:void 0);return v(e)||Array.isArray(e)||typeof e=="string"?e:String(e)}catch(e){return c(r,u.FORMATTING_ERROR,e.message)}}function M(r,l,d){const g=S(r,l,d);return typeof g!="string"?c(r,u.INVALID_MESSAGE,process.env.NODE_ENV!=="production"?`The message \`${r}\` in ${o?`namespace \`${o}\``:"messages"} didn't resolve to a string. If you want to format rich text, use \`t.rich\` instead.`:void 0):g}return M.rich=S,M.raw=r=>{if(a instanceof I)return n({error:a,key:r,namespace:o});const l=a;try{return A(l,r,o)}catch(d){return c(r,u.MISSING_MESSAGE,d.message)}},M}export{b as default,tr as getMessagesOrError};
2
2
  //# sourceMappingURL=createBaseTranslator.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";var y=Object.create;var p=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var G=(t,r)=>{for(var e in r)p(t,e,{get:r[e],enumerable:!0})},F=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of A(r))!_.call(t,m)&&m!==e&&p(t,m,{get:()=>r[m],enumerable:!(a=V(r,m))||a.enumerable});return t};var P=(t,r,e)=>(e=t!=null?y(S(t)):{},F(r||!t||!t.__esModule?p(e,"default",{value:t,enumerable:!0}):e,t)),U=t=>F(p({},"__esModule",{value:!0}),t);var Z={};G(Z,{default:()=>E});module.exports=U(Z);var s=P(require("./IntlError")),D=require("./defaults");const g=60,T=g*60,c=T*24,O=c*7,h=c*(365/12),b=c*365;function Y(t){const r=Math.abs(t);let e,a;return r<g?(a="second",e=Math.round(t)):r<T?(a="minute",e=Math.round(t/g)):r<c?(a="hour",e=Math.round(t/T)):r<O?(a="day",e=Math.round(t/c)):r<h?(a="week",e=Math.round(t/O)):r<b?(a="month",e=Math.round(t/h)):(a="year",e=Math.round(t/b)),{value:e,unit:a}}function E({formats:t,locale:r,now:e,onError:a=D.defaultOnError,timeZone:m}){function R(o,i){let n;if(typeof i=="string"){const f=i;if(n=o?.[f],!n){const u=new s.default(s.IntlErrorCode.MISSING_FORMAT,process.env.NODE_ENV!=="production"?`Format \`${f}\` is not available. You can configure it on the provider or provide custom options.`:void 0);throw a(u),u}}else n=i;return n}function d(o,i,n,f){let u;try{u=R(n,i)}catch{return String(o)}try{return f(u)}catch(l){return a(new s.default(s.IntlErrorCode.FORMATTING_ERROR,l.message)),String(o)}}function I(o,i){return d(o,i,t?.dateTime,n=>(m&&!n?.timeZone&&(n={...n,timeZone:m}),new Intl.DateTimeFormat(r,n).format(o)))}function w(o,i){return d(o,i,t?.number,n=>new Intl.NumberFormat(r,n).format(o))}function M(o,i){try{if(!i)if(e)i=e;else throw new Error(process.env.NODE_ENV!=="production"?"The `now` parameter wasn't provided and there was no global fallback configured on the provider.":void 0);const n=o instanceof Date?o:new Date(o),f=i instanceof Date?i:new Date(i),u=(n.getTime()-f.getTime())/1e3,{unit:l,value:v}=Y(u);return new Intl.RelativeTimeFormat(r,{numeric:"auto"}).format(v,l)}catch(n){return a(new s.default(s.IntlErrorCode.FORMATTING_ERROR,n.message)),String(o)}}function N(o,i){return d(o,i,t?.list,n=>new Intl.ListFormat(r,n).format(o))}return{dateTime:I,number:w,relativeTime:M,list:N}}
1
+ "use strict";var y=Object.create;var p=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var G=(t,r)=>{for(var e in r)p(t,e,{get:r[e],enumerable:!0})},F=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of A(r))!_.call(t,m)&&m!==e&&p(t,m,{get:()=>r[m],enumerable:!(a=V(r,m))||a.enumerable});return t};var P=(t,r,e)=>(e=t!=null?y(S(t)):{},F(r||!t||!t.__esModule?p(e,"default",{value:t,enumerable:!0}):e,t)),U=t=>F(p({},"__esModule",{value:!0}),t);var Z={};G(Z,{default:()=>E});module.exports=U(Z);var s=P(require("./IntlError")),D=require("./defaults");const g=60,T=g*60,c=T*24,O=c*7,h=c*(365/12),b=c*365;function Y(t){const r=Math.abs(t);let e,a;return r<g?(a="second",e=Math.round(t)):r<T?(a="minute",e=Math.round(t/g)):r<c?(a="hour",e=Math.round(t/T)):r<O?(a="day",e=Math.round(t/c)):r<h?(a="week",e=Math.round(t/O)):r<b?(a="month",e=Math.round(t/h)):(a="year",e=Math.round(t/b)),{value:e,unit:a}}function E({formats:t,locale:r,now:e,onError:a=D.defaultOnError,timeZone:m}){function R(o,i){let n;if(typeof i=="string"){const f=i;if(n=o?.[f],!n){const u=new s.default(s.IntlErrorCode.MISSING_FORMAT,process.env.NODE_ENV!=="production"?`Format \`${f}\` is not available. You can configure it on the provider or provide custom options.`:void 0);throw (a(u), u)}}else n=i;return n}function d(o,i,n,f){let u;try{u=R(n,i)}catch{return String(o)}try{return f(u)}catch(l){return a(new s.default(s.IntlErrorCode.FORMATTING_ERROR,l.message)),String(o)}}function I(o,i){return d(o,i,t?.dateTime,n=>(m&&!n?.timeZone&&(n={...n,timeZone:m}),new Intl.DateTimeFormat(r,n).format(o)))}function w(o,i){return d(o,i,t?.number,n=>new Intl.NumberFormat(r,n).format(o))}function M(o,i){try{if(!i)if(e)i=e;else throw new Error(process.env.NODE_ENV!=="production"?"The `now` parameter wasn't provided and there was no global fallback configured on the provider.":void 0);const n=o instanceof Date?o:new Date(o),f=i instanceof Date?i:new Date(i),u=(n.getTime()-f.getTime())/1e3,{unit:l,value:v}=Y(u);return new Intl.RelativeTimeFormat(r,{numeric:"auto"}).format(v,l)}catch(n){return a(new s.default(s.IntlErrorCode.FORMATTING_ERROR,n.message)),String(o)}}function N(o,i){return d(o,i,t?.list,n=>new Intl.ListFormat(r,n).format(o))}return{dateTime:I,number:w,relativeTime:M,list:N}}
2
2
  //# sourceMappingURL=createFormatter.js.map
@@ -1,2 +1,2 @@
1
- import l,{IntlErrorCode as p}from"./IntlError";import{defaultOnError as M}from"./defaults";const d=60,g=d*60,u=g*24,F=u*7,O=u*(365/12),h=u*365;function N(n){const i=Math.abs(n);let a,o;return i<d?(o="second",a=Math.round(n)):i<g?(o="minute",a=Math.round(n/d)):i<u?(o="hour",a=Math.round(n/g)):i<F?(o="day",a=Math.round(n/u)):i<O?(o="week",a=Math.round(n/F)):i<h?(o="month",a=Math.round(n/O)):(o="year",a=Math.round(n/h)),{value:a,unit:o}}function v({formats:n,locale:i,now:a,onError:o=M,timeZone:T}){function b(r,e){let t;if(typeof e=="string"){const s=e;if(t=r?.[s],!t){const m=new l(p.MISSING_FORMAT,process.env.NODE_ENV!=="production"?`Format \`${s}\` is not available. You can configure it on the provider or provide custom options.`:void 0);throw o(m),m}}else t=e;return t}function c(r,e,t,s){let m;try{m=b(t,e)}catch{return String(r)}try{return s(m)}catch(f){return o(new l(p.FORMATTING_ERROR,f.message)),String(r)}}function D(r,e){return c(r,e,n?.dateTime,t=>(T&&!t?.timeZone&&(t={...t,timeZone:T}),new Intl.DateTimeFormat(i,t).format(r)))}function E(r,e){return c(r,e,n?.number,t=>new Intl.NumberFormat(i,t).format(r))}function R(r,e){try{if(!e)if(a)e=a;else throw new Error(process.env.NODE_ENV!=="production"?"The `now` parameter wasn't provided and there was no global fallback configured on the provider.":void 0);const t=r instanceof Date?r:new Date(r),s=e instanceof Date?e:new Date(e),m=(t.getTime()-s.getTime())/1e3,{unit:f,value:w}=N(m);return new Intl.RelativeTimeFormat(i,{numeric:"auto"}).format(w,f)}catch(t){return o(new l(p.FORMATTING_ERROR,t.message)),String(r)}}function I(r,e){return c(r,e,n?.list,t=>new Intl.ListFormat(i,t).format(r))}return{dateTime:D,number:E,relativeTime:R,list:I}}export{v as default};
1
+ import l,{IntlErrorCode as p}from"./IntlError.mjs";import{defaultOnError as M}from"./defaults.mjs";const d=60,g=d*60,u=g*24,F=u*7,O=u*(365/12),h=u*365;function N(n){const i=Math.abs(n);let a,o;return i<d?(o="second",a=Math.round(n)):i<g?(o="minute",a=Math.round(n/d)):i<u?(o="hour",a=Math.round(n/g)):i<F?(o="day",a=Math.round(n/u)):i<O?(o="week",a=Math.round(n/F)):i<h?(o="month",a=Math.round(n/O)):(o="year",a=Math.round(n/h)),{value:a,unit:o}}function v({formats:n,locale:i,now:a,onError:o=M,timeZone:T}){function b(r,e){let t;if(typeof e=="string"){const s=e;if(t=r?.[s],!t){const m=new l(p.MISSING_FORMAT,process.env.NODE_ENV!=="production"?`Format \`${s}\` is not available. You can configure it on the provider or provide custom options.`:void 0);throw (o(m), m)}}else t=e;return t}function c(r,e,t,s){let m;try{m=b(t,e)}catch{return String(r)}try{return s(m)}catch(f){return o(new l(p.FORMATTING_ERROR,f.message)),String(r)}}function D(r,e){return c(r,e,n?.dateTime,t=>(T&&!t?.timeZone&&(t={...t,timeZone:T}),new Intl.DateTimeFormat(i,t).format(r)))}function E(r,e){return c(r,e,n?.number,t=>new Intl.NumberFormat(i,t).format(r))}function R(r,e){try{if(!e)if(a)e=a;else throw new Error(process.env.NODE_ENV!=="production"?"The `now` parameter wasn't provided and there was no global fallback configured on the provider.":void 0);const t=r instanceof Date?r:new Date(r),s=e instanceof Date?e:new Date(e),m=(t.getTime()-s.getTime())/1e3,{unit:f,value:w}=N(m);return new Intl.RelativeTimeFormat(i,{numeric:"auto"}).format(w,f)}catch(t){return o(new l(p.FORMATTING_ERROR,t.message)),String(r)}}function I(r,e){return c(r,e,n?.list,t=>new Intl.ListFormat(i,t).format(r))}return{dateTime:D,number:E,relativeTime:R,list:I}}export{v as default};
2
2
  //# sourceMappingURL=createFormatter.mjs.map
@@ -1,2 +1,2 @@
1
- import r from"./createFormatter";function a(...t){const e=r(...t);return{formatDateTime:e.dateTime,formatNumber:e.number,formatRelativeTime:e.relativeTime}}export{a as default};
1
+ import r from"./createFormatter.mjs";function a(...t){const e=r(...t);return{formatDateTime:e.dateTime,formatNumber:e.number,formatRelativeTime:e.relativeTime}}export{a as default};
2
2
  //# sourceMappingURL=createIntl.mjs.map
@@ -1,2 +1,2 @@
1
- import n from"./createTranslatorImpl";import{defaultGetMessageFallback as l,defaultOnError as d}from"./defaults";function o({getMessageFallback:s=l,messages:t,namespace:e,onError:a=d,...r}){return n({...r,onError:a,getMessageFallback:s,messages:{"!":t},namespace:e?`!.${e}`:"!"},"!")}export{o as default};
1
+ import n from"./createTranslatorImpl.mjs";import{defaultGetMessageFallback as l,defaultOnError as d}from"./defaults.mjs";function o({getMessageFallback:s=l,messages:t,namespace:e,onError:a=d,...r}){return n({...r,onError:a,getMessageFallback:s,messages:{"!":t},namespace:e?`!.${e}`:"!"},"!")}export{o as default};
2
2
  //# sourceMappingURL=createTranslator.mjs.map
@@ -1,2 +1,2 @@
1
- import u,{IntlErrorCode as d}from"./IntlError";import h,{getMessagesOrError as I}from"./createBaseTranslator";import T from"./resolveNamespace";function R({getMessageFallback:o,messages:s,namespace:r,onError:t,...g},i){s=s[i],r=T(r,i);const a=h({...g,onError:t,getMessageFallback:o,messagesOrError:I({messages:s,namespace:r,onError:t})}),f=a.rich;function n(...e){return a(...e)}return n.rich=(e,p,m)=>{const l=f(e,p,m);if(typeof l!="string"){const c=new u(d.FORMATTING_ERROR,process.env.NODE_ENV!=="production"?"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})":void 0);return t(c),o({error:c,key:e,namespace:r})}return l},n.raw=a.raw,n}export{R as default};
1
+ import u,{IntlErrorCode as d}from"./IntlError.mjs";import h,{getMessagesOrError as I}from"./createBaseTranslator.mjs";import T from"./resolveNamespace.mjs";function R({getMessageFallback:o,messages:s,namespace:r,onError:t,...g},i){s=s[i],r=T(r,i);const a=h({...g,onError:t,getMessageFallback:o,messagesOrError:I({messages:s,namespace:r,onError:t})}),f=a.rich;function n(...e){return a(...e)}return n.rich=(e,p,m)=>{const l=f(e,p,m);if(typeof l!="string"){const c=new u(d.FORMATTING_ERROR,process.env.NODE_ENV!=="production"?"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})":void 0);return t(c),o({error:c,key:e,namespace:r})}return l},n.raw=a.raw,n}export{R as default};
2
2
  //# sourceMappingURL=createTranslatorImpl.mjs.map
@@ -1,2 +1,2 @@
1
- import{default as e,IntlErrorCode as r}from"./IntlError";import{default as s}from"./createTranslator";import{default as m}from"./createFormatter";import{default as p}from"./createIntl";export{e as IntlError,r as IntlErrorCode,m as createFormatter,p as createIntl,s as createTranslator};
1
+ import{default as e,IntlErrorCode as r}from"./IntlError.mjs";import{default as s}from"./createTranslator.mjs";import{default as m}from"./createFormatter.mjs";import{default as p}from"./createIntl.mjs";export{e as IntlError,r as IntlErrorCode,m as createFormatter,p as createIntl,s as createTranslator};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,4 +1,4 @@
1
- import a,{IntlErrorCode as c}from"./IntlError";function i(n,t,e){Object.entries(n).forEach(([r,s])=>{if(r.includes(".")){let o=r;e&&(o+=` (at ${e})`),t.push(o)}s!=null&&typeof s=="object"&&i(s,t,[e,r].filter(o=>o!=null).join("."))})}function l(n,t){const e=[];i(n,e),e.length>0&&t(new a(c.INVALID_KEY,process.env.NODE_ENV!=="production"?`Namespace keys can not contain the character "." as this is used to express nesting. Please remove it or replace it with another character.
1
+ import a,{IntlErrorCode as c}from"./IntlError.mjs";function i(n,t,e){Object.entries(n).forEach(([r,s])=>{if(r.includes(".")){let o=r;e&&(o+=` (at ${e})`),t.push(o)}s!=null&&typeof s=="object"&&i(s,t,[e,r].filter(o=>o!=null).join("."))})}function l(n,t){const e=[];i(n,e),e.length>0&&t(new a(c.INVALID_KEY,process.env.NODE_ENV!=="production"?`Namespace keys can not contain the character "." as this is used to express nesting. Please remove it or replace it with another character.
2
2
 
3
3
  Invalid ${e.length===1?"key":"keys"}: ${e.join(", ")}
4
4
 
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export*from"./core";export*from"./react";
1
+ export*from"./core/index.mjs";export*from"./react/index.mjs";
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,2 +1,2 @@
1
- import r from"react";import e from"./IntlContext";import i from"./getInitializedConfig";function n({children:o,...t}){return r.createElement(e.Provider,{value:i(t)},o)}export{n as default};
1
+ import r from"react";import e from"./IntlContext.mjs";import i from"./getInitializedConfig.mjs";function n({children:o,...t}){return r.createElement(e.Provider,{value:i(t)},o)}export{n as default};
2
2
  //# sourceMappingURL=IntlProvider.mjs.map
@@ -1,2 +1,2 @@
1
- import{defaultGetMessageFallback as a,defaultOnError as l}from"../core/defaults";import f from"../core/validateMessages";function s({getMessageFallback:t,messages:r,onError:e,...n}){const o=e||l,i=t||a;return process.env.NODE_ENV!=="production"&&r&&f(r,o),{...n,messages:r,onError:o,getMessageFallback:i}}export{s as default};
1
+ import{defaultGetMessageFallback as a,defaultOnError as l}from"../core/defaults.mjs";import f from"../core/validateMessages.mjs";function s({getMessageFallback:t,messages:r,onError:e,...n}){const o=e||l,i=t||a;return process.env.NODE_ENV!=="production"&&r&&f(r,o),{...n,messages:r,onError:o,getMessageFallback:i}}export{s as default};
2
2
  //# sourceMappingURL=getInitializedConfig.mjs.map
@@ -1,2 +1,2 @@
1
- import{default as a}from"./IntlProvider";import{default as t}from"./useTranslations";import{default as f}from"./useLocale";import{default as l}from"./useNow";import{default as d}from"./useTimeZone";import{default as x}from"./useMessages";import{default as i}from"./useFormatter";import{default as T}from"./useIntl";export{a as IntlProvider,i as useFormatter,T as useIntl,f as useLocale,x as useMessages,l as useNow,d as useTimeZone,t as useTranslations};
1
+ import{default as a}from"./IntlProvider.mjs";import{default as t}from"./useTranslations.mjs";import{default as f}from"./useLocale.mjs";import{default as l}from"./useNow.mjs";import{default as d}from"./useTimeZone.mjs";import{default as x}from"./useMessages.mjs";import{default as i}from"./useFormatter.mjs";import{default as T}from"./useIntl.mjs";export{a as IntlProvider,i as useFormatter,T as useIntl,f as useLocale,x as useMessages,l as useNow,d as useTimeZone,t as useTranslations};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,2 +1,2 @@
1
- import{useMemo as n}from"react";import a from"../core/createFormatter";import f from"./useIntlContext";function l(){const{formats:o,locale:r,now:t,onError:e,timeZone:m}=f();return n(()=>a({formats:o,locale:r,now:t,onError:e,timeZone:m}),[o,t,r,e,m])}export{l as default};
1
+ import{useMemo as n}from"react";import a from"../core/createFormatter.mjs";import f from"./useIntlContext.mjs";function l(){const{formats:o,locale:r,now:t,onError:e,timeZone:m}=f();return n(()=>a({formats:o,locale:r,now:t,onError:e,timeZone:m}),[o,t,r,e,m])}export{l as default};
2
2
  //# sourceMappingURL=useFormatter.mjs.map
@@ -1,2 +1,2 @@
1
- import{useMemo as a}from"react";import s from"../core/createIntl";import m from"./useIntlContext";let l=!1;function i(){const{formats:e,locale:o,now:t,onError:r,timeZone:n}=m();return l||(l=!0,console.warn("`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.")),a(()=>s({formats:e,locale:o,now:t,onError:r,timeZone:n}),[e,t,o,r,n])}export{i as default};
1
+ import{useMemo as a}from"react";import s from"../core/createIntl.mjs";import m from"./useIntlContext.mjs";let l=!1;function i(){const{formats:e,locale:o,now:t,onError:r,timeZone:n}=m();return l||(l=!0,console.warn("`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.")),a(()=>s({formats:e,locale:o,now:t,onError:r,timeZone:n}),[e,t,o,r,n])}export{i as default};
2
2
  //# sourceMappingURL=useIntl.mjs.map
@@ -1,2 +1,2 @@
1
- import{useContext as o}from"react";import e from"./IntlContext";function n(){const t=o(e);if(!t)throw new Error(process.env.NODE_ENV!=="production"?"No intl context found. Have you configured the provider?":void 0);return t}export{n as default};
1
+ import{useContext as o}from"react";import e from"./IntlContext.mjs";function n(){const t=o(e);if(!t)throw new Error(process.env.NODE_ENV!=="production"?"No intl context found. Have you configured the provider?":void 0);return t}export{n as default};
2
2
  //# sourceMappingURL=useIntlContext.mjs.map
@@ -1,2 +1,2 @@
1
- import e from"./useIntlContext";function t(){return e().locale}export{t as default};
1
+ import e from"./useIntlContext.mjs";function t(){return e().locale}export{t as default};
2
2
  //# sourceMappingURL=useLocale.mjs.map
@@ -1,2 +1,2 @@
1
- import e from"./useIntlContext";function s(){return e().messages}export{s as default};
1
+ import e from"./useIntlContext.mjs";function s(){return e().messages}export{s as default};
2
2
  //# sourceMappingURL=useMessages.mjs.map
@@ -1,2 +1,2 @@
1
- import{useState as s,useEffect as l}from"react";import p from"./useIntlContext";function n(){return new Date}function c(o){const t=o?.updateInterval,{now:e}=p(),[r,u]=s(e||n());return l(()=>{if(!t)return;const a=setInterval(()=>{u(n())},t);return()=>{clearInterval(a)}},[e,t]),r}export{c as default};
1
+ import{useState as s,useEffect as l}from"react";import p from"./useIntlContext.mjs";function n(){return new Date}function c(o){const t=o?.updateInterval,{now:e}=p(),[r,u]=s(e||n());return l(()=>{if(!t)return;const a=setInterval(()=>{u(n())},t);return()=>{clearInterval(a)}},[e,t]),r}export{c as default};
2
2
  //# sourceMappingURL=useNow.mjs.map
@@ -1,2 +1,2 @@
1
- import e from"./useIntlContext";function t(){return e().timeZone}export{t as default};
1
+ import e from"./useIntlContext.mjs";function t(){return e().timeZone}export{t as default};
2
2
  //# sourceMappingURL=useTimeZone.mjs.map
@@ -1,2 +1,2 @@
1
- import t from"./useIntlContext";import a from"./useTranslationsImpl";function r(e){const s=t().messages;return a({"!":s},e?`!.${e}`:"!","!")}export{r as default};
1
+ import t from"./useIntlContext.mjs";import a from"./useTranslationsImpl.mjs";function r(e){const s=t().messages;return a({"!":s},e?`!.${e}`:"!","!")}export{r as default};
2
2
  //# sourceMappingURL=useTranslations.mjs.map
@@ -1,2 +1,2 @@
1
- import{useMemo as g,useRef as d}from"react";import i,{getMessagesOrError as u}from"../core/createBaseTranslator";import M from"../core/resolveNamespace";import y from"./useIntlContext";function F(t,e,r){const{defaultTranslationValues:o,formats:a,getMessageFallback:n,locale:m,onError:s,timeZone:l}=y();t=t[r],e=M(e,r);const c=d({}),f=g(()=>u({messages:t,namespace:e,onError:s}),[t,e,s]);return g(()=>i({cachedFormatsByLocale:c.current,getMessageFallback:n,messagesOrError:f,defaultTranslationValues:o,namespace:e,onError:s,formats:a,locale:m,timeZone:l}),[n,f,o,e,s,a,m,l])}export{F as default};
1
+ import{useMemo as g,useRef as d}from"react";import i,{getMessagesOrError as u}from"../core/createBaseTranslator.mjs";import M from"../core/resolveNamespace.mjs";import y from"./useIntlContext.mjs";function F(t,e,r){const{defaultTranslationValues:o,formats:a,getMessageFallback:n,locale:m,onError:s,timeZone:l}=y();t=t[r],e=M(e,r);const c=d({}),f=g(()=>u({messages:t,namespace:e,onError:s}),[t,e,s]);return g(()=>i({cachedFormatsByLocale:c.current,getMessageFallback:n,messagesOrError:f,defaultTranslationValues:o,namespace:e,onError:s,formats:a,locale:m,timeZone:l}),[n,f,o,e,s,a,m,l])}export{F as default};
2
2
  //# sourceMappingURL=useTranslationsImpl.mjs.map
@@ -1,2 +1,2 @@
1
- import y from"intl-messageformat";import{cloneElement as R,isValidElement as v}from"react";import I,{IntlErrorCode as u}from"./IntlError";import w from"./convertFormatsToIntlMessageFormat";import{defaultGetMessageFallback as O,defaultOnError as _}from"./defaults";function A(t,i,f){if(!t)throw new Error(process.env.NODE_ENV!=="production"?`No messages available at \`${f}\`.`:void 0);let n=t;return i.split(".").forEach(s=>{const a=n[s];if(s==null||a==null)throw new Error(process.env.NODE_ENV!=="production"?`Could not resolve \`${i}\` in ${f?`\`${f}\``:"messages"}.`:void 0);n=a}),n}function $(t){if(Object.keys(t).length===0)return;const i={};return Object.keys(t).forEach(f=>{let n=0;const s=t[f];let a;typeof s=="function"?a=o=>{const E=s(o);return v(E)?R(E,{key:f+n++}):E}:a=s,i[f]=a}),i}function tr({messages:t,namespace:i,onError:f=_}){try{if(!t)throw new Error(process.env.NODE_ENV!=="production"?"No messages were configured on the provider.":void 0);const n=i?A(t,i):t;if(!n)throw new Error(process.env.NODE_ENV!=="production"?`No messages for namespace \`${i}\` found.`:void 0);return n}catch(n){const s=new I(u.MISSING_MESSAGE,n.message);return f(s),s}}function b({cachedFormatsByLocale:t,defaultTranslationValues:i,formats:f,getMessageFallback:n=O,locale:s,messagesOrError:a,namespace:o,onError:E,timeZone:T}){function c(r,l,d){const g=new I(l,d);return E(g),n({error:g,key:r,namespace:o})}function S(r,l,d){if(a instanceof I)return n({error:a,key:r,namespace:o});const g=a;let m;try{m=A(g,r,o)}catch(e){return c(r,u.MISSING_MESSAGE,e.message)}function V(e){return e.filter(N=>N!=null).join(".")}const h=V([o,r,String(m)]);let p;if(t?.[s]?.[h])p=t?.[s][h];else{if(typeof m=="object"){let e,N;return Array.isArray(m)?(e=u.INVALID_MESSAGE,process.env.NODE_ENV!=="production"&&(N=`Message at \`${V([o,r])}\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`)):(e=u.INSUFFICIENT_PATH,process.env.NODE_ENV!=="production"&&(N=`Message at \`${V([o,r])}\` resolved to an object, but only strings are supported. Use a \`.\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`)),c(r,e,N)}try{p=new y(m,s,w({...f,...d},T))}catch(e){return c(r,u.INVALID_MESSAGE,e.message)}t&&(t[s]||(t[s]={}),t[s][h]=p)}try{const e=p.format($({...i,...l}));if(e==null)throw new Error(process.env.NODE_ENV!=="production"?`Unable to format \`${r}\` in ${o?`namespace \`${o}\``:"messages"}`:void 0);return v(e)||Array.isArray(e)||typeof e=="string"?e:String(e)}catch(e){return c(r,u.FORMATTING_ERROR,e.message)}}function M(r,l,d){const g=S(r,l,d);return typeof g!="string"?c(r,u.INVALID_MESSAGE,process.env.NODE_ENV!=="production"?`The message \`${r}\` in ${o?`namespace \`${o}\``:"messages"} didn't resolve to a string. If you want to format rich text, use \`t.rich\` instead.`:void 0):g}return M.rich=S,M.raw=r=>{if(a instanceof I)return n({error:a,key:r,namespace:o});const l=a;try{return A(l,r,o)}catch(d){return c(r,u.MISSING_MESSAGE,d.message)}},M}export{b as default,tr as getMessagesOrError};
1
+ import y from"intl-messageformat";import{cloneElement as R,isValidElement as v}from"react";import I,{IntlErrorCode as u}from"./IntlError.mjs";import w from"./convertFormatsToIntlMessageFormat.mjs";import{defaultGetMessageFallback as O,defaultOnError as _}from"./defaults.mjs";function A(t,i,f){if(!t)throw new Error(process.env.NODE_ENV!=="production"?`No messages available at \`${f}\`.`:void 0);let n=t;return i.split(".").forEach(s=>{const a=n[s];if(s==null||a==null)throw new Error(process.env.NODE_ENV!=="production"?`Could not resolve \`${i}\` in ${f?`\`${f}\``:"messages"}.`:void 0);n=a}),n}function $(t){if(Object.keys(t).length===0)return;const i={};return Object.keys(t).forEach(f=>{let n=0;const s=t[f];let a;typeof s=="function"?a=o=>{const E=s(o);return v(E)?R(E,{key:f+n++}):E}:a=s,i[f]=a}),i}function tr({messages:t,namespace:i,onError:f=_}){try{if(!t)throw new Error(process.env.NODE_ENV!=="production"?"No messages were configured on the provider.":void 0);const n=i?A(t,i):t;if(!n)throw new Error(process.env.NODE_ENV!=="production"?`No messages for namespace \`${i}\` found.`:void 0);return n}catch(n){const s=new I(u.MISSING_MESSAGE,n.message);return f(s),s}}function b({cachedFormatsByLocale:t,defaultTranslationValues:i,formats:f,getMessageFallback:n=O,locale:s,messagesOrError:a,namespace:o,onError:E,timeZone:T}){function c(r,l,d){const g=new I(l,d);return E(g),n({error:g,key:r,namespace:o})}function S(r,l,d){if(a instanceof I)return n({error:a,key:r,namespace:o});const g=a;let m;try{m=A(g,r,o)}catch(e){return c(r,u.MISSING_MESSAGE,e.message)}function V(e){return e.filter(N=>N!=null).join(".")}const h=V([o,r,String(m)]);let p;if(t?.[s]?.[h])p=t?.[s][h];else{if(typeof m=="object"){let e,N;return Array.isArray(m)?(e=u.INVALID_MESSAGE,process.env.NODE_ENV!=="production"&&(N=`Message at \`${V([o,r])}\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`)):(e=u.INSUFFICIENT_PATH,process.env.NODE_ENV!=="production"&&(N=`Message at \`${V([o,r])}\` resolved to an object, but only strings are supported. Use a \`.\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`)),c(r,e,N)}try{p=new y(m,s,w({...f,...d},T))}catch(e){return c(r,u.INVALID_MESSAGE,e.message)}t&&(t[s]||(t[s]={}),t[s][h]=p)}try{const e=p.format($({...i,...l}));if(e==null)throw new Error(process.env.NODE_ENV!=="production"?`Unable to format \`${r}\` in ${o?`namespace \`${o}\``:"messages"}`:void 0);return v(e)||Array.isArray(e)||typeof e=="string"?e:String(e)}catch(e){return c(r,u.FORMATTING_ERROR,e.message)}}function M(r,l,d){const g=S(r,l,d);return typeof g!="string"?c(r,u.INVALID_MESSAGE,process.env.NODE_ENV!=="production"?`The message \`${r}\` in ${o?`namespace \`${o}\``:"messages"} didn't resolve to a string. If you want to format rich text, use \`t.rich\` instead.`:void 0):g}return M.rich=S,M.raw=r=>{if(a instanceof I)return n({error:a,key:r,namespace:o});const l=a;try{return A(l,r,o)}catch(d){return c(r,u.MISSING_MESSAGE,d.message)}},M}export{b as default,tr as getMessagesOrError};
2
2
  //# sourceMappingURL=createBaseTranslator.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";var y=Object.create;var p=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var G=(t,r)=>{for(var e in r)p(t,e,{get:r[e],enumerable:!0})},F=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of A(r))!_.call(t,m)&&m!==e&&p(t,m,{get:()=>r[m],enumerable:!(a=V(r,m))||a.enumerable});return t};var P=(t,r,e)=>(e=t!=null?y(S(t)):{},F(r||!t||!t.__esModule?p(e,"default",{value:t,enumerable:!0}):e,t)),U=t=>F(p({},"__esModule",{value:!0}),t);var Z={};G(Z,{default:()=>E});module.exports=U(Z);var s=P(require("./IntlError")),D=require("./defaults");const g=60,T=g*60,c=T*24,O=c*7,h=c*(365/12),b=c*365;function Y(t){const r=Math.abs(t);let e,a;return r<g?(a="second",e=Math.round(t)):r<T?(a="minute",e=Math.round(t/g)):r<c?(a="hour",e=Math.round(t/T)):r<O?(a="day",e=Math.round(t/c)):r<h?(a="week",e=Math.round(t/O)):r<b?(a="month",e=Math.round(t/h)):(a="year",e=Math.round(t/b)),{value:e,unit:a}}function E({formats:t,locale:r,now:e,onError:a=D.defaultOnError,timeZone:m}){function R(o,i){let n;if(typeof i=="string"){const f=i;if(n=o?.[f],!n){const u=new s.default(s.IntlErrorCode.MISSING_FORMAT,process.env.NODE_ENV!=="production"?`Format \`${f}\` is not available. You can configure it on the provider or provide custom options.`:void 0);throw a(u),u}}else n=i;return n}function d(o,i,n,f){let u;try{u=R(n,i)}catch{return String(o)}try{return f(u)}catch(l){return a(new s.default(s.IntlErrorCode.FORMATTING_ERROR,l.message)),String(o)}}function I(o,i){return d(o,i,t?.dateTime,n=>(m&&!n?.timeZone&&(n={...n,timeZone:m}),new Intl.DateTimeFormat(r,n).format(o)))}function w(o,i){return d(o,i,t?.number,n=>new Intl.NumberFormat(r,n).format(o))}function M(o,i){try{if(!i)if(e)i=e;else throw new Error(process.env.NODE_ENV!=="production"?"The `now` parameter wasn't provided and there was no global fallback configured on the provider.":void 0);const n=o instanceof Date?o:new Date(o),f=i instanceof Date?i:new Date(i),u=(n.getTime()-f.getTime())/1e3,{unit:l,value:v}=Y(u);return new Intl.RelativeTimeFormat(r,{numeric:"auto"}).format(v,l)}catch(n){return a(new s.default(s.IntlErrorCode.FORMATTING_ERROR,n.message)),String(o)}}function N(o,i){return d(o,i,t?.list,n=>new Intl.ListFormat(r,n).format(o))}return{dateTime:I,number:w,relativeTime:M,list:N}}
1
+ "use strict";var y=Object.create;var p=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var G=(t,r)=>{for(var e in r)p(t,e,{get:r[e],enumerable:!0})},F=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of A(r))!_.call(t,m)&&m!==e&&p(t,m,{get:()=>r[m],enumerable:!(a=V(r,m))||a.enumerable});return t};var P=(t,r,e)=>(e=t!=null?y(S(t)):{},F(r||!t||!t.__esModule?p(e,"default",{value:t,enumerable:!0}):e,t)),U=t=>F(p({},"__esModule",{value:!0}),t);var Z={};G(Z,{default:()=>E});module.exports=U(Z);var s=P(require("./IntlError")),D=require("./defaults");const g=60,T=g*60,c=T*24,O=c*7,h=c*(365/12),b=c*365;function Y(t){const r=Math.abs(t);let e,a;return r<g?(a="second",e=Math.round(t)):r<T?(a="minute",e=Math.round(t/g)):r<c?(a="hour",e=Math.round(t/T)):r<O?(a="day",e=Math.round(t/c)):r<h?(a="week",e=Math.round(t/O)):r<b?(a="month",e=Math.round(t/h)):(a="year",e=Math.round(t/b)),{value:e,unit:a}}function E({formats:t,locale:r,now:e,onError:a=D.defaultOnError,timeZone:m}){function R(o,i){let n;if(typeof i=="string"){const f=i;if(n=o?.[f],!n){const u=new s.default(s.IntlErrorCode.MISSING_FORMAT,process.env.NODE_ENV!=="production"?`Format \`${f}\` is not available. You can configure it on the provider or provide custom options.`:void 0);throw (a(u), u)}}else n=i;return n}function d(o,i,n,f){let u;try{u=R(n,i)}catch{return String(o)}try{return f(u)}catch(l){return a(new s.default(s.IntlErrorCode.FORMATTING_ERROR,l.message)),String(o)}}function I(o,i){return d(o,i,t?.dateTime,n=>(m&&!n?.timeZone&&(n={...n,timeZone:m}),new Intl.DateTimeFormat(r,n).format(o)))}function w(o,i){return d(o,i,t?.number,n=>new Intl.NumberFormat(r,n).format(o))}function M(o,i){try{if(!i)if(e)i=e;else throw new Error(process.env.NODE_ENV!=="production"?"The `now` parameter wasn't provided and there was no global fallback configured on the provider.":void 0);const n=o instanceof Date?o:new Date(o),f=i instanceof Date?i:new Date(i),u=(n.getTime()-f.getTime())/1e3,{unit:l,value:v}=Y(u);return new Intl.RelativeTimeFormat(r,{numeric:"auto"}).format(v,l)}catch(n){return a(new s.default(s.IntlErrorCode.FORMATTING_ERROR,n.message)),String(o)}}function N(o,i){return d(o,i,t?.list,n=>new Intl.ListFormat(r,n).format(o))}return{dateTime:I,number:w,relativeTime:M,list:N}}
2
2
  //# sourceMappingURL=createFormatter.js.map
@@ -1,2 +1,2 @@
1
- import l,{IntlErrorCode as p}from"./IntlError";import{defaultOnError as M}from"./defaults";const d=60,g=d*60,u=g*24,F=u*7,O=u*(365/12),h=u*365;function N(n){const i=Math.abs(n);let a,o;return i<d?(o="second",a=Math.round(n)):i<g?(o="minute",a=Math.round(n/d)):i<u?(o="hour",a=Math.round(n/g)):i<F?(o="day",a=Math.round(n/u)):i<O?(o="week",a=Math.round(n/F)):i<h?(o="month",a=Math.round(n/O)):(o="year",a=Math.round(n/h)),{value:a,unit:o}}function v({formats:n,locale:i,now:a,onError:o=M,timeZone:T}){function b(r,e){let t;if(typeof e=="string"){const s=e;if(t=r?.[s],!t){const m=new l(p.MISSING_FORMAT,process.env.NODE_ENV!=="production"?`Format \`${s}\` is not available. You can configure it on the provider or provide custom options.`:void 0);throw o(m),m}}else t=e;return t}function c(r,e,t,s){let m;try{m=b(t,e)}catch{return String(r)}try{return s(m)}catch(f){return o(new l(p.FORMATTING_ERROR,f.message)),String(r)}}function D(r,e){return c(r,e,n?.dateTime,t=>(T&&!t?.timeZone&&(t={...t,timeZone:T}),new Intl.DateTimeFormat(i,t).format(r)))}function E(r,e){return c(r,e,n?.number,t=>new Intl.NumberFormat(i,t).format(r))}function R(r,e){try{if(!e)if(a)e=a;else throw new Error(process.env.NODE_ENV!=="production"?"The `now` parameter wasn't provided and there was no global fallback configured on the provider.":void 0);const t=r instanceof Date?r:new Date(r),s=e instanceof Date?e:new Date(e),m=(t.getTime()-s.getTime())/1e3,{unit:f,value:w}=N(m);return new Intl.RelativeTimeFormat(i,{numeric:"auto"}).format(w,f)}catch(t){return o(new l(p.FORMATTING_ERROR,t.message)),String(r)}}function I(r,e){return c(r,e,n?.list,t=>new Intl.ListFormat(i,t).format(r))}return{dateTime:D,number:E,relativeTime:R,list:I}}export{v as default};
1
+ import l,{IntlErrorCode as p}from"./IntlError.mjs";import{defaultOnError as M}from"./defaults.mjs";const d=60,g=d*60,u=g*24,F=u*7,O=u*(365/12),h=u*365;function N(n){const i=Math.abs(n);let a,o;return i<d?(o="second",a=Math.round(n)):i<g?(o="minute",a=Math.round(n/d)):i<u?(o="hour",a=Math.round(n/g)):i<F?(o="day",a=Math.round(n/u)):i<O?(o="week",a=Math.round(n/F)):i<h?(o="month",a=Math.round(n/O)):(o="year",a=Math.round(n/h)),{value:a,unit:o}}function v({formats:n,locale:i,now:a,onError:o=M,timeZone:T}){function b(r,e){let t;if(typeof e=="string"){const s=e;if(t=r?.[s],!t){const m=new l(p.MISSING_FORMAT,process.env.NODE_ENV!=="production"?`Format \`${s}\` is not available. You can configure it on the provider or provide custom options.`:void 0);throw (o(m), m)}}else t=e;return t}function c(r,e,t,s){let m;try{m=b(t,e)}catch{return String(r)}try{return s(m)}catch(f){return o(new l(p.FORMATTING_ERROR,f.message)),String(r)}}function D(r,e){return c(r,e,n?.dateTime,t=>(T&&!t?.timeZone&&(t={...t,timeZone:T}),new Intl.DateTimeFormat(i,t).format(r)))}function E(r,e){return c(r,e,n?.number,t=>new Intl.NumberFormat(i,t).format(r))}function R(r,e){try{if(!e)if(a)e=a;else throw new Error(process.env.NODE_ENV!=="production"?"The `now` parameter wasn't provided and there was no global fallback configured on the provider.":void 0);const t=r instanceof Date?r:new Date(r),s=e instanceof Date?e:new Date(e),m=(t.getTime()-s.getTime())/1e3,{unit:f,value:w}=N(m);return new Intl.RelativeTimeFormat(i,{numeric:"auto"}).format(w,f)}catch(t){return o(new l(p.FORMATTING_ERROR,t.message)),String(r)}}function I(r,e){return c(r,e,n?.list,t=>new Intl.ListFormat(i,t).format(r))}return{dateTime:D,number:E,relativeTime:R,list:I}}export{v as default};
2
2
  //# sourceMappingURL=createFormatter.mjs.map
@@ -1,2 +1,2 @@
1
- import r from"./createFormatter";function a(...t){const e=r(...t);return{formatDateTime:e.dateTime,formatNumber:e.number,formatRelativeTime:e.relativeTime}}export{a as default};
1
+ import r from"./createFormatter.mjs";function a(...t){const e=r(...t);return{formatDateTime:e.dateTime,formatNumber:e.number,formatRelativeTime:e.relativeTime}}export{a as default};
2
2
  //# sourceMappingURL=createIntl.mjs.map
@@ -1,2 +1,2 @@
1
- import n from"./createTranslatorImpl";import{defaultGetMessageFallback as l,defaultOnError as d}from"./defaults";function o({getMessageFallback:s=l,messages:t,namespace:e,onError:a=d,...r}){return n({...r,onError:a,getMessageFallback:s,messages:{"!":t},namespace:e?`!.${e}`:"!"},"!")}export{o as default};
1
+ import n from"./createTranslatorImpl.mjs";import{defaultGetMessageFallback as l,defaultOnError as d}from"./defaults.mjs";function o({getMessageFallback:s=l,messages:t,namespace:e,onError:a=d,...r}){return n({...r,onError:a,getMessageFallback:s,messages:{"!":t},namespace:e?`!.${e}`:"!"},"!")}export{o as default};
2
2
  //# sourceMappingURL=createTranslator.mjs.map
@@ -1,2 +1,2 @@
1
- import u,{IntlErrorCode as d}from"./IntlError";import h,{getMessagesOrError as I}from"./createBaseTranslator";import T from"./resolveNamespace";function R({getMessageFallback:o,messages:s,namespace:r,onError:t,...g},i){s=s[i],r=T(r,i);const a=h({...g,onError:t,getMessageFallback:o,messagesOrError:I({messages:s,namespace:r,onError:t})}),f=a.rich;function n(...e){return a(...e)}return n.rich=(e,p,m)=>{const l=f(e,p,m);if(typeof l!="string"){const c=new u(d.FORMATTING_ERROR,process.env.NODE_ENV!=="production"?"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})":void 0);return t(c),o({error:c,key:e,namespace:r})}return l},n.raw=a.raw,n}export{R as default};
1
+ import u,{IntlErrorCode as d}from"./IntlError.mjs";import h,{getMessagesOrError as I}from"./createBaseTranslator.mjs";import T from"./resolveNamespace.mjs";function R({getMessageFallback:o,messages:s,namespace:r,onError:t,...g},i){s=s[i],r=T(r,i);const a=h({...g,onError:t,getMessageFallback:o,messagesOrError:I({messages:s,namespace:r,onError:t})}),f=a.rich;function n(...e){return a(...e)}return n.rich=(e,p,m)=>{const l=f(e,p,m);if(typeof l!="string"){const c=new u(d.FORMATTING_ERROR,process.env.NODE_ENV!=="production"?"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})":void 0);return t(c),o({error:c,key:e,namespace:r})}return l},n.raw=a.raw,n}export{R as default};
2
2
  //# sourceMappingURL=createTranslatorImpl.mjs.map
@@ -1,2 +1,2 @@
1
- import{default as e,IntlErrorCode as r}from"./IntlError";import{default as s}from"./createTranslator";import{default as m}from"./createFormatter";import{default as p}from"./createIntl";export{e as IntlError,r as IntlErrorCode,m as createFormatter,p as createIntl,s as createTranslator};
1
+ import{default as e,IntlErrorCode as r}from"./IntlError.mjs";import{default as s}from"./createTranslator.mjs";import{default as m}from"./createFormatter.mjs";import{default as p}from"./createIntl.mjs";export{e as IntlError,r as IntlErrorCode,m as createFormatter,p as createIntl,s as createTranslator};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,4 +1,4 @@
1
- import a,{IntlErrorCode as c}from"./IntlError";function i(n,t,e){Object.entries(n).forEach(([r,s])=>{if(r.includes(".")){let o=r;e&&(o+=` (at ${e})`),t.push(o)}s!=null&&typeof s=="object"&&i(s,t,[e,r].filter(o=>o!=null).join("."))})}function l(n,t){const e=[];i(n,e),e.length>0&&t(new a(c.INVALID_KEY,process.env.NODE_ENV!=="production"?`Namespace keys can not contain the character "." as this is used to express nesting. Please remove it or replace it with another character.
1
+ import a,{IntlErrorCode as c}from"./IntlError.mjs";function i(n,t,e){Object.entries(n).forEach(([r,s])=>{if(r.includes(".")){let o=r;e&&(o+=` (at ${e})`),t.push(o)}s!=null&&typeof s=="object"&&i(s,t,[e,r].filter(o=>o!=null).join("."))})}function l(n,t){const e=[];i(n,e),e.length>0&&t(new a(c.INVALID_KEY,process.env.NODE_ENV!=="production"?`Namespace keys can not contain the character "." as this is used to express nesting. Please remove it or replace it with another character.
2
2
 
3
3
  Invalid ${e.length===1?"key":"keys"}: ${e.join(", ")}
4
4
 
@@ -1,2 +1,2 @@
1
- export*from"./core";export*from"./react";
1
+ export*from"./core/index.mjs";export*from"./react/index.mjs";
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,2 +1,2 @@
1
- import r from"react";import e from"./IntlContext";import i from"./getInitializedConfig";function n({children:o,...t}){return r.createElement(e.Provider,{value:i(t)},o)}export{n as default};
1
+ import r from"react";import e from"./IntlContext.mjs";import i from"./getInitializedConfig.mjs";function n({children:o,...t}){return r.createElement(e.Provider,{value:i(t)},o)}export{n as default};
2
2
  //# sourceMappingURL=IntlProvider.mjs.map
@@ -1,2 +1,2 @@
1
- import{defaultGetMessageFallback as a,defaultOnError as l}from"../core/defaults";import f from"../core/validateMessages";function s({getMessageFallback:t,messages:r,onError:e,...n}){const o=e||l,i=t||a;return process.env.NODE_ENV!=="production"&&r&&f(r,o),{...n,messages:r,onError:o,getMessageFallback:i}}export{s as default};
1
+ import{defaultGetMessageFallback as a,defaultOnError as l}from"../core/defaults.mjs";import f from"../core/validateMessages.mjs";function s({getMessageFallback:t,messages:r,onError:e,...n}){const o=e||l,i=t||a;return process.env.NODE_ENV!=="production"&&r&&f(r,o),{...n,messages:r,onError:o,getMessageFallback:i}}export{s as default};
2
2
  //# sourceMappingURL=getInitializedConfig.mjs.map
@@ -1,2 +1,2 @@
1
- import{default as a}from"./IntlProvider";import{default as t}from"./useTranslations";import{default as f}from"./useLocale";import{default as l}from"./useNow";import{default as d}from"./useTimeZone";import{default as x}from"./useMessages";import{default as i}from"./useFormatter";import{default as T}from"./useIntl";export{a as IntlProvider,i as useFormatter,T as useIntl,f as useLocale,x as useMessages,l as useNow,d as useTimeZone,t as useTranslations};
1
+ import{default as a}from"./IntlProvider.mjs";import{default as t}from"./useTranslations.mjs";import{default as f}from"./useLocale.mjs";import{default as l}from"./useNow.mjs";import{default as d}from"./useTimeZone.mjs";import{default as x}from"./useMessages.mjs";import{default as i}from"./useFormatter.mjs";import{default as T}from"./useIntl.mjs";export{a as IntlProvider,i as useFormatter,T as useIntl,f as useLocale,x as useMessages,l as useNow,d as useTimeZone,t as useTranslations};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,2 +1,2 @@
1
- import{useMemo as n}from"react";import a from"../core/createFormatter";import f from"./useIntlContext";function l(){const{formats:o,locale:r,now:t,onError:e,timeZone:m}=f();return n(()=>a({formats:o,locale:r,now:t,onError:e,timeZone:m}),[o,t,r,e,m])}export{l as default};
1
+ import{useMemo as n}from"react";import a from"../core/createFormatter.mjs";import f from"./useIntlContext.mjs";function l(){const{formats:o,locale:r,now:t,onError:e,timeZone:m}=f();return n(()=>a({formats:o,locale:r,now:t,onError:e,timeZone:m}),[o,t,r,e,m])}export{l as default};
2
2
  //# sourceMappingURL=useFormatter.mjs.map
@@ -1,2 +1,2 @@
1
- import{useMemo as a}from"react";import s from"../core/createIntl";import m from"./useIntlContext";let l=!1;function i(){const{formats:e,locale:o,now:t,onError:r,timeZone:n}=m();return l||(l=!0,console.warn("`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.")),a(()=>s({formats:e,locale:o,now:t,onError:r,timeZone:n}),[e,t,o,r,n])}export{i as default};
1
+ import{useMemo as a}from"react";import s from"../core/createIntl.mjs";import m from"./useIntlContext.mjs";let l=!1;function i(){const{formats:e,locale:o,now:t,onError:r,timeZone:n}=m();return l||(l=!0,console.warn("`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.")),a(()=>s({formats:e,locale:o,now:t,onError:r,timeZone:n}),[e,t,o,r,n])}export{i as default};
2
2
  //# sourceMappingURL=useIntl.mjs.map
@@ -1,2 +1,2 @@
1
- import{useContext as o}from"react";import e from"./IntlContext";function n(){const t=o(e);if(!t)throw new Error(process.env.NODE_ENV!=="production"?"No intl context found. Have you configured the provider?":void 0);return t}export{n as default};
1
+ import{useContext as o}from"react";import e from"./IntlContext.mjs";function n(){const t=o(e);if(!t)throw new Error(process.env.NODE_ENV!=="production"?"No intl context found. Have you configured the provider?":void 0);return t}export{n as default};
2
2
  //# sourceMappingURL=useIntlContext.mjs.map
@@ -1,2 +1,2 @@
1
- import e from"./useIntlContext";function t(){return e().locale}export{t as default};
1
+ import e from"./useIntlContext.mjs";function t(){return e().locale}export{t as default};
2
2
  //# sourceMappingURL=useLocale.mjs.map
@@ -1,2 +1,2 @@
1
- import e from"./useIntlContext";function s(){return e().messages}export{s as default};
1
+ import e from"./useIntlContext.mjs";function s(){return e().messages}export{s as default};
2
2
  //# sourceMappingURL=useMessages.mjs.map
@@ -1,2 +1,2 @@
1
- import{useState as s,useEffect as l}from"react";import p from"./useIntlContext";function n(){return new Date}function c(o){const t=o?.updateInterval,{now:e}=p(),[r,u]=s(e||n());return l(()=>{if(!t)return;const a=setInterval(()=>{u(n())},t);return()=>{clearInterval(a)}},[e,t]),r}export{c as default};
1
+ import{useState as s,useEffect as l}from"react";import p from"./useIntlContext.mjs";function n(){return new Date}function c(o){const t=o?.updateInterval,{now:e}=p(),[r,u]=s(e||n());return l(()=>{if(!t)return;const a=setInterval(()=>{u(n())},t);return()=>{clearInterval(a)}},[e,t]),r}export{c as default};
2
2
  //# sourceMappingURL=useNow.mjs.map
@@ -1,2 +1,2 @@
1
- import e from"./useIntlContext";function t(){return e().timeZone}export{t as default};
1
+ import e from"./useIntlContext.mjs";function t(){return e().timeZone}export{t as default};
2
2
  //# sourceMappingURL=useTimeZone.mjs.map
@@ -1,2 +1,2 @@
1
- import t from"./useIntlContext";import a from"./useTranslationsImpl";function r(e){const s=t().messages;return a({"!":s},e?`!.${e}`:"!","!")}export{r as default};
1
+ import t from"./useIntlContext.mjs";import a from"./useTranslationsImpl.mjs";function r(e){const s=t().messages;return a({"!":s},e?`!.${e}`:"!","!")}export{r as default};
2
2
  //# sourceMappingURL=useTranslations.mjs.map
@@ -1,2 +1,2 @@
1
- import{useMemo as g,useRef as d}from"react";import i,{getMessagesOrError as u}from"../core/createBaseTranslator";import M from"../core/resolveNamespace";import y from"./useIntlContext";function F(t,e,r){const{defaultTranslationValues:o,formats:a,getMessageFallback:n,locale:m,onError:s,timeZone:l}=y();t=t[r],e=M(e,r);const c=d({}),f=g(()=>u({messages:t,namespace:e,onError:s}),[t,e,s]);return g(()=>i({cachedFormatsByLocale:c.current,getMessageFallback:n,messagesOrError:f,defaultTranslationValues:o,namespace:e,onError:s,formats:a,locale:m,timeZone:l}),[n,f,o,e,s,a,m,l])}export{F as default};
1
+ import{useMemo as g,useRef as d}from"react";import i,{getMessagesOrError as u}from"../core/createBaseTranslator.mjs";import M from"../core/resolveNamespace.mjs";import y from"./useIntlContext.mjs";function F(t,e,r){const{defaultTranslationValues:o,formats:a,getMessageFallback:n,locale:m,onError:s,timeZone:l}=y();t=t[r],e=M(e,r);const c=d({}),f=g(()=>u({messages:t,namespace:e,onError:s}),[t,e,s]);return g(()=>i({cachedFormatsByLocale:c.current,getMessageFallback:n,messagesOrError:f,defaultTranslationValues:o,namespace:e,onError:s,formats:a,locale:m,timeZone:l}),[n,f,o,e,s,a,m,l])}export{F as default};
2
2
  //# sourceMappingURL=useTranslationsImpl.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "use-intl",
3
- "version": "2.17.1",
3
+ "version": "2.17.2-alpha.1",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.work>",
6
6
  "description": "Minimal, but complete solution for managing internationalization in React apps.",
@@ -10,12 +10,6 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/amannn/next-intl/tree/main/packages/use-intl"
12
12
  },
13
- "scripts": {
14
- "build": "tsup",
15
- "test": "TZ=Europe/Berlin vitest",
16
- "lint": "eslint src test && tsc --noEmit",
17
- "prepublishOnly": "turbo test && turbo lint && turbo build"
18
- },
19
13
  "main": "dist/index.js",
20
14
  "module": "dist/index.mjs",
21
15
  "typings": "dist/index.d.ts",
@@ -57,5 +51,9 @@
57
51
  "engines": {
58
52
  "node": ">=10"
59
53
  },
60
- "gitHead": "3fce1cbc2c0705185f4d12b1632b51efa982f26c"
61
- }
54
+ "scripts": {
55
+ "build": "tsup",
56
+ "test": "TZ=Europe/Berlin vitest",
57
+ "lint": "eslint src test && tsc --noEmit"
58
+ }
59
+ }