json-diff-kit
Advanced tools
Comparing version 1.0.29 to 1.0.30
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var differ = require('./differ.js'); | ||
@@ -11,3 +9,3 @@ var viewer = require('./viewer.js'); | ||
exports.Differ = differ["default"]; | ||
exports.Differ = differ.default; | ||
exports.Viewer = viewer; |
@@ -5,4 +5,3 @@ 'use strict'; | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) return e; | ||
function _interopNamespaceDefault(e) { | ||
var n = Object.create(null); | ||
@@ -20,7 +19,7 @@ if (e) { | ||
} | ||
n["default"] = e; | ||
n.default = e; | ||
return Object.freeze(n); | ||
} | ||
var React__namespace = /*#__PURE__*/_interopNamespace(React); | ||
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React); | ||
@@ -121,3 +120,2 @@ const isExpandLine = (segment)=>{ | ||
}; | ||
var calculatePlaceholderHeight$1 = calculatePlaceholderHeight; | ||
@@ -191,3 +189,2 @@ const findVisibleLines = (segments, accTop, viewportTop, viewportBottom, itemHeight, expandLineHeight)=>{ | ||
}; | ||
var findVisibleLines$1 = findVisibleLines; | ||
@@ -201,4 +198,4 @@ var bin = {}; | ||
function diff_internal(state, c) { | ||
const { b , eq , stack_base } = state; | ||
let { i , N , j , M , Z , stack_top } = state; | ||
const { b, eq, stack_base } = state; | ||
let { i, N, j, M, Z, stack_top } = state; | ||
for(;;){ | ||
@@ -323,3 +320,3 @@ switch(c){ | ||
next() { | ||
const { state , result } = this; | ||
const { state, result } = this; | ||
if (this.c > 1) { | ||
@@ -408,3 +405,3 @@ result.done = true; | ||
if (rec.done) { | ||
const { i , j , N } = this; | ||
const { i, j, N } = this; | ||
if (i < N) { | ||
@@ -425,3 +422,3 @@ rec.done = false; | ||
const ey = v[3]; | ||
const { i , j } = this; | ||
const { i, j } = this; | ||
if (i !== sx) { | ||
@@ -596,3 +593,2 @@ v.length--; | ||
}; | ||
var getInlineDiff$1 = getInlineDiff; | ||
@@ -722,3 +718,2 @@ const syntaxHighlightLine = (enabled, text, offset)=>{ | ||
}; | ||
var getInlineSyntaxHighlight = syntaxHighlightLine; | ||
@@ -767,3 +762,3 @@ const defaultOptions = { | ||
}; | ||
const { threshold , margin } = _options; | ||
const { threshold, margin } = _options; | ||
if (threshold < margin * 2 + 1) { | ||
@@ -828,3 +823,2 @@ // eslint-disable-next-line no-console, max-len | ||
}; | ||
var getSegments$1 = getSegments; | ||
@@ -857,3 +851,3 @@ const DEFAULT_INDENT = 2; | ||
const hideUnchangedLines = props.hideUnchangedLines ?? false; | ||
const { scrollContainer: _scrollContainer = 'body' , itemHeight =18 , expandLineHeight =26 } = !props.virtual || props.virtual === true ? {} : props.virtual; | ||
const { scrollContainer: _scrollContainer = 'body', itemHeight = 18, expandLineHeight = 26 } = !props.virtual || props.virtual === true ? {} : props.virtual; | ||
const scrollContainer = _scrollContainer === 'body' ? document.body : document.querySelector(_scrollContainer); | ||
@@ -865,3 +859,3 @@ // Use these refs to keep the diff data and segments sync, | ||
const linesRightRef = React__namespace.useRef(linesRight); | ||
const segmentsRef = React__namespace.useRef(getSegments$1(linesLeft, linesRight, hideUnchangedLines, jsonsAreEqual)); | ||
const segmentsRef = React__namespace.useRef(getSegments(linesLeft, linesRight, hideUnchangedLines, jsonsAreEqual)); | ||
const accTopRef = React__namespace.useRef([]); | ||
@@ -896,3 +890,3 @@ const totalHeightRef = React__namespace.useRef(0); | ||
linesRightRef.current = linesRight; | ||
segmentsRef.current = getSegments$1(linesLeft, linesRight, hideUnchangedLines, jsonsAreEqual); | ||
segmentsRef.current = getSegments(linesLeft, linesRight, hideUnchangedLines, jsonsAreEqual); | ||
updateViewer(); | ||
@@ -996,8 +990,8 @@ }, [ | ||
const r = linesRightRef.current[index]; | ||
const [lDiff, rDiff] = props.highlightInlineDiff && l.type === 'modify' && r.type === 'modify' ? getInlineDiff$1(l.text, r.text, inlineDiffOptions) : [ | ||
const [lDiff, rDiff] = props.highlightInlineDiff && l.type === 'modify' && r.type === 'modify' ? getInlineDiff(l.text, r.text, inlineDiffOptions) : [ | ||
[], | ||
[] | ||
]; | ||
const lTokens = getInlineSyntaxHighlight(syntaxHighlightEnabled, l.text, 0); | ||
const rTokens = getInlineSyntaxHighlight(syntaxHighlightEnabled, r.text, 0); | ||
const lTokens = syntaxHighlightLine(syntaxHighlightEnabled, l.text, 0); | ||
const rTokens = syntaxHighlightLine(syntaxHighlightEnabled, r.text, 0); | ||
const lResult = mergeSegments(lTokens, lDiff); | ||
@@ -1042,3 +1036,3 @@ const rResult = mergeSegments(rTokens, rDiff); | ||
const renderSegment = (segment, index, renderStart, renderEnd, syntaxHighlightEnabled)=>{ | ||
let { start , end } = segment; | ||
let { start, end } = segment; | ||
start = Math.max(start, renderStart); | ||
@@ -1052,3 +1046,3 @@ end = Math.min(end, renderEnd); | ||
} | ||
const { hasLinesBefore , hasLinesAfter } = segment; | ||
const { hasLinesBefore, hasLinesAfter } = segment; | ||
const expandMoreLinesLimit = typeof hideUnchangedLines === 'boolean' ? DEFAULT_EXPAND_MORE_LINES_LIMIT : hideUnchangedLines.expandMoreLinesLimit || DEFAULT_EXPAND_MORE_LINES_LIMIT; | ||
@@ -1102,4 +1096,4 @@ return [ | ||
const viewportBottom = scrollBottom - firstElementTop; | ||
const [startSegment, startLine, endSegment, endLine] = findVisibleLines$1(segmentsRef.current, accTopRef.current, viewportTop, viewportBottom, itemHeight, expandLineHeight); | ||
const [topHeight, bottomHeight] = calculatePlaceholderHeight$1(segmentsRef.current, accTopRef.current, startSegment, startLine, endSegment, endLine, itemHeight, expandLineHeight, totalHeightRef.current); | ||
const [startSegment, startLine, endSegment, endLine] = findVisibleLines(segmentsRef.current, accTopRef.current, viewportTop, viewportBottom, itemHeight, expandLineHeight); | ||
const [topHeight, bottomHeight] = calculatePlaceholderHeight(segmentsRef.current, accTopRef.current, startSegment, startLine, endSegment, endLine, itemHeight, expandLineHeight, totalHeightRef.current); | ||
const visibleSegments = segmentsRef.current.slice(startSegment, endSegment + 1); | ||
@@ -1106,0 +1100,0 @@ return visibleSegments.length ? /*#__PURE__*/ React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/ React__namespace.createElement("tr", null, /*#__PURE__*/ React__namespace.createElement("td", { |
@@ -97,3 +97,2 @@ import * as React from 'react'; | ||
}; | ||
var calculatePlaceholderHeight$1 = calculatePlaceholderHeight; | ||
@@ -167,3 +166,2 @@ const findVisibleLines = (segments, accTop, viewportTop, viewportBottom, itemHeight, expandLineHeight)=>{ | ||
}; | ||
var findVisibleLines$1 = findVisibleLines; | ||
@@ -177,4 +175,4 @@ var bin = {}; | ||
function diff_internal(state, c) { | ||
const { b , eq , stack_base } = state; | ||
let { i , N , j , M , Z , stack_top } = state; | ||
const { b, eq, stack_base } = state; | ||
let { i, N, j, M, Z, stack_top } = state; | ||
for(;;){ | ||
@@ -299,3 +297,3 @@ switch(c){ | ||
next() { | ||
const { state , result } = this; | ||
const { state, result } = this; | ||
if (this.c > 1) { | ||
@@ -384,3 +382,3 @@ result.done = true; | ||
if (rec.done) { | ||
const { i , j , N } = this; | ||
const { i, j, N } = this; | ||
if (i < N) { | ||
@@ -401,3 +399,3 @@ rec.done = false; | ||
const ey = v[3]; | ||
const { i , j } = this; | ||
const { i, j } = this; | ||
if (i !== sx) { | ||
@@ -572,3 +570,2 @@ v.length--; | ||
}; | ||
var getInlineDiff$1 = getInlineDiff; | ||
@@ -698,3 +695,2 @@ const syntaxHighlightLine = (enabled, text, offset)=>{ | ||
}; | ||
var getInlineSyntaxHighlight = syntaxHighlightLine; | ||
@@ -743,3 +739,3 @@ const defaultOptions = { | ||
}; | ||
const { threshold , margin } = _options; | ||
const { threshold, margin } = _options; | ||
if (threshold < margin * 2 + 1) { | ||
@@ -804,3 +800,2 @@ // eslint-disable-next-line no-console, max-len | ||
}; | ||
var getSegments$1 = getSegments; | ||
@@ -833,3 +828,3 @@ const DEFAULT_INDENT = 2; | ||
const hideUnchangedLines = props.hideUnchangedLines ?? false; | ||
const { scrollContainer: _scrollContainer = 'body' , itemHeight =18 , expandLineHeight =26 } = !props.virtual || props.virtual === true ? {} : props.virtual; | ||
const { scrollContainer: _scrollContainer = 'body', itemHeight = 18, expandLineHeight = 26 } = !props.virtual || props.virtual === true ? {} : props.virtual; | ||
const scrollContainer = _scrollContainer === 'body' ? document.body : document.querySelector(_scrollContainer); | ||
@@ -841,3 +836,3 @@ // Use these refs to keep the diff data and segments sync, | ||
const linesRightRef = React.useRef(linesRight); | ||
const segmentsRef = React.useRef(getSegments$1(linesLeft, linesRight, hideUnchangedLines, jsonsAreEqual)); | ||
const segmentsRef = React.useRef(getSegments(linesLeft, linesRight, hideUnchangedLines, jsonsAreEqual)); | ||
const accTopRef = React.useRef([]); | ||
@@ -872,3 +867,3 @@ const totalHeightRef = React.useRef(0); | ||
linesRightRef.current = linesRight; | ||
segmentsRef.current = getSegments$1(linesLeft, linesRight, hideUnchangedLines, jsonsAreEqual); | ||
segmentsRef.current = getSegments(linesLeft, linesRight, hideUnchangedLines, jsonsAreEqual); | ||
updateViewer(); | ||
@@ -972,8 +967,8 @@ }, [ | ||
const r = linesRightRef.current[index]; | ||
const [lDiff, rDiff] = props.highlightInlineDiff && l.type === 'modify' && r.type === 'modify' ? getInlineDiff$1(l.text, r.text, inlineDiffOptions) : [ | ||
const [lDiff, rDiff] = props.highlightInlineDiff && l.type === 'modify' && r.type === 'modify' ? getInlineDiff(l.text, r.text, inlineDiffOptions) : [ | ||
[], | ||
[] | ||
]; | ||
const lTokens = getInlineSyntaxHighlight(syntaxHighlightEnabled, l.text, 0); | ||
const rTokens = getInlineSyntaxHighlight(syntaxHighlightEnabled, r.text, 0); | ||
const lTokens = syntaxHighlightLine(syntaxHighlightEnabled, l.text, 0); | ||
const rTokens = syntaxHighlightLine(syntaxHighlightEnabled, r.text, 0); | ||
const lResult = mergeSegments(lTokens, lDiff); | ||
@@ -1018,3 +1013,3 @@ const rResult = mergeSegments(rTokens, rDiff); | ||
const renderSegment = (segment, index, renderStart, renderEnd, syntaxHighlightEnabled)=>{ | ||
let { start , end } = segment; | ||
let { start, end } = segment; | ||
start = Math.max(start, renderStart); | ||
@@ -1028,3 +1023,3 @@ end = Math.min(end, renderEnd); | ||
} | ||
const { hasLinesBefore , hasLinesAfter } = segment; | ||
const { hasLinesBefore, hasLinesAfter } = segment; | ||
const expandMoreLinesLimit = typeof hideUnchangedLines === 'boolean' ? DEFAULT_EXPAND_MORE_LINES_LIMIT : hideUnchangedLines.expandMoreLinesLimit || DEFAULT_EXPAND_MORE_LINES_LIMIT; | ||
@@ -1078,4 +1073,4 @@ return [ | ||
const viewportBottom = scrollBottom - firstElementTop; | ||
const [startSegment, startLine, endSegment, endLine] = findVisibleLines$1(segmentsRef.current, accTopRef.current, viewportTop, viewportBottom, itemHeight, expandLineHeight); | ||
const [topHeight, bottomHeight] = calculatePlaceholderHeight$1(segmentsRef.current, accTopRef.current, startSegment, startLine, endSegment, endLine, itemHeight, expandLineHeight, totalHeightRef.current); | ||
const [startSegment, startLine, endSegment, endLine] = findVisibleLines(segmentsRef.current, accTopRef.current, viewportTop, viewportBottom, itemHeight, expandLineHeight); | ||
const [topHeight, bottomHeight] = calculatePlaceholderHeight(segmentsRef.current, accTopRef.current, startSegment, startLine, endSegment, endLine, itemHeight, expandLineHeight, totalHeightRef.current); | ||
const visibleSegments = segmentsRef.current.slice(startSegment, endSegment + 1); | ||
@@ -1082,0 +1077,0 @@ return visibleSegments.length ? /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("tr", null, /*#__PURE__*/ React.createElement("td", { |
{ | ||
"name": "json-diff-kit", | ||
"version": "1.0.29", | ||
"version": "1.0.30", | ||
"description": "A better JSON differ & viewer.", | ||
@@ -52,6 +52,7 @@ "main": "dist/cjs/index.js", | ||
"@rollup/plugin-replace": "^5.0.2", | ||
"@swc/cli": "^0.1.62", | ||
"@swc/core": "^1.3.56", | ||
"@swc/jest": "^0.2.26", | ||
"@types/jest": "^27.4.1", | ||
"@rollup/plugin-swc": "^0.4.0", | ||
"@swc/cli": "^0.5.2", | ||
"@swc/core": "^1.10.1", | ||
"@swc/jest": "^0.2.37", | ||
"@types/jest": "^29.5.14", | ||
"@types/lodash": "^4.14.191", | ||
@@ -67,3 +68,3 @@ "@types/node": "^20.11.16", | ||
"fork-me-on-github": "^1.0.6", | ||
"jest": "^27.4.7", | ||
"jest": "^29.7.0", | ||
"less": "^4.1.3", | ||
@@ -73,8 +74,7 @@ "prismjs": "^1.29.0", | ||
"react-dom": "^17.0.2", | ||
"rollup": "^2.67.0", | ||
"rollup": "^4.28.1", | ||
"rollup-plugin-less": "^1.1.3", | ||
"rollup-plugin-livereload": "^2.0.5", | ||
"rollup-plugin-serve": "^1.1.0", | ||
"rollup-plugin-serve": "^1.1.1", | ||
"rollup-plugin-styles": "^4.0.0", | ||
"rollup-plugin-swc": "^0.2.1", | ||
"stylelint": "^15", | ||
@@ -94,3 +94,3 @@ "stylelint-plugin-rexskz": "1.0.0-alpha.3", | ||
"scripts": { | ||
"start": "cross-env rollup -c rollup.config.pages.ts -w", | ||
"start": "cross-env rollup -c rollup.config.pages.mjs -w", | ||
"dev": "cross-env pnpm start", | ||
@@ -101,8 +101,8 @@ "lint:eslint": "eslint ./{src,playground}/**/*.{ts,tsx} --quiet", | ||
"build": "cross-env pnpm build:ts && pnpm build:less && pnpm build:typings", | ||
"build:ts": "cross-env rollup -c && rollup -c rollup.config.cli.ts", | ||
"build:ts": "cross-env rollup -c && rollup -c rollup.config.cli.mjs", | ||
"build:typings": "cross-env tsc -p tsconfig.build.json", | ||
"build:less": "cross-env lessc src/viewer.less dist/viewer.css && lessc src/viewer-monokai.less dist/viewer-monokai.css", | ||
"build:pages": "cross-env NODE_ENV=production BASEDIR=docs rollup -c rollup.config.pages.ts", | ||
"build:pages": "cross-env NODE_ENV=production BASEDIR=docs rollup -c rollup.config.pages.mjs", | ||
"prepublish": "cross-env pnpm build" | ||
} | ||
} |
@@ -105,2 +105,6 @@ # JSON Diff Kit | ||
## Other Version of Viewer | ||
Here is an experimental [Vue version](https://github.com/RexSkz/json-diff-kit-vue) of the `Viewer` component. | ||
## More Complex Usages | ||
@@ -137,3 +141,3 @@ | ||
Please refer to the article [JSON Diff Kit: A Combination of Several Simple Algorithms](https://blog.rexskz.info/json-diff-kit-a-combination-of-several-simple-algorithms.html). | ||
Please refer to the article [JSON Diff Kit: A Combination of Several Simple Algorithms](https://blog.rexskz.info/json-diff-kit-a-combination-of-several-simple-algorithms.html?cc_lang=en). | ||
@@ -148,4 +152,4 @@ ## Features & Roadmap | ||
- [x] Add CLI tool | ||
- [x] Provide a Vue version of `Viewer` | ||
- [ ] Improve unit tests | ||
- [ ] Provide a Vue version of `Viewer` | ||
@@ -152,0 +156,0 @@ ## License |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54
12009
161
456092
8