@rsdoctor/components 0.1.6 → 0.1.8

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.
Files changed (41) hide show
  1. package/dist/components/BundleDiff/DiffContainer/assets.d.ts +7 -0
  2. package/dist/components/BundleDiff/DiffContainer/assets.js +507 -0
  3. package/dist/components/BundleDiff/DiffContainer/cards.d.ts +3 -0
  4. package/dist/components/BundleDiff/DiffContainer/cards.js +156 -0
  5. package/dist/components/BundleDiff/DiffContainer/changes.d.ts +15 -0
  6. package/dist/components/BundleDiff/DiffContainer/changes.js +69 -0
  7. package/dist/components/BundleDiff/DiffContainer/constants.d.ts +11 -0
  8. package/dist/components/BundleDiff/DiffContainer/constants.js +17 -0
  9. package/dist/components/BundleDiff/DiffContainer/diff.d.ts +23 -0
  10. package/dist/components/BundleDiff/DiffContainer/diff.js +114 -0
  11. package/dist/components/BundleDiff/DiffContainer/index.d.ts +3 -0
  12. package/dist/components/BundleDiff/DiffContainer/index.js +180 -0
  13. package/dist/components/BundleDiff/DiffContainer/modules.d.ts +8 -0
  14. package/dist/components/BundleDiff/DiffContainer/modules.js +302 -0
  15. package/dist/components/BundleDiff/DiffContainer/overview.d.ts +5 -0
  16. package/dist/components/BundleDiff/DiffContainer/overview.js +178 -0
  17. package/dist/components/BundleDiff/DiffContainer/packages.d.ts +19 -0
  18. package/dist/components/BundleDiff/DiffContainer/packages.js +330 -0
  19. package/dist/components/BundleDiff/DiffContainer/row.d.ts +9 -0
  20. package/dist/components/BundleDiff/DiffContainer/row.js +369 -0
  21. package/dist/components/BundleDiff/DiffContainer/types.d.ts +45 -0
  22. package/dist/components/BundleDiff/DiffContainer/types.js +0 -0
  23. package/dist/components/BundleDiff/DiffContainer/utils.d.ts +2 -0
  24. package/dist/components/BundleDiff/DiffContainer/utils.js +24 -0
  25. package/dist/components/BundleDiff/DiffServerAPIProvider/index.d.ts +4 -0
  26. package/dist/components/BundleDiff/DiffServerAPIProvider/index.js +37 -0
  27. package/dist/components/BundleDiff/constants.d.ts +11 -0
  28. package/dist/components/BundleDiff/constants.js +19 -0
  29. package/dist/components/BundleDiff/index.d.ts +1 -0
  30. package/dist/components/BundleDiff/index.js +1 -0
  31. package/dist/components/Card/diff.d.ts +1 -0
  32. package/dist/components/Card/diff.js +18 -4
  33. package/dist/components/Card/index.d.ts +1 -0
  34. package/dist/components/Card/index.js +22 -3
  35. package/dist/components/index.d.ts +4 -0
  36. package/dist/components/index.js +4 -0
  37. package/dist/utils/data/base.d.ts +1 -1
  38. package/dist/utils/data/remote.js +8 -2
  39. package/dist/utils/request.d.ts +4 -0
  40. package/dist/utils/request.js +25 -8
  41. package/package.json +6 -6
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { SDK } from '@rsdoctor/types';
3
+ export declare const Assets: React.FC<{
4
+ outputFilename: string;
5
+ baseline: SDK.ServerAPI.ResponseTypes[SDK.ServerAPI.API.GetBundleDiffSummary];
6
+ current: SDK.ServerAPI.ResponseTypes[SDK.ServerAPI.API.GetBundleDiffSummary];
7
+ }>;
@@ -0,0 +1,507 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from "react";
3
+ import {
4
+ Button,
5
+ Col,
6
+ Divider,
7
+ Row,
8
+ Select,
9
+ Space,
10
+ Table,
11
+ Tag,
12
+ Tooltip,
13
+ Typography
14
+ } from "antd";
15
+ import { Graph } from "@rsdoctor/utils/common";
16
+ import { flatten, includes, keys, sumBy, values } from "lodash-es";
17
+ import {
18
+ CheckSquareOutlined,
19
+ InfoCircleOutlined,
20
+ MinusSquareOutlined,
21
+ PlusSquareOutlined,
22
+ SortAscendingOutlined,
23
+ FileSearchOutlined,
24
+ AppstoreAddOutlined
25
+ } from "@ant-design/icons";
26
+ import { Constants, Client } from "@rsdoctor/types";
27
+ import { formatPercent, formatSize } from "@rsdoctor/components/utils";
28
+ import { Percent, SizePercent } from "@rsdoctor/components/elements";
29
+ import { KeywordInput } from "@rsdoctor/components";
30
+ import { ModuleRowForAsset } from "./row";
31
+ import { ViewChanges } from "./changes";
32
+ import { UpdateType, SortType } from "./constants";
33
+ import { formatDiffSize } from "./utils";
34
+ import { Color, Size } from "../../../constants";
35
+ const fileTypes = {
36
+ JS: [Constants.JSExtension],
37
+ CSS: [Constants.CSSExtension],
38
+ HTML: [Constants.HtmlExtension],
39
+ Imgs: Constants.ImgExtensions,
40
+ Fonts: Constants.FontExtensions,
41
+ Media: Constants.MediaExtensions,
42
+ Others: []
43
+ };
44
+ const definedExtensions = flatten(values(fileTypes));
45
+ const Name = ({ data: r }) => {
46
+ const name = /* @__PURE__ */ jsxs(Space, { children: [
47
+ /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: r.alias }),
48
+ /* @__PURE__ */ jsx(
49
+ Tooltip,
50
+ {
51
+ title: /* @__PURE__ */ jsxs(Space, { style: { color: "inherit" }, direction: "vertical", children: [
52
+ r.current ? /* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
53
+ "Current realpath: ",
54
+ r.current.path
55
+ ] }) : null,
56
+ r.baseline ? /* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
57
+ "Baseline realpath: ",
58
+ r.baseline.path
59
+ ] }) : null
60
+ ] }),
61
+ children: /* @__PURE__ */ jsx(InfoCircleOutlined, {})
62
+ }
63
+ )
64
+ ] });
65
+ if (r.baseline && !r.current) {
66
+ return /* @__PURE__ */ jsxs(Space, { children: [
67
+ /* @__PURE__ */ jsx(MinusSquareOutlined, { style: { color: Color.Red } }),
68
+ name
69
+ ] });
70
+ }
71
+ if (!r.baseline && r.current) {
72
+ return /* @__PURE__ */ jsxs(Space, { children: [
73
+ /* @__PURE__ */ jsx(PlusSquareOutlined, { style: { color: Color.Green } }),
74
+ name
75
+ ] });
76
+ }
77
+ if (r.baseline && r.current) {
78
+ return /* @__PURE__ */ jsxs(Space, { children: [
79
+ /* @__PURE__ */ jsx(CheckSquareOutlined, { style: { color: Color.Yellow } }),
80
+ name
81
+ ] });
82
+ }
83
+ return name;
84
+ };
85
+ const Assets = ({ baseline, current, outputFilename }) => {
86
+ const bOutPutFileName = outputFilename;
87
+ const [keyword, setKeyword] = useState();
88
+ const [selectedFileTypes, setSelectedFileTypes] = useState([]);
89
+ const [selectedUpdateTypes, setSelectedUpdateTypes] = useState(
90
+ []
91
+ );
92
+ const [selectedSortType, setSelectedSortType] = useState(
93
+ SortType.Size
94
+ );
95
+ const [selectedBAsset, setSelectedBAsset] = useState(null);
96
+ const [selectedCAsset, setSelectedCAsset] = useState(null);
97
+ const { assets: bAssets } = baseline.chunkGraph;
98
+ const { assets: cAssets } = current.chunkGraph;
99
+ const dataSource = useMemo(() => {
100
+ const res = {};
101
+ if (selectedBAsset && selectedCAsset) {
102
+ res.choose = {
103
+ alias: `${selectedBAsset}
104
+ ${selectedCAsset}`,
105
+ current: cAssets.find((c) => c.path === selectedCAsset),
106
+ baseline: bAssets.find((b) => b.path === selectedBAsset)
107
+ };
108
+ return values(res);
109
+ }
110
+ bAssets.forEach((asset) => {
111
+ const alias = Graph.formatAssetName(asset.path, bOutPutFileName);
112
+ if (!res[alias]) {
113
+ res[alias] = {
114
+ alias,
115
+ baseline: asset
116
+ };
117
+ } else {
118
+ console.warn("[Baseline Asset Exists]: ", asset, res);
119
+ }
120
+ });
121
+ cAssets.forEach((asset) => {
122
+ const alias = Graph.formatAssetName(asset.path, bOutPutFileName);
123
+ if (!res[alias]) {
124
+ res[alias] = { alias };
125
+ }
126
+ res[alias].current = asset;
127
+ });
128
+ return values(res);
129
+ }, [bAssets, cAssets, selectedBAsset, selectedCAsset]);
130
+ const filteredDataSource = useMemo(() => {
131
+ let list = dataSource.slice();
132
+ if (keyword) {
133
+ list = list.filter((e) => e.alias.indexOf(keyword) > -1);
134
+ }
135
+ if (selectedFileTypes.length) {
136
+ const exts = flatten(
137
+ selectedFileTypes.map((e) => fileTypes[e])
138
+ );
139
+ const hasOthers = selectedFileTypes.indexOf("Others") > -1;
140
+ list = list.filter((e) => {
141
+ const asset = e.baseline || e.current;
142
+ if (Graph.isAssetMatchExtensions(asset, exts)) {
143
+ return true;
144
+ }
145
+ if (hasOthers) {
146
+ return !Graph.isAssetMatchExtensions(asset, definedExtensions);
147
+ }
148
+ return false;
149
+ });
150
+ }
151
+ if (selectedUpdateTypes.length) {
152
+ list = list.filter((e) => {
153
+ if (e.baseline && !e.current) {
154
+ return includes(selectedUpdateTypes, UpdateType.Deleted);
155
+ }
156
+ if (!e.baseline && e.current) {
157
+ return includes(selectedUpdateTypes, UpdateType.New);
158
+ }
159
+ if (e.baseline && e.current) {
160
+ if (e.baseline.size === e.current.size) {
161
+ return includes(selectedUpdateTypes, UpdateType.NotChanged);
162
+ }
163
+ return includes(selectedUpdateTypes, UpdateType.Changed);
164
+ }
165
+ return false;
166
+ });
167
+ }
168
+ if (selectedSortType) {
169
+ if (selectedSortType === SortType.Name) {
170
+ list.sort((a, b) => {
171
+ return a.alias.localeCompare(b.alias);
172
+ });
173
+ } else {
174
+ const { prev, others } = list.reduce(
175
+ (t, c) => {
176
+ if (c.current) {
177
+ if (c.baseline) {
178
+ t.prev.unshift(c);
179
+ } else {
180
+ t.prev.push(c);
181
+ }
182
+ } else {
183
+ t.others.push(c);
184
+ }
185
+ return t;
186
+ },
187
+ {
188
+ prev: [],
189
+ others: []
190
+ }
191
+ );
192
+ list = [
193
+ ...prev.sort((a, b) => {
194
+ if (b.current && a.current) {
195
+ if (selectedSortType === SortType.Delta) {
196
+ const { percent: percentA } = Graph.diffAssetsByExtensions(
197
+ baseline.chunkGraph,
198
+ current.chunkGraph,
199
+ (asset) => Graph.formatAssetName(asset.path, bOutPutFileName) === a.alias
200
+ );
201
+ const { percent: percentB } = Graph.diffAssetsByExtensions(
202
+ baseline.chunkGraph,
203
+ current.chunkGraph,
204
+ (asset) => Graph.formatAssetName(asset.path, bOutPutFileName) === b.alias
205
+ );
206
+ return percentB - percentA;
207
+ }
208
+ return b.current.size - a.current.size;
209
+ }
210
+ return -1;
211
+ }),
212
+ ...others
213
+ ];
214
+ }
215
+ }
216
+ return list;
217
+ }, [
218
+ dataSource,
219
+ keyword,
220
+ selectedFileTypes,
221
+ selectedUpdateTypes,
222
+ selectedSortType
223
+ ]);
224
+ const cSize = useMemo(
225
+ () => sumBy(filteredDataSource, (e) => e.current ? e.current.size : 0) || 0,
226
+ [filteredDataSource]
227
+ );
228
+ const bSize = useMemo(
229
+ () => sumBy(filteredDataSource, (e) => e.baseline ? e.baseline.size : 0) || 0,
230
+ [filteredDataSource]
231
+ );
232
+ return /* @__PURE__ */ jsxs(Row, { gutter: [Size.BasePadding, Size.BasePadding], children: [
233
+ /* @__PURE__ */ jsxs(Col, { span: 24, children: [
234
+ /* @__PURE__ */ jsxs(Space, { wrap: true, children: [
235
+ /* @__PURE__ */ jsx(
236
+ KeywordInput,
237
+ {
238
+ icon: /* @__PURE__ */ jsx(FileSearchOutlined, {}),
239
+ label: "",
240
+ labelStyle: { width: 45 },
241
+ placeholder: "Search by file name",
242
+ onChange: (e) => {
243
+ setKeyword(e);
244
+ }
245
+ }
246
+ ),
247
+ /* @__PURE__ */ jsx(
248
+ Select,
249
+ {
250
+ mode: "multiple",
251
+ placeholder: "Filter by file type",
252
+ style: { width: 250 },
253
+ options: keys(fileTypes).map((e) => ({ label: e, value: e })),
254
+ allowClear: true,
255
+ onChange: (e) => {
256
+ setSelectedFileTypes(e);
257
+ }
258
+ }
259
+ ),
260
+ /* @__PURE__ */ jsx(
261
+ Select,
262
+ {
263
+ mode: "multiple",
264
+ placeholder: "Filter by file changed type",
265
+ style: { width: 200 },
266
+ options: values(UpdateType).map((e) => ({ label: e, value: e })),
267
+ allowClear: true,
268
+ onChange: (e) => {
269
+ setSelectedUpdateTypes(e);
270
+ }
271
+ }
272
+ ),
273
+ /* @__PURE__ */ jsx(
274
+ Select,
275
+ {
276
+ suffixIcon: /* @__PURE__ */ jsx(SortAscendingOutlined, {}),
277
+ options: values(SortType).map((e) => ({ label: e, value: e })),
278
+ value: selectedSortType,
279
+ onChange: (e) => {
280
+ setSelectedSortType(e);
281
+ }
282
+ }
283
+ )
284
+ ] }),
285
+ /* @__PURE__ */ jsxs(Row, { style: { marginTop: 10 }, gutter: [6, 6], children: [
286
+ /* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(Button, { children: "Select Baseline Asset and Current Asset to Diff " }) }),
287
+ /* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(
288
+ Select,
289
+ {
290
+ allowClear: true,
291
+ placeholder: "select baseline assets",
292
+ showSearch: true,
293
+ style: { width: 300 },
294
+ options: values(baseline.chunkGraph.assets).map((e) => ({
295
+ label: e.path,
296
+ value: e.path
297
+ })),
298
+ onChange: (e) => setSelectedBAsset(e)
299
+ }
300
+ ) }),
301
+ /* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(
302
+ Select,
303
+ {
304
+ allowClear: true,
305
+ placeholder: "select current assets",
306
+ showSearch: true,
307
+ style: { width: 300 },
308
+ options: values(current.chunkGraph.assets).map((e) => ({
309
+ label: e.path,
310
+ value: e.path
311
+ })),
312
+ onChange: (e) => setSelectedCAsset(e)
313
+ }
314
+ ) })
315
+ ] })
316
+ ] }),
317
+ /* @__PURE__ */ jsx(Col, { span: 24, children: /* @__PURE__ */ jsx(
318
+ Table,
319
+ {
320
+ bordered: true,
321
+ sticky: { offsetHeader: 54 },
322
+ pagination: {
323
+ pageSize: 20,
324
+ size: "small"
325
+ },
326
+ dataSource: filteredDataSource,
327
+ rowKey: (e) => e.alias,
328
+ expandable: {
329
+ expandedRowRender: (r) => {
330
+ return /* @__PURE__ */ jsx("div", { style: { margin: Size.BasePadding / 3 }, children: /* @__PURE__ */ jsx(
331
+ ModuleRowForAsset,
332
+ {
333
+ data: r,
334
+ baseline,
335
+ current
336
+ }
337
+ ) });
338
+ },
339
+ columnTitle: /* @__PURE__ */ jsx(
340
+ Tooltip,
341
+ {
342
+ title: "Click to expand row to see the modules which the chunk contains",
343
+ placement: "left",
344
+ children: /* @__PURE__ */ jsx(AppstoreAddOutlined, { style: { cursor: "pointer" } })
345
+ }
346
+ )
347
+ },
348
+ columns: [
349
+ {
350
+ title: /* @__PURE__ */ jsxs(
351
+ Tooltip,
352
+ {
353
+ title: /* @__PURE__ */ jsxs(Space, { direction: "vertical", children: [
354
+ /* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
355
+ "filtered assets is ",
356
+ filteredDataSource.length
357
+ ] }),
358
+ /* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
359
+ "total assets is ",
360
+ dataSource.length
361
+ ] })
362
+ ] }),
363
+ children: [
364
+ /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "Assets" }),
365
+ /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
366
+ /* @__PURE__ */ jsxs(
367
+ Typography.Text,
368
+ {
369
+ type: "secondary",
370
+ style: { fontSize: 10, fontWeight: 400, marginRight: 4 },
371
+ children: [
372
+ filteredDataSource.length,
373
+ "/",
374
+ dataSource.length
375
+ ]
376
+ }
377
+ ),
378
+ /* @__PURE__ */ jsx(InfoCircleOutlined, {})
379
+ ]
380
+ }
381
+ ),
382
+ render: (_v, r) => /* @__PURE__ */ jsx(Name, { data: r })
383
+ },
384
+ {
385
+ title: () => {
386
+ const cs = formatSize(cSize);
387
+ const diff = Graph.diffSize(bSize, cSize);
388
+ return /* @__PURE__ */ jsxs(
389
+ Tooltip,
390
+ {
391
+ title: `Current size is ${cs}, Delta is ${formatPercent(
392
+ diff.percent
393
+ )}`,
394
+ children: [
395
+ /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "Current" }),
396
+ /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
397
+ /* @__PURE__ */ jsxs(
398
+ Typography.Text,
399
+ {
400
+ style: { fontSize: 10, fontWeight: 400, marginRight: 4 },
401
+ children: [
402
+ /* @__PURE__ */ jsx(
403
+ Typography.Text,
404
+ {
405
+ style: { fontSize: "inherit", marginRight: 8 },
406
+ children: cs
407
+ }
408
+ ),
409
+ /* @__PURE__ */ jsx(
410
+ SizePercent,
411
+ {
412
+ fontSize: "inherit",
413
+ baseline: bSize,
414
+ current: cSize
415
+ }
416
+ ),
417
+ formatDiffSize(
418
+ bSize,
419
+ cSize,
420
+ bSize > cSize ? Client.RsdoctorClientDiffState.Down : Client.RsdoctorClientDiffState.Up,
421
+ { fontSize: 10, fontWeight: 400, marginLeft: 4 }
422
+ )
423
+ ]
424
+ }
425
+ ),
426
+ /* @__PURE__ */ jsx(InfoCircleOutlined, {})
427
+ ]
428
+ }
429
+ );
430
+ },
431
+ render: (_v, r) => {
432
+ if (r.current) {
433
+ const { percent, state } = Graph.diffAssetsByExtensions(
434
+ baseline.chunkGraph,
435
+ current.chunkGraph,
436
+ (asset) => Graph.formatAssetName(asset.path, bOutPutFileName) === r.alias
437
+ );
438
+ const isInitial = Graph.isInitialAsset(
439
+ r.current,
440
+ current.chunkGraph.chunks
441
+ );
442
+ return /* @__PURE__ */ jsxs(Space, { children: [
443
+ /* @__PURE__ */ jsx(Typography.Text, { children: formatSize(r.current.size) }),
444
+ /* @__PURE__ */ jsx(Percent, { percent, state }),
445
+ isInitial ? /* @__PURE__ */ jsx(Tag, { color: Color.Blue, children: "initial" }) : null
446
+ ] });
447
+ }
448
+ return "-";
449
+ }
450
+ },
451
+ {
452
+ title: () => {
453
+ const bs = formatSize(bSize);
454
+ return /* @__PURE__ */ jsxs(Tooltip, { title: `Baseline size is ${bs}`, children: [
455
+ /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "Baseline" }),
456
+ /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
457
+ /* @__PURE__ */ jsx(
458
+ Typography.Text,
459
+ {
460
+ style: { fontSize: 10, fontWeight: 400, marginRight: 4 },
461
+ children: bs
462
+ }
463
+ ),
464
+ /* @__PURE__ */ jsx(InfoCircleOutlined, {})
465
+ ] });
466
+ },
467
+ render: (_v, r) => {
468
+ if (r.baseline) {
469
+ const isInitial = Graph.isInitialAsset(
470
+ r.baseline,
471
+ baseline.chunkGraph.chunks
472
+ );
473
+ return /* @__PURE__ */ jsxs(Space, { children: [
474
+ /* @__PURE__ */ jsx(Typography.Text, { children: formatSize(r.baseline.size) }),
475
+ isInitial ? /* @__PURE__ */ jsx(Tag, { color: Color.Blue, children: "initial" }) : null
476
+ ] });
477
+ }
478
+ return "-";
479
+ }
480
+ },
481
+ {
482
+ title: "Actions",
483
+ key: "actions",
484
+ render: (_v, r) => {
485
+ return /* @__PURE__ */ jsx(
486
+ ViewChanges,
487
+ {
488
+ file: r.alias,
489
+ data: [
490
+ {
491
+ baseline: r.baseline?.content,
492
+ current: r.current?.content,
493
+ group: "assets"
494
+ }
495
+ ]
496
+ }
497
+ );
498
+ }
499
+ }
500
+ ]
501
+ }
502
+ ) })
503
+ ] });
504
+ };
505
+ export {
506
+ Assets
507
+ };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { BundleDiffComponentCardProps } from './types';
3
+ export declare const DiffCards: React.FC<BundleDiffComponentCardProps>;
@@ -0,0 +1,156 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { DuplicatePackageDrawer } from "@rsdoctor/components";
3
+ import { DiffCard, Percent } from "@rsdoctor/components/elements";
4
+ import {
5
+ useDuplicatePackagesByErrors,
6
+ useModuleGraph,
7
+ useUniqModules
8
+ } from "@rsdoctor/components/utils";
9
+ import { Client } from "@rsdoctor/types";
10
+ import { Graph } from "@rsdoctor/utils/common";
11
+ import { Col, Row, Space, Typography } from "antd";
12
+ import { Size } from "../../../constants";
13
+ import { PackagesStatistic, getPackagesTableDataSource } from "./packages";
14
+ const DiffCards = ({
15
+ baseline,
16
+ current,
17
+ assetsDiffResult
18
+ }) => {
19
+ const baselineMod = useUniqModules(baseline.moduleGraph.modules);
20
+ const currentMod = useUniqModules(current.moduleGraph.modules);
21
+ const baselineDup = useDuplicatePackagesByErrors(baseline.errors);
22
+ const currentDup = useDuplicatePackagesByErrors(current.errors);
23
+ const baselineModuleGraph = useModuleGraph(baseline.moduleGraph);
24
+ const currentModuleGraph = useModuleGraph(current.moduleGraph);
25
+ const baselineCwd = baseline.root;
26
+ const currentCwd = current.root;
27
+ const packages = getPackagesTableDataSource({
28
+ baseline: baseline.packageGraph,
29
+ current: current.packageGraph
30
+ });
31
+ const arr = [
32
+ {
33
+ title: ["Bundle Size"],
34
+ value: [assetsDiffResult.all.total]
35
+ },
36
+ {
37
+ title: ["Total JS", "Initial JS"],
38
+ value: [assetsDiffResult.js.total, assetsDiffResult.js.initial]
39
+ },
40
+ {
41
+ title: ["Total CSS", "Initial CSS"],
42
+ value: [assetsDiffResult.css.total, assetsDiffResult.css.initial]
43
+ },
44
+ {
45
+ title: ["Images", "Fonts", "Media"],
46
+ value: [
47
+ assetsDiffResult.imgs.total,
48
+ assetsDiffResult.fonts.total,
49
+ assetsDiffResult.media.total
50
+ ]
51
+ },
52
+ { title: ["HTML"], value: [assetsDiffResult.html.total] },
53
+ { title: ["Others"], value: [assetsDiffResult.others.total] }
54
+ ];
55
+ return /* @__PURE__ */ jsxs(
56
+ Row,
57
+ {
58
+ gutter: [Size.BasePadding, Size.BasePadding],
59
+ wrap: true,
60
+ style: { marginBottom: Size.BasePadding },
61
+ children: [
62
+ arr.map((e) => {
63
+ return /* @__PURE__ */ jsx(Col, { style: { minWidth: 335 }, children: /* @__PURE__ */ jsx(DiffCard, { titles: e.title, datas: e.value, showPercentInTitle: true }) }, e.title.join(","));
64
+ }),
65
+ /* @__PURE__ */ jsx(Col, { style: { minWidth: 335 }, children: /* @__PURE__ */ jsx(
66
+ DiffCard,
67
+ {
68
+ titles: ["Duplicate Packages"],
69
+ datas: [
70
+ {
71
+ size: {
72
+ baseline: baselineDup.length,
73
+ current: currentDup.length
74
+ },
75
+ count: {
76
+ baseline: baselineDup.length,
77
+ current: currentDup.length
78
+ },
79
+ percent: 0,
80
+ state: Client.RsdoctorClientDiffState.Equal
81
+ }
82
+ ],
83
+ formatter: (_v, target) => /* @__PURE__ */ jsx(
84
+ DuplicatePackageDrawer,
85
+ {
86
+ duplicatePackages: target === "baseline" ? baselineDup : currentDup,
87
+ moduleGraph: target === "baseline" ? baselineModuleGraph : currentModuleGraph,
88
+ cwd: target === "baseline" ? baselineCwd : currentCwd,
89
+ buttonProps: { size: "small" },
90
+ moduleCodeMap: target === "baseline" ? baseline.moduleCodeMap : current.moduleCodeMap
91
+ }
92
+ )
93
+ }
94
+ ) }),
95
+ /* @__PURE__ */ jsx(Col, { style: { minWidth: 335 }, children: /* @__PURE__ */ jsx(
96
+ DiffCard,
97
+ {
98
+ titles: ["Modules"],
99
+ datas: [
100
+ {
101
+ size: {
102
+ baseline: baselineMod.length,
103
+ current: currentMod.length
104
+ },
105
+ count: {
106
+ baseline: baselineMod.length,
107
+ current: currentMod.length
108
+ },
109
+ percent: 0,
110
+ state: Client.RsdoctorClientDiffState.Equal
111
+ }
112
+ ],
113
+ formatter: (v, t) => {
114
+ if (t === "baseline")
115
+ return v;
116
+ const diff = Graph.diffSize(baselineMod.length, currentMod.length);
117
+ return /* @__PURE__ */ jsxs(Space, { style: { fontSize: "inherit" }, children: [
118
+ /* @__PURE__ */ jsx(Typography.Text, { style: { fontSize: "inherit" }, children: v }),
119
+ /* @__PURE__ */ jsx(Percent, { ...diff })
120
+ ] });
121
+ }
122
+ }
123
+ ) }),
124
+ /* @__PURE__ */ jsx(Col, { style: { minWidth: 335 }, children: /* @__PURE__ */ jsx(
125
+ DiffCard,
126
+ {
127
+ titles: [
128
+ /* @__PURE__ */ jsxs(Space, { children: [
129
+ /* @__PURE__ */ jsx(Typography.Text, { style: { color: "inherit" }, children: "Packages" }),
130
+ /* @__PURE__ */ jsx(PackagesStatistic, { dataSource: packages })
131
+ ] }, "0")
132
+ ],
133
+ datas: [
134
+ {
135
+ size: {
136
+ baseline: packages.filter((e) => e.baseline).length,
137
+ current: packages.filter((e) => e.current).length
138
+ },
139
+ count: {
140
+ baseline: packages.filter((e) => e.baseline).length,
141
+ current: packages.filter((e) => e.current).length
142
+ },
143
+ percent: 0,
144
+ state: Client.RsdoctorClientDiffState.Equal
145
+ }
146
+ ],
147
+ formatter: (v, t) => t === "baseline" ? v : /* @__PURE__ */ jsx(Space, { children: v })
148
+ }
149
+ ) })
150
+ ]
151
+ }
152
+ );
153
+ };
154
+ export {
155
+ DiffCards
156
+ };
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ interface ViewChangesContentProps {
3
+ file: string;
4
+ data: {
5
+ baseline?: string | void;
6
+ current: string | void;
7
+ baselineTitle?: string;
8
+ currentTitle?: string;
9
+ group: string;
10
+ }[];
11
+ }
12
+ export declare const ViewChanges: React.FC<ViewChangesContentProps & {
13
+ text?: string;
14
+ }>;
15
+ export {};