Comparing version 4.0.0-beta-00a79d4 to 4.0.0-beta-0825f08
@@ -1,3 +0,3 @@ | ||
import { r as resolveNamespace, e as createBaseTranslator, d as createCache, b as createIntlFormatters, f as defaultGetMessageFallback, g as defaultOnError } from './initializeConfig-DSmAVNvj.js'; | ||
export { I as IntlError, a as IntlErrorCode, c as createFormatter, i as initializeConfig } from './initializeConfig-DSmAVNvj.js'; | ||
import { r as resolveNamespace, e as createBaseTranslator, d as createCache, b as createIntlFormatters, f as defaultGetMessageFallback, g as defaultOnError } from './initializeConfig-DNjOIggo.js'; | ||
export { I as IntlError, a as IntlErrorCode, c as createFormatter, i as initializeConfig } from './initializeConfig-DNjOIggo.js'; | ||
@@ -61,20 +61,5 @@ | ||
* | ||
* Additionally, in development, the provided locales are validated to | ||
* ensure they follow the Unicode language identifier standard. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale | ||
*/ | ||
function hasLocale(locales, candidate) { | ||
{ | ||
for (const locale of locales) { | ||
try { | ||
const constructed = new Intl.Locale(locale); | ||
if (!constructed.language) { | ||
throw new Error('Language is required'); | ||
} | ||
} catch { | ||
console.error(`Found invalid locale within provided \`locales\`: "${locale}"\nPlease ensure you're using a valid Unicode locale identifier (e.g. "en-US").`); | ||
} | ||
} | ||
} | ||
return locales.includes(candidate); | ||
@@ -81,0 +66,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export { I as IntlError, a as IntlErrorCode, d as _createCache, b as _createIntlFormatters, c as createFormatter, i as initializeConfig } from './initializeConfig-DSmAVNvj.js'; | ||
export { I as IntlError, a as IntlErrorCode, d as _createCache, b as _createIntlFormatters, c as createFormatter, i as initializeConfig } from './initializeConfig-DNjOIggo.js'; | ||
export { createTranslator, hasLocale } from './core.js'; | ||
@@ -3,0 +3,0 @@ export { IntlProvider, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations } from './react.js'; |
import { createContext, useContext, useMemo, useState, useEffect } from 'react'; | ||
import { d as createCache, b as createIntlFormatters, i as initializeConfig, r as resolveNamespace, I as IntlError, a as IntlErrorCode, e as createBaseTranslator, c as createFormatter } from './initializeConfig-DSmAVNvj.js'; | ||
import { d as createCache, b as createIntlFormatters, i as initializeConfig, r as resolveNamespace, I as IntlError, a as IntlErrorCode, e as createBaseTranslator, c as createFormatter } from './initializeConfig-DNjOIggo.js'; | ||
import { jsx } from 'react/jsx-runtime'; | ||
@@ -60,3 +60,3 @@ | ||
if (!context) { | ||
throw new Error('No intl context found. Have you configured the provider? See https://next-intl-docs.vercel.app/docs/usage/configuration#server-client-components' ); | ||
throw new Error('No intl context found. Have you configured the provider? See https://next-intl.dev/docs/usage/configuration#server-client-components' ); | ||
} | ||
@@ -86,3 +86,3 @@ return context; | ||
hasWarnedForMissingTimezone = true; | ||
onError(new IntlError(IntlErrorCode.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` )); | ||
onError(new IntlError(IntlErrorCode.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.dev/docs/configuration#time-zone` )); | ||
} | ||
@@ -135,3 +135,3 @@ const translate = useMemo(() => createBaseTranslator({ | ||
/** | ||
* @see https://next-intl-docs.vercel.app/docs/usage/dates-times#relative-times-usenow | ||
* @see https://next-intl.dev/docs/usage/dates-times#relative-times-usenow | ||
*/ | ||
@@ -163,3 +163,3 @@ function useNow(options) { | ||
if (!context.messages) { | ||
throw new Error('No messages found. Have you configured them correctly? See https://next-intl-docs.vercel.app/docs/configuration#messages' ); | ||
throw new Error('No messages found. Have you configured them correctly? See https://next-intl.dev/docs/configuration#messages' ); | ||
} | ||
@@ -166,0 +166,0 @@ return context.messages; |
@@ -5,3 +5,3 @@ /** | ||
* Optionally, messages can be strictly-typed in order to get type safety for message | ||
* namespaces and keys. See https://next-intl-docs.vercel.app/docs/usage/typescript | ||
* namespaces and keys. See https://next-intl.dev/docs/usage/typescript | ||
*/ | ||
@@ -8,0 +8,0 @@ type AbstractIntlMessages = { |
@@ -8,12 +8,15 @@ import type { ReactNode } from 'react'; | ||
import type { MessageKeys, NamespaceKeys, NestedKeyOf, NestedValueOf } from './MessageKeys.tsx'; | ||
import type { ICUArg, ICUDate, ICUNumber, MarkupTagsFunction, RichTagsFunction } from './TranslationValues.tsx'; | ||
import type { MarkupTagsFunction, RichTagsFunction, TranslationValues } from './TranslationValues.tsx'; | ||
import { type Formatters, type IntlCache } from './formatters.tsx'; | ||
import type { Prettify } from './types.tsx'; | ||
type ICUArgsWithTags<MessageString extends string, TagsFn extends RichTagsFunction | MarkupTagsFunction = never> = ICUArgs<MessageString, { | ||
ICUArgument: ICUArg; | ||
ICUNumberArgument: ICUNumber; | ||
ICUDateArgument: ICUDate; | ||
ICUArgument: string; | ||
ICUNumberArgument: number; | ||
ICUDateArgument: Date; | ||
}> & ([TagsFn] extends [never] ? {} : ICUTags<MessageString, TagsFn>); | ||
type OnlyOptional<T> = Partial<T> extends T ? true : false; | ||
type TranslateArgs<Value extends string, TagsFn extends RichTagsFunction | MarkupTagsFunction = never> = string extends Value ? [values?: Record<string, ICUArg | TagsFn>, formats?: Formats] : (Value extends any ? (key: ICUArgsWithTags<Value, TagsFn>) => void : never) extends (key: infer Args) => void ? OnlyOptional<Args> extends true ? [values?: undefined, formats?: Formats] : [values: Prettify<Args>, formats?: Formats] : never; | ||
type TranslateArgs<Value extends string, TagsFn extends RichTagsFunction | MarkupTagsFunction = never> = string extends Value ? [ | ||
values?: Record<string, TranslationValues[string] | TagsFn>, | ||
formats?: Formats | ||
] : (Value extends any ? (key: ICUArgsWithTags<Value, TagsFn>) => void : never) extends (key: infer Args) => void ? OnlyOptional<Args> extends true ? [values?: undefined, formats?: Formats] : [values: Prettify<Args>, formats?: Formats] : never; | ||
type NamespacedMessageKeys<TranslatorMessages extends Messages, Namespace extends NamespaceKeys<TranslatorMessages, NestedKeyOf<TranslatorMessages>> = never> = MessageKeys<NestedValueOf<{ | ||
@@ -20,0 +23,0 @@ '!': TranslatorMessages; |
@@ -5,7 +5,4 @@ import type { Locale } from './AppConfig.tsx'; | ||
* | ||
* Additionally, in development, the provided locales are validated to | ||
* ensure they follow the Unicode language identifier standard. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale | ||
*/ | ||
export default function hasLocale<LocaleType extends Locale>(locales: ReadonlyArray<LocaleType>, candidate?: string | null): candidate is LocaleType; | ||
export default function hasLocale<LocaleType extends Locale>(locales: ReadonlyArray<LocaleType>, candidate: unknown): candidate is LocaleType; |
export type { default as AbstractIntlMessages } from './AbstractIntlMessages.tsx'; | ||
export type { TranslationValues, RichTranslationValues, MarkupTranslationValues, ICUArg, ICUNumber, ICUDate, RichTagsFunction, MarkupTagsFunction } from './TranslationValues.tsx'; | ||
export type { TranslationValues, RichTranslationValues, MarkupTranslationValues, RichTagsFunction, MarkupTagsFunction } from './TranslationValues.tsx'; | ||
export type { default as Formats } from './Formats.tsx'; | ||
@@ -4,0 +4,0 @@ export type { default as IntlConfig } from './IntlConfig.tsx'; |
import type { ReactNode } from 'react'; | ||
export type ICUArg = string | number | boolean | Date; | ||
export type ICUNumber = number; | ||
export type ICUDate = Date | number | string; | ||
export type TranslationValues = Record<string, ICUArg>; | ||
export type TranslationValues = Record<string, string | number | Date>; | ||
export type RichTagsFunction = (chunks: ReactNode) => ReactNode; | ||
export type MarkupTagsFunction = (chunks: string) => string; | ||
export type RichTranslationValues = Record<string, ICUArg | RichTagsFunction>; | ||
export type MarkupTranslationValues = Record<string, ICUArg | MarkupTagsFunction>; | ||
export type RichTranslationValues = Record<string, TranslationValues[string] | RichTagsFunction>; | ||
export type MarkupTranslationValues = Record<string, TranslationValues[string] | MarkupTagsFunction>; |
@@ -5,5 +5,5 @@ type Options = { | ||
/** | ||
* @see https://next-intl-docs.vercel.app/docs/usage/dates-times#relative-times-usenow | ||
* @see https://next-intl.dev/docs/usage/dates-times#relative-times-usenow | ||
*/ | ||
export default function useNow(options?: Options): Date; | ||
export {}; |
{ | ||
"name": "use-intl", | ||
"version": "4.0.0-beta-00a79d4", | ||
"version": "4.0.0-beta-0825f08", | ||
"sideEffects": false, | ||
@@ -8,3 +8,3 @@ "author": "Jan Amann <jan@amann.work>", | ||
"license": "MIT", | ||
"homepage": "https://next-intl-docs.vercel.app/", | ||
"homepage": "https://next-intl.dev", | ||
"repository": { | ||
@@ -66,5 +66,5 @@ "type": "git", | ||
"peerDependencies": { | ||
"react": "^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0" | ||
"react": "^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0" | ||
}, | ||
"gitHead": "9c05cd576d214480f7459b2351f94cfa9e4aef85" | ||
"gitHead": "4c9f2f636b2ce73f2758b77035f94d47e9f91879" | ||
} |
@@ -83,2 +83,2 @@ # 🌐 use-intl | ||
### [→ Read the docs](https://next-intl-docs.vercel.app/docs/environments/core-library) | ||
### [→ Read the docs](https://next-intl.dev/docs/environments/core-library) |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
82697
1468