@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,45 @@
1
+ /// <reference types="react" />
2
+ import { Client, Manifest, SDK } from '@rsdoctor/types';
3
+ import { UpdateType } from './constants';
4
+ import { InferServerAPIBody } from '../../Manifest';
5
+ export type BundleDiffServerAPIProviderComponentCommonProps<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends> = {
6
+ manifests?: Manifest.RsdoctorManifest[];
7
+ api: T;
8
+ children: (baseline: SDK.ServerAPI.InferResponseType<T>, current: SDK.ServerAPI.InferResponseType<T>) => JSX.Element;
9
+ } & InferServerAPIBody<T>;
10
+ export interface BundleDiffContainerProps {
11
+ manifests: Manifest.RsdoctorManifest[];
12
+ }
13
+ export interface BundleDiffComponentCommonProps {
14
+ baseline: Manifest.RsdoctorManifest;
15
+ current: Manifest.RsdoctorManifest;
16
+ onlyBaseline: boolean;
17
+ assetsDiffResult: Client.RsdoctorClientAssetsDiffResult;
18
+ }
19
+ export interface BundleDiffComponentCardProps {
20
+ baseline: SDK.ServerAPI.ResponseTypes[SDK.ServerAPI.API.GetBundleDiffSummary];
21
+ current: SDK.ServerAPI.ResponseTypes[SDK.ServerAPI.API.GetBundleDiffSummary];
22
+ onlyBaseline: boolean;
23
+ assetsDiffResult: Client.RsdoctorClientAssetsDiffResult;
24
+ }
25
+ export interface BundleDiffTableOverviewData {
26
+ total: Client.RsdoctorClientAssetsDiffItem;
27
+ initial?: Client.RsdoctorClientAssetsDiffItem;
28
+ }
29
+ export interface BundleDiffTableAssetsData {
30
+ alias: string;
31
+ baseline?: SDK.AssetData;
32
+ current?: SDK.AssetData;
33
+ }
34
+ export interface BundleDiffTableModulesData {
35
+ [key: string]: unknown;
36
+ path: string;
37
+ baseline?: SDK.ModuleData;
38
+ current?: SDK.ModuleData;
39
+ }
40
+ export interface BundleDiffTablePackagesData {
41
+ name: string;
42
+ updateType: UpdateType;
43
+ baseline?: SDK.PackageData[];
44
+ current?: SDK.PackageData[];
45
+ }
@@ -0,0 +1,2 @@
1
+ import { Client } from '@rsdoctor/types';
2
+ export declare const formatDiffSize: (bSize: number, cSize: number, state: Client.RsdoctorClientDiffState, propsStyle?: Record<string, string | number>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { formatSize } from "@rsdoctor/components/utils";
3
+ import { Client } from "@rsdoctor/types";
4
+ import { Typography } from "antd";
5
+ import { Color } from "../../../constants";
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,4 @@
1
+ /// <reference types="react" />
2
+ import { SDK } from '@rsdoctor/types';
3
+ import { BundleDiffServerAPIProviderComponentCommonProps } from '../DiffContainer/types';
4
+ export declare const DiffServerAPIProvider: <T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(props: BundleDiffServerAPIProviderComponentCommonProps<T>) => JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { Client } from "@rsdoctor/types";
3
+ import { Empty } from "antd";
4
+ import { ServerAPIProvider } from "../../Manifest";
5
+ import { useUrlQuery, fetchManifest } from "../../../utils";
6
+ const DiffServerAPIProvider = (props) => {
7
+ const { api, body, children, manifests } = props;
8
+ const query = useUrlQuery();
9
+ const [baselineFile, currentFile] = query[Client.RsdoctorClientUrlQuery.BundleDiffFiles]?.split(",") || [];
10
+ if (manifests?.length) {
11
+ return /* @__PURE__ */ jsx(Fragment, { children: children(manifests[0].data, manifests[1].data) });
12
+ }
13
+ return /* @__PURE__ */ jsx(
14
+ ServerAPIProvider,
15
+ {
16
+ api,
17
+ body,
18
+ manifestLoader: baselineFile ? () => fetchManifest(baselineFile) : void 0,
19
+ children: (baseline) => {
20
+ return baseline ? /* @__PURE__ */ jsx(
21
+ ServerAPIProvider,
22
+ {
23
+ api,
24
+ body,
25
+ manifestLoader: currentFile ? () => fetchManifest(currentFile) : void 0,
26
+ children: (current) => {
27
+ return current ? children(baseline, current) : /* @__PURE__ */ jsx(Empty, {});
28
+ }
29
+ }
30
+ ) : /* @__PURE__ */ jsx(Empty, {});
31
+ }
32
+ }
33
+ );
34
+ };
35
+ export {
36
+ DiffServerAPIProvider
37
+ };
@@ -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
+ };
@@ -0,0 +1 @@
1
+ export * from './DiffContainer';
@@ -0,0 +1 @@
1
+ export * from "./DiffContainer";
@@ -1,5 +1,6 @@
1
1
  import { Client } from '@rsdoctor/types';
2
2
  import React from 'react';
3
+ export { StatisticCard } from './statistic';
3
4
  export interface DiffCardProps extends Pick<DiffCardContentProps, 'formatter'> {
4
5
  titles: Array<string> | [string | React.ReactNode];
5
6
  datas: Array<DiffCardContentProps['data']>;
@@ -6,11 +6,16 @@ import { useState } from "react";
6
6
  import { formatSize } from "../../utils";
7
7
  import { Color } from "../../constants";
8
8
  import { StatisticCard } from "./statistic";
9
+ import { StatisticCard as StatisticCard2 } from "./statistic";
9
10
  const SizePercent = ({ baseline, current, ...rest }) => {
10
11
  const diff = Graph.diffSize(baseline, current);
11
12
  return /* @__PURE__ */ jsx(Percent, { ...rest, ...diff });
12
13
  };
13
- const Percent = ({ percent, state, fontSize = 14 }) => {
14
+ const Percent = ({
15
+ percent,
16
+ state,
17
+ fontSize = 14
18
+ }) => {
14
19
  const _percent = +percent.toFixed(2);
15
20
  if (_percent > 0) {
16
21
  const percentText = `${_percent}`;
@@ -31,7 +36,10 @@ const Percent = ({ percent, state, fontSize = 14 }) => {
31
36
  }
32
37
  return null;
33
38
  };
34
- const DiffCardContent = ({ data, formatter }) => {
39
+ const DiffCardContent = ({
40
+ data,
41
+ formatter
42
+ }) => {
35
43
  const { percent, state, size } = data;
36
44
  const { baseline, current } = size;
37
45
  const bSize = formatter ? formatter(baseline, "baseline") : formatSize(baseline);
@@ -60,7 +68,12 @@ const DiffCardContent = ({ data, formatter }) => {
60
68
  ] })
61
69
  ] }) });
62
70
  };
63
- const DiffCard = ({ titles, datas, formatter, showPercentInTitle }) => {
71
+ const DiffCard = ({
72
+ titles,
73
+ datas,
74
+ formatter,
75
+ showPercentInTitle
76
+ }) => {
64
77
  const [idx, setIdx] = useState(0);
65
78
  return /* @__PURE__ */ jsx(
66
79
  StatisticCard,
@@ -98,5 +111,6 @@ export {
98
111
  DiffCard,
99
112
  DiffCardContent,
100
113
  Percent,
101
- SizePercent
114
+ SizePercent,
115
+ StatisticCard2 as StatisticCard
102
116
  };
@@ -1,5 +1,6 @@
1
1
  import { CardProps as CProps } from 'antd';
2
2
  import React, { CSSProperties } from 'react';
3
+ export * from './diff';
3
4
  export interface CardProps extends CProps {
4
5
  collapsable?: boolean;
5
6
  dividerStyle?: CSSProperties;
@@ -1,8 +1,19 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { ColumnHeightOutlined, VerticalAlignMiddleOutlined } from "@ant-design/icons";
2
+ import {
3
+ ColumnHeightOutlined,
4
+ VerticalAlignMiddleOutlined
5
+ } from "@ant-design/icons";
3
6
  import { Card as C, Space, Button, Divider } from "antd";
4
7
  import { useState } from "react";
5
- const Card = ({ collapsable = false, children, title, dividerStyle, defaultCollapsed = false, ...rest }) => {
8
+ export * from "./diff";
9
+ const Card = ({
10
+ collapsable = false,
11
+ children,
12
+ title,
13
+ dividerStyle,
14
+ defaultCollapsed = false,
15
+ ...rest
16
+ }) => {
6
17
  const [collapsed, setCollapsed] = useState(defaultCollapsed);
7
18
  if (title && collapsable) {
8
19
  return /* @__PURE__ */ jsx(
@@ -20,7 +31,15 @@ const Card = ({ collapsable = false, children, title, dividerStyle, defaultColla
20
31
  ),
21
32
  title
22
33
  ] }),
23
- children: collapsed ? /* @__PURE__ */ jsx(Divider, { orientation: "center", style: dividerStyle, plain: true, children: /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(ColumnHeightOutlined, {}), type: "text", onClick: () => setCollapsed(!collapsed), children: "show more" }) }) : children
34
+ children: collapsed ? /* @__PURE__ */ jsx(Divider, { orientation: "center", style: dividerStyle, plain: true, children: /* @__PURE__ */ jsx(
35
+ Button,
36
+ {
37
+ icon: /* @__PURE__ */ jsx(ColumnHeightOutlined, {}),
38
+ type: "text",
39
+ onClick: () => setCollapsed(!collapsed),
40
+ children: "show more"
41
+ }
42
+ ) }) : children
24
43
  }
25
44
  );
26
45
  }
@@ -5,4 +5,8 @@ export * from './Card';
5
5
  export * from './CodeViewer';
6
6
  export * from './Layout';
7
7
  export * from './Overall';
8
+ export * from './Manifest';
9
+ export * from './Form/keyword';
10
+ export * from './TextDrawer';
11
+ export * from './BundleDiff';
8
12
  export { TimelineCom } from './Charts/TimelineCharts';
@@ -5,6 +5,10 @@ export * from "./Card";
5
5
  export * from "./CodeViewer";
6
6
  export * from "./Layout";
7
7
  export * from "./Overall";
8
+ export * from "./Manifest";
9
+ export * from "./Form/keyword";
10
+ export * from "./TextDrawer";
11
+ export * from "./BundleDiff";
8
12
  import { TimelineCom } from "./Charts/TimelineCharts";
9
13
  export {
10
14
  TimelineCom
@@ -8,7 +8,7 @@ export declare abstract class BaseDataLoader implements Manifest.ManifestDataLoa
8
8
  protected shardingDataMap: Map<keyof Manifest.RsdoctorManifestData, Promise<any>>;
9
9
  constructor(manifest: Manifest.RsdoctorManifestWithShardingFiles);
10
10
  protected get<T extends keyof Manifest.RsdoctorManifestWithShardingFiles>(key: T): void | Manifest.RsdoctorManifestWithShardingFiles[T];
11
- protected getData<T extends keyof Manifest.RsdoctorManifestData>(key: T, scope?: 'data'): void | Manifest.RsdoctorManifestWithShardingFiles['data'][T];
11
+ protected getData<T extends keyof Manifest.RsdoctorManifestData>(key: T, scope?: 'data' | 'cloudData'): void | Manifest.RsdoctorManifestWithShardingFiles['data'][T];
12
12
  protected getKeys(key: string): string[];
13
13
  protected joinKeys(keys: string[]): string;
14
14
  dispose(): void;
@@ -9,13 +9,19 @@ class RemoteDataLoader extends BaseDataLoader {
9
9
  async loadData(key) {
10
10
  return this.limit(key, async () => {
11
11
  const [scope, ...rest] = this.getKeys(key);
12
- const data = this.getData(scope);
12
+ const data = this.getData(
13
+ scope,
14
+ "cloudData"
15
+ );
13
16
  if (!data)
14
17
  return;
15
18
  let res = data;
16
19
  if (ManifestShared.isShardingData(res)) {
17
20
  if (!this.shardingDataMap.has(scope)) {
18
- const task = ManifestShared.fetchShardingData(res, fetchShardingFile).catch((err) => {
21
+ const task = ManifestShared.fetchShardingData(
22
+ res,
23
+ fetchShardingFile
24
+ ).catch((err) => {
19
25
  this.log(`loadData error: `, res, key);
20
26
  throw err;
21
27
  });
@@ -2,9 +2,11 @@ import { Manifest, SDK } from '@rsdoctor/types';
2
2
  export declare function fetchShardingFile(url: string): Promise<string>;
3
3
  export declare function loadManifestByUrl(url: string): Promise<{
4
4
  data: Manifest.RsdoctorManifestData;
5
+ cloudData?: Record<keyof Manifest.RsdoctorManifestData, string | string[]> | undefined;
5
6
  __LOCAL__SERVER__?: boolean | undefined;
6
7
  __SOCKET__URL__?: string | undefined;
7
8
  client: Manifest.RsdoctorManifestClient;
9
+ cloudManifestUrl?: string | undefined;
8
10
  name?: string | undefined;
9
11
  series?: Manifest.RsdoctorManifestSeriesData[] | undefined;
10
12
  }>;
@@ -12,9 +14,11 @@ export declare function fetchJSONByUrl(url: string): Promise<Manifest.RsdoctorMa
12
14
  export declare function fetchJSONByUrls(urls: string[]): Promise<Manifest.RsdoctorManifestWithShardingFiles[]>;
13
15
  export declare function parseManifest(json: Manifest.RsdoctorManifestWithShardingFiles): Promise<{
14
16
  data: Manifest.RsdoctorManifestData;
17
+ cloudData?: Record<keyof Manifest.RsdoctorManifestData, string | string[]> | undefined;
15
18
  __LOCAL__SERVER__?: boolean | undefined;
16
19
  __SOCKET__URL__?: string | undefined;
17
20
  client: Manifest.RsdoctorManifestClient;
21
+ cloudManifestUrl?: string | undefined;
18
22
  name?: string | undefined;
19
23
  series?: Manifest.RsdoctorManifestSeriesData[] | undefined;
20
24
  }>;
@@ -31,14 +31,27 @@ function fetchJSONByUrls(urls) {
31
31
  }
32
32
  async function parseManifest(json) {
33
33
  let transformedData;
34
- if (json.data) {
35
- try {
36
- transformedData = await ManifestMethod.fetchShardingFiles(json.data, fetchShardingFile);
37
- } catch (error) {
38
- console.log("cloudData load error: ", error);
34
+ try {
35
+ if (json.cloudData) {
36
+ try {
37
+ transformedData = await ManifestMethod.fetchShardingFiles(
38
+ json.cloudData,
39
+ fetchShardingFile
40
+ );
41
+ } catch (error) {
42
+ console.log("cloudData load error: ", error);
43
+ }
44
+ } else {
45
+ transformedData = await ManifestMethod.fetchShardingFiles(
46
+ json.data,
47
+ fetchShardingFile
48
+ );
39
49
  }
40
- } else {
41
- throw new Error("fallback to load json.data");
50
+ } catch (error) {
51
+ transformedData = await ManifestMethod.fetchShardingFiles(
52
+ json.data,
53
+ fetchShardingFile
54
+ );
42
55
  }
43
56
  return {
44
57
  ...json,
@@ -98,7 +111,11 @@ if (process.env.NODE_ENV === "development") {
98
111
  async function postServerAPI(...args) {
99
112
  const [api, body] = args;
100
113
  const timeout = process.env.NODE_ENV === "development" ? 1e4 : 6e4;
101
- const { data } = await axios.post(`${api}?_t=${random()}`, body, { timeout });
114
+ const { data } = await axios.post(
115
+ `${api}?_t=${random()}`,
116
+ body,
117
+ { timeout }
118
+ );
102
119
  return data;
103
120
  }
104
121
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/components",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "main": "./dist/index.js",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -51,7 +51,7 @@
51
51
  "@types/react": "^18",
52
52
  "@types/url-parse": "1.4.8",
53
53
  "ansi-to-react": "6.1.6",
54
- "antd": "5.8.3",
54
+ "antd": "5.15.3",
55
55
  "axios": "^1.6.1",
56
56
  "dayjs": "1.11.6",
57
57
  "echarts": "^5.4.3",
@@ -61,7 +61,7 @@
61
61
  "monaco-editor": "0.34.1",
62
62
  "rc-dialog": "9.1.0",
63
63
  "rc-tree": "5.7.2",
64
- "react": "^18",
64
+ "react": "18.2.0",
65
65
  "react-hyper-tree": "0.3.12",
66
66
  "react-i18next": "12.0.0",
67
67
  "react-json-view": "1.21.3",
@@ -71,9 +71,9 @@
71
71
  "terser": "^5.26.0",
72
72
  "typescript": "^5.2.2",
73
73
  "url-parse": "1.5.10",
74
- "@rsdoctor/graph": "0.1.6",
75
- "@rsdoctor/utils": "0.1.6",
76
- "@rsdoctor/types": "0.1.6"
74
+ "@rsdoctor/graph": "0.1.8",
75
+ "@rsdoctor/utils": "0.1.8",
76
+ "@rsdoctor/types": "0.1.8"
77
77
  },
78
78
  "publishConfig": {
79
79
  "access": "public",