lit-xml
Version:
Burning your XML documents to the ground? Yes please. In the mean time, let's use lit-xml.
51 lines (43 loc) • 1.86 kB
TypeScript
declare function isWellFormed(xml: string): void;
declare const validators_isWellFormed: typeof isWellFormed;
declare namespace validators {
export { validators_isWellFormed as isWellFormed };
}
type Validator = (maybeValidXml: string) => void;
interface LitXmlOptions {
readonly validators: Validator[];
readonly format: boolean;
readonly indent: number;
/**
* Enable strict mode for the template values.
* This mode requires all template values to be a xml primitive (`string | number | boolean | bigint | XmlFragment | XmlFragment[]`)
*/
readonly strictTemplateValues: boolean;
}
declare class XmlFragment {
private xmlLiterals;
private values;
private options;
constructor(xmlLiterals: TemplateStringsArray, values: unknown[], options: LitXmlOptions);
toString(): string;
/**
* @internal
*/
toStringRaw(): string;
}
type XmlPrimitive = string | number | boolean | bigint | XmlFragment | XmlFragment[];
type XmlTemplateLiteralTag<T> = (xmlLiterals: TemplateStringsArray, ...values: T[]) => XmlFragment;
type XmlTemplateLiteral = XmlTemplateLiteralTag<unknown>;
type StrictXmlTemplateLiteral = XmlTemplateLiteralTag<XmlPrimitive>;
declare function createLitXml<T extends Partial<LitXmlOptions>>(overrideOptions?: T): XmlTemplateLiteralTag<T extends {
strictTemplateValues: true;
} ? XmlPrimitive : unknown>;
declare namespace createLitXml {
var inject: readonly ["lit-xml-options"];
}
declare const xml: XmlTemplateLiteralTag<unknown>;
declare class InvalidXmlError extends Error {
xmlDocument: string;
constructor(line: number, message: string, xmlDocument: string);
}
export { InvalidXmlError, type StrictXmlTemplateLiteral, type Validator, XmlFragment, type XmlPrimitive, type XmlTemplateLiteral, type XmlTemplateLiteralTag, createLitXml, validators, xml };