import { Plugin } from "vite"; //#region src/index.d.ts interface MoonbitPluginOptions { /** * Root directory of the MoonBit project (where moon.mod.json is located) * @default process.cwd() */ root?: string; /** * Whether to start `moon build --watch` subprocess * @default true in dev mode */ watch?: boolean; /** * Build mode: "release" or "debug" * @default "release" */ mode?: "release" | "debug"; /** * Build target: "js", "wasm", or "wasm-gc" * @default "js" */ target?: "js" | "wasm" | "wasm-gc"; /** * Whether to show MoonBit build logs * @default true */ showLogs?: boolean; /** * Enables support for JS String Builtins in `wasm-gc` target. * Required when using `"use-js-builtin-string": true` in MoonBit configuration. * If left undefined, the plugin auto-detects it by scanning the member * packages' `moon.pkg(.json)` files for `link.wasm-gc.use-js-builtin-string`. * * @default auto-detected from moon.pkg files */ useJsBuiltinString?: boolean; /** * Strictly type-check TypeScript entrypoints through the `mizchi/ts/mtsc` * MoonBit JavaScript module, then generate MoonBit bridge packages before * starting `moon build`. */ tsBridge?: MoonbitTsBridgeOptions; /** * Experimental: post-process MoonBit-generated `_build/.../*.d.ts` files with * `mizchi/ts.mbt` to emit clearer TypeScript declarations in place. * The normalized output shape may still change between releases. */ normalizedDts?: MoonbitNormalizedDtsOptions; /** * Generate an npm-publishable ESM package from a MoonBit package. The output * contains JavaScript, `.d.ts`, and `package.json`, so it can be published * without exposing MoonBit-specific build glue. */ npmPackage?: MoonbitNpmPackageOptions; /** * Import prefix used to identify MoonBit modules. Change this when loading * the plugin more than once in a single project to mix multiple backends: * * plugins: [ * moonbit({ target: "js" }), // mbt:foo * moonbit({ target: "wasm-gc", prefix: "mbtw:" }), // mbtw:foo * ] * * The prefix must end with `":"`. * * @default "mbt:" */ prefix?: string; } interface MoonbitTsBridgeEntrySpec { /** * TypeScript / TSX / declaration entrypoint. Resolved relative to the Vite root. */ entry: string; /** * Runtime module specifier imported by the generated `bridge.js`. * Prefer non-relative specifiers like `/src/api/client.ts`, `node:fs`, or a * bare package name. Relative specs still work, but they prevent the * generator from using some direct `#module("...")` MoonBit externs. */ moduleSpec: string; /** * Output package directory inside the MoonBit project. Resolved relative to `root`. */ outDir: string; } interface MoonbitTsBridgePackageEntrySpec { /** * npm package whose declaration file should be bridged. A package subpath is * supported, for example `@types/node/fs` resolves `fs.d.ts` from * `@types/node`. */ package: string; /** Runtime module specifier imported by the generated `bridge.js`. */ moduleSpec?: string; /** Output package directory inside the MoonBit project. */ outDir?: string; } type MoonbitTsBridgeEntry = string | (Partial & Pick) | MoonbitTsBridgePackageEntrySpec; interface MoonbitTsBridgeOptions { /** * Path to the `mizchi/ts.mbt` checkout. Resolved relative to the Vite root. * The plugin builds `src/mtsc` for the JS target and imports its * `checkModuleGraph` export directly before generating a bridge. */ generatorRoot: string; /** * Command used to build the `mtsc` JS module and invoke the generator. * @default "moon" */ command?: string; /** * Emit explicit `validate(JSValue)` boundary functions for generated * structural types. Disabled by default so existing bridge APIs and runtime * cost remain unchanged. * * @default false */ runtimeValidation?: boolean; /** Bridge package generation specs. */ entries: MoonbitTsBridgeEntry[]; } interface MoonbitNormalizedDtsOptions { /** * Optional path to the `mizchi/ts.mbt` checkout. Resolved relative to the * Vite root. When omitted, `tsBridge.generatorRoot` is reused if available. */ generatorRoot?: string; /** * Optional command used to invoke the generator. * When omitted, `tsBridge.command` is reused if available. * * @default "moon" */ command?: string; } interface MoonbitNpmPackageOptions { /** * MoonBit package name (for example `internal/app`) or a path to its * `pkg.generated.mbti`. Package names are resolved from this Vite project's * MoonBit workspace. */ entry: string; /** * Directory that becomes the publishable npm package. Resolved relative to * the Vite root. */ outDir: string; /** * Path to the `mizchi/ts.mbt` checkout. Defaults to `tsBridge.generatorRoot` * when that integration is enabled. */ generatorRoot?: string; /** Command used for `moon info` and `mbt2ts`. @default "moon" */ command?: string; /** * npm package name to write into the generated `package.json`. * Defaults to the MoonBit package name derived by `mbt2ts`. */ name?: string; /** * npm package version to write into the generated `package.json`. * Defaults to the version emitted by `mbt2ts`. */ version?: string; /** * Generate callable wrappers for eligible MoonBit methods and constructors. * @default true */ facade?: boolean; /** Reject the package when public MoonBit members cannot be autolinked. */ strict?: boolean; /** Optional import-rewrite JSON file for external MoonBit package imports. */ importRewrites?: string; /** Optional path for copied autolink diagnostics. */ diagnostics?: string; /** * Bundle MoonBit's generated JS together with local TypeScript bridge * modules into the published `index.js`. Disable only when the consumer * will provide every runtime import itself. * @default true */ bundle?: boolean; } declare function moonbitPlugin(options?: MoonbitPluginOptions): Plugin; //#endregion export { MoonbitNormalizedDtsOptions, MoonbitNpmPackageOptions, MoonbitPluginOptions, MoonbitTsBridgeEntry, MoonbitTsBridgeEntrySpec, MoonbitTsBridgeOptions, MoonbitTsBridgePackageEntrySpec, moonbitPlugin as default, moonbitPlugin as moonbit }; //# sourceMappingURL=index.d.mts.map