@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,16 +1,9 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Document — enrich manifest with routes, anchors, nav; diagnose links.
4
3
  */
5
4
  import fs from 'node:fs';
6
5
  import path from 'node:path';
7
6
  import { DIAG } from './document-schema.js';
8
- /**
9
- * @param {string} routeBase e.g. /docs
10
- * @param {string} locale
11
- * @param {string} pageKey
12
- * @param {{ strategy?: string }} [routing]
13
- */
14
7
  export function pageRoute(routeBase, locale, pageKey, routing = {}) {
15
8
  const base = String(routeBase || '/').replace(/\/$/, '') || '';
16
9
  const key = pageKey === 'index' ? '' : pageKey.replace(/\\/g, '/');
@@ -22,12 +15,7 @@ export function pageRoute(routeBase, locale, pageKey, routing = {}) {
22
15
  const parts = [base.replace(/^\//, ''), locale, key].filter((p) => p !== '');
23
16
  return '/' + parts.join('/');
24
17
  }
25
- /**
26
- * Static file path relative to out dir (posix).
27
- * @param {string} routeBase
28
- * @param {string} locale
29
- * @param {string} pageKey
30
- */
18
+ /** Static file path relative to out dir (posix). */
31
19
  export function pageHtmlRel(routeBase, locale, pageKey) {
32
20
  const base = String(routeBase || '/')
33
21
  .replace(/^\//, '')
@@ -35,18 +23,11 @@ export function pageHtmlRel(routeBase, locale, pageKey) {
35
23
  const file = pageKey === 'index' ? 'index.html' : `${pageKey.replace(/\\/g, '/')}.html`;
36
24
  return [base, locale, file].filter(Boolean).join('/');
37
25
  }
38
- /**
39
- * @param {import('./document-schema.js').DocumentManifest} manifest
40
- * @param {{ analyzeMarkdown: Function, projectRoot: string, designsCssHref?: string | null }} ctx
41
- */
42
26
  export function enrichDocumentContent(manifest, ctx) {
43
27
  const routeBase = manifest.mounts?.[0]?.routeBase || '/docs';
44
28
  const routing = ctx.routing || { strategy: 'prefix' };
45
- /** @type {Map<string, { html: string, headings: any[], links: any[], title: string, route: string, anchors: string[] }>} */
46
29
  const byId = new Map();
47
- /** @type {import('./document-schema.js').DocumentDiagnostic[]} */
48
30
  const diagnostics = [...(manifest.diagnostics || [])];
49
- /** @type {Map<string, string>} */
50
31
  const routeOwners = new Map();
51
32
  for (const page of manifest.pages) {
52
33
  const abs = path.isAbsolute(page.sourcePath) ? page.sourcePath : path.join(manifest.root, page.sourcePath);
@@ -89,14 +70,13 @@ export function enrichDocumentContent(manifest, ctx) {
89
70
  byId.set(`${page.identity.locale}:${page.identity.pageKey}`, {
90
71
  html: analyzed.html,
91
72
  headings: analyzed.headings,
92
- links: analyzed.links,
73
+ links: analyzed.links || [],
93
74
  title,
94
75
  route,
95
76
  anchors,
96
77
  });
97
78
  }
98
79
  // Nav per locale (directory order: pageKey sorted)
99
- /** @type {Record<string, Array<{ pageKey: string, title: string, href: string }>>} */
100
80
  const navByLocale = {};
101
81
  for (const loc of manifest.locales) {
102
82
  const pages = manifest.pages
@@ -106,7 +86,7 @@ export function enrichDocumentContent(manifest, ctx) {
106
86
  navByLocale[loc] = pages.map((p) => ({
107
87
  pageKey: p.identity.pageKey,
108
88
  title: p.title || p.identity.pageKey,
109
- href: p.route,
89
+ href: p.route || '',
110
90
  }));
111
91
  }
112
92
  // Link checks
@@ -142,7 +122,7 @@ export function enrichDocumentContent(manifest, ctx) {
142
122
  continue;
143
123
  }
144
124
  const resolved = resolveDocHref(href, page.identity.pageKey, page.identity.locale, routeBase, pageKeySet);
145
- if (!resolved.ok) {
125
+ if (resolved.ok === false) {
146
126
  diagnostics.push({
147
127
  code: DIAG.LINK_BROKEN,
148
128
  severity: 'error',
@@ -166,13 +146,6 @@ export function enrichDocumentContent(manifest, ctx) {
166
146
  }
167
147
  return { byId, navByLocale, diagnostics, routeBase };
168
148
  }
169
- /**
170
- * @param {string} href
171
- * @param {string} fromPageKey
172
- * @param {string} locale
173
- * @param {string} routeBase
174
- * @param {Map<string, Set<string>>} pageKeySet
175
- */
176
149
  function resolveDocHref(href, fromPageKey, locale, routeBase, pageKeySet) {
177
150
  let pathPart = href;
178
151
  let anchor = null;
@@ -185,7 +158,6 @@ function resolveDocHref(href, fromPageKey, locale, routeBase, pageKeySet) {
185
158
  if (pathPart.startsWith('/')) {
186
159
  // Absolute site path under mount: /docs/zh-hans/guide/install
187
160
  const want = pathPart.replace(/\/$/, '') || '/';
188
- const prefix = pageRoute(routeBase, locale, 'index').replace(/\/$/, '');
189
161
  // Accept full route or locale-relative
190
162
  for (const [loc, keys] of pageKeySet) {
191
163
  for (const pk of keys) {
@@ -1,49 +1,52 @@
1
- /**
2
- * @param {string} info
3
- * @returns {{ lang: string, run: string | null, source: string | null, playground: boolean }}
4
- */
5
- export declare function parseFenceInfo(info: any): {
1
+ import { type DocumentDiagnostic, type DocumentEvidence, type DocumentManifest } from './document-schema.js';
2
+ import type { AnalyzedMarkdown } from './document-enrich.js';
3
+ export interface FenceInfoMeta {
6
4
  lang: string;
7
- run: any;
8
- source: any;
5
+ run: string | null;
6
+ source: string | null;
9
7
  playground: boolean;
8
+ }
9
+ export declare function parseFenceInfo(info: string | undefined | null): FenceInfoMeta;
10
+ /** Symbol query (chunkId or name). */
11
+ export declare function parseApiHref(href: string | undefined | null): string | null;
12
+ export interface ProgramApiIndexRow {
13
+ chunkId: string;
14
+ name: string;
15
+ path: string;
16
+ capabilities: string[];
17
+ programPath: string;
18
+ }
19
+ export declare function loadProgramApiIndex(projectRoot: string): ProgramApiIndexRow[];
20
+ /** Resolve API symbol against Program Graph index. */
21
+ export declare function resolveApiSymbol(index: ProgramApiIndexRow[], query: string): {
22
+ status: 'ok' | 'missing' | 'ambiguous';
23
+ matches: ProgramApiIndexRow[];
10
24
  };
11
- /**
12
- * @param {string} href
13
- * @returns {string | null} symbol query (chunkId or name)
14
- */
15
- export declare function parseApiHref(href: any): string;
16
- /**
17
- * @param {string} projectRoot
18
- * @returns {Array<{ chunkId: string, name: string, path: string, capabilities: string[], programPath: string }>}
19
- */
20
- export declare function loadProgramApiIndex(projectRoot: any): any[];
21
- /**
22
- * Resolve API symbol against Program Graph index.
23
- * @param {ReturnType<typeof loadProgramApiIndex>} index
24
- * @param {string} query
25
- */
26
- export declare function resolveApiSymbol(index: any, query: any): {
27
- status: string;
28
- matches: any;
29
- };
30
- /**
31
- * @param {import('./document-schema.js').DocumentManifest} manifest
32
- * @param {{
33
- * analyzeMarkdown: Function,
34
- * projectRoot: string,
35
- * createWorkspace?: Function,
36
- * ensureProgramGraph?: boolean,
37
- * }} ctx
38
- */
39
- export declare function enrichDocumentEvidence(manifest: any, ctx: any): Promise<{
40
- diagnostics: any[];
41
- evidence: {
42
- schema: string;
43
- fences: any[];
44
- apiRefs: any[];
45
- testSelections: any[];
46
- status: string;
25
+ export interface EnrichDocumentEvidenceCtx {
26
+ analyzeMarkdown: (source: string) => AnalyzedMarkdown;
27
+ projectRoot: string;
28
+ createWorkspace?: (opts: {
29
+ root: string;
30
+ outDir: string;
31
+ }) => {
32
+ check: (strict?: boolean) => {
33
+ diagnostics?: Array<{
34
+ severity?: string;
35
+ message?: string;
36
+ }>;
37
+ };
38
+ build: (strict?: boolean) => {
39
+ diagnostics?: Array<{
40
+ severity?: string;
41
+ message?: string;
42
+ }>;
43
+ };
44
+ dispose?: () => void;
47
45
  };
46
+ ensureProgramGraph?: boolean;
47
+ }
48
+ export declare function enrichDocumentEvidence(manifest: DocumentManifest, ctx: EnrichDocumentEvidenceCtx): Promise<{
49
+ diagnostics: DocumentDiagnostic[];
50
+ evidence: DocumentEvidence;
48
51
  }>;
49
52
  /** Lazy note: callers pass `createWorkspace` from `./index.js` (see document-cmd / document-build). */
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Document Evidence — fence check + API refs from Program Graph.
4
3
  *
@@ -8,21 +7,15 @@ import { createRequire } from 'node:module';
8
7
  import fs from 'node:fs';
9
8
  import os from 'node:os';
10
9
  import path from 'node:path';
11
- import { DIAG, DOCUMENT_EVIDENCE_SCHEMA } from './document-schema.js';
10
+ import { DIAG, DOCUMENT_EVIDENCE_SCHEMA, } from './document-schema.js';
12
11
  const require = createRequire(import.meta.url);
13
- /**
14
- * @param {string} info
15
- * @returns {{ lang: string, run: string | null, source: string | null, playground: boolean }}
16
- */
17
12
  export function parseFenceInfo(info) {
18
13
  const parts = String(info || '')
19
14
  .trim()
20
15
  .split(/\s+/)
21
16
  .filter(Boolean);
22
17
  const lang = (parts[0] || '').toLowerCase();
23
- /** @type {string | null} */
24
18
  let run = null;
25
- /** @type {string | null} */
26
19
  let source = null;
27
20
  let playground = false;
28
21
  for (const p of parts.slice(1)) {
@@ -37,10 +30,7 @@ export function parseFenceInfo(info) {
37
30
  }
38
31
  return { lang, run, source, playground };
39
32
  }
40
- /**
41
- * @param {string} href
42
- * @returns {string | null} symbol query (chunkId or name)
43
- */
33
+ /** Symbol query (chunkId or name). */
44
34
  export function parseApiHref(href) {
45
35
  const h = String(href || '').trim();
46
36
  if (h.startsWith('vmz-api:'))
@@ -49,13 +39,8 @@ export function parseApiHref(href) {
49
39
  return h.slice('api:'.length).replace(/^\/+/, '');
50
40
  return null;
51
41
  }
52
- /**
53
- * @param {string} projectRoot
54
- * @returns {Array<{ chunkId: string, name: string, path: string, capabilities: string[], programPath: string }>}
55
- */
56
42
  export function loadProgramApiIndex(projectRoot) {
57
43
  const outDir = path.join(projectRoot, 'dist');
58
- /** @type {Array<{ chunkId: string, name: string, path: string, capabilities: string[], programPath: string }>} */
59
44
  const rows = [];
60
45
  if (!fs.existsSync(outDir))
61
46
  return rows;
@@ -92,11 +77,7 @@ export function loadProgramApiIndex(projectRoot) {
92
77
  });
93
78
  return rows;
94
79
  }
95
- /**
96
- * Resolve API symbol against Program Graph index.
97
- * @param {ReturnType<typeof loadProgramApiIndex>} index
98
- * @param {string} query
99
- */
80
+ /** Resolve API symbol against Program Graph index. */
100
81
  export function resolveApiSymbol(index, query) {
101
82
  const q = String(query || '').trim();
102
83
  if (!q)
@@ -113,27 +94,13 @@ export function resolveApiSymbol(index, query) {
113
94
  return { status: 'ambiguous', matches: loose };
114
95
  return { status: 'missing', matches: [] };
115
96
  }
116
- /**
117
- * @param {import('./document-schema.js').DocumentManifest} manifest
118
- * @param {{
119
- * analyzeMarkdown: Function,
120
- * projectRoot: string,
121
- * createWorkspace?: Function,
122
- * ensureProgramGraph?: boolean,
123
- * }} ctx
124
- */
125
97
  export async function enrichDocumentEvidence(manifest, ctx) {
126
98
  const projectRoot = path.resolve(ctx.projectRoot || manifest.root);
127
- /** @type {import('./document-schema.js').DocumentDiagnostic[]} */
128
99
  const diagnostics = [...(manifest.diagnostics || [])];
129
- /** @type {any[]} */
130
100
  const fenceRecords = [];
131
- /** @type {any[]} */
132
101
  const apiRefs = [];
133
- /** @type {any[]} */
134
102
  const testSelections = [];
135
103
  // Collect fences + api links from pages.
136
- /** @type {Array<{ page: any, fences: any[], apiQueries: string[], sourcePath: string }>} */
137
104
  const pages = [];
138
105
  for (const page of manifest.pages) {
139
106
  const abs = path.isAbsolute(page.sourcePath) ? page.sourcePath : path.join(manifest.root, page.sourcePath);
@@ -157,7 +124,7 @@ export async function enrichDocumentEvidence(manifest, ctx) {
157
124
  diagnostics.push({
158
125
  code: DIAG.FENCE_CHECK,
159
126
  severity: 'error',
160
- message: `project build for evidence failed: ${e.message || e}`,
127
+ message: `project build for evidence failed: ${e instanceof Error ? e.message : String(e)}`,
161
128
  path: projectRoot,
162
129
  });
163
130
  }
@@ -268,11 +235,7 @@ export async function enrichDocumentEvidence(manifest, ctx) {
268
235
  };
269
236
  return { diagnostics, evidence };
270
237
  }
271
- /**
272
- * @param {{ projectRoot: string, fence: any, meta: any, createWorkspace?: Function, sourcePath: string }} opts
273
- */
274
238
  async function checkVmzFence(opts) {
275
- /** @type {import('./document-schema.js').DocumentDiagnostic[]} */
276
239
  const diagnostics = [];
277
240
  const { fence, meta, projectRoot, sourcePath } = opts;
278
241
  let body = fence.content;
@@ -326,7 +289,6 @@ async function checkVmzFence(opts) {
326
289
  ws.dispose?.();
327
290
  return { record: { status: 'failed', detail: 'check' }, diagnostics, testSelection: null };
328
291
  }
329
- /** @type {any} */
330
292
  let testSelection = null;
331
293
  if (meta.run) {
332
294
  const mode = meta.run === 'logic' || meta.run === 'browser' ? meta.run : 'compile';
@@ -385,11 +347,8 @@ function wrapVmzFragment(body) {
385
347
  function pageKeySafe(p) {
386
348
  return String(p || 'page').replace(/[^\w.-]+/g, '_');
387
349
  }
388
- /**
389
- * TS/JS fence: oxc-aligned surface via TypeScript parse (syntax only; no execute).
390
- */
391
- function checkScriptFence({ fence, meta, sourcePath, page }) {
392
- /** @type {import('./document-schema.js').DocumentDiagnostic[]} */
350
+ /** TS/JS fence: oxc-aligned surface via TypeScript parse (syntax only; no execute). */
351
+ function checkScriptFence({ fence, meta, sourcePath, }) {
393
352
  const diagnostics = [];
394
353
  try {
395
354
  const ts = require('typescript');
@@ -2,33 +2,17 @@
2
2
  * Integrated DocumentMount — build /documents into the host app dist so
3
3
  * routeBase (e.g. /d) is served as static HTML next to SSR pages.
4
4
  */
5
- /**
6
- * @param {string} projectRoot
7
- */
8
- export declare function projectHasDocuments(projectRoot: any): boolean;
9
- /**
10
- * Build integrated documents into the application outDir (URL-aligned).
11
- * @param {{ projectRoot: string, outDir: string, strict?: boolean }} opts
12
- * @returns {Promise<{ ok: boolean, skipped?: boolean, pages?: number, error?: string }>}
13
- */
14
- export declare function buildIntegratedDocuments(opts: any): Promise<{
15
- ok: boolean;
16
- skipped: boolean;
17
- error?: undefined;
18
- pages?: undefined;
19
- } | {
20
- ok: boolean;
21
- error: string;
22
- pages: number;
23
- skipped?: undefined;
24
- } | {
25
- ok: boolean;
26
- pages: number;
27
- skipped?: undefined;
28
- error?: undefined;
29
- } | {
5
+ export declare function projectHasDocuments(projectRoot: string): boolean;
6
+ export interface BuildIntegratedDocumentsOpts {
7
+ projectRoot: string;
8
+ outDir: string;
9
+ strict?: boolean;
10
+ }
11
+ export interface BuildIntegratedDocumentsResult {
30
12
  ok: boolean;
31
- error: string;
32
- skipped?: undefined;
33
- pages?: undefined;
34
- }>;
13
+ skipped?: boolean;
14
+ pages?: number;
15
+ error?: string;
16
+ }
17
+ /** Build integrated documents into the application outDir (URL-aligned). */
18
+ export declare function buildIntegratedDocuments(opts: BuildIntegratedDocumentsOpts): Promise<BuildIntegratedDocumentsResult>;
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Integrated DocumentMount — build /documents into the host app dist so
4
3
  * routeBase (e.g. /d) is served as static HTML next to SSR pages.
@@ -7,22 +6,15 @@ import fs from 'node:fs';
7
6
  import path from 'node:path';
8
7
  import { buildDocuments } from './document-build.js';
9
8
  import { resolveDocumentsRoot } from './document-check.js';
10
- import { loadLocalesRouting } from './document-routing-config.js';
11
9
  import { pageHtmlRel } from './document-enrich.js';
10
+ import { loadLocalesRouting } from './document-routing-config.js';
12
11
  import { log } from './log.js';
13
12
  import { requireNativeAddon } from './native-addon.js';
14
- /**
15
- * @param {string} projectRoot
16
- */
17
13
  export function projectHasDocuments(projectRoot) {
18
14
  const root = resolveDocumentsRoot(projectRoot);
19
15
  return fs.existsSync(root) && fs.statSync(root).isDirectory();
20
16
  }
21
- /**
22
- * Build integrated documents into the application outDir (URL-aligned).
23
- * @param {{ projectRoot: string, outDir: string, strict?: boolean }} opts
24
- * @returns {Promise<{ ok: boolean, skipped?: boolean, pages?: number, error?: string }>}
25
- */
17
+ /** Build integrated documents into the application outDir (URL-aligned). */
26
18
  export async function buildIntegratedDocuments(opts) {
27
19
  const projectRoot = path.resolve(opts.projectRoot);
28
20
  const outDir = path.resolve(opts.outDir);
@@ -57,9 +49,6 @@ export async function buildIntegratedDocuments(opts) {
57
49
  * Emit `{routeBase}/index.html` for integrated mounts.
58
50
  * `routing.strategy: none` → copy default-locale docs index (LocaleId is Host state).
59
51
  * prefix strategy → redirect HTML to `{routeBase}/{defaultLocale}/`.
60
- * @param {import('./document-schema.js').DocumentManifest} manifest
61
- * @param {string} outDir
62
- * @param {string} projectRoot
63
52
  */
64
53
  function writeMountRootRedirects(manifest, outDir, projectRoot) {
65
54
  const defaultLocale = manifest.defaultLocale || manifest.locales?.[0];
@@ -1,69 +1,47 @@
1
- /**
2
- * Strip tags / collapse whitespace for search body text.
3
- * @param {string} html
4
- */
5
- export declare function htmlToSearchText(html: any): string;
6
- /**
7
- * @param {{
8
- * manifest: any,
9
- * enriched: { byId: Map<string, any> },
10
- * evidence: any,
11
- * version?: string | null,
12
- * }} opts
13
- */
14
- export declare function buildDocumentSearch(opts: any): {
15
- schema: string;
16
- status: string;
17
- version: any;
18
- records: any[];
19
- };
20
- /**
21
- * Island-only resume plan for document surfaces.
22
- * @param {{
23
- * evidence: any,
24
- * searchHref?: string,
25
- * fenceBodies?: Map<string, string>,
26
- * }} opts
27
- */
28
- export declare function buildDocumentIslands(opts: any): {
29
- schema: string;
30
- hydrate: string;
31
- fullPageHydrate: boolean;
32
- islands: {
33
- name: string;
34
- kind: string;
35
- resume: string;
36
- index: any;
37
- }[];
38
- status: string;
39
- };
40
- /**
41
- * Relative href from an HTML page to a root artifact (posix).
42
- * @param {string} htmlRel
43
- * @param {string} artifactName
44
- */
45
- export declare function artifactHrefFromHtml(htmlRel: any, artifactName: any): string;
46
- /**
47
- * Stable map key for fence body lookup.
48
- * @param {{ locale: string, pageKey: string, lineStart: number }} f
49
- */
50
- export declare function fenceBodyKey(f: any): string;
51
- /**
52
- * Collect fence bodies from analyzeMarkdown results for playground islands.
53
- * @param {Map<string, { fences?: any[] }>} analyzedByPageId locale:pageKey → analyze result
54
- * @param {any[]} pages manifest.pages
55
- */
56
- export declare function collectFenceBodies(analyzedByPageId: any, pages: any): Map<any, any>;
57
- /**
58
- * Render SSR island shells (no script — resume later).
59
- * @param {{
60
- * islands: any,
61
- * searchIndexHref: string,
62
- * pageKey: string,
63
- * locale: string,
64
- * }} opts
65
- */
66
- export declare function renderIslandShellsHtml(opts: any): {
1
+ import type { EnrichDocumentContentResult } from './document-enrich.js';
2
+ import { type DocumentEvidence, type DocumentIslandsPlan, type DocumentManifest, type DocumentSearchIndex, type PageRecord } from './document-schema.js';
3
+ /** Strip tags / collapse whitespace for search body text. */
4
+ export declare function htmlToSearchText(html: string): string;
5
+ export interface BuildDocumentSearchOpts {
6
+ manifest: DocumentManifest;
7
+ enriched: Pick<EnrichDocumentContentResult, 'byId'>;
8
+ evidence: DocumentEvidence;
9
+ version?: string | null;
10
+ }
11
+ export declare function buildDocumentSearch(opts: BuildDocumentSearchOpts): DocumentSearchIndex;
12
+ export interface BuildDocumentIslandsOpts {
13
+ evidence: DocumentEvidence;
14
+ searchHref?: string;
15
+ fenceBodies?: Map<string, string>;
16
+ }
17
+ /** Island-only resume plan for document surfaces. */
18
+ export declare function buildDocumentIslands(opts: BuildDocumentIslandsOpts): DocumentIslandsPlan;
19
+ /** Relative href from an HTML page to a root artifact (posix). */
20
+ export declare function artifactHrefFromHtml(htmlRel: string, artifactName: string): string;
21
+ /** Stable map key for fence body lookup. */
22
+ export declare function fenceBodyKey(f: {
23
+ locale: string;
24
+ pageKey: string;
25
+ lineStart: number;
26
+ }): string;
27
+ export interface AnalyzedFence {
28
+ info?: string;
29
+ content?: string;
30
+ lineStart?: number;
31
+ lineEnd?: number;
32
+ }
33
+ /** Collect fence bodies from analyzeMarkdown results for playground islands. */
34
+ export declare function collectFenceBodies(analyzedByPageId: Map<string, {
35
+ fences?: AnalyzedFence[];
36
+ }>, pages: PageRecord[]): Map<string, string>;
37
+ export interface RenderIslandShellsOpts {
38
+ islands: DocumentIslandsPlan;
39
+ searchIndexHref: string;
40
+ pageKey: string;
41
+ locale: string;
42
+ }
43
+ /** Render SSR island shells (no script — resume later). */
44
+ export declare function renderIslandShellsHtml(opts: RenderIslandShellsOpts): {
67
45
  searchHtml: string;
68
- playgroundHtml: any;
46
+ playgroundHtml: string;
69
47
  };
@@ -1,16 +1,12 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Document Interactive — search index + Island-only resume plan.
4
3
  *
5
4
  * Not a Doc IR: build artifacts + ResumeEntry-shaped island hosts.
6
5
  * Static HTML stays no-JS readable; islands resume later, never full-page hydrate.
7
6
  */
8
- import { DOCUMENT_ISLANDS_SCHEMA, DOCUMENT_SEARCH_SCHEMA } from './document-schema.js';
9
7
  import { parseFenceInfo } from './document-evidence.js';
10
- /**
11
- * Strip tags / collapse whitespace for search body text.
12
- * @param {string} html
13
- */
8
+ import { DOCUMENT_ISLANDS_SCHEMA, DOCUMENT_SEARCH_SCHEMA, } from './document-schema.js';
9
+ /** Strip tags / collapse whitespace for search body text. */
14
10
  export function htmlToSearchText(html) {
15
11
  return String(html || '')
16
12
  .replace(/<script[\s\S]*?<\/script>/gi, ' ')
@@ -24,18 +20,9 @@ export function htmlToSearchText(html) {
24
20
  .replace(/\s+/g, ' ')
25
21
  .trim();
26
22
  }
27
- /**
28
- * @param {{
29
- * manifest: any,
30
- * enriched: { byId: Map<string, any> },
31
- * evidence: any,
32
- * version?: string | null,
33
- * }} opts
34
- */
35
23
  export function buildDocumentSearch(opts) {
36
24
  const { manifest, enriched, evidence } = opts;
37
25
  const version = opts.version ?? null;
38
- /** @type {any[]} */
39
26
  const records = [];
40
27
  for (const page of manifest.pages || []) {
41
28
  const id = `${page.identity.locale}:${page.identity.pageKey}`;
@@ -55,7 +42,7 @@ export function buildDocumentSearch(opts) {
55
42
  const apiSymbolIds = (evidence?.apiRefs || [])
56
43
  .filter((r) => r.locale === locale && r.pageKey === pageKey && r.status === 'ok')
57
44
  .flatMap((r) => (r.matches || []).map((m) => m.chunkId || m.name))
58
- .filter(Boolean);
45
+ .filter((x) => Boolean(x));
59
46
  records.push({
60
47
  kind: 'page',
61
48
  id: `page:${locale}:${pageKey}`,
@@ -110,17 +97,9 @@ export function buildDocumentSearch(opts) {
110
97
  records,
111
98
  };
112
99
  }
113
- /**
114
- * Island-only resume plan for document surfaces.
115
- * @param {{
116
- * evidence: any,
117
- * searchHref?: string,
118
- * fenceBodies?: Map<string, string>,
119
- * }} opts
120
- */
100
+ /** Island-only resume plan for document surfaces. */
121
101
  export function buildDocumentIslands(opts) {
122
102
  const searchHref = opts.searchHref || 'document.search.json';
123
- /** @type {any[]} */
124
103
  const islands = [
125
104
  {
126
105
  name: 'DocumentSearch',
@@ -169,30 +148,18 @@ export function buildDocumentIslands(opts) {
169
148
  status: 'ready',
170
149
  };
171
150
  }
172
- /**
173
- * Relative href from an HTML page to a root artifact (posix).
174
- * @param {string} htmlRel
175
- * @param {string} artifactName
176
- */
151
+ /** Relative href from an HTML page to a root artifact (posix). */
177
152
  export function artifactHrefFromHtml(htmlRel, artifactName) {
178
153
  const depth = String(htmlRel).replace(/\\/g, '/').split('/').length - 1;
179
154
  const prefix = depth > 0 ? '../'.repeat(depth) : './';
180
155
  return prefix + artifactName;
181
156
  }
182
- /**
183
- * Stable map key for fence body lookup.
184
- * @param {{ locale: string, pageKey: string, lineStart: number }} f
185
- */
157
+ /** Stable map key for fence body lookup. */
186
158
  export function fenceBodyKey(f) {
187
159
  return `${f.locale}:${f.pageKey}:${f.lineStart}`;
188
160
  }
189
- /**
190
- * Collect fence bodies from analyzeMarkdown results for playground islands.
191
- * @param {Map<string, { fences?: any[] }>} analyzedByPageId locale:pageKey → analyze result
192
- * @param {any[]} pages manifest.pages
193
- */
161
+ /** Collect fence bodies from analyzeMarkdown results for playground islands. */
194
162
  export function collectFenceBodies(analyzedByPageId, pages) {
195
- /** @type {Map<string, string>} */
196
163
  const out = new Map();
197
164
  for (const page of pages || []) {
198
165
  const id = `${page.identity.locale}:${page.identity.pageKey}`;
@@ -206,21 +173,13 @@ export function collectFenceBodies(analyzedByPageId, pages) {
206
173
  out.set(fenceBodyKey({
207
174
  locale: page.identity.locale,
208
175
  pageKey: page.identity.pageKey,
209
- lineStart: fence.lineStart,
176
+ lineStart: fence.lineStart ?? 0,
210
177
  }), String(fence.content || '').trim());
211
178
  }
212
179
  }
213
180
  return out;
214
181
  }
215
- /**
216
- * Render SSR island shells (no script — resume later).
217
- * @param {{
218
- * islands: any,
219
- * searchIndexHref: string,
220
- * pageKey: string,
221
- * locale: string,
222
- * }} opts
223
- */
182
+ /** Render SSR island shells (no script — resume later). */
224
183
  export function renderIslandShellsHtml(opts) {
225
184
  const esc = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
226
185
  const search = `