// The frontend orchestration: resolve the core's import graph (teaching // diagnostics for every module-boundary mistake), check every module with // the provider's own checker (same semantics as the author-facing tsc by // upstream design), run the subset checker, run integer inference, then — // when asked — emit the contract sidecar for the whole graph. The // external core compiler does the compiling; this pass is the subset's // teaching surface and the contract source. import { ts, TypedAst, createSubsetProgram, lineColumn } from "./typed_ast.ts"; import { resolveModuleGraph } from "./modules.ts"; import { TypeTable } from "./types.ts"; import { IntInference } from "./infer.ts"; import { SubsetChecker } from "./checker.ts"; import type { PersistRoutes } from "./checker.ts"; import { emitContractSidecar, ContractError } from "./contract.ts"; import { emitServiceContract, type ServicePackage } from "./service_contract.ts"; import { makeDiagnostic, formatDiagnostic, type SubsetDiagnostic } from "./diagnostics.ts"; import path from "node:path"; import fs from "node:fs"; export interface FrontendOptions { /// When set, also emit the contract sidecar (core.contract.json, /// schema format 1) from the checked program — the entry spelling the /// document states (never a filesystem-absolute leak). readonly contractEntry?: string; /// Ask the CLI/API caller to consume services.contract.json. The service /// surface is analyzed whenever src/services exists because core request /// names validate against it; this flag records emission intent. readonly servicesContract?: boolean; /// Exact checked-in npm package facts from app.zon. Bare imports in the /// service class are accepted only when named here; the sidecar carries /// the same name/version/hash facts into the offline staging gate. readonly servicePackages?: readonly ServicePackage[]; /// app.zon capabilities supplied by the build/check launcher. The core /// frontend stays manifest-format agnostic; it needs only declared names /// for capability-backed effect diagnostics. readonly capabilities?: readonly string[]; /// app.zon permissions supplied beside capabilities. Core credential /// effects are refused unless the explicit runtime grant is present. readonly permissions?: readonly string[]; /// Manifest schema version for engine-owned model persistence. When a /// state path is also supplied, the frontend remembers the last accepted /// version/fingerprint pair and warns if a shape moves without a bump. readonly persistVersion?: number; readonly persistStatePath?: string; /// app.zon's persistence restore routes, projected without manifest syntax /// so the frontend can validate them against the core's Msg union. readonly persistRoutes?: PersistRoutes; /// Generated @native-sdk/core surface carrying declared SQLite query /// constructors. Omitted for non-relational apps and direct checker tests. readonly sdkCorePath?: string; /// Statically compiled secondary-window view labels discovered from direct /// `src/windows/