@x18n/core 0.0.13 → 0.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/dist/index.d.mts +284 -9
- package/dist/index.mjs +664 -67
- package/package.json +1 -1
- package/schema/config.json +58 -10
- package/schema/plugin.json +32 -10
- package/schema/reviews.json +98 -0
package/dist/index.d.mts
CHANGED
|
@@ -139,6 +139,31 @@ declare const errorDefinitions: {
|
|
|
139
139
|
}) => string;
|
|
140
140
|
fix: string;
|
|
141
141
|
};
|
|
142
|
+
X18N5001: {
|
|
143
|
+
why: (p: {
|
|
144
|
+
path: string;
|
|
145
|
+
reason: string;
|
|
146
|
+
}) => string;
|
|
147
|
+
fix: string;
|
|
148
|
+
};
|
|
149
|
+
X18N5003: {
|
|
150
|
+
why: (p: {
|
|
151
|
+
reason: string;
|
|
152
|
+
}) => string;
|
|
153
|
+
fix: string;
|
|
154
|
+
};
|
|
155
|
+
X18N5004: {
|
|
156
|
+
why: (p: {
|
|
157
|
+
id: string;
|
|
158
|
+
}) => string;
|
|
159
|
+
fix: string;
|
|
160
|
+
};
|
|
161
|
+
X18N5005: {
|
|
162
|
+
why: (p: {
|
|
163
|
+
id: string;
|
|
164
|
+
}) => string;
|
|
165
|
+
fix: string;
|
|
166
|
+
};
|
|
142
167
|
};
|
|
143
168
|
type ErrorCode = keyof typeof errorDefinitions;
|
|
144
169
|
type X18nError = Diagnostic$1 & {
|
|
@@ -159,6 +184,70 @@ interface ErrorInfo {
|
|
|
159
184
|
export declare function isX18nError(error: unknown): error is X18nError;
|
|
160
185
|
export declare function toErrorInfo(error: unknown): ErrorInfo;
|
|
161
186
|
//#endregion
|
|
187
|
+
//#region src/types/review.d.ts
|
|
188
|
+
type ReviewType = "comment" | "approve" | "request-change" | "suggestion";
|
|
189
|
+
interface ReviewAuthor {
|
|
190
|
+
readonly name?: string | undefined;
|
|
191
|
+
readonly email?: string | undefined;
|
|
192
|
+
}
|
|
193
|
+
/** One entry of a review thread, as stored. */
|
|
194
|
+
interface ReviewComment {
|
|
195
|
+
/** Short random id, unique within the review file. */
|
|
196
|
+
readonly id: string;
|
|
197
|
+
readonly type: ReviewType;
|
|
198
|
+
readonly author?: ReviewAuthor | undefined;
|
|
199
|
+
/** ISO 8601 time. */
|
|
200
|
+
readonly time: string;
|
|
201
|
+
readonly text?: string | undefined;
|
|
202
|
+
/** The proposed value of a `suggestion`. */
|
|
203
|
+
readonly suggestion?: string | undefined;
|
|
204
|
+
/** The value an `approve` approved; the approval is stale once the message has another value. */
|
|
205
|
+
readonly value?: string | undefined;
|
|
206
|
+
readonly resolved?: boolean | undefined;
|
|
207
|
+
}
|
|
208
|
+
/** Everything a review store holds. */
|
|
209
|
+
interface ReviewData {
|
|
210
|
+
/** Comments per key and locale, oldest first. */
|
|
211
|
+
readonly threads: {
|
|
212
|
+
readonly [key: KeyString]: {
|
|
213
|
+
readonly [locale: LocaleCode]: readonly ReviewComment[];
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
/** Hash of the source value when x18n last wrote each target message. */
|
|
217
|
+
readonly sources: {
|
|
218
|
+
readonly [key: KeyString]: {
|
|
219
|
+
readonly [locale: LocaleCode]: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/** Reads and writes the review file (`review.file`). Core does the I/O and puts writes into edit plans. */
|
|
224
|
+
interface ReviewStore {
|
|
225
|
+
readonly id: string;
|
|
226
|
+
/** Throws on invalid content; core reports it as a coded error. */
|
|
227
|
+
readonly parse: (text: string) => ReviewData;
|
|
228
|
+
readonly serialize: (data: ReviewData) => string;
|
|
229
|
+
}
|
|
230
|
+
/** Where a thread stands: the last open approval or change request decides, then open suggestions, then open comments. */
|
|
231
|
+
type ReviewState = "changes-requested" | "approved" | "stale-approval" | "suggested" | "commented";
|
|
232
|
+
interface ThreadComment extends ReviewComment {
|
|
233
|
+
/** An approval of a value the message no longer has. */
|
|
234
|
+
readonly stale: boolean;
|
|
235
|
+
}
|
|
236
|
+
/** The comments on one message. */
|
|
237
|
+
interface ReviewThread {
|
|
238
|
+
readonly key: KeyString;
|
|
239
|
+
readonly locale: LocaleCode;
|
|
240
|
+
readonly comments: readonly ThreadComment[];
|
|
241
|
+
/** Undefined when every comment is resolved. */
|
|
242
|
+
readonly state: ReviewState | undefined;
|
|
243
|
+
}
|
|
244
|
+
interface ReviewFilter {
|
|
245
|
+
readonly key?: KeyString | undefined;
|
|
246
|
+
readonly locale?: LocaleCode | undefined;
|
|
247
|
+
/** Only unresolved comments, and only threads that have some. */
|
|
248
|
+
readonly open?: boolean | undefined;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
162
251
|
//#region src/types/model.d.ts
|
|
163
252
|
/** A locale code exactly as written in paths and files: `en`, `zh_CN`, `pt-BR`. Never normalized. */
|
|
164
253
|
type LocaleCode = string;
|
|
@@ -277,6 +366,27 @@ type EditOp = {
|
|
|
277
366
|
} | {
|
|
278
367
|
readonly type: "format";
|
|
279
368
|
readonly paths?: readonly string[];
|
|
369
|
+
} | {
|
|
370
|
+
readonly type: "review";
|
|
371
|
+
readonly key: KeyString;
|
|
372
|
+
readonly locale: LocaleCode;
|
|
373
|
+
readonly review: ReviewType;
|
|
374
|
+
readonly text?: string | undefined;
|
|
375
|
+
/** The proposed value, required for `suggestion`. */
|
|
376
|
+
readonly suggestion?: string | undefined;
|
|
377
|
+
readonly author?: ReviewAuthor | undefined;
|
|
378
|
+
readonly id?: string | undefined;
|
|
379
|
+
readonly time?: string | undefined;
|
|
380
|
+
} | {
|
|
381
|
+
readonly type: "resolve-review";
|
|
382
|
+
readonly id: string;
|
|
383
|
+
} | {
|
|
384
|
+
readonly type: "apply-suggestion";
|
|
385
|
+
readonly id: string;
|
|
386
|
+
} | {
|
|
387
|
+
readonly type: "mark-fresh";
|
|
388
|
+
readonly key: KeyString;
|
|
389
|
+
readonly locales?: readonly LocaleCode[] | undefined;
|
|
280
390
|
};
|
|
281
391
|
interface ExtractItem {
|
|
282
392
|
readonly path: string;
|
|
@@ -393,6 +503,8 @@ interface Host {
|
|
|
393
503
|
readonly watch?: ((patterns: readonly string[], onChange: (events: readonly FileEvent[]) => void) => Disposable) | undefined;
|
|
394
504
|
readonly cache?: CacheStore | undefined;
|
|
395
505
|
readonly logger?: Logger | undefined;
|
|
506
|
+
/** Who writes reviews. The node host reads git `user.name` and `user.email`. */
|
|
507
|
+
readonly identity?: (() => Promise<ReviewAuthor | undefined>) | undefined;
|
|
396
508
|
}
|
|
397
509
|
//#endregion
|
|
398
510
|
//#region src/types/plugin.d.ts
|
|
@@ -434,10 +546,14 @@ interface LocaleFinder {
|
|
|
434
546
|
readonly id: string;
|
|
435
547
|
readonly override?: boolean | undefined;
|
|
436
548
|
readonly find: (ctx: FinderContext) => Promise<readonly ResourceCandidate[]>;
|
|
437
|
-
/**
|
|
549
|
+
/**
|
|
550
|
+
* Where a new resource for (locale, namespace) should go. Used by edits that create files.
|
|
551
|
+
* `model` is the existing resource the new one would otherwise mirror: the key's source file when it has one.
|
|
552
|
+
*/
|
|
438
553
|
readonly resolveNew?: ((target: {
|
|
439
554
|
readonly locale: LocaleCode;
|
|
440
555
|
readonly namespace: string | undefined;
|
|
556
|
+
readonly model: Resource | undefined;
|
|
441
557
|
}, ctx: FinderContext) => string | undefined) | undefined;
|
|
442
558
|
}
|
|
443
559
|
interface FormatContext {
|
|
@@ -459,6 +575,28 @@ type MessageOp = {
|
|
|
459
575
|
readonly type: "delete";
|
|
460
576
|
readonly path: readonly string[];
|
|
461
577
|
};
|
|
578
|
+
/** A built-in format known by its extensions only: the module behind `load` is imported when a file of that format is read. */
|
|
579
|
+
interface FormatEntry {
|
|
580
|
+
/** File extensions without the dot. */
|
|
581
|
+
readonly extensions: readonly string[];
|
|
582
|
+
/** The module's default export creates a plugin that holds the format. */
|
|
583
|
+
readonly load: PluginLoader;
|
|
584
|
+
}
|
|
585
|
+
/** A format entry under its id, as plugins list it. */
|
|
586
|
+
interface LazyFormat extends FormatEntry {
|
|
587
|
+
readonly id: string;
|
|
588
|
+
}
|
|
589
|
+
/** A built-in scanner known by its extensions only: the module behind `load` is imported when a file it scans is first scanned. */
|
|
590
|
+
interface ScannerEntry {
|
|
591
|
+
/** File extensions without dot. `*` matches every file. */
|
|
592
|
+
readonly extensions: readonly string[];
|
|
593
|
+
/** The module's default export creates a plugin that holds the scanner. */
|
|
594
|
+
readonly load: PluginLoader;
|
|
595
|
+
}
|
|
596
|
+
/** A scanner entry under its id, as plugins list it. */
|
|
597
|
+
interface LazyScanner extends ScannerEntry {
|
|
598
|
+
readonly id: string;
|
|
599
|
+
}
|
|
462
600
|
interface Format {
|
|
463
601
|
readonly id: string;
|
|
464
602
|
/** File extensions without the dot. */
|
|
@@ -496,6 +634,8 @@ interface Scope {
|
|
|
496
634
|
readonly range: TextRange;
|
|
497
635
|
readonly namespace?: string | undefined;
|
|
498
636
|
readonly keyPrefix?: string | undefined;
|
|
637
|
+
/** The key prefix applies only to keys it defines; others resolve without it, as page messages that extend global ones. */
|
|
638
|
+
readonly optionalPrefix?: boolean | undefined;
|
|
499
639
|
}
|
|
500
640
|
interface HardString {
|
|
501
641
|
readonly text: string;
|
|
@@ -618,6 +758,7 @@ interface CheckContext {
|
|
|
618
758
|
}>;
|
|
619
759
|
/** When a message last changed, from the history providers. Undefined until history is loaded. */
|
|
620
760
|
readonly history: (key: KeyString, locale: LocaleCode) => MessageChange | undefined;
|
|
761
|
+
readonly reviews: (filter?: ReviewFilter) => readonly ReviewThread[];
|
|
621
762
|
}
|
|
622
763
|
interface Check {
|
|
623
764
|
readonly id: string;
|
|
@@ -703,12 +844,18 @@ interface Plugin {
|
|
|
703
844
|
readonly manifests?: readonly ManifestReader[] | undefined;
|
|
704
845
|
readonly localeFinders?: readonly LocaleFinder[] | undefined;
|
|
705
846
|
readonly formats?: readonly Format[] | undefined;
|
|
847
|
+
/** Formats that load their module when a file of that format is first read. */
|
|
848
|
+
readonly lazyFormats?: readonly LazyFormat[] | undefined;
|
|
849
|
+
/** Scanners that load their module when a file they scan is first scanned. */
|
|
850
|
+
readonly lazyScanners?: readonly LazyScanner[] | undefined;
|
|
706
851
|
readonly scanners?: readonly Scanner[] | undefined;
|
|
707
852
|
readonly extractors?: readonly Extractor[] | undefined;
|
|
708
853
|
readonly checks?: readonly Check[] | undefined;
|
|
709
854
|
readonly reporters?: readonly Reporter[] | undefined;
|
|
710
855
|
readonly placeholders?: readonly PlaceholderSyntax[] | undefined;
|
|
711
856
|
readonly histories?: readonly HistoryProvider[] | undefined;
|
|
857
|
+
/** Only one store is active: the last one, so a plugin's store replaces the built-in one. */
|
|
858
|
+
readonly reviewStores?: readonly ReviewStore[] | undefined;
|
|
712
859
|
/** Turns raw key text into canonical form. The first plugin that returns a value wins. */
|
|
713
860
|
readonly normalizeKey?: ((raw: string, ctx: KeyContext) => string | undefined) | undefined;
|
|
714
861
|
readonly derivedKeys?: readonly string[] | undefined;
|
|
@@ -727,6 +874,32 @@ interface Preset {
|
|
|
727
874
|
}
|
|
728
875
|
/** A preset factory as referenced by name from YAML and JSON configs. */
|
|
729
876
|
type PresetFactory = (options?: JsonObject) => Preset;
|
|
877
|
+
/** Loads a plugin on demand, usually `() => import('./plugin')`: the module's default export creates it. */
|
|
878
|
+
type PluginLoader = () => Promise<{
|
|
879
|
+
readonly default: () => Plugin;
|
|
880
|
+
}>;
|
|
881
|
+
/** Loads a reporter on demand, usually `() => import('./reporter')`: the module's default export is the reporter. */
|
|
882
|
+
type ReporterLoader = () => Promise<{
|
|
883
|
+
readonly default: Reporter;
|
|
884
|
+
}>;
|
|
885
|
+
/** Loads a preset on demand, usually `() => import('./preset')`: the module's default export is the factory. */
|
|
886
|
+
type PresetLoader = () => Promise<{
|
|
887
|
+
readonly default: PresetFactory;
|
|
888
|
+
}>;
|
|
889
|
+
/** When a built-in preset applies. Cheap, so it stays loaded while the preset module does not. */
|
|
890
|
+
interface PresetDetection {
|
|
891
|
+
/** Without `detect`, the preset applies only when listed in config. */
|
|
892
|
+
readonly detect?: ((ctx: DetectContext) => boolean | Promise<boolean>) | undefined;
|
|
893
|
+
/** When true and detected, presets that come after it are not applied. */
|
|
894
|
+
readonly exclusive?: boolean | undefined;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* A built-in preset split in two: the detection is always loaded; the module behind `load`
|
|
898
|
+
* is imported only when it passes or the preset is listed in config.
|
|
899
|
+
*/
|
|
900
|
+
interface PresetEntry extends PresetDetection {
|
|
901
|
+
readonly load: PresetLoader;
|
|
902
|
+
}
|
|
730
903
|
//#endregion
|
|
731
904
|
//#region src/types/config.d.ts
|
|
732
905
|
/** Where a value comes from: an argument, or a property of an object argument. */
|
|
@@ -742,8 +915,8 @@ interface CallSpec {
|
|
|
742
915
|
readonly kind?: "call" | "selector" | "accessor" | undefined;
|
|
743
916
|
/** Which argument holds the key. Default 0. */
|
|
744
917
|
readonly key?: number | ArgSource | undefined;
|
|
745
|
-
/** Where the namespace comes from (call option, or factory argument when `factory` is true)
|
|
746
|
-
readonly namespace?: ArgSource | undefined;
|
|
918
|
+
/** Where the namespace comes from (call option, or factory argument when `factory` is true), or a fixed namespace such as `'shared'` for a hook that wraps `useTranslation('shared')`. */
|
|
919
|
+
readonly namespace?: ArgSource | string | undefined;
|
|
747
920
|
/** Where a key prefix comes from (`keyPrefix` option, or next-intl `useTranslations('a.b')`). */
|
|
748
921
|
readonly keyPrefix?: ArgSource | undefined;
|
|
749
922
|
/** The callee is a factory that returns the translate function, for example `useI18n()` returning `{ t }`. */
|
|
@@ -835,9 +1008,23 @@ interface NamespaceOptions {
|
|
|
835
1008
|
readonly separator?: string | undefined;
|
|
836
1009
|
/** Namespace of keys written without one. */
|
|
837
1010
|
readonly default?: string | undefined;
|
|
1011
|
+
/** Namespaces searched in order when a key written without a namespace is not in its own (i18next `fallbackNS`). */
|
|
1012
|
+
readonly fallback?: readonly string[] | undefined;
|
|
1013
|
+
/** Namespace of keys written without one, per glob of source files, before `default`: `{ 'packages/admin/**': 'admin' }`. */
|
|
1014
|
+
readonly byFile?: {
|
|
1015
|
+
readonly [glob: string]: string;
|
|
1016
|
+
} | undefined;
|
|
838
1017
|
/** How `{namespaces}` folders name a namespace: `dot` makes `pages/home` into `pages.home`, `slash` keeps `pages/home`, `camel` makes `todos-page` into `todosPage`. Default `dot`. */
|
|
839
1018
|
readonly fromPath?: "dot" | "slash" | "camel" | undefined;
|
|
840
1019
|
}
|
|
1020
|
+
interface ReviewOptions {
|
|
1021
|
+
/** Default true. */
|
|
1022
|
+
readonly enabled?: boolean | undefined;
|
|
1023
|
+
/** Review file, relative to the project root. Default `.x18n/reviews.yml`. */
|
|
1024
|
+
readonly file?: string | undefined;
|
|
1025
|
+
/** Author of new reviews, instead of the host identity (git `user.name` and `user.email`). */
|
|
1026
|
+
readonly author?: ReviewAuthor | undefined;
|
|
1027
|
+
}
|
|
841
1028
|
type NamespaceFromPath = NonNullable<NamespaceOptions["fromPath"]>;
|
|
842
1029
|
type PluginSpecifier = string | readonly [string, JsonObject];
|
|
843
1030
|
/** The part of the config that YAML and JSON files can hold. Validated by `ConfigSchema`. */
|
|
@@ -879,6 +1066,8 @@ interface SerializableConfig {
|
|
|
879
1066
|
readonly glossary?: readonly GlossaryEntry[] | undefined;
|
|
880
1067
|
/** History providers for stale translations. `false` turns every provider off. Options of a provider sit under its key, such as `git: { maxDepth, since }` (or `git: false`). */
|
|
881
1068
|
readonly history?: boolean | HistoryOptions | undefined;
|
|
1069
|
+
/** Review comments, approvals and suggested values on messages, kept in a file tracked in git. */
|
|
1070
|
+
readonly review?: ReviewOptions | undefined;
|
|
882
1071
|
/** Monorepo: directories (globs) that are projects inheriting this config. */
|
|
883
1072
|
readonly projects?: readonly string[] | undefined;
|
|
884
1073
|
}
|
|
@@ -926,6 +1115,10 @@ interface ResolvedConfig {
|
|
|
926
1115
|
readonly namespace: {
|
|
927
1116
|
readonly separator: string;
|
|
928
1117
|
readonly default: string | undefined;
|
|
1118
|
+
readonly fallback: readonly string[];
|
|
1119
|
+
readonly byFile: {
|
|
1120
|
+
readonly [glob: string]: string;
|
|
1121
|
+
};
|
|
929
1122
|
readonly fromPath: NamespaceFromPath;
|
|
930
1123
|
};
|
|
931
1124
|
readonly usage: {
|
|
@@ -950,6 +1143,11 @@ interface ResolvedConfig {
|
|
|
950
1143
|
readonly ignoreKeys: readonly string[];
|
|
951
1144
|
readonly glossary: readonly GlossaryEntry[];
|
|
952
1145
|
readonly history: false | HistorySettings;
|
|
1146
|
+
readonly review: {
|
|
1147
|
+
readonly enabled: boolean;
|
|
1148
|
+
readonly file: string;
|
|
1149
|
+
readonly author: ReviewAuthor | undefined;
|
|
1150
|
+
};
|
|
953
1151
|
readonly pluginConfigs: Partial<PluginConfigs>;
|
|
954
1152
|
/** Origin of each top-level value, for `explain()`. */
|
|
955
1153
|
readonly origins: {
|
|
@@ -965,6 +1163,10 @@ export declare function definePlugin<O, const T extends Plugin>(factory: (option
|
|
|
965
1163
|
export declare function definePreset<const T extends Preset>(preset: T): T;
|
|
966
1164
|
export declare function defineConfig(config: UserConfig & { readonly [K in keyof PluginConfigs]?: PluginConfigs[K]; }): UserConfig;
|
|
967
1165
|
//#endregion
|
|
1166
|
+
//#region src/fuzzy.d.ts
|
|
1167
|
+
/** Subsequence match score of `query` in `text`, case-insensitive; higher is better, -1 when it does not match. Substring hits rank above every subsequence. */
|
|
1168
|
+
export declare function fuzzyScore(query: string, text: string): number;
|
|
1169
|
+
//#endregion
|
|
968
1170
|
//#region src/keys.d.ts
|
|
969
1171
|
/** Canonical string form of a key: `ns:a.b.c`, or `a.b.c` without namespace. */
|
|
970
1172
|
export declare function joinKey(namespace: string | undefined, path: readonly string[]): KeyString;
|
|
@@ -984,6 +1186,34 @@ export declare function keyMatcher(globs: readonly string[]): (key: KeyString) =
|
|
|
984
1186
|
/** Matcher over posix file paths. */
|
|
985
1187
|
export declare function pathMatcher(globs: readonly string[]): (path: string) => boolean;
|
|
986
1188
|
//#endregion
|
|
1189
|
+
//#region src/library.d.ts
|
|
1190
|
+
interface LibraryOptions {
|
|
1191
|
+
/** The plugin name, prefixed by the caller: `x18n:vue-i18n`. */
|
|
1192
|
+
readonly name: string;
|
|
1193
|
+
readonly calls?: readonly CallSpec[];
|
|
1194
|
+
/** i18n-ally style `usageMatchRegex` patterns, for languages without an AST scanner. */
|
|
1195
|
+
readonly regex?: readonly RegexScannerSpec[];
|
|
1196
|
+
/** The library's placeholder syntaxes. */
|
|
1197
|
+
readonly placeholders?: readonly PlaceholderSyntax[];
|
|
1198
|
+
readonly derivedKeys?: readonly string[];
|
|
1199
|
+
readonly namespace?: {
|
|
1200
|
+
readonly separator?: string;
|
|
1201
|
+
readonly default?: string;
|
|
1202
|
+
readonly fromPath?: NamespaceFromPath;
|
|
1203
|
+
};
|
|
1204
|
+
/** Default resource patterns (i18n-ally `preferredLocalePaths` + `pathMatcher`). */
|
|
1205
|
+
readonly resources?: readonly ResourceSpec[];
|
|
1206
|
+
readonly keyStyle?: "nested" | "flat";
|
|
1207
|
+
readonly templates?: readonly ExtractTemplate[];
|
|
1208
|
+
readonly finders?: readonly LocaleFinder[];
|
|
1209
|
+
readonly normalizeKey?: Plugin["normalizeKey"];
|
|
1210
|
+
readonly transformResource?: ResourceTransform;
|
|
1211
|
+
readonly extra?: (draft: ConfigDraft, ctx: ConfigContext) => void | Promise<void>;
|
|
1212
|
+
readonly translatePrompt?: Plugin["translatePrompt"];
|
|
1213
|
+
}
|
|
1214
|
+
/** One plugin holding a library's call specs, regexes, namespace rules, defaults and extraction templates. */
|
|
1215
|
+
export declare function createLibraryPlugin(options: LibraryOptions): Plugin;
|
|
1216
|
+
//#endregion
|
|
987
1217
|
//#region src/locale.d.ts
|
|
988
1218
|
/** Lenient display parse of a locale code (`zh_CN`, `pt-BR`, `sr-Latn-RS`). Never changes the code. */
|
|
989
1219
|
export declare function parseLocaleInfo(code: LocaleCode): LocaleInfo;
|
|
@@ -1036,20 +1266,31 @@ interface CapabilityConflict {
|
|
|
1036
1266
|
/** The capabilities of the final plugin list, indexed for the project engine. */
|
|
1037
1267
|
interface PluginRegistry {
|
|
1038
1268
|
readonly plugins: readonly Plugin[];
|
|
1039
|
-
|
|
1269
|
+
/** Every format, loaded or not; use `formatFor` and `loadFormatFor` to run one. */
|
|
1270
|
+
readonly formats: readonly (Format | LazyFormat)[];
|
|
1040
1271
|
readonly finders: readonly LocaleFinder[];
|
|
1041
|
-
|
|
1272
|
+
/** Every scanner, loaded or not. */
|
|
1273
|
+
readonly scanners: readonly (Scanner | LazyScanner)[];
|
|
1042
1274
|
readonly checks: ReadonlyMap<string, Check>;
|
|
1043
1275
|
readonly reporters: ReadonlyMap<string, Reporter>;
|
|
1044
1276
|
readonly placeholders: readonly PlaceholderSyntax[];
|
|
1045
1277
|
readonly manifests: readonly ManifestReader[];
|
|
1046
1278
|
readonly extractors: readonly Extractor[];
|
|
1047
1279
|
readonly histories: readonly HistoryProvider[];
|
|
1280
|
+
readonly reviewStores: readonly ReviewStore[];
|
|
1048
1281
|
readonly conflicts: readonly CapabilityConflict[];
|
|
1049
|
-
/**
|
|
1282
|
+
/** The loaded format for a file path: config `formats` first, then the first format that claims the extension. */
|
|
1050
1283
|
readonly formatFor: (path: string, hint?: string) => Format | undefined;
|
|
1284
|
+
/** The id of the format `formatFor` would pick, loaded or not. */
|
|
1285
|
+
readonly formatIdFor: (path: string, hint?: string) => string | undefined;
|
|
1286
|
+
/** The loaded format with this id. */
|
|
1051
1287
|
readonly formatById: (id: string) => Format | undefined;
|
|
1052
|
-
|
|
1288
|
+
/** Loads the format of a file path, once, and returns it. */
|
|
1289
|
+
readonly loadFormatFor: (path: string, hint?: string) => Promise<Format | undefined>;
|
|
1290
|
+
/** The scanners that handle a file path, loaded or not. */
|
|
1291
|
+
readonly scannersFor: (path: string) => readonly (Scanner | LazyScanner)[];
|
|
1292
|
+
/** Loads the scanners of a file path, once each, and returns them. */
|
|
1293
|
+
readonly loadScannersFor: (path: string) => Promise<readonly Scanner[]>;
|
|
1053
1294
|
}
|
|
1054
1295
|
export declare function extensionOf(path: string): string;
|
|
1055
1296
|
export declare function createRegistry(input: readonly Plugin[], config: Pick<ResolvedConfig, "formats">): PluginRegistry;
|
|
@@ -1116,7 +1357,7 @@ export declare function renderPrompt(data: PromptData): string;
|
|
|
1116
1357
|
interface Builtins {
|
|
1117
1358
|
readonly plugins: readonly Plugin[];
|
|
1118
1359
|
readonly presets: {
|
|
1119
|
-
readonly [name: string]:
|
|
1360
|
+
readonly [name: string]: PresetEntry;
|
|
1120
1361
|
};
|
|
1121
1362
|
}
|
|
1122
1363
|
interface ResolveConfigOptions {
|
|
@@ -1159,6 +1400,18 @@ interface KeyQuery {
|
|
|
1159
1400
|
/** Only keys without usages. */
|
|
1160
1401
|
readonly unused?: boolean | undefined;
|
|
1161
1402
|
}
|
|
1403
|
+
interface SearchOptions {
|
|
1404
|
+
/** Only values containing the query; by default a fuzzy (subsequence) match also counts. Both ignore case. */
|
|
1405
|
+
readonly exact?: boolean | undefined;
|
|
1406
|
+
}
|
|
1407
|
+
/** A key found by its value: the best-matching locale, source first on ties. */
|
|
1408
|
+
interface SearchMatch {
|
|
1409
|
+
readonly key: KeyString;
|
|
1410
|
+
readonly locale: LocaleCode;
|
|
1411
|
+
readonly value: string;
|
|
1412
|
+
/** Higher is better; substring hits rank above fuzzy ones. */
|
|
1413
|
+
readonly score: number;
|
|
1414
|
+
}
|
|
1162
1415
|
interface UsageMatch {
|
|
1163
1416
|
readonly usage: Usage;
|
|
1164
1417
|
/** True for prefix usages that may refer to the key. */
|
|
@@ -1179,6 +1432,7 @@ interface KeyInfo {
|
|
|
1179
1432
|
readonly missing: readonly LocaleCode[];
|
|
1180
1433
|
readonly usages: readonly UsageMatch[];
|
|
1181
1434
|
readonly diagnostics: readonly Diagnostic[];
|
|
1435
|
+
readonly reviews: readonly ReviewThread[];
|
|
1182
1436
|
}
|
|
1183
1437
|
/** The key, or the resource node, under a position. */
|
|
1184
1438
|
type KeyTarget = {
|
|
@@ -1311,6 +1565,8 @@ interface Project {
|
|
|
1311
1565
|
/** Extraction templates: config `extract.templates` first, then those of presets. */
|
|
1312
1566
|
readonly extractTemplates: readonly ExtractTemplate[];
|
|
1313
1567
|
readonly keys: (query?: KeyQuery) => KeyString[];
|
|
1568
|
+
/** Keys whose value in some locale matches the query, best first. */
|
|
1569
|
+
readonly search: (query: string, options?: SearchOptions) => SearchMatch[];
|
|
1314
1570
|
readonly get: (key: KeyString) => KeyInfo | undefined;
|
|
1315
1571
|
readonly message: (key: KeyString, locale: LocaleCode) => Message | undefined;
|
|
1316
1572
|
/** The message a usage of `key` shows: the key's own, or one of its derived keys (`item` → `item_other`). */
|
|
@@ -1337,6 +1593,12 @@ interface Project {
|
|
|
1337
1593
|
readonly history: (key: KeyString, locale: LocaleCode) => MessageChange | undefined;
|
|
1338
1594
|
/** The value a message had at a time (ms), from the provider that knows the message. */
|
|
1339
1595
|
readonly valueAt: (key: KeyString, locale: LocaleCode, at: number) => MessageLeaf | undefined;
|
|
1596
|
+
/** Review threads, in key order and then locale order. */
|
|
1597
|
+
readonly reviews: (filter?: ReviewFilter) => readonly ReviewThread[];
|
|
1598
|
+
/** The review file when reviews are on and a review store is registered. */
|
|
1599
|
+
readonly reviewFile: string | undefined;
|
|
1600
|
+
/** Author of new reviews: config `review.author`, else the host identity. */
|
|
1601
|
+
readonly reviewAuthor: () => Promise<ReviewAuthor | undefined>;
|
|
1340
1602
|
/** Parts of a translate or review prompt for an agent or LLM; render with `renderPrompt`. */
|
|
1341
1603
|
readonly prompt: (kind: "translate" | "review", locale: LocaleCode, options?: PromptOptions) => PromptData;
|
|
1342
1604
|
readonly explain: () => ProjectExplanation;
|
|
@@ -1378,6 +1640,10 @@ type PlaceholderComparer = (source: string, target: string) => {
|
|
|
1378
1640
|
export declare function createPlaceholderComparer(syntaxes: readonly PlaceholderSyntax[], find?: (value: string) => readonly Placeholder[]): PlaceholderComparer;
|
|
1379
1641
|
export declare function placeholderProblems(project: Project, ops: readonly EditOp[]): PlaceholderProblem[];
|
|
1380
1642
|
//#endregion
|
|
1643
|
+
//#region src/project/explain.d.ts
|
|
1644
|
+
/** `project.explain()` as the text `x18n doctor` prints. `root` and `configFile` are shown as given. */
|
|
1645
|
+
export declare function renderExplanation(e: ProjectExplanation, configFile?: string | undefined): string;
|
|
1646
|
+
//#endregion
|
|
1381
1647
|
//#region src/project/project.d.ts
|
|
1382
1648
|
interface CreateProjectOptions {
|
|
1383
1649
|
readonly host: Host;
|
|
@@ -1436,6 +1702,15 @@ interface PluginFile {
|
|
|
1436
1702
|
} | undefined;
|
|
1437
1703
|
}
|
|
1438
1704
|
export declare const PluginFileSchema: v.GenericSchema<PluginFile>;
|
|
1705
|
+
/** The review file (`.x18n/reviews.yml`), as the YAML review store reads it. */
|
|
1706
|
+
interface ReviewFile {
|
|
1707
|
+
readonly $schema?: string | undefined;
|
|
1708
|
+
/** File format version. */
|
|
1709
|
+
readonly x18n: 1;
|
|
1710
|
+
readonly threads?: ReviewData["threads"] | undefined;
|
|
1711
|
+
readonly sources?: ReviewData["sources"] | undefined;
|
|
1712
|
+
}
|
|
1713
|
+
export declare const ReviewFileSchema: v.GenericSchema<ReviewFile>;
|
|
1439
1714
|
interface SchemaIssue {
|
|
1440
1715
|
readonly path: string;
|
|
1441
1716
|
readonly message: string;
|
|
@@ -1473,4 +1748,4 @@ export declare function rangeContains(range: TextRange, offset: number): boolean
|
|
|
1473
1748
|
/** Fast non-cryptographic string hash (cyrb53), as hex. */
|
|
1474
1749
|
export declare function hashText(text: string): string;
|
|
1475
1750
|
//#endregion
|
|
1476
|
-
export type { Analysis, Answers, ApplyResult, ArgSource, Builtins, CacheStore, CallSpec, CapabilityConflict, Check, CheckContext, CheckIds, CheckLevel, CheckSetting, ConfigContext, ConfigDraft, ConfigOrigin, CreateProjectOptions, Decision, DecisionOption, DetectContext, Diagnostic, DiagnosticInput, Disposable, EditOp, Envelope, ErrorCode, ErrorInfo, ExtractItem, ExtractOptions, ExtractTemplate, Extractor, FileChange, FileEvent, FileScan, FinderContext, Fix, Format, FormatContext, GlobOptions, GlossaryEntry, HardString, HistoryConfigs, HistoryContext, HistoryOptions, HistoryProvider, HistorySettings, Host, JsonObject, JsonPrimitive, JsonValue, KeyContext, KeyId, KeyInfo, KeyQuery, KeyString, KeyTarget, LineIndex, LinePosition, LocaleCode, LocaleCoverage, LocaleFinder, LocaleInfo, Location, Logger, ManifestReader, MemoryHost, Message, MessageChange, MessageHistory, MessageLeaf, MessageOp, MessageTree, NamespaceFromPath, NamespaceOptions, NodeRange, OverlayHost, ParseResult, Placeholder, PlaceholderComparer, PlaceholderProblem, PlaceholderSyntax, Plan, Plugin, PluginConfigs, PluginFile, PluginOption, PluginRegistry, PluginSpecifier, PluralForm, Preset, PresetExplanation, PresetFactory, PresetOption, Project, ProjectChange, ProjectExplanation, PromptContext, PromptData, PromptDraft, PromptItem, PromptOptions, RegexScannerSpec, ReportInput, ReportSummary, Reporter, ReporterContext, ResolveConfigOptions, ResolvedConfig, Resource, ResourceBlock, ResourceCandidate, ResourceId, ResourceNode, ResourceSpec, ResourceTransform, ResourceTransformContext, ScanContext, ScanResult, Scanner, SchemaIssue, Scope, SerializableConfig, Setup, Severity, SourceFile, TextEdit, TextRange, TreeLeaf, Usage, UsageCandidate, UsageContext, UsageKind, UsageMatch, UsageOptions, UsageQuery, UserConfig, WireDiagnostic, WireRange, WriteOptions, X18nError };
|
|
1751
|
+
export type { Analysis, Answers, ApplyResult, ArgSource, Builtins, CacheStore, CallSpec, CapabilityConflict, Check, CheckContext, CheckIds, CheckLevel, CheckSetting, ConfigContext, ConfigDraft, ConfigOrigin, CreateProjectOptions, Decision, DecisionOption, DetectContext, Diagnostic, DiagnosticInput, Disposable, EditOp, Envelope, ErrorCode, ErrorInfo, ExtractItem, ExtractOptions, ExtractTemplate, Extractor, FileChange, FileEvent, FileScan, FinderContext, Fix, Format, FormatContext, FormatEntry, GlobOptions, GlossaryEntry, HardString, HistoryConfigs, HistoryContext, HistoryOptions, HistoryProvider, HistorySettings, Host, JsonObject, JsonPrimitive, JsonValue, KeyContext, KeyId, KeyInfo, KeyQuery, KeyString, KeyTarget, LazyFormat, LazyScanner, LibraryOptions, LineIndex, LinePosition, LocaleCode, LocaleCoverage, LocaleFinder, LocaleInfo, Location, Logger, ManifestReader, MemoryHost, Message, MessageChange, MessageHistory, MessageLeaf, MessageOp, MessageTree, NamespaceFromPath, NamespaceOptions, NodeRange, OverlayHost, ParseResult, Placeholder, PlaceholderComparer, PlaceholderProblem, PlaceholderSyntax, Plan, Plugin, PluginConfigs, PluginFile, PluginLoader, PluginOption, PluginRegistry, PluginSpecifier, PluralForm, Preset, PresetDetection, PresetEntry, PresetExplanation, PresetFactory, PresetLoader, PresetOption, Project, ProjectChange, ProjectExplanation, PromptContext, PromptData, PromptDraft, PromptItem, PromptOptions, RegexScannerSpec, ReportInput, ReportSummary, Reporter, ReporterContext, ReporterLoader, ResolveConfigOptions, ResolvedConfig, Resource, ResourceBlock, ResourceCandidate, ResourceId, ResourceNode, ResourceSpec, ResourceTransform, ResourceTransformContext, ReviewAuthor, ReviewComment, ReviewData, ReviewFile, ReviewFilter, ReviewOptions, ReviewState, ReviewStore, ReviewThread, ReviewType, ScanContext, ScanResult, Scanner, ScannerEntry, SchemaIssue, Scope, SearchMatch, SearchOptions, SerializableConfig, Setup, Severity, SourceFile, TextEdit, TextRange, ThreadComment, TreeLeaf, Usage, UsageCandidate, UsageContext, UsageKind, UsageMatch, UsageOptions, UsageQuery, UserConfig, WireDiagnostic, WireRange, WriteOptions, X18nError };
|