🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

v-code-diff

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

v-code-diff - npm Package Compare versions

Comparing version

to
1.5.0

{
"name": "v-code-diff",
"version": "1.4.0",
"version": "1.5.0",
"description": "template component for vue-demi, can dev and build",

@@ -5,0 +5,0 @@ "main": "dist/index.cjs",

@@ -33,4 +33,2 @@ # v-code-diff

- [Migrate from 0.x version](#Migrate-from-0x-version)
- [Changelog](#Changelog)
- [LICENSE](#licence)

@@ -73,3 +71,3 @@ ## Install

然后
then

@@ -195,108 +193,2 @@ ```vue

| trim | Remove blank characters at the beginning and end of the string | None |
| noDiffLineFeed | Don't diff Windows line feed (CRLF) and Linux line feed (LF) | None |
## ChangeLog
### 1.0.0-alpha.0
1. Remove the diff2html dependency and draw the UI by self. By getting rid of the diff2html dependency, many styling
problems have been resolved.
2. More accurate syntax highlighting and faster highlighting speed.
### 0.3.12
1. Remove prop `syncScroll` due to bug. Synchronized scrolling is now enabled by default
### 0.3.11
1. Add prop `syncScroll` to control whether the horizontal scroll bar needs to be scrolled synchronously
### 0.3.10
1. Fixed type error when exporting
### 0.3.9
1. Make the imported highlight.js style take effect only in `.d2h-wrapper` div
### 0.3.8
1. Style adjustment, hide css `d2h-file-header`, same as vue-code-diff
2. Add prop `noDiffLineFeed`, do not diff windows line feed (CRLF) and linux line feed (LF)
### 0.3.7
1. Fix the problem of displaying "File Without Change..." when isShowNoChange is true and the old and new codes are
different,
then show all the source code
### 0.3.6
1. Add prop `language`, make highlighting more accurate
### 0.3.5
1. In the side-by-side mode, support left and right synchronous scrolling
### 0.3.4
1. Add Prop `trim`, it will remove the blank characters before and after the string
### 0.3.3
1. Fixed the problem of highlight failure.
### 0.3.2
1. Fixed the warning for vue2 users in console
### 0.3.1
1. Fix incorrect style when comparing text
### 0.3.0
1. Performance optimization, now rendering has better performance
2. Add Prop `diffStyle` to control whether to display word-level differences or char-level differences
### 0.2.1
1. Use the function of asynchronous rendering of the highlight code, without blocking the ui, greatly improving the page
rendering speed
2. Add hook function (before rendering, after rendering): `before-render`, `after-render`
### 0.1.0
1. Add prop `highlight` to control whether to highlight the code.
### 0.0.4
1. Fix the problem of abnormal rendering in some browsers (such as safari)
### 0.0.3
1. Prop: `context` default value changed from 5 to 10
2. fix possible line-height conflict(such as `antd.css` in [antd-vue](https://github.com/vueComponent/ant-design-vue))
### 0.0.1
First Version.
## LICENCE
MIT License
Copyright (c) 2021 Shimada666
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| noDiffLineFeed | Don't diff Windows line feed (CRLF) and Linux line feed (LF) | None |

@@ -8,2 +8,12 @@ export const enum DiffType {

export interface UnifiedLineUnchanges {
lines: UnifiedLineChange[]
fold: boolean
}
export interface SplitLineUnchanges {
lines: SplitLineChange[]
fold: boolean
}
export interface DiffLine {

@@ -19,2 +29,4 @@ type: DiffType

right: DiffLine
hide?: boolean
hideIndex?: number
}

@@ -28,2 +40,4 @@

addNum?: number
hide?: boolean
hideIndex?: number
}

@@ -35,4 +49,6 @@

}
export interface SplitViewerChange {
changes: SplitLineChange[]
collector: SplitLineUnchanges[]
stat: DiffStat

@@ -43,3 +59,4 @@ }

changes: UnifiedLineChange[]
collector: UnifiedLineUnchanges[]
stat: DiffStat
}

@@ -6,3 +6,3 @@ import * as Diff from 'diff'

import { DiffType } from './types'
import type { DiffLine, DiffStat, SplitLineChange, SplitViewerChange, UnifiedLineChange, UnifiedViewerChange } from './types'
import type { DiffLine, DiffStat, SplitLineChange, SplitLineUnchanges, SplitViewerChange, UnifiedLineChange, UnifiedLineUnchanges, UnifiedViewerChange } from './types'

@@ -172,2 +172,3 @@ const MODIFIED_START_TAG = '<code-diff-modified>'

changes: rawChanges,
collector: [],
stat: calcDiffStat(changes),

@@ -213,3 +214,2 @@ }

}
rawChanges.push({ left, right })

@@ -306,14 +306,32 @@ }

const processedChanges = []
const processedChanges: SplitViewerChange['changes'] = []
let unchanges: SplitLineUnchanges['lines'] = [] // collector for unchanged lines.
for (let i = 0; i < rawChanges.length; i++) {
const line = rawChanges[i]
if (line.fold === false) {
if (unchanges.length) {
unchanges[0].hideIndex = result.collector.length
result.collector.push({
lines: unchanges,
fold: true,
})
unchanges = []
}
processedChanges.push(line)
continue
}
if (line.fold === true) {
if (processedChanges[processedChanges.length - 1]?.fold !== true)
processedChanges.push(line)
}
line.hide = true
unchanges.push(line)
processedChanges.push(line)
}
if (unchanges.length) {
unchanges[0].hideIndex = result.collector.length
result.collector.push({
lines: unchanges,
fold: true,
})
unchanges = []
}
result.changes = processedChanges

@@ -340,2 +358,3 @@

changes: rawChanges,
collector: [],
stat: calcDiffStat(changes),

@@ -457,13 +476,34 @@ }

const processedChanges = []
let unchanges: UnifiedLineUnchanges['lines'] = [] // collector for unchanged lines.
for (let i = 0; i < rawChanges.length; i++) {
const line = rawChanges[i]
if (line.fold === false) {
if (unchanges.length) {
unchanges[0].hideIndex = result.collector.length
// Keeps "hideIndex" in first element of collector
// for delegating lines to expand.
result.collector.push({
lines: unchanges,
fold: true,
})
unchanges = []
}
processedChanges.push(line)
continue
}
if (line.fold === true) {
if (i === 0 || processedChanges[processedChanges.length - 1]?.fold !== true)
processedChanges.push(line)
if (line.type === 'equal') {
line.hide = true
unchanges.push(line)
}
processedChanges.push(line)
}
if (unchanges.length) {
unchanges[0].hideIndex = result.collector.length
result.collector.push({
lines: unchanges,
fold: true,
})
unchanges = []
}
result.changes = processedChanges

@@ -470,0 +510,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

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