New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More โ†’
Socket
Sign inDemoInstall
Socket

diff2html

Package Overview
Dependencies
Maintainers
1
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diff2html - npm Package Compare versions

Comparing version 3.4.43 to 3.4.44

4

lib-esm/diff2html-templates.js
import * as Hogan from "hogan.js";
export const defaultTemplates = {};
defaultTemplates["file-summary-line"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<li class=\"d2h-file-list-line\">"); t.b("\n" + i); t.b(" <span class=\"d2h-file-name-wrapper\">"); t.b("\n" + i); t.b(t.rp("<fileIcon0", c, p, " ")); t.b(" <a href=\"#"); t.b(t.v(t.f("fileHtmlId", c, p, 0))); t.b("\" class=\"d2h-file-name\">"); t.b(t.v(t.f("fileName", c, p, 0))); t.b("</a>"); t.b("\n" + i); t.b(" <span class=\"d2h-file-stats\">"); t.b("\n" + i); t.b(" <span class=\"d2h-lines-added\">"); t.b(t.v(t.f("addedLines", c, p, 0))); t.b("</span>"); t.b("\n" + i); t.b(" <span class=\"d2h-lines-deleted\">"); t.b(t.v(t.f("deletedLines", c, p, 0))); t.b("</span>"); t.b("\n" + i); t.b(" </span>"); t.b("\n" + i); t.b(" </span>"); t.b("\n" + i); t.b("</li>"); return t.fl(); }, partials: { "<fileIcon0": { name: "fileIcon", partials: {}, subs: {} } }, subs: {} });
defaultTemplates["file-summary-wrapper"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"d2h-file-list-wrapper\">"); t.b("\n" + i); t.b(" <div class=\"d2h-file-list-header\">"); t.b("\n" + i); t.b(" <span class=\"d2h-file-list-title\">Files changed ("); t.b(t.v(t.f("filesNumber", c, p, 0))); t.b(")</span>"); t.b("\n" + i); t.b(" <a class=\"d2h-file-switch d2h-hide\">hide</a>"); t.b("\n" + i); t.b(" <a class=\"d2h-file-switch d2h-show\">show</a>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" <ol class=\"d2h-file-list\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("files", c, p, 0))); t.b("\n" + i); t.b(" </ol>"); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
defaultTemplates["file-summary-wrapper"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"d2h-file-list-wrapper "); t.b(t.v(t.f("colorScheme", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\"d2h-file-list-header\">"); t.b("\n" + i); t.b(" <span class=\"d2h-file-list-title\">Files changed ("); t.b(t.v(t.f("filesNumber", c, p, 0))); t.b(")</span>"); t.b("\n" + i); t.b(" <a class=\"d2h-file-switch d2h-hide\">hide</a>"); t.b("\n" + i); t.b(" <a class=\"d2h-file-switch d2h-show\">show</a>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" <ol class=\"d2h-file-list\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("files", c, p, 0))); t.b("\n" + i); t.b(" </ol>"); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
defaultTemplates["generic-block-header"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<tr>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.f("lineClass", c, p, 0))); t.b(" "); t.b(t.v(t.d("CSSLineClass.INFO", c, p, 0))); t.b("\"></td>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.d("CSSLineClass.INFO", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\""); t.b(t.v(t.f("contentClass", c, p, 0))); t.b("\">"); if (t.s(t.f("blockHeader", c, p, 1), c, p, 0, 156, 173, "{{ }}")) {

@@ -26,3 +26,3 @@ t.rs(c, p, function (c, p, t) { t.b(t.t(t.f("blockHeader", c, p, 0))); });

} ; t.b(" </div>"); t.b("\n" + i); t.b(" </td>"); t.b("\n" + i); t.b("</tr>"); return t.fl(); }, partials: {}, subs: {} });
defaultTemplates["generic-wrapper"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"d2h-wrapper\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("content", c, p, 0))); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
defaultTemplates["generic-wrapper"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"d2h-wrapper "); t.b(t.v(t.f("colorScheme", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("content", c, p, 0))); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
defaultTemplates["icon-file-added"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon d2h-added\" height=\"16\" title=\"added\" version=\"1.1\" viewBox=\"0 0 14 16\""); t.b("\n" + i); t.b(" width=\"14\">"); t.b("\n" + i); t.b(" <path d=\"M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM6 9H3V7h3V4h2v3h3v2H8v3H6V9z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });

@@ -29,0 +29,0 @@ defaultTemplates["icon-file-changed"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon d2h-changed\" height=\"16\" title=\"modified\" version=\"1.1\""); t.b("\n" + i); t.b(" viewBox=\"0 0 14 16\" width=\"14\">"); t.b("\n" + i); t.b(" <path d=\"M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });

@@ -20,2 +20,3 @@ import * as DiffParser from './diff-parser';

diffStyle: import("./types").DiffStyleType;
colorScheme: import("./types").ColorSchemeType;
};

@@ -22,0 +23,0 @@ export declare function parse(diffInput: string, configuration?: Diff2HtmlConfig): DiffFile[];

import * as DiffParser from './diff-parser';
import * as fileListPrinter from './file-list-renderer';
import { FileListRenderer } from './file-list-renderer';
import LineByLineRenderer, { defaultLineByLineRendererConfig } from './line-by-line-renderer';

@@ -15,3 +15,5 @@ import SideBySideRenderer, { defaultSideBySideRendererConfig } from './side-by-side-renderer';

const hoganUtils = new HoganJsUtils(config);
const fileList = config.drawFileList ? fileListPrinter.render(diffJson, hoganUtils) : '';
const { colorScheme } = config;
const fileListRendererConfig = { colorScheme };
const fileList = config.drawFileList ? new FileListRenderer(hoganUtils, fileListRendererConfig).render(diffJson) : '';
const diffOutput = config.outputFormat === 'side-by-side'

@@ -18,0 +20,0 @@ ? new SideBySideRenderer(hoganUtils, config).render(diffJson)

import HoganJsUtils from './hoganjs-utils';
import { DiffFile } from './types';
export declare function render(diffFiles: DiffFile[], hoganUtils: HoganJsUtils): string;
import { ColorSchemeType, DiffFile } from './types';
export interface FileListRendererConfig {
colorScheme?: ColorSchemeType;
}
export declare const defaultFileListRendererConfig: {
colorScheme: ColorSchemeType;
};
export declare class FileListRenderer {
private readonly hoganUtils;
private readonly config;
constructor(hoganUtils: HoganJsUtils, config?: FileListRendererConfig);
render(diffFiles: DiffFile[]): string;
}
//# sourceMappingURL=file-list-renderer.d.ts.map
import * as renderUtils from './render-utils';
const baseTemplatesPath = 'file-summary';
const iconsBaseTemplatesPath = 'icon';
export function render(diffFiles, hoganUtils) {
const files = diffFiles
.map(file => hoganUtils.render(baseTemplatesPath, 'line', {
fileHtmlId: renderUtils.getHtmlId(file),
oldName: file.oldName,
newName: file.newName,
fileName: renderUtils.filenameDiff(file),
deletedLines: '-' + file.deletedLines,
addedLines: '+' + file.addedLines,
}, {
fileIcon: hoganUtils.template(iconsBaseTemplatesPath, renderUtils.getFileIcon(file)),
}))
.join('\n');
return hoganUtils.render(baseTemplatesPath, 'wrapper', {
filesNumber: diffFiles.length,
files: files,
});
export const defaultFileListRendererConfig = {
colorScheme: renderUtils.defaultRenderConfig.colorScheme,
};
export class FileListRenderer {
constructor(hoganUtils, config = {}) {
this.hoganUtils = hoganUtils;
this.config = Object.assign(Object.assign({}, defaultFileListRendererConfig), config);
}
render(diffFiles) {
const files = diffFiles
.map(file => this.hoganUtils.render(baseTemplatesPath, 'line', {
fileHtmlId: renderUtils.getHtmlId(file),
oldName: file.oldName,
newName: file.newName,
fileName: renderUtils.filenameDiff(file),
deletedLines: '-' + file.deletedLines,
addedLines: '+' + file.addedLines,
}, {
fileIcon: this.hoganUtils.template(iconsBaseTemplatesPath, renderUtils.getFileIcon(file)),
}))
.join('\n');
return this.hoganUtils.render(baseTemplatesPath, 'wrapper', {
colorScheme: renderUtils.colorSchemeToCss(this.config.colorScheme),
filesNumber: diffFiles.length,
files: files,
});
}
}
//# sourceMappingURL=file-list-renderer.js.map

@@ -18,2 +18,3 @@ import HoganJsUtils from './hoganjs-utils';

diffStyle: import("./types").DiffStyleType;
colorScheme: import("./types").ColorSchemeType;
};

@@ -20,0 +21,0 @@ export default class LineByLineRenderer {

@@ -27,3 +27,6 @@ import * as Rematch from './rematch';

.join('\n');
return this.hoganUtils.render(genericTemplatesPath, 'wrapper', { content: diffsHtml });
return this.hoganUtils.render(genericTemplatesPath, 'wrapper', {
colorScheme: renderUtils.colorSchemeToCss(this.config.colorScheme),
content: diffsHtml,
});
}

@@ -30,0 +33,0 @@ makeFileDiffHtml(file, diffs) {

@@ -1,2 +0,2 @@

import { LineMatchingType, DiffStyleType, LineType, DiffLineParts, DiffFile, DiffFileName } from './types';
import { ColorSchemeType, DiffFile, DiffFileName, DiffLineParts, DiffStyleType, LineMatchingType, LineType } from './types';
export type CSSLineClass = 'd2h-ins' | 'd2h-del' | 'd2h-cntx' | 'd2h-info' | 'd2h-ins d2h-change' | 'd2h-del d2h-change';

@@ -21,2 +21,3 @@ export declare const CSSLineClass: {

diffStyle?: DiffStyleType;
colorScheme?: ColorSchemeType;
}

@@ -28,4 +29,6 @@ export declare const defaultRenderConfig: {

diffStyle: DiffStyleType;
colorScheme: ColorSchemeType;
};
export declare function toCSSClass(lineType: LineType): CSSLineClass;
export declare function colorSchemeToCss(colorScheme: ColorSchemeType): string;
export declare function escapeForHtml(str: string): string;

@@ -32,0 +35,0 @@ export declare function deconstructLine(line: string, isCombined: boolean, escape?: boolean): DiffLineParts;

import * as jsDiff from 'diff';
import { unifyPath, hashCode } from './utils';
import * as rematch from './rematch';
import { LineMatchingType, DiffStyleType, LineType } from './types';
import { ColorSchemeType, DiffStyleType, LineMatchingType, LineType, } from './types';
export const CSSLineClass = {

@@ -18,2 +18,3 @@ INSERTS: 'd2h-ins',

diffStyle: DiffStyleType.WORD,
colorScheme: ColorSchemeType.LIGHT,
};

@@ -42,2 +43,13 @@ const separator = '/';

}
export function colorSchemeToCss(colorScheme) {
switch (colorScheme) {
case ColorSchemeType.DARK:
return 'd2h-dark-color-scheme';
case ColorSchemeType.AUTO:
return 'd2h-auto-color-scheme';
case ColorSchemeType.LIGHT:
default:
return 'd2h-light-color-scheme';
}
}
function prefixLength(isCombined) {

@@ -44,0 +56,0 @@ return isCombined ? 2 : 1;

@@ -18,2 +18,3 @@ import HoganJsUtils from './hoganjs-utils';

diffStyle: import("./types").DiffStyleType;
colorScheme: import("./types").ColorSchemeType;
};

@@ -20,0 +21,0 @@ export default class SideBySideRenderer {

@@ -27,3 +27,6 @@ import * as Rematch from './rematch';

.join('\n');
return this.hoganUtils.render(genericTemplatesPath, 'wrapper', { content: diffsHtml });
return this.hoganUtils.render(genericTemplatesPath, 'wrapper', {
colorScheme: renderUtils.colorSchemeToCss(this.config.colorScheme),
content: diffsHtml,
});
}

@@ -30,0 +33,0 @@ makeFileDiffHtml(file, diffs) {

@@ -75,2 +75,7 @@ export type DiffLineParts = {

};
export declare enum ColorSchemeType {
AUTO = "auto",
DARK = "dark",
LIGHT = "light"
}
//# sourceMappingURL=types.d.ts.map

@@ -20,2 +20,8 @@ export var LineType;

};
export var ColorSchemeType;
(function (ColorSchemeType) {
ColorSchemeType["AUTO"] = "auto";
ColorSchemeType["DARK"] = "dark";
ColorSchemeType["LIGHT"] = "light";
})(ColorSchemeType || (ColorSchemeType = {}));
//# sourceMappingURL=types.js.map

@@ -32,2 +32,3 @@ import { Diff2HtmlConfig } from '../../diff2html';

diffStyle: import("../../types").DiffStyleType;
colorScheme: import("../../types").ColorSchemeType;
};

@@ -34,0 +35,0 @@ export declare class Diff2HtmlUI {

@@ -30,3 +30,3 @@ "use strict";

exports.defaultTemplates["file-summary-line"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<li class=\"d2h-file-list-line\">"); t.b("\n" + i); t.b(" <span class=\"d2h-file-name-wrapper\">"); t.b("\n" + i); t.b(t.rp("<fileIcon0", c, p, " ")); t.b(" <a href=\"#"); t.b(t.v(t.f("fileHtmlId", c, p, 0))); t.b("\" class=\"d2h-file-name\">"); t.b(t.v(t.f("fileName", c, p, 0))); t.b("</a>"); t.b("\n" + i); t.b(" <span class=\"d2h-file-stats\">"); t.b("\n" + i); t.b(" <span class=\"d2h-lines-added\">"); t.b(t.v(t.f("addedLines", c, p, 0))); t.b("</span>"); t.b("\n" + i); t.b(" <span class=\"d2h-lines-deleted\">"); t.b(t.v(t.f("deletedLines", c, p, 0))); t.b("</span>"); t.b("\n" + i); t.b(" </span>"); t.b("\n" + i); t.b(" </span>"); t.b("\n" + i); t.b("</li>"); return t.fl(); }, partials: { "<fileIcon0": { name: "fileIcon", partials: {}, subs: {} } }, subs: {} });
exports.defaultTemplates["file-summary-wrapper"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"d2h-file-list-wrapper\">"); t.b("\n" + i); t.b(" <div class=\"d2h-file-list-header\">"); t.b("\n" + i); t.b(" <span class=\"d2h-file-list-title\">Files changed ("); t.b(t.v(t.f("filesNumber", c, p, 0))); t.b(")</span>"); t.b("\n" + i); t.b(" <a class=\"d2h-file-switch d2h-hide\">hide</a>"); t.b("\n" + i); t.b(" <a class=\"d2h-file-switch d2h-show\">show</a>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" <ol class=\"d2h-file-list\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("files", c, p, 0))); t.b("\n" + i); t.b(" </ol>"); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
exports.defaultTemplates["file-summary-wrapper"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"d2h-file-list-wrapper "); t.b(t.v(t.f("colorScheme", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\"d2h-file-list-header\">"); t.b("\n" + i); t.b(" <span class=\"d2h-file-list-title\">Files changed ("); t.b(t.v(t.f("filesNumber", c, p, 0))); t.b(")</span>"); t.b("\n" + i); t.b(" <a class=\"d2h-file-switch d2h-hide\">hide</a>"); t.b("\n" + i); t.b(" <a class=\"d2h-file-switch d2h-show\">show</a>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" <ol class=\"d2h-file-list\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("files", c, p, 0))); t.b("\n" + i); t.b(" </ol>"); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
exports.defaultTemplates["generic-block-header"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<tr>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.f("lineClass", c, p, 0))); t.b(" "); t.b(t.v(t.d("CSSLineClass.INFO", c, p, 0))); t.b("\"></td>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.d("CSSLineClass.INFO", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\""); t.b(t.v(t.f("contentClass", c, p, 0))); t.b("\">"); if (t.s(t.f("blockHeader", c, p, 1), c, p, 0, 156, 173, "{{ }}")) {

@@ -53,3 +53,3 @@ t.rs(c, p, function (c, p, t) { t.b(t.t(t.f("blockHeader", c, p, 0))); });

} ; t.b(" </div>"); t.b("\n" + i); t.b(" </td>"); t.b("\n" + i); t.b("</tr>"); return t.fl(); }, partials: {}, subs: {} });
exports.defaultTemplates["generic-wrapper"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"d2h-wrapper\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("content", c, p, 0))); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
exports.defaultTemplates["generic-wrapper"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"d2h-wrapper "); t.b(t.v(t.f("colorScheme", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("content", c, p, 0))); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
exports.defaultTemplates["icon-file-added"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon d2h-added\" height=\"16\" title=\"added\" version=\"1.1\" viewBox=\"0 0 14 16\""); t.b("\n" + i); t.b(" width=\"14\">"); t.b("\n" + i); t.b(" <path d=\"M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM6 9H3V7h3V4h2v3h3v2H8v3H6V9z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });

@@ -56,0 +56,0 @@ exports.defaultTemplates["icon-file-changed"] = new Hogan.Template({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon d2h-changed\" height=\"16\" title=\"modified\" version=\"1.1\""); t.b("\n" + i); t.b(" viewBox=\"0 0 14 16\" width=\"14\">"); t.b("\n" + i); t.b(" <path d=\"M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });

@@ -20,2 +20,3 @@ import * as DiffParser from './diff-parser';

diffStyle: import("./types").DiffStyleType;
colorScheme: import("./types").ColorSchemeType;
};

@@ -22,0 +23,0 @@ export declare function parse(diffInput: string, configuration?: Diff2HtmlConfig): DiffFile[];

@@ -31,3 +31,3 @@ "use strict";

const DiffParser = __importStar(require("./diff-parser"));
const fileListPrinter = __importStar(require("./file-list-renderer"));
const file_list_renderer_1 = require("./file-list-renderer");
const line_by_line_renderer_1 = __importStar(require("./line-by-line-renderer"));

@@ -46,3 +46,5 @@ const side_by_side_renderer_1 = __importStar(require("./side-by-side-renderer"));

const hoganUtils = new hoganjs_utils_1.default(config);
const fileList = config.drawFileList ? fileListPrinter.render(diffJson, hoganUtils) : '';
const { colorScheme } = config;
const fileListRendererConfig = { colorScheme };
const fileList = config.drawFileList ? new file_list_renderer_1.FileListRenderer(hoganUtils, fileListRendererConfig).render(diffJson) : '';
const diffOutput = config.outputFormat === 'side-by-side'

@@ -49,0 +51,0 @@ ? new side_by_side_renderer_1.default(hoganUtils, config).render(diffJson)

import HoganJsUtils from './hoganjs-utils';
import { DiffFile } from './types';
export declare function render(diffFiles: DiffFile[], hoganUtils: HoganJsUtils): string;
import { ColorSchemeType, DiffFile } from './types';
export interface FileListRendererConfig {
colorScheme?: ColorSchemeType;
}
export declare const defaultFileListRendererConfig: {
colorScheme: ColorSchemeType;
};
export declare class FileListRenderer {
private readonly hoganUtils;
private readonly config;
constructor(hoganUtils: HoganJsUtils, config?: FileListRendererConfig);
render(diffFiles: DiffFile[]): string;
}
//# sourceMappingURL=file-list-renderer.d.ts.map

@@ -26,25 +26,35 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.render = void 0;
exports.FileListRenderer = exports.defaultFileListRendererConfig = void 0;
const renderUtils = __importStar(require("./render-utils"));
const baseTemplatesPath = 'file-summary';
const iconsBaseTemplatesPath = 'icon';
function render(diffFiles, hoganUtils) {
const files = diffFiles
.map(file => hoganUtils.render(baseTemplatesPath, 'line', {
fileHtmlId: renderUtils.getHtmlId(file),
oldName: file.oldName,
newName: file.newName,
fileName: renderUtils.filenameDiff(file),
deletedLines: '-' + file.deletedLines,
addedLines: '+' + file.addedLines,
}, {
fileIcon: hoganUtils.template(iconsBaseTemplatesPath, renderUtils.getFileIcon(file)),
}))
.join('\n');
return hoganUtils.render(baseTemplatesPath, 'wrapper', {
filesNumber: diffFiles.length,
files: files,
});
exports.defaultFileListRendererConfig = {
colorScheme: renderUtils.defaultRenderConfig.colorScheme,
};
class FileListRenderer {
constructor(hoganUtils, config = {}) {
this.hoganUtils = hoganUtils;
this.config = Object.assign(Object.assign({}, exports.defaultFileListRendererConfig), config);
}
render(diffFiles) {
const files = diffFiles
.map(file => this.hoganUtils.render(baseTemplatesPath, 'line', {
fileHtmlId: renderUtils.getHtmlId(file),
oldName: file.oldName,
newName: file.newName,
fileName: renderUtils.filenameDiff(file),
deletedLines: '-' + file.deletedLines,
addedLines: '+' + file.addedLines,
}, {
fileIcon: this.hoganUtils.template(iconsBaseTemplatesPath, renderUtils.getFileIcon(file)),
}))
.join('\n');
return this.hoganUtils.render(baseTemplatesPath, 'wrapper', {
colorScheme: renderUtils.colorSchemeToCss(this.config.colorScheme),
filesNumber: diffFiles.length,
files: files,
});
}
}
exports.render = render;
exports.FileListRenderer = FileListRenderer;
//# sourceMappingURL=file-list-renderer.js.map

@@ -18,2 +18,3 @@ import HoganJsUtils from './hoganjs-utils';

diffStyle: import("./types").DiffStyleType;
colorScheme: import("./types").ColorSchemeType;
};

@@ -20,0 +21,0 @@ export default class LineByLineRenderer {

@@ -53,3 +53,6 @@ "use strict";

.join('\n');
return this.hoganUtils.render(genericTemplatesPath, 'wrapper', { content: diffsHtml });
return this.hoganUtils.render(genericTemplatesPath, 'wrapper', {
colorScheme: renderUtils.colorSchemeToCss(this.config.colorScheme),
content: diffsHtml,
});
}

@@ -56,0 +59,0 @@ makeFileDiffHtml(file, diffs) {

@@ -1,2 +0,2 @@

import { LineMatchingType, DiffStyleType, LineType, DiffLineParts, DiffFile, DiffFileName } from './types';
import { ColorSchemeType, DiffFile, DiffFileName, DiffLineParts, DiffStyleType, LineMatchingType, LineType } from './types';
export type CSSLineClass = 'd2h-ins' | 'd2h-del' | 'd2h-cntx' | 'd2h-info' | 'd2h-ins d2h-change' | 'd2h-del d2h-change';

@@ -21,2 +21,3 @@ export declare const CSSLineClass: {

diffStyle?: DiffStyleType;
colorScheme?: ColorSchemeType;
}

@@ -28,4 +29,6 @@ export declare const defaultRenderConfig: {

diffStyle: DiffStyleType;
colorScheme: ColorSchemeType;
};
export declare function toCSSClass(lineType: LineType): CSSLineClass;
export declare function colorSchemeToCss(colorScheme: ColorSchemeType): string;
export declare function escapeForHtml(str: string): string;

@@ -32,0 +35,0 @@ export declare function deconstructLine(line: string, isCombined: boolean, escape?: boolean): DiffLineParts;

@@ -26,3 +26,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.diffHighlight = exports.getFileIcon = exports.getHtmlId = exports.filenameDiff = exports.deconstructLine = exports.escapeForHtml = exports.toCSSClass = exports.defaultRenderConfig = exports.CSSLineClass = void 0;
exports.diffHighlight = exports.getFileIcon = exports.getHtmlId = exports.filenameDiff = exports.deconstructLine = exports.escapeForHtml = exports.colorSchemeToCss = exports.toCSSClass = exports.defaultRenderConfig = exports.CSSLineClass = void 0;
const jsDiff = __importStar(require("diff"));

@@ -45,2 +45,3 @@ const utils_1 = require("./utils");

diffStyle: types_1.DiffStyleType.WORD,
colorScheme: types_1.ColorSchemeType.LIGHT,
};

@@ -70,2 +71,14 @@ const separator = '/';

exports.toCSSClass = toCSSClass;
function colorSchemeToCss(colorScheme) {
switch (colorScheme) {
case types_1.ColorSchemeType.DARK:
return 'd2h-dark-color-scheme';
case types_1.ColorSchemeType.AUTO:
return 'd2h-auto-color-scheme';
case types_1.ColorSchemeType.LIGHT:
default:
return 'd2h-light-color-scheme';
}
}
exports.colorSchemeToCss = colorSchemeToCss;
function prefixLength(isCombined) {

@@ -72,0 +85,0 @@ return isCombined ? 2 : 1;

@@ -18,2 +18,3 @@ import HoganJsUtils from './hoganjs-utils';

diffStyle: import("./types").DiffStyleType;
colorScheme: import("./types").ColorSchemeType;
};

@@ -20,0 +21,0 @@ export default class SideBySideRenderer {

@@ -53,3 +53,6 @@ "use strict";

.join('\n');
return this.hoganUtils.render(genericTemplatesPath, 'wrapper', { content: diffsHtml });
return this.hoganUtils.render(genericTemplatesPath, 'wrapper', {
colorScheme: renderUtils.colorSchemeToCss(this.config.colorScheme),
content: diffsHtml,
});
}

@@ -56,0 +59,0 @@ makeFileDiffHtml(file, diffs) {

@@ -20,2 +20,3 @@ import * as DiffParser from './diff-parser';

diffStyle: import("./types").DiffStyleType;
colorScheme: import("./types").ColorSchemeType;
};

@@ -22,0 +23,0 @@ export declare function parse(diffInput: string, configuration?: Diff2HtmlConfig): DiffFile[];

import HoganJsUtils from './hoganjs-utils';
import { DiffFile } from './types';
export declare function render(diffFiles: DiffFile[], hoganUtils: HoganJsUtils): string;
import { ColorSchemeType, DiffFile } from './types';
export interface FileListRendererConfig {
colorScheme?: ColorSchemeType;
}
export declare const defaultFileListRendererConfig: {
colorScheme: ColorSchemeType;
};
export declare class FileListRenderer {
private readonly hoganUtils;
private readonly config;
constructor(hoganUtils: HoganJsUtils, config?: FileListRendererConfig);
render(diffFiles: DiffFile[]): string;
}
//# sourceMappingURL=file-list-renderer.d.ts.map

@@ -18,2 +18,3 @@ import HoganJsUtils from './hoganjs-utils';

diffStyle: import("./types").DiffStyleType;
colorScheme: import("./types").ColorSchemeType;
};

@@ -20,0 +21,0 @@ export default class LineByLineRenderer {

@@ -1,2 +0,2 @@

import { LineMatchingType, DiffStyleType, LineType, DiffLineParts, DiffFile, DiffFileName } from './types';
import { ColorSchemeType, DiffFile, DiffFileName, DiffLineParts, DiffStyleType, LineMatchingType, LineType } from './types';
export type CSSLineClass = 'd2h-ins' | 'd2h-del' | 'd2h-cntx' | 'd2h-info' | 'd2h-ins d2h-change' | 'd2h-del d2h-change';

@@ -21,2 +21,3 @@ export declare const CSSLineClass: {

diffStyle?: DiffStyleType;
colorScheme?: ColorSchemeType;
}

@@ -28,4 +29,6 @@ export declare const defaultRenderConfig: {

diffStyle: DiffStyleType;
colorScheme: ColorSchemeType;
};
export declare function toCSSClass(lineType: LineType): CSSLineClass;
export declare function colorSchemeToCss(colorScheme: ColorSchemeType): string;
export declare function escapeForHtml(str: string): string;

@@ -32,0 +35,0 @@ export declare function deconstructLine(line: string, isCombined: boolean, escape?: boolean): DiffLineParts;

@@ -18,2 +18,3 @@ import HoganJsUtils from './hoganjs-utils';

diffStyle: import("./types").DiffStyleType;
colorScheme: import("./types").ColorSchemeType;
};

@@ -20,0 +21,0 @@ export default class SideBySideRenderer {

@@ -75,2 +75,7 @@ export type DiffLineParts = {

};
export declare enum ColorSchemeType {
AUTO = "auto",
DARK = "dark",
LIGHT = "light"
}
//# sourceMappingURL=types.d.ts.map

@@ -32,2 +32,3 @@ import { Diff2HtmlConfig } from '../../diff2html';

diffStyle: import("../../types").DiffStyleType;
colorScheme: import("../../types").ColorSchemeType;
};

@@ -34,0 +35,0 @@ export declare class Diff2HtmlUI {

@@ -75,2 +75,7 @@ export type DiffLineParts = {

};
export declare enum ColorSchemeType {
AUTO = "auto",
DARK = "dark",
LIGHT = "light"
}
//# sourceMappingURL=types.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DiffStyleType = exports.LineMatchingType = exports.OutputFormatType = exports.LineType = void 0;
exports.ColorSchemeType = exports.DiffStyleType = exports.LineMatchingType = exports.OutputFormatType = exports.LineType = void 0;
var LineType;

@@ -23,2 +23,8 @@ (function (LineType) {

};
var ColorSchemeType;
(function (ColorSchemeType) {
ColorSchemeType["AUTO"] = "auto";
ColorSchemeType["DARK"] = "dark";
ColorSchemeType["LIGHT"] = "light";
})(ColorSchemeType || (exports.ColorSchemeType = ColorSchemeType = {}));
//# sourceMappingURL=types.js.map

@@ -32,2 +32,3 @@ import { Diff2HtmlConfig } from '../../diff2html';

diffStyle: import("../../types").DiffStyleType;
colorScheme: import("../../types").ColorSchemeType;
};

@@ -34,0 +35,0 @@ export declare class Diff2HtmlUI {

import '../../../main.ts';
import '../../../main.css';
import 'highlight.js/styles/github.css';
import './github-highlights.css';
import '../../../../src/ui/css/diff2html.css';
import './demo.css';
//# sourceMappingURL=demo.d.ts.map
{
"name": "diff2html",
"version": "3.4.43",
"version": "3.4.44",
"homepage": "https://diff2html.xyz",

@@ -5,0 +5,0 @@ "description": "Fast Diff to colorized HTML",

@@ -204,3 +204,3 @@ # diff2html

<!-- Stylesheet -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/github.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/diff2html/bundles/css/diff2html.min.css" />

@@ -231,2 +231,17 @@

When using the `auto` color scheme, you will need to specify both the light and dark themes for highlight.js to use.
```html
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github.min.css"
media="screen and (prefers-color-scheme: light)"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github-dark.min.css"
media="screen and (prefers-color-scheme: dark)"
/>
```
#### Collapsable File Summary List

@@ -391,2 +406,4 @@

detection based on file extensions.
- `colorScheme`: color scheme to use for the diff, default is `light`. Possible values are `light`, `dark`, and `auto`
which will use the browser's preferred color scheme.

@@ -393,0 +410,0 @@ ### Diff2Html Browser

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc