react-diff-viewer-continued 4.0.4 → 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [4.0.5](https://github.com/aeolun/react-diff-viewer-continued/compare/v4.0.4...v4.0.5) (2025-01-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * modify imports for proper esm resolution ([7fda63a](https://github.com/aeolun/react-diff-viewer-continued/commit/7fda63afae8bcd98547c8bdff569d02256821b2d))
7
+
1
8
  ## [4.0.4](https://github.com/aeolun/react-diff-viewer-continued/compare/v4.0.3...v4.0.4) (2025-01-28)
2
9
 
3
10
 
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import type { ReactElement } from "react";
3
3
  import type { Change } from "diff";
4
- import { type DiffInformation, DiffMethod, DiffType, type LineInformation } from "./compute-lines";
5
- import { type ReactDiffViewerStyles, type ReactDiffViewerStylesOverride } from "./styles";
4
+ import { type DiffInformation, DiffMethod, DiffType, type LineInformation } from "./compute-lines.js";
5
+ import { type ReactDiffViewerStyles, type ReactDiffViewerStylesOverride } from "./styles.js";
6
6
  export declare enum LineNumberPrefix {
7
7
  LEFT = "L",
8
8
  RIGHT = "R"
@@ -41,12 +41,12 @@ const jsx_runtime_1 = require("react/jsx-runtime");
41
41
  const classnames_1 = __importDefault(require("classnames"));
42
42
  const React = __importStar(require("react"));
43
43
  const memoize_one_1 = __importDefault(require("memoize-one"));
44
- const compute_hidden_blocks_1 = require("./compute-hidden-blocks");
45
- const compute_lines_1 = require("./compute-lines");
46
- Object.defineProperty(exports, "DiffMethod", { enumerable: true, get: function () { return compute_lines_1.DiffMethod; } });
47
- const expand_1 = require("./expand");
48
- const styles_1 = __importDefault(require("./styles"));
49
- const fold_1 = require("./fold");
44
+ const compute_hidden_blocks_js_1 = require("./compute-hidden-blocks.js");
45
+ const compute_lines_js_1 = require("./compute-lines.js");
46
+ Object.defineProperty(exports, "DiffMethod", { enumerable: true, get: function () { return compute_lines_js_1.DiffMethod; } });
47
+ const expand_js_1 = require("./expand.js");
48
+ const styles_js_1 = __importDefault(require("./styles.js"));
49
+ const fold_js_1 = require("./fold.js");
50
50
  var LineNumberPrefix;
51
51
  (function (LineNumberPrefix) {
52
52
  LineNumberPrefix["LEFT"] = "L";
@@ -85,7 +85,7 @@ class DiffViewer extends React.Component {
85
85
  *
86
86
  * @param styles User supplied style overrides.
87
87
  */
88
- this.computeStyles = (0, memoize_one_1.default)(styles_1.default);
88
+ this.computeStyles = (0, memoize_one_1.default)(styles_js_1.default);
89
89
  /**
90
90
  * Returns a function with clicked line number in the closure. Returns an no-op function when no
91
91
  * onLineNumberClick handler is supplied.
@@ -111,10 +111,10 @@ class DiffViewer extends React.Component {
111
111
  : wordDiff.value;
112
112
  if (typeof content !== "string")
113
113
  return;
114
- return wordDiff.type === compute_lines_1.DiffType.ADDED ? ((0, jsx_runtime_1.jsx)("ins", { className: (0, classnames_1.default)(this.styles.wordDiff, {
115
- [this.styles.wordAdded]: wordDiff.type === compute_lines_1.DiffType.ADDED,
116
- }), children: content }, i)) : wordDiff.type === compute_lines_1.DiffType.REMOVED ? ((0, jsx_runtime_1.jsx)("del", { className: (0, classnames_1.default)(this.styles.wordDiff, {
117
- [this.styles.wordRemoved]: wordDiff.type === compute_lines_1.DiffType.REMOVED,
114
+ return wordDiff.type === compute_lines_js_1.DiffType.ADDED ? ((0, jsx_runtime_1.jsx)("ins", { className: (0, classnames_1.default)(this.styles.wordDiff, {
115
+ [this.styles.wordAdded]: wordDiff.type === compute_lines_js_1.DiffType.ADDED,
116
+ }), children: content }, i)) : wordDiff.type === compute_lines_js_1.DiffType.REMOVED ? ((0, jsx_runtime_1.jsx)("del", { className: (0, classnames_1.default)(this.styles.wordDiff, {
117
+ [this.styles.wordRemoved]: wordDiff.type === compute_lines_js_1.DiffType.REMOVED,
118
118
  }), children: content }, i)) : ((0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)(this.styles.wordDiff), children: content }, i));
119
119
  });
120
120
  };
@@ -136,9 +136,9 @@ class DiffViewer extends React.Component {
136
136
  const additionalLineNumberTemplate = `${additionalPrefix}-${additionalLineNumber}`;
137
137
  const highlightLine = this.props.highlightLines.includes(lineNumberTemplate) ||
138
138
  this.props.highlightLines.includes(additionalLineNumberTemplate);
139
- const added = type === compute_lines_1.DiffType.ADDED;
140
- const removed = type === compute_lines_1.DiffType.REMOVED;
141
- const changed = type === compute_lines_1.DiffType.CHANGED;
139
+ const added = type === compute_lines_js_1.DiffType.ADDED;
140
+ const removed = type === compute_lines_js_1.DiffType.REMOVED;
141
+ const changed = type === compute_lines_js_1.DiffType.CHANGED;
142
142
  let content;
143
143
  const hasWordDiff = Array.isArray(value);
144
144
  if (hasWordDiff) {
@@ -227,16 +227,16 @@ class DiffViewer extends React.Component {
227
227
  */
228
228
  this.renderInlineView = ({ left, right }, index) => {
229
229
  let content;
230
- if (left.type === compute_lines_1.DiffType.REMOVED && right.type === compute_lines_1.DiffType.ADDED) {
230
+ if (left.type === compute_lines_js_1.DiffType.REMOVED && right.type === compute_lines_js_1.DiffType.ADDED) {
231
231
  return ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [(0, jsx_runtime_1.jsx)("tr", { className: this.styles.line, children: this.renderLine(left.lineNumber, left.type, LineNumberPrefix.LEFT, left.value, null) }), (0, jsx_runtime_1.jsx)("tr", { className: this.styles.line, children: this.renderLine(null, right.type, LineNumberPrefix.RIGHT, right.value, right.lineNumber, LineNumberPrefix.RIGHT) })] }, index));
232
232
  }
233
- if (left.type === compute_lines_1.DiffType.REMOVED) {
233
+ if (left.type === compute_lines_js_1.DiffType.REMOVED) {
234
234
  content = this.renderLine(left.lineNumber, left.type, LineNumberPrefix.LEFT, left.value, null);
235
235
  }
236
- if (left.type === compute_lines_1.DiffType.DEFAULT) {
236
+ if (left.type === compute_lines_js_1.DiffType.DEFAULT) {
237
237
  content = this.renderLine(left.lineNumber, left.type, LineNumberPrefix.LEFT, left.value, right.lineNumber, LineNumberPrefix.RIGHT);
238
238
  }
239
- if (right.type === compute_lines_1.DiffType.ADDED) {
239
+ if (right.type === compute_lines_js_1.DiffType.ADDED) {
240
240
  content = this.renderLine(null, right.type, LineNumberPrefix.RIGHT, right.value, right.lineNumber);
241
241
  }
242
242
  return ((0, jsx_runtime_1.jsx)("tr", { className: this.styles.line, children: content }, index));
@@ -270,11 +270,11 @@ class DiffViewer extends React.Component {
270
270
  */
271
271
  this.renderDiff = () => {
272
272
  const { oldValue, newValue, splitView, disableWordDiff, compareMethod, linesOffset, } = this.props;
273
- const { lineInformation, diffLines } = (0, compute_lines_1.computeLineInformation)(oldValue, newValue, disableWordDiff, compareMethod, linesOffset, this.props.alwaysShowLines);
273
+ const { lineInformation, diffLines } = (0, compute_lines_js_1.computeLineInformation)(oldValue, newValue, disableWordDiff, compareMethod, linesOffset, this.props.alwaysShowLines);
274
274
  const extraLines = this.props.extraLinesSurroundingDiff < 0
275
275
  ? 0
276
276
  : Math.round(this.props.extraLinesSurroundingDiff);
277
- const { lineBlocks, blocks } = (0, compute_hidden_blocks_1.computeHiddenBlocks)(lineInformation, diffLines, extraLines);
277
+ const { lineBlocks, blocks } = (0, compute_hidden_blocks_js_1.computeHiddenBlocks)(lineInformation, diffLines, extraLines);
278
278
  const diffNodes = lineInformation.map((line, lineIndex) => {
279
279
  if (this.props.showDiffOnly) {
280
280
  const blockIndex = lineBlocks[lineIndex];
@@ -302,7 +302,7 @@ class DiffViewer extends React.Component {
302
302
  this.render = () => {
303
303
  const { oldValue, newValue, useDarkTheme, leftTitle, rightTitle, splitView, compareMethod, hideLineNumbers, nonce, } = this.props;
304
304
  if (typeof compareMethod === "string" &&
305
- compareMethod !== compute_lines_1.DiffMethod.JSON) {
305
+ compareMethod !== compute_lines_js_1.DiffMethod.JSON) {
306
306
  if (typeof oldValue !== "string" || typeof newValue !== "string") {
307
307
  throw Error('"oldValue" and "newValue" should be strings');
308
308
  }
@@ -322,16 +322,16 @@ class DiffViewer extends React.Component {
322
322
  let deletions = 0;
323
323
  let additions = 0;
324
324
  for (const l of nodes.lineInformation) {
325
- if (l.left.type === compute_lines_1.DiffType.ADDED) {
325
+ if (l.left.type === compute_lines_js_1.DiffType.ADDED) {
326
326
  additions++;
327
327
  }
328
- if (l.right.type === compute_lines_1.DiffType.ADDED) {
328
+ if (l.right.type === compute_lines_js_1.DiffType.ADDED) {
329
329
  additions++;
330
330
  }
331
- if (l.left.type === compute_lines_1.DiffType.REMOVED) {
331
+ if (l.left.type === compute_lines_js_1.DiffType.REMOVED) {
332
332
  deletions++;
333
333
  }
334
- if (l.right.type === compute_lines_1.DiffType.REMOVED) {
334
+ if (l.right.type === compute_lines_js_1.DiffType.REMOVED) {
335
335
  deletions++;
336
336
  }
337
337
  }
@@ -353,7 +353,7 @@ class DiffViewer extends React.Component {
353
353
  ? []
354
354
  : nodes.blocks.map((b) => b.index),
355
355
  });
356
- }, children: allExpanded ? (0, jsx_runtime_1.jsx)(fold_1.Fold, {}) : (0, jsx_runtime_1.jsx)(expand_1.Expand, {}) }), " ", totalChanges, (0, jsx_runtime_1.jsx)("div", { style: { display: "flex", gap: "1px" }, children: blocks }), this.props.summary ? (0, jsx_runtime_1.jsx)("span", { children: this.props.summary }) : null] }), (0, jsx_runtime_1.jsx)("table", { className: (0, classnames_1.default)(this.styles.diffContainer, {
356
+ }, children: allExpanded ? (0, jsx_runtime_1.jsx)(fold_js_1.Fold, {}) : (0, jsx_runtime_1.jsx)(expand_js_1.Expand, {}) }), " ", totalChanges, (0, jsx_runtime_1.jsx)("div", { style: { display: "flex", gap: "1px" }, children: blocks }), this.props.summary ? (0, jsx_runtime_1.jsx)("span", { children: this.props.summary }) : null] }), (0, jsx_runtime_1.jsx)("table", { className: (0, classnames_1.default)(this.styles.diffContainer, {
357
357
  [this.styles.splitView]: splitView,
358
358
  }), onMouseUp: () => {
359
359
  const elements = document.getElementsByClassName("right");
@@ -380,7 +380,7 @@ DiffViewer.defaultProps = {
380
380
  splitView: true,
381
381
  highlightLines: [],
382
382
  disableWordDiff: false,
383
- compareMethod: compute_lines_1.DiffMethod.CHARS,
383
+ compareMethod: compute_lines_js_1.DiffMethod.CHARS,
384
384
  styles: {},
385
385
  hideLineNumbers: false,
386
386
  extraLinesSurroundingDiff: 3,
@@ -2,11 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import cn from "classnames";
3
3
  import * as React from "react";
4
4
  import memoize from "memoize-one";
5
- import { computeHiddenBlocks } from "./compute-hidden-blocks";
6
- import { DiffMethod, DiffType, computeLineInformation, } from "./compute-lines";
7
- import { Expand } from "./expand";
8
- import computeStyles from "./styles";
9
- import { Fold } from "./fold";
5
+ import { computeHiddenBlocks } from "./compute-hidden-blocks.js";
6
+ import { DiffMethod, DiffType, computeLineInformation, } from "./compute-lines.js";
7
+ import { Expand } from "./expand.js";
8
+ import computeStyles from "./styles.js";
9
+ import { Fold } from "./fold.js";
10
10
  export var LineNumberPrefix;
11
11
  (function (LineNumberPrefix) {
12
12
  LineNumberPrefix["LEFT"] = "L";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-diff-viewer-continued",
3
- "version": "4.0.4",
3
+ "version": "4.0.5",
4
4
  "private": false,
5
5
  "description": "Continuation of a simple and beautiful text diff viewer component made with diff and React",
6
6
  "keywords": [