import { ParsingWarningOrError, PdJson } from '@webpd/pd-parser'; import { NodeBuilders } from './types'; interface AbstractionLoaderSuccess { status: 0; pd: PdJson.Pd; parsingWarnings?: Array; } interface AbstractionLoaderFailure { status: 1; parsingWarnings?: Array; unknownNodeType?: PdJson.NodeType; parsingErrors?: Array; } type AbstractionLoaderResult = AbstractionLoaderSuccess | AbstractionLoaderFailure; /** * An aync function that is passed to the parser and has for role * to fetch/load/... any node type that is not yet known to the parser. * If fetching that new node type fails (because of a parsing error, * or because the node is not known), the function can return `{status: 1}` * with the appropriate error fields. */ export type AbstractionLoader = (nodeType: PdJson.NodeType) => Promise; type Abstractions = { [nodeType: string]: PdJson.Pd; }; export type AbstractionsLoadingErrors = { [nodeType: string]: { unknownNodeType?: PdJson.NodeType; parsingErrors?: Array; }; }; export type AbstractionsLoadingWarnings = { [nodeType: string]: Array; }; export type NodeTypes = Set; interface CompilationSuccess { readonly status: 0; readonly pd: PdJson.Pd; readonly abstractions: Abstractions; readonly warnings: AbstractionsLoadingWarnings; } interface CompilationFailure { readonly status: 1; readonly pd: PdJson.Pd; readonly errors: AbstractionsLoadingErrors; readonly warnings: AbstractionsLoadingWarnings; } type CompilationResult = CompilationSuccess | CompilationFailure; /** * Goes through a pd object, resolves and instantiates abstractions, turning * them into standard subpatches. * @returns A new PdJson.Pd object, which contains all patches and arrays * from the resolved abstraction as well as those from the pd object passed as argument. * The second value returned is the main root patch to be used for further processing. */ declare const _default: (pd: PdJson.Pd, nodeBuilders: NodeBuilders, abstractionLoader: AbstractionLoader) => Promise; export default _default;