@i18n-micro/types 1.0.15
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/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.mjs +5 -0
- package/fix.ts +1 -0
- package/jest.config.cjs +7 -0
- package/package.json +31 -0
- package/src/index.ts +141 -0
- package/tsconfig.json +24 -0
- package/vite.config.mts +25 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# @i18n-micro/types
|
|
2
|
+
|
|
3
|
+
`@i18n-micro/types` provides TypeScript type definitions and interfaces for the `nuxt-i18n-micro` ecosystem. This package is designed to enhance type safety and developer experience when working with translations, locales, and routing in a Nuxt.js application. It includes types for locales, routing strategies, translation parameters, and more.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You can install `@i18n-micro/types` using npm or yarn:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @i18n-micro/types
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @i18n-micro/types
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
This package provides TypeScript types and interfaces for working with `nuxt-i18n-micro`. It is primarily used to ensure type safety when defining locales, routing strategies, and translation parameters.
|
|
22
|
+
|
|
23
|
+
### Example
|
|
24
|
+
|
|
25
|
+
Here’s an example of how you might use the types provided by this package:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Locale, Strategies, ModuleOptions, I18nRouteParams } from '@i18n-micro/types'
|
|
29
|
+
|
|
30
|
+
// Define locales
|
|
31
|
+
const locales: Locale[] = [
|
|
32
|
+
{
|
|
33
|
+
code: 'en',
|
|
34
|
+
iso: 'en-US',
|
|
35
|
+
dir: 'ltr',
|
|
36
|
+
displayName: 'English',
|
|
37
|
+
baseUrl: 'https://example.com/en',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
code: 'de',
|
|
41
|
+
iso: 'de-DE',
|
|
42
|
+
dir: 'ltr',
|
|
43
|
+
displayName: 'German',
|
|
44
|
+
baseUrl: 'https://example.com/de',
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
// Define routing strategy
|
|
49
|
+
const strategy: Strategies = 'prefix_except_default'
|
|
50
|
+
|
|
51
|
+
// Define module options
|
|
52
|
+
const options: ModuleOptions = {
|
|
53
|
+
locales,
|
|
54
|
+
strategy,
|
|
55
|
+
defaultLocale: 'en',
|
|
56
|
+
includeDefaultLocaleRoute: true,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Define route parameters
|
|
60
|
+
const routeParams: I18nRouteParams = {
|
|
61
|
+
en: { page: 'home' },
|
|
62
|
+
de: { page: 'startseite' },
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## API Reference
|
|
67
|
+
|
|
68
|
+
### Types and Interfaces
|
|
69
|
+
|
|
70
|
+
#### `Locale`
|
|
71
|
+
Represents a locale configuration.
|
|
72
|
+
|
|
73
|
+
#### `LocaleCode`
|
|
74
|
+
Represents a locale code (e.g., `'en'`, `'de'`).
|
|
75
|
+
|
|
76
|
+
#### `Strategies`
|
|
77
|
+
Represents the available routing strategies.
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
export type Strategies = 'no_prefix' | 'prefix_except_default' | 'prefix' | 'prefix_and_default'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### `ModuleOptions`
|
|
84
|
+
Represents the configuration options for the `nuxt-i18n-micro` module.
|
|
85
|
+
|
|
86
|
+
#### `ModuleOptionsExtend`
|
|
87
|
+
Extends `ModuleOptions` with additional properties.
|
|
88
|
+
|
|
89
|
+
#### `I18nRouteParams`
|
|
90
|
+
Represents route parameters for different locales.
|
|
91
|
+
|
|
92
|
+
#### `Params`
|
|
93
|
+
Represents a key-value pair of parameters for interpolation.
|
|
94
|
+
|
|
95
|
+
#### `PluralFunc`
|
|
96
|
+
Represents a function for handling pluralization in translations.
|
|
97
|
+
|
|
98
|
+
#### `GlobalLocaleRoutes`
|
|
99
|
+
Represents global route configurations for different locales.
|
|
100
|
+
|
|
101
|
+
#### `Translations`
|
|
102
|
+
Represents a key-value pair of translations.
|
|
103
|
+
|
|
104
|
+
#### `Translation`
|
|
105
|
+
Represents a translation value, which can be a string, number, boolean, nested translations, or `null`.
|
|
106
|
+
|
|
107
|
+
#### `PluralTranslations`
|
|
108
|
+
Represents translations for singular and plural forms.
|
|
109
|
+
|
|
110
|
+
## Contributing
|
|
111
|
+
|
|
112
|
+
If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the [GitHub repository](https://github.com/s00d/nuxt-i18n-micro).
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
This project is licensed under the MIT License. See the [LICENSE](https://github.com/s00d/nuxt-i18n-micro/blob/main/LICENSE) file for more details.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
For more information, visit the [GitHub repository](https://github.com/s00d/nuxt-i18n-micro).
|
|
121
|
+
|
|
122
|
+
## Author
|
|
123
|
+
|
|
124
|
+
- **Name**: s00d
|
|
125
|
+
- **Email**: Virus191288@gmail.com
|
|
126
|
+
- **Website**: [https://s00d.github.io/](https://s00d.github.io/)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=()=>{};exports.init=t;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export type LocaleCode = string;
|
|
2
|
+
export interface DefineLocaleMessage {
|
|
3
|
+
readonly __augmentation?: never;
|
|
4
|
+
}
|
|
5
|
+
export type TranslationKey = keyof DefineLocaleMessage extends never ? string : keyof DefineLocaleMessage | string;
|
|
6
|
+
/**
|
|
7
|
+
* Хелпер для создания типизированных префиксов.
|
|
8
|
+
* Позволяет безопасно использовать динамические ключи.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Допустим, есть ключи: 'errors.404', 'errors.500', 'btn.save'
|
|
13
|
+
* function getErrorText(code: string) {
|
|
14
|
+
* return t(`errors.${code}` as ScopedKey<'errors'>)
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export type ScopedKey<Scope extends string> = Extract<TranslationKey, `${Scope}.${string}`>;
|
|
19
|
+
export interface Locale {
|
|
20
|
+
code: LocaleCode;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
iso?: string;
|
|
23
|
+
dir?: 'ltr' | 'rtl' | 'auto';
|
|
24
|
+
displayName?: string;
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
baseDefault?: boolean;
|
|
27
|
+
fallbackLocale?: string;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface DefineI18nRouteConfig {
|
|
31
|
+
locales?: string[] | Record<LocaleCode, Translations>;
|
|
32
|
+
localeRoutes?: Record<LocaleCode, string>;
|
|
33
|
+
disableMeta?: boolean | string[];
|
|
34
|
+
}
|
|
35
|
+
export type I18nRouteParams = Record<LocaleCode, Record<string, string>> | null;
|
|
36
|
+
export type Params = Record<string, string | number | boolean>;
|
|
37
|
+
export type Getter = (key: TranslationKey, params?: Record<string, string | number | boolean>, defaultValue?: string) => unknown;
|
|
38
|
+
export type PluralFunc = (key: TranslationKey, count: number, params: Params, locale: string, getter: Getter) => string | null;
|
|
39
|
+
export type GlobalLocaleRoutes = Record<string, Record<LocaleCode, string> | false | boolean> | null | undefined;
|
|
40
|
+
export type Strategies = 'no_prefix' | 'prefix_except_default' | 'prefix' | 'prefix_and_default';
|
|
41
|
+
export type MissingHandler = (locale: string, key: TranslationKey, routeName: string, instance?: unknown, type?: string) => void;
|
|
42
|
+
export interface ModuleOptions {
|
|
43
|
+
locales?: Locale[];
|
|
44
|
+
meta?: boolean;
|
|
45
|
+
strategy?: Strategies;
|
|
46
|
+
metaBaseUrl?: string;
|
|
47
|
+
define?: boolean;
|
|
48
|
+
redirects?: boolean;
|
|
49
|
+
plugin?: boolean;
|
|
50
|
+
hooks?: boolean;
|
|
51
|
+
defaultLocale?: string;
|
|
52
|
+
apiBaseUrl?: string;
|
|
53
|
+
apiBaseClientHost?: string;
|
|
54
|
+
apiBaseServerHost?: string;
|
|
55
|
+
translationDir?: string;
|
|
56
|
+
autoDetectLanguage?: boolean;
|
|
57
|
+
autoDetectPath?: string;
|
|
58
|
+
disableWatcher?: boolean;
|
|
59
|
+
types?: boolean;
|
|
60
|
+
includeDefaultLocaleRoute?: boolean;
|
|
61
|
+
routesLocaleLinks?: {
|
|
62
|
+
[key: string]: string;
|
|
63
|
+
};
|
|
64
|
+
plural?: string | PluralFunc;
|
|
65
|
+
disablePageLocales?: boolean;
|
|
66
|
+
fallbackLocale?: string;
|
|
67
|
+
localeCookie?: string;
|
|
68
|
+
debug?: boolean;
|
|
69
|
+
globalLocaleRoutes?: GlobalLocaleRoutes;
|
|
70
|
+
customRegexMatcher?: string | RegExp;
|
|
71
|
+
noPrefixRedirect?: boolean;
|
|
72
|
+
canonicalQueryWhitelist?: string[];
|
|
73
|
+
excludePatterns?: (string | RegExp)[];
|
|
74
|
+
routeLocales?: Record<string, string[]>;
|
|
75
|
+
routeDisableMeta?: Record<string, boolean | string[]>;
|
|
76
|
+
missingWarn?: boolean;
|
|
77
|
+
experimental?: {
|
|
78
|
+
i18nPreviousPageFallback?: boolean;
|
|
79
|
+
hmr?: boolean;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export interface ModuleOptionsExtend extends ModuleOptions {
|
|
83
|
+
dateBuild: number;
|
|
84
|
+
hashMode: boolean;
|
|
85
|
+
isSSG: boolean;
|
|
86
|
+
apiBaseUrl: string;
|
|
87
|
+
disablePageLocales: boolean;
|
|
88
|
+
}
|
|
89
|
+
export interface ModulePrivateOptionsExtend extends ModuleOptions {
|
|
90
|
+
rootDir: string;
|
|
91
|
+
rootDirs: string[];
|
|
92
|
+
debug: boolean;
|
|
93
|
+
translationDir: string;
|
|
94
|
+
fallbackLocale: string;
|
|
95
|
+
apiBaseUrl: string;
|
|
96
|
+
apiBaseClientHost?: string;
|
|
97
|
+
apiBaseServerHost?: string;
|
|
98
|
+
customRegexMatcher?: string | RegExp;
|
|
99
|
+
routesLocaleLinks?: {
|
|
100
|
+
[key: string]: string;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export interface PluralTranslations {
|
|
104
|
+
singular: string;
|
|
105
|
+
plural: string;
|
|
106
|
+
}
|
|
107
|
+
export type CleanTranslation = string | number | boolean | Translations | PluralTranslations | null;
|
|
108
|
+
export type Translation = CleanTranslation | unknown;
|
|
109
|
+
export interface Translations {
|
|
110
|
+
[key: string]: Translation;
|
|
111
|
+
}
|
|
112
|
+
declare const init: () => void;
|
|
113
|
+
export { init };
|
package/dist/index.mjs
ADDED
package/fix.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@types/jest'
|
package/jest.config.cjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@i18n-micro/types",
|
|
3
|
+
"version": "1.0.15",
|
|
4
|
+
"description": "",
|
|
5
|
+
"repository": "s00d/nuxt-i18n-micro",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "s00d",
|
|
10
|
+
"email": "Virus191288@gmail.com",
|
|
11
|
+
"url": "https://s00d.github.io/"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/s00d/nuxt-i18n-micro",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/s00d/nuxt-i18n-micro/issues"
|
|
16
|
+
},
|
|
17
|
+
"main": "dist/index.cjs",
|
|
18
|
+
"module": "dist/index.mjs",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [],
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"vite-plugin-dts": "^4.3.0"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "vite build",
|
|
29
|
+
"test": "echo \"Error: no test specified\""
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export type LocaleCode = string
|
|
2
|
+
|
|
3
|
+
// Реестр ключей. Пользователь (через генератор) будет делать module augmentation этого интерфейса.
|
|
4
|
+
export interface DefineLocaleMessage {
|
|
5
|
+
// Module augmentation point - will be extended by @i18n-micro/types-generator
|
|
6
|
+
readonly __augmentation?: never
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Логика определения типа ключа.
|
|
10
|
+
// Если интерфейс пустой (генератор не подключен), тип ключа — string.
|
|
11
|
+
// Если в интерфейсе есть ключи, тип ключа — объединение этих ключей и string (Union Type).
|
|
12
|
+
// Это позволяет использовать как строгие типы (автокомплит), так и обычные строки (динамические ключи).
|
|
13
|
+
export type TranslationKey = keyof DefineLocaleMessage extends never
|
|
14
|
+
? string
|
|
15
|
+
: keyof DefineLocaleMessage | string
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Хелпер для создания типизированных префиксов.
|
|
19
|
+
* Позволяет безопасно использовать динамические ключи.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Допустим, есть ключи: 'errors.404', 'errors.500', 'btn.save'
|
|
24
|
+
* function getErrorText(code: string) {
|
|
25
|
+
* return t(`errors.${code}` as ScopedKey<'errors'>)
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export type ScopedKey<Scope extends string> = Extract<TranslationKey, `${Scope}.${string}`>
|
|
30
|
+
|
|
31
|
+
export interface Locale {
|
|
32
|
+
code: LocaleCode
|
|
33
|
+
disabled?: boolean
|
|
34
|
+
iso?: string
|
|
35
|
+
dir?: 'ltr' | 'rtl' | 'auto'
|
|
36
|
+
displayName?: string
|
|
37
|
+
baseUrl?: string
|
|
38
|
+
baseDefault?: boolean
|
|
39
|
+
fallbackLocale?: string
|
|
40
|
+
[key: string]: unknown
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface DefineI18nRouteConfig {
|
|
44
|
+
locales?: string[] | Record<LocaleCode, Translations>
|
|
45
|
+
localeRoutes?: Record<LocaleCode, string>
|
|
46
|
+
disableMeta?: boolean | string[]
|
|
47
|
+
}
|
|
48
|
+
export type I18nRouteParams = Record<LocaleCode, Record<string, string>> | null
|
|
49
|
+
|
|
50
|
+
export type Params = Record<string, string | number | boolean>
|
|
51
|
+
|
|
52
|
+
export type Getter = (key: TranslationKey, params?: Record<string, string | number | boolean>, defaultValue?: string) => unknown
|
|
53
|
+
export type PluralFunc = (key: TranslationKey, count: number, params: Params, locale: string, getter: Getter) => string | null
|
|
54
|
+
|
|
55
|
+
export type GlobalLocaleRoutes = Record<string, Record<LocaleCode, string> | false | boolean> | null | undefined
|
|
56
|
+
|
|
57
|
+
export type Strategies = 'no_prefix' | 'prefix_except_default' | 'prefix' | 'prefix_and_default'
|
|
58
|
+
|
|
59
|
+
export type MissingHandler = (
|
|
60
|
+
locale: string,
|
|
61
|
+
key: TranslationKey,
|
|
62
|
+
routeName: string,
|
|
63
|
+
instance?: unknown,
|
|
64
|
+
type?: string
|
|
65
|
+
) => void
|
|
66
|
+
|
|
67
|
+
export interface ModuleOptions {
|
|
68
|
+
locales?: Locale[]
|
|
69
|
+
meta?: boolean
|
|
70
|
+
strategy?: Strategies
|
|
71
|
+
metaBaseUrl?: string
|
|
72
|
+
define?: boolean
|
|
73
|
+
redirects?: boolean
|
|
74
|
+
plugin?: boolean
|
|
75
|
+
hooks?: boolean
|
|
76
|
+
defaultLocale?: string
|
|
77
|
+
apiBaseUrl?: string
|
|
78
|
+
apiBaseClientHost?: string
|
|
79
|
+
apiBaseServerHost?: string
|
|
80
|
+
translationDir?: string
|
|
81
|
+
autoDetectLanguage?: boolean
|
|
82
|
+
autoDetectPath?: string
|
|
83
|
+
disableWatcher?: boolean
|
|
84
|
+
types?: boolean
|
|
85
|
+
includeDefaultLocaleRoute?: boolean
|
|
86
|
+
routesLocaleLinks?: { [key: string]: string }
|
|
87
|
+
plural?: string | PluralFunc
|
|
88
|
+
disablePageLocales?: boolean
|
|
89
|
+
fallbackLocale?: string
|
|
90
|
+
localeCookie?: string
|
|
91
|
+
debug?: boolean
|
|
92
|
+
globalLocaleRoutes?: GlobalLocaleRoutes
|
|
93
|
+
customRegexMatcher?: string | RegExp
|
|
94
|
+
noPrefixRedirect?: boolean
|
|
95
|
+
canonicalQueryWhitelist?: string[]
|
|
96
|
+
excludePatterns?: (string | RegExp)[]
|
|
97
|
+
routeLocales?: Record<string, string[]>
|
|
98
|
+
routeDisableMeta?: Record<string, boolean | string[]>
|
|
99
|
+
missingWarn?: boolean
|
|
100
|
+
experimental?: {
|
|
101
|
+
i18nPreviousPageFallback?: boolean
|
|
102
|
+
hmr?: boolean
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface ModuleOptionsExtend extends ModuleOptions {
|
|
107
|
+
dateBuild: number
|
|
108
|
+
hashMode: boolean
|
|
109
|
+
isSSG: boolean
|
|
110
|
+
apiBaseUrl: string
|
|
111
|
+
disablePageLocales: boolean
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface ModulePrivateOptionsExtend extends ModuleOptions {
|
|
115
|
+
rootDir: string
|
|
116
|
+
rootDirs: string[]
|
|
117
|
+
debug: boolean
|
|
118
|
+
translationDir: string
|
|
119
|
+
fallbackLocale: string
|
|
120
|
+
apiBaseUrl: string
|
|
121
|
+
apiBaseClientHost?: string
|
|
122
|
+
apiBaseServerHost?: string
|
|
123
|
+
customRegexMatcher?: string | RegExp
|
|
124
|
+
routesLocaleLinks?: { [key: string]: string }
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface PluralTranslations {
|
|
128
|
+
singular: string
|
|
129
|
+
plural: string
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export type CleanTranslation = string | number | boolean | Translations | PluralTranslations | null
|
|
133
|
+
export type Translation = CleanTranslation | unknown
|
|
134
|
+
|
|
135
|
+
export interface Translations {
|
|
136
|
+
[key: string]: Translation
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const init = () => {}
|
|
140
|
+
|
|
141
|
+
export { init }
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2018",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationDir": "./dist",
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"rootDir": "./src",
|
|
16
|
+
"baseUrl": "./",
|
|
17
|
+
"paths": {
|
|
18
|
+
"*": ["node_modules/*", "src/types/*"]
|
|
19
|
+
},
|
|
20
|
+
"types": ["jest", "node"]
|
|
21
|
+
},
|
|
22
|
+
"include": ["src/**/*"],
|
|
23
|
+
"exclude": ["node_modules", "dist", "tests"]
|
|
24
|
+
}
|
package/vite.config.mts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import { resolve } from 'node:path'
|
|
4
|
+
import { defineConfig } from 'vite'
|
|
5
|
+
import dts from 'vite-plugin-dts'
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
build: {
|
|
9
|
+
lib: {
|
|
10
|
+
entry: resolve(__dirname, 'src/index.ts'),
|
|
11
|
+
name: '@i18n-micro/core',
|
|
12
|
+
formats: ['cjs', 'es'],
|
|
13
|
+
fileName: format => `index.${format === 'cjs' ? 'cjs' : 'mjs'}`,
|
|
14
|
+
},
|
|
15
|
+
rollupOptions: {
|
|
16
|
+
external: ['vue'],
|
|
17
|
+
output: {
|
|
18
|
+
exports: 'named',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
plugins: [
|
|
23
|
+
dts(),
|
|
24
|
+
],
|
|
25
|
+
})
|