@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.
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 +46 -30
  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,9 +1,10 @@
1
- /**
2
- * Load the N-API addon or throw (production printers must not fall back to TS).
3
- * @returns {any}
4
- */
5
- export declare function requireNativeAddon(): any;
6
- /**
7
- * @returns {any | null}
8
- */
9
- export declare function tryLoadNativeAddon(): any;
1
+ export interface NativeAddon {
2
+ generatePrettyJson?: (json: string) => string;
3
+ authorJson5ToCanonicalJson?: (source: string) => string;
4
+ loadLocalePlan?: (projectRoot: string) => string;
5
+ loadDocumentRoutePlan?: (projectRoot: string) => string;
6
+ [key: string]: unknown;
7
+ }
8
+ /** Load the N-API addon or throw (production printers must not fall back to TS). */
9
+ export declare function requireNativeAddon(): NativeAddon;
10
+ export declare function tryLoadNativeAddon(): NativeAddon | null;
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Load the N-API `.node` addon without importing `index.js`
4
3
  * (avoids cycles with modules re-exported from the package entry).
@@ -8,12 +7,8 @@ import { createRequire } from 'node:module';
8
7
  import path from 'node:path';
9
8
  import { fileURLToPath } from 'node:url';
10
9
  const require = createRequire(import.meta.url);
11
- /** @type {any} */
12
10
  let cached;
13
- /**
14
- * Load the N-API addon or throw (production printers must not fall back to TS).
15
- * @returns {any}
16
- */
11
+ /** Load the N-API addon or throw (production printers must not fall back to TS). */
17
12
  export function requireNativeAddon() {
18
13
  const native = tryLoadNativeAddon();
19
14
  if (!native) {
@@ -21,9 +16,6 @@ export function requireNativeAddon() {
21
16
  }
22
17
  return native;
23
18
  }
24
- /**
25
- * @returns {any | null}
26
- */
27
19
  export function tryLoadNativeAddon() {
28
20
  if (cached !== undefined)
29
21
  return cached;
@@ -58,7 +50,6 @@ export function tryLoadNativeAddon() {
58
50
  : triple;
59
51
  const pkgRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
60
52
  const name = `@vmz/vmz-${short}`;
61
- /** @type {string[]} */
62
53
  const candidates = [];
63
54
  try {
64
55
  const resolved = require.resolve(`${name}/package.json`);
@@ -12,7 +12,10 @@
12
12
  * @param {{ projectRoot?: string | null }} [opts]
13
13
  * @returns {{ rewrittenFiles: number, vendoredModules: string[], bareSpecs: string[] }}
14
14
  */
15
- export declare function packClientBareImports(outDir: any, opts?: {}): {
15
+ interface PackClientBareImportsOpts {
16
+ projectRoot?: string | null;
17
+ }
18
+ export declare function packClientBareImports(outDir: string, opts?: PackClientBareImportsOpts): {
16
19
  rewrittenFiles: number;
17
20
  vendoredModules: string[];
18
21
  bareSpecs: any[];
@@ -23,3 +26,4 @@ export declare function packClientBareImports(outDir: any, opts?: {}): {
23
26
  /** @param {string} js */
24
27
  export declare function collectBareSpecs(js: any): unknown[];
25
28
  export declare function rewriteRelativeTsSpecs(js: any): any;
29
+ export {};
@@ -7,18 +7,12 @@
7
7
  *
8
8
  * Not full oxc chunk-split/minify (`oxc-pending` remains for release minify).
9
9
  */
10
- // @ts-nocheck
11
10
  import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
12
11
  import path from 'node:path';
13
12
  import { createRequire } from 'node:module';
14
13
  import { resolvePackageRoot } from './packages.js';
15
14
  const VENDOR_DIR = 'vendor';
16
15
  const SKIP_PREFIXES = ['node:', 'nodejs:', 'cloudflare:', 'data:', 'http:', 'https:', 'vmz:', '#'];
17
- /**
18
- * @param {string} outDir
19
- * @param {{ projectRoot?: string | null }} [opts]
20
- * @returns {{ rewrittenFiles: number, vendoredModules: string[], bareSpecs: string[] }}
21
- */
22
16
  export function packClientBareImports(outDir, opts = {}) {
23
17
  const projectRoot = opts.projectRoot ? path.resolve(opts.projectRoot) : path.dirname(path.resolve(outDir));
24
18
  /** @type {Map<string, string>} bareSpec → absolute vendored .js path */
package/dist/pack.d.ts CHANGED
@@ -23,28 +23,29 @@ export declare function ensureRuntimeCompanions(outDir: any, coreDist: any): any
23
23
  * projectRoot?: string | null,
24
24
  * }} [opts]
25
25
  */
26
- export declare function packFromDeploymentIr(outDir: any, opts?: {}): {
26
+ interface PackFromDeploymentIrOpts {
27
+ release?: boolean;
28
+ profileId?: string;
29
+ assembly?: string;
30
+ preferredClientFace?: string;
31
+ coreDist?: string | null;
32
+ projectRoot?: string | null;
33
+ }
34
+ export declare function packFromDeploymentIr(outDir: string, opts?: PackFromDeploymentIrOpts): {
27
35
  manifest: {
28
36
  schema: string;
29
- profileId: any;
30
- assembly: any;
37
+ profileId: string | null;
38
+ assembly: string | null;
31
39
  release: boolean;
32
- preferredClientFace: any;
33
- deploymentSchema: any;
40
+ preferredClientFace: string;
41
+ deploymentSchema: unknown;
34
42
  unitCount: number;
35
- units: any[];
43
+ units: unknown[];
36
44
  minify: string;
37
45
  treeShakeBasis: string;
38
46
  bundler: string;
39
- clientPackageLowering: {
40
- status: string;
41
- rewrittenFiles: number;
42
- bareSpecs: any[];
43
- vendoredModules: string[];
44
- unresolvedBareSpecs: any[];
45
- skippedVmzExports: any[];
46
- remainingBareSpecs: any[];
47
- };
47
+ clientPackageLowering: Record<string, unknown>;
48
+ packDigest?: string;
48
49
  };
49
50
  path: string;
50
51
  clientPackages: {
@@ -56,3 +57,4 @@ export declare function packFromDeploymentIr(outDir: any, opts?: {}): {
56
57
  remainingBareSpecs: any[];
57
58
  };
58
59
  };
60
+ export {};
package/dist/pack.js CHANGED
@@ -3,7 +3,6 @@
3
3
  * and lower browser-unreachable bare package imports to `dist/vendor/**`.
4
4
  * Full oxc minify/chunk-split lands progressively (`oxc-pending` on release minify).
5
5
  */
6
- // @ts-nocheck
7
6
  import crypto from 'node:crypto';
8
7
  import { copyFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs';
9
8
  import path from 'node:path';
@@ -33,17 +32,6 @@ export function ensureRuntimeCompanions(outDir, coreDist) {
33
32
  }
34
33
  return copied;
35
34
  }
36
- /**
37
- * @param {string} outDir
38
- * @param {{
39
- * release?: boolean,
40
- * profileId?: string,
41
- * assembly?: string,
42
- * preferredClientFace?: string,
43
- * coreDist?: string | null,
44
- * projectRoot?: string | null,
45
- * }} [opts]
46
- */
47
35
  export function packFromDeploymentIr(outDir, opts = {}) {
48
36
  ensureRuntimeCompanions(outDir, opts.coreDist);
49
37
  // Browser ESM cannot resolve bare npm specs — materialize reachable packages first
@@ -1,26 +1,13 @@
1
1
  /**
2
2
  * npm / pnpm workspace package resolution helpers (session).
3
3
  */
4
- /**
5
- * @typedef {object} ResolvedPackage
6
- * @property {string} name
7
- * @property {string} root
8
- * @property {boolean} [private]
9
- * @property {boolean} hasSrc
10
- * @property {string} [version]
11
- */
12
- /**
13
- * Resolve workspace packages under a project (package.json workspaces or pnpm-workspace.yaml).
14
- * Does not invent VMZ semantics — only filesystem / npm layout facts for plugins.
15
- *
16
- * @param {string} project
17
- * @returns {ResolvedPackage[]}
18
- */
19
- export declare function resolveWorkspacePackages(project: any): any[];
20
- /**
21
- * Resolve a package name to an absolute root (workspace first, then node_modules).
22
- * @param {string} project
23
- * @param {string} name
24
- * @returns {string | null}
25
- */
26
- export declare function resolvePackageRoot(project: any, name: any): any;
4
+ export interface ResolvedPackage {
5
+ name: string;
6
+ root: string;
7
+ private?: boolean;
8
+ hasSrc: boolean;
9
+ version?: string;
10
+ }
11
+ /** Resolve workspace packages under a project (package.json workspaces or pnpm-workspace.yaml). */
12
+ export declare function resolveWorkspacePackages(project: string): ResolvedPackage[];
13
+ export declare function resolvePackageRoot(project: string, name: string): string | null;
package/dist/packages.js CHANGED
@@ -1,28 +1,12 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * npm / pnpm workspace package resolution helpers (session).
4
3
  */
5
4
  import { existsSync, readFileSync, readdirSync } from 'node:fs';
6
5
  import path from 'node:path';
7
- /**
8
- * @typedef {object} ResolvedPackage
9
- * @property {string} name
10
- * @property {string} root
11
- * @property {boolean} [private]
12
- * @property {boolean} hasSrc
13
- * @property {string} [version]
14
- */
15
- /**
16
- * Resolve workspace packages under a project (package.json workspaces or pnpm-workspace.yaml).
17
- * Does not invent VMZ semantics — only filesystem / npm layout facts for plugins.
18
- *
19
- * @param {string} project
20
- * @returns {ResolvedPackage[]}
21
- */
6
+ /** Resolve workspace packages under a project (package.json workspaces or pnpm-workspace.yaml). */
22
7
  export function resolveWorkspacePackages(project) {
23
8
  const root = path.resolve(project);
24
9
  const patterns = readWorkspacePatterns(root);
25
- /** @type {Map<string, ResolvedPackage>} */
26
10
  const out = new Map();
27
11
  // Always include the project itself when it has package.json.
28
12
  const self = readPkg(root);
@@ -37,12 +21,6 @@ export function resolveWorkspacePackages(project) {
37
21
  }
38
22
  return [...out.values()].sort((a, b) => a.name.localeCompare(b.name));
39
23
  }
40
- /**
41
- * Resolve a package name to an absolute root (workspace first, then node_modules).
42
- * @param {string} project
43
- * @param {string} name
44
- * @returns {string | null}
45
- */
46
24
  export function resolvePackageRoot(project, name) {
47
25
  const hit = resolveWorkspacePackages(project).find((p) => p.name === name);
48
26
  if (hit)
@@ -52,10 +30,6 @@ export function resolvePackageRoot(project, name) {
52
30
  return nm;
53
31
  return null;
54
32
  }
55
- /**
56
- * @param {string} root
57
- * @returns {string[]}
58
- */
59
33
  function readWorkspacePatterns(root) {
60
34
  const patterns = [];
61
35
  const pkgPath = path.join(root, 'package.json');
@@ -88,11 +62,6 @@ function readWorkspacePatterns(root) {
88
62
  }
89
63
  return [...new Set(patterns)];
90
64
  }
91
- /**
92
- * Minimal glob: supports `packages/*`, `examples/*`, exact dirs. No `**`.
93
- * @param {string} root
94
- * @param {string} pattern
95
- */
96
65
  function expandWorkspacePattern(root, pattern) {
97
66
  const cleaned = pattern.replace(/\\/g, '/').replace(/\/$/, '');
98
67
  if (!cleaned.includes('*')) {
@@ -107,7 +76,6 @@ function expandWorkspacePattern(root, pattern) {
107
76
  const base = path.join(root, prefix);
108
77
  if (!existsSync(base))
109
78
  return [];
110
- /** @type {string[]} */
111
79
  const dirs = [];
112
80
  for (const name of readdirSync(base, { withFileTypes: true })) {
113
81
  if (!name.isDirectory())
@@ -120,10 +88,6 @@ function expandWorkspacePattern(root, pattern) {
120
88
  }
121
89
  return dirs;
122
90
  }
123
- /**
124
- * @param {string} dir
125
- * @returns {ResolvedPackage | null}
126
- */
127
91
  function readPkg(dir) {
128
92
  const pkgPath = path.join(dir, 'package.json');
129
93
  if (!existsSync(pkgPath))
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `vmz plan` — dump frozen Rust plans via N-API; registered on `@vmz/commander`.
3
+ */
4
+ import type { Command, ParsedOptions } from '@vmz/commander';
5
+ export declare function registerPlanCommands(parent: Command): void;
6
+ export declare function runPlanKind(kind: 'locale' | 'document-route', options: ParsedOptions): number;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * `vmz plan` — dump frozen Rust plans via N-API; registered on `@vmz/commander`.
3
+ */
4
+ import path from 'node:path';
5
+ import { loadDocumentRoutePlan, loadLocalePlan, mapPlanDiagnostics } from './author-input.js';
6
+ import { log } from './log.js';
7
+ import { emitPrettyJson } from './pretty-json.js';
8
+ export function registerPlanCommands(parent) {
9
+ const withJson = (cmd) => cmd.option('--json [file]', 'cli.opt.json');
10
+ withJson(parent.command('locale', 'cli.cmd.plan.locale')).action((options) => runPlanKind('locale', options));
11
+ withJson(parent.command('document-route|document_route', 'cli.cmd.plan.document-route')).action((options) => runPlanKind('document-route', options));
12
+ }
13
+ export function runPlanKind(kind, options) {
14
+ const rootArg = typeof options._[0] === 'string' ? options._[0] : '.';
15
+ const root = path.resolve(rootArg);
16
+ let plan;
17
+ switch (kind) {
18
+ case 'locale':
19
+ plan = loadLocalePlan(root);
20
+ break;
21
+ case 'document-route':
22
+ plan = loadDocumentRoutePlan(root);
23
+ break;
24
+ default:
25
+ log.errorId('cli.err.unknown_plan_kind', { kind: String(kind) });
26
+ return 1;
27
+ }
28
+ const diagnostics = mapPlanDiagnostics(plan?.diagnostics || []);
29
+ const hardErrors = diagnostics.filter((d) => d.severity === 'error');
30
+ if (diagnostics.length) {
31
+ log.diagnostics(diagnostics);
32
+ }
33
+ emitPrettyJson(typeof options.json === 'string' ? options.json : true, plan);
34
+ return hardErrors.length ? 1 : 0;
35
+ }
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Plugin protocol v1 helpers + typed config loading.
4
3
  */
package/dist/port.d.ts CHANGED
@@ -1,10 +1,2 @@
1
- /**
2
- * Probe for a free TCP port starting at `start` (inclusive).
3
- * Used by `vmz dev` when `--port` is omitted.
4
- *
5
- * @param {string} host
6
- * @param {number} [start=5173]
7
- * @param {number} [maxTries=50]
8
- * @returns {Promise<number>}
9
- */
10
- export declare function findAvailablePort(host: any, start?: number, maxTries?: number): Promise<unknown>;
1
+ /** Probe for a free TCP port starting at `start` (inclusive). Used by `vmz dev` when `--port` is omitted. */
2
+ export declare function findAvailablePort(host: string, start?: number, maxTries?: number): Promise<number>;
package/dist/port.js CHANGED
@@ -1,14 +1,5 @@
1
- // @ts-nocheck
2
1
  import net from 'node:net';
3
- /**
4
- * Probe for a free TCP port starting at `start` (inclusive).
5
- * Used by `vmz dev` when `--port` is omitted.
6
- *
7
- * @param {string} host
8
- * @param {number} [start=5173]
9
- * @param {number} [maxTries=50]
10
- * @returns {Promise<number>}
11
- */
2
+ /** Probe for a free TCP port starting at `start` (inclusive). Used by `vmz dev` when `--port` is omitted. */
12
3
  export function findAvailablePort(host, start = 5173, maxTries = 50) {
13
4
  const first = Number(start);
14
5
  if (!Number.isFinite(first) || first <= 0) {
@@ -24,7 +15,7 @@ export function findAvailablePort(host, start = 5173, maxTries = 50) {
24
15
  const server = net.createServer();
25
16
  server.unref();
26
17
  server.once('error', (err) => {
27
- if (err && err.code === 'EADDRINUSE') {
18
+ if (err?.code === 'EADDRINUSE') {
28
19
  port += 1;
29
20
  attempt();
30
21
  return;
@@ -1,19 +1,9 @@
1
- /**
2
- * Pretty-print a value through `vmz-generator` (N-API).
3
- * @param {unknown} value
4
- * @returns {string} Pretty JSON without trailing newline.
5
- */
6
- export declare function generatePrettyJson(value: any): any;
7
- /**
8
- * Write a pretty JSON artifact with a trailing newline.
9
- * @param {string} filePath
10
- * @param {unknown} value
11
- */
12
- export declare function writePrettyJsonFile(filePath: any, value: any): void;
13
- /**
14
- * CLI `--json` helper: write to a path when `target` is a string, else stdout.
15
- * @param {string | boolean | undefined} target
16
- * @param {unknown} value
17
- * @param {{ logWrote?: (path: string) => void }} [opts]
18
- */
19
- export declare function emitPrettyJson(target: any, value: any, opts?: {}): void;
1
+ export interface EmitPrettyJsonOpts {
2
+ logWrote?: (path: string) => void;
3
+ }
4
+ /** Pretty-print a value through `vmz-generator` (N-API). Returns pretty JSON without trailing newline. */
5
+ export declare function generatePrettyJson(value: unknown): string;
6
+ /** Write a pretty JSON artifact with a trailing newline. */
7
+ export declare function writePrettyJsonFile(filePath: string, value: unknown): void;
8
+ /** CLI `--json` helper: write to a path when `target` is a string, else stdout. */
9
+ export declare function emitPrettyJson(target: string | boolean | undefined, value: unknown, opts?: EmitPrettyJsonOpts): void;
@@ -1,15 +1,10 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Production JSON artifact printer — always via N-API JsonCodeGenerator.
4
3
  * Do not use `JSON.stringify(x, null, 2)` for on-disk artifacts.
5
4
  */
6
5
  import fs from 'node:fs';
7
6
  import { requireNativeAddon } from './native-addon.js';
8
- /**
9
- * Pretty-print a value through `vmz-generator` (N-API).
10
- * @param {unknown} value
11
- * @returns {string} Pretty JSON without trailing newline.
12
- */
7
+ /** Pretty-print a value through `vmz-generator` (N-API). Returns pretty JSON without trailing newline. */
13
8
  export function generatePrettyJson(value) {
14
9
  const native = requireNativeAddon();
15
10
  if (typeof native.generatePrettyJson !== 'function') {
@@ -17,20 +12,11 @@ export function generatePrettyJson(value) {
17
12
  }
18
13
  return native.generatePrettyJson(JSON.stringify(value));
19
14
  }
20
- /**
21
- * Write a pretty JSON artifact with a trailing newline.
22
- * @param {string} filePath
23
- * @param {unknown} value
24
- */
15
+ /** Write a pretty JSON artifact with a trailing newline. */
25
16
  export function writePrettyJsonFile(filePath, value) {
26
17
  fs.writeFileSync(filePath, `${generatePrettyJson(value)}\n`, 'utf8');
27
18
  }
28
- /**
29
- * CLI `--json` helper: write to a path when `target` is a string, else stdout.
30
- * @param {string | boolean | undefined} target
31
- * @param {unknown} value
32
- * @param {{ logWrote?: (path: string) => void }} [opts]
33
- */
19
+ /** CLI `--json` helper: write to a path when `target` is a string, else stdout. */
34
20
  export function emitPrettyJson(target, value, opts = {}) {
35
21
  const text = generatePrettyJson(value);
36
22
  if (typeof target === 'string') {