Skip to content

Commit 62d18e1

Browse files
fix ui
1 parent d086bf2 commit 62d18e1

File tree

15 files changed

+214
-6
lines changed

15 files changed

+214
-6
lines changed

packages/core/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
"types": "./index.d.ts",
2424
"import": "./dist/esm/index.mjs"
2525
},
26-
"./cjsIndex.js": "./index.js",
27-
"./esmIndex.js": "./dist/esm/index.mjs",
2826
"./package.json": "./package.json"
2927
},
3028
"buildOptions": {

packages/core/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Pure Logic for Diff View Component
1+
## `git diff` for @git-diff-view Component
22

33
## Usage
44

packages/file/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 MrWangJustToDo
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/file/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./dist/types";

packages/file/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"use strict";
2+
3+
if (process.env.NODE_ENV === "production") {
4+
module.exports = require("./dist/cjs/index.production");
5+
} else {
6+
module.exports = require("./dist/cjs/index.development");
7+
}

packages/file/package.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "@git-diff-view/file",
3+
"description": "@git-diff-view/file",
4+
"author": "MrWangJustToDo",
5+
"license": "MIT",
6+
"version": "0.0.11",
7+
"main": "index.js",
8+
"types": "index.d.ts",
9+
"files": [
10+
"dist",
11+
"index.js",
12+
"index.d.ts"
13+
],
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/MrWangJustToDo/git-diff-view.git",
17+
"directory": "packages/file"
18+
},
19+
"homepage": "https://github.com/MrWangJustToDo/git-diff-view",
20+
"exports": {
21+
".": {
22+
"require": "./index.js",
23+
"types": "./index.d.ts",
24+
"import": "./dist/esm/index.mjs"
25+
},
26+
"./package.json": "./package.json"
27+
},
28+
"buildOptions": {
29+
"input": "./src/index.ts",
30+
"output": [
31+
{
32+
"dir": "./dist",
33+
"entryFileNames": "cjs/index.js",
34+
"format": "cjs",
35+
"type": true,
36+
"multiple": true,
37+
"sourcemap": true
38+
},
39+
{
40+
"dir": "./dist",
41+
"entryFileNames": "esm/index.mjs",
42+
"format": "esm",
43+
"sourcemap": true
44+
}
45+
]
46+
},
47+
"keywords": [
48+
"diff",
49+
"diff parse"
50+
],
51+
"dependencies": {
52+
"diff": "^5.2.0",
53+
"lowlight": "^3.1.0"
54+
},
55+
"devDependencies": {
56+
"@git-diff-view/core": "latest",
57+
"@git-diff-view/lowlight": "latest",
58+
"@types/diff": "^5.0.9"
59+
}
60+
}

packages/file/readme.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## File content diff for @git-diff-view component
2+
3+
## Usage
4+
5+
```tsx
6+
const file = new DiffFile(
7+
data?.oldFile?.fileName || "",
8+
data?.oldFile?.content || "",
9+
data?.newFile?.fileName || "",
10+
data?.newFile?.content || "",
11+
data?.oldFile?.fileLang || "",
12+
data?.newFile?.fileLang || ""
13+
);
14+
15+
file.init();
16+
17+
file.buildSplitDiffLines();
18+
19+
file.buildUnifiedDiffLines();
20+
21+
// get All the bundle
22+
const bundle = file.getBundle();
23+
24+
// merge bundle
25+
const mergeFile = DiffFile.createInstance(data || {}, bundle);
26+
27+
// used for @git-diff-view/react and @git-diff-view/vue
28+
<DiffView diffFile={mergeFile} />
29+
30+
<DiffView :diffFile="mergeFile" />
31+
32+
```

packages/file/src/diff-file.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { DiffFile as _DiffFile } from "@git-diff-view/core";
2+
3+
import type { Change } from "diff";
4+
5+
// TODO
6+
export class DiffFile extends _DiffFile {
7+
#hasInitRaw: boolean = false;
8+
9+
#hasInitSyntax: boolean = false;
10+
11+
#hasBuildSplit: boolean = false;
12+
13+
#hasBuildUnified: boolean = false;
14+
15+
#diffResults?: Change[];
16+
17+
// #doDiff() {
18+
// this.#diffResults =
19+
// }
20+
21+
initRaw() {
22+
if (this.#hasInitRaw) return;
23+
this.#hasInitRaw = true;
24+
this.initRaw();
25+
}
26+
27+
init() {
28+
this.initRaw();
29+
this.initSyntax();
30+
}
31+
32+
// setDiffOptions(options?: LinesOptions{}) {
33+
34+
// }
35+
}

packages/file/src/index.ts

Whitespace-only changes.

packages/file/tsconfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"rootDir": "src",
4+
"target": "ES2015",
5+
"moduleResolution": "Bundler",
6+
"stripInternal": true
7+
},
8+
"include": ["./src"],
9+
"exclude": ["node_modules"]
10+
}

0 commit comments

Comments
 (0)