webpd
Version:
WebPd is a compiler for audio programming language Pure Data allowing to run .pd patches on web pages.
50 lines (49 loc) • 1.82 kB
TypeScript
import { Artefacts, BuildSettings } from './types';
import { BuildFormat } from './formats';
interface BuildSuccess {
status: 0;
warnings: Array<string>;
}
interface BuildFailure {
status: 1;
warnings: Array<string>;
errors: Array<string>;
}
export type BuildResult = BuildSuccess | BuildFailure;
/**
* Simple build function to compile a Pd patch into compiled code
* that can be directly run into a web app.
*
* Throws an error if the build fails.
*
* @see performBuildStep
*/
export declare const buildRunnable: (pdFile: string, format: 'javascript' | 'wasm', settings: BuildSettings) => Promise<string | ArrayBuffer>;
export declare const defaultSettingsForBuild: () => BuildSettings;
/**
* @returns an empty artefacts object.
*/
export declare const createArtefacts: () => Artefacts;
/**
* Helper to unpack an artefact from an ArrayBuffer into its correct format.
* Useful for example to load artefacts from files or http requests.
*
* @returns a new artefacts object.
*/
export declare const loadArtefact: (artefacts: Artefacts, artefactBuffer: ArrayBuffer, artefactFormat: BuildFormat) => Artefacts;
/**
* A helper to perform a build step on a given artefacts object.
* If the build is successful, the artefacts object is updated in place with
* the newly built artefact.
*
* Beware that this can only build one step at a time. If targetting a given format
* requires multiple steps, you need to call this function multiple times with intermediate targets.
*
* @see fromPatch
*
* @param artefacts
* @param target
* @param settings
*/
export declare const performBuildStep: (artefacts: Artefacts, target: BuildFormat, { nodeBuilders, nodeImplementations, audioSettings, renderAudioSettings, io, abstractionLoader, }: BuildSettings) => Promise<BuildResult>;
export {};