export interface NotificationOptions { title: string; body?: string; icon: string; duration?: "short" | "long"; silent?: boolean; progress?: { status?: string; value: number; valueOverride: string; }; } function escape(string: string) { return string.replace(/[<>&'"]/g, (match) => { switch (match) { case "<": return "<"; case ">": return ">"; case "&": return "&"; case "'": return "'"; case '"': return """; default: return ""; } }); } function addAttributeOrTrim(name: string, value: string) { return value ? `${name}="${value}" ` : ""; } export function toXmlString(options: NotificationOptions) { let template = ""; //Visual template += ``; if (options.icon) template += ``; template += `` + ``; //Progress bar if (options.progress) { template += ""; } template += ""; //Actions template += ""; template += ""; //Audio template += ""; return template; }