import type { Rolldown } from 'vite'; import type { MiniGeneratedSubpackage } from '../mini-contract.ts'; /** Identifies one generated code-only subpackage by its physical output root. */ export type SubpackageLocation = { /** Discriminates generated subpackages from main. */ kind: 'subpackage'; /** Native subpackage root relative to the Mini Program output directory. */ root: string; }; /** Physical package ownership for one final Rolldown chunk. */ export type PackageLocation = { kind: 'main'; } | SubpackageLocation; /** One generated code package retained by the final output graph. */ export type GeneratedSubpackage = MiniGeneratedSubpackage; /** Immutable ownership and materialization operations for one complete final-chunk graph. */ export type Placement = Readonly<{ getPackageLocation(chunk: Rolldown.RenderedChunk | Rolldown.OutputChunk): PackageLocation; /** Resolves a rendered chunk or its exact entry module ID to its planned physical path. */ getPhysicalChunkId(chunk: Rolldown.RenderedChunk | string): string; finalize(bundle: Rolldown.OutputBundle): readonly GeneratedSubpackage[]; }>; /** * Applies Load-Transition Hypergraph Partitioning to Rolldown's final preliminary chunk graph: * * 1. Sort preliminary filenames to remove callback and object-enumeration order from every later decision. * 2. Reserve every explicit entry and its complete static closure in main because native startup must load it synchronously. * 3. Treat each dynamic-import edge as one load transition; the target's static closure is that transition's hyperedge. * Nested dynamic edges remain separate transitions rather than being folded into the parent closure. * 4. Index every lazy chunk by all transitions requiring it. Shared chunks therefore carry global demand rather than being * assigned according to the first source module or dynamic root that happens to visit them. * 5. Order chunks by transition demand, estimated emitted bytes, then preliminary filename. Place each chunk once into the * fitting bin with maximum transition overlap, using best-fit remaining capacity only as a tie-breaker. * 6. Hash each bin's sorted preliminary filenames into a deterministic physical package root and return unique ownership. * * Analysis costs the sum of transition static-closure traversals. Packing scans fitting bins and intersects sparse * transition sets; its worst case is O(CBT), while practical graphs have few bins and sparse transition membership. */ export declare function createPlacement({ chunks, planningBudgetBytes, getAdditionalModuleBytes }: { chunks: Readonly>; planningBudgetBytes: number; getAdditionalModuleBytes(moduleId: string): number; }): Placement; /** Tests the plugin-owned output prefix that physically identifies every generated subpackage. */ export declare function isGeneratedSubpackageFile(fileName: string): boolean;