@x18n/ui 0.0.2 → 0.0.5

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 (49) hide show
  1. package/dist/index.d.mts +281 -0
  2. package/dist/index.mjs +678 -0
  3. package/dist/nitro.json +15 -0
  4. package/dist/public/200.html +1 -0
  5. package/dist/public/404.html +1 -0
  6. package/dist/public/_nuxt/B4prFwj0.js +3 -0
  7. package/dist/public/_nuxt/BAuZ_bOg.js +1 -0
  8. package/dist/public/_nuxt/BDNMzG2s.js +1 -0
  9. package/dist/public/_nuxt/BF0GwwSj.js +1 -0
  10. package/dist/public/_nuxt/BL7WZl0t.js +1 -0
  11. package/dist/public/_nuxt/BOzFHLxb.js +1 -0
  12. package/dist/public/_nuxt/BPDtdGtS.js +1 -0
  13. package/dist/public/_nuxt/BQsRGoRo.js +1 -0
  14. package/dist/public/_nuxt/BhEbR39R.js +1 -0
  15. package/dist/public/_nuxt/BriO7i_e.js +1 -0
  16. package/dist/public/_nuxt/Bw3sjlsE.js +1 -0
  17. package/dist/public/_nuxt/Bx_-K8sr.js +1 -0
  18. package/dist/public/_nuxt/C7ReGOzp.js +1 -0
  19. package/dist/public/_nuxt/CSj9m9n-.js +1 -0
  20. package/dist/public/_nuxt/C_0Sx1sV.js +1 -0
  21. package/dist/public/_nuxt/Ccxs59XZ.js +1 -0
  22. package/dist/public/_nuxt/ChbLIx1c.js +1 -0
  23. package/dist/public/_nuxt/CiBP4H8h.js +1 -0
  24. package/dist/public/_nuxt/CleZzkRG.js +1 -0
  25. package/dist/public/_nuxt/CoPvbHfg.js +1 -0
  26. package/dist/public/_nuxt/CvZr1WUA.js +1 -0
  27. package/dist/public/_nuxt/D0iElgch.js +1 -0
  28. package/dist/public/_nuxt/D1ZHlQ5G.js +1 -0
  29. package/dist/public/_nuxt/D4dwYDex.js +2 -0
  30. package/dist/public/_nuxt/DCrEftnh.js +1 -0
  31. package/dist/public/_nuxt/DH5mSOoi.js +1 -0
  32. package/dist/public/_nuxt/Df7YC0e0.js +1 -0
  33. package/dist/public/_nuxt/DiDiLO9x.js +1 -0
  34. package/dist/public/_nuxt/DoHg1T7s.js +2 -0
  35. package/dist/public/_nuxt/DqvFL0Kd.js +1 -0
  36. package/dist/public/_nuxt/DyY1zKC9.js +5 -0
  37. package/dist/public/_nuxt/OQ06FBli.js +1 -0
  38. package/dist/public/_nuxt/UNS2zuJ1.js +1 -0
  39. package/dist/public/_nuxt/_cWgq-kS.js +1 -0
  40. package/dist/public/_nuxt/builds/latest.json +1 -0
  41. package/dist/public/_nuxt/builds/meta/7ac730c1-0d41-432b-b8d2-f847ad2a3472.json +1 -0
  42. package/dist/public/_nuxt/entry.CI_zWg7k.css +1 -0
  43. package/dist/public/_nuxt/error-404.B3F8lAkA.css +1 -0
  44. package/dist/public/_nuxt/error-500.BO-H0E44.css +1 -0
  45. package/dist/public/_nuxt/k4SpML6D.js +1 -0
  46. package/dist/public/_nuxt/pmF1D2Eh.js +1 -0
  47. package/dist/public/_nuxt/xKaCciGs.js +1 -0
  48. package/dist/public/index.html +1 -0
  49. package/package.json +15 -13
@@ -0,0 +1,281 @@
1
+ import { DevframeDefinition } from "devframe";
2
+ import { ExtractCandidate } from "@x18n/builtins/extractors";
3
+ import { Decision, EditOp, FileChange, KeyString, LocaleCode, MessageLeaf, PlaceholderProblem, Project, ProjectExplanation, Severity, TextRange, UsageKind, WireDiagnostic } from "@x18n/core";
4
+ //#region src/node/types.d.ts
5
+ /** A loaded project as the UI sees it. */
6
+ interface UiProject {
7
+ readonly name: string;
8
+ /** Absolute root. */
9
+ readonly root: string;
10
+ readonly project: Project;
11
+ }
12
+ /** A file position in a project, for "open in editor". */
13
+ interface UiLocation {
14
+ readonly project: UiProject;
15
+ /** Path relative to the project root. */
16
+ readonly path: string;
17
+ /** 1-based. */
18
+ readonly line: number;
19
+ /** 1-based. */
20
+ readonly column: number;
21
+ }
22
+ /** ---- Inputs ---- */
23
+ interface ProjectQuery {
24
+ /** Project name; may be omitted when the workspace has one project. */
25
+ readonly project?: string | undefined;
26
+ }
27
+ interface KeyQuery extends ProjectQuery {
28
+ readonly key: KeyString;
29
+ }
30
+ interface UsageQuery extends ProjectQuery {
31
+ readonly key?: KeyString | undefined;
32
+ readonly path?: string | undefined;
33
+ }
34
+ interface PromptQuery extends ProjectQuery {
35
+ readonly locale: LocaleCode;
36
+ readonly keys?: string | readonly KeyString[] | undefined;
37
+ readonly namespace?: string | undefined;
38
+ readonly limit?: number | undefined;
39
+ readonly cursor?: string | undefined;
40
+ /** Also translate stale translations. */
41
+ readonly stale?: boolean | undefined;
42
+ }
43
+ /** Edit ops the UI and agents send; extraction has its own functions. */
44
+ type UiEditOp = Exclude<EditOp, {
45
+ readonly type: "extract" | "format";
46
+ }>;
47
+ interface PlanQuery extends ProjectQuery {
48
+ readonly ops: readonly UiEditOp[];
49
+ }
50
+ interface ApplyQuery extends PlanQuery {
51
+ /** Decision id to option id; unanswered decisions take their default. */
52
+ readonly answers?: Readonly<Record<string, string>> | undefined;
53
+ /** Write values whose placeholders differ from the source value. */
54
+ readonly force?: boolean | undefined;
55
+ }
56
+ interface ExtractQuery extends ProjectQuery {
57
+ readonly files?: readonly string[] | undefined;
58
+ }
59
+ type ExtractPlanItem = Pick<ExtractCandidate, "path" | "range" | "original" | "key" | "value" | "replacement" | "imports">;
60
+ interface ExtractApplyQuery extends ProjectQuery {
61
+ readonly items: readonly ExtractPlanItem[];
62
+ }
63
+ interface OpenQuery extends ProjectQuery {
64
+ readonly path: string;
65
+ readonly line: number;
66
+ readonly column: number;
67
+ }
68
+ interface PageQuery {
69
+ readonly limit?: number | undefined;
70
+ readonly cursor?: string | undefined;
71
+ }
72
+ interface AgentKeysQuery extends ProjectQuery, PageQuery {
73
+ readonly glob?: string | undefined;
74
+ readonly missing?: LocaleCode | undefined;
75
+ readonly unused?: boolean | undefined;
76
+ readonly namespace?: string | undefined;
77
+ readonly values?: boolean | undefined;
78
+ }
79
+ interface AgentUsagesQuery extends UsageQuery, PageQuery {}
80
+ interface AgentCheckQuery extends ProjectQuery, PageQuery {
81
+ readonly only?: readonly string[] | undefined;
82
+ readonly locale?: readonly LocaleCode[] | undefined;
83
+ }
84
+ interface AgentSetQuery extends ProjectQuery {
85
+ readonly messages: Readonly<Record<LocaleCode, Readonly<Record<string, MessageLeaf>>>>;
86
+ readonly force?: boolean | undefined;
87
+ }
88
+ interface Confirmable {
89
+ readonly confirm?: boolean | undefined;
90
+ readonly answers?: Readonly<Record<string, string>> | undefined;
91
+ }
92
+ interface AgentRenameQuery extends ProjectQuery, Confirmable {
93
+ readonly from: KeyString;
94
+ readonly to: KeyString;
95
+ readonly usages?: boolean | undefined;
96
+ }
97
+ interface AgentDeleteQuery extends ProjectQuery, Confirmable {
98
+ readonly key: KeyString;
99
+ readonly locales?: readonly LocaleCode[] | undefined;
100
+ }
101
+ /** ---- Outputs ---- */
102
+ /** When a message last changed, from the history providers (git). */
103
+ interface HistoryView {
104
+ /** Milliseconds since the epoch; null for a local change the provider does not know yet. */
105
+ readonly at: number | null;
106
+ /** Commit sha or another provider revision. */
107
+ readonly revision: string | undefined;
108
+ readonly author: string | undefined;
109
+ }
110
+ interface LocaleSummary {
111
+ readonly code: LocaleCode;
112
+ readonly displayName: string | undefined;
113
+ readonly flag: string | undefined;
114
+ readonly total: number;
115
+ readonly translated: number;
116
+ readonly missing: number;
117
+ readonly empty: number;
118
+ /** Translations older than their source message. */
119
+ readonly outdated: number;
120
+ /** One decimal, rounded down. */
121
+ readonly percent: number;
122
+ }
123
+ interface DiagnosticCounts {
124
+ readonly errors: number;
125
+ readonly warnings: number;
126
+ /** Infos and hints. */
127
+ readonly infos: number;
128
+ readonly byCode: readonly {
129
+ readonly code: string;
130
+ readonly severity: Severity;
131
+ readonly count: number;
132
+ }[];
133
+ }
134
+ interface ProjectSummary {
135
+ readonly name: string;
136
+ readonly sourceLocale: LocaleCode;
137
+ readonly namespaced: boolean;
138
+ readonly locales: readonly LocaleSummary[];
139
+ readonly resources: number;
140
+ readonly keys: number;
141
+ readonly usages: number;
142
+ readonly diagnostics: DiagnosticCounts;
143
+ /** Presets that are listed in the config or detected. */
144
+ readonly presets: readonly string[];
145
+ /** The latest message changes in history, local changes first. */
146
+ readonly changes: readonly (HistoryView & {
147
+ readonly key: KeyString;
148
+ readonly locale: LocaleCode;
149
+ })[];
150
+ }
151
+ interface ProjectList {
152
+ readonly projects: readonly ProjectSummary[];
153
+ readonly openInEditor: boolean;
154
+ }
155
+ interface KeyRow {
156
+ readonly key: KeyString;
157
+ readonly namespace: string | undefined;
158
+ /** Stored value per locale; locales without the key are absent. */
159
+ readonly values: Readonly<Record<LocaleCode, MessageLeaf>>;
160
+ /** Locales where the key is missing or empty. */
161
+ readonly missing: readonly LocaleCode[];
162
+ readonly unused: boolean;
163
+ readonly diagnostics: number;
164
+ /** Locales whose translation is older than the source message. */
165
+ readonly outdated: readonly LocaleCode[];
166
+ /** The latest change in any locale (ms); local changes count as now. */
167
+ readonly changedAt: number | undefined;
168
+ }
169
+ interface KeyTable {
170
+ readonly project: string;
171
+ readonly sourceLocale: LocaleCode;
172
+ readonly locales: readonly LocaleCode[];
173
+ readonly rows: readonly KeyRow[];
174
+ }
175
+ /** Lines of code around a position. */
176
+ interface Snippet {
177
+ /** 1-based number of the first line. */
178
+ readonly line: number;
179
+ readonly lines: readonly string[];
180
+ }
181
+ interface UsageView {
182
+ readonly key: KeyString | undefined;
183
+ readonly raw: string;
184
+ readonly path: string;
185
+ /** 1-based. */
186
+ readonly line: number;
187
+ /** 1-based. */
188
+ readonly column: number;
189
+ readonly kind: UsageKind;
190
+ readonly dynamic: false | "prefix" | "unknown";
191
+ /** True for prefix usages that may refer to the key. */
192
+ readonly possible: boolean;
193
+ readonly snippet: Snippet;
194
+ }
195
+ interface MessageView {
196
+ readonly locale: LocaleCode;
197
+ readonly value: MessageLeaf;
198
+ readonly path: string;
199
+ readonly line: number;
200
+ /** Placeholders in a string value, with offsets in the value. */
201
+ readonly placeholders: readonly ({
202
+ readonly text: string;
203
+ } & TextRange)[];
204
+ readonly changed: HistoryView | undefined;
205
+ /** Older than the source message. */
206
+ readonly outdated: boolean;
207
+ /** For an outdated translation: the source value when it last changed, when known. */
208
+ readonly sourceThen: string | undefined;
209
+ }
210
+ interface KeyDetail {
211
+ readonly project: string;
212
+ readonly key: KeyString;
213
+ readonly namespace: string | undefined;
214
+ readonly messages: readonly MessageView[];
215
+ readonly missing: readonly LocaleCode[];
216
+ readonly usages: readonly UsageView[];
217
+ readonly diagnostics: readonly WireDiagnostic[];
218
+ }
219
+ interface AnalysisView {
220
+ readonly project: string;
221
+ readonly diagnostics: readonly WireDiagnostic[];
222
+ readonly unused: readonly KeyString[];
223
+ /** Usages whose key is not defined in the source locale. */
224
+ readonly undefinedUsages: readonly UsageView[];
225
+ }
226
+ type ExplainView = Omit<ProjectExplanation, "root">;
227
+ interface ExplainList {
228
+ readonly projects: readonly ExplainView[];
229
+ }
230
+ interface ChangeView {
231
+ readonly type: FileChange["type"];
232
+ readonly path: string;
233
+ }
234
+ interface PlanView {
235
+ readonly keys: readonly KeyString[];
236
+ readonly warnings: readonly string[];
237
+ readonly decisions: readonly Decision[];
238
+ readonly changes: readonly ChangeView[];
239
+ /** Set values whose placeholders differ from the source value. */
240
+ readonly problems: readonly PlaceholderProblem[];
241
+ }
242
+ interface ApplyView extends PlanView {
243
+ /** False when placeholder problems blocked the write. */
244
+ readonly applied: boolean;
245
+ readonly revision: number;
246
+ }
247
+ /** Shared state `x18n:state`: bumps on every change in any project. Mutable: it is the draft type of `mutate`. */
248
+ interface X18nState {
249
+ revision: number;
250
+ changedKeys: KeyString[];
251
+ }
252
+ declare module "devframe" {
253
+ interface DevframeRpcServerFunctions {
254
+ "x18n:project": () => ProjectList;
255
+ "x18n:keys": (query: ProjectQuery) => KeyTable;
256
+ "x18n:key": (query: KeyQuery) => KeyDetail | null;
257
+ "x18n:usages": (query: UsageQuery) => UsageView[];
258
+ "x18n:analysis": (query: ProjectQuery) => AnalysisView;
259
+ "x18n:explain": () => ExplainList;
260
+ "x18n:translate-prompt": (query: PromptQuery) => string;
261
+ "x18n:plan": (query: PlanQuery) => PlanView;
262
+ "x18n:apply": (query: ApplyQuery) => Promise<ApplyView>;
263
+ "x18n:extract-candidates": (query: ExtractQuery) => ExtractCandidate[];
264
+ "x18n:extract-apply": (query: ExtractApplyQuery) => Promise<ApplyView>;
265
+ "x18n:open-in-editor": (query: OpenQuery) => Promise<void>;
266
+ }
267
+ interface DevframeRpcSharedStates {
268
+ "x18n:state": X18nState;
269
+ }
270
+ }
271
+ //#endregion
272
+ //#region src/node/rpc.d.ts
273
+ interface RpcOptions {
274
+ readonly openInEditor?: ((location: UiLocation) => Promise<void>) | undefined;
275
+ }
276
+ //#endregion
277
+ //#region src/node/index.d.ts
278
+ /** The x18n UI, RPC functions and MCP tools over loaded projects, as a devframe definition. */
279
+ export declare function createX18nDevframe(projects: readonly UiProject[], options?: RpcOptions): DevframeDefinition;
280
+ //#endregion
281
+ export type { AgentCheckQuery, AgentDeleteQuery, AgentKeysQuery, AgentRenameQuery, AgentSetQuery, AgentUsagesQuery, AnalysisView, ApplyQuery, ApplyView, ChangeView, DiagnosticCounts, ExplainList, ExplainView, ExtractApplyQuery, ExtractPlanItem, ExtractQuery, HistoryView, KeyDetail, KeyQuery, KeyRow, KeyTable, LocaleSummary, MessageView, OpenQuery, PlanQuery, PlanView, ProjectList, ProjectQuery, ProjectSummary, PromptQuery, Snippet, UiEditOp, UiLocation, UiProject, UsageQuery, UsageView, RpcOptions as X18nDevframeOptions, X18nState };