diff = (leftOrPatch, right, options = {}) => {
const defaults = {
wrapper: htl.html`<div>`,
outputFormat: "side-by-side",
drawFileList: false,
drawFileHeaders: false,
css: '',
};
const { wrapper, drawFileHeaders, css, ...opts } = { ...defaults, ...options };
const diff = right == null ? leftOrPatch : jsdiff.createTwoFilesPatch(
leftOrPatch.name || "left",
right.name || "right",
"" + leftOrPatch,
"" + right,
undefined,
undefined,
{ context: options.context || 2 }
);
const json = diff2html.parse(diff);
const root = wrapper.attachShadow({mode: "open"});
root.innerHTML = diff2html.html(json, opts);
root.appendChild(htl.html`<style>${defaultCSS}${css}`);
if (!drawFileHeaders) {
for (const n of root.querySelectorAll(".d2h-file-header")) n.remove();
}
return wrapper;
}