@browsery/i18next
Advanced tools
Comparing version 23.8.2 to 23.11.5
@@ -506,2 +506,7 @@ // Internal Helpers | ||
/** | ||
* Is initializing | ||
*/ | ||
isInitializing: boolean; | ||
/** | ||
* Store was initialized | ||
@@ -508,0 +513,0 @@ */ |
{ | ||
"name": "@browsery/i18next", | ||
"version": "23.8.2", | ||
"version": "23.11.5", | ||
"description": "Browser compatible i18next module", | ||
@@ -5,0 +5,0 @@ "author": "Panates", |
@@ -15,2 +15,47 @@ // Types | ||
export type $NormalizeIntoArray<T extends unknown | readonly unknown[]> = T extends readonly unknown[] ? T : [T]; | ||
export type $NormalizeIntoArray<T extends unknown | readonly unknown[]> = | ||
T extends readonly unknown[] ? T : [T]; | ||
/** | ||
* @typeParam T | ||
* @example | ||
* ``` | ||
* $UnionToIntersection<{foo: {bar: string} | {asd: boolean}}> = {foo: {bar: string} & {asd: boolean}} | ||
* ``` | ||
* | ||
* @see https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type | ||
*/ | ||
type $UnionToIntersection<T> = (T extends unknown ? (k: T) => void : never) extends ( | ||
k: infer I, | ||
) => void | ||
? I | ||
: never; | ||
/** | ||
* @typeParam TPath union of strings | ||
* @typeParam TValue value of the record | ||
* @example | ||
* ``` | ||
* $StringKeyPathToRecord<'foo.bar' | 'asd'> = {foo: {bar: string} | {asd: boolean}} | ||
* ``` | ||
*/ | ||
type $StringKeyPathToRecordUnion< | ||
TPath extends string, | ||
TValue, | ||
> = TPath extends `${infer TKey}.${infer Rest}` | ||
? { [Key in TKey]: $StringKeyPathToRecord<Rest, TValue> } | ||
: { [Key in TPath]: TValue }; | ||
/** | ||
* Used to intersect output of {@link $StringKeyPathToRecordUnion} | ||
* | ||
* @typeParam TPath union of strings | ||
* @typeParam TValue value of the record | ||
* @example | ||
* ``` | ||
* $StringKeyPathToRecord<'foo.bar' | 'asd'> = {foo: {bar: string} & {asd: boolean}} | ||
* ``` | ||
*/ | ||
export type $StringKeyPathToRecord<TPath extends string, TValue> = $UnionToIntersection< | ||
$StringKeyPathToRecordUnion<TPath, TValue> | ||
>; |
@@ -1,3 +0,9 @@ | ||
import type { $OmitArrayKeys, $PreservedValue, $Dictionary, $SpecialObject } from './helpers.js'; | ||
import type { | ||
$OmitArrayKeys, | ||
$PreservedValue, | ||
$Dictionary, | ||
$SpecialObject, | ||
$StringKeyPathToRecord, | ||
} from './helpers.js'; | ||
import type { | ||
TypeOptions, | ||
@@ -113,4 +119,4 @@ Namespace, | ||
type FilterKeysByContext<Keys, TOpt extends TOptions> = TOpt['context'] extends string | ||
? Keys extends `${infer Prefix}${_ContextSeparator}${TOpt['context']}${infer Suffix}` | ||
type FilterKeysByContext<Keys, Context> = Context extends string | ||
? Keys extends `${infer Prefix}${_ContextSeparator}${Context}${infer Suffix}` | ||
? `${Prefix}${Suffix}` | ||
@@ -126,2 +132,3 @@ : never | ||
ActualNS extends Namespace = NsByTOptions<Ns, TOpt>, | ||
Context extends TOpt['context'] = TOpt['context'], | ||
> = $IsResourcesDefined extends true | ||
@@ -132,3 +139,3 @@ ? FilterKeysByContext< | ||
| ParseKeysByFallbackNs<Keys>, | ||
TOpt | ||
Context | ||
> | ||
@@ -146,5 +153,6 @@ : string; | ||
: never; | ||
type InterpolationMap<Ret> = Record< | ||
$PreservedValue<ParseInterpolationValues<Ret>, string>, | ||
unknown | ||
type InterpolationMap<Ret> = $PreservedValue< | ||
$StringKeyPathToRecord<ParseInterpolationValues<Ret>, unknown>, | ||
Record<string, unknown> | ||
>; | ||
@@ -151,0 +159,0 @@ |
@@ -1,3 +0,9 @@ | ||
import type { $OmitArrayKeys, $PreservedValue, $Dictionary, $SpecialObject } from './helpers.js'; | ||
import type { | ||
$OmitArrayKeys, | ||
$PreservedValue, | ||
$Dictionary, | ||
$SpecialObject, | ||
$StringKeyPathToRecord, | ||
} from './helpers.js'; | ||
import type { | ||
TypeOptions, | ||
@@ -10,2 +16,5 @@ Namespace, | ||
/** @todo consider to replace {} with Record<string, never> */ | ||
/* eslint @typescript-eslint/ban-types: ['error', { types: { "{}": false } }] */ | ||
// Type Options | ||
@@ -25,5 +34,2 @@ type _ReturnObjects = TypeOptions['returnObjects']; | ||
/** @todo consider to replace {} with Record<string, never> */ | ||
/* eslint @typescript-eslint/ban-types: ['error', { types: { "{}": false } }] */ | ||
type $IsResourcesDefined = [keyof _Resources] extends [never] ? false : true; | ||
@@ -145,5 +151,6 @@ type $ValueIfResourcesDefined<Value, Fallback> = $IsResourcesDefined extends true | ||
: never; | ||
type InterpolationMap<Ret> = Record< | ||
$PreservedValue<ParseInterpolationValues<Ret>, string>, | ||
unknown | ||
type InterpolationMap<Ret> = $PreservedValue< | ||
$StringKeyPathToRecord<ParseInterpolationValues<Ret>, unknown>, | ||
Record<string, unknown> | ||
>; | ||
@@ -150,0 +157,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
250202
6885