@rsdoctor/components 0.4.3 → 0.4.4
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/components/Alerts/common.js +16 -5
- package/dist/pages/Resources/BundleDiff/DiffContainer/assets.d.ts +7 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/assets.js +505 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/cards.d.ts +3 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/cards.js +156 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/changes.d.ts +15 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/changes.js +69 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/constants.d.ts +11 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/constants.js +17 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/index.d.ts +3 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/index.js +180 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/modules.d.ts +8 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/modules.js +303 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/overview.d.ts +5 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/overview.js +178 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/packages.d.ts +19 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/packages.js +331 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/row.d.ts +9 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/row.js +377 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/types.d.ts +44 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/types.js +0 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/utils.d.ts +2 -0
- package/dist/pages/Resources/BundleDiff/DiffContainer/utils.js +24 -0
- package/dist/pages/Resources/BundleDiff/DiffServerAPIProvider/index.d.ts +3 -0
- package/dist/pages/Resources/BundleDiff/DiffServerAPIProvider/index.js +36 -0
- package/dist/pages/Resources/BundleDiff/constants.d.ts +11 -0
- package/dist/pages/Resources/BundleDiff/constants.js +19 -0
- package/dist/pages/Resources/BundleDiff/index.d.ts +3 -0
- package/dist/pages/Resources/BundleDiff/index.js +9 -0
- package/dist/pages/index.d.ts +1 -0
- package/dist/pages/index.js +2 -0
- package/package.json +5 -5
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { InfoCircleOutlined, SearchOutlined } from "@ant-design/icons";
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
Divider,
|
|
6
|
+
Input,
|
|
7
|
+
Space,
|
|
8
|
+
Table,
|
|
9
|
+
Tag,
|
|
10
|
+
Tooltip,
|
|
11
|
+
Typography
|
|
12
|
+
} from "antd";
|
|
13
|
+
import { upperFirst } from "lodash-es";
|
|
14
|
+
import { useMemo, useRef, useState } from "react";
|
|
15
|
+
import { Client } from "@rsdoctor/types";
|
|
16
|
+
import { Color } from "../../../../constants";
|
|
17
|
+
import {
|
|
18
|
+
beautifyModulePath,
|
|
19
|
+
formatPercent,
|
|
20
|
+
formatSize
|
|
21
|
+
} from "../../../../utils";
|
|
22
|
+
import { ViewChanges } from "./changes";
|
|
23
|
+
import { FileUpdateTypeTag, getUpdateType } from "./modules";
|
|
24
|
+
import { UpdateType } from "./constants";
|
|
25
|
+
import { formatDiffSize } from "./utils";
|
|
26
|
+
import { Graph } from "@rsdoctor/utils/common";
|
|
27
|
+
const ModuleHashPattern = /[a-fA-F0-9]{20,}/;
|
|
28
|
+
const getSizeColumnPropsForModuleRow = (key, sizeKey, sortByChanged) => {
|
|
29
|
+
const sortByChangedFn = (a, b) => (a.current?.size[sizeKey] || 0) - (a.baseline?.size[sizeKey] || 0) - (b.current?.size[sizeKey] || 0) + (b.baseline?.size[sizeKey] || 0);
|
|
30
|
+
const sorterFn = sortByChanged ? (a, b) => sortByChangedFn(a, b) : (a, b) => (a[key]?.size[sizeKey] || 0) - (b[key]?.size[sizeKey] || 0);
|
|
31
|
+
return {
|
|
32
|
+
width: 200,
|
|
33
|
+
sorter: (a, b) => sorterFn(a, b),
|
|
34
|
+
render: (_v, r) => {
|
|
35
|
+
if (!r[key])
|
|
36
|
+
return "-";
|
|
37
|
+
const size = r[key].size[sizeKey];
|
|
38
|
+
return /* @__PURE__ */ jsxs(Space, { children: [
|
|
39
|
+
/* @__PURE__ */ jsx(Typography.Text, { children: formatSize(size) }),
|
|
40
|
+
key === "current" ? formatDiffSize(
|
|
41
|
+
r.baseline?.size[sizeKey] || 0,
|
|
42
|
+
size,
|
|
43
|
+
(r.baseline?.size[sizeKey] || 0) > size ? Client.RsdoctorClientDiffState.Down : Client.RsdoctorClientDiffState.Up
|
|
44
|
+
) : null
|
|
45
|
+
] });
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const getTargetColumnPropsForModuleRow = (key, bMoudlesCount, cMoudlesCount) => {
|
|
50
|
+
const [sortByChanged, setSortByChanged] = useState(false);
|
|
51
|
+
const isB = key === "baseline";
|
|
52
|
+
return {
|
|
53
|
+
title: () => {
|
|
54
|
+
const count = isB ? bMoudlesCount : cMoudlesCount;
|
|
55
|
+
const title = upperFirst(key);
|
|
56
|
+
const diff = Graph.diffSize(bMoudlesCount, cMoudlesCount);
|
|
57
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
58
|
+
/* @__PURE__ */ jsx(Typography.Text, { children: title }),
|
|
59
|
+
/* @__PURE__ */ jsx(Divider, { type: "vertical" }),
|
|
60
|
+
/* @__PURE__ */ jsx(
|
|
61
|
+
Tooltip,
|
|
62
|
+
{
|
|
63
|
+
title: /* @__PURE__ */ jsxs(Space, { direction: "vertical", children: [
|
|
64
|
+
/* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
|
|
65
|
+
title,
|
|
66
|
+
" modules is ",
|
|
67
|
+
count
|
|
68
|
+
] }),
|
|
69
|
+
isB ? null : /* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
|
|
70
|
+
"Percent is ",
|
|
71
|
+
formatPercent(diff.percent)
|
|
72
|
+
] })
|
|
73
|
+
] }),
|
|
74
|
+
children: /* @__PURE__ */ jsxs(Space, { children: [
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
Typography.Text,
|
|
77
|
+
{
|
|
78
|
+
type: "secondary",
|
|
79
|
+
style: { fontSize: 10, fontWeight: 400 },
|
|
80
|
+
children: count
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
/* @__PURE__ */ jsx(InfoCircleOutlined, {})
|
|
84
|
+
] })
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
] });
|
|
88
|
+
},
|
|
89
|
+
children: [
|
|
90
|
+
{
|
|
91
|
+
title: "Source Size",
|
|
92
|
+
...getSizeColumnPropsForModuleRow(key, "sourceSize", sortByChanged)
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
title: "Parsed Size",
|
|
96
|
+
defaultSortOrder: isB ? void 0 : "descend",
|
|
97
|
+
...getSizeColumnPropsForModuleRow(key, "parsedSize", sortByChanged)
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
filterSearch: true,
|
|
101
|
+
filters: [
|
|
102
|
+
{
|
|
103
|
+
text: "Show Changed",
|
|
104
|
+
value: UpdateType.NotChanged
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
text: "Show All",
|
|
108
|
+
value: "All"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
onFilter(v, r) {
|
|
112
|
+
if (v === UpdateType.NotChanged) {
|
|
113
|
+
setSortByChanged(true);
|
|
114
|
+
} else {
|
|
115
|
+
setSortByChanged(false);
|
|
116
|
+
}
|
|
117
|
+
return v === UpdateType.NotChanged ? getUpdateType(r) !== v : true;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
const ModuleRowForAsset = ({ data, baseline, current }) => {
|
|
122
|
+
const { modules: bTotalModules } = baseline.moduleGraph;
|
|
123
|
+
const { modules: cTotalModules } = current.moduleGraph;
|
|
124
|
+
const { chunks: bToTalChunks } = baseline.chunkGraph;
|
|
125
|
+
const { chunks: cToTalChunks } = current.chunkGraph;
|
|
126
|
+
const bRoot = baseline.root;
|
|
127
|
+
const cRoot = current.root;
|
|
128
|
+
const [searchText, setSearchText] = useState("");
|
|
129
|
+
const searchInput = useRef(null);
|
|
130
|
+
const handleSearch = (selectedKeys, confirm) => {
|
|
131
|
+
confirm();
|
|
132
|
+
setSearchText(selectedKeys[0]);
|
|
133
|
+
};
|
|
134
|
+
const handleReset = (clearFilters) => {
|
|
135
|
+
clearFilters();
|
|
136
|
+
setSearchText("");
|
|
137
|
+
};
|
|
138
|
+
const isBaseline = "__is_baseline__";
|
|
139
|
+
const bModules = useMemo(
|
|
140
|
+
() => data.baseline ? Graph.getModulesByAsset(data.baseline, bToTalChunks, bTotalModules).map((e) => ({
|
|
141
|
+
...e,
|
|
142
|
+
[isBaseline]: true
|
|
143
|
+
})).filter((cModule) => !cModule.concatenationModules?.length) : [],
|
|
144
|
+
[data, baseline]
|
|
145
|
+
);
|
|
146
|
+
const cModules = useMemo(
|
|
147
|
+
() => data.current ? Graph.getModulesByAsset(data.current, cToTalChunks, cTotalModules).map((e) => ({
|
|
148
|
+
...e,
|
|
149
|
+
[isBaseline]: false
|
|
150
|
+
})).filter((cModule) => !cModule.concatenationModules?.length) : [],
|
|
151
|
+
[data, current]
|
|
152
|
+
);
|
|
153
|
+
const getPathInfo = (r) => beautifyModulePath(r.path, r.__is_baseline__ ? bRoot : cRoot);
|
|
154
|
+
const dataSource = useMemo(() => {
|
|
155
|
+
const mods = [...bModules, ...cModules];
|
|
156
|
+
const map = /* @__PURE__ */ new Map();
|
|
157
|
+
mods.forEach((mod) => {
|
|
158
|
+
const modPath = mod.webpackId?.replace(ModuleHashPattern, "") || mod.path?.replace(ModuleHashPattern, "");
|
|
159
|
+
let t = map.get(modPath);
|
|
160
|
+
if (!t) {
|
|
161
|
+
t = { path: modPath };
|
|
162
|
+
}
|
|
163
|
+
if (mod[isBaseline]) {
|
|
164
|
+
t.baseline = mod;
|
|
165
|
+
} else {
|
|
166
|
+
t.current = mod;
|
|
167
|
+
}
|
|
168
|
+
map.set(modPath, t);
|
|
169
|
+
});
|
|
170
|
+
return [...map.values()];
|
|
171
|
+
}, [bModules, cModules, searchText]);
|
|
172
|
+
const { bMoudlesCount, cMoudlesCount, totalCount } = useMemo(() => {
|
|
173
|
+
const fileNameFilter = (e) => getPathInfo(e).alias.indexOf(searchText) > -1;
|
|
174
|
+
let b = dataSource.filter((e) => e.baseline);
|
|
175
|
+
let c = dataSource.filter((e) => e.current);
|
|
176
|
+
let totalCount2 = dataSource.length;
|
|
177
|
+
if (searchText) {
|
|
178
|
+
b = b.filter(fileNameFilter);
|
|
179
|
+
c = c.filter(fileNameFilter);
|
|
180
|
+
totalCount2 = dataSource.filter(fileNameFilter).length;
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
bMoudlesCount: b.length,
|
|
184
|
+
cMoudlesCount: c.length,
|
|
185
|
+
totalCount: totalCount2
|
|
186
|
+
};
|
|
187
|
+
}, [dataSource, searchText]);
|
|
188
|
+
return /* @__PURE__ */ jsx(
|
|
189
|
+
Table,
|
|
190
|
+
{
|
|
191
|
+
dataSource,
|
|
192
|
+
rowKey: (e) => e.path,
|
|
193
|
+
size: "small",
|
|
194
|
+
pagination: {
|
|
195
|
+
size: "small"
|
|
196
|
+
},
|
|
197
|
+
bordered: true,
|
|
198
|
+
scroll: { x: 1500 },
|
|
199
|
+
columns: [
|
|
200
|
+
{
|
|
201
|
+
fixed: "left",
|
|
202
|
+
title: () => {
|
|
203
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
204
|
+
/* @__PURE__ */ jsxs(Typography.Text, { children: [
|
|
205
|
+
"Modules of ",
|
|
206
|
+
`"${data.alias}"`
|
|
207
|
+
] }),
|
|
208
|
+
/* @__PURE__ */ jsx(Divider, { type: "vertical" }),
|
|
209
|
+
/* @__PURE__ */ jsxs(
|
|
210
|
+
Tooltip,
|
|
211
|
+
{
|
|
212
|
+
title: /* @__PURE__ */ jsxs(Space, { direction: "vertical", children: [
|
|
213
|
+
/* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
|
|
214
|
+
"filtered modules: ",
|
|
215
|
+
totalCount
|
|
216
|
+
] }),
|
|
217
|
+
/* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
|
|
218
|
+
"total modules: ",
|
|
219
|
+
dataSource.length
|
|
220
|
+
] })
|
|
221
|
+
] }),
|
|
222
|
+
children: [
|
|
223
|
+
/* @__PURE__ */ jsxs(
|
|
224
|
+
Typography.Text,
|
|
225
|
+
{
|
|
226
|
+
type: "secondary",
|
|
227
|
+
style: { fontSize: 10, fontWeight: 400, marginRight: 4 },
|
|
228
|
+
children: [
|
|
229
|
+
totalCount,
|
|
230
|
+
"/",
|
|
231
|
+
dataSource.length
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
),
|
|
235
|
+
/* @__PURE__ */ jsx(InfoCircleOutlined, {})
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
] });
|
|
240
|
+
},
|
|
241
|
+
filterDropdown({
|
|
242
|
+
setSelectedKeys,
|
|
243
|
+
selectedKeys,
|
|
244
|
+
confirm,
|
|
245
|
+
clearFilters
|
|
246
|
+
}) {
|
|
247
|
+
return /* @__PURE__ */ jsxs(
|
|
248
|
+
"div",
|
|
249
|
+
{
|
|
250
|
+
style: { padding: 8 },
|
|
251
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
252
|
+
children: [
|
|
253
|
+
/* @__PURE__ */ jsx(
|
|
254
|
+
Input,
|
|
255
|
+
{
|
|
256
|
+
ref: searchInput,
|
|
257
|
+
placeholder: `Search by file name`,
|
|
258
|
+
value: selectedKeys[0],
|
|
259
|
+
onChange: (e) => setSelectedKeys(e.target.value ? [e.target.value] : []),
|
|
260
|
+
onPressEnter: () => handleSearch(selectedKeys, confirm),
|
|
261
|
+
style: { marginBottom: 8, display: "block" }
|
|
262
|
+
}
|
|
263
|
+
),
|
|
264
|
+
/* @__PURE__ */ jsxs(Space, { children: [
|
|
265
|
+
/* @__PURE__ */ jsx(
|
|
266
|
+
Button,
|
|
267
|
+
{
|
|
268
|
+
type: "primary",
|
|
269
|
+
onClick: () => handleSearch(selectedKeys, confirm),
|
|
270
|
+
icon: /* @__PURE__ */ jsx(SearchOutlined, {}),
|
|
271
|
+
size: "small",
|
|
272
|
+
style: { width: 90 },
|
|
273
|
+
children: "Search"
|
|
274
|
+
}
|
|
275
|
+
),
|
|
276
|
+
/* @__PURE__ */ jsx(
|
|
277
|
+
Button,
|
|
278
|
+
{
|
|
279
|
+
onClick: () => {
|
|
280
|
+
clearFilters && handleReset(clearFilters);
|
|
281
|
+
setSelectedKeys([]);
|
|
282
|
+
handleSearch([], confirm);
|
|
283
|
+
},
|
|
284
|
+
size: "small",
|
|
285
|
+
style: { width: 90 },
|
|
286
|
+
children: "Reset"
|
|
287
|
+
}
|
|
288
|
+
)
|
|
289
|
+
] })
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
},
|
|
294
|
+
filterSearch: true,
|
|
295
|
+
filterIcon: (filtered) => /* @__PURE__ */ jsxs(Space, { children: [
|
|
296
|
+
/* @__PURE__ */ jsx(
|
|
297
|
+
Typography.Text,
|
|
298
|
+
{
|
|
299
|
+
type: searchText ? void 0 : "secondary",
|
|
300
|
+
style: { fontWeight: 400 },
|
|
301
|
+
children: searchText || "Search by file name"
|
|
302
|
+
}
|
|
303
|
+
),
|
|
304
|
+
/* @__PURE__ */ jsx(
|
|
305
|
+
SearchOutlined,
|
|
306
|
+
{
|
|
307
|
+
style: { color: filtered ? Color.Blue : void 0 }
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
] }),
|
|
311
|
+
onFilterDropdownOpenChange: (visible) => {
|
|
312
|
+
if (visible) {
|
|
313
|
+
setTimeout(() => searchInput.current?.focus(), 100);
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
onFilter(v, r) {
|
|
317
|
+
return getPathInfo(r).alias.indexOf(v) > -1;
|
|
318
|
+
},
|
|
319
|
+
render: (_v, r) => {
|
|
320
|
+
const { alias, inNodeModules } = getPathInfo(r);
|
|
321
|
+
return /* @__PURE__ */ jsxs(Space, { children: [
|
|
322
|
+
/* @__PURE__ */ jsx(Tooltip, { title: r.path, children: /* @__PURE__ */ jsx(Typography.Text, { copyable: { text: r.path }, children: alias }) }),
|
|
323
|
+
inNodeModules ? /* @__PURE__ */ jsx(Tag, { color: "warning", children: "node_modules" }) : null,
|
|
324
|
+
/* @__PURE__ */ jsx(FileUpdateTypeTag, { type: getUpdateType(r) })
|
|
325
|
+
] });
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
getTargetColumnPropsForModuleRow(
|
|
329
|
+
"current",
|
|
330
|
+
bMoudlesCount,
|
|
331
|
+
cMoudlesCount
|
|
332
|
+
),
|
|
333
|
+
getTargetColumnPropsForModuleRow(
|
|
334
|
+
"baseline",
|
|
335
|
+
bMoudlesCount,
|
|
336
|
+
cMoudlesCount
|
|
337
|
+
),
|
|
338
|
+
{
|
|
339
|
+
title: "Actions",
|
|
340
|
+
width: 200,
|
|
341
|
+
render: (_v, r) => {
|
|
342
|
+
return /* @__PURE__ */ jsx(Space, { direction: "vertical", style: { maxWidth: 170 }, children: /* @__PURE__ */ jsx(
|
|
343
|
+
ViewChanges,
|
|
344
|
+
{
|
|
345
|
+
text: "View Changes",
|
|
346
|
+
file: r.path,
|
|
347
|
+
data: [
|
|
348
|
+
{
|
|
349
|
+
baseline: baseline.moduleCodeMap[r.baseline?.id]?.source,
|
|
350
|
+
current: current.moduleCodeMap[r.current?.id]?.source,
|
|
351
|
+
group: "Source"
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
baseline: baseline.moduleCodeMap[r.baseline?.id]?.transformed,
|
|
355
|
+
current: current.moduleCodeMap[r.current?.id]?.transformed,
|
|
356
|
+
group: "Transformed Source"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
baseline: baseline.moduleCodeMap[r.baseline?.id]?.parsedSource,
|
|
360
|
+
current: current.moduleCodeMap[r.current?.id]?.parsedSource,
|
|
361
|
+
group: "Parsed Source"
|
|
362
|
+
}
|
|
363
|
+
]
|
|
364
|
+
}
|
|
365
|
+
) });
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
]
|
|
369
|
+
}
|
|
370
|
+
);
|
|
371
|
+
};
|
|
372
|
+
export {
|
|
373
|
+
ModuleHashPattern,
|
|
374
|
+
ModuleRowForAsset,
|
|
375
|
+
getSizeColumnPropsForModuleRow,
|
|
376
|
+
getTargetColumnPropsForModuleRow
|
|
377
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Client, Manifest, SDK } from '@rsdoctor/types';
|
|
2
|
+
import { UpdateType } from './constants';
|
|
3
|
+
import { InferServerAPIBody } from '../../../../components/Manifest/api';
|
|
4
|
+
export type BundleDiffServerAPIProviderComponentCommonProps<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends> = {
|
|
5
|
+
manifests?: Manifest.RsdoctorManifest[];
|
|
6
|
+
api: T;
|
|
7
|
+
children: (baseline: SDK.ServerAPI.InferResponseType<T>, current: SDK.ServerAPI.InferResponseType<T>) => JSX.Element;
|
|
8
|
+
} & InferServerAPIBody<T>;
|
|
9
|
+
export interface BundleDiffContainerProps {
|
|
10
|
+
manifests: Manifest.RsdoctorManifest[];
|
|
11
|
+
}
|
|
12
|
+
export interface BundleDiffComponentCommonProps {
|
|
13
|
+
baseline: Manifest.RsdoctorManifest;
|
|
14
|
+
current: Manifest.RsdoctorManifest;
|
|
15
|
+
onlyBaseline: boolean;
|
|
16
|
+
assetsDiffResult: Client.RsdoctorClientAssetsDiffResult;
|
|
17
|
+
}
|
|
18
|
+
export interface BundleDiffComponentCardProps {
|
|
19
|
+
baseline: SDK.ServerAPI.ResponseTypes[SDK.ServerAPI.API.GetBundleDiffSummary];
|
|
20
|
+
current: SDK.ServerAPI.ResponseTypes[SDK.ServerAPI.API.GetBundleDiffSummary];
|
|
21
|
+
onlyBaseline: boolean;
|
|
22
|
+
assetsDiffResult: Client.RsdoctorClientAssetsDiffResult;
|
|
23
|
+
}
|
|
24
|
+
export interface BundleDiffTableOverviewData {
|
|
25
|
+
total: Client.RsdoctorClientAssetsDiffItem;
|
|
26
|
+
initial?: Client.RsdoctorClientAssetsDiffItem;
|
|
27
|
+
}
|
|
28
|
+
export interface BundleDiffTableAssetsData {
|
|
29
|
+
alias: string;
|
|
30
|
+
baseline?: SDK.AssetData;
|
|
31
|
+
current?: SDK.AssetData;
|
|
32
|
+
}
|
|
33
|
+
export interface BundleDiffTableModulesData {
|
|
34
|
+
path: string;
|
|
35
|
+
baseline?: SDK.ModuleData;
|
|
36
|
+
current?: SDK.ModuleData;
|
|
37
|
+
__is_baseline__?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface BundleDiffTablePackagesData {
|
|
40
|
+
name: string;
|
|
41
|
+
updateType: UpdateType;
|
|
42
|
+
baseline?: SDK.PackageData[];
|
|
43
|
+
current?: SDK.PackageData[];
|
|
44
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Client } from "@rsdoctor/types";
|
|
3
|
+
import { Typography } from "antd";
|
|
4
|
+
import { Color } from "../../../../constants";
|
|
5
|
+
import { formatSize } from "../../../../utils";
|
|
6
|
+
const formatDiffSize = (bSize, cSize, state, propsStyle) => {
|
|
7
|
+
return /* @__PURE__ */ jsx(Fragment, { children: cSize - bSize === 0 ? /* @__PURE__ */ jsx(Fragment, {}) : /* @__PURE__ */ jsxs(
|
|
8
|
+
Typography.Text,
|
|
9
|
+
{
|
|
10
|
+
strong: true,
|
|
11
|
+
style: {
|
|
12
|
+
color: state === Client.RsdoctorClientDiffState.Up ? Color.Red : Color.Green,
|
|
13
|
+
...propsStyle
|
|
14
|
+
},
|
|
15
|
+
children: [
|
|
16
|
+
state === Client.RsdoctorClientDiffState.Up ? "+" : "-",
|
|
17
|
+
formatSize(Math.abs(cSize - bSize))
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
) });
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
formatDiffSize
|
|
24
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
import { BundleDiffServerAPIProviderComponentCommonProps } from '../DiffContainer/types';
|
|
3
|
+
export declare const DiffServerAPIProvider: <T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(props: BundleDiffServerAPIProviderComponentCommonProps<T>) => JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Client } from "@rsdoctor/types";
|
|
3
|
+
import { ServerAPIProvider } from "../../../../components/Manifest";
|
|
4
|
+
import { fetchManifest, useUrlQuery } from "../../../../utils";
|
|
5
|
+
const DiffServerAPIProvider = (props) => {
|
|
6
|
+
const { api, body, children, manifests } = props;
|
|
7
|
+
const query = useUrlQuery();
|
|
8
|
+
const [baselineFile, currentFile] = query[Client.RsdoctorClientUrlQuery.BundleDiffFiles]?.split(",") || [];
|
|
9
|
+
if (manifests?.length) {
|
|
10
|
+
return /* @__PURE__ */ jsx(Fragment, { children: children(manifests[0].data, manifests[1].data) });
|
|
11
|
+
}
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
ServerAPIProvider,
|
|
14
|
+
{
|
|
15
|
+
api,
|
|
16
|
+
body,
|
|
17
|
+
manifestLoader: baselineFile ? () => fetchManifest(baselineFile) : void 0,
|
|
18
|
+
children: (baseline) => {
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
ServerAPIProvider,
|
|
21
|
+
{
|
|
22
|
+
api,
|
|
23
|
+
body,
|
|
24
|
+
manifestLoader: currentFile ? () => fetchManifest(currentFile) : void 0,
|
|
25
|
+
children: (current) => {
|
|
26
|
+
return children(baseline, current);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
DiffServerAPIProvider
|
|
36
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Client, Manifest } from '@rsdoctor/types';
|
|
3
|
+
export declare const name = "Bundle Diff";
|
|
4
|
+
export declare const route = Client.RsdoctorClientRoutes.BundleDiff;
|
|
5
|
+
export declare const BundleDiffContext: React.Context<{
|
|
6
|
+
manifests: Manifest.RsdoctorManifest[];
|
|
7
|
+
setManifests(_manifests: Manifest.RsdoctorManifest[]): void;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
setLoading(_loading: boolean): void;
|
|
10
|
+
withLoading(_func: (...args: unknown[]) => Promise<unknown> | unknown): Promise<void>;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Client } from "@rsdoctor/types";
|
|
3
|
+
const name = "Bundle Diff";
|
|
4
|
+
const route = Client.RsdoctorClientRoutes.BundleDiff;
|
|
5
|
+
const BundleDiffContext = React.createContext({
|
|
6
|
+
manifests: [],
|
|
7
|
+
setManifests(_manifests) {
|
|
8
|
+
},
|
|
9
|
+
loading: false,
|
|
10
|
+
setLoading(_loading) {
|
|
11
|
+
},
|
|
12
|
+
async withLoading(_func) {
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
BundleDiffContext,
|
|
17
|
+
name,
|
|
18
|
+
route
|
|
19
|
+
};
|
package/dist/pages/index.d.ts
CHANGED
package/dist/pages/index.js
CHANGED
|
@@ -7,7 +7,9 @@ import * as PluginsAnalyze from "./WebpackPlugins";
|
|
|
7
7
|
import * as ModuleResolve from "./ModuleResolve";
|
|
8
8
|
import * as RuleIndex from "./Resources/RuleIndex";
|
|
9
9
|
import * as TreeShaking from "./TreeShaking";
|
|
10
|
+
import * as BundleDiff from "./Resources/BundleDiff";
|
|
10
11
|
export {
|
|
12
|
+
BundleDiff,
|
|
11
13
|
BundleSize,
|
|
12
14
|
LoaderFiles,
|
|
13
15
|
LoaderTimeline,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/components",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dist/"
|
|
45
45
|
],
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@ant-design/icons": "5.
|
|
47
|
+
"@ant-design/icons": "5.5.1",
|
|
48
48
|
"@monaco-editor/react": "4.6.0",
|
|
49
49
|
"@types/lodash-es": "4.17.12",
|
|
50
50
|
"@types/node": "^16",
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"terser": "^5.31.6",
|
|
76
76
|
"typescript": "^5.2.2",
|
|
77
77
|
"url-parse": "1.5.10",
|
|
78
|
-
"@rsdoctor/graph": "0.4.
|
|
79
|
-
"@rsdoctor/types": "0.4.
|
|
80
|
-
"@rsdoctor/utils": "0.4.
|
|
78
|
+
"@rsdoctor/graph": "0.4.4",
|
|
79
|
+
"@rsdoctor/types": "0.4.4",
|
|
80
|
+
"@rsdoctor/utils": "0.4.4"
|
|
81
81
|
},
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public",
|