@vmz/vmz 0.3.12 → 0.3.14

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 (57) hide show
  1. package/bin/vmz.js +4 -0
  2. package/delivery-runtime-files.json +2 -0
  3. package/dist/cli/cli.js +46 -23
  4. package/dist/cli/format-cmd.d.ts +9 -17
  5. package/dist/cli/format-cmd.js +37 -49
  6. package/dist/cli/format-config.d.ts +6 -9
  7. package/dist/cli/format-config.js +5 -29
  8. package/dist/delivery/delivery-profile.js +1 -1
  9. package/dist/dev/dev-incremental.d.ts +0 -2
  10. package/dist/dev/dev-incremental.js +0 -1
  11. package/dist/dev/dev-session.d.ts +53 -1
  12. package/dist/dev/dev-session.js +368 -65
  13. package/dist/document/document-base-css.d.ts +15 -0
  14. package/dist/document/document-base-css.js +578 -0
  15. package/dist/document/document-build.d.ts +1 -0
  16. package/dist/document/document-build.js +94 -78
  17. package/dist/document/document-client.d.ts +13 -0
  18. package/dist/document/document-client.js +217 -0
  19. package/dist/document/document-cmd.js +3 -1
  20. package/dist/document/document-designs.d.ts +9 -3
  21. package/dist/document/document-designs.js +20 -34
  22. package/dist/document/document-enrich.d.ts +9 -0
  23. package/dist/document/document-enrich.js +55 -0
  24. package/dist/document/document-highlight.d.ts +26 -0
  25. package/dist/document/document-highlight.js +54 -0
  26. package/dist/document/document-integrate.d.ts +5 -0
  27. package/dist/document/document-integrate.js +1 -0
  28. package/dist/document/document-interactive.js +10 -2
  29. package/dist/document/document-layout-render.js +6 -2
  30. package/dist/document/document-schema.d.ts +5 -0
  31. package/dist/workspace/build-assemble.js +18 -6
  32. package/dist/workspace/content-addressed-assets.d.ts +6 -17
  33. package/dist/workspace/content-addressed-assets.js +10 -95
  34. package/dist/workspace/delivery-runtime-imports.js +9 -0
  35. package/dist/workspace/native-addon.d.ts +4 -0
  36. package/dist/workspace/pack-native.d.ts +151 -0
  37. package/dist/workspace/pack-native.js +280 -0
  38. package/dist/workspace/pack.d.ts +131 -32
  39. package/dist/workspace/pack.js +381 -65
  40. package/dist/workspace/plugin-host.d.ts +4 -4
  41. package/dist/workspace/plugin-host.js +6 -6
  42. package/dist/workspace/production-observability.d.ts +2 -0
  43. package/dist/workspace/production-observability.js +6 -2
  44. package/dist/workspace/project-build.js +26 -4
  45. package/dist/workspace/public-api.d.ts +7 -3
  46. package/dist/workspace/public-api.js +5 -3
  47. package/dist/workspace/static-emit.d.ts +30 -0
  48. package/dist/workspace/static-emit.js +211 -18
  49. package/dist/workspace/user-config.d.ts +112 -0
  50. package/dist/workspace/user-config.js +12 -0
  51. package/host-runtime-files.json +1 -0
  52. package/locales/en-US/cli.json +5 -4
  53. package/locales/en-US/diag.json +2 -0
  54. package/locales/zh-CN/diag.json +2 -0
  55. package/package.json +20 -20
  56. package/dist/workspace/pack-client-packages.d.ts +0 -34
  57. package/dist/workspace/pack-client-packages.js +0 -550
package/bin/vmz.js CHANGED
@@ -9,4 +9,8 @@ if (major < 24 || (major === 24 && minor < 12)) {
9
9
  }
10
10
  const { runCli } = await import('../dist/cli/cli.js');
11
11
  const code = await runCli(process.argv.slice(2));
12
+ // POSIX pipes flush asynchronously, so `process.exit` can drop queued
13
+ // diagnostics before CI captures them. Drain both streams first.
14
+ await new Promise((resolve) => process.stderr.write('', resolve));
15
+ await new Promise((resolve) => process.stdout.write('', resolve));
12
16
  process.exit(code ?? 0);
@@ -11,6 +11,7 @@
11
11
  { "src": "browser/direct-host-box.js", "out": "direct-host-box.js" },
12
12
  { "src": "browser/unknown-component.js", "out": "unknown-component.js" },
13
13
  { "src": "shared/dom-attr-normalize.js", "out": "dom-attr-normalize.js" },
14
+ { "src": "shared/html-digest.js", "out": "html-digest.js" },
14
15
  { "src": "faces/http.js", "out": "vmz-http.js" },
15
16
  { "src": "browser/client-nav.js", "out": "vmz-client-nav.js" }
16
17
  ],
@@ -33,6 +34,7 @@
33
34
  { "src": "browser/resume/resume.js", "out": "browser/resume/resume.js" },
34
35
  { "src": "ssr/render.js", "out": "ssr/render.js" },
35
36
  { "src": "ssr/serialize.js", "out": "ssr/serialize.js" },
37
+ { "src": "ssr/onmount.js", "out": "ssr/onmount.js" },
36
38
  { "src": "ssr/document.js", "out": "ssr/document.js" }
37
39
  ]
38
40
  }
package/dist/cli/cli.js CHANGED
@@ -2,6 +2,7 @@
2
2
  * Node CLI command implementations .
3
3
  */
4
4
  import { spawn } from 'node:child_process';
5
+ import { existsSync, statSync } from 'node:fs';
5
6
  import path from 'node:path';
6
7
  import { createCli } from '@vmz/commander';
7
8
  import { registerApplicationCommands } from './application-cmd.js';
@@ -14,7 +15,7 @@ import { buildIntegratedDocuments, projectHasDocuments } from '../document/docum
14
15
  import { registerExplainCommand } from './explain-cmd.js';
15
16
  import { registerGithubActionsCommand } from './github-actions-cmd.js';
16
17
  import { registerInitCommands } from './init-cmd.js';
17
- import { createWorkspace, getProtocolVersions, HOST_PROTOCOL, materializeServeHostRuntime, materializeWechatPackaging, resolveCoreRuntimeDist, resolveNativePath, } from '../workspace/public-api.js';
18
+ import { createWorkspace, getProtocolVersions, HOST_PROTOCOL, materializeServeHostRuntime, materializeWechatPackaging, resolveNativePath, } from '../workspace/public-api.js';
18
19
  import { gateGlobalProjectCommand, getInvocationContext, isGlobalAllowedCommand } from '../workspace/invocation.js';
19
20
  import { emitLocaleRuntimeModules, localeHasErrors } from '../locale/locale-check.js';
20
21
  import { registerLocaleCommands } from '../locale/locale-cmd.js';
@@ -22,15 +23,17 @@ import { emitLocaleRouteRealization } from '../locale/locale-route-emit.js';
22
23
  import { log } from '../workspace/log.js';
23
24
  import { resolveCliLogLevel, setCliLogLevel } from '../workspace/log-level.js';
24
25
  import { parseCliLogStyle, setCliLogStyle } from '../workspace/log-style.js';
25
- import { packFromDeploymentIr } from '../workspace/pack.js';
26
+ import { ensureRuntimeCompanions, packFromDeploymentIr, packSsrFromDeploymentIr } from '../workspace/pack.js';
26
27
  import { registerPlanCommands } from './plan-cmd.js';
27
28
  import { loadVmzConfig } from '../workspace/plugin-host.js';
28
29
  import { findAvailablePort } from '../workspace/port.js';
29
30
  import { registerRefactorCommands } from './refactor-cmd.js';
30
31
  import { registerArtifactCommands } from './release-cmd.js';
31
- import { readPackageMeta, resolveWorkspaceDirs } from '../workspace/resolve.js';
32
+ import { findPackageJson, readPackageMeta, resolveWorkspaceDirs } from '../workspace/resolve.js';
32
33
  import { emitRouteCatalog } from '../workspace/route-catalog-emit.js';
34
+ import { resolveCoreRuntimeDist } from '../workspace/runtime-dist.js';
33
35
  import { registerTestCommand } from './test-cmd.js';
36
+ import { emitStaticBootstrapEntries } from '../workspace/static-emit.js';
34
37
  export function printGlobalHelp() {
35
38
  return buildProductCli({ mode: 'global' }).parse(['help']);
36
39
  }
@@ -75,6 +78,7 @@ function buildProductCli(opts = {}) {
75
78
  withServeExtras(withCoreOpts(cli.command('serve', 'cli.cmd.serve'))).action((options) => cmdServe(options));
76
79
  withServeExtras(withCoreOpts(cli.command('dev', 'cli.cmd.dev'))).action((options) => cmdDev(options));
77
80
  withCoreOpts(cli.command('format', 'cli.cmd.format'))
81
+ .option('--rust', 'cli.opt.format-rust')
78
82
  .option('--no-javascript', 'cli.opt.format-no-javascript')
79
83
  .option('--no-rust', 'cli.opt.format-no-rust')
80
84
  .option('--no-vmz', 'cli.opt.format-no-vmz')
@@ -269,8 +273,21 @@ async function cmdBuild(args) {
269
273
  if (routeCatalog.written.length) {
270
274
  log.info(`route catalog (${routeCatalog.written.length} artifact(s))`);
271
275
  }
276
+ if (!wechatPack) {
277
+ try {
278
+ // Node graph must be packed before any SSR consumer (document
279
+ // build, static emit, render host) imports a compiled chunk.
280
+ ensureRuntimeCompanions(outDir, resolveCoreRuntimeDist());
281
+ const nodePack = packSsrFromDeploymentIr(outDir, { projectRoot: project });
282
+ log.info(`node pack ok (entries=${nodePack.manifest.entryCount}, chunks=${nodePack.manifest.chunkCount}, digest=${String(nodePack.manifest.packDigest).slice(0, 12)}…)`);
283
+ }
284
+ catch (err) {
285
+ log.error(`node pack failed: ${err instanceof Error ? err.message : String(err)}`);
286
+ return 1;
287
+ }
288
+ }
272
289
  if (projectHasDocuments(project)) {
273
- const docs = await buildIntegratedDocuments({ projectRoot: project, outDir });
290
+ const docs = await buildIntegratedDocuments({ projectRoot: project, outDir, engines: cfg.engines });
274
291
  if (!docs.ok)
275
292
  return 1;
276
293
  }
@@ -299,21 +316,16 @@ async function cmdBuild(args) {
299
316
  }
300
317
  let pack = null;
301
318
  try {
319
+ // Browser pack entries are the static bootstrap modules; static emit
320
+ // runs after pack (HTML resolves `_vmz/pack/`), so write them first.
321
+ emitStaticBootstrapEntries(outDir);
302
322
  pack = packFromDeploymentIr(outDir, {
303
323
  release: Boolean(args.release),
304
324
  profileId: selected.selection.profileId,
305
325
  assembly: selected.selection.assembly,
306
- coreDist: resolveCoreRuntimeDist(),
307
326
  projectRoot: project,
308
327
  });
309
- const lower = pack.manifest?.clientPackageLowering;
310
- if (lower?.bareSpecs?.length) {
311
- log.info(`pack client packages (${lower.bareSpecs.length} bare → vendor; rewritten=${lower.rewrittenFiles})`);
312
- }
313
- if (lower?.remainingBareSpecs?.length) {
314
- log.warn(`pack client packages: ${lower.remainingBareSpecs.length} bare specifier(s) still unresolved for browser: ${lower.remainingBareSpecs.slice(0, 8).join(', ')}${lower.remainingBareSpecs.length > 8 ? '…' : ''}`);
315
- }
316
- log.info(`pack ok (units=${pack.manifest.unitCount}, digest=${String(pack.manifest.packDigest).slice(0, 12)}…)`);
328
+ log.info(`pack ok (entries=${pack.manifest.entryCount}, chunks=${pack.manifest.chunkCount}, digest=${String(pack.manifest.packDigest).slice(0, 12)}…)`);
317
329
  }
318
330
  catch (err) {
319
331
  log.error(`pack failed: ${err instanceof Error ? err.message : String(err)}`);
@@ -513,24 +525,35 @@ async function cmdDev(args) {
513
525
  }
514
526
  }
515
527
  async function cmdFormat(args) {
516
- const pathArg = args._[0] ?? '.';
517
- const { project, outDir } = resolveWorkspaceDirs({
518
- path: pathArg,
519
- outDir: typeof args['out-dir'] === 'string' ? args['out-dir'] : undefined,
520
- });
528
+ const rawPath = args._[0];
529
+ if (typeof rawPath !== 'string' || rawPath.trim() === '') {
530
+ log.error('format: explicit <file|dir> path required — no implicit workspace scope (pass `.` for the current directory)');
531
+ return 1;
532
+ }
533
+ const target = path.resolve(process.cwd(), rawPath);
534
+ if (!existsSync(target)) {
535
+ log.error(`format: path does not exist: ${target}`);
536
+ return 1;
537
+ }
538
+ if (args.rust && args['no-rust']) {
539
+ log.error('format: conflicting `--rust` and `--no-rust`');
540
+ return 1;
541
+ }
542
+ const startDir = statSync(target).isDirectory() ? target : path.dirname(target);
543
+ const pkg = findPackageJson(startDir);
544
+ const configRoot = pkg ? path.dirname(pkg) : startDir;
521
545
  const checkOnly = Boolean(args.check);
522
- log.info(`format ${project}${checkOnly ? ' --check' : ''}`);
546
+ log.info(`format ${target}${checkOnly ? ' --check' : ''}`);
523
547
  const { runFormatCommand } = await import('./format-cmd.js');
524
548
  return runFormatCommand({
525
- project,
526
- outDir,
549
+ target,
550
+ configRoot,
527
551
  check: checkOnly,
528
552
  overrides: {
529
553
  javascript: args['no-javascript'] ? false : undefined,
530
- rust: args['no-rust'] ? false : undefined,
554
+ rust: args.rust ? true : args['no-rust'] ? false : undefined,
531
555
  vmz: args['no-vmz'] ? false : undefined,
532
556
  },
533
- createWorkspace,
534
557
  });
535
558
  }
536
559
  function cmdLint(args) {
@@ -1,28 +1,20 @@
1
1
  /**
2
- * `vmz format` — workspace surfaces (JS/TS + Rust) + `.vmz` authoring formatter.
2
+ * `vmz format` — explicit-path formatter.
3
+ *
4
+ * Scope contract: the positional path is the whole scope. A file formats only
5
+ * itself; a directory is walked locally. Nothing ever falls back to a
6
+ * workspace-wide pass, and Rust runs per-file `rustfmt` — never `cargo fmt`.
3
7
  */
4
8
  export type FormatCommandOptions = {
5
- project: string;
6
- outDir: string;
9
+ /** Absolute explicit file or directory (already validated to exist). */
10
+ target: string;
11
+ /** Project root used to load `vmz.config` and the style config. */
12
+ configRoot: string;
7
13
  check: boolean;
8
14
  overrides?: {
9
15
  javascript?: boolean;
10
16
  rust?: boolean;
11
17
  vmz?: boolean;
12
18
  };
13
- createWorkspace: (opts: {
14
- root: string;
15
- outDir: string;
16
- }) => {
17
- format: (checkOnly?: boolean) => {
18
- filesChecked: number;
19
- filesWritten: number;
20
- filesNeedWrite: number;
21
- diagnostics?: Array<{
22
- severity?: string;
23
- }>;
24
- };
25
- dispose: () => void;
26
- };
27
19
  };
28
20
  export declare function runFormatCommand(opts: FormatCommandOptions): Promise<number>;
@@ -1,65 +1,53 @@
1
1
  /**
2
- * `vmz format` — workspace surfaces (JS/TS + Rust) + `.vmz` authoring formatter.
2
+ * `vmz format` — explicit-path formatter.
3
+ *
4
+ * Scope contract: the positional path is the whole scope. A file formats only
5
+ * itself; a directory is walked locally. Nothing ever falls back to a
6
+ * workspace-wide pass, and Rust runs per-file `rustfmt` — never `cargo fmt`.
3
7
  */
8
+ import fs from 'node:fs';
9
+ import path from 'node:path';
4
10
  import { loadNative } from '../workspace/public-api.js';
5
11
  import { loadVmzConfig } from '../workspace/plugin-host.js';
6
12
  import { log } from '../workspace/log.js';
7
13
  import { resolveFormatConfig } from './format-config.js';
8
14
  export async function runFormatCommand(opts) {
9
- const { project, outDir, check, createWorkspace } = opts;
10
- const { format: formatConfig } = await loadVmzConfig(project);
11
- const resolved = resolveFormatConfig(project, formatConfig);
12
- if (opts.overrides?.javascript !== undefined)
13
- resolved.javascript = opts.overrides.javascript;
14
- if (opts.overrides?.rust !== undefined)
15
- resolved.rust = opts.overrides.rust;
16
- if (opts.overrides?.vmz !== undefined)
17
- resolved.vmz = opts.overrides.vmz;
15
+ const { target, configRoot, check } = opts;
16
+ const { format: formatConfig } = await loadVmzConfig(configRoot);
17
+ const resolved = resolveFormatConfig(formatConfig);
18
18
  const native = loadNative();
19
- let exit = 0;
20
- if (resolved.javascript || resolved.rust) {
21
- const report = native.formatWorkspaceRun({
22
- cwd: project,
19
+ let report;
20
+ try {
21
+ report = native.formatTargetsRun({
22
+ targets: [target],
23
23
  check,
24
- includes: resolved.includes,
24
+ rust: opts.overrides?.rust,
25
+ javascript: opts.overrides?.javascript,
26
+ vmz: opts.overrides?.vmz,
25
27
  excludes: resolved.excludes,
26
- rust: resolved.rust,
27
- javascript: resolved.javascript,
28
- styleConfig: resolved.style,
28
+ styleConfig: path.resolve(configRoot, resolved.style),
29
29
  });
30
- if (report.errors.length > 0) {
31
- for (const message of report.errors) {
32
- log.error(message);
33
- }
30
+ }
31
+ catch (err) {
32
+ log.error(err instanceof Error ? err.message : String(err));
33
+ return 1;
34
+ }
35
+ let exit = 0;
36
+ for (const message of report.errors) {
37
+ log.error(message);
38
+ }
39
+ if (report.errors.length > 0)
40
+ exit = 1;
41
+ if (log.diagnostics(report.diagnostics ?? []))
42
+ exit = 1;
43
+ const scope = fs.statSync(target).isDirectory() ? `${target}${path.sep}` : target;
44
+ if (check) {
45
+ log.info(`format ${scope}: ${report.needWrite} file(s) would change, ${report.unchanged} unchanged`);
46
+ if (report.needWrite > 0)
34
47
  exit = 1;
35
- }
36
- else if (check && report.formatted === 0 && report.unchanged > 0) {
37
- log.info(`workspace format: no changes needed (${report.unchanged} file(s) checked)`);
38
- }
39
- else if (!check) {
40
- log.info(`workspace format: ${report.formatted} file(s) updated, ${report.unchanged} unchanged`);
41
- }
42
48
  }
43
- if (resolved.vmz) {
44
- log.info(`format .vmz ${project}${check ? ' --check' : ''}`);
45
- const ws = createWorkspace({ root: project, outDir });
46
- try {
47
- const report = ws.format(check);
48
- const errors = log.diagnostics(report.diagnostics ?? []);
49
- if (check) {
50
- log.info(`checked ${report.filesChecked} .vmz file(s); ${report.filesNeedWrite} need write`);
51
- if (report.filesNeedWrite > 0)
52
- exit = 1;
53
- }
54
- else {
55
- log.info(`formatted ${report.filesWritten}/${report.filesChecked} .vmz file(s)`);
56
- }
57
- if (errors)
58
- exit = 1;
59
- }
60
- finally {
61
- ws.dispose();
62
- }
49
+ else {
50
+ log.info(`format ${scope}: ${report.formatted} file(s) updated, ${report.unchanged} unchanged`);
63
51
  }
64
52
  return exit;
65
53
  }
@@ -1,16 +1,13 @@
1
1
  /**
2
2
  * `vmz.config` `format` resolution for `vmz format`.
3
+ *
4
+ * Scope always comes from the explicit CLI path — config only narrows
5
+ * (`excludes`) and styles. There are no config-driven `includes`.
3
6
  */
4
- import type { VmzFormatConfig } from '@vmz/plugin';
7
+ import type { VmzFormatConfig } from '../workspace/user-config.js';
5
8
  export type ResolvedFormatOptions = {
6
- includes?: string[];
7
9
  excludes: string[];
8
- rust: boolean;
9
- javascript: boolean;
10
- vmz: boolean;
11
10
  style: string;
12
11
  };
13
- /** VMZ hybrid monorepo — JS/TS surfaces only, never whole-repo walk. */
14
- export declare const VMZ_FRAMEWORK_INCLUDES: readonly ["scripts/**", "packages/runtimes/**", "packages/examples/**", "packages/editors/**", "packages/ui/**", "packages/plugins/**", "packages/content/**", "packages/homepage/**", "package.json", "biome.json", "vmz.config.ts", "nifty.config.ts"];
15
- /** Merge `vmz.config` `format` with framework monorepo defaults. */
16
- export declare function resolveFormatConfig(projectRoot: string, format?: VmzFormatConfig): ResolvedFormatOptions;
12
+ /** Merge `vmz.config` `format` excludes / style with the defaults. */
13
+ export declare function resolveFormatConfig(format?: VmzFormatConfig | null): ResolvedFormatOptions;
@@ -1,38 +1,14 @@
1
1
  /**
2
2
  * `vmz.config` `format` resolution for `vmz format`.
3
+ *
4
+ * Scope always comes from the explicit CLI path — config only narrows
5
+ * (`excludes`) and styles. There are no config-driven `includes`.
3
6
  */
4
- import { existsSync } from 'node:fs';
5
- import path from 'node:path';
6
- /** VMZ hybrid monorepo — JS/TS surfaces only, never whole-repo walk. */
7
- export const VMZ_FRAMEWORK_INCLUDES = [
8
- 'scripts/**',
9
- 'packages/runtimes/**',
10
- 'packages/examples/**',
11
- 'packages/editors/**',
12
- 'packages/ui/**',
13
- 'packages/plugins/**',
14
- 'packages/content/**',
15
- 'packages/homepage/**',
16
- 'package.json',
17
- 'biome.json',
18
- 'vmz.config.ts',
19
- 'nifty.config.ts',
20
- ];
21
7
  const DEFAULT_EXCLUDES = ['**/fixtures/**', '**/dist/**', '**/node_modules/**', '**/target/**'];
22
- function isFrameworkMonorepoRoot(projectRoot) {
23
- return existsSync(path.join(projectRoot, 'packages', 'runtimes'));
24
- }
25
- /** Merge `vmz.config` `format` with framework monorepo defaults. */
26
- export function resolveFormatConfig(projectRoot, format) {
27
- const frameworkRoot = isFrameworkMonorepoRoot(projectRoot);
28
- const hasCargo = existsSync(path.join(projectRoot, 'Cargo.toml'));
29
- const hasFormatSection = format !== undefined;
8
+ /** Merge `vmz.config` `format` excludes / style with the defaults. */
9
+ export function resolveFormatConfig(format) {
30
10
  return {
31
- includes: format?.includes ?? (frameworkRoot ? [...VMZ_FRAMEWORK_INCLUDES] : undefined),
32
11
  excludes: [...DEFAULT_EXCLUDES, ...(format?.excludes ?? [])],
33
- rust: format?.rust ?? (hasCargo && (frameworkRoot || hasFormatSection)),
34
- javascript: format?.javascript ?? (frameworkRoot || hasFormatSection),
35
- vmz: format?.vmz ?? true,
36
12
  style: format?.style ?? 'biome.json',
37
13
  };
38
14
  }
@@ -391,7 +391,7 @@ export function semanticIdsForAssembly(assembly) {
391
391
  case 'rust-embedded':
392
392
  return ['site-fallback', 'asset-graph'];
393
393
  case 'local-static':
394
- return ['asset-graph'];
394
+ return ['static-delivery', 'asset-graph'];
395
395
  default:
396
396
  return [];
397
397
  }
@@ -36,14 +36,12 @@ export interface DevReloadPayload {
36
36
  islandHmr?: boolean;
37
37
  rerunLoaders?: string[];
38
38
  staticRevision?: string;
39
- skipEntryRewrite?: boolean;
40
39
  outputRevision?: string;
41
40
  }
42
41
  export declare function parseHmrPlan(raw: string | object | null | undefined): HmrPlanWire | null;
43
42
  export declare function hmrRerunLoaders(plan: HmrPlanWire | null | undefined): string[];
44
43
  export declare function buildReloadPayload(report: BuildReportWire, hmrPlan: HmrPlanWire | null, opts?: {
45
44
  staticRevision?: string;
46
- skipEntryRewrite?: boolean;
47
45
  }): DevReloadPayload;
48
46
  export declare function shouldSoftReload(report: BuildReportWire, lastOutputRevision: string | null, opts?: {
49
47
  force?: boolean;
@@ -38,7 +38,6 @@ export function buildReloadPayload(report, hmrPlan, opts = {}) {
38
38
  islandHmr: islandHmr && !full,
39
39
  rerunLoaders,
40
40
  staticRevision: opts.staticRevision,
41
- skipEntryRewrite: opts.skipEntryRewrite,
42
41
  outputRevision: report.outputRevision ?? report.output_revision,
43
42
  };
44
43
  }
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import { createWorkspace } from '../workspace/public-api.js';
13
13
  import { type ConfigCycle } from './config-cycle.js';
14
+ import { packFromDeploymentIr } from '../workspace/pack.js';
14
15
  interface DevSessionOptions {
15
16
  project: string;
16
17
  outDir: string;
@@ -28,7 +29,9 @@ interface DevSessionOptions {
28
29
  host: string;
29
30
  port: number;
30
31
  }) => import('node:child_process').ChildProcess;
31
- softReloadFn?: (host: string, port: number, payload?: object) => Promise<void>;
32
+ softReloadFn?: (body: Record<string, unknown>) => Promise<Record<string, unknown>>;
33
+ /** Test seam for the browser pack stage (defaults to `packFromDeploymentIr`). */
34
+ packFn?: typeof packFromDeploymentIr;
32
35
  /** Override the detached config build process (tests). */
33
36
  configCycleFn?: (opts: {
34
37
  project: string;
@@ -38,6 +41,55 @@ interface DevSessionOptions {
38
41
  /** Built config cycle worker path (defaults to `dist/dev/config-cycle-worker.js`). */
39
42
  configCycleWorkerPath?: string;
40
43
  }
44
+ export interface PackManifestView {
45
+ chunks?: Array<{
46
+ fileName?: string;
47
+ sourceMap?: string;
48
+ modules?: unknown[];
49
+ }>;
50
+ styles?: Array<{
51
+ fileName?: string;
52
+ sourcePaths?: unknown[];
53
+ }>;
54
+ assets?: Array<{
55
+ fileName?: string;
56
+ }>;
57
+ entryFiles?: Array<{
58
+ file?: string;
59
+ }>;
60
+ dynamicFiles?: Array<{
61
+ from?: string;
62
+ to?: string;
63
+ }>;
64
+ unitChunks?: Array<{
65
+ fileName?: string | null;
66
+ }>;
67
+ }
68
+ export interface PackInputSnapshot {
69
+ files: Array<{
70
+ path: string;
71
+ digest: string;
72
+ }>;
73
+ listings: Array<{
74
+ dir: string;
75
+ names: string[];
76
+ }>;
77
+ deploymentOrigins: string;
78
+ lockfile: {
79
+ path: string;
80
+ digest: string;
81
+ };
82
+ manifest: {
83
+ path: string;
84
+ digest: string;
85
+ };
86
+ }
87
+ /** 记下决定 pack 产物的全部输入;任何一项取不到就放弃快照(等同于永远重打包)。 */
88
+ export declare function capturePackInputSnapshot(manifest: PackManifestView, outDir: string, project: string): PackInputSnapshot | null;
89
+ /** 返回 null 表示全部输入字节全等;否则返回第一个变化原因。 */
90
+ export declare function packInputsChangedReason(snapshot: PackInputSnapshot, outDir: string): string | null;
91
+ /** 复用上次 manifest 前确认 entry/chunk/island 查表指向的文件仍在盘上;缺任何一个就退回真实 pack。 */
92
+ export declare function missingPackOutput(manifest: PackManifestView, outDir: string): string | null;
41
93
  export declare function createDevSession(options: DevSessionOptions): {
42
94
  ws: any;
43
95
  rebuild: (changes?: Array<{