@vmz/vmz 0.1.17 → 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
  * Document Static + Interactive artifacts.
4
3
  */
@@ -16,9 +15,6 @@ import { DOCUMENT_VIEW_SCHEMA } from './document-schema.js';
16
15
  import { createWorkspace } from './index.js';
17
16
  import { requireNativeAddon } from './native-addon.js';
18
17
  import { writePrettyJsonFile } from './pretty-json.js';
19
- /**
20
- * @param {{ projectRoot: string, outDir?: string, appDistDir?: string, strict?: boolean, engines?: { markdown?: string } }} opts
21
- */
22
18
  export async function buildDocuments(opts) {
23
19
  const projectRoot = path.resolve(opts.projectRoot);
24
20
  const outDir = path.resolve(opts.outDir || path.join(projectRoot, 'dist', 'documents'));
@@ -42,7 +38,6 @@ export async function buildDocuments(opts) {
42
38
  if (manifestHasErrors(manifest)) {
43
39
  return { ok: false, manifest, outDir, pages: [] };
44
40
  }
45
- /** @type {Map<string, any>} */
46
41
  const analyzedByPageId = new Map();
47
42
  for (const page of manifest.pages) {
48
43
  const abs = path.isAbsolute(page.sourcePath) ? page.sourcePath : path.join(manifest.root, page.sourcePath);
@@ -72,7 +67,6 @@ export async function buildDocuments(opts) {
72
67
  }
73
68
  fs.mkdirSync(outDir, { recursive: true });
74
69
  const designs = resolveDocumentDesignsCss(projectRoot);
75
- /** @type {string | null} */
76
70
  let designsHref = null;
77
71
  if (designs.css && designs.href) {
78
72
  const cssPath = path.join(outDir, designs.href);
@@ -82,7 +76,6 @@ export async function buildDocuments(opts) {
82
76
  }
83
77
  const viewsDir = path.join(outDir, 'views');
84
78
  fs.mkdirSync(viewsDir, { recursive: true });
85
- /** @type {Array<{ route: string, htmlPath: string, viewPath: string }>} */
86
79
  const written = [];
87
80
  for (const page of manifest.pages) {
88
81
  const id = `${page.identity.locale}:${page.identity.pageKey}`;
@@ -111,7 +104,7 @@ export async function buildDocuments(opts) {
111
104
  playgroundShellHtml: shells.playgroundHtml,
112
105
  });
113
106
  let compiledLayoutHtml = null;
114
- if (useCompiledShell) {
107
+ if (useCompiledShell && appDistDir) {
115
108
  compiledLayoutHtml = await renderCompiledDocumentLayout(appDistDir, page.identity.locale, slotHtml);
116
109
  }
117
110
  const view = {
@@ -180,10 +173,6 @@ export async function buildDocuments(opts) {
180
173
  writePrettyJsonFile(path.join(outDir, 'document.islands.json'), islands);
181
174
  return { ok: true, manifest: manifestOut, outDir, pages: written, search, islands };
182
175
  }
183
- /**
184
- * @param {{ appDistDir?: string }} opts
185
- * @param {string} outDir
186
- */
187
176
  function resolveAppDistDir(opts, outDir) {
188
177
  if (opts.appDistDir) {
189
178
  const p = path.resolve(opts.appDistDir);
@@ -191,10 +180,8 @@ function resolveAppDistDir(opts, outDir) {
191
180
  }
192
181
  return fs.existsSync(path.join(outDir, 'vmz-dom.js')) ? outDir : null;
193
182
  }
194
- /**
195
- * Document main column + sidebar (injected into DocumentLayout slot).
196
- */
197
- function buildDocumentSlotHtml({ nav, bodyHtml, headings, htmlRel, route, routing, searchShellHtml = '', playgroundShellHtml = '' }) {
183
+ /** Document main column + sidebar (injected into DocumentLayout slot). */
184
+ function buildDocumentSlotHtml({ nav, bodyHtml, headings, htmlRel, route, routing, searchShellHtml = '', playgroundShellHtml = '', }) {
198
185
  const esc = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
199
186
  const navItems = nav
200
187
  .map((n) => {
@@ -232,17 +219,15 @@ function renderStaticHtml({ title, locale, route, nav, bodyHtml, headings, desig
232
219
  const esc = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
233
220
  const depth = htmlRel.split('/').length - 1;
234
221
  const prefix = depth > 0 ? '../'.repeat(depth) : './';
235
- /** @type {string[]} */
236
222
  const cssHrefs = [];
237
223
  if (useCompiledShell) {
238
224
  cssHrefs.push('/vmz.css');
239
225
  }
240
226
  if (designsHref)
241
227
  cssHrefs.push(useCompiledShell ? `/${designsHref}` : prefix + designsHref);
242
- /** @type {string} */
243
228
  let bodyInner;
244
229
  if (useCompiledShell) {
245
- bodyInner = compiledLayoutHtml;
230
+ bodyInner = compiledLayoutHtml || '';
246
231
  }
247
232
  else {
248
233
  const navItems = nav
@@ -4,60 +4,37 @@
4
4
  * Author documents config is parsed by Rust DocumentRoutePlan; TS only
5
5
  * merges filesystem scan (pageKeys) and coverage diagnostics.
6
6
  */
7
- /**
8
- * Resolve project documents root.
9
- * @param {string} projectRoot
10
- */
11
- export declare function resolveDocumentsRoot(projectRoot: any): string;
12
- /**
13
- * Load normalized DocumentRoutePlan from Rust (author JSON5/JSON/declaration).
14
- * @param {string} projectRoot
15
- */
16
- export declare function loadDocumentsRoutePlan(projectRoot: any): any;
7
+ import { type DocumentRoutePlan } from './author-input.js';
8
+ import { type DocumentDiagnostic, type DocumentManifest } from './document-schema.js';
9
+ export interface DocumentsConfigShape {
10
+ defaultLocale?: string;
11
+ locales: Record<string, {
12
+ label: unknown;
13
+ }>;
14
+ collections: Record<string, {
15
+ source: string;
16
+ mount: string;
17
+ }>;
18
+ fallback?: boolean;
19
+ }
20
+ export interface LoadDocumentsConfigResult {
21
+ config: DocumentsConfigShape | null;
22
+ diagnostics: DocumentDiagnostic[];
23
+ configPath: string | null;
24
+ plan: DocumentRoutePlan;
25
+ }
26
+ export interface CheckDocumentsOpts {
27
+ projectRoot: string;
28
+ strict?: boolean;
29
+ }
30
+ /** Resolve project documents root. */
31
+ export declare function resolveDocumentsRoot(projectRoot: string): string;
32
+ /** Load normalized DocumentRoutePlan from Rust (author JSON5/JSON/declaration). */
33
+ export declare function loadDocumentsRoutePlan(projectRoot: string): DocumentRoutePlan;
17
34
  /**
18
35
  * @deprecated Prefer loadDocumentsRoutePlan(projectRoot). Kept for call sites that
19
36
  * only need the plan-shaped config fields.
20
- * @param {string} documentsRoot
21
- */
22
- export declare function loadDocumentsConfig(documentsRoot: any): {
23
- config: {
24
- defaultLocale: any;
25
- locales: {
26
- [k: string]: {
27
- label: unknown;
28
- };
29
- };
30
- collections: {
31
- [k: string]: any;
32
- };
33
- };
34
- diagnostics: any;
35
- configPath: string;
36
- plan: any;
37
- };
38
- /**
39
- * @param {object} opts
40
- * @param {string} opts.projectRoot
41
- * @param {boolean} [opts.strict]
42
- * @returns {import('./document-schema.js').DocumentManifest}
43
- */
44
- export declare function checkDocuments(opts: any): {
45
- schema: string;
46
- root: string;
47
- defaultLocale: any;
48
- locales: any[];
49
- localeLabels: any;
50
- collections: any[];
51
- mounts: any[];
52
- pages: {
53
- identity: any;
54
- sourcePath: any;
55
- route: any;
56
- anchors: any[];
57
- }[];
58
- diagnostics: any[];
59
- };
60
- /**
61
- * @param {import('./document-schema.js').DocumentManifest} manifest
62
37
  */
63
- export declare function manifestHasErrors(manifest: any): any;
38
+ export declare function loadDocumentsConfig(documentsRoot: string): LoadDocumentsConfigResult;
39
+ export declare function checkDocuments(opts: CheckDocumentsOpts): DocumentManifest;
40
+ export declare function manifestHasErrors(manifest: DocumentManifest): boolean;
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Build DocumentManifest + run / --strict checks.
4
3
  *
@@ -8,62 +7,47 @@
8
7
  import path from 'node:path';
9
8
  import { loadDocumentRoutePlan, mapPlanDiagnostics } from './author-input.js';
10
9
  import { scanDocumentsTree } from './document-scan.js';
11
- import { DIAG, DOCUMENT_MANIFEST_SCHEMA } from './document-schema.js';
12
- /**
13
- * Resolve project documents root.
14
- * @param {string} projectRoot
15
- */
10
+ import { DIAG, DOCUMENT_MANIFEST_SCHEMA, } from './document-schema.js';
11
+ /** Resolve project documents root. */
16
12
  export function resolveDocumentsRoot(projectRoot) {
17
13
  return path.resolve(projectRoot, 'documents');
18
14
  }
19
- /**
20
- * Load normalized DocumentRoutePlan from Rust (author JSON5/JSON/declaration).
21
- * @param {string} projectRoot
22
- */
15
+ /** Load normalized DocumentRoutePlan from Rust (author JSON5/JSON/declaration). */
23
16
  export function loadDocumentsRoutePlan(projectRoot) {
24
17
  return loadDocumentRoutePlan(projectRoot);
25
18
  }
26
19
  /**
27
20
  * @deprecated Prefer loadDocumentsRoutePlan(projectRoot). Kept for call sites that
28
21
  * only need the plan-shaped config fields.
29
- * @param {string} documentsRoot
30
22
  */
31
23
  export function loadDocumentsConfig(documentsRoot) {
32
24
  const projectRoot = path.dirname(documentsRoot);
33
25
  const plan = loadDocumentRoutePlan(projectRoot);
34
- const diagnostics = mapPlanDiagnostics(plan.diagnostics);
26
+ const diagnostics = toDocumentDiagnostics(mapPlanDiagnostics(plan.diagnostics));
35
27
  const configPath = plan.sourcePath ? path.join(projectRoot, plan.sourcePath) : null;
36
28
  const missing = diagnostics.some((d) => d.code === DIAG.CONFIG_MISSING);
37
29
  if (missing) {
38
30
  return { config: null, diagnostics, configPath, plan };
39
31
  }
40
- /** @type {Record<string, any>} */
41
32
  const config = {
42
33
  defaultLocale: plan.defaultLocale ?? undefined,
43
34
  locales: Object.fromEntries(Object.entries(plan.localeLabels || {}).map(([id, label]) => [id, { label }])),
44
- collections: Object.fromEntries((plan.collections || []).map((c) => [c.id, { source: c.sourceRoot, mount: c.routeBase }])),
35
+ collections: Object.fromEntries((plan.collections || []).map((c) => [c.id, { source: c.sourceRoot || '.', mount: c.routeBase || '/docs' }])),
45
36
  };
46
37
  if (plan.silentFallbackRequested) {
47
38
  config.fallback = true;
48
39
  }
49
40
  return { config, diagnostics, configPath, plan };
50
41
  }
51
- /**
52
- * @param {object} opts
53
- * @param {string} opts.projectRoot
54
- * @param {boolean} [opts.strict]
55
- * @returns {import('./document-schema.js').DocumentManifest}
56
- */
57
42
  export function checkDocuments(opts) {
58
43
  const projectRoot = path.resolve(opts.projectRoot);
59
44
  const documentsRoot = resolveDocumentsRoot(projectRoot);
60
45
  const strict = Boolean(opts.strict);
61
- /** @type {import('./document-schema.js').DocumentDiagnostic[]} */
62
46
  const diagnostics = [];
63
47
  const scanned = scanDocumentsTree(documentsRoot);
64
48
  diagnostics.push(...scanned.diagnostics);
65
49
  const plan = loadDocumentRoutePlan(projectRoot);
66
- diagnostics.push(...mapPlanDiagnostics(plan.diagnostics));
50
+ diagnostics.push(...toDocumentDiagnostics(mapPlanDiagnostics(plan.diagnostics)));
67
51
  const configMissing = (plan.diagnostics || []).some((d) => d.code === DIAG.CONFIG_MISSING);
68
52
  const configPath = plan.sourcePath ? path.join(projectRoot, plan.sourcePath) : null;
69
53
  if (configMissing && strict) {
@@ -77,12 +61,9 @@ export function checkDocuments(opts) {
77
61
  });
78
62
  }
79
63
  }
80
- /** @type {Record<string, string>} */
81
64
  const localeLabels = { ...(plan.localeLabels || {}) };
82
65
  const defaultLocale = plan.defaultLocale || null;
83
- /** @type {import('./document-schema.js').DocumentCollection[]} */
84
66
  const collections = [];
85
- /** @type {import('./document-schema.js').DocumentMount[]} */
86
67
  const mounts = [];
87
68
  for (const c of plan.collections || []) {
88
69
  const sourceRoot = c.sourceRoot || '.';
@@ -182,7 +163,6 @@ export function checkDocuments(opts) {
182
163
  }
183
164
  }
184
165
  }
185
- /** @type {import('./document-schema.js').PageRecord[]} */
186
166
  const pages = scanned.pages.map((p) => ({
187
167
  identity: p.identity,
188
168
  sourcePath: p.sourcePath,
@@ -201,9 +181,14 @@ export function checkDocuments(opts) {
201
181
  diagnostics,
202
182
  };
203
183
  }
204
- /**
205
- * @param {import('./document-schema.js').DocumentManifest} manifest
206
- */
207
184
  export function manifestHasErrors(manifest) {
208
185
  return (manifest.diagnostics || []).some((d) => d.severity === 'error');
209
186
  }
187
+ function toDocumentDiagnostics(rows) {
188
+ return rows.map((d) => ({
189
+ code: d.code,
190
+ severity: d.severity === 'warning' || d.severity === 'advice' ? 'warning' : 'error',
191
+ message: d.message,
192
+ path: d.path,
193
+ }));
194
+ }
@@ -1,8 +1,5 @@
1
1
  /**
2
- * `vmz document` / `vmz docs` CLI .
2
+ * `vmz document` / `vmz docs` — registered on `@vmz/commander`.
3
3
  */
4
- /**
5
- * @param {string[]} argv
6
- * @returns {Promise<number>}
7
- */
8
- export declare function cmdDocument(argv: any): Promise<0 | 1>;
4
+ import type { Command } from '@vmz/commander';
5
+ export declare function registerDocumentCommands(parent: Command): void;
@@ -1,6 +1,5 @@
1
- // @ts-nocheck
2
1
  /**
3
- * `vmz document` / `vmz docs` CLI .
2
+ * `vmz document` / `vmz docs` — registered on `@vmz/commander`.
4
3
  */
5
4
  import path from 'node:path';
6
5
  import { buildDocuments } from './document-build.js';
@@ -10,66 +9,16 @@ import { enrichDocumentEvidence } from './document-evidence.js';
10
9
  import { resolveMarkdownEngine } from './document-markdown.js';
11
10
  import { createWorkspace } from './index.js';
12
11
  import { log } from './log.js';
13
- import { parseArgs } from './cli.js';
14
12
  import { emitPrettyJson } from './pretty-json.js';
15
- function printDocumentHelp() {
16
- console.log(`vmz document — project /documents domain
17
-
18
- Usage:
19
- vmz document check [project] Check locale tree + links/anchors + fence/API evidence
20
- vmz document build [project] Static HTML + view + evidence + search/islands + /designs CSS
21
- vmz docs check|build […] Alias of document
22
-
23
- Options:
24
- --root <dir> Project root (default: . or positional path)
25
- --out <dir> Build output (default: <project>/dist/documents)
26
- --strict Fail on missing/orphan translations & require defaultLocale
27
- --json [file] Emit DocumentManifest JSON to stdout or file
28
- `);
13
+ export function registerDocumentCommands(parent) {
14
+ const withOpts = (cmd) => cmd
15
+ .option('--root <dir>', 'cli.opt.root')
16
+ .option('--out <dir>', 'cli.opt.out')
17
+ .option('--strict', 'cli.opt.strict')
18
+ .option('--json [file]', 'cli.opt.json');
19
+ withOpts(parent.command('check', 'cli.cmd.document.check')).action((options) => cmdDocumentCheck(options));
20
+ withOpts(parent.command('build', 'cli.cmd.document.build')).action((options) => cmdDocumentBuild(options));
29
21
  }
30
- /**
31
- * @param {string[]} argv
32
- * @returns {Promise<number>}
33
- */
34
- export async function cmdDocument(argv) {
35
- const [sub, ...rest] = argv;
36
- if (!sub) {
37
- if (process.stdout.isTTY) {
38
- printDocumentHelp();
39
- return 0;
40
- }
41
- log.error('vmz document requires a subcommand in non-interactive/CI contexts');
42
- printDocumentHelp();
43
- return 1;
44
- }
45
- if (sub === 'help' || sub === '-h' || sub === '--help') {
46
- printDocumentHelp();
47
- return 0;
48
- }
49
- if (sub.startsWith('-')) {
50
- log.error('vmz document requires a subcommand (check|build)');
51
- printDocumentHelp();
52
- return 1;
53
- }
54
- const args = parseArgs(rest);
55
- switch (sub) {
56
- case 'check':
57
- return cmdDocumentCheck(args);
58
- case 'build':
59
- return cmdDocumentBuild(args);
60
- case 'dev':
61
- case 'serve':
62
- case 'test':
63
- case 'clean':
64
- log.error(`vmz document ${sub} is not implemented yet`);
65
- return 1;
66
- default:
67
- log.error(`unknown document subcommand \`${sub}\``);
68
- printDocumentHelp();
69
- return 1;
70
- }
71
- }
72
- /** @param {Record<string, string | boolean> & { _: string[] }} args */
73
22
  async function cmdDocumentCheck(args) {
74
23
  const project = (typeof args.root === 'string' && args.root) || (typeof args._[0] === 'string' && args._[0]) || '.';
75
24
  const projectRoot = path.resolve(project);
@@ -91,25 +40,21 @@ async function cmdDocumentCheck(args) {
91
40
  manifest.evidence = evidence.evidence;
92
41
  }
93
42
  catch (e) {
94
- log.warn(`document check: markdown/evidence unavailable (${e.message}); skipping enrich`);
43
+ const msg = e instanceof Error ? e.message : String(e);
44
+ log.warn(`document check: markdown/evidence unavailable (${msg}); skipping enrich`);
95
45
  }
96
46
  const jsonOut = args.json;
97
47
  if (jsonOut) {
98
- emitPrettyJson(jsonOut, manifest, { logWrote: (p) => log.info(`wrote ${p}`) });
48
+ emitPrettyJson(typeof jsonOut === 'string' ? jsonOut : true, manifest, {
49
+ logWrote: (p) => log.info(`wrote ${p}`),
50
+ });
99
51
  }
100
52
  else {
101
- for (const d of manifest.diagnostics) {
102
- const loc = d.path ? ` (${d.path})` : '';
103
- if (d.severity === 'error')
104
- log.error(`${d.code}: ${d.message}${loc}`);
105
- else
106
- console.warn(`vmz warn ${d.code}: ${d.message}${loc}`);
107
- }
53
+ log.diagnostics(manifest.diagnostics ?? []);
108
54
  log.info(`document check: locales=${manifest.locales.join(',') || '(none)'} pages=${manifest.pages.length} defaultLocale=${manifest.defaultLocale ?? '(none)'}`);
109
55
  }
110
56
  return manifestHasErrors(manifest) ? 1 : 0;
111
57
  }
112
- /** @param {Record<string, string | boolean> & { _: string[] }} args */
113
58
  async function cmdDocumentBuild(args) {
114
59
  const project = (typeof args.root === 'string' && args.root) || (typeof args._[0] === 'string' && args._[0]) || '.';
115
60
  const projectRoot = path.resolve(project);
@@ -120,18 +65,13 @@ async function cmdDocumentBuild(args) {
120
65
  result = await buildDocuments({ projectRoot, outDir, strict });
121
66
  }
122
67
  catch (e) {
123
- log.error(`document build failed: ${e.message || e}`);
68
+ const msg = e instanceof Error ? e.message : String(e);
69
+ log.error(`document build failed: ${msg}`);
124
70
  return 1;
125
71
  }
126
- for (const d of result.manifest.diagnostics || []) {
127
- const loc = d.path ? ` (${d.path})` : '';
128
- if (d.severity === 'error')
129
- log.error(`${d.code}: ${d.message}${loc}`);
130
- else
131
- console.warn(`vmz warn ${d.code}: ${d.message}${loc}`);
132
- }
72
+ log.diagnostics(result.manifest.diagnostics || []);
133
73
  if (!result.ok) {
134
- log.error('document build aborted due to diagnostics');
74
+ log.errorId('cli.err.document_build_aborted');
135
75
  return 1;
136
76
  }
137
77
  log.info(`document build: pages=${result.pages.length} out=${path.relative(process.cwd(), result.outDir) || '.'} designs=${result.manifest.build?.designsCss ?? '(none)'}`);
@@ -1,9 +1,6 @@
1
- /**
2
- * @param {string} projectRoot
3
- * @returns {{ css: string, source: string | null, href: string | null }}
4
- */
5
- export declare function resolveDocumentDesignsCss(projectRoot: any): {
1
+ export interface DocumentDesignsCssResult {
6
2
  css: string;
7
- source: string;
8
- href: string;
9
- };
3
+ source: string | null;
4
+ href: string | null;
5
+ }
6
+ export declare function resolveDocumentDesignsCss(projectRoot: string): DocumentDesignsCssResult;
@@ -1,22 +1,15 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Document — wire project `/designs` into static document assets.
4
3
  * Prefer compiled `vmz-designs.css` / `vmz.css`; else emit a minimal token CSS.
5
4
  */
6
5
  import fs from 'node:fs';
7
6
  import path from 'node:path';
8
- /**
9
- * @param {string} projectRoot
10
- * @returns {{ css: string, source: string | null, href: string | null }}
11
- */
12
7
  export function resolveDocumentDesignsCss(projectRoot) {
13
8
  const designsDir = path.join(projectRoot, 'designs');
14
9
  if (!fs.existsSync(designsDir) || !fs.statSync(designsDir).isDirectory()) {
15
10
  return { css: '', source: null, href: null };
16
11
  }
17
- /** @type {string[]} */
18
12
  const parts = [];
19
- /** @type {string[]} */
20
13
  const sources = [];
21
14
  // Layout first so @import (fonts) stays at stylesheet top; theme tokens follow.
22
15
  const layoutCandidates = [path.join(designsDir, 'document', 'chrome.css'), path.join(designsDir, 'styles', 'document.css')];
@@ -58,9 +51,7 @@ export function resolveDocumentDesignsCss(projectRoot) {
58
51
  }
59
52
  return { css: '', source: 'designs/', href: null };
60
53
  }
61
- /** @param {string} designsDir */
62
54
  function emitMinimalDesignsCss(designsDir) {
63
- /** @type {Record<string, string>} */
64
55
  const vars = {};
65
56
  const tokenDir = path.join(designsDir, 'tokens');
66
57
  if (fs.existsSync(tokenDir)) {
@@ -94,15 +85,11 @@ function cssVar(key) {
94
85
  .replace(/^-|-$/g, '');
95
86
  return `--${name}`;
96
87
  }
97
- /**
98
- * Style Theme entries (`key.path` + `value`) → `vmz-*` CSS vars (same naming as application compile).
99
- * @param {unknown} obj
100
- * @param {Record<string, string>} out
101
- */
88
+ /** Style Theme entries (`key.path` + `value`) → `vmz-*` CSS vars (same naming as application compile). */
102
89
  function collectStyleThemeEntries(obj, out) {
103
90
  if (obj == null || typeof obj !== 'object' || Array.isArray(obj))
104
91
  return;
105
- const entries = /** @type {{ key?: { path?: unknown }, value?: unknown }[]} */ ( /** @type {{ entries?: unknown }} */(obj).entries);
92
+ const entries = obj.entries;
106
93
  if (!Array.isArray(entries))
107
94
  return;
108
95
  for (const e of entries) {
@@ -1,24 +1,52 @@
1
- /**
2
- * @param {string} routeBase e.g. /docs
3
- * @param {string} locale
4
- * @param {string} pageKey
5
- * @param {{ strategy?: string }} [routing]
6
- */
7
- export declare function pageRoute(routeBase: any, locale: any, pageKey: any, routing?: {}): string;
8
- /**
9
- * Static file path relative to out dir (posix).
10
- * @param {string} routeBase
11
- * @param {string} locale
12
- * @param {string} pageKey
13
- */
14
- export declare function pageHtmlRel(routeBase: any, locale: any, pageKey: any): string;
15
- /**
16
- * @param {import('./document-schema.js').DocumentManifest} manifest
17
- * @param {{ analyzeMarkdown: Function, projectRoot: string, designsCssHref?: string | null }} ctx
18
- */
19
- export declare function enrichDocumentContent(manifest: any, ctx: any): {
20
- byId: Map<any, any>;
21
- navByLocale: {};
22
- diagnostics: any[];
23
- routeBase: any;
24
- };
1
+ import { type DocumentDiagnostic, type DocumentManifest } from './document-schema.js';
2
+ export interface DocumentRoutingStrategy {
3
+ strategy?: string;
4
+ }
5
+ export interface DocumentHeading {
6
+ id: string;
7
+ level: number;
8
+ text: string;
9
+ }
10
+ export interface DocumentLink {
11
+ href?: string;
12
+ }
13
+ export interface AnalyzedMarkdown {
14
+ html: string;
15
+ headings: DocumentHeading[];
16
+ links?: DocumentLink[];
17
+ fences?: Array<{
18
+ info?: string;
19
+ content?: string;
20
+ lineStart?: number;
21
+ lineEnd?: number;
22
+ }>;
23
+ }
24
+ export interface EnrichedPageInfo {
25
+ html: string;
26
+ headings: DocumentHeading[];
27
+ links: DocumentLink[];
28
+ title: string;
29
+ route: string;
30
+ anchors: string[];
31
+ }
32
+ export interface DocumentNavItem {
33
+ pageKey: string;
34
+ title: string;
35
+ href: string;
36
+ }
37
+ export interface EnrichDocumentContentCtx {
38
+ analyzeMarkdown: (source: string) => AnalyzedMarkdown;
39
+ projectRoot: string;
40
+ designsCssHref?: string | null;
41
+ routing?: DocumentRoutingStrategy;
42
+ }
43
+ export interface EnrichDocumentContentResult {
44
+ byId: Map<string, EnrichedPageInfo>;
45
+ navByLocale: Record<string, DocumentNavItem[]>;
46
+ diagnostics: DocumentDiagnostic[];
47
+ routeBase: string;
48
+ }
49
+ export declare function pageRoute(routeBase: string, locale: string, pageKey: string, routing?: DocumentRoutingStrategy): string;
50
+ /** Static file path relative to out dir (posix). */
51
+ export declare function pageHtmlRel(routeBase: string, locale: string, pageKey: string): string;
52
+ export declare function enrichDocumentContent(manifest: DocumentManifest, ctx: EnrichDocumentContentCtx): EnrichDocumentContentResult;