@intlify/vue-i18n-extensions 9.0.1 → 9.1.0
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 +2 -4
- package/dist/index.cjs +374 -421
- package/dist/index.d.cts +39 -41
- package/dist/index.d.mts +39 -41
- package/dist/index.mjs +373 -419
- package/package.json +49 -68
- package/dist/index.d.ts +0 -131
package/package.json
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlify/vue-i18n-extensions",
|
|
3
|
-
"
|
|
4
|
-
"version": "9.0.1",
|
|
3
|
+
"version": "9.1.0",
|
|
5
4
|
"description": "vue-i18n extensions",
|
|
6
|
-
"author": {
|
|
7
|
-
"name": "kazuya kawaguchi",
|
|
8
|
-
"email": "kawakazu80@gmail.com"
|
|
9
|
-
},
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/intlify/vue-i18n-extensions/issues"
|
|
12
|
-
},
|
|
13
|
-
"homepage": "https://github.com/intlify/vue-i18n-extensions#readme",
|
|
14
5
|
"keywords": [
|
|
15
6
|
"extensions",
|
|
16
7
|
"i18n",
|
|
@@ -19,18 +10,52 @@
|
|
|
19
10
|
"vue",
|
|
20
11
|
"vue-i18n"
|
|
21
12
|
],
|
|
13
|
+
"homepage": "https://github.com/intlify/vue-i18n-extensions#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/intlify/vue-i18n-extensions/issues"
|
|
16
|
+
},
|
|
22
17
|
"license": "MIT",
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "kazuya kawaguchi",
|
|
20
|
+
"email": "kawakazu80@gmail.com"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/intlify/vue-i18n-extensions.git"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/index.cjs",
|
|
28
|
+
"dist/index.mjs",
|
|
29
|
+
"dist/index.d.mts",
|
|
30
|
+
"dist/index.d.cts"
|
|
31
|
+
],
|
|
32
|
+
"type": "module",
|
|
33
|
+
"main": "./dist/index.cjs",
|
|
34
|
+
"module": "./dist/index.mjs",
|
|
35
|
+
"types": "./dist/index.d.cts",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./dist/index.d.mts",
|
|
40
|
+
"default": "./dist/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./dist/index.d.cts",
|
|
44
|
+
"default": "./dist/index.cjs"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"./package.json": "./package.json"
|
|
48
|
+
},
|
|
23
49
|
"dependencies": {
|
|
24
50
|
"@babel/parser": "^7.24.6",
|
|
25
51
|
"@vue/compiler-dom": "^3.2.45"
|
|
26
52
|
},
|
|
27
53
|
"devDependencies": {
|
|
28
54
|
"@babel/types": "^7.24.6",
|
|
29
|
-
"@
|
|
55
|
+
"@kazupon/vp-config": "^1.1.0",
|
|
30
56
|
"@microsoft/api-extractor": "^7.18.4",
|
|
31
|
-
"@types/eslint": "^9.6.1",
|
|
32
57
|
"@types/node": "^25.9.1",
|
|
33
|
-
"@vitest/coverage-v8": "
|
|
58
|
+
"@vitest/coverage-v8": "5.0.5",
|
|
34
59
|
"@vue/compiler-core": "^3.2.45",
|
|
35
60
|
"@vue/compiler-sfc": "^3.2.45",
|
|
36
61
|
"@vue/compiler-ssr": "^3.2.45",
|
|
@@ -38,21 +63,15 @@
|
|
|
38
63
|
"@vue/server-renderer": "^3.2.45",
|
|
39
64
|
"api-docs-gen": "^0.4.0",
|
|
40
65
|
"bumpp": "^12.0.0",
|
|
41
|
-
"eslint": "^9.11.0",
|
|
42
66
|
"get-port-please": "^3.1.2",
|
|
43
67
|
"gh-changelogen": "^2.0.2",
|
|
44
|
-
"
|
|
45
|
-
"jsdom": "^24.0.0",
|
|
46
|
-
"lint-staged": "^17.0.5",
|
|
68
|
+
"jsdom": "^31.0.0",
|
|
47
69
|
"opener": "^1.5.2",
|
|
48
70
|
"playwright": "^1.64.1",
|
|
49
|
-
"prettier": "^3.8.3",
|
|
50
|
-
"tsx": "^4.22.3",
|
|
51
71
|
"typescript": "^5.9.3",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"vitest": "^4.1.7",
|
|
72
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
|
|
73
|
+
"vite-plus": "1.4.0",
|
|
74
|
+
"vitest": "5.0.5",
|
|
56
75
|
"vue": "^3.2.45"
|
|
57
76
|
},
|
|
58
77
|
"peerDependencies": {
|
|
@@ -75,64 +94,26 @@
|
|
|
75
94
|
"optional": true
|
|
76
95
|
}
|
|
77
96
|
},
|
|
78
|
-
"exports": {
|
|
79
|
-
".": {
|
|
80
|
-
"import": "./dist/index.mjs",
|
|
81
|
-
"require": "./dist/index.cjs"
|
|
82
|
-
},
|
|
83
|
-
"./package.json": "./package.json"
|
|
84
|
-
},
|
|
85
|
-
"main": "dist/index.cjs",
|
|
86
|
-
"module": "dist/index.mjs",
|
|
87
|
-
"types": "dist/index.d.ts",
|
|
88
|
-
"files": [
|
|
89
|
-
"dist/index.cjs",
|
|
90
|
-
"dist/index.mjs",
|
|
91
|
-
"dist/index.d.ts",
|
|
92
|
-
"dist/index.d.mts",
|
|
93
|
-
"dist/index.d.cts"
|
|
94
|
-
],
|
|
95
|
-
"repository": {
|
|
96
|
-
"type": "git",
|
|
97
|
-
"url": "git+https://github.com/intlify/vue-i18n-extensions.git"
|
|
98
|
-
},
|
|
99
97
|
"engines": {
|
|
100
98
|
"node": ">= 22"
|
|
101
99
|
},
|
|
102
|
-
"lint-staged": {
|
|
103
|
-
"*.{json,md,yml}": [
|
|
104
|
-
"prettier --write"
|
|
105
|
-
],
|
|
106
|
-
"*.{js,mjs,cjs}": [
|
|
107
|
-
"prettier --write",
|
|
108
|
-
"eslint --fix"
|
|
109
|
-
],
|
|
110
|
-
"*.ts?(x)": [
|
|
111
|
-
"prettier --parser=typescript --write",
|
|
112
|
-
"eslint --fix"
|
|
113
|
-
]
|
|
114
|
-
},
|
|
115
100
|
"scripts": {
|
|
116
101
|
"release": "bumpp",
|
|
117
102
|
"build": "pnpm build:transpile",
|
|
118
103
|
"build:docs": "api-docs-gen ./temp/vue-i18n-extensions.api.json -c ./docsgen.config.cjs -o ./docs",
|
|
119
104
|
"build:extract": "api-extractor run -l -c ./api-extractor.json --typescript-compiler-folder node_modules/typescript",
|
|
120
|
-
"build:transpile": "
|
|
121
|
-
"check-install": "
|
|
105
|
+
"build:transpile": "vp pack",
|
|
106
|
+
"check-install": "vpx scripts/playwright.ts",
|
|
122
107
|
"clean": "git clean -fdx",
|
|
123
108
|
"coverage": "opener coverage/lcov-report/index.html",
|
|
124
109
|
"example": "webpack serve --config example/webpack.config.js --inline --hot",
|
|
125
|
-
"lint": "
|
|
126
|
-
"
|
|
127
|
-
"lint:eslint": "eslint .",
|
|
128
|
-
"fix": "pnpm --color run \"/^fix:/\"",
|
|
129
|
-
"fix:prettier": "prettier . --write",
|
|
130
|
-
"fix:eslint": "eslint . --fix",
|
|
110
|
+
"lint": "vp check",
|
|
111
|
+
"fix": "vp check --fix",
|
|
131
112
|
"test": "pnpm test:cover && pnpm check-install && pnpm test:e2e",
|
|
132
113
|
"test:cover": "pnpm test:unit --coverage --coverage.include=src",
|
|
133
|
-
"test:e2e": "
|
|
134
|
-
"test:unit": "
|
|
135
|
-
"test:watch": "
|
|
114
|
+
"test:e2e": "vp test run -c ./vitest.e2e.config.ts",
|
|
115
|
+
"test:unit": "vp test run",
|
|
116
|
+
"test:watch": "vp test watch --no-cache",
|
|
136
117
|
"watch": "tsc -p tsconfig.cjs.json --watch"
|
|
137
118
|
}
|
|
138
119
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { TransformContext, DirectiveTransform } from '@vue/compiler-dom';
|
|
2
|
-
import { I18n, I18nMode } from 'vue-i18n';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Translation signature resolver
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* This resolver is used at {@link TransformVTDirectiveOptions | 'translationSignatures' option}
|
|
9
|
-
*
|
|
10
|
-
* @public
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```js
|
|
14
|
-
* import { compile } from '@vue/compiler-dom'
|
|
15
|
-
* import { transformVTDirective } from '@intlify/vue-i18n-extensions'
|
|
16
|
-
*
|
|
17
|
-
* // the below is just an example, you can use your own signature resolver
|
|
18
|
-
* const signatureMap = new Map()
|
|
19
|
-
*
|
|
20
|
-
* const transformVT = transformVTDirective({
|
|
21
|
-
* translationSignatures: (context) => {
|
|
22
|
-
* const { prefixIdentifiers, bindingMetadata, inline, filename } = context
|
|
23
|
-
* let signature = ''
|
|
24
|
-
*
|
|
25
|
-
* // something logic to resolve signature like using `signatureMap`
|
|
26
|
-
* // signature = signatureMap.get(filename)
|
|
27
|
-
* // ...
|
|
28
|
-
*
|
|
29
|
-
* return signature
|
|
30
|
-
* }
|
|
31
|
-
* })
|
|
32
|
-
*
|
|
33
|
-
* const { code } = compile(`<p v-t="'hello'"></p>`, {
|
|
34
|
-
* // ...
|
|
35
|
-
* directiveTransforms: { t: transformVT }
|
|
36
|
-
* })
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
type TranslationSignatureResolver = (context: TransformContext, baseResolver: (context: TransformContext, signature: string) => string | undefined) => string | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Transform options for `v-t` custom directive
|
|
42
|
-
*
|
|
43
|
-
* @public
|
|
44
|
-
*/
|
|
45
|
-
interface TransformVTDirectiveOptions<Messages extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/no-empty-object-type -- TODO: fix this
|
|
46
|
-
DateTimeFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/no-empty-object-type -- TODO: fix this
|
|
47
|
-
NumberFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/no-empty-object-type -- TODO: fix this
|
|
48
|
-
Legacy extends boolean = true> {
|
|
49
|
-
/**
|
|
50
|
-
* I18n instance
|
|
51
|
-
*
|
|
52
|
-
* @remarks
|
|
53
|
-
* If this option is specified, `v-t` custom directive transform uses an I18n instance to pre-translate.
|
|
54
|
-
* The translation will use the global resources registered in the I18n instance,
|
|
55
|
-
* that is, `v-t` directive transform is also a limitation that the resources of each component cannot be used.
|
|
56
|
-
*/
|
|
57
|
-
i18n?: I18n<Messages, DateTimeFormats, NumberFormats, Legacy>;
|
|
58
|
-
/**
|
|
59
|
-
* I18n Mode
|
|
60
|
-
*
|
|
61
|
-
* @remarks
|
|
62
|
-
* Specify the API style of vue-i18n. If you use legacy API style (e.g. `$t`) at vue-i18n, you need to specify `legacy`.
|
|
63
|
-
*
|
|
64
|
-
* @default 'composition'
|
|
65
|
-
*/
|
|
66
|
-
mode?: I18nMode;
|
|
67
|
-
/**
|
|
68
|
-
* Translation function signatures
|
|
69
|
-
*
|
|
70
|
-
* @remarks
|
|
71
|
-
* You can specify the signature of the translation function attached to the binding context when it is codegen in the Vue Compiler.
|
|
72
|
-
* If you have changed the signature to a non `t` signature in the `setup` hook or `<script setup>`, you can safely SSR it.
|
|
73
|
-
* If each Vue component has a different signature for the translation function, you can specify several in an array for safe SSR.
|
|
74
|
-
* This option value is `undefined` and the signature attached to the binding context is `t`.
|
|
75
|
-
*/
|
|
76
|
-
translationSignatures?: string | TranslationSignatureResolver | string[] | TranslationSignatureResolver[] | (string | TranslationSignatureResolver)[];
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Transform `v-t` custom directive
|
|
80
|
-
*
|
|
81
|
-
* @remarks
|
|
82
|
-
* Transform that `v-t` custom directive is optimized vue-i18n code by Vue compiler.
|
|
83
|
-
* This transform can improve the performance by pre-translating, and it does support SSR.
|
|
84
|
-
*
|
|
85
|
-
* @param options - `v-t` custom directive transform options, see {@link TransformVTDirectiveOptions}
|
|
86
|
-
* @returns Directive transform
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* ```js
|
|
90
|
-
* import { compile } from '@vue/compiler-dom'
|
|
91
|
-
* import { createI18n } from 'vue-i18n'
|
|
92
|
-
* import { transformVTDirective } from '@intlify/vue-i18n-extensions'
|
|
93
|
-
*
|
|
94
|
-
* // create i18n instance
|
|
95
|
-
* const i18n = createI18n({
|
|
96
|
-
* locale: 'ja',
|
|
97
|
-
* messages: {
|
|
98
|
-
* en: {
|
|
99
|
-
* hello: 'hello'
|
|
100
|
-
* },
|
|
101
|
-
* ja: {
|
|
102
|
-
* hello: 'こんにちは'
|
|
103
|
-
* }
|
|
104
|
-
* }
|
|
105
|
-
* })
|
|
106
|
-
*
|
|
107
|
-
* // get transform from `transformVTDirective` function, with `i18n` option
|
|
108
|
-
* const transformVT = transformVTDirective({ i18n })
|
|
109
|
-
*
|
|
110
|
-
* const { code } = compile(`<p v-t="'hello'"></p>`, {
|
|
111
|
-
* mode: 'function',
|
|
112
|
-
* hoistStatic: true,
|
|
113
|
-
* prefixIdentifiers: true,
|
|
114
|
-
* directiveTransforms: { t: transformVT } // <- you need to specify to `directiveTransforms` option!
|
|
115
|
-
* })
|
|
116
|
-
*
|
|
117
|
-
* console.log(code)
|
|
118
|
-
* // output ->
|
|
119
|
-
* // const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = Vue
|
|
120
|
-
* // return function render(_ctx, _cache) {
|
|
121
|
-
* // return (_openBlock(), _createBlock(\\"div\\", null, \\"こんにちは!\\"))
|
|
122
|
-
* // }
|
|
123
|
-
* ```
|
|
124
|
-
* @public
|
|
125
|
-
*/
|
|
126
|
-
declare function transformVTDirective<Messages extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/no-empty-object-type -- TODO: fix this
|
|
127
|
-
DateTimeFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/no-empty-object-type -- TODO: fix this
|
|
128
|
-
NumberFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/no-empty-object-type -- TODO: fix this
|
|
129
|
-
Legacy extends boolean = true>(options?: TransformVTDirectiveOptions<Messages, DateTimeFormats, NumberFormats, Legacy>): DirectiveTransform;
|
|
130
|
-
|
|
131
|
-
export { type TransformVTDirectiveOptions, type TranslationSignatureResolver, transformVTDirective };
|