@git-diff-view/core
Advanced tools
+3
-0
@@ -530,2 +530,3 @@ // Generated by dts-bundle-generator v9.5.1 | ||
| export declare const getCurrentComposeLength: () => number; | ||
| export declare const getEnableBuildTemplate: () => boolean; | ||
| export declare const getEnableFastDiffTemplate: () => boolean; | ||
@@ -613,2 +614,3 @@ export declare const getLang: (fileName: string) => string; | ||
| export declare const resetDefaultComposeLength: () => void; | ||
| export declare const resetEnableBuildTemplate: () => void; | ||
| export declare const resetEnableFastDiffTemplate: () => void; | ||
@@ -625,2 +627,3 @@ export declare const resetMaxLengthToIgnoreLineDiff: () => void; | ||
| export declare const resetTransform: () => void; | ||
| export declare const setEnableBuildTemplate: (enable: boolean) => void; | ||
| export declare const setEnableFastDiffTemplate: (enable: boolean) => void; | ||
@@ -627,0 +630,0 @@ /** |
+2
-2
@@ -6,3 +6,3 @@ { | ||
| "license": "MIT", | ||
| "version": "0.1.4", | ||
| "version": "0.1.5", | ||
| "main": "index.js", | ||
@@ -54,3 +54,3 @@ "types": "index.d.ts", | ||
| "dependencies": { | ||
| "@git-diff-view/lowlight": "^0.1.4", | ||
| "@git-diff-view/lowlight": "^0.1.5", | ||
| "highlight.js": "^11.11.0", | ||
@@ -57,0 +57,0 @@ "lowlight": "^3.3.0", |
+9
-6
| import { highlighter } from "@git-diff-view/lowlight"; | ||
| import { Cache } from "./cache"; | ||
| import { getPlainLineTemplate, getSyntaxLineTemplate, processTransformForFile } from "./parse"; | ||
| import { getEnableBuildTemplate, getPlainLineTemplate, getSyntaxLineTemplate, processTransformForFile } from "./parse"; | ||
@@ -177,6 +177,7 @@ import type { DiffAST, DiffHighlighter, DiffHighlighterLang, SyntaxLine } from "@git-diff-view/lowlight"; | ||
| // get syntax template | ||
| Object.values(syntaxFileObject).forEach((line: SyntaxLineWithTemplate) => { | ||
| line.template = getSyntaxLineTemplate(line); | ||
| }); | ||
| if (getEnableBuildTemplate()) { | ||
| Object.values(syntaxFileObject).forEach((line: SyntaxLineWithTemplate) => { | ||
| line.template = getSyntaxLineTemplate(line); | ||
| }); | ||
| } | ||
@@ -213,2 +214,4 @@ this.syntaxFile = syntaxFileObject; | ||
| const buildTemplate = getEnableBuildTemplate(); | ||
| for (let i = 0; i < rawArray.length; i++) { | ||
@@ -218,3 +221,3 @@ this.rawFile[i + 1] = i < rawArray.length - 1 ? rawArray[i] + "\n" : rawArray[i]; | ||
| value: this.rawFile[i + 1], | ||
| template: getPlainLineTemplate(this.rawFile[i + 1]), | ||
| template: buildTemplate ? getPlainLineTemplate(this.rawFile[i + 1]) : undefined, | ||
| }; | ||
@@ -221,0 +224,0 @@ } |
+50
-44
@@ -5,2 +5,3 @@ import { diffChanges, relativeChanges } from "./change-range"; | ||
| import { | ||
| getEnableBuildTemplate, | ||
| getEnableFastDiffTemplate, | ||
@@ -152,25 +153,28 @@ getPlainDiffTemplate, | ||
| } | ||
| const buildTemplate = getEnableBuildTemplate(); | ||
| if (!getEnableFastDiffTemplate()) { | ||
| getPlainDiffTemplate({ | ||
| diffLine: addition, | ||
| rawLine: getAdditionRaw(addition.newLineNumber!) || "", | ||
| operator: "add", | ||
| }); | ||
| getPlainDiffTemplate({ | ||
| diffLine: deletion, | ||
| rawLine: getDeletionRaw(deletion.oldLineNumber!) || "", | ||
| operator: "del", | ||
| }); | ||
| getSyntaxDiffTemplate({ | ||
| diffFile, | ||
| diffLine: addition, | ||
| syntaxLine: getAdditionSyntax(addition.newLineNumber!) || null, | ||
| operator: "add", | ||
| }); | ||
| getSyntaxDiffTemplate({ | ||
| diffFile, | ||
| diffLine: deletion, | ||
| syntaxLine: getDeletionSyntax(deletion.oldLineNumber!) || null, | ||
| operator: "del", | ||
| }); | ||
| if (buildTemplate) { | ||
| getPlainDiffTemplate({ | ||
| diffLine: addition, | ||
| rawLine: getAdditionRaw(addition.newLineNumber!) || "", | ||
| operator: "add", | ||
| }); | ||
| getPlainDiffTemplate({ | ||
| diffLine: deletion, | ||
| rawLine: getDeletionRaw(deletion.oldLineNumber!) || "", | ||
| operator: "del", | ||
| }); | ||
| getSyntaxDiffTemplate({ | ||
| diffFile, | ||
| diffLine: addition, | ||
| syntaxLine: getAdditionSyntax(addition.newLineNumber!) || null, | ||
| operator: "add", | ||
| }); | ||
| getSyntaxDiffTemplate({ | ||
| diffFile, | ||
| diffLine: deletion, | ||
| syntaxLine: getDeletionSyntax(deletion.oldLineNumber!) || null, | ||
| operator: "del", | ||
| }); | ||
| } | ||
| } else { | ||
@@ -190,24 +194,26 @@ const _addition = DiffLine.prototype.clone.call( | ||
| deletion._diffChanges = addRange; | ||
| getPlainDiffTemplateByFastDiff({ | ||
| diffLine: addition, | ||
| rawLine: getAdditionRaw(addition.newLineNumber!) || "", | ||
| operator: "add", | ||
| }); | ||
| getPlainDiffTemplateByFastDiff({ | ||
| diffLine: deletion, | ||
| rawLine: getDeletionRaw(deletion.oldLineNumber!) || "", | ||
| operator: "del", | ||
| }); | ||
| getSyntaxDiffTemplateByFastDiff({ | ||
| diffFile, | ||
| diffLine: addition, | ||
| syntaxLine: getAdditionSyntax(addition.newLineNumber!) || null, | ||
| operator: "add", | ||
| }); | ||
| getSyntaxDiffTemplateByFastDiff({ | ||
| diffFile, | ||
| diffLine: deletion, | ||
| syntaxLine: getDeletionSyntax(deletion.oldLineNumber!) || null, | ||
| operator: "del", | ||
| }); | ||
| if (buildTemplate) { | ||
| getPlainDiffTemplateByFastDiff({ | ||
| diffLine: addition, | ||
| rawLine: getAdditionRaw(addition.newLineNumber!) || "", | ||
| operator: "add", | ||
| }); | ||
| getPlainDiffTemplateByFastDiff({ | ||
| diffLine: deletion, | ||
| rawLine: getDeletionRaw(deletion.oldLineNumber!) || "", | ||
| operator: "del", | ||
| }); | ||
| getSyntaxDiffTemplateByFastDiff({ | ||
| diffFile, | ||
| diffLine: addition, | ||
| syntaxLine: getAdditionSyntax(addition.newLineNumber!) || null, | ||
| operator: "add", | ||
| }); | ||
| getSyntaxDiffTemplateByFastDiff({ | ||
| diffFile, | ||
| diffLine: deletion, | ||
| syntaxLine: getDeletionSyntax(deletion.oldLineNumber!) || null, | ||
| operator: "del", | ||
| }); | ||
| } | ||
| } | ||
@@ -214,0 +220,0 @@ } |
@@ -23,2 +23,14 @@ import { addContentHighlightBGName, delContentHighlightBGName, getSymbol } from "@git-diff-view/utils"; | ||
| let enableBuildTemplate = true; | ||
| export const getEnableBuildTemplate = () => enableBuildTemplate; | ||
| export const setEnableBuildTemplate = (enable: boolean) => { | ||
| enableBuildTemplate = enable; | ||
| }; | ||
| export const resetEnableBuildTemplate = () => { | ||
| enableBuildTemplate = true; | ||
| }; | ||
| export const defaultTransform = (content: string) => escapeHtml(content).replace(/\n/g, "").replace(/\r/g, ""); | ||
@@ -25,0 +37,0 @@ |
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 too big to display
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1395520
0.32%15952
0.44%