react-diff-viewer-continued 4.2.2 → 4.3.0
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/.github/workflows/pages.yml +36 -0
- package/.github/workflows/publish.yml +2 -10
- package/CHANGELOG.md +24 -0
- package/README.md +5 -3
- package/lib/cjs/src/index.d.ts +3 -2
- package/lib/cjs/src/index.js +1 -0
- package/lib/cjs/src/styles.d.ts +2 -0
- package/lib/cjs/src/styles.js +85 -55
- package/lib/cjs/src/workerBundle.d.ts +1 -1
- package/lib/cjs/src/workerBundle.js +1 -1
- package/lib/esm/src/index.js +1 -0
- package/lib/esm/src/styles.js +85 -55
- package/lib/esm/src/workerBundle.js +1 -1
- package/package.json +10 -7
- package/pnpm-workspace.yaml +7 -0
- package/publish-examples.sh +0 -10
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Deploy GitHub Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
deploy:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- uses: pnpm/action-setup@v4
|
|
18
|
+
with:
|
|
19
|
+
version: latest
|
|
20
|
+
|
|
21
|
+
- uses: actions/setup-node@v4
|
|
22
|
+
with:
|
|
23
|
+
node-version: 'lts/*'
|
|
24
|
+
cache: 'pnpm'
|
|
25
|
+
|
|
26
|
+
- run: pnpm install
|
|
27
|
+
|
|
28
|
+
- name: Configure git
|
|
29
|
+
run: |
|
|
30
|
+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
31
|
+
git config --global user.name "github-actions[bot]"
|
|
32
|
+
|
|
33
|
+
- name: Deploy examples to GitHub Pages
|
|
34
|
+
run: pnpm publish:examples
|
|
35
|
+
env:
|
|
36
|
+
GITHUB_REPO_URL: https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
|
|
@@ -33,16 +33,8 @@ jobs:
|
|
|
33
33
|
- run: pnpm install
|
|
34
34
|
- run: pnpm build
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
- run: npm install -g npm@latest
|
|
38
|
-
|
|
39
|
-
- name: Publish to npm
|
|
40
|
-
run: pnpm publish --access public --provenance --no-git-checks
|
|
41
|
-
env:
|
|
42
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
43
|
-
|
|
44
|
-
# Create GitHub release with changelog notes
|
|
45
|
-
- name: Create GitHub release
|
|
36
|
+
- name: Publish and create GitHub release
|
|
46
37
|
run: pnpm just-release
|
|
47
38
|
env:
|
|
48
39
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
40
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.3.0 (2026-07-10)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- export default light and dark theme variables
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- do not do extra publish step, just release publishes
|
|
12
|
+
- make exports immutable
|
|
13
|
+
- freeze dark theme variables and add export-existence tests
|
|
14
|
+
- add GitHub Pages deployment workflow and Vite base path
|
|
15
|
+
- isolate diff table from host table CSS (daisyui/bootstrap)
|
|
16
|
+
- bump js-yaml to ^4.2.0 (CVE-2026-53550)
|
|
17
|
+
- clear remaining audit advisories in dev toolchain
|
|
18
|
+
|
|
19
|
+
### Documentation
|
|
20
|
+
|
|
21
|
+
- add overscan, disableWorker, and loading overlay to README
|
|
22
|
+
|
|
23
|
+
### Chores
|
|
24
|
+
|
|
25
|
+
- make pnpm canonical (drop npm lockfile, approve builds)
|
|
26
|
+
|
|
3
27
|
## 4.2.2 (2026-04-23)
|
|
4
28
|
|
|
5
29
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -92,8 +92,9 @@ class Diff extends PureComponent {
|
|
|
92
92
|
| linesOffset | `number` | `0` | Number to start count code lines from. |
|
|
93
93
|
| summary | `string \| ReactElement` | `undefined` | Text or element to display in the summary bar (e.g., filename). |
|
|
94
94
|
| hideSummary | `boolean` | `false` | Hide the summary bar (expand/collapse button, change count, summary text). |
|
|
95
|
-
| infiniteLoading | `{ pageSize: number, containerHeight: string }` | `undefined` | Enable virtualization for large diffs. When enabled, only visible rows are rendered. `containerHeight` sets the scrollable container height (e.g., `'500px'` or `'80vh'`).
|
|
96
|
-
| loadingElement | `() => ReactElement` | `undefined` | Function that returns an element to display while the diff is being computed. Useful with `infiniteLoading` for large files.
|
|
95
|
+
| infiniteLoading | `{ pageSize: number, containerHeight: string, overscan?: number }` | `undefined` | Enable virtualization for large diffs. When enabled, only visible rows are rendered. `containerHeight` sets the scrollable container height (e.g., `'500px'` or `'80vh'`). `overscan` controls how many extra rows to render above and below the viewport (default `20`). |
|
|
96
|
+
| loadingElement | `() => ReactElement` | `undefined` | Function that returns an element to display while the diff is being computed or when content is hidden during fast scrolling. Useful with `infiniteLoading` for large files. |
|
|
97
|
+
| disableWorker | `boolean` | `false` | Disable the Web Worker used for diff computation, falling back to synchronous computation on the main thread. Useful when the worker bundle fails to load in certain bundler configurations. |
|
|
97
98
|
| nonce | `string` | `''` | Nonce to use for inline styles (for CSP). |
|
|
98
99
|
|
|
99
100
|
## Instance Methods
|
|
@@ -114,7 +115,8 @@ Enable virtualization to only render visible rows:
|
|
|
114
115
|
newValue={largeNewFile}
|
|
115
116
|
infiniteLoading={{
|
|
116
117
|
pageSize: 20,
|
|
117
|
-
containerHeight: '80vh'
|
|
118
|
+
containerHeight: '80vh',
|
|
119
|
+
overscan: 20,
|
|
118
120
|
}}
|
|
119
121
|
loadingElement={() => (
|
|
120
122
|
<div style={{ padding: '20px', textAlign: 'center' }}>
|
package/lib/cjs/src/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ReactElement, RefObject } from "react";
|
|
|
3
3
|
import type { Change } from "diff";
|
|
4
4
|
import { type Block } from "./compute-hidden-blocks.js";
|
|
5
5
|
import { type DiffInformation, DiffMethod, DiffType, type LineInformation } from "./compute-lines.js";
|
|
6
|
-
import { type ReactDiffViewerStyles, type ReactDiffViewerStylesOverride } from "./styles.js";
|
|
6
|
+
import { type ReactDiffViewerStyles, type ReactDiffViewerStylesOverride, type ReactDiffViewerStylesVariables } from "./styles.js";
|
|
7
7
|
export declare enum LineNumberPrefix {
|
|
8
8
|
LEFT = "L",
|
|
9
9
|
RIGHT = "R"
|
|
@@ -258,4 +258,5 @@ declare class DiffViewer extends React.Component<ReactDiffViewerProps, ReactDiff
|
|
|
258
258
|
export default DiffViewer;
|
|
259
259
|
export { DiffMethod };
|
|
260
260
|
export { default as computeStyles } from "./styles.js";
|
|
261
|
-
export
|
|
261
|
+
export { defaultLightThemeVariables, defaultDarkThemeVariables, } from "./styles.js";
|
|
262
|
+
export type { ReactDiffViewerStylesOverride, ReactDiffViewerStyles, ReactDiffViewerStylesVariables };
|
package/lib/cjs/src/index.js
CHANGED
package/lib/cjs/src/styles.d.ts
CHANGED
|
@@ -98,5 +98,7 @@ export interface ReactDiffViewerStylesOverride {
|
|
|
98
98
|
splitView?: Interpolation;
|
|
99
99
|
allExpandButton?: Interpolation;
|
|
100
100
|
}
|
|
101
|
+
export declare const defaultLightThemeVariables: Readonly<Required<ReactDiffViewerStylesVariables>>;
|
|
102
|
+
export declare const defaultDarkThemeVariables: Readonly<Required<ReactDiffViewerStylesVariables>>;
|
|
101
103
|
declare const _default: (styleOverride: ReactDiffViewerStylesOverride, useDarkTheme?: boolean, nonce?: string) => ReactDiffViewerStyles;
|
|
102
104
|
export default _default;
|
package/lib/cjs/src/styles.js
CHANGED
|
@@ -10,69 +10,74 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import createEmotion from "@emotion/css/create-instance";
|
|
13
|
+
export const defaultLightThemeVariables = Object.freeze({
|
|
14
|
+
diffViewerBackground: "#fff",
|
|
15
|
+
diffViewerColor: "#212529",
|
|
16
|
+
addedBackground: "#e6ffed",
|
|
17
|
+
addedColor: "#24292e",
|
|
18
|
+
removedBackground: "#ffeef0",
|
|
19
|
+
removedColor: "#24292e",
|
|
20
|
+
changedBackground: "#fffbdd",
|
|
21
|
+
wordAddedBackground: "#acf2bd",
|
|
22
|
+
wordRemovedBackground: "#fdb8c0",
|
|
23
|
+
addedGutterBackground: "#cdffd8",
|
|
24
|
+
removedGutterBackground: "#ffdce0",
|
|
25
|
+
gutterBackground: "#f7f7f7",
|
|
26
|
+
gutterBackgroundDark: "#f3f1f1",
|
|
27
|
+
highlightBackground: "#fffbdd",
|
|
28
|
+
highlightGutterBackground: "#fff5b1",
|
|
29
|
+
codeFoldGutterBackground: "#dbedff",
|
|
30
|
+
codeFoldBackground: "#f1f8ff",
|
|
31
|
+
emptyLineBackground: "#fafbfc",
|
|
32
|
+
gutterColor: "#212529",
|
|
33
|
+
addedGutterColor: "#212529",
|
|
34
|
+
removedGutterColor: "#212529",
|
|
35
|
+
codeFoldContentColor: "#212529",
|
|
36
|
+
diffViewerTitleBackground: "#fafbfc",
|
|
37
|
+
diffViewerTitleColor: "#212529",
|
|
38
|
+
diffViewerTitleBorderColor: "#eee",
|
|
39
|
+
});
|
|
40
|
+
export const defaultDarkThemeVariables = Object.freeze({
|
|
41
|
+
diffViewerBackground: "#2e303c",
|
|
42
|
+
diffViewerColor: "#FFF",
|
|
43
|
+
addedBackground: "#2ea04326",
|
|
44
|
+
addedColor: "white",
|
|
45
|
+
removedBackground: "#f851491a",
|
|
46
|
+
removedColor: "white",
|
|
47
|
+
changedBackground: "#3e302c",
|
|
48
|
+
wordAddedBackground: "#2ea04366",
|
|
49
|
+
wordRemovedBackground: "#f8514966",
|
|
50
|
+
addedGutterBackground: "#3fb9504d",
|
|
51
|
+
removedGutterBackground: "#f851494d",
|
|
52
|
+
gutterBackground: "#2c2f3a",
|
|
53
|
+
gutterBackgroundDark: "#262933",
|
|
54
|
+
highlightBackground: "#2a3967",
|
|
55
|
+
highlightGutterBackground: "#2d4077",
|
|
56
|
+
codeFoldGutterBackground: "#262831",
|
|
57
|
+
codeFoldBackground: "#262831",
|
|
58
|
+
emptyLineBackground: "#363946",
|
|
59
|
+
gutterColor: "#f0f6fc",
|
|
60
|
+
addedGutterColor: "#f0f6fc",
|
|
61
|
+
removedGutterColor: "#f0f6fc",
|
|
62
|
+
codeFoldContentColor: "#9198a1",
|
|
63
|
+
diffViewerTitleBackground: "#2f323e",
|
|
64
|
+
diffViewerTitleColor: "#f0f6fc",
|
|
65
|
+
diffViewerTitleBorderColor: "#353846",
|
|
66
|
+
});
|
|
13
67
|
export default (styleOverride, useDarkTheme = false, nonce = "") => {
|
|
14
68
|
const { variables: overrideVariables = {} } = styleOverride, styles = __rest(styleOverride, ["variables"]);
|
|
15
69
|
const themeVariables = {
|
|
16
|
-
light: Object.assign({
|
|
17
|
-
|
|
18
|
-
diffViewerColor: "#212529",
|
|
19
|
-
addedBackground: "#e6ffed",
|
|
20
|
-
addedColor: "#24292e",
|
|
21
|
-
removedBackground: "#ffeef0",
|
|
22
|
-
removedColor: "#24292e",
|
|
23
|
-
changedBackground: "#fffbdd",
|
|
24
|
-
wordAddedBackground: "#acf2bd",
|
|
25
|
-
wordRemovedBackground: "#fdb8c0",
|
|
26
|
-
addedGutterBackground: "#cdffd8",
|
|
27
|
-
removedGutterBackground: "#ffdce0",
|
|
28
|
-
gutterBackground: "#f7f7f7",
|
|
29
|
-
gutterBackgroundDark: "#f3f1f1",
|
|
30
|
-
highlightBackground: "#fffbdd",
|
|
31
|
-
highlightGutterBackground: "#fff5b1",
|
|
32
|
-
codeFoldGutterBackground: "#dbedff",
|
|
33
|
-
codeFoldBackground: "#f1f8ff",
|
|
34
|
-
emptyLineBackground: "#fafbfc",
|
|
35
|
-
gutterColor: "#212529",
|
|
36
|
-
addedGutterColor: "#212529",
|
|
37
|
-
removedGutterColor: "#212529",
|
|
38
|
-
codeFoldContentColor: "#212529",
|
|
39
|
-
diffViewerTitleBackground: "#fafbfc",
|
|
40
|
-
diffViewerTitleColor: "#212529",
|
|
41
|
-
diffViewerTitleBorderColor: "#eee",
|
|
42
|
-
}, (overrideVariables.light || {})),
|
|
43
|
-
dark: Object.assign({
|
|
44
|
-
diffViewerBackground: "#2e303c",
|
|
45
|
-
diffViewerColor: "#FFF",
|
|
46
|
-
addedBackground: "#2ea04326",
|
|
47
|
-
addedColor: "white",
|
|
48
|
-
removedBackground: "#f851491a",
|
|
49
|
-
removedColor: "white",
|
|
50
|
-
changedBackground: "#3e302c",
|
|
51
|
-
wordAddedBackground: "#2ea04366",
|
|
52
|
-
wordRemovedBackground: "#f8514966",
|
|
53
|
-
addedGutterBackground: "#3fb9504d",
|
|
54
|
-
removedGutterBackground: "#f851494d",
|
|
55
|
-
gutterBackground: "#2c2f3a",
|
|
56
|
-
gutterBackgroundDark: "#262933",
|
|
57
|
-
highlightBackground: "#2a3967",
|
|
58
|
-
highlightGutterBackground: "#2d4077",
|
|
59
|
-
codeFoldGutterBackground: "#262831",
|
|
60
|
-
codeFoldBackground: "#262831",
|
|
61
|
-
emptyLineBackground: "#363946",
|
|
62
|
-
gutterColor: "#f0f6fc",
|
|
63
|
-
addedGutterColor: "#f0f6fc",
|
|
64
|
-
removedGutterColor: "#f0f6fc",
|
|
65
|
-
codeFoldContentColor: "#9198a1",
|
|
66
|
-
diffViewerTitleBackground: "#2f323e",
|
|
67
|
-
diffViewerTitleColor: "#f0f6fc",
|
|
68
|
-
diffViewerTitleBorderColor: "#353846",
|
|
69
|
-
}, (overrideVariables.dark || {})),
|
|
70
|
+
light: Object.assign(Object.assign({}, defaultLightThemeVariables), (overrideVariables.light || {})),
|
|
71
|
+
dark: Object.assign(Object.assign({}, defaultDarkThemeVariables), (overrideVariables.dark || {})),
|
|
70
72
|
};
|
|
71
73
|
const variables = useDarkTheme ? themeVariables.dark : themeVariables.light;
|
|
72
74
|
const { css, cx } = createEmotion({ key: "react-diff", nonce });
|
|
73
75
|
const content = css({
|
|
74
76
|
width: "auto",
|
|
75
77
|
overflow: "hidden",
|
|
78
|
+
// Host `:where(th,td){ padding }` (daisyui `.table`) would indent the code
|
|
79
|
+
// column; we own horizontal spacing via gutter/marker instead.
|
|
80
|
+
padding: 0,
|
|
76
81
|
label: "content",
|
|
77
82
|
});
|
|
78
83
|
const splitView = css({
|
|
@@ -114,6 +119,18 @@ export default (styleOverride, useDarkTheme = false, nonce = "") => {
|
|
|
114
119
|
},
|
|
115
120
|
label: "diff-container",
|
|
116
121
|
borderCollapse: "collapse",
|
|
122
|
+
borderRadius: 0,
|
|
123
|
+
// Isolate from host table CSS (e.g. daisyui `.table` / `.table-zebra`, Bootstrap,
|
|
124
|
+
// etc.). Such frameworks emit their table rules inside `@layer` with `:where()`
|
|
125
|
+
// selectors, so these unlayered declarations win regardless of specificity. We
|
|
126
|
+
// only reset properties a host injects onto our rows/cells that we do NOT set
|
|
127
|
+
// ourselves per-cell — background, font-size and padding are pinned on the
|
|
128
|
+
// individual line/gutter/marker/content classes instead, so this container rule
|
|
129
|
+
// never outranks and clobbers our own diff colouring.
|
|
130
|
+
"& td, & th": {
|
|
131
|
+
border: 0,
|
|
132
|
+
verticalAlign: "baseline",
|
|
133
|
+
},
|
|
117
134
|
"@media (max-width: 768px)": {
|
|
118
135
|
minWidth: "unset",
|
|
119
136
|
},
|
|
@@ -232,11 +249,15 @@ export default (styleOverride, useDarkTheme = false, nonce = "") => {
|
|
|
232
249
|
label: "code-fold-gutter",
|
|
233
250
|
minWidth: "50px",
|
|
234
251
|
width: "50px",
|
|
252
|
+
// Neutralize host `:where(th,td){ padding }` on the fold gutter cell.
|
|
253
|
+
padding: 0,
|
|
235
254
|
textAlign: "center",
|
|
236
255
|
fill: variables.codeFoldContentColor,
|
|
237
256
|
});
|
|
238
257
|
const codeFoldContentContainer = css({
|
|
239
|
-
padding
|
|
258
|
+
// Neutralize host `:where(th,td){ padding }` on the fold content cell.
|
|
259
|
+
padding: 0,
|
|
260
|
+
label: "code-fold-content-container",
|
|
240
261
|
});
|
|
241
262
|
const codeFoldExpandButton = css({
|
|
242
263
|
background: variables.codeFoldBackground,
|
|
@@ -299,6 +320,10 @@ export default (styleOverride, useDarkTheme = false, nonce = "") => {
|
|
|
299
320
|
width: 28,
|
|
300
321
|
paddingLeft: 10,
|
|
301
322
|
paddingRight: 10,
|
|
323
|
+
// Host `padding-block` (daisyui `:where(th,td){ padding }`) would misalign the
|
|
324
|
+
// +/- marker against its line; pin the vertical padding to zero.
|
|
325
|
+
paddingTop: 0,
|
|
326
|
+
paddingBottom: 0,
|
|
302
327
|
userSelect: "none",
|
|
303
328
|
label: "marker",
|
|
304
329
|
[`&.${diffAdded}`]: {
|
|
@@ -368,6 +393,11 @@ export default (styleOverride, useDarkTheme = false, nonce = "") => {
|
|
|
368
393
|
verticalAlign: "baseline",
|
|
369
394
|
label: "line",
|
|
370
395
|
textDecoration: "none",
|
|
396
|
+
// Neutralize host row styling (e.g. daisyui `.table-zebra` striping and the
|
|
397
|
+
// `tr { font-size }` set by `.table-*` size variants). Cell-level diff colours
|
|
398
|
+
// are painted on the td, so a transparent row lets them show through.
|
|
399
|
+
backgroundColor: "transparent",
|
|
400
|
+
fontSize: 12,
|
|
371
401
|
});
|
|
372
402
|
const column = css({});
|
|
373
403
|
const defaultStyles = {
|