@rsdoctor/components 0.4.2 → 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.
Files changed (32) hide show
  1. package/dist/components/Alerts/common.js +16 -5
  2. package/dist/pages/Resources/BundleDiff/DiffContainer/assets.d.ts +7 -0
  3. package/dist/pages/Resources/BundleDiff/DiffContainer/assets.js +505 -0
  4. package/dist/pages/Resources/BundleDiff/DiffContainer/cards.d.ts +3 -0
  5. package/dist/pages/Resources/BundleDiff/DiffContainer/cards.js +156 -0
  6. package/dist/pages/Resources/BundleDiff/DiffContainer/changes.d.ts +15 -0
  7. package/dist/pages/Resources/BundleDiff/DiffContainer/changes.js +69 -0
  8. package/dist/pages/Resources/BundleDiff/DiffContainer/constants.d.ts +11 -0
  9. package/dist/pages/Resources/BundleDiff/DiffContainer/constants.js +17 -0
  10. package/dist/pages/Resources/BundleDiff/DiffContainer/index.d.ts +3 -0
  11. package/dist/pages/Resources/BundleDiff/DiffContainer/index.js +180 -0
  12. package/dist/pages/Resources/BundleDiff/DiffContainer/modules.d.ts +8 -0
  13. package/dist/pages/Resources/BundleDiff/DiffContainer/modules.js +303 -0
  14. package/dist/pages/Resources/BundleDiff/DiffContainer/overview.d.ts +5 -0
  15. package/dist/pages/Resources/BundleDiff/DiffContainer/overview.js +178 -0
  16. package/dist/pages/Resources/BundleDiff/DiffContainer/packages.d.ts +19 -0
  17. package/dist/pages/Resources/BundleDiff/DiffContainer/packages.js +331 -0
  18. package/dist/pages/Resources/BundleDiff/DiffContainer/row.d.ts +9 -0
  19. package/dist/pages/Resources/BundleDiff/DiffContainer/row.js +377 -0
  20. package/dist/pages/Resources/BundleDiff/DiffContainer/types.d.ts +44 -0
  21. package/dist/pages/Resources/BundleDiff/DiffContainer/types.js +0 -0
  22. package/dist/pages/Resources/BundleDiff/DiffContainer/utils.d.ts +2 -0
  23. package/dist/pages/Resources/BundleDiff/DiffContainer/utils.js +24 -0
  24. package/dist/pages/Resources/BundleDiff/DiffServerAPIProvider/index.d.ts +3 -0
  25. package/dist/pages/Resources/BundleDiff/DiffServerAPIProvider/index.js +36 -0
  26. package/dist/pages/Resources/BundleDiff/constants.d.ts +11 -0
  27. package/dist/pages/Resources/BundleDiff/constants.js +19 -0
  28. package/dist/pages/Resources/BundleDiff/index.d.ts +3 -0
  29. package/dist/pages/Resources/BundleDiff/index.js +9 -0
  30. package/dist/pages/index.d.ts +1 -0
  31. package/dist/pages/index.js +2 -0
  32. package/package.json +5 -5
@@ -0,0 +1,156 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Col, Row, Space, Typography } from "antd";
3
+ import { Client } from "@rsdoctor/types";
4
+ import { Size } from "../../../../constants";
5
+ import { DiffCard, Percent } from "../../../../components/Card/diff";
6
+ import {
7
+ useDuplicatePackagesByErrors,
8
+ useModuleGraph,
9
+ useUniqModules
10
+ } from "../../../../utils";
11
+ import { DuplicatePackageDrawer } from "../../../../components/TextDrawer";
12
+ import { getPackagesTableDataSource, PackagesStatistic } from "./packages";
13
+ import { Graph } from "@rsdoctor/utils/common";
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 {};
@@ -0,0 +1,69 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import React, { useState } from "react";
3
+ import { Col, Row, Typography, Segmented } from "antd";
4
+ import { DiffOutlined } from "@ant-design/icons";
5
+ import { DiffViewer } from "../../../../components/CodeViewer";
6
+ import { Size } from "../../../../constants";
7
+ import { TextDrawer } from "../../../../components/TextDrawer";
8
+ const ViewChangesContent = ({
9
+ file,
10
+ data
11
+ }) => {
12
+ const [group, setGroup] = useState(data[0].group);
13
+ const match = data.find((e) => e.group === group);
14
+ return /* @__PURE__ */ jsxs(
15
+ Row,
16
+ {
17
+ wrap: true,
18
+ gutter: [Size.BasePadding, Size.BasePadding],
19
+ style: { height: "100%" },
20
+ children: [
21
+ data.length > 1 ? /* @__PURE__ */ jsx(Col, { span: 24, children: /* @__PURE__ */ jsx(
22
+ Segmented,
23
+ {
24
+ style: { marginTop: Size.BasePadding },
25
+ value: group,
26
+ options: data.map((e) => e.group),
27
+ onChange: (e) => setGroup(e)
28
+ }
29
+ ) }) : null,
30
+ match ? /* @__PURE__ */ jsxs(React.Fragment, { children: [
31
+ /* @__PURE__ */ jsx(Col, { span: 12, children: /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: match.baselineTitle || "Baseline" }) }),
32
+ /* @__PURE__ */ jsx(Col, { span: 12, children: /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: match.currentTitle || "Current" }) }),
33
+ /* @__PURE__ */ jsx(Col, { span: 24, children: /* @__PURE__ */ jsx(
34
+ DiffViewer,
35
+ {
36
+ filepath: file,
37
+ before: match.baseline || "",
38
+ after: match.current || "",
39
+ editorProps: {
40
+ // eslint-disable-next-line financial/no-float-calculation
41
+ height: Math.floor(window.innerHeight / 1.25)
42
+ }
43
+ }
44
+ ) })
45
+ ] }, group) : null
46
+ ]
47
+ }
48
+ );
49
+ };
50
+ const ViewChanges = ({ text = "View Changes", ...props }) => {
51
+ return /* @__PURE__ */ jsx(
52
+ TextDrawer,
53
+ {
54
+ text,
55
+ buttonProps: {
56
+ size: "small",
57
+ icon: /* @__PURE__ */ jsx(DiffOutlined, {})
58
+ },
59
+ drawerProps: {
60
+ destroyOnClose: true,
61
+ title: `Content diff for "${props.file}"`
62
+ },
63
+ children: /* @__PURE__ */ jsx(ViewChangesContent, { ...props })
64
+ }
65
+ );
66
+ };
67
+ export {
68
+ ViewChanges
69
+ };
@@ -0,0 +1,11 @@
1
+ export declare enum UpdateType {
2
+ New = "New",
3
+ Changed = "Changed",
4
+ Deleted = "Deleted",
5
+ NotChanged = "Not Changed"
6
+ }
7
+ export declare enum SortType {
8
+ Name = "Sorted by Name",
9
+ Size = "Sorted by Size",
10
+ Delta = "Sorted by Delta"
11
+ }
@@ -0,0 +1,17 @@
1
+ var UpdateType = /* @__PURE__ */ ((UpdateType2) => {
2
+ UpdateType2["New"] = "New";
3
+ UpdateType2["Changed"] = "Changed";
4
+ UpdateType2["Deleted"] = "Deleted";
5
+ UpdateType2["NotChanged"] = "Not Changed";
6
+ return UpdateType2;
7
+ })(UpdateType || {});
8
+ var SortType = /* @__PURE__ */ ((SortType2) => {
9
+ SortType2["Name"] = "Sorted by Name";
10
+ SortType2["Size"] = "Sorted by Size";
11
+ SortType2["Delta"] = "Sorted by Delta";
12
+ return SortType2;
13
+ })(SortType || {});
14
+ export {
15
+ SortType,
16
+ UpdateType
17
+ };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { BundleDiffContainerProps } from './types';
3
+ export declare const DiffContainer: React.FC<BundleDiffContainerProps>;
@@ -0,0 +1,180 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import {
3
+ Button,
4
+ Card,
5
+ Divider,
6
+ FloatButton,
7
+ Popconfirm,
8
+ Space,
9
+ Tabs,
10
+ Tooltip,
11
+ Typography
12
+ } from "antd";
13
+ import { useEffect } from "react";
14
+ import { InfoCircleOutlined, LogoutOutlined } from "@ant-design/icons";
15
+ import { SDK } from "@rsdoctor/types";
16
+ import { Size } from "../../../../constants";
17
+ import { DiffCards } from "./cards";
18
+ import { Overview } from "./overview";
19
+ import { Assets } from "./assets";
20
+ import { Modules } from "./modules";
21
+ import { Packages } from "./packages";
22
+ import { DiffServerAPIProvider } from "../DiffServerAPIProvider";
23
+ import { Graph } from "@rsdoctor/utils/common";
24
+ const DiffContainer = ({
25
+ manifests
26
+ }) => {
27
+ useEffect(() => {
28
+ console.log("BundleDiff Manifests: ", manifests);
29
+ }, [manifests]);
30
+ return /* @__PURE__ */ jsx(
31
+ DiffServerAPIProvider,
32
+ {
33
+ api: SDK.ServerAPI.API.GetBundleDiffSummary,
34
+ manifests,
35
+ children: (baselineSummary, currentSummary) => {
36
+ const onlyBaseline = baselineSummary.chunkGraph === currentSummary.chunkGraph;
37
+ const baselineChunkGraph = baselineSummary.chunkGraph;
38
+ const currentChunkGraph = onlyBaseline ? baselineChunkGraph : currentSummary.chunkGraph;
39
+ const assetsDiffResult = Graph.getAssetsDiffResult(
40
+ baselineChunkGraph,
41
+ currentChunkGraph
42
+ );
43
+ return /* @__PURE__ */ jsxs("div", { children: [
44
+ /* @__PURE__ */ jsxs(FloatButton.Group, { children: [
45
+ /* @__PURE__ */ jsx(
46
+ Tooltip,
47
+ {
48
+ placement: "leftBottom",
49
+ title: /* @__PURE__ */ jsx(Space, { direction: "vertical", children: [
50
+ { title: "Baseline", data: baselineSummary },
51
+ { title: "Current", data: currentSummary }
52
+ ].map(({ title, data }) => {
53
+ return /* @__PURE__ */ jsx(Card, { size: "small", children: /* @__PURE__ */ jsxs(Space, { direction: "vertical", children: [
54
+ /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: title }),
55
+ /* @__PURE__ */ jsxs(Space, { style: { fontSize: 10 }, children: [
56
+ /* @__PURE__ */ jsx(
57
+ Typography.Text,
58
+ {
59
+ style: {
60
+ fontSize: "inherit",
61
+ width: 30,
62
+ display: "inline-block"
63
+ },
64
+ children: "Hash"
65
+ }
66
+ ),
67
+ /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
68
+ /* @__PURE__ */ jsx(
69
+ Typography.Text,
70
+ {
71
+ type: "secondary",
72
+ style: { fontSize: "inherit" },
73
+ children: data.hash || "-"
74
+ }
75
+ )
76
+ ] }),
77
+ data.cloudManifestUrl ? /* @__PURE__ */ jsx(
78
+ Button,
79
+ {
80
+ type: "link",
81
+ size: "small",
82
+ style: { padding: 0, fontSize: 10 },
83
+ onClick: () => window.open(data.cloudManifestUrl),
84
+ children: "Open File"
85
+ }
86
+ ) : null
87
+ ] }) }, title);
88
+ }) }),
89
+ children: /* @__PURE__ */ jsx(FloatButton, { icon: /* @__PURE__ */ jsx(InfoCircleOutlined, {}) })
90
+ }
91
+ ),
92
+ /* @__PURE__ */ jsx(
93
+ Popconfirm,
94
+ {
95
+ title: /* @__PURE__ */ jsxs(Typography.Text, { children: [
96
+ "Are you sure to",
97
+ /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: " re-upload " }),
98
+ "json files for bundle diff?"
99
+ ] }),
100
+ onConfirm: () => {
101
+ },
102
+ okText: "Yes",
103
+ cancelText: "Cancel",
104
+ placement: "topLeft",
105
+ trigger: "hover",
106
+ children: /* @__PURE__ */ jsx(FloatButton, { icon: /* @__PURE__ */ jsx(LogoutOutlined, {}) })
107
+ }
108
+ ),
109
+ /* @__PURE__ */ jsx(FloatButton.BackTop, {})
110
+ ] }),
111
+ /* @__PURE__ */ jsx(
112
+ DiffCards,
113
+ {
114
+ baseline: baselineSummary,
115
+ current: currentSummary,
116
+ onlyBaseline,
117
+ assetsDiffResult
118
+ }
119
+ ),
120
+ /* @__PURE__ */ jsx(
121
+ Tabs,
122
+ {
123
+ defaultActiveKey: "Overview",
124
+ tabBarStyle: { marginBottom: Size.BasePadding / 3 },
125
+ items: [
126
+ {
127
+ label: "Overview",
128
+ key: "Overview",
129
+ children: /* @__PURE__ */ jsx(Overview, { assetsDiffResult })
130
+ },
131
+ {
132
+ label: "Assets",
133
+ key: "Assets",
134
+ children: /* @__PURE__ */ jsx(
135
+ Assets,
136
+ {
137
+ outputFilename: baselineSummary.outputFilename,
138
+ baseline: baselineSummary,
139
+ current: currentSummary
140
+ }
141
+ )
142
+ },
143
+ {
144
+ label: "Modules",
145
+ key: "Modules",
146
+ children: /* @__PURE__ */ jsx(
147
+ Modules,
148
+ {
149
+ baseline: baselineSummary,
150
+ current: currentSummary,
151
+ onlyBaseline,
152
+ assetsDiffResult
153
+ }
154
+ )
155
+ },
156
+ {
157
+ label: "Packages",
158
+ key: "Packages",
159
+ children: /* @__PURE__ */ jsx(
160
+ Packages,
161
+ {
162
+ baseline: baselineSummary.packageGraph,
163
+ current: currentSummary.packageGraph
164
+ }
165
+ )
166
+ }
167
+ ].map((el) => ({
168
+ ...el,
169
+ label: /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: el.label })
170
+ }))
171
+ }
172
+ )
173
+ ] });
174
+ }
175
+ }
176
+ );
177
+ };
178
+ export {
179
+ DiffContainer
180
+ };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { BundleDiffComponentCardProps, BundleDiffTableModulesData } from './types';
3
+ import { UpdateType } from './constants';
4
+ export declare function getUpdateType(e: BundleDiffTableModulesData): UpdateType;
5
+ export declare const FileUpdateTypeTag: React.FC<{
6
+ type: UpdateType;
7
+ }>;
8
+ export declare const Modules: React.FC<BundleDiffComponentCardProps>;