intor 2.3.0 → 2.3.2

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/README.md CHANGED
@@ -1,22 +1,23 @@
1
- # Intor
1
+ <h1 align="center">Intor</h1>
2
2
 
3
- A modular and extensible i18n core for JavaScript/TypeScript.
3
+ <div align="center">
4
+
5
+ A lightweight, framework-agnostic i18n engine that works instantly with a clean, type-safe API.
6
+ Fast to start, easy to extend, and free from the usual i18n heaviness.
4
7
 
5
- ## Features
8
+ </div>
6
9
 
7
- - ✅ Runtime configuration
8
- - ✅ Backend and frontend support
9
- - ✅ Custom messages and adapters
10
- - ✅ Caching, error handling, and logging
10
+ <div align="center">
11
11
 
12
- ## Installation
12
+ [![NPM version](https://img.shields.io/npm/v/intor?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/intor)
13
+ [![Bundle size](https://img.shields.io/bundlephobia/minzip/intor?style=flat&colorA=000000&colorB=000000)](https://bundlephobia.com/package/intor)
14
+ [![TypeScript](https://img.shields.io/badge/TypeScript-%E2%9C%94-blue?style=flat&colorA=000000&colorB=000000)](https://www.typescriptlang.org/)
15
+ [![License](https://img.shields.io/npm/l/intor?style=flat&colorA=000000&colorB=000000)](LICENSE)
13
16
 
14
- ```bash
15
- npm install intor
16
- ```
17
+ </div>
17
18
 
18
- Or use **yarn**
19
+ <div align="center">
19
20
 
20
- ```bash
21
- yarn add intor
22
- ```
21
+ #### 🍳 Cooking the Intor v2 docs, crafting them to perfection...
22
+
23
+ </div>
@@ -2,4 +2,4 @@
2
2
  export { PREFIX_PLACEHOLDER } from "../src/shared/constants/prefix-placeholder";
3
3
  export { mergeMessages, normalizeCacheKey, resolveNamespaces, normalizeLocale, resolvePreferredLocale, extractPathname, normalizePathname, standardizePathname, } from "../src/shared/utils";
4
4
  export { IntorError, IntorErrorCode } from "../src/shared/error";
5
- export { Translator, type TranslateHandlers, type FormatHandler, type LoadingHandler, type MissingHandler, type TranslateHandlerContext, type Locale, type FallbackLocalesMap, type NestedMessage, type LocaleMessages, type LocalizedMessagesUnion, type Replacement, type NodeKeys, type LeafKeys, type LocalizedLeafKeys, type ScopedLeafKeys, } from "intor-translator";
5
+ export { Translator, type TranslatorOptions, type TranslatorMethods, type TranslatorPlugin, type TranslateConfig, type TranslateHandlers, type FormatHandler, type LoadingHandler, type MissingHandler, type HandlerContext, type TranslateContext, type TranslateHook, type Locale, type FallbackLocalesMap, type NestedMessage, type LocaleMessages, type LocalizedMessagesUnion, type Replacement, type DefaultDepth, type NodeKeys, type LeafKeys, type LocalizedNodeKeys, type LocalizedLeafKeys, type ScopedLeafKeys, } from "intor-translator";
@@ -1,2 +1,3 @@
1
1
  import type { TranslatorContextValue } from "./types";
2
- export declare function useTranslator<M>(): TranslatorContextValue<M>;
2
+ import type { LocaleMessages } from "intor-translator";
3
+ export declare function useTranslator<M extends LocaleMessages = LocaleMessages>(): TranslatorContextValue<M>;
@@ -1,6 +1,6 @@
1
- import type { Translator } from "intor-translator";
1
+ import type { LocaleMessages, Translator } from "intor-translator";
2
2
  import type * as React from "react";
3
- export type TranslatorContextValue<M = unknown> = {
3
+ export type TranslatorContextValue<M extends LocaleMessages = LocaleMessages> = {
4
4
  translator: Translator<M>;
5
5
  };
6
6
  export type TranslatorProviderProps = {
@@ -1,5 +1,5 @@
1
1
  import type { IfGen } from "../../shared/types/generated.types";
2
- import { type Locale, type Replacement, type ScopedLeafKeys, type LocalizedLeafKeys } from "intor-translator";
2
+ import { type Locale, type Replacement, type ScopedLeafKeys, type LocalizedLeafKeys, type LocaleMessages } from "intor-translator";
3
3
  /** Base properties shared by all translator instances. */
4
4
  export interface TranslatorBaseProps<M = unknown> {
5
5
  /** `messages`: The message object containing all translations. */
@@ -19,12 +19,12 @@ export interface TranslatorClientProps<M = unknown> {
19
19
  * - Resolves to `ScopedLeafKeys` if a pre-key `PK` is provided,
20
20
  * otherwise resolves to `LocalizedLeafKeys`.
21
21
  */
22
- type Key<M, PK> = IfGen<PK extends string ? ScopedLeafKeys<M, PK> : LocalizedLeafKeys<M>, string>;
22
+ type Key<M extends LocaleMessages, PK> = IfGen<PK extends string ? ScopedLeafKeys<M, PK> : LocalizedLeafKeys<M>, string>;
23
23
  /**
24
24
  * Translator instance type.
25
25
  * Combines base props, client props, and core translation methods.
26
26
  */
27
- export type TranslatorInstance<M, PK extends string | undefined = undefined> = {
27
+ export type TranslatorInstance<M extends LocaleMessages, PK extends string | undefined = undefined> = {
28
28
  /** Check if a given key exists in the messages. */
29
29
  hasKey: (key?: Key<M, PK>, targetLocale?: Locale<M>) => boolean;
30
30
  /** Translate a given key into its string representation. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intor",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "description": "A modular and extensible i18n core designed for TypeScript and JavaScript projects. Intor enables custom translation logic with support for both frontend and backend environments, featuring runtime configuration, caching, adapters, and message loaders.",
5
5
  "author": "Yiming Liao",
6
6
  "license": "MIT",
@@ -63,6 +63,8 @@
63
63
  "README.md",
64
64
  "LICENSE"
65
65
  ],
66
+ "main": "./dist/exports/index.js",
67
+ "module": "./dist/exports/index.js",
66
68
  "type": "module",
67
69
  "scripts": {
68
70
  "type": "tsc --noEmit",
@@ -76,10 +78,11 @@
76
78
  "build:next": "rollup -c .config/rollup/next.js",
77
79
  "build:dts": "rollup -c .config/rollup/dts.js",
78
80
  "build": "yarn clean && yarn build:core && yarn build:react && yarn build:next && yarn tsc -p tsconfig.build.json && yarn tsc-alias tsconfig.build.json --outDir dist",
79
- "prepublishOnly": "yarn build"
81
+ "prepublishOnly": "yarn build",
82
+ "examples:html": "vite --config examples/html/vite.config.ts"
80
83
  },
81
84
  "dependencies": {
82
- "intor-translator": "^1.1.5",
85
+ "intor-translator": "^1.2.0",
83
86
  "keyv": "^5.5.3",
84
87
  "lodash.merge": "^4.6.2",
85
88
  "logry": "^2.0.1",
@@ -113,6 +116,7 @@
113
116
  "tsc-alias": "^1.8.16",
114
117
  "typescript": "^5.8.3",
115
118
  "typescript-eslint": "^8.32.1",
119
+ "vite": "^7.2.6",
116
120
  "vitest": "^4.0.9"
117
121
  },
118
122
  "sideEffects": false,