@vmz/vmz 0.1.17 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application-cmd.d.ts +6 -16
- package/dist/application-cmd.js +34 -180
- package/dist/author-input.d.ts +40 -19
- package/dist/author-input.js +2 -16
- package/dist/build-assemble.d.ts +63 -41
- package/dist/build-assemble.js +42 -43
- package/dist/bundler-adapter.d.ts +46 -48
- package/dist/bundler-adapter.js +4 -43
- package/dist/cdn-policy.d.ts +77 -93
- package/dist/cdn-policy.js +10 -16
- package/dist/cli-localize.d.ts +34 -0
- package/dist/cli-localize.js +58 -0
- package/dist/cli.d.ts +8 -19
- package/dist/cli.js +69 -252
- package/dist/content-addressed-assets.d.ts +24 -10
- package/dist/content-addressed-assets.js +2 -7
- package/dist/delivery-profile.d.ts +54 -27
- package/dist/delivery-profile.js +15 -13
- package/dist/dev-session.d.ts +29 -23
- package/dist/dev-session.js +0 -21
- package/dist/dev-watch-roots.d.ts +34 -25
- package/dist/dev-watch-roots.js +0 -31
- package/dist/document-build.d.ts +22 -97
- package/dist/document-build.js +4 -19
- package/dist/document-check.d.ts +30 -53
- package/dist/document-check.js +14 -29
- package/dist/document-cmd.d.ts +3 -6
- package/dist/document-cmd.js +19 -79
- package/dist/document-designs.d.ts +5 -8
- package/dist/document-designs.js +2 -15
- package/dist/document-enrich.d.ts +52 -24
- package/dist/document-enrich.js +4 -32
- package/dist/document-evidence.d.ts +46 -43
- package/dist/document-evidence.js +6 -47
- package/dist/document-integrate.d.ts +13 -29
- package/dist/document-integrate.js +2 -13
- package/dist/document-interactive.d.ts +45 -67
- package/dist/document-interactive.js +9 -50
- package/dist/document-layout-render.d.ts +7 -16
- package/dist/document-layout-render.js +0 -17
- package/dist/document-locale.d.ts +12 -25
- package/dist/document-locale.js +3 -14
- package/dist/document-markdown.d.ts +9 -5
- package/dist/document-markdown.js +0 -4
- package/dist/document-routing-config.d.ts +7 -14
- package/dist/document-routing-config.js +0 -9
- package/dist/document-scan.d.ts +14 -18
- package/dist/document-scan.js +2 -23
- package/dist/document-schema.d.ts +154 -41
- package/dist/document-schema.js +0 -35
- package/dist/embedded-packaging.d.ts +20 -8
- package/dist/embedded-packaging.js +0 -1
- package/dist/explain-cmd.d.ts +4 -3
- package/dist/explain-cmd.js +16 -65
- package/dist/index.d.ts +70 -143
- package/dist/index.js +16 -136
- package/dist/invocation.d.ts +29 -50
- package/dist/invocation.js +11 -57
- package/dist/locale-check.d.ts +69 -70
- package/dist/locale-check.js +5 -66
- package/dist/locale-cmd.d.ts +2 -5
- package/dist/locale-cmd.js +62 -142
- package/dist/locale-delivery.d.ts +294 -191
- package/dist/locale-delivery.js +8 -94
- package/dist/locale-route-emit.d.ts +23 -9
- package/dist/locale-route-emit.js +0 -7
- package/dist/locale-router.d.ts +189 -162
- package/dist/locale-router.js +13 -122
- package/dist/locale-runtime.d.ts +292 -262
- package/dist/locale-runtime.js +8 -102
- package/dist/locale-schema.js +0 -1
- package/dist/locale-tooling.d.ts +100 -63
- package/dist/locale-tooling.js +7 -45
- package/dist/log.d.ts +22 -15
- package/dist/log.js +24 -21
- package/dist/native-addon.d.ts +10 -9
- package/dist/native-addon.js +1 -10
- package/dist/pack-client-packages.d.ts +5 -1
- package/dist/pack-client-packages.js +0 -6
- package/dist/pack.d.ts +17 -15
- package/dist/pack.js +0 -12
- package/dist/packages.d.ts +10 -23
- package/dist/packages.js +1 -37
- package/dist/plan-cmd.d.ts +6 -0
- package/dist/plan-cmd.js +35 -0
- package/dist/plugin-host.js +0 -1
- package/dist/port.d.ts +2 -10
- package/dist/port.js +2 -11
- package/dist/pretty-json.d.ts +9 -19
- package/dist/pretty-json.js +3 -17
- package/dist/production-observability.d.ts +37 -181
- package/dist/production-observability.js +1 -9
- package/dist/production-test-pack.d.ts +17 -3
- package/dist/production-test-pack.js +0 -2
- package/dist/public-static-assets.d.ts +6 -1
- package/dist/public-static-assets.js +0 -5
- package/dist/refactor-cmd.d.ts +3 -6
- package/dist/refactor-cmd.js +16 -69
- package/dist/release-cmd.d.ts +7 -6
- package/dist/release-cmd.js +17 -59
- package/dist/release-pack.d.ts +7 -3
- package/dist/release-pack.js +0 -6
- package/dist/resolve.d.ts +15 -19
- package/dist/resolve.js +1 -15
- package/dist/server-artifact.d.ts +30 -75
- package/dist/server-artifact.js +0 -10
- package/dist/server-language-backend.d.ts +22 -79
- package/dist/server-language-backend.js +0 -26
- package/dist/site-delivery.d.ts +46 -59
- package/dist/site-delivery.js +3 -8
- package/dist/site-favicon.d.ts +6 -1
- package/dist/site-favicon.js +0 -5
- package/dist/static-emit.d.ts +73 -103
- package/dist/static-emit.js +1 -26
- package/dist/test-cmd.d.ts +3 -5
- package/dist/test-cmd.js +46 -30
- package/dist/test-compile.js +0 -1
- package/dist/test-discover.js +0 -1
- package/dist/test-logic.js +0 -1
- package/dist/test-protocol.js +0 -1
- package/dist/toolchain-dx.d.ts +11 -0
- package/dist/toolchain-dx.js +10 -0
- package/dist/watch-diff.d.ts +4 -13
- package/dist/watch-diff.js +0 -17
- package/dist/wechat-packaging.d.ts +8 -7
- package/dist/wechat-packaging.js +0 -6
- package/locales/en-US/cli.json +105 -0
- package/locales/locales.json +4 -0
- package/package.json +15 -12
- package/dist/resolve-native-cli.d.ts +0 -14
- package/dist/resolve-native-cli.js +0 -84
package/dist/document-enrich.js
CHANGED
|
@@ -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 (
|
|
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
|
-
|
|
3
|
-
|
|
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:
|
|
8
|
-
source:
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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:
|
|
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
|
-
|
|
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, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
226
185
|
const search = `
|