import { ProgressTracker } from '@php-wasm/progress'; import { Semaphore } from '@php-wasm/util'; import type { AllPHPVersion, UniversalPHP } from '@php-wasm/universal'; import type { Step, StepDefinition } from '../steps'; import type { BlueprintV1Declaration, ExtraLibrary, StreamBundledFile, BlueprintV1 } from './types'; import type { BlueprintBundle } from '../types'; import type { ErrorObject } from 'ajv'; export declare class InvalidBlueprintError extends Error { readonly validationErrors?: unknown; constructor(message: string, validationErrors?: unknown); } /** * Error thrown when a single Blueprint step fails during execution. * * This error carries structured information about the failing step so that * consumers (e.g. the Playground UI) do not have to parse human‑readable * error messages to understand what went wrong. */ export declare class BlueprintStepExecutionError extends Error { readonly stepNumber: number; readonly step: StepDefinition; readonly messages: string[]; constructor(options: { stepNumber: number; step: StepDefinition; cause: unknown; }); } export type CompiledV1Step = (php: UniversalPHP) => Promise | void; export interface CompiledBlueprintV1 { /** The requested versions of PHP and WordPress for the blueprint */ versions: { php: AllPHPVersion; wp: string; }; features: { /** Should boot with support for Intl dynamic extension */ intl: boolean; /** Should boot with support for network request via wp_safe_remote_get? */ networking: boolean; }; extraLibraries: ExtraLibrary[]; /** The compiled steps for the blueprint */ run: (playground: UniversalPHP) => Promise; } export type OnStepCompleted = (output: any, step: StepDefinition) => any; export interface CompileBlueprintV1Options { /** Optional progress tracker to monitor progress */ progress?: ProgressTracker; /** Optional semaphore to control access to a shared resource */ semaphore?: Semaphore; /** Optional callback with step output */ onStepCompleted?: OnStepCompleted; /** Optional callback with blueprint validation result */ onBlueprintValidated?: (blueprint: BlueprintV1Declaration) => void; /** * Proxy URL to use for cross-origin requests. * * For example, if corsProxy is set to "https://cors.wordpress.net/proxy.php", * then the CORS requests to https://github.com/WordPress/gutenberg.git would actually * be made to https://cors.wordpress.net/proxy.php?https://github.com/WordPress/gutenberg.git. */ corsProxy?: string; /** * A filesystem to use for the blueprint. */ streamBundledFile?: StreamBundledFile; /** * Additional headers to pass to git operations. * A function that returns headers based on the URL being accessed. */ gitAdditionalHeadersCallback?: (url: string) => Record; /** * Additional steps to add to the blueprint. */ additionalSteps?: any[]; } export declare function compileBlueprintV1(input: BlueprintV1Declaration | BlueprintBundle, options?: Omit): Promise; export declare function isBlueprintBundle(input: any): input is BlueprintBundle; export declare function getBlueprintDeclaration(blueprint: BlueprintV1 | BlueprintBundle): Promise; export type BlueprintValidationResult = { valid: true; } | { valid: false; errors: ErrorObject[]; }; export declare function validateBlueprint(blueprintMaybe: object): BlueprintValidationResult; /** * Determines if a step is a StepDefinition object * * @param step The object to test * @returns Whether the object is a StepDefinition */ export declare function isStepDefinition(step: Step | string | undefined | false | null): step is StepDefinition; export declare function runBlueprintV1Steps(compiledBlueprint: CompiledBlueprintV1, playground: UniversalPHP): Promise;