@vmz/vmz 0.0.0 → 0.0.2
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/README.md +48 -2
- package/bin/vmz.js +4 -0
- package/dist/application-cmd.d.ts +22 -0
- package/dist/application-cmd.js +348 -0
- package/dist/bundler-adapter.d.ts +64 -0
- package/dist/bundler-adapter.js +111 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.js +370 -0
- package/dist/dev-session.d.ts +35 -0
- package/dist/dev-session.js +290 -0
- package/dist/document-build.d.ts +99 -0
- package/dist/document-build.js +274 -0
- package/dist/document-check.d.ts +44 -0
- package/dist/document-check.js +246 -0
- package/dist/document-cmd.d.ts +9 -0
- package/dist/document-cmd.js +147 -0
- package/dist/document-designs.d.ts +9 -0
- package/dist/document-designs.js +126 -0
- package/dist/document-enrich.d.ts +23 -0
- package/dist/document-enrich.js +234 -0
- package/dist/document-evidence.d.ts +49 -0
- package/dist/document-evidence.js +501 -0
- package/dist/document-integrate.d.ts +35 -0
- package/dist/document-integrate.js +89 -0
- package/dist/document-interactive.d.ts +69 -0
- package/dist/document-interactive.js +255 -0
- package/dist/document-locale.d.ts +31 -0
- package/dist/document-locale.js +59 -0
- package/dist/document-markdown.d.ts +13 -0
- package/dist/document-markdown.js +39 -0
- package/dist/document-scan.d.ts +21 -0
- package/dist/document-scan.js +151 -0
- package/dist/document-schema.d.ts +87 -0
- package/dist/document-schema.js +88 -0
- package/dist/explain-cmd.d.ts +5 -0
- package/dist/explain-cmd.js +123 -0
- package/dist/index.d.ts +808 -0
- package/dist/index.js +569 -0
- package/dist/locale-check.d.ts +106 -0
- package/dist/locale-check.js +737 -0
- package/dist/locale-cmd.d.ts +5 -0
- package/dist/locale-cmd.js +443 -0
- package/dist/locale-delivery.d.ts +298 -0
- package/dist/locale-delivery.js +444 -0
- package/dist/locale-router.d.ts +207 -0
- package/dist/locale-router.js +508 -0
- package/dist/locale-runtime.d.ts +406 -0
- package/dist/locale-runtime.js +542 -0
- package/dist/locale-schema.d.ts +9 -0
- package/dist/locale-schema.js +10 -0
- package/dist/locale-tooling.d.ts +118 -0
- package/dist/locale-tooling.js +358 -0
- package/dist/log.d.ts +19 -0
- package/dist/log.js +42 -0
- package/dist/packages.d.ts +27 -0
- package/dist/packages.js +147 -0
- package/dist/plugin-host.d.ts +30 -0
- package/dist/plugin-host.js +370 -0
- package/dist/refactor-cmd.d.ts +8 -0
- package/dist/refactor-cmd.js +156 -0
- package/dist/resolve.d.ts +25 -0
- package/dist/resolve.js +56 -0
- package/dist/test-cmd.d.ts +9 -0
- package/dist/test-cmd.js +343 -0
- package/dist/test-compile.d.ts +2 -0
- package/dist/test-compile.js +3 -0
- package/dist/test-discover.d.ts +2 -0
- package/dist/test-discover.js +3 -0
- package/dist/test-logic.d.ts +2 -0
- package/dist/test-logic.js +3 -0
- package/dist/test-protocol.d.ts +2 -0
- package/dist/test-protocol.js +3 -0
- package/dist/watch-diff.d.ts +17 -0
- package/dist/watch-diff.js +56 -0
- package/package.json +86 -4
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Document D0 Contract — schema constants & diagnostic codes.
|
|
4
|
+
* Design: 规划设计/vmz/19 §2.3 · D0
|
|
5
|
+
*
|
|
6
|
+
* Not a Doc IR: this is a filesystem/manifest projection only.
|
|
7
|
+
*/
|
|
8
|
+
/** @typedef {{ pageKey: string, locale: string }} PageIdentity */
|
|
9
|
+
/** @typedef {{
|
|
10
|
+
* identity: PageIdentity,
|
|
11
|
+
* sourcePath: string,
|
|
12
|
+
* route?: string | null,
|
|
13
|
+
* anchors?: string[],
|
|
14
|
+
* }} PageRecord */
|
|
15
|
+
/** @typedef {{
|
|
16
|
+
* id: string,
|
|
17
|
+
* sourceRoot: string,
|
|
18
|
+
* pageKeys: string[],
|
|
19
|
+
* }} DocumentCollection */
|
|
20
|
+
/** @typedef {{
|
|
21
|
+
* collectionId: string,
|
|
22
|
+
* routeBase: string,
|
|
23
|
+
* mode: 'integrated' | 'standalone',
|
|
24
|
+
* }} DocumentMount */
|
|
25
|
+
/** @typedef {{
|
|
26
|
+
* code: string,
|
|
27
|
+
* severity: 'error' | 'warning',
|
|
28
|
+
* message: string,
|
|
29
|
+
* path?: string,
|
|
30
|
+
* }} DocumentDiagnostic */
|
|
31
|
+
/** @typedef {{
|
|
32
|
+
* schema: typeof DOCUMENT_MANIFEST_SCHEMA,
|
|
33
|
+
* root: string,
|
|
34
|
+
* defaultLocale: string | null,
|
|
35
|
+
* locales: string[],
|
|
36
|
+
* localeLabels: Record<string, string>,
|
|
37
|
+
* collections: DocumentCollection[],
|
|
38
|
+
* mounts: DocumentMount[],
|
|
39
|
+
* pages: PageRecord[],
|
|
40
|
+
* diagnostics: DocumentDiagnostic[],
|
|
41
|
+
* }} DocumentManifest */
|
|
42
|
+
export const DOCUMENT_MANIFEST_SCHEMA = 'vmz.document.manifest.v0';
|
|
43
|
+
/** Static page view fragment (D1) — not a Doc IR. */
|
|
44
|
+
export const DOCUMENT_VIEW_SCHEMA = 'vmz.document.view.v0';
|
|
45
|
+
/** D2 evidence projection (fences + API refs) — not a Doc IR. */
|
|
46
|
+
export const DOCUMENT_EVIDENCE_SCHEMA = 'vmz.document.evidence.v0';
|
|
47
|
+
/** D3 search index (SearchRecord[]) — not a Doc IR. */
|
|
48
|
+
export const DOCUMENT_SEARCH_SCHEMA = 'vmz.document.search.v0';
|
|
49
|
+
/** D3 island-only resume plan for search/playground — not a Doc IR. */
|
|
50
|
+
export const DOCUMENT_ISLANDS_SCHEMA = 'vmz.document.islands.v0';
|
|
51
|
+
/** Top-level non-locale reserved names under /documents */
|
|
52
|
+
export const DOCUMENT_RESERVED_TOP = new Set(['package.json', 'documents.config.ts', 'documents.config.json', 'documents.config.js', 'public']);
|
|
53
|
+
/** Known locale aliases → canonical key (lowercase, hyphen). */
|
|
54
|
+
export const LOCALE_ALIASES = {
|
|
55
|
+
'zh-cn': 'zh-hans',
|
|
56
|
+
'zh-sg': 'zh-hans',
|
|
57
|
+
'zh-tw': 'zh-hant',
|
|
58
|
+
'zh-hk': 'zh-hant',
|
|
59
|
+
'zh-mo': 'zh-hant',
|
|
60
|
+
};
|
|
61
|
+
export const DIAG = {
|
|
62
|
+
LOCALE_INVALID: 'document::locale::invalid',
|
|
63
|
+
LOCALE_CASE: 'document::locale::case',
|
|
64
|
+
LOCALE_SEPARATOR: 'document::locale::separator',
|
|
65
|
+
LOCALE_CONFLICT: 'document::locale::conflict',
|
|
66
|
+
LOCALE_MISSING_DEFAULT: 'document::locale::missing_default',
|
|
67
|
+
LOCALE_MISSING_PAGE: 'document::locale::missing_page',
|
|
68
|
+
LOCALE_ORPHAN_PAGE: 'document::locale::orphan_page',
|
|
69
|
+
LAYOUT_ILLEGAL_TOP: 'document::layout::illegal_top',
|
|
70
|
+
LAYOUT_MISSING_DOCUMENTS: 'document::layout::missing_documents',
|
|
71
|
+
CONFIG_MISSING: 'document::config::missing',
|
|
72
|
+
CONFIG_INVALID: 'document::config::invalid',
|
|
73
|
+
CONFIG_DEFAULT_LOCALE: 'document::config::default_locale',
|
|
74
|
+
FALLBACK_SILENT: 'document::fallback::silent_forbidden',
|
|
75
|
+
PAGE_DUPLICATE: 'document::page::duplicate',
|
|
76
|
+
LINK_BROKEN: 'document::link::broken',
|
|
77
|
+
LINK_AMBIGUOUS: 'document::link::ambiguous',
|
|
78
|
+
ANCHOR_MISSING: 'document::anchor::missing',
|
|
79
|
+
ANCHOR_DUPLICATE: 'document::anchor::duplicate',
|
|
80
|
+
ROUTE_DUPLICATE: 'document::route::duplicate',
|
|
81
|
+
NAV_EMPTY: 'document::nav::empty',
|
|
82
|
+
FENCE_CHECK: 'document::fence::check_failed',
|
|
83
|
+
FENCE_UNSUPPORTED: 'document::fence::unsupported',
|
|
84
|
+
FENCE_SOURCE_MISSING: 'document::fence::source_missing',
|
|
85
|
+
FENCE_RUN_FAILED: 'document::fence::run_failed',
|
|
86
|
+
API_MISSING: 'document::api::missing',
|
|
87
|
+
API_AMBIGUOUS: 'document::api::ambiguous',
|
|
88
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* `vmz explain` — DX causal explain queries (doc 21).
|
|
4
|
+
*
|
|
5
|
+
* @param {string[]} argv args after `explain`
|
|
6
|
+
*/
|
|
7
|
+
import { createWorkspace } from './index.js';
|
|
8
|
+
import { log } from './log.js';
|
|
9
|
+
import { resolveWorkspaceDirs } from './resolve.js';
|
|
10
|
+
/**
|
|
11
|
+
* @param {string[]} argv
|
|
12
|
+
* @returns {number}
|
|
13
|
+
*/
|
|
14
|
+
export function cmdExplain(argv) {
|
|
15
|
+
const args = parse(argv);
|
|
16
|
+
if (args.help || args._[0] === 'help') {
|
|
17
|
+
printHelp();
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
let target;
|
|
21
|
+
let pathArg = '.';
|
|
22
|
+
if (args._[0] === 'style') {
|
|
23
|
+
const node = args._[1];
|
|
24
|
+
if (!node) {
|
|
25
|
+
log.error('usage: vmz explain style <node> [path]');
|
|
26
|
+
return 1;
|
|
27
|
+
}
|
|
28
|
+
target = `style:${node}`;
|
|
29
|
+
pathArg = args._[2] ?? args.path ?? '.';
|
|
30
|
+
}
|
|
31
|
+
else if (args._[0]) {
|
|
32
|
+
target = String(args._[0]);
|
|
33
|
+
pathArg = args._[1] ?? args.path ?? '.';
|
|
34
|
+
}
|
|
35
|
+
else if (args.target) {
|
|
36
|
+
target = String(args.target);
|
|
37
|
+
pathArg = args.path ?? '.';
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
printHelp();
|
|
41
|
+
return 1;
|
|
42
|
+
}
|
|
43
|
+
const { project, outDir } = resolveWorkspaceDirs({
|
|
44
|
+
path: String(pathArg),
|
|
45
|
+
outDir: args['out-dir'] ?? 'dist',
|
|
46
|
+
});
|
|
47
|
+
const ws = createWorkspace({ root: project, outDir });
|
|
48
|
+
if (typeof ws.explain !== 'function') {
|
|
49
|
+
log.error('Workspace.explain unavailable (rebuild N-API)');
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
const raw = ws.explain(target);
|
|
53
|
+
if (args.json) {
|
|
54
|
+
console.log(raw);
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
let doc;
|
|
58
|
+
try {
|
|
59
|
+
doc = JSON.parse(raw);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
console.log(raw);
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
console.log(`explain kind=${doc.kind} target=${doc.target}`);
|
|
66
|
+
if (doc.notes)
|
|
67
|
+
console.log(`notes: ${doc.notes}`);
|
|
68
|
+
const chain = Array.isArray(doc.chain) ? doc.chain : [];
|
|
69
|
+
for (const e of chain) {
|
|
70
|
+
const from = e.from ? `${e.from.kind}:${e.from.id}` : '?';
|
|
71
|
+
const to = e.to ? `${e.to.kind}:${e.to.id}` : '?';
|
|
72
|
+
console.log(` ${from} -> ${to} (${e.reason})`);
|
|
73
|
+
}
|
|
74
|
+
if (chain.length === 0) {
|
|
75
|
+
console.log(' (empty chain)');
|
|
76
|
+
}
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
function printHelp() {
|
|
80
|
+
console.log(`vmz explain — causal explain (DX)
|
|
81
|
+
|
|
82
|
+
Usage:
|
|
83
|
+
vmz explain style <node> [path] Style Theme / style:tw / global styles
|
|
84
|
+
vmz explain <target> [path] Generic Workspace.explain target
|
|
85
|
+
|
|
86
|
+
Style nodes:
|
|
87
|
+
bg-action | colors.action | --vmz-colors-action
|
|
88
|
+
designs/styles/index.scss
|
|
89
|
+
|
|
90
|
+
Options:
|
|
91
|
+
--json Print raw ExplainDocument JSON
|
|
92
|
+
--out-dir, -o <dir> Dist directory (default: dist)
|
|
93
|
+
`);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @param {string[]} argv
|
|
97
|
+
*/
|
|
98
|
+
function parse(argv) {
|
|
99
|
+
/** @type {Record<string, string | boolean> & { _: string[] }} */
|
|
100
|
+
const out = { _: [] };
|
|
101
|
+
for (let i = 0; i < argv.length; i++) {
|
|
102
|
+
const a = argv[i];
|
|
103
|
+
if (a.startsWith('--')) {
|
|
104
|
+
const eq = a.indexOf('=');
|
|
105
|
+
if (eq !== -1) {
|
|
106
|
+
out[a.slice(2, eq)] = a.slice(eq + 1);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const key = a.slice(2);
|
|
110
|
+
const next = argv[i + 1];
|
|
111
|
+
if (next && !next.startsWith('-') && key !== 'json' && key !== 'help') {
|
|
112
|
+
out[key] = next;
|
|
113
|
+
i += 1;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
out[key] = true;
|
|
117
|
+
}
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
out._.push(a);
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
}
|