@intlify/vue-i18n-extensions 9.0.0 → 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 +5 -8
- 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 +56 -80
- 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.0",
|
|
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,41 +10,68 @@
|
|
|
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",
|
|
37
62
|
"@vue/runtime-dom": "^3.2.45",
|
|
38
63
|
"@vue/server-renderer": "^3.2.45",
|
|
39
64
|
"api-docs-gen": "^0.4.0",
|
|
40
|
-
"bumpp": "^
|
|
41
|
-
"eslint": "^9.11.0",
|
|
65
|
+
"bumpp": "^12.0.0",
|
|
42
66
|
"get-port-please": "^3.1.2",
|
|
43
|
-
"gh-changelogen": "^0.2
|
|
44
|
-
"
|
|
45
|
-
"jsdom": "^24.0.0",
|
|
46
|
-
"lint-staged": "^17.0.5",
|
|
67
|
+
"gh-changelogen": "^2.0.2",
|
|
68
|
+
"jsdom": "^31.0.0",
|
|
47
69
|
"opener": "^1.5.2",
|
|
48
|
-
"
|
|
49
|
-
"playwright": "^1.44.0",
|
|
50
|
-
"prettier": "^3.8.3",
|
|
51
|
-
"tsx": "^4.22.3",
|
|
70
|
+
"playwright": "^1.64.1",
|
|
52
71
|
"typescript": "^5.9.3",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"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",
|
|
57
75
|
"vue": "^3.2.45"
|
|
58
76
|
},
|
|
59
77
|
"peerDependencies": {
|
|
@@ -76,68 +94,26 @@
|
|
|
76
94
|
"optional": true
|
|
77
95
|
}
|
|
78
96
|
},
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"import": "./dist/index.mjs",
|
|
82
|
-
"require": "./dist/index.cjs"
|
|
83
|
-
},
|
|
84
|
-
"./package.json": "./package.json"
|
|
85
|
-
},
|
|
86
|
-
"main": "dist/index.cjs",
|
|
87
|
-
"module": "dist/index.mjs",
|
|
88
|
-
"types": "dist/index.d.ts",
|
|
89
|
-
"files": [
|
|
90
|
-
"dist/index.cjs",
|
|
91
|
-
"dist/index.mjs",
|
|
92
|
-
"dist/index.d.ts",
|
|
93
|
-
"dist/index.d.mts",
|
|
94
|
-
"dist/index.d.cts"
|
|
95
|
-
],
|
|
96
|
-
"repository": {
|
|
97
|
-
"type": "git",
|
|
98
|
-
"url": "git+https://github.com/intlify/vue-i18n-extensions.git"
|
|
97
|
+
"engines": {
|
|
98
|
+
"node": ">= 22"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
|
-
"
|
|
102
|
-
"changelog": "gh-changelogen --repo=intlify/vue-i18n-extensions",
|
|
103
|
-
"release": "bumpp --commit \"release: v%s\" --push --tag",
|
|
101
|
+
"release": "bumpp",
|
|
104
102
|
"build": "pnpm build:transpile",
|
|
105
|
-
"build:nightly": "pnpm build:transpile && pnpm build:extract",
|
|
106
103
|
"build:docs": "api-docs-gen ./temp/vue-i18n-extensions.api.json -c ./docsgen.config.cjs -o ./docs",
|
|
107
104
|
"build:extract": "api-extractor run -l -c ./api-extractor.json --typescript-compiler-folder node_modules/typescript",
|
|
108
|
-
"build:transpile": "
|
|
109
|
-
"check-install": "
|
|
105
|
+
"build:transpile": "vp pack",
|
|
106
|
+
"check-install": "vpx scripts/playwright.ts",
|
|
110
107
|
"clean": "git clean -fdx",
|
|
111
108
|
"coverage": "opener coverage/lcov-report/index.html",
|
|
112
109
|
"example": "webpack serve --config example/webpack.config.js --inline --hot",
|
|
113
|
-
"lint": "
|
|
114
|
-
"
|
|
115
|
-
"lint:eslint": "eslint .",
|
|
116
|
-
"fix": "pnpm --color run \"/^fix:/\"",
|
|
117
|
-
"fix:prettier": "prettier . --write",
|
|
118
|
-
"fix:eslint": "eslint . --fix",
|
|
110
|
+
"lint": "vp check",
|
|
111
|
+
"fix": "vp check --fix",
|
|
119
112
|
"test": "pnpm test:cover && pnpm check-install && pnpm test:e2e",
|
|
120
113
|
"test:cover": "pnpm test:unit --coverage --coverage.include=src",
|
|
121
|
-
"test:e2e": "
|
|
122
|
-
"test:unit": "
|
|
123
|
-
"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",
|
|
124
117
|
"watch": "tsc -p tsconfig.cjs.json --watch"
|
|
125
|
-
},
|
|
126
|
-
"packageManager": "pnpm@11.2.2",
|
|
127
|
-
"engines": {
|
|
128
|
-
"node": ">= 22"
|
|
129
|
-
},
|
|
130
|
-
"lint-staged": {
|
|
131
|
-
"*.{json,md,yml}": [
|
|
132
|
-
"prettier --write"
|
|
133
|
-
],
|
|
134
|
-
"*.{js,mjs,cjs}": [
|
|
135
|
-
"prettier --write",
|
|
136
|
-
"eslint --fix"
|
|
137
|
-
],
|
|
138
|
-
"*.ts?(x)": [
|
|
139
|
-
"prettier --parser=typescript --write",
|
|
140
|
-
"eslint --fix"
|
|
141
|
-
]
|
|
142
118
|
}
|
|
143
|
-
}
|
|
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 };
|