@canonical/react-ds-app-launchpad 0.9.0-experimental.14 → 0.9.0-experimental.16
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/dist/esm/ui/GitDiffViewer/Provider.js +1 -7
- package/dist/esm/ui/GitDiffViewer/Provider.js.map +1 -1
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.js +43 -81
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.js.map +1 -1
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/AnnotatedDiffLine.js +33 -0
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/AnnotatedDiffLine.js.map +1 -0
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/index.js +4 -0
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/index.js.map +1 -0
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/styles.css +15 -0
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/types.js +3 -0
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/types.js.map +1 -0
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.js +10 -7
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.js.map +1 -1
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/styles.css +11 -1
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/constants.js +2 -0
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/constants.js.map +1 -0
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/styles.css +0 -14
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/utils/updateTableWidth.js +6 -0
- package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/utils/updateTableWidth.js.map +1 -0
- package/dist/esm/ui/GitDiffViewer/common/FileHeader/styles.css +7 -3
- package/dist/esm/ui/GitDiffViewer/styles.css +1 -1
- package/dist/esm/ui/GitDiffViewer/utils/highlightDiffHunkLines.js +38 -0
- package/dist/esm/ui/GitDiffViewer/utils/highlightDiffHunkLines.js.map +1 -0
- package/dist/esm/ui/GitDiffViewer/utils/index.js +1 -0
- package/dist/esm/ui/GitDiffViewer/utils/index.js.map +1 -1
- package/dist/esm/ui/GitDiffViewer/utils/parseGitDiff.js +3 -0
- package/dist/esm/ui/GitDiffViewer/utils/parseGitDiff.js.map +1 -1
- package/dist/types/ui/GitDiffViewer/Provider.d.ts.map +1 -1
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.d.ts +3 -12
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.d.ts.map +1 -1
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/AnnotatedDiffLine.d.ts +10 -0
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/AnnotatedDiffLine.d.ts.map +1 -0
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/index.d.ts +3 -0
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/index.d.ts.map +1 -0
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/types.d.ts +10 -0
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/types.d.ts.map +1 -0
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.d.ts +1 -1
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.d.ts.map +1 -1
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/types.d.ts +9 -2
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/types.d.ts.map +1 -1
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/constants.d.ts +2 -0
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/constants.d.ts.map +1 -0
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/types.d.ts +19 -3
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/types.d.ts.map +1 -1
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/utils/updateTableWidth.d.ts +3 -0
- package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/utils/updateTableWidth.d.ts.map +1 -0
- package/dist/types/ui/GitDiffViewer/types.d.ts +2 -3
- package/dist/types/ui/GitDiffViewer/types.d.ts.map +1 -1
- package/dist/types/ui/GitDiffViewer/utils/highlightDiffHunkLines.d.ts +4 -0
- package/dist/types/ui/GitDiffViewer/utils/highlightDiffHunkLines.d.ts.map +1 -0
- package/dist/types/ui/GitDiffViewer/utils/index.d.ts +1 -0
- package/dist/types/ui/GitDiffViewer/utils/index.d.ts.map +1 -1
- package/dist/types/ui/GitDiffViewer/utils/parseGitDiff.d.ts.map +1 -1
- package/package.json +2 -2
@@ -4,12 +4,8 @@ import Context from "./Context.js";
|
|
4
4
|
import "./styles.css";
|
5
5
|
const componentCssClassName = "ds git-diff-viewer";
|
6
6
|
const Provider = ({ id, className, style, children, ...contextOptions }) => {
|
7
|
-
const [addCommentEnabled, setAddCommentEnabled] = useState(false);
|
8
7
|
const [addCommentOpenLocations, setAddCommentOpenLocations] = useState(new Set());
|
9
8
|
const toggleAddCommentLocation = useCallback((lineNumber) => {
|
10
|
-
if (!addCommentEnabled) {
|
11
|
-
return;
|
12
|
-
}
|
13
9
|
const newSet = new Set(addCommentOpenLocations);
|
14
10
|
if (newSet.has(lineNumber)) {
|
15
11
|
newSet.delete(lineNumber);
|
@@ -18,11 +14,9 @@ const Provider = ({ id, className, style, children, ...contextOptions }) => {
|
|
18
14
|
newSet.add(lineNumber);
|
19
15
|
}
|
20
16
|
setAddCommentOpenLocations(newSet);
|
21
|
-
}, [addCommentOpenLocations
|
17
|
+
}, [addCommentOpenLocations]);
|
22
18
|
return (_jsx(Context.Provider, { value: {
|
23
19
|
...contextOptions,
|
24
|
-
addCommentEnabled,
|
25
|
-
setAddCommentEnabled,
|
26
20
|
addCommentOpenLocations,
|
27
21
|
toggleAddCommentLocation,
|
28
22
|
}, children: _jsx("div", { id: id, style: style, className: [componentCssClassName, className].filter(Boolean).join(" "), children: children }) }));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../../src/ui/GitDiffViewer/Provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,cAAc,CAAC;AAGtB,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD,MAAM,QAAQ,GAAG,CAAC,EAChB,EAAE,EACF,SAAS,EACT,KAAK,EACL,QAAQ,EACR,GAAG,cAAc,EACD,EAAsB,EAAE;IACxC,MAAM,CAAC,
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../../src/ui/GitDiffViewer/Provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,cAAc,CAAC;AAGtB,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD,MAAM,QAAQ,GAAG,CAAC,EAChB,EAAE,EACF,SAAS,EACT,KAAK,EACL,QAAQ,EACR,GAAG,cAAc,EACD,EAAsB,EAAE;IACxC,MAAM,CAAC,uBAAuB,EAAE,0BAA0B,CAAC,GAAG,QAAQ,CAEpE,IAAI,GAAG,EAAE,CAAC,CAAC;IAEb,MAAM,wBAAwB,GAAG,WAAW,CAC1C,CAAC,UAAkB,EAAE,EAAE;QACrB,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,uBAAuB,CAAC,CAAC;QAChD,IAAI,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACzB,CAAC;QACD,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC,EACD,CAAC,uBAAuB,CAAC,CAC1B,CAAC;IAEF,OAAO,CACL,KAAC,OAAO,CAAC,QAAQ,IACf,KAAK,EAAE;YACL,GAAG,cAAc;YACjB,uBAAuB;YACvB,wBAAwB;SACzB,YAED,cACE,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAEtE,QAAQ,GACL,GACW,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -1,56 +1,28 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import { Fragment,
|
2
|
+
import { Fragment, forwardRef, useEffect, useImperativeHandle, useMemo, useRef, } from "react";
|
3
|
+
import { highlightDiffHunkLines } from "ui/GitDiffViewer/utils/index.js";
|
3
4
|
import { useGitDiffViewer } from "../../hooks/index.js";
|
4
5
|
import { DiffLine } from "./common/index.js";
|
5
|
-
import "./styles.css";
|
6
|
-
// TODO: decide where to put this once we provide an external syntax highlighter option
|
7
|
-
import hljs from "highlight.js";
|
8
6
|
import "./HighlighTheme.css";
|
7
|
+
import "./styles.css";
|
8
|
+
import { AnnotatedDiffLine } from "./common/AnnotatedDiffLine/index.js";
|
9
|
+
import updateTableWidth from "./utils/updateTableWidth.js";
|
9
10
|
const componentCssClassName = "ds code-diff-viewer";
|
10
|
-
const tableWidthCSSVar = "--table-width";
|
11
11
|
/**
|
12
12
|
* Displays a diff in a table format with line numbers and syntax highlighting.
|
13
13
|
* With option to add comments to specific lines and interactive gutter for adding comments.
|
14
14
|
*
|
15
15
|
* @returns {React.ReactElement} - Rendered CodeDiffViewer
|
16
16
|
*/
|
17
|
-
const CodeDiffViewer = ({ id, AddComment, className, style, }) => {
|
18
|
-
const { isCollapsed, diff
|
17
|
+
const CodeDiffViewer = ({ id, AddComment, onLineClick, className, style, disableWidthCalculation = false, }, ref) => {
|
18
|
+
const { isCollapsed, diff } = useGitDiffViewer();
|
19
19
|
const tableRef = useRef(null);
|
20
|
-
// TODO: temporary syntax highlighting
|
21
|
-
// replace with a proper syntax highlighter
|
22
|
-
// add support for option to have external syntax highlighter
|
23
|
-
const diffCodeLanguage = useMemo(() => {
|
24
|
-
const extension = diff?.newPath.split(".").pop();
|
25
|
-
const mapping = {
|
26
|
-
js: "javascript",
|
27
|
-
jsx: "javascript",
|
28
|
-
ts: "typescript",
|
29
|
-
tsx: "typescript",
|
30
|
-
css: "css",
|
31
|
-
scss: "scss",
|
32
|
-
html: "xml",
|
33
|
-
py: "python",
|
34
|
-
java: "java",
|
35
|
-
// Add more mappings as needed
|
36
|
-
};
|
37
|
-
return mapping[extension || ""] || "plaintext";
|
38
|
-
}, [diff?.newPath]);
|
39
|
-
const highlight = useCallback((code) => {
|
40
|
-
if (hljs.getLanguage(diffCodeLanguage)) {
|
41
|
-
return hljs.highlight(code, { language: diffCodeLanguage }).value;
|
42
|
-
}
|
43
|
-
return hljs.highlight(code, { language: "plaintext" }).value;
|
44
|
-
}, [diffCodeLanguage]);
|
45
20
|
const highlightedLines = useMemo(() => {
|
46
21
|
if (!diff)
|
47
22
|
return [];
|
48
|
-
return diff.hunks.map((hunk) =>
|
49
|
-
|
50
|
-
|
51
|
-
});
|
52
|
-
});
|
53
|
-
}, [diff, highlight]);
|
23
|
+
return diff.hunks.map((hunk) => highlightDiffHunkLines(hunk.lines));
|
24
|
+
}, [diff]);
|
25
|
+
useImperativeHandle(ref, () => tableRef.current);
|
54
26
|
/**
|
55
27
|
* Observe the table for size changes and update the CSS variable
|
56
28
|
*/
|
@@ -58,61 +30,51 @@ const CodeDiffViewer = ({ id, AddComment, className, style, }) => {
|
|
58
30
|
// SSR check
|
59
31
|
if (typeof ResizeObserver === "undefined")
|
60
32
|
return;
|
33
|
+
if (disableWidthCalculation)
|
34
|
+
return;
|
61
35
|
if (!tableRef.current)
|
62
36
|
return;
|
63
37
|
const resizeObserver = new ResizeObserver(() => {
|
64
38
|
if (!tableRef.current)
|
65
39
|
return;
|
66
|
-
|
67
|
-
tableRef.current.style.cssText = `${tableWidthCSSVar}: ${tableWidth}px`;
|
40
|
+
updateTableWidth(tableRef.current);
|
68
41
|
});
|
69
|
-
// Observe the table for size changes
|
70
42
|
resizeObserver.observe(tableRef.current);
|
71
|
-
// Cleanup on unmount
|
72
43
|
return () => {
|
73
44
|
resizeObserver.disconnect();
|
74
45
|
};
|
75
|
-
}, []);
|
76
|
-
useEffect(() => {
|
77
|
-
if (AddComment && !addCommentEnabled) {
|
78
|
-
setAddCommentEnabled(true);
|
79
|
-
}
|
80
|
-
else if (!AddComment && addCommentEnabled) {
|
81
|
-
setAddCommentEnabled(false);
|
82
|
-
}
|
83
|
-
}, [AddComment, addCommentEnabled, setAddCommentEnabled]);
|
46
|
+
}, [disableWidthCalculation]);
|
84
47
|
return (_jsx("div", { id: id, style: style, className: [componentCssClassName, className, isCollapsed && "collapsed"]
|
85
48
|
.filter(Boolean)
|
86
|
-
.join(" "), children: diff.hunks.map((hunk, hunkIndex) => {
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
}) }));
|
49
|
+
.join(" "), children: _jsx("div", { className: "diff-hunk", children: _jsx("table", { className: "diff-table", ref: tableRef, tabIndex: -1, children: _jsx("tbody", { children: diff.hunks.map((hunk, hunkIndex) => {
|
50
|
+
// We'll track the counters for old and new lines
|
51
|
+
// as we iterate through each hunk.
|
52
|
+
let oldLineCounter = hunk.oldStart;
|
53
|
+
let newLineCounter = hunk.newStart;
|
54
|
+
return (_jsxs(Fragment, { children: [_jsx(DiffLine, { type: "hunk", hunkHeader: hunk.header, hunkIndex: hunkIndex }), hunk.lines.map((line, lineIndex) => {
|
55
|
+
let lineNum1 = null;
|
56
|
+
let lineNum2 = null;
|
57
|
+
if (line.type === "remove") {
|
58
|
+
// Only the old line number advances
|
59
|
+
lineNum1 = oldLineCounter++;
|
60
|
+
}
|
61
|
+
else if (line.type === "add") {
|
62
|
+
// Only the new line number advances
|
63
|
+
lineNum2 = newLineCounter++;
|
64
|
+
}
|
65
|
+
else {
|
66
|
+
// context line => both lines advance
|
67
|
+
lineNum1 = oldLineCounter++;
|
68
|
+
lineNum2 = newLineCounter++;
|
69
|
+
}
|
70
|
+
// For rendering, if lineNum1 or lineNum2 is null,
|
71
|
+
// you can display e.g. '+' or '-' or an empty cell.
|
72
|
+
return (
|
73
|
+
// Normal diff line
|
74
|
+
_jsx(AnnotatedDiffLine, { lineNum1: lineNum1, lineNum2: lineNum2, content: highlightedLines[hunkIndex][lineIndex], type: line.type, diffLineNumber: hunk.diffStart + lineIndex, onLineClick: onLineClick, AddComment: AddComment }, `${diff.oldPath}-${hunkIndex}-${lineIndex}`));
|
75
|
+
})] }, `${diff.oldPath}-${hunkIndex}`));
|
76
|
+
}) }) }) }) }));
|
115
77
|
};
|
116
78
|
CodeDiffViewer.displayName = "GitDiffViewer.CodeDiff";
|
117
|
-
export default CodeDiffViewer;
|
79
|
+
export default forwardRef(CodeDiffViewer);
|
118
80
|
//# sourceMappingURL=CodeDiffViewer.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CodeDiffViewer.js","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.tsx"],"names":[],"mappings":";AAEA,OAAO,
|
1
|
+
{"version":3,"file":"CodeDiffViewer.js","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,QAAQ,EACR,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,qBAAqB,CAAC;AAC7B,OAAO,cAAc,CAAC;AAGtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAE3D,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,cAAc,GAAG,CACrB,EACE,EAAE,EACF,UAAU,EACV,WAAW,EACX,SAAS,EACT,KAAK,EACL,uBAAuB,GAAG,KAAK,GACX,EACtB,GAAgC,EACL,EAAE;IAC7B,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,gBAAgB,EAAE,CAAC;IACjD,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAEhD,MAAM,gBAAgB,GAAe,OAAO,CAAC,GAAG,EAAE;QAChD,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,CAAC;QAErB,O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OAAO,IAAI,SAAS,EAAE,CAwClC,CACZ,CAAC;oBACJ,CAAC,CAAC,GACI,GACF,GACJ,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,cAAc,CAAC,WAAW,GAAG,wBAAwB,CAAC;AAEtD,eAAe,UAAU,CAAC,cAAc,CAAC,CAAC"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import "./styles.css";
|
3
|
+
import { useCallback } from "react";
|
4
|
+
import { useGitDiffViewer } from "../../../../hooks/index.js";
|
5
|
+
import DiffLine from "../DiffLine/DiffLine.js";
|
6
|
+
const componentCssClassName = "ds annotated-diff-line";
|
7
|
+
/**
|
8
|
+
* A component that displays a diff line content, line decorations and AddComment component.
|
9
|
+
* @returns {React.ReactElement} - Rendered AnnotatedDiffLine
|
10
|
+
*/
|
11
|
+
const AnnotatedDiffLine = ({ lineNum1, lineNum2, diffLineNumber, AddComment, onLineClick, ...rest }) => {
|
12
|
+
const { addCommentOpenLocations, toggleAddCommentLocation, lineDecorations } = useGitDiffViewer();
|
13
|
+
const lineNumber = Number(lineNum2 || lineNum1 || 0);
|
14
|
+
const diffLineIsInteractive = Boolean(onLineClick || AddComment);
|
15
|
+
const handleLineClick = useCallback(() => {
|
16
|
+
if (diffLineIsInteractive) {
|
17
|
+
onLineClick?.({ lineNumber, diffLineNumber });
|
18
|
+
toggleAddCommentLocation(lineNumber);
|
19
|
+
}
|
20
|
+
}, [
|
21
|
+
onLineClick,
|
22
|
+
lineNumber,
|
23
|
+
diffLineNumber,
|
24
|
+
toggleAddCommentLocation,
|
25
|
+
diffLineIsInteractive,
|
26
|
+
]);
|
27
|
+
const handleCloseComment = useCallback(() => {
|
28
|
+
toggleAddCommentLocation(lineNumber);
|
29
|
+
}, [toggleAddCommentLocation, lineNumber]);
|
30
|
+
return (_jsxs(_Fragment, { children: [_jsx(DiffLine, { ...rest, lineNum1: lineNum1, lineNum2: lineNum2, onLineClick: diffLineIsInteractive ? handleLineClick : undefined }), lineNum2 && lineDecorations?.[lineNum2] && (_jsx("tr", { className: componentCssClassName, children: _jsx("td", { className: "container", children: lineDecorations[lineNum2] }) })), lineNum2 && AddComment && addCommentOpenLocations.has(lineNum2) && (_jsx("tr", { className: componentCssClassName, children: _jsx("td", { className: "container", children: _jsx(AddComment, { lineNumber: lineNumber, diffLineNumber: diffLineNumber, onClose: handleCloseComment }) }) }))] }));
|
31
|
+
};
|
32
|
+
export default AnnotatedDiffLine;
|
33
|
+
//# sourceMappingURL=AnnotatedDiffLine.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AnnotatedDiffLine.js","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/AnnotatedDiffLine.tsx"],"names":[],"mappings":";AAGA,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAE/C,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CAAC,EACzB,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,UAAU,EACV,WAAW,EACX,GAAG,IAAI,EACgB,EAAsB,EAAE;IAC/C,MAAM,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,eAAe,EAAE,GAC1E,gBAAgB,EAAE,CAAC;IAErB,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,IAAI,QAAQ,IAAI,CAAC,CAAC,CAAC;IACrD,MAAM,qBAAqB,GAAG,OAAO,CAAC,WAAW,IAAI,UAAU,CAAC,CAAC;IAEjE,MAAM,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE;QACvC,IAAI,qBAAqB,EAAE,CAAC;YAC1B,WAAW,EAAE,CAAC,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC;YAC9C,wBAAwB,CAAC,UAAU,CAAC,CAAC;QACvC,CAAC;IACH,CAAC,EAAE;QACD,WAAW;QACX,UAAU;QACV,cAAc;QACd,wBAAwB;QACxB,qBAAqB;KACtB,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC1C,wBAAwB,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC,CAAC;IAE3C,OAAO,CACL,8BACE,KAAC,QAAQ,OACH,IAAI,EACR,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,qBAAqB,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,GAChE,EACD,QAAQ,IAAI,eAAe,EAAE,CAAC,QAAQ,CAAC,IAAI,CAC1C,aAAI,SAAS,EAAE,qBAAqB,YAClC,aAAI,SAAS,EAAC,WAAW,YAAE,eAAe,CAAC,QAAQ,CAAC,GAAM,GACvD,CACN,EAEA,QAAQ,IAAI,UAAU,IAAI,uBAAuB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAClE,aAAI,SAAS,EAAE,qBAAqB,YAClC,aAAI,SAAS,EAAC,WAAW,YACvB,KAAC,UAAU,IACT,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,kBAAkB,GAC3B,GACC,GACF,CACN,IACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACtE,cAAc,YAAY,CAAC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/* @canonical/generator-ds 0.9.0-experimental.12 */
|
2
|
+
|
3
|
+
.ds.annotated-diff-line {
|
4
|
+
display: flex;
|
5
|
+
position: sticky;
|
6
|
+
left: 0;
|
7
|
+
width: var(--table-width);
|
8
|
+
.container {
|
9
|
+
width: 100%;
|
10
|
+
border: 1px solid var(--git-diff-viewer-border-color-tinted);
|
11
|
+
border-width: 1px 0;
|
12
|
+
border-radius: 1px;
|
13
|
+
padding: 0;
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/types.ts"],"names":[],"mappings":"AAAA,mDAAmD"}
|
@@ -2,26 +2,29 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useGitDiffViewer } from "../../../../hooks/index.js";
|
3
3
|
import "./styles.css";
|
4
4
|
const componentCssClassName = "ds diff-line";
|
5
|
+
const firstHunkLineCssClassName = "is-first-hunk";
|
5
6
|
/**
|
6
7
|
* Displays a single line of a diff as a table row with line numbers.
|
7
8
|
*
|
8
9
|
* @returns {React.ReactElement} - Rendered DiffLine
|
9
10
|
*/
|
10
|
-
const DiffLine = ({ id, className, style, ...props }) => {
|
11
|
-
const { wrapLines
|
12
|
-
const gutterIsInteractive = addCommentEnabled;
|
11
|
+
const DiffLine = ({ id, className, style, onLineClick, ...props }) => {
|
12
|
+
const { wrapLines } = useGitDiffViewer();
|
13
13
|
const typeClass = `diff-line-${props.type}`;
|
14
|
-
const
|
14
|
+
const isInteractive = Boolean(onLineClick);
|
15
15
|
return (_jsxs("tr", { id: id, style: style, className: [
|
16
16
|
componentCssClassName,
|
17
17
|
typeClass,
|
18
|
-
|
18
|
+
isInteractive && "interactive",
|
19
19
|
className,
|
20
|
+
props.type === "hunk" &&
|
21
|
+
props.hunkIndex === 0 &&
|
22
|
+
firstHunkLineCssClassName,
|
20
23
|
]
|
21
24
|
.filter(Boolean)
|
22
|
-
.join(" "), children: [_jsx("td", { className: `diff-gutter ${wrapLines ? "wrap" : ""} ${props.type}`, tabIndex:
|
25
|
+
.join(" "), children: [_jsx("td", { className: `diff-gutter ${wrapLines ? "wrap" : ""} ${props.type}`, tabIndex: isInteractive && props.type !== "hunk" ? 0 : undefined, onClick: onLineClick, onKeyUp: (e) => {
|
23
26
|
if (e.key === "Enter") {
|
24
|
-
|
27
|
+
onLineClick?.();
|
25
28
|
}
|
26
29
|
}, onKeyDown: undefined, children: props.type === "hunk" ? ("\u00A0") : (_jsxs("div", { className: "diff-line-numbers", children: [_jsx("span", { className: "line-num", children: props.lineNum1 ?? "+" }), _jsx("span", { className: "line-num", children: props.lineNum2 ?? "-" })] })) }), _jsx("td", { className: `diff-content ${wrapLines ? "wrap" : ""}`, children: props.type === "hunk" ? (_jsx("pre", { children: props.hunkHeader })) : (_jsx("pre", {
|
27
30
|
// biome-ignore lint/security/noDangerouslySetInnerHtml: syntax highlighting requires adding generated HTML
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DiffLine.js","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,cAAc,CAAC;AAGtB,MAAM,qBAAqB,GAAG,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"DiffLine.js","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,cAAc,CAAC;AAGtB,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAC7C,MAAM,yBAAyB,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EACzD,eAAM,SAAS,EAAC,UAAU,YAAE,KAAK,CAAC,QAAQ,IAAI,GAAG,GAAQ,IACrD,CACP,GACE,EACL,aAAI,SAAS,EAAE,gBAAgB,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,YACrD,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CACvB,wBAAM,KAAK,CAAC,UAAU,GAAO,CAC9B,CAAC,CAAC,CAAC,CACF;oBACE,2GAA2G;oBAC3G,uBAAuB,EAAE;wBACvB,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;qBACjD,GACD,CACH,GACE,IACF,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -6,6 +6,10 @@
|
|
6
6
|
min-width: var(--table-width);
|
7
7
|
color: var(--git-diff-viewer-code-default-color);
|
8
8
|
|
9
|
+
pre {
|
10
|
+
color: var(--git-diff-viewer-code-default-color);
|
11
|
+
}
|
12
|
+
|
9
13
|
&.diff-line-add {
|
10
14
|
background-color: var(--git-diff-viewer-code-insertion-background);
|
11
15
|
|
@@ -34,7 +38,13 @@
|
|
34
38
|
background-color: var(--git-diff-viewer-hunk-header-background);
|
35
39
|
color: var(--git-diff-viewer-hunk-header-color);
|
36
40
|
user-select: none;
|
37
|
-
border-
|
41
|
+
border-color: var(--git-diff-viewer-border-color-tinted);
|
42
|
+
border-style: solid;
|
43
|
+
border-width: 1px 0;
|
44
|
+
|
45
|
+
&.is-first-hunk {
|
46
|
+
border-top-width: 0px;
|
47
|
+
}
|
38
48
|
|
39
49
|
td.diff-gutter {
|
40
50
|
background-color: var(--git-diff-viewer-hunk-header-background);
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC"}
|
@@ -26,19 +26,5 @@
|
|
26
26
|
margin-left: -1px;
|
27
27
|
margin-right: -1px;
|
28
28
|
}
|
29
|
-
|
30
|
-
.line-decoration {
|
31
|
-
display: flex;
|
32
|
-
position: sticky;
|
33
|
-
left: 0;
|
34
|
-
width: var(--table-width);
|
35
|
-
.container {
|
36
|
-
width: 100%;
|
37
|
-
border: 1px solid var(--git-diff-viewer-border-color-tinted);
|
38
|
-
border-width: 1px 0;
|
39
|
-
border-radius: 1px;
|
40
|
-
padding: 0;
|
41
|
-
}
|
42
|
-
}
|
43
29
|
}
|
44
30
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"updateTableWidth.js","sourceRoot":"","sources":["../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/utils/updateTableWidth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAuB,EAAE,EAAE;IAC1D,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,gBAAgB,KAAK,KAAK,CAAC,WAAW,IAAI,CAAC;AACtE,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -34,8 +34,6 @@
|
|
34
34
|
display: flex;
|
35
35
|
align-items: center;
|
36
36
|
border-radius: 1px;
|
37
|
-
transition: transform 0.15s ease-out;
|
38
|
-
transform: rotate(90deg);
|
39
37
|
|
40
38
|
&:hover {
|
41
39
|
background-color: var(--git-diff-file-header-button-hover-background);
|
@@ -44,8 +42,14 @@
|
|
44
42
|
background-color: var(--git-diff-file-header-button-focus-background);
|
45
43
|
}
|
46
44
|
|
45
|
+
> svg {
|
46
|
+
transform: rotate(90deg);
|
47
|
+
transition: transform 0.15s ease-out;
|
48
|
+
}
|
47
49
|
&.collapsed {
|
48
|
-
|
50
|
+
> svg {
|
51
|
+
transform: rotate(0deg);
|
52
|
+
}
|
49
53
|
}
|
50
54
|
}
|
51
55
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/* GitDiffViewer.css */
|
2
2
|
.ds.git-diff-viewer {
|
3
3
|
--git-diff-viewer-code-default-background: #f7f7f7;
|
4
|
-
--git-diff-viewer-code-default-color: #
|
4
|
+
--git-diff-viewer-code-default-color: #000000;
|
5
5
|
--git-diff-viewer-code-insertion-background: #dff1e2;
|
6
6
|
--git-diff-viewer-code-insertion-color: #8cd297;
|
7
7
|
--git-diff-viewer-code-deletion-background: #f8e8ea;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import hljs from "highlight.js";
|
2
|
+
function highlight(code) {
|
3
|
+
return hljs.highlightAuto(code).value;
|
4
|
+
}
|
5
|
+
function highlightDiffHunkLines(hunkLines) {
|
6
|
+
const hunkContentAddedVersion = hunkLines
|
7
|
+
.filter((line) => line.type === "add" || line.type === "context")
|
8
|
+
.map((line) => line.content)
|
9
|
+
.join("\n");
|
10
|
+
const hunkContentDeletedVersion = hunkLines
|
11
|
+
.filter((line) => line.type === "remove" || line.type === "context")
|
12
|
+
.map((line) => line.content)
|
13
|
+
.join("\n");
|
14
|
+
const highlightedHunkAddedVersion = highlight(hunkContentAddedVersion).split("\n");
|
15
|
+
const highlightedHunkDeletedVersion = highlight(hunkContentDeletedVersion).split("\n");
|
16
|
+
const highlightedLines = [];
|
17
|
+
let addedOffset = 0;
|
18
|
+
let removedOffset = 0;
|
19
|
+
for (let i = 0; i < hunkLines.length; i++) {
|
20
|
+
const line = hunkLines[i];
|
21
|
+
switch (line.type) {
|
22
|
+
case "context":
|
23
|
+
highlightedLines.push(highlightedHunkDeletedVersion[i - addedOffset]);
|
24
|
+
break;
|
25
|
+
case "remove":
|
26
|
+
highlightedLines.push(highlightedHunkDeletedVersion[i - addedOffset]);
|
27
|
+
removedOffset++;
|
28
|
+
break;
|
29
|
+
case "add":
|
30
|
+
highlightedLines.push(highlightedHunkAddedVersion[i - removedOffset]);
|
31
|
+
addedOffset++;
|
32
|
+
break;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return highlightedLines;
|
36
|
+
}
|
37
|
+
export default highlightDiffHunkLines;
|
38
|
+
//# sourceMappingURL=highlightDiffHunkLines.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"highlightDiffHunkLines.js","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/utils/highlightDiffHunkLines.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,cAAc,CAAC;AAGhC,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;AACxC,CAAC;AAED,SAAS,sBAAsB,CAAC,SAAwB;IACtD,MAAM,uBAAuB,GAAG,SAAS;SACtC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;SAChE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;SAC3B,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,MAAM,yBAAyB,GAAG,SAAS;SACxC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;SACnE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;SAC3B,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,2BAA2B,GAAG,SAAS,CAAC,uBAAuB,CAAC,CAAC,KAAK,CAC1E,IAAI,CACL,CAAC;IACF,MAAM,6BAA6B,GAAG,SAAS,CAC7C,yBAAyB,CAC1B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,gBAAgB,GAAa,EAAE,CAAC;IACtC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1B,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;YAClB,KAAK,SAAS;gBACZ,gBAAgB,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;gBACtE,MAAM;YACR,KAAK,QAAQ;gBACX,gBAAgB,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;gBACtE,aAAa,EAAE,CAAC;gBAChB,MAAM;YACR,KAAK,KAAK;gBACR,gBAAgB,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;gBACtE,WAAW,EAAE,CAAC;gBACd,MAAM;QACV,CAAC;IACH,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,eAAe,sBAAsB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
|
@@ -3,12 +3,14 @@ function parseGitDiff(diffText) {
|
|
3
3
|
const files = [];
|
4
4
|
let currentFile = null;
|
5
5
|
let currentHunk = null;
|
6
|
+
let currentDiffStart = 0;
|
6
7
|
// Regular expressions to match file and hunk headers
|
7
8
|
const fileRegex = /^diff --git a\/(.+) b\/(.+)$/;
|
8
9
|
const hunkRegex = /^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@/;
|
9
10
|
const oldFileRegex = /^--- (.+)$/;
|
10
11
|
const newFileRegex = /^\+\+\+ (.+)$/;
|
11
12
|
for (const line of lines) {
|
13
|
+
currentDiffStart++;
|
12
14
|
const fileMatch = line.match(fileRegex);
|
13
15
|
if (fileMatch) {
|
14
16
|
// New file diff start
|
@@ -49,6 +51,7 @@ function parseGitDiff(diffText) {
|
|
49
51
|
oldLines: hunkMatch[2] ? Number.parseInt(hunkMatch[2], 10) : 1,
|
50
52
|
newStart: Number.parseInt(hunkMatch[3], 10),
|
51
53
|
newLines: hunkMatch[4] ? Number.parseInt(hunkMatch[4], 10) : 1,
|
54
|
+
diffStart: currentDiffStart + 1, // +1 because the first line is the hunk header
|
52
55
|
lines: [],
|
53
56
|
};
|
54
57
|
currentFile.hunks.push(currentHunk);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"parseGitDiff.js","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/utils/parseGitDiff.ts"],"names":[],"mappings":"AAEA,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,IAAI,WAAW,GAAoB,IAAI,CAAC;IACxC,IAAI,WAAW,GAAgB,IAAI,CAAC;
|
1
|
+
{"version":3,"file":"parseGitDiff.js","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/utils/parseGitDiff.ts"],"names":[],"mappings":"AAEA,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,KAA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AC,UAAU,CAAC,GAAG,CAAC;oBACpB,CAAC,CAAC,QAAQ;oBACV,CAAC,CAAC,SAAS,CAAC;YAChB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC;YAClE,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,IAAI,WAAW;QAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,eAAe,YAAY,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/ui/GitDiffViewer/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,QAAA,MAAM,QAAQ,GAAI,uDAMf,eAAe,KAAG,KAAK,CAAC,
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/ui/GitDiffViewer/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,QAAA,MAAM,QAAQ,GAAI,uDAMf,eAAe,KAAG,KAAK,CAAC,YAmC1B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -1,16 +1,7 @@
|
|
1
1
|
import type React from "react";
|
2
|
+
import "./HighlighTheme.css";
|
2
3
|
import "./styles.css";
|
3
4
|
import type { CodeDiffViewerProps } from "./types.js";
|
4
|
-
|
5
|
-
|
6
|
-
* Displays a diff in a table format with line numbers and syntax highlighting.
|
7
|
-
* With option to add comments to specific lines and interactive gutter for adding comments.
|
8
|
-
*
|
9
|
-
* @returns {React.ReactElement} - Rendered CodeDiffViewer
|
10
|
-
*/
|
11
|
-
declare const CodeDiffViewer: {
|
12
|
-
({ id, AddComment, className, style, }: CodeDiffViewerProps): React.ReactElement | null;
|
13
|
-
displayName: string;
|
14
|
-
};
|
15
|
-
export default CodeDiffViewer;
|
5
|
+
declare const _default: React.ForwardRefExoticComponent<CodeDiffViewerProps & React.RefAttributes<HTMLTableElement>>;
|
6
|
+
export default _default;
|
16
7
|
//# sourceMappingURL=CodeDiffViewer.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CodeDiffViewer.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"CodeDiffViewer.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;;AAiItD,wBAA0C"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type React from "react";
|
2
|
+
import type { AnnotatedDiffLineProps } from "./types.js";
|
3
|
+
import "./styles.css";
|
4
|
+
/**
|
5
|
+
* A component that displays a diff line content, line decorations and AddComment component.
|
6
|
+
* @returns {React.ReactElement} - Rendered AnnotatedDiffLine
|
7
|
+
*/
|
8
|
+
declare const AnnotatedDiffLine: ({ lineNum1, lineNum2, diffLineNumber, AddComment, onLineClick, ...rest }: AnnotatedDiffLineProps) => React.ReactElement;
|
9
|
+
export default AnnotatedDiffLine;
|
10
|
+
//# sourceMappingURL=AnnotatedDiffLine.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AnnotatedDiffLine.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/AnnotatedDiffLine.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,cAAc,CAAC;AAOtB;;;GAGG;AACH,QAAA,MAAM,iBAAiB,GAAI,0EAOxB,sBAAsB,KAAG,KAAK,CAAC,YAmDjC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/index.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACtE,cAAc,YAAY,CAAC"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { CodeDiffViewerAddComment, CodeDiffViewerLineSelectOptions } from "../../types.js";
|
2
|
+
import type { DiffContentLineProps } from "../DiffLine/types.js";
|
3
|
+
export type AnnotatedDiffLineProps = Omit<DiffContentLineProps, "onLineClick" | "lineNum1" | "lineNum2"> & {
|
4
|
+
lineNum1: number | null;
|
5
|
+
lineNum2: number | null;
|
6
|
+
diffLineNumber: number;
|
7
|
+
AddComment?: CodeDiffViewerAddComment;
|
8
|
+
onLineClick?: (options: CodeDiffViewerLineSelectOptions) => void;
|
9
|
+
};
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/types.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/AnnotatedDiffLine/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,wBAAwB,EACxB,+BAA+B,EAChC,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,oBAAoB,EACpB,aAAa,GAAG,UAAU,GAAG,UAAU,CACxC,GAAG;IACF,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,wBAAwB,CAAC;IACtC,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,+BAA+B,KAAK,IAAI,CAAC;CAClE,CAAC"}
|
@@ -6,6 +6,6 @@ import type { DiffLineProps } from "./types.js";
|
|
6
6
|
*
|
7
7
|
* @returns {React.ReactElement} - Rendered DiffLine
|
8
8
|
*/
|
9
|
-
declare const DiffLine: ({ id, className, style, ...props }: DiffLineProps) => React.ReactElement;
|
9
|
+
declare const DiffLine: ({ id, className, style, onLineClick, ...props }: DiffLineProps) => React.ReactElement;
|
10
10
|
export default DiffLine;
|
11
11
|
//# sourceMappingURL=DiffLine.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DiffLine.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
1
|
+
{"version":3,"file":"DiffLine.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKhD;;;;GAIG;AACH,QAAA,MAAM,QAAQ,GAAI,iDAMf,aAAa,KAAG,KAAK,CAAC,YAuDxB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -8,13 +8,20 @@ export type DiffContentLine = {
|
|
8
8
|
export type DiffHunkLine = {
|
9
9
|
type: "hunk";
|
10
10
|
hunkHeader: string;
|
11
|
+
hunkIndex: number;
|
11
12
|
};
|
12
|
-
|
13
|
+
type DiffLineCommonProps = {
|
13
14
|
/** A unique identifier for the DiffLine */
|
14
15
|
id?: string;
|
15
16
|
/** Additional CSS classes */
|
16
17
|
className?: string;
|
17
18
|
/** Inline styles */
|
18
19
|
style?: React.CSSProperties;
|
19
|
-
|
20
|
+
/** Callback function for when a line is clicked. */
|
21
|
+
onLineClick?: (() => void) | undefined;
|
22
|
+
};
|
23
|
+
export type DiffContentLineProps = DiffLineCommonProps & DiffContentLine;
|
24
|
+
export type DiffHunkLineProps = DiffLineCommonProps & DiffHunkLine;
|
25
|
+
export type DiffLineProps = DiffContentLineProps | DiffHunkLineProps;
|
26
|
+
export {};
|
20
27
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,2CAA2C;IAC3C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,oDAAoD;IACpD,WAAW,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG,eAAe,CAAC;AACzE,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,GAAG,YAAY,CAAC;AACnE,MAAM,MAAM,aAAa,GAAG,oBAAoB,GAAG,iBAAiB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,kBAAkB,CAAC"}
|
@@ -1,18 +1,34 @@
|
|
1
1
|
import type React from "react";
|
2
|
-
export type
|
2
|
+
export type CodeDiffViewerLineSelectOptions = {
|
3
3
|
lineNumber: number;
|
4
|
+
diffLineNumber: number;
|
5
|
+
};
|
6
|
+
export type CodeDiffViewerAddComment = (props: {
|
4
7
|
onClose: () => void;
|
5
|
-
}) => React.ReactNode;
|
8
|
+
} & CodeDiffViewerLineSelectOptions) => React.ReactNode;
|
6
9
|
export type CodeDiffViewerProps = {
|
7
10
|
/** A unique identifier for the CodeDiffViewer */
|
8
11
|
id?: string;
|
9
12
|
/** Additional CSS classes */
|
10
13
|
className?: string;
|
11
14
|
/** Add comment element.
|
12
|
-
* If provided, the
|
15
|
+
* If provided, the code viewer will be in interactive mode.
|
13
16
|
*/
|
14
17
|
AddComment?: CodeDiffViewerAddComment;
|
18
|
+
/** Callback function for when a line is clicked.
|
19
|
+
* If provided, the code viewer will be in interactive mode.
|
20
|
+
*/
|
21
|
+
onLineClick?: (options: CodeDiffViewerLineSelectOptions) => void;
|
15
22
|
/** Inline styles */
|
16
23
|
style?: React.CSSProperties;
|
24
|
+
/**
|
25
|
+
* Disable width calculation for the table (default: false).
|
26
|
+
* This is useful when there is multiple instances of this component on the same page.
|
27
|
+
* To avoid doing the same width calculation for each instance separately.
|
28
|
+
*
|
29
|
+
* Instead, ref the table element and set the width on the parent element.
|
30
|
+
* To update the table width, call the `utils/updateTableWidth` function.
|
31
|
+
*/
|
32
|
+
disableWidthCalculation?: boolean;
|
17
33
|
};
|
18
34
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,+BAA+B,GAAG;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,CACrC,KAAK,EAAE;IACL,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,GAAG,+BAA+B,KAChC,KAAK,CAAC,SAAS,CAAC;AAErB,MAAM,MAAM,mBAAmB,GAAG;IAChC,iDAAiD;IACjD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,wBAAwB,CAAC;IACtC;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,+BAA+B,KAAK,IAAI,CAAC;IACjE,oBAAoB;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAE5B;;;;;;;OAOG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"updateTableWidth.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/utils/updateTableWidth.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,GAAI,OAAO,gBAAgB,SAEvD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -37,8 +37,6 @@ export type LineDecorationOptions = {
|
|
37
37
|
};
|
38
38
|
type UserContextOptions = LineDecorationOptions & DiffOptions & WrapLinesOption & AllOrNone<CollapseOption>;
|
39
39
|
type ManagedContextOptions = {
|
40
|
-
addCommentEnabled: boolean;
|
41
|
-
setAddCommentEnabled: (enabled: boolean) => void;
|
42
40
|
addCommentOpenLocations: Set<number>;
|
43
41
|
toggleAddCommentLocation: (lineNumber: number) => void;
|
44
42
|
};
|
@@ -58,6 +56,7 @@ export type Hunk = {
|
|
58
56
|
oldLines: number;
|
59
57
|
newStart: number;
|
60
58
|
newLines: number;
|
59
|
+
diffStart: number;
|
61
60
|
lines: {
|
62
61
|
type: "add" | "remove" | "context";
|
63
62
|
content: string;
|
@@ -71,7 +70,7 @@ export type DiffFile = {
|
|
71
70
|
};
|
72
71
|
export type GitDiffViewerComponent = ((props: ProviderOptions) => React.ReactElement) & {
|
73
72
|
FileHeader: (props: FileHeaderProps) => React.ReactElement | null;
|
74
|
-
CodeDiffViewer:
|
73
|
+
CodeDiffViewer: React.ForwardRefExoticComponent<CodeDiffViewerProps & React.RefAttributes<HTMLTableElement>>;
|
75
74
|
};
|
76
75
|
export {};
|
77
76
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/ui/GitDiffViewer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/ui/GitDiffViewer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,gBAAgB,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;;;;OAKG;IACH,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM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IACd,eAAe,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CACpC,KAAK,EAAE,eAAe,KACnB,KAAK,CAAC,YAAY,CAAC,GAAG;IACzB,UAAU,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;IAClE,cAAc,EAAE,KAAK,CAAC,yBAAyB,CAC7C,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAC5D,CAAC;CACH,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"highlightDiffHunkLines.d.ts","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/utils/highlightDiffHunkLines.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAMxC,iBAAS,sBAAsB,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,MAAM,EAAE,CAsClE;AAED,eAAe,sBAAsB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"parseGitDiff.d.ts","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/utils/parseGitDiff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAQ,MAAM,aAAa,CAAC;AAElD,iBAAS,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,
|
1
|
+
{"version":3,"file":"parseGitDiff.d.ts","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/utils/parseGitDiff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAQ,MAAM,aAAa,CAAC;AAElD,iBAAS,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,CA0ElD;AAED,eAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@canonical/react-ds-app-launchpad",
|
3
|
-
"version": "0.9.0-experimental.
|
3
|
+
"version": "0.9.0-experimental.16",
|
4
4
|
"type": "module",
|
5
5
|
"module": "dist/esm/index.js",
|
6
6
|
"types": "dist/types/index.d.ts",
|
@@ -73,5 +73,5 @@
|
|
73
73
|
"vite-tsconfig-paths": "^5.1.4",
|
74
74
|
"vitest": "^3.0.9"
|
75
75
|
},
|
76
|
-
"gitHead": "
|
76
|
+
"gitHead": "801642fb24944aef6940b0fa6c91b3e99ab42235"
|
77
77
|
}
|