@gunshi/plugin-i18n 0.27.0-alpha.6 → 0.27.0-alpha.7

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.
Files changed (2) hide show
  1. package/lib/index.d.ts +87 -40
  2. package/package.json +5 -5
package/lib/index.d.ts CHANGED
@@ -3,74 +3,115 @@ import { Awaitable, Command, CommandContext, DefaultGunshiParams, ExtractArgs, G
3
3
  //#region rolldown:runtime
4
4
 
5
5
  //#endregion
6
- //#region ../../node_modules/.pnpm/args-tokens@0.20.1/node_modules/args-tokens/lib/resolver-U72Jg6Ll.d.ts
6
+ //#region ../../node_modules/.pnpm/args-tokens@0.22.0/node_modules/args-tokens/lib/resolver-BoS-UnqX.d.ts
7
7
  //#region src/resolver.d.ts
8
8
 
9
9
  /**
10
- * An argument schema
11
- * This schema is similar to the schema of the `node:utils`.
12
- * difference is that:
13
- * - `required` property and `description` property are added
14
- * - `type` is not only 'string' and 'boolean', but also 'number', 'enum', 'positional', 'custom' too.
15
- * - `default` property type, not support multiple types
16
- */
10
+ * An argument schema
11
+ * This schema is similar to the schema of the `node:utils`.
12
+ * difference is that:
13
+ * - `required` property and `description` property are added
14
+ * - `type` is not only 'string' and 'boolean', but also 'number', 'enum', 'positional', 'custom' too.
15
+ * - `default` property type, not support multiple types
16
+ */
17
17
  interface ArgSchema {
18
18
  /**
19
- * Type of argument.
20
- */
21
- type: "string" | "boolean" | "number" | "enum" | "positional" | "custom";
19
+ * Type of argument.
20
+ */
21
+ type: 'string' | 'boolean' | 'number' | 'enum' | 'positional' | 'custom';
22
22
  /**
23
- * A single character alias for the argument.
24
- */
23
+ * A single character alias for the argument.
24
+ */
25
25
  short?: string;
26
26
  /**
27
- * A description of the argument.
28
- */
27
+ * A description of the argument.
28
+ */
29
29
  description?: string;
30
30
  /**
31
- * Whether the argument is required or not.
32
- */
31
+ * Whether the argument is required or not.
32
+ */
33
33
  required?: true;
34
34
  /**
35
- * Whether the argument allow multiple values or not.
36
- */
35
+ * Whether the argument allow multiple values or not.
36
+ */
37
37
  multiple?: true;
38
38
  /**
39
- * Whether the negatable option for `boolean` type
40
- */
39
+ * Whether the negatable option for `boolean` type
40
+ */
41
41
  negatable?: boolean;
42
42
  /**
43
- * The allowed values of the argument, and string only. This property is only used when the type is 'enum'.
44
- */
43
+ * The allowed values of the argument, and string only. This property is only used when the type is 'enum'.
44
+ */
45
45
  choices?: string[] | readonly string[];
46
46
  /**
47
- * The default value of the argument.
48
- * if the type is 'enum', the default value must be one of the allowed values.
49
- */
47
+ * The default value of the argument.
48
+ * if the type is 'enum', the default value must be one of the allowed values.
49
+ */
50
50
  default?: string | boolean | number;
51
51
  /**
52
- * Whether to convert the argument name to kebab-case.
53
- */
52
+ * Whether to convert the argument name to kebab-case.
53
+ */
54
54
  toKebab?: true;
55
55
  /**
56
- * A function to parse the value of the argument. if the type is 'custom', this function is required.
57
- * If argument value will be invalid, this function have to throw an error.
58
- * @param value
59
- * @returns Parsed value
60
- * @throws An Error, If the value is invalid. Error type should be `Error` or extends it
61
- */
62
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ * A function to parse the value of the argument. if the type is 'custom', this function is required.
57
+ * If argument value will be invalid, this function have to throw an error.
58
+ * @param value
59
+ * @returns Parsed value
60
+ * @throws An Error, If the value is invalid. Error type should be `Error` or extends it
61
+ */
63
62
  parse?: (value: string) => any;
64
63
  }
65
64
  /**
66
- * An object that contains {@link ArgSchema | argument schema}.
67
- */
65
+ * An object that contains {@link ArgSchema | argument schema}.
66
+ */
68
67
  interface Args {
69
68
  [option: string]: ArgSchema;
70
69
  }
71
70
  /**
72
- * An object that contains the values of the arguments.
73
- */
71
+ * An object that contains the values of the arguments.
72
+ */
73
+ //#endregion
74
+ //#region ../gunshi/src/types.d.ts
75
+ /**
76
+ * Extend command context type. This type is used to extend the command context with additional properties at {@link CommandContext.extensions}.
77
+ * @since v0.27.0
78
+ */
79
+ type ExtendContext = Record<string, unknown>;
80
+ /**
81
+ * Gunshi unified parameter type.
82
+ * This type combines both argument definitions and command context extensions.
83
+ * @since v0.27.0
84
+ */
85
+ interface GunshiParams$1<P extends {
86
+ args?: Args;
87
+ extensions?: ExtendContext;
88
+ } = {
89
+ args: Args;
90
+ extensions: {};
91
+ }> {
92
+ /**
93
+ * Command argument definitions
94
+ */
95
+ args: P extends {
96
+ args: infer A extends Args;
97
+ } ? A : Args;
98
+ /**
99
+ * Command context extensions
100
+ */
101
+ extensions: P extends {
102
+ extensions: infer E extends ExtendContext;
103
+ } ? E : {};
104
+ }
105
+ /**
106
+ * Default Gunshi parameters
107
+ * @since v0.27.0
108
+ */
109
+ type DefaultGunshiParams$1 = GunshiParams$1;
110
+ /**
111
+ * Generic constraint for command-related types.
112
+ * This type constraint allows both GunshiParams and objects with extensions.
113
+ * @since v0.27.0
114
+ */
74
115
  declare namespace constants_d_exports {
75
116
  export { ARG_NEGATABLE_PREFIX, ARG_PREFIX, ARG_PREFIX_AND_KEY_SEPARATOR, BUILD_IN_PREFIX_AND_KEY_SEPARATOR, BUILT_IN_KEY_SEPARATOR, BUILT_IN_PREFIX, COMMAND_BUILTIN_RESOURCE_KEYS, COMMON_ARGS, PLUGIN_PREFIX };
76
117
  }
@@ -133,6 +174,12 @@ type CommandBuiltinKeys = GenerateNamespacedKey<BuiltinResourceKeys> | 'descript
133
174
  * The command i18n option keys are used by the i18n plugin for translation.
134
175
  */
135
176
  type CommandArgKeys<A extends Args> = GenerateNamespacedKey<KeyOfArgs<RemovedIndex<A>>, typeof ARG_PREFIX>;
177
+ /**
178
+ * Translation function interface
179
+ */
180
+ interface Translation<T extends string = CommandBuiltinKeys, G extends GunshiParams$1<any> = DefaultGunshiParams$1> {
181
+ <O = CommandArgKeys<G['args']>, K = CommandBuiltinKeys | O | T>(key: K, values?: Record<string, unknown>): string;
182
+ }
136
183
  //#endregion
137
184
  //#region src/types.d.ts
138
185
  /**
@@ -160,7 +207,7 @@ interface I18nCommandContext<G extends GunshiParams<any> = DefaultGunshiParams>
160
207
  * - For custom keys: returns an empty string ('')
161
208
  * - For built-in keys (prefixed with '_:'): returns the key itself
162
209
  */
163
- translate: <T extends string = CommandBuiltinKeys, O = CommandArgKeys<G['args']>, K = CommandBuiltinKeys | O | T>(key: K, values?: Record<string, unknown>) => string;
210
+ translate: Translation<CommandBuiltinKeys, G>;
164
211
  }
165
212
  /**
166
213
  * i18n plugin options
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gunshi/plugin-i18n",
3
3
  "description": "internationalization plugin for gunshi",
4
- "version": "0.27.0-alpha.6",
4
+ "version": "0.27.0-alpha.7",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -53,10 +53,10 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@gunshi/plugin": "0.27.0-alpha.6"
56
+ "@gunshi/plugin": "0.27.0-alpha.7"
57
57
  },
58
58
  "peerDependencies": {
59
- "@gunshi/plugin-global": "0.27.0-alpha.6"
59
+ "@gunshi/plugin-global": "0.27.0-alpha.7"
60
60
  },
61
61
  "peerDependenciesMeta": {
62
62
  "@gunshi/plugin-global": {
@@ -73,8 +73,8 @@
73
73
  "tsdown": "^0.12.9",
74
74
  "typedoc": "^0.28.7",
75
75
  "typedoc-plugin-markdown": "^4.7.0",
76
- "@gunshi/resources": "0.27.0-alpha.6",
77
- "@gunshi/shared": "0.27.0-alpha.6"
76
+ "@gunshi/resources": "0.27.0-alpha.7",
77
+ "@gunshi/shared": "0.27.0-alpha.7"
78
78
  },
79
79
  "scripts": {
80
80
  "build": "tsdown",