@vmz/vmz 0.1.16 → 0.1.18

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 (131) hide show
  1. package/dist/application-cmd.d.ts +6 -16
  2. package/dist/application-cmd.js +34 -180
  3. package/dist/author-input.d.ts +40 -19
  4. package/dist/author-input.js +2 -16
  5. package/dist/build-assemble.d.ts +63 -41
  6. package/dist/build-assemble.js +42 -43
  7. package/dist/bundler-adapter.d.ts +46 -48
  8. package/dist/bundler-adapter.js +4 -43
  9. package/dist/cdn-policy.d.ts +77 -93
  10. package/dist/cdn-policy.js +10 -16
  11. package/dist/cli-localize.d.ts +34 -0
  12. package/dist/cli-localize.js +58 -0
  13. package/dist/cli.d.ts +8 -19
  14. package/dist/cli.js +69 -252
  15. package/dist/content-addressed-assets.d.ts +24 -10
  16. package/dist/content-addressed-assets.js +2 -7
  17. package/dist/delivery-profile.d.ts +54 -27
  18. package/dist/delivery-profile.js +15 -13
  19. package/dist/dev-session.d.ts +29 -23
  20. package/dist/dev-session.js +0 -21
  21. package/dist/dev-watch-roots.d.ts +34 -25
  22. package/dist/dev-watch-roots.js +0 -31
  23. package/dist/document-build.d.ts +22 -97
  24. package/dist/document-build.js +4 -19
  25. package/dist/document-check.d.ts +30 -53
  26. package/dist/document-check.js +14 -29
  27. package/dist/document-cmd.d.ts +3 -6
  28. package/dist/document-cmd.js +19 -79
  29. package/dist/document-designs.d.ts +5 -8
  30. package/dist/document-designs.js +2 -15
  31. package/dist/document-enrich.d.ts +52 -24
  32. package/dist/document-enrich.js +4 -32
  33. package/dist/document-evidence.d.ts +46 -43
  34. package/dist/document-evidence.js +6 -47
  35. package/dist/document-integrate.d.ts +13 -29
  36. package/dist/document-integrate.js +2 -13
  37. package/dist/document-interactive.d.ts +45 -67
  38. package/dist/document-interactive.js +9 -50
  39. package/dist/document-layout-render.d.ts +7 -16
  40. package/dist/document-layout-render.js +0 -17
  41. package/dist/document-locale.d.ts +12 -25
  42. package/dist/document-locale.js +3 -14
  43. package/dist/document-markdown.d.ts +9 -5
  44. package/dist/document-markdown.js +0 -4
  45. package/dist/document-routing-config.d.ts +7 -14
  46. package/dist/document-routing-config.js +0 -9
  47. package/dist/document-scan.d.ts +14 -18
  48. package/dist/document-scan.js +2 -23
  49. package/dist/document-schema.d.ts +154 -41
  50. package/dist/document-schema.js +0 -35
  51. package/dist/embedded-packaging.d.ts +20 -8
  52. package/dist/embedded-packaging.js +0 -1
  53. package/dist/explain-cmd.d.ts +4 -3
  54. package/dist/explain-cmd.js +16 -65
  55. package/dist/index.d.ts +70 -143
  56. package/dist/index.js +16 -136
  57. package/dist/invocation.d.ts +29 -50
  58. package/dist/invocation.js +11 -57
  59. package/dist/locale-check.d.ts +69 -70
  60. package/dist/locale-check.js +5 -66
  61. package/dist/locale-cmd.d.ts +2 -5
  62. package/dist/locale-cmd.js +62 -142
  63. package/dist/locale-delivery.d.ts +294 -191
  64. package/dist/locale-delivery.js +8 -94
  65. package/dist/locale-route-emit.d.ts +23 -9
  66. package/dist/locale-route-emit.js +0 -7
  67. package/dist/locale-router.d.ts +189 -162
  68. package/dist/locale-router.js +13 -122
  69. package/dist/locale-runtime.d.ts +292 -262
  70. package/dist/locale-runtime.js +8 -102
  71. package/dist/locale-schema.js +0 -1
  72. package/dist/locale-tooling.d.ts +100 -63
  73. package/dist/locale-tooling.js +7 -45
  74. package/dist/log.d.ts +22 -15
  75. package/dist/log.js +24 -21
  76. package/dist/native-addon.d.ts +10 -9
  77. package/dist/native-addon.js +1 -10
  78. package/dist/pack-client-packages.d.ts +5 -1
  79. package/dist/pack-client-packages.js +0 -6
  80. package/dist/pack.d.ts +17 -15
  81. package/dist/pack.js +0 -12
  82. package/dist/packages.d.ts +10 -23
  83. package/dist/packages.js +1 -37
  84. package/dist/plan-cmd.d.ts +6 -0
  85. package/dist/plan-cmd.js +35 -0
  86. package/dist/plugin-host.js +0 -1
  87. package/dist/port.d.ts +2 -10
  88. package/dist/port.js +2 -11
  89. package/dist/pretty-json.d.ts +9 -19
  90. package/dist/pretty-json.js +3 -17
  91. package/dist/production-observability.d.ts +37 -181
  92. package/dist/production-observability.js +1 -9
  93. package/dist/production-test-pack.d.ts +17 -3
  94. package/dist/production-test-pack.js +0 -2
  95. package/dist/public-static-assets.d.ts +6 -1
  96. package/dist/public-static-assets.js +0 -5
  97. package/dist/refactor-cmd.d.ts +3 -6
  98. package/dist/refactor-cmd.js +16 -69
  99. package/dist/release-cmd.d.ts +7 -6
  100. package/dist/release-cmd.js +17 -59
  101. package/dist/release-pack.d.ts +7 -3
  102. package/dist/release-pack.js +0 -6
  103. package/dist/resolve.d.ts +15 -19
  104. package/dist/resolve.js +1 -15
  105. package/dist/server-artifact.d.ts +30 -75
  106. package/dist/server-artifact.js +0 -10
  107. package/dist/server-language-backend.d.ts +22 -79
  108. package/dist/server-language-backend.js +0 -26
  109. package/dist/site-delivery.d.ts +46 -59
  110. package/dist/site-delivery.js +3 -8
  111. package/dist/site-favicon.d.ts +6 -1
  112. package/dist/site-favicon.js +0 -5
  113. package/dist/static-emit.d.ts +73 -103
  114. package/dist/static-emit.js +1 -26
  115. package/dist/test-cmd.d.ts +3 -5
  116. package/dist/test-cmd.js +15 -25
  117. package/dist/test-compile.js +0 -1
  118. package/dist/test-discover.js +0 -1
  119. package/dist/test-logic.js +0 -1
  120. package/dist/test-protocol.js +0 -1
  121. package/dist/toolchain-dx.d.ts +11 -0
  122. package/dist/toolchain-dx.js +10 -0
  123. package/dist/watch-diff.d.ts +4 -13
  124. package/dist/watch-diff.js +0 -17
  125. package/dist/wechat-packaging.d.ts +8 -7
  126. package/dist/wechat-packaging.js +0 -6
  127. package/locales/en-US/cli.json +105 -0
  128. package/locales/locales.json +4 -0
  129. package/package.json +15 -12
  130. package/dist/resolve-native-cli.d.ts +0 -14
  131. package/dist/resolve-native-cli.js +0 -84
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Locale runtime: LocaleContext · FormatterContext · negotiation ·
4
3
  * atomic LocaleTransition · SSR/client parity.
@@ -7,20 +6,9 @@
7
6
  */
8
7
  import { createHash } from 'node:crypto';
9
8
  import { DIAG_FORMATTER_CONTEXT_INCOMPLETE, DIAG_FORMATTER_VERSION_MISMATCH, DIAG_LOCALE_DIGEST_MISMATCH, DIAG_LOCALE_MACHINE_DEFAULT_FORBIDDEN, DIAG_LOCALE_STALE_GENERATION, DIAG_LOCALE_TRANSITION_LOAD_FAILED, DIAG_LOCALE_TRANSITION_PARTIAL, DIAG_LOCALE_TRANSITION_UNSUPPORTED, DIAG_MESSAGE_MIXED_LOCALE, FORMATTER_DATA_VERSION, LOCALE_APPLICATION_CONTEXT_SCHEMA, LOCALE_FALLBACK_RESOLUTION_SCHEMA, LOCALE_FORMATTER_CONTEXT_SCHEMA, LOCALE_RUNTIME_CHECK_SCHEMA, LOCALE_TRANSITION_SCHEMA, } from './locale-schema.js';
10
- /**
11
- * Fixed negotiation priority (locale notes ). Host only supplies candidates.
12
- * @param {{
13
- * supportedLocales: string[],
14
- * defaultLocale: string,
15
- * routeLocale?: string|null,
16
- * userChoice?: string|null,
17
- * preference?: string|null,
18
- * hostCandidates?: string[],
19
- * }} input
20
- */
9
+ /** Fixed negotiation priority. Host only supplies candidates. */
21
10
  export function negotiateLocale(input) {
22
11
  const supported = new Set(input.supportedLocales || []);
23
- /** @param {string|null|undefined} id */
24
12
  const accept = (id) => {
25
13
  if (!id || typeof id !== 'string')
26
14
  return null;
@@ -33,18 +21,6 @@ export function negotiateLocale(input) {
33
21
  (input.hostCandidates || []).map(accept).find(Boolean) ||
34
22
  input.defaultLocale);
35
23
  }
36
- /**
37
- * @param {{
38
- * applicationId: string,
39
- * deliveryId: string,
40
- * localeId: string,
41
- * timeZone: string,
42
- * calendar?: string,
43
- * numberingSystem?: string,
44
- * direction?: string,
45
- * generation?: number,
46
- * }} opts
47
- */
48
24
  export function buildApplicationContext(opts) {
49
25
  return {
50
26
  schema: LOCALE_APPLICATION_CONTEXT_SCHEMA,
@@ -58,10 +34,6 @@ export function buildApplicationContext(opts) {
58
34
  generation: opts.generation ?? 1,
59
35
  };
60
36
  }
61
- /**
62
- * @param {ReturnType<typeof buildApplicationContext>} app
63
- * @param {{ currency?: string }} [opts]
64
- */
65
37
  export function buildFormatterContext(app, opts = {}) {
66
38
  return {
67
39
  schema: LOCALE_FORMATTER_CONTEXT_SCHEMA,
@@ -73,10 +45,7 @@ export function buildFormatterContext(app, opts = {}) {
73
45
  formatterDataVersion: FORMATTER_DATA_VERSION,
74
46
  };
75
47
  }
76
- /**
77
- * Stable digest for Resume / SSR↔client parity.
78
- * @param {ReturnType<typeof buildFormatterContext>} formatter
79
- */
48
+ /** Stable digest for Resume / SSR↔client parity. */
80
49
  export function formatterContextDigest(formatter) {
81
50
  const canonical = {
82
51
  schema: formatter.schema,
@@ -89,13 +58,8 @@ export function formatterContextDigest(formatter) {
89
58
  };
90
59
  return createHash('sha256').update(JSON.stringify(canonical)).digest('hex').slice(0, 32);
91
60
  }
92
- /**
93
- * Server must not read machine locale/timezone defaults.
94
- * @param {ReturnType<typeof buildFormatterContext>} formatter
95
- * @param {{ allowMachineDefault?: boolean }} [opts]
96
- */
61
+ /** Server must not read machine locale/timezone defaults. */
97
62
  export function validateFormatterContext(formatter, opts = {}) {
98
- /** @type {Array<{code:string,severity:string,message:string}>} */
99
63
  const diagnostics = [];
100
64
  if (!formatter?.localeId || !formatter?.timeZone) {
101
65
  diagnostics.push({
@@ -133,15 +97,7 @@ export function validateFormatterContext(formatter, opts = {}) {
133
97
  diagnostics,
134
98
  };
135
99
  }
136
- /**
137
- * Resolve one MessageBinding to a single locale variant (whole-message, no mix).
138
- * @param {{
139
- * messageId: string,
140
- * requestedLocale: string,
141
- * variants: Record<string, { template: string }>,
142
- * fallback?: Record<string, string[]>,
143
- * }} input
144
- */
100
+ /** Resolve one MessageBinding to a single locale variant (whole-message, no mix). */
145
101
  export function resolveMessageVariant(input) {
146
102
  const fallback = input.fallback || {};
147
103
  const chain = [input.requestedLocale, ...(fallback[input.requestedLocale] || [])];
@@ -171,8 +127,6 @@ export function resolveMessageVariant(input) {
171
127
  }
172
128
  /**
173
129
  * Minimal ICU MessageFormat subset for parity proofs (params + plural + #).
174
- * @param {string} template
175
- * @param {Record<string, any>} [args]
176
130
  */
177
131
  export function formatMessageTemplate(template, args = {}) {
178
132
  let text = String(template || '');
@@ -202,27 +156,11 @@ export function formatMessageTemplate(template, args = {}) {
202
156
  });
203
157
  return text;
204
158
  }
205
- /**
206
- * @param {{
207
- * applicationId: string,
208
- * deliveryId: string,
209
- * supportedLocales: string[],
210
- * defaultLocale: string,
211
- * fallback?: Record<string, string[]>,
212
- * directions?: Record<string, string>,
213
- * messages: Record<string, { variants: Record<string, { template: string }> }>,
214
- * initialLocaleId: string,
215
- * timeZone: string,
216
- * generation?: number,
217
- * loadedChunks?: Set<string>|string[],
218
- * }} opts
219
- */
220
159
  export function createLocaleSession(opts) {
221
160
  const supported = new Set(opts.supportedLocales);
222
161
  const directions = opts.directions || {};
223
162
  const fallback = opts.fallback || {};
224
163
  let generation = opts.generation ?? 1;
225
- /** @type {Set<string>} */
226
164
  const loaded = new Set(opts.loadedChunks || [opts.initialLocaleId]);
227
165
  let app = buildApplicationContext({
228
166
  applicationId: opts.applicationId,
@@ -243,14 +181,9 @@ export function createLocaleSession(opts) {
243
181
  generation,
244
182
  };
245
183
  }
246
- /**
247
- * Render all known messages under current locale (atomic surface proof).
248
- * @param {Record<string, Record<string, any>>} [argMap]
249
- */
184
+ /** Render all known messages under current locale (atomic surface proof). */
250
185
  function renderAll(argMap = {}) {
251
- /** @type {Record<string, { text: string, resolvedLocale: string }>} */
252
186
  const out = {};
253
- /** @type {string[]} */
254
187
  const resolvedLocales = [];
255
188
  for (const [messageId, node] of Object.entries(opts.messages)) {
256
189
  const res = resolveMessageVariant({
@@ -270,15 +203,7 @@ export function createLocaleSession(opts) {
270
203
  const unique = [...new Set(resolvedLocales)];
271
204
  return { bindings: out, resolvedLocales: unique };
272
205
  }
273
- /**
274
- * Atomic LocaleTransition (locale notes ).
275
- * @param {string} targetLocaleId
276
- * @param {{
277
- * generation?: number,
278
- * loadChunk?: (localeId: string) => boolean|Promise<boolean>,
279
- * timeZone?: string,
280
- * }} [transitionOpts]
281
- */
206
+ /** Atomic LocaleTransition. */
282
207
  async function transition(targetLocaleId, transitionOpts = {}) {
283
208
  const fromLocale = app.localeId;
284
209
  const expectedGen = transitionOpts.generation ?? generation;
@@ -363,7 +288,6 @@ export function createLocaleSession(opts) {
363
288
  // After commit, every binding must resolve under the new requested locale
364
289
  // (or its explicit fallback chain) — never a mix of independent "half pages".
365
290
  const foreign = rendered.resolvedLocales.filter((loc) => loc !== targetLocaleId && !(fallback[targetLocaleId] || []).includes(loc));
366
- /** @type {any[]} */
367
291
  const diagnostics = [];
368
292
  if (foreign.length) {
369
293
  diagnostics.push({
@@ -404,15 +328,8 @@ export function createLocaleSession(opts) {
404
328
  },
405
329
  };
406
330
  }
407
- /**
408
- * SSR and client must share the same resolved FormatterContext digest and texts.
409
- * @param {{
410
- * ssr: { localeId: string, formatterDigest: string, formatterDataVersion?: string, texts: Record<string, string> },
411
- * client: { localeId: string, formatterDigest: string, formatterDataVersion?: string, texts: Record<string, string> },
412
- * }} input
413
- */
331
+ /** SSR and client must share the same resolved FormatterContext digest and texts. */
414
332
  export function checkSsrClientParity(input) {
415
- /** @type {Array<{code:string,severity:string,message:string}>} */
416
333
  const diagnostics = [];
417
334
  const { ssr, client } = input;
418
335
  if (ssr.localeId !== client.localeId) {
@@ -455,24 +372,13 @@ export function checkSsrClientParity(input) {
455
372
  diagnostics,
456
373
  };
457
374
  }
458
- /**
459
- * Aggregate runtime proof for a project check report + explicit contexts.
460
- * @param {{
461
- * manifest: { defaultLocale: string, locales: Array<{id:string,direction?:string}>, fallback?: Record<string,string[]> },
462
- * messages: Array<{ messageId: string, variants: Record<string, { template: string }> }>,
463
- * applicationId?: string,
464
- * deliveryId?: string,
465
- * timeZone?: string,
466
- * }} input
467
- */
375
+ /** Aggregate runtime proof for a project check report + explicit contexts. */
468
376
  export function checkLocaleRuntime(input) {
469
- /** @type {any[]} */
470
377
  const diagnostics = [];
471
378
  const supported = (input.manifest?.locales || []).map((l) => l.id);
472
379
  const defaultLocale = input.manifest?.defaultLocale;
473
380
  const fallback = input.manifest?.fallback || {};
474
381
  const directions = Object.fromEntries((input.manifest?.locales || []).map((l) => [l.id, l.direction || 'ltr']));
475
- /** @type {Record<string, { variants: Record<string, { template: string }> }>} */
476
382
  const messages = {};
477
383
  for (const m of input.messages || []) {
478
384
  messages[m.messageId] = { variants: m.variants };
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Locale – schema constants & diagnostic codes.
4
3
  */
@@ -1,17 +1,18 @@
1
- /**
2
- * Explain one MessageId: definition, params, variants, fallback, delivery reachability.
3
- * @param {{
4
- * messageId: string,
5
- * locale?: string|null,
6
- * deliveryId?: string|null,
7
- * checkReport: any,
8
- * }} input
9
- */
10
- export declare function explainLocaleMessage(input: any): {
1
+ /** Explain one MessageId: definition, params, variants, fallback, delivery reachability. */
2
+ export declare function explainLocaleMessage(input: {
3
+ messageId: string;
4
+ locale?: string | null;
5
+ deliveryId?: string | null;
6
+ checkReport: any;
7
+ }): {
11
8
  schema: string;
12
9
  status: string;
13
- messageId: any;
14
- diagnostics: any[];
10
+ messageId: string;
11
+ diagnostics: {
12
+ code: string;
13
+ severity: string;
14
+ message: string;
15
+ }[];
15
16
  catalogId?: undefined;
16
17
  params?: undefined;
17
18
  variants?: undefined;
@@ -23,45 +24,62 @@ export declare function explainLocaleMessage(input: any): {
23
24
  } | {
24
25
  schema: string;
25
26
  status: string;
26
- messageId: any;
27
+ messageId: string;
27
28
  catalogId: any;
28
29
  params: any;
29
30
  variants: {
30
31
  [k: string]: {
31
- template: any;
32
- path: any;
33
- params: any;
32
+ template: string;
33
+ path: string;
34
+ params: unknown;
34
35
  };
35
36
  };
36
37
  requestedLocale: any;
37
- resolvedLocale: any;
38
- fallbackPath: any[];
38
+ resolvedLocale: string;
39
+ fallbackPath: string[];
39
40
  formatterDataVersion: string;
40
41
  delivery: {
41
- deliveryId: any;
42
+ deliveryId: string;
42
43
  reachable: boolean;
43
- catalogHash: any;
44
- bundledLocales: any[];
44
+ catalogHash: string;
45
+ bundledLocales: string[];
45
46
  };
46
- diagnostics: any[];
47
+ diagnostics: {
48
+ code: string;
49
+ severity: string;
50
+ message: string;
51
+ }[];
47
52
  };
48
- /**
49
- * Diff two locales' catalogs.
50
- * @param {{
51
- * baseLocale: string,
52
- * targetLocale: string,
53
- * messages: Array<{ messageId: string, variants: Record<string, { template: string, params?: any[] }> }>,
54
- * }} input
55
- */
56
- export declare function diffLocaleCatalogs(input: any): {
53
+ export interface MessageCatalogEntry {
54
+ messageId: string;
55
+ variants: Record<string, {
56
+ template: string;
57
+ params?: unknown[];
58
+ path?: string;
59
+ }>;
60
+ }
61
+ /** Diff two locales' catalogs. */
62
+ export declare function diffLocaleCatalogs(input: {
63
+ baseLocale: string;
64
+ targetLocale: string;
65
+ messages: MessageCatalogEntry[];
66
+ }): {
57
67
  schema: string;
58
68
  status: string;
59
- baseLocale: any;
60
- targetLocale: any;
61
- missingInTarget: any[];
62
- missingInBase: any[];
63
- changed: any[];
64
- paramMismatches: any[];
69
+ baseLocale: string;
70
+ targetLocale: string;
71
+ missingInTarget: string[];
72
+ missingInBase: string[];
73
+ changed: {
74
+ messageId: string;
75
+ base: string;
76
+ target: string;
77
+ }[];
78
+ paramMismatches: {
79
+ messageId: string;
80
+ baseParams: unknown[];
81
+ targetParams: unknown[];
82
+ }[];
65
83
  summary: {
66
84
  missingInTarget: number;
67
85
  missingInBase: number;
@@ -72,47 +90,66 @@ export declare function diffLocaleCatalogs(input: any): {
72
90
  /**
73
91
  * Scan source for likely hardcoded UI text sinks (extract --check).
74
92
  * Does not auto-generate MessageIds.
75
- * @param {string} projectRoot
76
- * @param {{ check?: boolean }} [opts]
77
93
  */
78
- export declare function extractHardcodedText(projectRoot: any, opts?: {}): {
94
+ export declare function extractHardcodedText(projectRoot: string, opts?: {
95
+ check?: boolean;
96
+ }): {
79
97
  schema: string;
80
98
  status: string;
81
- findings: any[];
82
- diagnostics: any[];
99
+ findings: {
100
+ path: string;
101
+ kind: string;
102
+ text: string;
103
+ suggestion: string;
104
+ }[];
105
+ diagnostics: {
106
+ code: string;
107
+ severity: string;
108
+ message: string;
109
+ path?: string;
110
+ }[];
83
111
  };
84
112
  /**
85
113
  * Pseudo-localize a source locale for layout/overflow testing.
86
114
  * Preserves ICU placeholders; marks provenance — never a production fallback.
87
- * @param {{
88
- * sourceLocale: string,
89
- * messages: Array<{ messageId: string, variants: Record<string, { template: string }> }>,
90
- * production?: boolean,
91
- * }} input
92
115
  */
93
- export declare function pseudoLocalizeCatalog(input: any): {
116
+ export declare function pseudoLocalizeCatalog(input: {
117
+ sourceLocale: string;
118
+ messages: Array<{
119
+ messageId: string;
120
+ variants: Record<string, {
121
+ template: string;
122
+ }>;
123
+ }>;
124
+ production?: boolean;
125
+ }): {
94
126
  schema: string;
95
127
  status: string;
96
- sourceLocale: any;
128
+ sourceLocale: string;
97
129
  pseudoLocale: string;
98
130
  provenance: string;
99
- catalog: {};
100
- diagnostics: any[];
131
+ catalog: Record<string, string>;
132
+ diagnostics: {
133
+ code: string;
134
+ severity: string;
135
+ message: string;
136
+ }[];
101
137
  };
102
- /**
103
- * Cross-host conformance: same MessageId set + catalog hashes + formatter version.
104
- * @param {{
105
- * manifest: any,
106
- * messages: any[],
107
- * routeIds?: string[],
108
- * }} input
109
- */
110
- export declare function checkLocaleConformance(input: any): {
138
+ /** Cross-host conformance: same MessageId set + catalog hashes + formatter version. */
139
+ export declare function checkLocaleConformance(input: {
140
+ manifest: any;
141
+ messages: any[];
142
+ routeIds?: string[];
143
+ }): {
111
144
  schema: string;
112
145
  status: string;
113
146
  hosts: string[];
114
147
  formatterDataVersion: string;
115
- messageIds: any;
116
- catalogHashes: {};
117
- diagnostics: any[];
148
+ messageIds: any[];
149
+ catalogHashes: Record<string, string>;
150
+ diagnostics: {
151
+ code: string;
152
+ severity: string;
153
+ message: string;
154
+ }[];
118
155
  };
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Locale tooling: explain · diff · extract · pseudo · cross-host conformance.
4
3
  */
@@ -7,17 +6,8 @@ import path from 'node:path';
7
6
  import { DIAG_LOCALE_CONFORMANCE_DIVERGENCE, DIAG_LOCALE_EXPLAIN_UNKNOWN, DIAG_LOCALE_HARDCODED_TEXT, DIAG_LOCALE_PSEUDO_PRODUCTION_FORBIDDEN, DIAG_MESSAGE_DYNAMIC_ID_UNBOUNDED, FORMATTER_DATA_VERSION, LOCALE_CONFORMANCE_SCHEMA, LOCALE_DIFF_SCHEMA, LOCALE_EXPLAIN_SCHEMA, LOCALE_EXTRACT_SCHEMA, LOCALE_PSEUDO_SCHEMA, } from './locale-schema.js';
8
7
  import { resolveMessageVariant } from './locale-runtime.js';
9
8
  import { assertHostMessageInvariant, buildLocaleDeliveryResolution } from './locale-delivery.js';
10
- /**
11
- * Explain one MessageId: definition, params, variants, fallback, delivery reachability.
12
- * @param {{
13
- * messageId: string,
14
- * locale?: string|null,
15
- * deliveryId?: string|null,
16
- * checkReport: any,
17
- * }} input
18
- */
9
+ /** Explain one MessageId: definition, params, variants, fallback, delivery reachability. */
19
10
  export function explainLocaleMessage(input) {
20
- /** @type {any[]} */
21
11
  const diagnostics = [];
22
12
  const messages = input.checkReport?.messageCatalog?.messages || [];
23
13
  const node = messages.find((m) => m.messageId === input.messageId);
@@ -63,7 +53,10 @@ export function explainLocaleMessage(input) {
63
53
  messageId: input.messageId,
64
54
  catalogId: node.catalogId,
65
55
  params: base?.params || [],
66
- variants: Object.fromEntries(Object.entries(node.variants || {}).map(([loc, v]) => [loc, { template: v.template, path: v.path, params: v.params }])),
56
+ variants: Object.fromEntries(Object.entries(node.variants || {}).map(([loc, v]) => {
57
+ const variant = v;
58
+ return [loc, { template: variant.template, path: variant.path, params: variant.params }];
59
+ })),
67
60
  requestedLocale: requested,
68
61
  resolvedLocale: resolution.resolvedLocale,
69
62
  fallbackPath: resolution.fallbackPath,
@@ -77,24 +70,13 @@ export function explainLocaleMessage(input) {
77
70
  diagnostics,
78
71
  };
79
72
  }
80
- /**
81
- * Diff two locales' catalogs.
82
- * @param {{
83
- * baseLocale: string,
84
- * targetLocale: string,
85
- * messages: Array<{ messageId: string, variants: Record<string, { template: string, params?: any[] }> }>,
86
- * }} input
87
- */
73
+ /** Diff two locales' catalogs. */
88
74
  export function diffLocaleCatalogs(input) {
89
75
  const base = input.baseLocale;
90
76
  const target = input.targetLocale;
91
- /** @type {any[]} */
92
77
  const missingInTarget = [];
93
- /** @type {any[]} */
94
78
  const missingInBase = [];
95
- /** @type {any[]} */
96
79
  const changed = [];
97
- /** @type {any[]} */
98
80
  const paramMismatches = [];
99
81
  const ids = new Set();
100
82
  for (const m of input.messages || [])
@@ -138,13 +120,9 @@ export function diffLocaleCatalogs(input) {
138
120
  /**
139
121
  * Scan source for likely hardcoded UI text sinks (extract --check).
140
122
  * Does not auto-generate MessageIds.
141
- * @param {string} projectRoot
142
- * @param {{ check?: boolean }} [opts]
143
123
  */
144
124
  export function extractHardcodedText(projectRoot, opts = {}) {
145
- /** @type {any[]} */
146
125
  const findings = [];
147
- /** @type {any[]} */
148
126
  const diagnostics = [];
149
127
  const srcRoot = path.join(projectRoot, 'src');
150
128
  if (!fs.existsSync(srcRoot)) {
@@ -155,7 +133,6 @@ export function extractHardcodedText(projectRoot, opts = {}) {
155
133
  diagnostics: [],
156
134
  };
157
135
  }
158
- /** @type {string[]} */
159
136
  const files = [];
160
137
  const walk = (dir) => {
161
138
  for (const ent of fs.readdirSync(dir, { withFileTypes: true })) {
@@ -248,14 +225,8 @@ export function extractHardcodedText(projectRoot, opts = {}) {
248
225
  /**
249
226
  * Pseudo-localize a source locale for layout/overflow testing.
250
227
  * Preserves ICU placeholders; marks provenance — never a production fallback.
251
- * @param {{
252
- * sourceLocale: string,
253
- * messages: Array<{ messageId: string, variants: Record<string, { template: string }> }>,
254
- * production?: boolean,
255
- * }} input
256
228
  */
257
229
  export function pseudoLocalizeCatalog(input) {
258
- /** @type {any[]} */
259
230
  const diagnostics = [];
260
231
  if (input.production) {
261
232
  diagnostics.push({
@@ -264,7 +235,6 @@ export function pseudoLocalizeCatalog(input) {
264
235
  message: 'pseudo locale must not be used as production fallback',
265
236
  });
266
237
  }
267
- /** @type {Record<string, string>} */
268
238
  const catalog = {};
269
239
  for (const m of input.messages || []) {
270
240
  const src = m.variants?.[input.sourceLocale]?.template;
@@ -292,16 +262,8 @@ export function pseudoLocalizeCatalog(input) {
292
262
  diagnostics,
293
263
  };
294
264
  }
295
- /**
296
- * Cross-host conformance: same MessageId set + catalog hashes + formatter version.
297
- * @param {{
298
- * manifest: any,
299
- * messages: any[],
300
- * routeIds?: string[],
301
- * }} input
302
- */
265
+ /** Cross-host conformance: same MessageId set + catalog hashes + formatter version. */
303
266
  export function checkLocaleConformance(input) {
304
- /** @type {any[]} */
305
267
  const diagnostics = [];
306
268
  const supported = (input.manifest?.locales || []).map((l) => l.id);
307
269
  const defaultLocale = input.manifest?.defaultLocale;
package/dist/log.d.ts CHANGED
@@ -1,19 +1,26 @@
1
1
  /**
2
- * Unified CLI logging / diagnostics .
2
+ * Unified CLI logging / diagnostics via `@vmz/diagnostic` + product catalog.
3
3
  */
4
+ export type DiagnosticLike = {
5
+ severity?: string;
6
+ path?: string;
7
+ message?: string;
8
+ code?: string;
9
+ args?: Record<string, string>;
10
+ span?: {
11
+ start: number;
12
+ end: number;
13
+ };
14
+ };
4
15
  export declare const log: {
5
- /** @param {...unknown} args */
6
- info(...args: any[]): void;
7
- /** @param {...unknown} args */
8
- warn(...args: any[]): void;
9
- /** @param {...unknown} args */
10
- error(...args: any[]): void;
11
- /** @param {{ severity: string, path?: string, message: string, code?: string }} d */
12
- diagnostic(d: any): void;
13
- /**
14
- * @param {Array<{ severity: string, path?: string, message: string, code?: string }>} diagnostics
15
- * @param {{ denyWarnings?: boolean }} [opts]
16
- * @returns {number} failing count (errors, and warnings if denyWarnings)
17
- */
18
- diagnostics(diagnostics: any, opts?: {}): number;
16
+ info(...args: unknown[]): void;
17
+ warn(...args: unknown[]): void;
18
+ error(...args: unknown[]): void;
19
+ /** Localized framework error (`cli.err.*`). */
20
+ errorId(id: string, args?: Record<string, string>): void;
21
+ diagnostic(d: DiagnosticLike): void;
22
+ /** Failing count: errors, and warnings when `denyWarnings`. */
23
+ diagnostics(diagnostics: DiagnosticLike[] | null | undefined, opts?: {
24
+ denyWarnings?: boolean;
25
+ }): number;
19
26
  };
package/dist/log.js CHANGED
@@ -1,41 +1,44 @@
1
- // @ts-nocheck
2
1
  /**
3
- * Unified CLI logging / diagnostics .
2
+ * Unified CLI logging / diagnostics via `@vmz/diagnostic` + product catalog.
4
3
  */
5
- /** @param {string} level */
4
+ import { formatDiagnostic } from '@vmz/diagnostic';
5
+ import { loadCliCatalog, resolveVmzLocale, vmzCliLocalize } from './cli-localize.js';
6
6
  function stamp(level) {
7
7
  return `vmz ${level}`;
8
8
  }
9
9
  export const log = {
10
- /** @param {...unknown} args */
11
10
  info(...args) {
12
11
  console.error(stamp('info'), ...args);
13
12
  },
14
- /** @param {...unknown} args */
15
13
  warn(...args) {
16
14
  console.error(stamp('warn'), ...args);
17
15
  },
18
- /** @param {...unknown} args */
19
16
  error(...args) {
20
17
  console.error(stamp('error'), ...args);
21
18
  },
22
- /** @param {{ severity: string, path?: string, message: string, code?: string }} d */
19
+ /** Localized framework error (`cli.err.*`). */
20
+ errorId(id, args) {
21
+ console.error(stamp('error'), vmzCliLocalize.t(id, args));
22
+ },
23
23
  diagnostic(d) {
24
- const sev = d.severity || 'error';
25
- const code = d.code ? `${d.code}: ` : '';
26
- const loc = d.path ? ` (${d.path})` : '';
27
- // Prefer `vmz warn|error CODE: message (path)` so locale warnings are visible, not silent.
28
- if (sev === 'warning') {
29
- console.error(`${stamp('warn')} ${code}${d.message}${loc}`);
30
- return;
31
- }
32
- console.error(`${stamp(sev === 'error' ? 'error' : sev)} ${code}${d.path ? `${d.path}: ` : ''}${d.message}`);
24
+ const severity = d.severity === 'warning' || d.severity === 'advice' || d.severity === 'error' ? d.severity : 'error';
25
+ const code = d.code && String(d.code).length ? String(d.code) : 'diag.message';
26
+ const locale = resolveVmzLocale();
27
+ const catalog = loadCliCatalog(locale);
28
+ const line = formatDiagnostic({
29
+ path: d.path || '',
30
+ severity,
31
+ code,
32
+ args: d.args || (d.message ? { message: String(d.message) } : undefined),
33
+ message: d.message,
34
+ span: d.span,
35
+ }, {
36
+ locale,
37
+ catalog,
38
+ });
39
+ console.error(stamp(severity === 'warning' ? 'warn' : severity === 'error' ? 'error' : 'diag'), line);
33
40
  },
34
- /**
35
- * @param {Array<{ severity: string, path?: string, message: string, code?: string }>} diagnostics
36
- * @param {{ denyWarnings?: boolean }} [opts]
37
- * @returns {number} failing count (errors, and warnings if denyWarnings)
38
- */
41
+ /** Failing count: errors, and warnings when `denyWarnings`. */
39
42
  diagnostics(diagnostics, opts = {}) {
40
43
  let failing = 0;
41
44
  for (const d of diagnostics ?? []) {