intor-translator 1.2.2 → 1.2.3

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.
package/dist/index.d.cts CHANGED
@@ -188,7 +188,7 @@ type LeafKeys<M, D extends number = DefaultDepth> = [D] extends [never] ? never
188
188
  * LocalizedNodeKeys // → string
189
189
  * ```
190
190
  */
191
- type LocalizedNodeKeys<M extends LocaleMessages | undefined = undefined, L extends keyof M | "union" = "union", D extends number = DefaultDepth> = [M] extends [undefined] ? string : L extends "union" ? NodeKeys<M[keyof M], D> : NodeKeys<M[Extract<L, keyof M>], D>;
191
+ type LocalizedNodeKeys<M = unknown, L extends keyof M | "union" = "union", D extends number = DefaultDepth> = M extends LocaleMessages ? L extends "union" ? NodeKeys<M[keyof M], D> : NodeKeys<M[Extract<L, keyof M>], D> : string;
192
192
  /**
193
193
  * Extracts all **leaf keys** from the messages
194
194
  * of a specified locale (or union of locales).
@@ -211,7 +211,7 @@ type LocalizedNodeKeys<M extends LocaleMessages | undefined = undefined, L exten
211
211
  * LocalizedLeafKeys // → string
212
212
  * ```
213
213
  */
214
- type LocalizedLeafKeys<M extends LocaleMessages | undefined = undefined, L extends keyof M | "union" = "union", D extends number = DefaultDepth> = [M] extends [undefined] ? string : L extends "union" ? LeafKeys<M[keyof M], D> : LeafKeys<M[Extract<L, keyof M>], D>;
214
+ type LocalizedLeafKeys<M = unknown, L extends keyof M | "union" = "union", D extends number = DefaultDepth> = M extends LocaleMessages ? L extends "union" ? LeafKeys<M[keyof M], D> : LeafKeys<M[Extract<L, keyof M>], D> : string;
215
215
 
216
216
  /**
217
217
  * Resolves the type at a dot-separated key in a nested object.
@@ -351,7 +351,7 @@ interface BaseTranslatorOptions<M = unknown> {
351
351
  *
352
352
  * @template M - Shape of the messages object.
353
353
  */
354
- declare class BaseTranslator<M extends LocaleMessages> {
354
+ declare class BaseTranslator<M extends LocaleMessages | unknown = unknown> {
355
355
  /** Current messages for translation */
356
356
  protected _messages: Readonly<M>;
357
357
  /** Current active locale */
@@ -400,7 +400,7 @@ interface TranslatorPlugin {
400
400
  * @template M - Shape of the messages object.
401
401
  * @template L - Locale selection strategy ("union" or specific locale keys).
402
402
  */
403
- declare class CoreTranslator<M extends LocaleMessages, L extends keyof M | "union" = "union"> extends BaseTranslator<M> {
403
+ declare class CoreTranslator<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union"> extends BaseTranslator<M> {
404
404
  /** User-provided options including messages, locale, and config. */
405
405
  protected translateConfig: TranslateConfig<M>;
406
406
  /** Active pipeline hooks applied during translation. */
@@ -419,12 +419,12 @@ declare class CoreTranslator<M extends LocaleMessages, L extends keyof M | "unio
419
419
  }
420
420
 
421
421
  type ScopeTranslatorOptions<M> = CoreTranslatorOptions<M>;
422
- type ScopeTranslatorMethods<M extends LocaleMessages | undefined = undefined, L extends keyof M | "union" = "union", K = LocalizedLeafKeys<M, L>> = {
422
+ type ScopeTranslatorMethods<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union", K = LocalizedLeafKeys<M, L>> = {
423
423
  hasKey: (key?: K, targetLocale?: Locale<M>) => boolean;
424
424
  t: <Result = string>(key?: K, replacements?: Replacement) => Result;
425
425
  };
426
426
 
427
- declare class ScopeTranslator<M extends LocaleMessages, L extends keyof M | "union" = "union"> extends CoreTranslator<M> {
427
+ declare class ScopeTranslator<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union"> extends CoreTranslator<M> {
428
428
  constructor(options: ScopeTranslatorOptions<M>);
429
429
  /** Create a scoped translator with a prefix key, providing `t` and `hasKey` for nested keys. */
430
430
  scoped<PK extends LocalizedNodeKeys<M, L> | undefined = undefined>(preKey?: PK): PK extends string ? ScopeTranslatorMethods<M, L, ScopedLeafKeys<M, PK, L>> : ScopeTranslatorMethods<M, L>;
package/dist/index.d.ts CHANGED
@@ -188,7 +188,7 @@ type LeafKeys<M, D extends number = DefaultDepth> = [D] extends [never] ? never
188
188
  * LocalizedNodeKeys // → string
189
189
  * ```
190
190
  */
191
- type LocalizedNodeKeys<M extends LocaleMessages | undefined = undefined, L extends keyof M | "union" = "union", D extends number = DefaultDepth> = [M] extends [undefined] ? string : L extends "union" ? NodeKeys<M[keyof M], D> : NodeKeys<M[Extract<L, keyof M>], D>;
191
+ type LocalizedNodeKeys<M = unknown, L extends keyof M | "union" = "union", D extends number = DefaultDepth> = M extends LocaleMessages ? L extends "union" ? NodeKeys<M[keyof M], D> : NodeKeys<M[Extract<L, keyof M>], D> : string;
192
192
  /**
193
193
  * Extracts all **leaf keys** from the messages
194
194
  * of a specified locale (or union of locales).
@@ -211,7 +211,7 @@ type LocalizedNodeKeys<M extends LocaleMessages | undefined = undefined, L exten
211
211
  * LocalizedLeafKeys // → string
212
212
  * ```
213
213
  */
214
- type LocalizedLeafKeys<M extends LocaleMessages | undefined = undefined, L extends keyof M | "union" = "union", D extends number = DefaultDepth> = [M] extends [undefined] ? string : L extends "union" ? LeafKeys<M[keyof M], D> : LeafKeys<M[Extract<L, keyof M>], D>;
214
+ type LocalizedLeafKeys<M = unknown, L extends keyof M | "union" = "union", D extends number = DefaultDepth> = M extends LocaleMessages ? L extends "union" ? LeafKeys<M[keyof M], D> : LeafKeys<M[Extract<L, keyof M>], D> : string;
215
215
 
216
216
  /**
217
217
  * Resolves the type at a dot-separated key in a nested object.
@@ -351,7 +351,7 @@ interface BaseTranslatorOptions<M = unknown> {
351
351
  *
352
352
  * @template M - Shape of the messages object.
353
353
  */
354
- declare class BaseTranslator<M extends LocaleMessages> {
354
+ declare class BaseTranslator<M extends LocaleMessages | unknown = unknown> {
355
355
  /** Current messages for translation */
356
356
  protected _messages: Readonly<M>;
357
357
  /** Current active locale */
@@ -400,7 +400,7 @@ interface TranslatorPlugin {
400
400
  * @template M - Shape of the messages object.
401
401
  * @template L - Locale selection strategy ("union" or specific locale keys).
402
402
  */
403
- declare class CoreTranslator<M extends LocaleMessages, L extends keyof M | "union" = "union"> extends BaseTranslator<M> {
403
+ declare class CoreTranslator<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union"> extends BaseTranslator<M> {
404
404
  /** User-provided options including messages, locale, and config. */
405
405
  protected translateConfig: TranslateConfig<M>;
406
406
  /** Active pipeline hooks applied during translation. */
@@ -419,12 +419,12 @@ declare class CoreTranslator<M extends LocaleMessages, L extends keyof M | "unio
419
419
  }
420
420
 
421
421
  type ScopeTranslatorOptions<M> = CoreTranslatorOptions<M>;
422
- type ScopeTranslatorMethods<M extends LocaleMessages | undefined = undefined, L extends keyof M | "union" = "union", K = LocalizedLeafKeys<M, L>> = {
422
+ type ScopeTranslatorMethods<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union", K = LocalizedLeafKeys<M, L>> = {
423
423
  hasKey: (key?: K, targetLocale?: Locale<M>) => boolean;
424
424
  t: <Result = string>(key?: K, replacements?: Replacement) => Result;
425
425
  };
426
426
 
427
- declare class ScopeTranslator<M extends LocaleMessages, L extends keyof M | "union" = "union"> extends CoreTranslator<M> {
427
+ declare class ScopeTranslator<M extends LocaleMessages | unknown = unknown, L extends keyof M | "union" = "union"> extends CoreTranslator<M> {
428
428
  constructor(options: ScopeTranslatorOptions<M>);
429
429
  /** Create a scoped translator with a prefix key, providing `t` and `hasKey` for nested keys. */
430
430
  scoped<PK extends LocalizedNodeKeys<M, L> | undefined = undefined>(preKey?: PK): PK extends string ? ScopeTranslatorMethods<M, L, ScopedLeafKeys<M, PK, L>> : ScopeTranslatorMethods<M, L>;
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "intor-translator",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "🤖 A modern, type-safe i18n engine.",
5
- "author": "Yiming Liao",
6
- "license": "MIT",
5
+ "author": {
6
+ "name": "Yiming Liao",
7
+ "email": "yimingliao.official@gmail.com",
8
+ "url": "https://github.com/yiming-liao"
9
+ },
7
10
  "homepage": "https://github.com/yiming-liao/intor-translator#readme",
8
11
  "repository": {
9
12
  "type": "git",
@@ -12,6 +15,10 @@
12
15
  "bugs": {
13
16
  "url": "https://github.com/yiming-liao/intor-translator/issues"
14
17
  },
18
+ "funding": {
19
+ "type": "github",
20
+ "url": "https://github.com/sponsors/yiming-liao"
21
+ },
15
22
  "keywords": [
16
23
  "i18n",
17
24
  "internationalization",
@@ -21,6 +28,8 @@
21
28
  "i18n engine",
22
29
  "translator"
23
30
  ],
31
+ "license": "MIT",
32
+ "type": "module",
24
33
  "exports": {
25
34
  ".": {
26
35
  "types": "./dist/index.d.ts",
@@ -36,7 +45,10 @@
36
45
  "README.md",
37
46
  "LICENSE"
38
47
  ],
39
- "type": "module",
48
+ "sideEffects": false,
49
+ "engines": {
50
+ "node": ">=16.0.0"
51
+ },
40
52
  "scripts": {
41
53
  "build": "tsup",
42
54
  "prepublishOnly": "yarn build",
@@ -47,10 +59,6 @@
47
59
  "knip": "knip --config .config/knip.config.ts",
48
60
  "examples:html": "vite --config examples/html/vite.config.ts"
49
61
  },
50
- "sideEffects": false,
51
- "engines": {
52
- "node": ">=16.0.0"
53
- },
54
62
  "dependencies": {
55
63
  "rura": "1.0.7"
56
64
  },