@uipath/apollo-react 6.75.0 → 6.76.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/dist/canvas/components/AgentCanvas/nodes/AgentNode.cjs +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.js +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/ResourceNode.cjs +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/ResourceNode.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/ResourceNode.js +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.cjs +2 -1
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +2 -1
- package/dist/canvas/components/BaseNode/BaseNode.types.d.ts +2 -0
- package/dist/canvas/components/BaseNode/BaseNode.types.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNodeConfigContext.d.ts +1 -1
- package/dist/canvas/components/BaseNode/BaseNodeConfigContext.d.ts.map +1 -1
- package/dist/canvas/components/CanvasDiffView/ApolloCanvasDiffPane.cjs +188 -0
- package/dist/canvas/components/CanvasDiffView/ApolloCanvasDiffPane.d.ts +18 -0
- package/dist/canvas/components/CanvasDiffView/ApolloCanvasDiffPane.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/ApolloCanvasDiffPane.js +154 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.cjs +470 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.d.ts +3 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.js +436 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.types.cjs +18 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.types.d.ts +76 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.types.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.types.js +0 -0
- package/dist/canvas/components/CanvasDiffView/CodeDiffView.cjs +220 -0
- package/dist/canvas/components/CanvasDiffView/CodeDiffView.d.ts +7 -0
- package/dist/canvas/components/CanvasDiffView/CodeDiffView.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/CodeDiffView.js +186 -0
- package/dist/canvas/components/CanvasDiffView/applyDiffHighlight.cjs +57 -0
- package/dist/canvas/components/CanvasDiffView/applyDiffHighlight.d.ts +7 -0
- package/dist/canvas/components/CanvasDiffView/applyDiffHighlight.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/applyDiffHighlight.js +23 -0
- package/dist/canvas/components/CanvasDiffView/diffById.cjs +110 -0
- package/dist/canvas/components/CanvasDiffView/diffById.d.ts +15 -0
- package/dist/canvas/components/CanvasDiffView/diffById.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/diffById.js +76 -0
- package/dist/canvas/components/CanvasDiffView/index.cjs +93 -0
- package/dist/canvas/components/CanvasDiffView/index.d.ts +7 -0
- package/dist/canvas/components/CanvasDiffView/index.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/index.js +6 -0
- package/dist/canvas/components/CanvasDiffView/lineDiff.cjs +116 -0
- package/dist/canvas/components/CanvasDiffView/lineDiff.d.ts +7 -0
- package/dist/canvas/components/CanvasDiffView/lineDiff.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/lineDiff.js +79 -0
- package/dist/canvas/components/Edges/CanvasEdge.cjs +5 -1
- package/dist/canvas/components/Edges/CanvasEdge.d.ts.map +1 -1
- package/dist/canvas/components/Edges/CanvasEdge.js +5 -1
- package/dist/canvas/components/Edges/shared/constants.cjs +1 -0
- package/dist/canvas/components/Edges/shared/constants.d.ts +1 -0
- package/dist/canvas/components/Edges/shared/constants.d.ts.map +1 -1
- package/dist/canvas/components/Edges/shared/constants.js +1 -0
- package/dist/canvas/components/Edges/shared/resolveEdgeColor.cjs +4 -1
- package/dist/canvas/components/Edges/shared/resolveEdgeColor.d.ts +2 -0
- package/dist/canvas/components/Edges/shared/resolveEdgeColor.d.ts.map +1 -1
- package/dist/canvas/components/Edges/shared/resolveEdgeColor.js +4 -1
- package/dist/canvas/components/Edges/shared/types.d.ts +2 -0
- package/dist/canvas/components/Edges/shared/types.d.ts.map +1 -1
- package/dist/canvas/components/index.cjs +69 -62
- package/dist/canvas/components/index.d.ts +1 -0
- package/dist/canvas/components/index.d.ts.map +1 -1
- package/dist/canvas/components/index.js +1 -0
- package/dist/canvas/locales/en.cjs +1 -1
- package/dist/canvas/locales/en.d.ts.map +1 -1
- package/dist/canvas/locales/en.js +1 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
CodeDiffView: ()=>CodeDiffView
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
|
|
31
|
+
const external_react_namespaceObject = require("react");
|
|
32
|
+
const index_cjs_namespaceObject = require("../../../i18n/index.cjs");
|
|
33
|
+
const external_lineDiff_cjs_namespaceObject = require("./lineDiff.cjs");
|
|
34
|
+
const toLines = (text)=>'' === text ? [] : text.split('\n');
|
|
35
|
+
function unmarkedRows(a, b) {
|
|
36
|
+
return Array.from({
|
|
37
|
+
length: Math.max(a.length, b.length)
|
|
38
|
+
}, (_, k)=>({
|
|
39
|
+
left: k < a.length ? {
|
|
40
|
+
number: k + 1,
|
|
41
|
+
text: a[k] ?? ''
|
|
42
|
+
} : void 0,
|
|
43
|
+
right: k < b.length ? {
|
|
44
|
+
number: k + 1,
|
|
45
|
+
text: b[k] ?? ''
|
|
46
|
+
} : void 0,
|
|
47
|
+
changed: false
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
function diffRows(a, b) {
|
|
51
|
+
const ops = (0, external_lineDiff_cjs_namespaceObject.diffLines)(a, b);
|
|
52
|
+
if (!ops) return;
|
|
53
|
+
const rows = [];
|
|
54
|
+
let removed = [];
|
|
55
|
+
let added = [];
|
|
56
|
+
const flushChanges = ()=>{
|
|
57
|
+
for(let k = 0; k < Math.max(removed.length, added.length); k++)rows.push({
|
|
58
|
+
left: removed[k],
|
|
59
|
+
right: added[k],
|
|
60
|
+
changed: true
|
|
61
|
+
});
|
|
62
|
+
removed = [];
|
|
63
|
+
added = [];
|
|
64
|
+
};
|
|
65
|
+
let beforeNumber = 0;
|
|
66
|
+
let afterNumber = 0;
|
|
67
|
+
for (const op of ops)if ('removed' === op.type) {
|
|
68
|
+
beforeNumber++;
|
|
69
|
+
removed.push({
|
|
70
|
+
number: beforeNumber,
|
|
71
|
+
text: op.text
|
|
72
|
+
});
|
|
73
|
+
} else if ('added' === op.type) {
|
|
74
|
+
afterNumber++;
|
|
75
|
+
added.push({
|
|
76
|
+
number: afterNumber,
|
|
77
|
+
text: op.text
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
flushChanges();
|
|
81
|
+
beforeNumber++;
|
|
82
|
+
afterNumber++;
|
|
83
|
+
rows.push({
|
|
84
|
+
left: {
|
|
85
|
+
number: beforeNumber,
|
|
86
|
+
text: op.text
|
|
87
|
+
},
|
|
88
|
+
right: {
|
|
89
|
+
number: afterNumber,
|
|
90
|
+
text: op.text
|
|
91
|
+
},
|
|
92
|
+
changed: false
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
flushChanges();
|
|
96
|
+
return rows;
|
|
97
|
+
}
|
|
98
|
+
function Side({ line, kind, changed, changeLabel }) {
|
|
99
|
+
const marked = changed && !!line;
|
|
100
|
+
const tint = marked && ('removed' === kind ? 'bg-error-background' : 'bg-success-background');
|
|
101
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
102
|
+
children: [
|
|
103
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("td", {
|
|
104
|
+
className: (0, apollo_wind_namespaceObject.cn)('select-none px-2 text-right align-top text-foreground-subtle', 'added' === kind && 'border-l border-border-subtle', tint),
|
|
105
|
+
children: line?.number
|
|
106
|
+
}),
|
|
107
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("td", {
|
|
108
|
+
className: (0, apollo_wind_namespaceObject.cn)('whitespace-pre-wrap break-all px-2 align-top', tint),
|
|
109
|
+
children: [
|
|
110
|
+
marked && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
111
|
+
className: "sr-only",
|
|
112
|
+
children: [
|
|
113
|
+
changeLabel,
|
|
114
|
+
" "
|
|
115
|
+
]
|
|
116
|
+
}),
|
|
117
|
+
line?.text
|
|
118
|
+
]
|
|
119
|
+
})
|
|
120
|
+
]
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function CodeDiffView({ before, after, className }) {
|
|
124
|
+
const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
|
|
125
|
+
const { rows, tooLarge } = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
126
|
+
const a = toLines(before);
|
|
127
|
+
const b = toLines(after);
|
|
128
|
+
const diffed = diffRows(a, b);
|
|
129
|
+
return {
|
|
130
|
+
rows: diffed ?? unmarkedRows(a, b),
|
|
131
|
+
tooLarge: !diffed
|
|
132
|
+
};
|
|
133
|
+
}, [
|
|
134
|
+
before,
|
|
135
|
+
after
|
|
136
|
+
]);
|
|
137
|
+
const removedLabel = _({
|
|
138
|
+
id: 'canvas.diff_view.code_line_removed',
|
|
139
|
+
message: 'Removed'
|
|
140
|
+
});
|
|
141
|
+
const addedLabel = _({
|
|
142
|
+
id: 'canvas.diff_view.code_line_added',
|
|
143
|
+
message: 'Added'
|
|
144
|
+
});
|
|
145
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
146
|
+
className: (0, apollo_wind_namespaceObject.cn)('relative h-full overflow-auto bg-surface font-mono text-xs leading-5', className),
|
|
147
|
+
children: [
|
|
148
|
+
tooLarge && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("output", {
|
|
149
|
+
className: "block border-b border-border-subtle px-2 py-1 text-foreground-subtle",
|
|
150
|
+
children: _({
|
|
151
|
+
id: 'canvas.diff_view.code_too_large',
|
|
152
|
+
message: 'Too many changes to highlight. Showing both versions unmarked.'
|
|
153
|
+
})
|
|
154
|
+
}),
|
|
155
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("table", {
|
|
156
|
+
className: "w-full table-fixed border-collapse",
|
|
157
|
+
children: [
|
|
158
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("colgroup", {
|
|
159
|
+
children: [
|
|
160
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("col", {
|
|
161
|
+
className: "w-12"
|
|
162
|
+
}),
|
|
163
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("col", {}),
|
|
164
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("col", {
|
|
165
|
+
className: "w-12"
|
|
166
|
+
}),
|
|
167
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("col", {})
|
|
168
|
+
]
|
|
169
|
+
}),
|
|
170
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("thead", {
|
|
171
|
+
className: "sr-only",
|
|
172
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("tr", {
|
|
173
|
+
children: [
|
|
174
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("th", {
|
|
175
|
+
colSpan: 2,
|
|
176
|
+
children: _({
|
|
177
|
+
id: 'canvas.diff_view.before_label',
|
|
178
|
+
message: 'Before'
|
|
179
|
+
})
|
|
180
|
+
}),
|
|
181
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("th", {
|
|
182
|
+
colSpan: 2,
|
|
183
|
+
children: _({
|
|
184
|
+
id: 'canvas.diff_view.after_label',
|
|
185
|
+
message: 'After'
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
})
|
|
190
|
+
}),
|
|
191
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("tbody", {
|
|
192
|
+
children: rows.map((row)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("tr", {
|
|
193
|
+
children: [
|
|
194
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Side, {
|
|
195
|
+
line: row.left,
|
|
196
|
+
kind: "removed",
|
|
197
|
+
changed: row.changed,
|
|
198
|
+
changeLabel: removedLabel
|
|
199
|
+
}),
|
|
200
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Side, {
|
|
201
|
+
line: row.right,
|
|
202
|
+
kind: "added",
|
|
203
|
+
changed: row.changed,
|
|
204
|
+
changeLabel: addedLabel
|
|
205
|
+
})
|
|
206
|
+
]
|
|
207
|
+
}, `${row.left?.number ?? '-'}:${row.right?.number ?? '-'}`))
|
|
208
|
+
})
|
|
209
|
+
]
|
|
210
|
+
})
|
|
211
|
+
]
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
exports.CodeDiffView = __webpack_exports__.CodeDiffView;
|
|
215
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
216
|
+
"CodeDiffView"
|
|
217
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
218
|
+
Object.defineProperty(exports, '__esModule', {
|
|
219
|
+
value: true
|
|
220
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface CodeDiffViewProps {
|
|
2
|
+
before: string;
|
|
3
|
+
after: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function CodeDiffView({ before, after, className }: CodeDiffViewProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=CodeDiffView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeDiffView.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/CanvasDiffView/CodeDiffView.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,iBAAiB;IAEhC,MAAM,EAAE,MAAM,CAAC;IAEf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAqGD,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,iBAAiB,2CAuD3E"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@uipath/apollo-wind";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { useSafeLingui } from "../../../i18n/index.js";
|
|
5
|
+
import { diffLines } from "./lineDiff.js";
|
|
6
|
+
const toLines = (text)=>'' === text ? [] : text.split('\n');
|
|
7
|
+
function unmarkedRows(a, b) {
|
|
8
|
+
return Array.from({
|
|
9
|
+
length: Math.max(a.length, b.length)
|
|
10
|
+
}, (_, k)=>({
|
|
11
|
+
left: k < a.length ? {
|
|
12
|
+
number: k + 1,
|
|
13
|
+
text: a[k] ?? ''
|
|
14
|
+
} : void 0,
|
|
15
|
+
right: k < b.length ? {
|
|
16
|
+
number: k + 1,
|
|
17
|
+
text: b[k] ?? ''
|
|
18
|
+
} : void 0,
|
|
19
|
+
changed: false
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
function diffRows(a, b) {
|
|
23
|
+
const ops = diffLines(a, b);
|
|
24
|
+
if (!ops) return;
|
|
25
|
+
const rows = [];
|
|
26
|
+
let removed = [];
|
|
27
|
+
let added = [];
|
|
28
|
+
const flushChanges = ()=>{
|
|
29
|
+
for(let k = 0; k < Math.max(removed.length, added.length); k++)rows.push({
|
|
30
|
+
left: removed[k],
|
|
31
|
+
right: added[k],
|
|
32
|
+
changed: true
|
|
33
|
+
});
|
|
34
|
+
removed = [];
|
|
35
|
+
added = [];
|
|
36
|
+
};
|
|
37
|
+
let beforeNumber = 0;
|
|
38
|
+
let afterNumber = 0;
|
|
39
|
+
for (const op of ops)if ('removed' === op.type) {
|
|
40
|
+
beforeNumber++;
|
|
41
|
+
removed.push({
|
|
42
|
+
number: beforeNumber,
|
|
43
|
+
text: op.text
|
|
44
|
+
});
|
|
45
|
+
} else if ('added' === op.type) {
|
|
46
|
+
afterNumber++;
|
|
47
|
+
added.push({
|
|
48
|
+
number: afterNumber,
|
|
49
|
+
text: op.text
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
flushChanges();
|
|
53
|
+
beforeNumber++;
|
|
54
|
+
afterNumber++;
|
|
55
|
+
rows.push({
|
|
56
|
+
left: {
|
|
57
|
+
number: beforeNumber,
|
|
58
|
+
text: op.text
|
|
59
|
+
},
|
|
60
|
+
right: {
|
|
61
|
+
number: afterNumber,
|
|
62
|
+
text: op.text
|
|
63
|
+
},
|
|
64
|
+
changed: false
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
flushChanges();
|
|
68
|
+
return rows;
|
|
69
|
+
}
|
|
70
|
+
function Side({ line, kind, changed, changeLabel }) {
|
|
71
|
+
const marked = changed && !!line;
|
|
72
|
+
const tint = marked && ('removed' === kind ? 'bg-error-background' : 'bg-success-background');
|
|
73
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
74
|
+
children: [
|
|
75
|
+
/*#__PURE__*/ jsx("td", {
|
|
76
|
+
className: cn('select-none px-2 text-right align-top text-foreground-subtle', 'added' === kind && 'border-l border-border-subtle', tint),
|
|
77
|
+
children: line?.number
|
|
78
|
+
}),
|
|
79
|
+
/*#__PURE__*/ jsxs("td", {
|
|
80
|
+
className: cn('whitespace-pre-wrap break-all px-2 align-top', tint),
|
|
81
|
+
children: [
|
|
82
|
+
marked && /*#__PURE__*/ jsxs("span", {
|
|
83
|
+
className: "sr-only",
|
|
84
|
+
children: [
|
|
85
|
+
changeLabel,
|
|
86
|
+
" "
|
|
87
|
+
]
|
|
88
|
+
}),
|
|
89
|
+
line?.text
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function CodeDiffView({ before, after, className }) {
|
|
96
|
+
const { _ } = useSafeLingui();
|
|
97
|
+
const { rows, tooLarge } = useMemo(()=>{
|
|
98
|
+
const a = toLines(before);
|
|
99
|
+
const b = toLines(after);
|
|
100
|
+
const diffed = diffRows(a, b);
|
|
101
|
+
return {
|
|
102
|
+
rows: diffed ?? unmarkedRows(a, b),
|
|
103
|
+
tooLarge: !diffed
|
|
104
|
+
};
|
|
105
|
+
}, [
|
|
106
|
+
before,
|
|
107
|
+
after
|
|
108
|
+
]);
|
|
109
|
+
const removedLabel = _({
|
|
110
|
+
id: 'canvas.diff_view.code_line_removed',
|
|
111
|
+
message: 'Removed'
|
|
112
|
+
});
|
|
113
|
+
const addedLabel = _({
|
|
114
|
+
id: 'canvas.diff_view.code_line_added',
|
|
115
|
+
message: 'Added'
|
|
116
|
+
});
|
|
117
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
118
|
+
className: cn('relative h-full overflow-auto bg-surface font-mono text-xs leading-5', className),
|
|
119
|
+
children: [
|
|
120
|
+
tooLarge && /*#__PURE__*/ jsx("output", {
|
|
121
|
+
className: "block border-b border-border-subtle px-2 py-1 text-foreground-subtle",
|
|
122
|
+
children: _({
|
|
123
|
+
id: 'canvas.diff_view.code_too_large',
|
|
124
|
+
message: 'Too many changes to highlight. Showing both versions unmarked.'
|
|
125
|
+
})
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ jsxs("table", {
|
|
128
|
+
className: "w-full table-fixed border-collapse",
|
|
129
|
+
children: [
|
|
130
|
+
/*#__PURE__*/ jsxs("colgroup", {
|
|
131
|
+
children: [
|
|
132
|
+
/*#__PURE__*/ jsx("col", {
|
|
133
|
+
className: "w-12"
|
|
134
|
+
}),
|
|
135
|
+
/*#__PURE__*/ jsx("col", {}),
|
|
136
|
+
/*#__PURE__*/ jsx("col", {
|
|
137
|
+
className: "w-12"
|
|
138
|
+
}),
|
|
139
|
+
/*#__PURE__*/ jsx("col", {})
|
|
140
|
+
]
|
|
141
|
+
}),
|
|
142
|
+
/*#__PURE__*/ jsx("thead", {
|
|
143
|
+
className: "sr-only",
|
|
144
|
+
children: /*#__PURE__*/ jsxs("tr", {
|
|
145
|
+
children: [
|
|
146
|
+
/*#__PURE__*/ jsx("th", {
|
|
147
|
+
colSpan: 2,
|
|
148
|
+
children: _({
|
|
149
|
+
id: 'canvas.diff_view.before_label',
|
|
150
|
+
message: 'Before'
|
|
151
|
+
})
|
|
152
|
+
}),
|
|
153
|
+
/*#__PURE__*/ jsx("th", {
|
|
154
|
+
colSpan: 2,
|
|
155
|
+
children: _({
|
|
156
|
+
id: 'canvas.diff_view.after_label',
|
|
157
|
+
message: 'After'
|
|
158
|
+
})
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
})
|
|
162
|
+
}),
|
|
163
|
+
/*#__PURE__*/ jsx("tbody", {
|
|
164
|
+
children: rows.map((row)=>/*#__PURE__*/ jsxs("tr", {
|
|
165
|
+
children: [
|
|
166
|
+
/*#__PURE__*/ jsx(Side, {
|
|
167
|
+
line: row.left,
|
|
168
|
+
kind: "removed",
|
|
169
|
+
changed: row.changed,
|
|
170
|
+
changeLabel: removedLabel
|
|
171
|
+
}),
|
|
172
|
+
/*#__PURE__*/ jsx(Side, {
|
|
173
|
+
line: row.right,
|
|
174
|
+
kind: "added",
|
|
175
|
+
changed: row.changed,
|
|
176
|
+
changeLabel: addedLabel
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
}, `${row.left?.number ?? '-'}:${row.right?.number ?? '-'}`))
|
|
180
|
+
})
|
|
181
|
+
]
|
|
182
|
+
})
|
|
183
|
+
]
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
export { CodeDiffView };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
applyDiffHighlight: ()=>applyDiffHighlight
|
|
28
|
+
});
|
|
29
|
+
const SUGGESTION_BY_KIND = {
|
|
30
|
+
added: 'add',
|
|
31
|
+
changed: 'update',
|
|
32
|
+
removed: 'delete'
|
|
33
|
+
};
|
|
34
|
+
function withSuggestion(element, kinds) {
|
|
35
|
+
const kind = kinds.get(element.id);
|
|
36
|
+
if (!kind) return element;
|
|
37
|
+
return {
|
|
38
|
+
...element,
|
|
39
|
+
data: {
|
|
40
|
+
...element.data,
|
|
41
|
+
suggestionType: SUGGESTION_BY_KIND[kind]
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function applyDiffHighlight(nodes, edges, highlight) {
|
|
46
|
+
return {
|
|
47
|
+
nodes: nodes.map((node)=>withSuggestion(node, highlight.nodeKind)),
|
|
48
|
+
edges: edges.map((edge)=>withSuggestion(edge, highlight.edgeKind))
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
exports.applyDiffHighlight = __webpack_exports__.applyDiffHighlight;
|
|
52
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
53
|
+
"applyDiffHighlight"
|
|
54
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
55
|
+
Object.defineProperty(exports, '__esModule', {
|
|
56
|
+
value: true
|
|
57
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Edge, Node } from '../../xyflow/react.ts';
|
|
2
|
+
import type { DiffHighlight } from './CanvasDiffView.types';
|
|
3
|
+
export declare function applyDiffHighlight<N extends Node, E extends Edge>(nodes: readonly N[], edges: readonly E[], highlight: DiffHighlight): {
|
|
4
|
+
nodes: N[];
|
|
5
|
+
edges: E[];
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=applyDiffHighlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyDiffHighlight.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/CanvasDiffView/applyDiffHighlight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAuBxE,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,IAAI,EAC/D,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,SAAS,EAAE,aAAa,GACvB;IAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAAC,KAAK,EAAE,CAAC,EAAE,CAAA;CAAE,CAK5B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const SUGGESTION_BY_KIND = {
|
|
2
|
+
added: 'add',
|
|
3
|
+
changed: 'update',
|
|
4
|
+
removed: 'delete'
|
|
5
|
+
};
|
|
6
|
+
function withSuggestion(element, kinds) {
|
|
7
|
+
const kind = kinds.get(element.id);
|
|
8
|
+
if (!kind) return element;
|
|
9
|
+
return {
|
|
10
|
+
...element,
|
|
11
|
+
data: {
|
|
12
|
+
...element.data,
|
|
13
|
+
suggestionType: SUGGESTION_BY_KIND[kind]
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function applyDiffHighlight(nodes, edges, highlight) {
|
|
18
|
+
return {
|
|
19
|
+
nodes: nodes.map((node)=>withSuggestion(node, highlight.nodeKind)),
|
|
20
|
+
edges: edges.map((edge)=>withSuggestion(edge, highlight.edgeKind))
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export { applyDiffHighlight };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
diffById: ()=>diffById
|
|
28
|
+
});
|
|
29
|
+
function stableStringify(value) {
|
|
30
|
+
if (null === value || 'object' != typeof value) return JSON.stringify(value) ?? 'null';
|
|
31
|
+
if ('function' == typeof value.toJSON) return stableStringify(value.toJSON());
|
|
32
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(',')}]`;
|
|
33
|
+
const record = value;
|
|
34
|
+
const keys = Object.keys(record).filter((key)=>void 0 !== record[key]).sort();
|
|
35
|
+
return `{${keys.map((key)=>`${JSON.stringify(key)}:${stableStringify(record[key])}`).join(',')}}`;
|
|
36
|
+
}
|
|
37
|
+
function omitPath(value, path) {
|
|
38
|
+
if (!value || 'object' != typeof value || Array.isArray(value) || 0 === path.length) return value;
|
|
39
|
+
const [head, ...rest] = path;
|
|
40
|
+
if (!(head in value)) return value;
|
|
41
|
+
const { [head]: child, ...others } = value;
|
|
42
|
+
return 0 === rest.length ? others : {
|
|
43
|
+
...others,
|
|
44
|
+
[head]: omitPath(child, rest)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function fingerprint(value, ignorePaths) {
|
|
48
|
+
return stableStringify(ignorePaths.reduce(omitPath, value));
|
|
49
|
+
}
|
|
50
|
+
const defaultId = (element)=>String(element.id);
|
|
51
|
+
function diffCollection(before, after, getId, ignoreKeys) {
|
|
52
|
+
const ignorePaths = (ignoreKeys ?? []).map((key)=>key.split('.'));
|
|
53
|
+
const beforeById = new Map(before.map((el)=>[
|
|
54
|
+
getId(el),
|
|
55
|
+
fingerprint(el, ignorePaths)
|
|
56
|
+
]));
|
|
57
|
+
const afterIds = new Set();
|
|
58
|
+
const kinds = new Map();
|
|
59
|
+
let added = 0;
|
|
60
|
+
let removed = 0;
|
|
61
|
+
let changed = 0;
|
|
62
|
+
for (const element of after){
|
|
63
|
+
const id = getId(element);
|
|
64
|
+
afterIds.add(id);
|
|
65
|
+
const previous = beforeById.get(id);
|
|
66
|
+
if (void 0 === previous) {
|
|
67
|
+
kinds.set(id, 'added');
|
|
68
|
+
added++;
|
|
69
|
+
} else if (previous !== fingerprint(element, ignorePaths)) {
|
|
70
|
+
kinds.set(id, 'changed');
|
|
71
|
+
changed++;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for (const id of beforeById.keys())if (!afterIds.has(id)) {
|
|
75
|
+
kinds.set(id, 'removed');
|
|
76
|
+
removed++;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
kinds,
|
|
80
|
+
added,
|
|
81
|
+
removed,
|
|
82
|
+
changed
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function diffById(before, after, options) {
|
|
86
|
+
const { getNodes, getEdges, nodeId = defaultId, edgeId = defaultId } = options;
|
|
87
|
+
const nodes = diffCollection(getNodes(before), getNodes(after), nodeId, options.ignoreNodeKeys);
|
|
88
|
+
const edges = diffCollection(getEdges(before), getEdges(after), edgeId, options.ignoreEdgeKeys);
|
|
89
|
+
return {
|
|
90
|
+
highlight: {
|
|
91
|
+
nodeKind: nodes.kinds,
|
|
92
|
+
edgeKind: edges.kinds
|
|
93
|
+
},
|
|
94
|
+
summary: {
|
|
95
|
+
addedNodes: nodes.added,
|
|
96
|
+
removedNodes: nodes.removed,
|
|
97
|
+
changedNodes: nodes.changed,
|
|
98
|
+
addedEdges: edges.added,
|
|
99
|
+
removedEdges: edges.removed,
|
|
100
|
+
changedEdges: edges.changed
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
exports.diffById = __webpack_exports__.diffById;
|
|
105
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
106
|
+
"diffById"
|
|
107
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
108
|
+
Object.defineProperty(exports, '__esModule', {
|
|
109
|
+
value: true
|
|
110
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DiffHighlight, DiffSummary } from './CanvasDiffView.types';
|
|
2
|
+
export interface DiffByIdOptions<Doc, Node, Edge> {
|
|
3
|
+
getNodes(doc: Doc): readonly Node[];
|
|
4
|
+
getEdges(doc: Doc): readonly Edge[];
|
|
5
|
+
nodeId?(node: Node): string;
|
|
6
|
+
edgeId?(edge: Edge): string;
|
|
7
|
+
ignoreNodeKeys?: string[];
|
|
8
|
+
ignoreEdgeKeys?: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface DiffByIdResult {
|
|
11
|
+
highlight: DiffHighlight;
|
|
12
|
+
summary: DiffSummary;
|
|
13
|
+
}
|
|
14
|
+
export declare function diffById<Doc, Node, Edge>(before: Doc, after: Doc, options: DiffByIdOptions<Doc, Node, Edge>): DiffByIdResult;
|
|
15
|
+
//# sourceMappingURL=diffById.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diffById.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/CanvasDiffView/diffById.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErF,MAAM,WAAW,eAAe,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI;IAC9C,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,IAAI,EAAE,CAAC;IACpC,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,IAAI,EAAE,CAAC;IAEpC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;IAE5B,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;IAK5B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,EAAE,WAAW,CAAC;CACtB;AA4ED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EACtC,MAAM,EAAE,GAAG,EACX,KAAK,EAAE,GAAG,EACV,OAAO,EAAE,eAAe,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,GACxC,cAAc,CAgBhB"}
|