@intlify/vue-i18n-extensions 6.1.1 → 7.0.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/dist/index.cjs CHANGED
@@ -394,18 +394,21 @@ function generateTranslationCode(context, mode, params, translationSignatures) {
394
394
  return mode === "composition" ? generateComposableCode(context, params, translationSignatures) : generateLegacyCode(context, params);
395
395
  }
396
396
  function generateTranslationCallableSignatures(context, translationSignatures) {
397
- const { prefixIdentifiers, bindingMetadata, inline } = context;
397
+ const baseResolver = (context2, signature) => {
398
+ const { prefixIdentifiers, bindingMetadata, inline } = context2;
399
+ if (inline && signature !== GLOBAL_TRANSLATE_SIGNATURE) {
400
+ return signature;
401
+ }
402
+ const type = shared.hasOwn(bindingMetadata, signature) && bindingMetadata[signature];
403
+ const bindingContext = prefixIdentifiers ? type && type.startsWith("setup") || type === compilerDom.BindingTypes.LITERAL_CONST ? "$setup." : "_ctx." : "";
404
+ return `${bindingContext}${signature}`;
405
+ };
398
406
  return translationSignatures.map((signatureOrResolver) => {
399
407
  if (shared.isFunction(signatureOrResolver)) {
400
- return signatureOrResolver(context);
408
+ return signatureOrResolver(context, baseResolver);
401
409
  }
402
- if (inline && signatureOrResolver !== GLOBAL_TRANSLATE_SIGNATURE) {
403
- return signatureOrResolver;
404
- }
405
- const type = shared.hasOwn(bindingMetadata, signatureOrResolver) && bindingMetadata[signatureOrResolver];
406
- const bindingContext = prefixIdentifiers ? type && type.startsWith("setup") || type === compilerDom.BindingTypes.LITERAL_CONST ? "$setup." : "_ctx." : "";
407
- return `${bindingContext}${signatureOrResolver}`;
408
- }).join(" || ");
410
+ return baseResolver(context, signatureOrResolver);
411
+ }).filter(Boolean).join(" || ");
409
412
  }
410
413
  function generateComposableCode(context, params, translationSignatures) {
411
414
  const baseCode = `(${generateTranslationCallableSignatures(context, translationSignatures)})`;
package/dist/index.d.cts CHANGED
@@ -36,15 +36,15 @@ import { I18n, I18nMode } from 'vue-i18n';
36
36
  * })
37
37
  * ```
38
38
  */
39
- type TranslationSignatureResolver = (context: TransformContext) => string;
39
+ type TranslationSignatureResolver = (context: TransformContext, baseResolver: (context: TransformContext, signature: string) => string | undefined) => string | undefined;
40
40
  /**
41
41
  * Transform options for `v-t` custom directive
42
42
  *
43
43
  * @public
44
44
  */
45
- interface TransformVTDirectiveOptions<Messages extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
46
- DateTimeFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
47
- NumberFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
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
48
  Legacy extends boolean = true> {
49
49
  /**
50
50
  * I18n instance
@@ -123,9 +123,9 @@ Legacy extends boolean = true> {
123
123
  * ```
124
124
  * @public
125
125
  */
126
- declare function transformVTDirective<Messages extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
127
- DateTimeFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
128
- NumberFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
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
129
  Legacy extends boolean = true>(options?: TransformVTDirectiveOptions<Messages, DateTimeFormats, NumberFormats, Legacy>): DirectiveTransform;
130
130
 
131
131
  export { type TransformVTDirectiveOptions, type TranslationSignatureResolver, transformVTDirective };
package/dist/index.d.mts CHANGED
@@ -36,15 +36,15 @@ import { I18n, I18nMode } from 'vue-i18n';
36
36
  * })
37
37
  * ```
38
38
  */
39
- type TranslationSignatureResolver = (context: TransformContext) => string;
39
+ type TranslationSignatureResolver = (context: TransformContext, baseResolver: (context: TransformContext, signature: string) => string | undefined) => string | undefined;
40
40
  /**
41
41
  * Transform options for `v-t` custom directive
42
42
  *
43
43
  * @public
44
44
  */
45
- interface TransformVTDirectiveOptions<Messages extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
46
- DateTimeFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
47
- NumberFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
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
48
  Legacy extends boolean = true> {
49
49
  /**
50
50
  * I18n instance
@@ -123,9 +123,9 @@ Legacy extends boolean = true> {
123
123
  * ```
124
124
  * @public
125
125
  */
126
- declare function transformVTDirective<Messages extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
127
- DateTimeFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
128
- NumberFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
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
129
  Legacy extends boolean = true>(options?: TransformVTDirectiveOptions<Messages, DateTimeFormats, NumberFormats, Legacy>): DirectiveTransform;
130
130
 
131
131
  export { type TransformVTDirectiveOptions, type TranslationSignatureResolver, transformVTDirective };
package/dist/index.d.ts CHANGED
@@ -36,15 +36,15 @@ import { I18n, I18nMode } from 'vue-i18n';
36
36
  * })
37
37
  * ```
38
38
  */
39
- type TranslationSignatureResolver = (context: TransformContext) => string;
39
+ type TranslationSignatureResolver = (context: TransformContext, baseResolver: (context: TransformContext, signature: string) => string | undefined) => string | undefined;
40
40
  /**
41
41
  * Transform options for `v-t` custom directive
42
42
  *
43
43
  * @public
44
44
  */
45
- interface TransformVTDirectiveOptions<Messages extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
46
- DateTimeFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
47
- NumberFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
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
48
  Legacy extends boolean = true> {
49
49
  /**
50
50
  * I18n instance
@@ -123,9 +123,9 @@ Legacy extends boolean = true> {
123
123
  * ```
124
124
  * @public
125
125
  */
126
- declare function transformVTDirective<Messages extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
127
- DateTimeFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
128
- NumberFormats extends Record<string, unknown> = {}, // eslint-disable-line @typescript-eslint/ban-types -- TODO: fix this
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
129
  Legacy extends boolean = true>(options?: TransformVTDirectiveOptions<Messages, DateTimeFormats, NumberFormats, Legacy>): DirectiveTransform;
130
130
 
131
131
  export { type TransformVTDirectiveOptions, type TranslationSignatureResolver, transformVTDirective };
package/dist/index.mjs CHANGED
@@ -392,18 +392,21 @@ function generateTranslationCode(context, mode, params, translationSignatures) {
392
392
  return mode === "composition" ? generateComposableCode(context, params, translationSignatures) : generateLegacyCode(context, params);
393
393
  }
394
394
  function generateTranslationCallableSignatures(context, translationSignatures) {
395
- const { prefixIdentifiers, bindingMetadata, inline } = context;
395
+ const baseResolver = (context2, signature) => {
396
+ const { prefixIdentifiers, bindingMetadata, inline } = context2;
397
+ if (inline && signature !== GLOBAL_TRANSLATE_SIGNATURE) {
398
+ return signature;
399
+ }
400
+ const type = hasOwn(bindingMetadata, signature) && bindingMetadata[signature];
401
+ const bindingContext = prefixIdentifiers ? type && type.startsWith("setup") || type === BindingTypes.LITERAL_CONST ? "$setup." : "_ctx." : "";
402
+ return `${bindingContext}${signature}`;
403
+ };
396
404
  return translationSignatures.map((signatureOrResolver) => {
397
405
  if (isFunction(signatureOrResolver)) {
398
- return signatureOrResolver(context);
406
+ return signatureOrResolver(context, baseResolver);
399
407
  }
400
- if (inline && signatureOrResolver !== GLOBAL_TRANSLATE_SIGNATURE) {
401
- return signatureOrResolver;
402
- }
403
- const type = hasOwn(bindingMetadata, signatureOrResolver) && bindingMetadata[signatureOrResolver];
404
- const bindingContext = prefixIdentifiers ? type && type.startsWith("setup") || type === BindingTypes.LITERAL_CONST ? "$setup." : "_ctx." : "";
405
- return `${bindingContext}${signatureOrResolver}`;
406
- }).join(" || ");
408
+ return baseResolver(context, signatureOrResolver);
409
+ }).filter(Boolean).join(" || ");
407
410
  }
408
411
  function generateComposableCode(context, params, translationSignatures) {
409
412
  const baseCode = `(${generateTranslationCallableSignatures(context, translationSignatures)})`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@intlify/vue-i18n-extensions",
3
3
  "description": "vue-i18n extensions",
4
- "version": "6.1.1",
4
+ "version": "7.0.0",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -21,25 +21,25 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@babel/parser": "^7.24.6",
24
- "@intlify/shared": "^9.0.0",
24
+ "@intlify/shared": "^10.0.0",
25
25
  "@vue/compiler-dom": "^3.2.45",
26
- "vue-i18n": "^9.0.0"
26
+ "vue-i18n": "^10.0.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@babel/types": "^7.24.6",
30
- "@eslint/js": "^9.2.0",
30
+ "@eslint/js": "^9.11.0",
31
31
  "@microsoft/api-extractor": "^7.18.4",
32
- "@types/eslint": "^8.56.10",
33
- "@types/node": "^20.13.0",
34
- "@vitest/coverage-v8": "^1.6.0",
32
+ "@types/eslint": "^9.6.1",
33
+ "@types/node": "^22.5.5",
34
+ "@vitest/coverage-v8": "^2.1.0",
35
35
  "@vue/compiler-core": "^3.2.45",
36
36
  "@vue/compiler-sfc": "^3.2.45",
37
37
  "@vue/compiler-ssr": "^3.2.45",
38
38
  "@vue/runtime-dom": "^3.2.45",
39
39
  "@vue/server-renderer": "^3.2.45",
40
40
  "api-docs-gen": "^0.4.0",
41
- "bumpp": "^9.4.1",
42
- "eslint": "^9.2.0",
41
+ "bumpp": "^9.5.2",
42
+ "eslint": "^9.11.0",
43
43
  "get-port-please": "^3.1.2",
44
44
  "gh-changelogen": "^0.2.8",
45
45
  "globals": "^15.0.0",
@@ -49,12 +49,12 @@
49
49
  "opener": "^1.5.2",
50
50
  "pkg-types": "^1.1.1",
51
51
  "playwright": "^1.44.0",
52
- "prettier": "^3.2.5",
53
- "tsx": "^4.11.0",
54
- "typescript": "^5.4.5",
55
- "typescript-eslint": "^7.9.0",
52
+ "prettier": "^3.3.3",
53
+ "tsx": "^4.19.0",
54
+ "typescript": "^5.6.2",
55
+ "typescript-eslint": "^8.6.0",
56
56
  "unbuild": "^2.0.0",
57
- "vitest": "^1.6.0",
57
+ "vitest": "^2.1.0",
58
58
  "vue": "^3.2.45"
59
59
  },
60
60
  "peerDependencies": {