@git-diff-view/core
TypeScript icon, indicating that this package has built-in type declarations

0.0.26 • Public • Published

git diff for @git-diff-view Component

Usage

// ==== step1: generate diff view data, this part can be used in the worker/server environment for better performance ==== //
import { DiffFile } from "@git-diff-view/core";
const file = new DiffFile(
    data?.oldFile?.fileName || "",
    data?.oldFile?.content || "",
    data?.newFile?.fileName || "",
    data?.newFile?.content || "",
    data?.hunks || [],
    data?.oldFile?.fileLang || "",
    data?.newFile?.fileLang || ""
  );
// light / dark theme, base on current highlight engine
// default is light
file.initTheme(xxx);
// init
file.init();
// or you can use below method to init
file.initRaw();
file.initSyntax(); // if you do not want syntax highlight, you can skip this step

// build the `Split View` data;
file.buildSplitDiffLines();

// build the `Unified View` data;
file.buildUnifiedDiffLines();

// get All the diff data bundle, you can safely to send this data to the client side
const bundle = file.getBundle();

// ==== step2: render the @git-diff-view component ==== //

// merge bundle
const mergeFile = DiffFile.createInstance(data || {}, bundle);

// used for @git-diff-view/react and @git-diff-view/vue
<DiffView diffFile={mergeFile} />

<DiffView :diffFile="mergeFile" />

Screen Shot

Screenshot Screenshot Screenshot Screenshot Screenshot

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.1-beta.20beta
0.0.264,353latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.264,353
0.0.25296
0.0.24244
0.0.230
0.0.220
0.0.212,184
0.0.2070
0.0.196
0.0.184
0.0.173
0.0.162,139
0.0.150
0.0.140
0.0.130
0.0.120
0.0.110
0.0.100
0.0.90
0.0.80
0.0.70
0.0.60
0.0.50
0.0.30
0.0.20
0.0.10
0.0.1-beta.20
0.0.1-beta.10

Package Sidebar

Install

npm i @git-diff-view/core

Weekly Downloads

9,299

Version

0.0.26

License

MIT

Unpacked Size

668 kB

Total Files

11

Last publish

Collaborators

  • mrwang555