@rsdoctor/components 0.0.0-next-20240620044732
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/LICENSE +21 -0
- package/README.md +22 -0
- package/dist/assets/connection-point.3b3c78ca.svg +1 -0
- package/dist/assets/webpack.98604d64.svg +1 -0
- package/dist/components/Alert/change.d.ts +8 -0
- package/dist/components/Alert/change.js +93 -0
- package/dist/components/Alert/file-relation.d.ts +3 -0
- package/dist/components/Alert/file-relation.js +9 -0
- package/dist/components/Alert/index.css +32 -0
- package/dist/components/Alert/index.d.ts +4 -0
- package/dist/components/Alert/index.js +37 -0
- package/dist/components/Alert/link.d.ts +3 -0
- package/dist/components/Alert/link.js +27 -0
- package/dist/components/Alert/package-relation.d.ts +17 -0
- package/dist/components/Alert/package-relation.js +281 -0
- package/dist/components/Alert/types.d.ts +31 -0
- package/dist/components/Alert/types.js +0 -0
- package/dist/components/Alert/view.d.ts +4 -0
- package/dist/components/Alert/view.js +58 -0
- package/dist/components/Alerts/bundle.d.ts +11 -0
- package/dist/components/Alerts/bundle.js +61 -0
- package/dist/components/Alerts/common.d.ts +15 -0
- package/dist/components/Alerts/common.js +112 -0
- package/dist/components/Alerts/compile.d.ts +10 -0
- package/dist/components/Alerts/compile.js +46 -0
- package/dist/components/Alerts/index.d.ts +3 -0
- package/dist/components/Alerts/index.js +3 -0
- package/dist/components/Alerts/overlay.d.ts +26 -0
- package/dist/components/Alerts/overlay.js +154 -0
- package/dist/components/Badge/index.d.ts +21 -0
- package/dist/components/Badge/index.js +87 -0
- package/dist/components/BundleDiff/DiffContainer/assets.d.ts +7 -0
- package/dist/components/BundleDiff/DiffContainer/assets.js +507 -0
- package/dist/components/BundleDiff/DiffContainer/cards.d.ts +3 -0
- package/dist/components/BundleDiff/DiffContainer/cards.js +156 -0
- package/dist/components/BundleDiff/DiffContainer/changes.d.ts +15 -0
- package/dist/components/BundleDiff/DiffContainer/changes.js +69 -0
- package/dist/components/BundleDiff/DiffContainer/constants.d.ts +11 -0
- package/dist/components/BundleDiff/DiffContainer/constants.js +17 -0
- package/dist/components/BundleDiff/DiffContainer/diff.d.ts +23 -0
- package/dist/components/BundleDiff/DiffContainer/diff.js +114 -0
- package/dist/components/BundleDiff/DiffContainer/index.d.ts +3 -0
- package/dist/components/BundleDiff/DiffContainer/index.js +180 -0
- package/dist/components/BundleDiff/DiffContainer/modules.d.ts +8 -0
- package/dist/components/BundleDiff/DiffContainer/modules.js +302 -0
- package/dist/components/BundleDiff/DiffContainer/overview.d.ts +5 -0
- package/dist/components/BundleDiff/DiffContainer/overview.js +178 -0
- package/dist/components/BundleDiff/DiffContainer/packages.d.ts +19 -0
- package/dist/components/BundleDiff/DiffContainer/packages.js +330 -0
- package/dist/components/BundleDiff/DiffContainer/row.d.ts +9 -0
- package/dist/components/BundleDiff/DiffContainer/row.js +369 -0
- package/dist/components/BundleDiff/DiffContainer/types.d.ts +45 -0
- package/dist/components/BundleDiff/DiffContainer/types.js +0 -0
- package/dist/components/BundleDiff/DiffContainer/utils.d.ts +2 -0
- package/dist/components/BundleDiff/DiffContainer/utils.js +24 -0
- package/dist/components/BundleDiff/DiffServerAPIProvider/index.d.ts +4 -0
- package/dist/components/BundleDiff/DiffServerAPIProvider/index.js +37 -0
- package/dist/components/BundleDiff/constants.d.ts +11 -0
- package/dist/components/BundleDiff/constants.js +19 -0
- package/dist/components/BundleDiff/index.d.ts +1 -0
- package/dist/components/BundleDiff/index.js +1 -0
- package/dist/components/Card/diff.d.ts +24 -0
- package/dist/components/Card/diff.js +116 -0
- package/dist/components/Card/index.d.ts +9 -0
- package/dist/components/Card/index.js +50 -0
- package/dist/components/Card/size.d.ts +21 -0
- package/dist/components/Card/size.js +79 -0
- package/dist/components/Card/statistic.css +17 -0
- package/dist/components/Card/statistic.d.ts +12 -0
- package/dist/components/Card/statistic.js +19 -0
- package/dist/components/Charts/TimelineCharts/index.d.ts +8 -0
- package/dist/components/Charts/TimelineCharts/index.js +212 -0
- package/dist/components/Charts/bootstrap.d.ts +5 -0
- package/dist/components/Charts/bootstrap.js +44 -0
- package/dist/components/Charts/common.d.ts +13 -0
- package/dist/components/Charts/common.js +56 -0
- package/dist/components/Charts/constants.d.ts +2 -0
- package/dist/components/Charts/constants.js +46 -0
- package/dist/components/Charts/done.d.ts +5 -0
- package/dist/components/Charts/done.js +45 -0
- package/dist/components/Charts/index.d.ts +10 -0
- package/dist/components/Charts/index.js +37 -0
- package/dist/components/Charts/loader.css +31 -0
- package/dist/components/Charts/loader.d.ts +4 -0
- package/dist/components/Charts/loader.js +88 -0
- package/dist/components/Charts/minify.d.ts +5 -0
- package/dist/components/Charts/minify.js +37 -0
- package/dist/components/Charts/tooltips.css +62 -0
- package/dist/components/Charts/types.d.ts +61 -0
- package/dist/components/Charts/types.js +11 -0
- package/dist/components/Charts/utils.d.ts +13 -0
- package/dist/components/Charts/utils.js +206 -0
- package/dist/components/CodeViewer/config.d.ts +2 -0
- package/dist/components/CodeViewer/config.js +18 -0
- package/dist/components/CodeViewer/diff.d.ts +11 -0
- package/dist/components/CodeViewer/diff.js +35 -0
- package/dist/components/CodeViewer/hightlight.d.ts +10 -0
- package/dist/components/CodeViewer/hightlight.js +76 -0
- package/dist/components/CodeViewer/index.d.ts +4 -0
- package/dist/components/CodeViewer/index.js +4 -0
- package/dist/components/CodeViewer/viewer.d.ts +13 -0
- package/dist/components/CodeViewer/viewer.js +60 -0
- package/dist/components/Configuration/builder.d.ts +13 -0
- package/dist/components/Configuration/builder.js +67 -0
- package/dist/components/Configuration/index.d.ts +1 -0
- package/dist/components/Configuration/index.js +1 -0
- package/dist/components/FileTree/index.css +58 -0
- package/dist/components/FileTree/index.d.ts +4 -0
- package/dist/components/FileTree/index.js +42 -0
- package/dist/components/Form/keyword.d.ts +14 -0
- package/dist/components/Form/keyword.js +60 -0
- package/dist/components/Keyword/index.d.ts +6 -0
- package/dist/components/Keyword/index.js +36 -0
- package/dist/components/Layout/builder-select.d.ts +2 -0
- package/dist/components/Layout/builder-select.js +50 -0
- package/dist/components/Layout/constants.d.ts +1 -0
- package/dist/components/Layout/constants.js +4 -0
- package/dist/components/Layout/header.css +12 -0
- package/dist/components/Layout/header.d.ts +3 -0
- package/dist/components/Layout/header.js +86 -0
- package/dist/components/Layout/index.d.ts +5 -0
- package/dist/components/Layout/index.js +34 -0
- package/dist/components/Layout/menus.d.ts +8 -0
- package/dist/components/Layout/menus.js +167 -0
- package/dist/components/Layout/progress.d.ts +8 -0
- package/dist/components/Layout/progress.js +44 -0
- package/dist/components/Loader/Analysis/files.d.ts +8 -0
- package/dist/components/Loader/Analysis/files.js +193 -0
- package/dist/components/Loader/Analysis/index.d.ts +11 -0
- package/dist/components/Loader/Analysis/index.js +23 -0
- package/dist/components/Loader/executions.d.ts +9 -0
- package/dist/components/Loader/executions.js +199 -0
- package/dist/components/Manifest/api.d.ts +34 -0
- package/dist/components/Manifest/api.js +127 -0
- package/dist/components/Manifest/data.d.ts +8 -0
- package/dist/components/Manifest/data.js +65 -0
- package/dist/components/Manifest/index.d.ts +2 -0
- package/dist/components/Manifest/index.js +2 -0
- package/dist/components/Opener/code.d.ts +20 -0
- package/dist/components/Opener/code.js +78 -0
- package/dist/components/Opener/index.d.ts +2 -0
- package/dist/components/Opener/index.js +2 -0
- package/dist/components/Opener/vscode.d.ts +11 -0
- package/dist/components/Opener/vscode.js +42 -0
- package/dist/components/Overall/NumberButton.d.ts +8 -0
- package/dist/components/Overall/NumberButton.js +29 -0
- package/dist/components/Overall/NumberButton.module.js +5 -0
- package/dist/components/Overall/NumberButton_module.css +70 -0
- package/dist/components/Overall/bundle.d.ts +6 -0
- package/dist/components/Overall/bundle.js +167 -0
- package/dist/components/Overall/bundle.module.css +0 -0
- package/dist/components/Overall/card.module.js +5 -0
- package/dist/components/Overall/card_module.css +6 -0
- package/dist/components/Overall/compile.d.ts +5 -0
- package/dist/components/Overall/compile.js +67 -0
- package/dist/components/Overall/compile.module.js +5 -0
- package/dist/components/Overall/compile_module.css +4 -0
- package/dist/components/Overall/index.d.ts +3 -0
- package/dist/components/Overall/index.js +3 -0
- package/dist/components/Overall/list.module.js +5 -0
- package/dist/components/Overall/list_module.css +7 -0
- package/dist/components/Overall/project.d.ts +8 -0
- package/dist/components/Overall/project.js +73 -0
- package/dist/components/Plugins/webpack.d.ts +18 -0
- package/dist/components/Plugins/webpack.js +76 -0
- package/dist/components/Resolver/analysis.d.ts +15 -0
- package/dist/components/Resolver/analysis.js +144 -0
- package/dist/components/Select/index.d.ts +15 -0
- package/dist/components/Select/index.js +68 -0
- package/dist/components/Status/failed.d.ts +9 -0
- package/dist/components/Status/failed.js +33 -0
- package/dist/components/Status/index.d.ts +1 -0
- package/dist/components/Status/index.js +1 -0
- package/dist/components/TextDrawer/duplicate.d.ts +17 -0
- package/dist/components/TextDrawer/duplicate.js +69 -0
- package/dist/components/TextDrawer/index.d.ts +11 -0
- package/dist/components/TextDrawer/index.js +36 -0
- package/dist/components/Title/index.d.ts +15 -0
- package/dist/components/Title/index.js +10 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/index.js +15 -0
- package/dist/components/worker/ecmaversion/client.d.ts +10 -0
- package/dist/components/worker/ecmaversion/client.js +60 -0
- package/dist/components/worker/ecmaversion/worker.d.ts +1 -0
- package/dist/components/worker/ecmaversion/worker.js +13 -0
- package/dist/components/worker/jsequal/client.d.ts +11 -0
- package/dist/components/worker/jsequal/client.js +38 -0
- package/dist/components/worker/jsequal/worker.d.ts +1 -0
- package/dist/components/worker/jsequal/worker.js +23 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +25 -0
- package/dist/constants.d.ts +50 -0
- package/dist/constants.js +75 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -0
- package/dist/pages/BundleSize/components/asset.d.ts +26 -0
- package/dist/pages/BundleSize/components/asset.js +545 -0
- package/dist/pages/BundleSize/components/cards.d.ts +7 -0
- package/dist/pages/BundleSize/components/cards.js +143 -0
- package/dist/pages/BundleSize/components/editor.d.ts +5 -0
- package/dist/pages/BundleSize/components/editor.js +38 -0
- package/dist/pages/BundleSize/components/index.css +20 -0
- package/dist/pages/BundleSize/components/index.d.ts +16 -0
- package/dist/pages/BundleSize/components/index.js +366 -0
- package/dist/pages/BundleSize/config.d.ts +7 -0
- package/dist/pages/BundleSize/config.js +9 -0
- package/dist/pages/BundleSize/constants.d.ts +5 -0
- package/dist/pages/BundleSize/constants.js +9 -0
- package/dist/pages/BundleSize/index.d.ts +3 -0
- package/dist/pages/BundleSize/index.js +11 -0
- package/dist/pages/ModuleAnalyze/chunks.d.ts +6 -0
- package/dist/pages/ModuleAnalyze/chunks.js +48 -0
- package/dist/pages/ModuleAnalyze/components/fileTreeCom.css +97 -0
- package/dist/pages/ModuleAnalyze/components/fileTreeCom.d.ts +15 -0
- package/dist/pages/ModuleAnalyze/components/fileTreeCom.js +120 -0
- package/dist/pages/ModuleAnalyze/constants.d.ts +7 -0
- package/dist/pages/ModuleAnalyze/constants.js +14 -0
- package/dist/pages/ModuleAnalyze/dependncy.d.ts +9 -0
- package/dist/pages/ModuleAnalyze/dependncy.js +31 -0
- package/dist/pages/ModuleAnalyze/fileTree.d.ts +9 -0
- package/dist/pages/ModuleAnalyze/fileTree.js +125 -0
- package/dist/pages/ModuleAnalyze/index.css +10 -0
- package/dist/pages/ModuleAnalyze/index.d.ts +8 -0
- package/dist/pages/ModuleAnalyze/index.js +64 -0
- package/dist/pages/ModuleAnalyze/utils/hooks.d.ts +21 -0
- package/dist/pages/ModuleAnalyze/utils/hooks.js +62 -0
- package/dist/pages/ModuleAnalyze/utils/index.d.ts +3 -0
- package/dist/pages/ModuleAnalyze/utils/index.js +34 -0
- package/dist/pages/ModuleResolve/constants.d.ts +3 -0
- package/dist/pages/ModuleResolve/constants.js +7 -0
- package/dist/pages/ModuleResolve/index.d.ts +3 -0
- package/dist/pages/ModuleResolve/index.js +19 -0
- package/dist/pages/Overall/constants.d.ts +3 -0
- package/dist/pages/Overall/constants.js +7 -0
- package/dist/pages/Overall/index.d.ts +9 -0
- package/dist/pages/Overall/index.js +39 -0
- package/dist/pages/Overall/responsiveGridList.d.ts +6 -0
- package/dist/pages/Overall/responsiveGridList.js +28 -0
- package/dist/pages/Resources/RuleIndex/constants.d.ts +3 -0
- package/dist/pages/Resources/RuleIndex/constants.js +7 -0
- package/dist/pages/Resources/RuleIndex/index.d.ts +3 -0
- package/dist/pages/Resources/RuleIndex/index.js +53 -0
- package/dist/pages/TreeShaking/constants.d.ts +3 -0
- package/dist/pages/TreeShaking/constants.js +7 -0
- package/dist/pages/TreeShaking/editor.d.ts +12 -0
- package/dist/pages/TreeShaking/editor.js +110 -0
- package/dist/pages/TreeShaking/index.css +74 -0
- package/dist/pages/TreeShaking/index.d.ts +8 -0
- package/dist/pages/TreeShaking/index.js +177 -0
- package/dist/pages/TreeShaking/open-tag.d.ts +11 -0
- package/dist/pages/TreeShaking/open-tag.js +43 -0
- package/dist/pages/TreeShaking/space.d.ts +1 -0
- package/dist/pages/TreeShaking/space.js +16 -0
- package/dist/pages/TreeShaking/table.d.ts +13 -0
- package/dist/pages/TreeShaking/table.js +319 -0
- package/dist/pages/TreeShaking/types.d.ts +3 -0
- package/dist/pages/TreeShaking/types.js +0 -0
- package/dist/pages/TreeShaking/utils.d.ts +7 -0
- package/dist/pages/TreeShaking/utils.js +147 -0
- package/dist/pages/WebpackLoaders/Analysis/constants.d.ts +3 -0
- package/dist/pages/WebpackLoaders/Analysis/constants.js +7 -0
- package/dist/pages/WebpackLoaders/Analysis/index.d.ts +3 -0
- package/dist/pages/WebpackLoaders/Analysis/index.js +19 -0
- package/dist/pages/WebpackLoaders/Overall/constants.d.ts +3 -0
- package/dist/pages/WebpackLoaders/Overall/constants.js +7 -0
- package/dist/pages/WebpackLoaders/Overall/index.d.ts +3 -0
- package/dist/pages/WebpackLoaders/Overall/index.js +11 -0
- package/dist/pages/WebpackLoaders/constants.d.ts +2 -0
- package/dist/pages/WebpackLoaders/constants.js +6 -0
- package/dist/pages/WebpackPlugins/constants.d.ts +3 -0
- package/dist/pages/WebpackPlugins/constants.js +7 -0
- package/dist/pages/WebpackPlugins/index.d.ts +3 -0
- package/dist/pages/WebpackPlugins/index.js +79 -0
- package/dist/pages/index.d.ts +9 -0
- package/dist/pages/index.js +20 -0
- package/dist/utils/data/base.d.ts +24 -0
- package/dist/utils/data/base.js +48 -0
- package/dist/utils/data/index.d.ts +5 -0
- package/dist/utils/data/index.js +44 -0
- package/dist/utils/data/local.d.ts +14 -0
- package/dist/utils/data/local.js +86 -0
- package/dist/utils/data/remote.d.ts +10 -0
- package/dist/utils/data/remote.js +52 -0
- package/dist/utils/file.d.ts +33 -0
- package/dist/utils/file.js +154 -0
- package/dist/utils/hooks.d.ts +31 -0
- package/dist/utils/hooks.js +216 -0
- package/dist/utils/i18n/cn.d.ts +3 -0
- package/dist/utils/i18n/cn.js +33 -0
- package/dist/utils/i18n/en.d.ts +30 -0
- package/dist/utils/i18n/en.js +33 -0
- package/dist/utils/i18n/index.d.ts +2 -0
- package/dist/utils/i18n/index.js +34 -0
- package/dist/utils/index.d.ts +16 -0
- package/dist/utils/index.js +16 -0
- package/dist/utils/loader.d.ts +7 -0
- package/dist/utils/loader.js +34 -0
- package/dist/utils/locale.d.ts +2 -0
- package/dist/utils/locale.js +9 -0
- package/dist/utils/manifest.d.ts +27 -0
- package/dist/utils/manifest.js +54 -0
- package/dist/utils/monaco.d.ts +12 -0
- package/dist/utils/monaco.js +71 -0
- package/dist/utils/request.d.ts +27 -0
- package/dist/utils/request.js +130 -0
- package/dist/utils/routes.d.ts +3 -0
- package/dist/utils/routes.js +14 -0
- package/dist/utils/size.d.ts +2 -0
- package/dist/utils/size.js +24 -0
- package/dist/utils/socket.d.ts +2 -0
- package/dist/utils/socket.js +21 -0
- package/dist/utils/storage.d.ts +13 -0
- package/dist/utils/storage.js +70 -0
- package/dist/utils/string.d.ts +2 -0
- package/dist/utils/string.js +14 -0
- package/dist/utils/time.d.ts +3 -0
- package/dist/utils/time.js +7 -0
- package/dist/utils/url.d.ts +7 -0
- package/dist/utils/url.js +75 -0
- package/dist/utils/worker/index.d.ts +4 -0
- package/dist/utils/worker/index.js +4 -0
- package/dist/utils/worker/master.d.ts +8 -0
- package/dist/utils/worker/master.js +18 -0
- package/dist/utils/worker/types.d.ts +9 -0
- package/dist/utils/worker/types.js +0 -0
- package/dist/utils/worker/utils.d.ts +7 -0
- package/dist/utils/worker/utils.js +29 -0
- package/dist/utils/worker/worker.d.ts +13 -0
- package/dist/utils/worker/worker.js +38 -0
- package/package.json +92 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useMemo, useState } from "react";
|
|
3
|
+
import { get, map } from "lodash-es";
|
|
4
|
+
import { Button, Card, Col, Row, Space, Table, Typography } from "antd";
|
|
5
|
+
import { CloseCircleOutlined, FileSearchOutlined, MenuFoldOutlined, MenuUnfoldOutlined } from "@ant-design/icons";
|
|
6
|
+
import { Resolver } from "@rsdoctor/utils/common";
|
|
7
|
+
import { SDK } from "@rsdoctor/types";
|
|
8
|
+
import { Size } from "../../constants";
|
|
9
|
+
import { createFileStructures, formatCosts, mapFileKey } from "../../utils";
|
|
10
|
+
import { FileTree } from "../FileTree";
|
|
11
|
+
import { KeywordInput } from "../Form/keyword";
|
|
12
|
+
import { DiffViewer } from "../CodeViewer";
|
|
13
|
+
import { ServerAPIProvider, withServerAPI } from "../Manifest";
|
|
14
|
+
const height = 735;
|
|
15
|
+
const ResolverDetailsPanel = ({
|
|
16
|
+
filepath,
|
|
17
|
+
before,
|
|
18
|
+
after,
|
|
19
|
+
resolvers
|
|
20
|
+
}) => {
|
|
21
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
22
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
23
|
+
/* @__PURE__ */ jsx(Col, { flex: 1, children: /* @__PURE__ */ jsx(Card, { title: "Resolve Diff Viewer", children: /* @__PURE__ */ jsx(DiffViewer, { filepath, before, after, editorProps: { height } }) }) }),
|
|
24
|
+
/* @__PURE__ */ jsx(Col, { span: collapsed ? 2 : 7, children: /* @__PURE__ */ jsx(
|
|
25
|
+
Card,
|
|
26
|
+
{
|
|
27
|
+
title: collapsed ? "..." : "Resolve Details",
|
|
28
|
+
extra: /* @__PURE__ */ jsx(
|
|
29
|
+
Button,
|
|
30
|
+
{
|
|
31
|
+
onClick: () => setCollapsed(!collapsed),
|
|
32
|
+
size: "small",
|
|
33
|
+
icon: collapsed ? /* @__PURE__ */ jsx(MenuFoldOutlined, {}) : /* @__PURE__ */ jsx(MenuUnfoldOutlined, {})
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
style: collapsed ? { width: 80 } : void 0,
|
|
37
|
+
children: collapsed ? null : /* @__PURE__ */ jsx(
|
|
38
|
+
Table,
|
|
39
|
+
{
|
|
40
|
+
style: { width: "100%", height, overflowY: "scroll", wordBreak: "break-all" },
|
|
41
|
+
size: "small",
|
|
42
|
+
pagination: false,
|
|
43
|
+
bordered: true,
|
|
44
|
+
rowKey: (e) => e.request,
|
|
45
|
+
columns: [
|
|
46
|
+
{
|
|
47
|
+
title: "Source Code",
|
|
48
|
+
width: 200,
|
|
49
|
+
render: (_v, r) => /* @__PURE__ */ jsx(Typography.Text, { copyable: true, children: /* @__PURE__ */ jsx(Typography.Text, { code: true, strong: true, children: r.request }) })
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
title: "Duration",
|
|
53
|
+
width: 80,
|
|
54
|
+
render: (_v, r) => /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: formatCosts(r.costs) }),
|
|
55
|
+
sorter: (a, b) => a.costs - b.costs,
|
|
56
|
+
sortDirections: ["descend", "ascend"]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
title: "Resolve Result",
|
|
60
|
+
render: (_v, r) => {
|
|
61
|
+
if (Resolver.isResolveSuccessData(r))
|
|
62
|
+
return /* @__PURE__ */ jsx(Typography.Text, { copyable: true, children: r.result });
|
|
63
|
+
return /* @__PURE__ */ jsx(CloseCircleOutlined, { style: { color: "#f50" } });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
dataSource: resolvers
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
) })
|
|
72
|
+
] });
|
|
73
|
+
};
|
|
74
|
+
const ResolverFiles = (props) => {
|
|
75
|
+
const { resolver, cwd } = props;
|
|
76
|
+
const [filepath, setFilepath] = useState("");
|
|
77
|
+
const inlinedResourcePathKey = "__RESOURCEPATH__";
|
|
78
|
+
const n = "/node_modules/";
|
|
79
|
+
const paths = useMemo(() => {
|
|
80
|
+
return map(resolver, (e) => e.issuerPath).filter(Boolean);
|
|
81
|
+
}, [resolver]);
|
|
82
|
+
const filterPaths = useMemo(() => {
|
|
83
|
+
return paths.filter((e) => props.filename ? e.indexOf(props.filename) > -1 : true);
|
|
84
|
+
}, [props.filename, paths]);
|
|
85
|
+
const allNodeModules = filterPaths.length && filterPaths.every((e) => e.indexOf(n) > -1);
|
|
86
|
+
const files = useMemo(() => {
|
|
87
|
+
return createFileStructures({
|
|
88
|
+
files: filterPaths.length ? filterPaths : paths,
|
|
89
|
+
cwd,
|
|
90
|
+
fileTitle(file, basename) {
|
|
91
|
+
return /* @__PURE__ */ jsx("div", { onClick: () => setFilepath(file), children: basename });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}, [props.filename]);
|
|
95
|
+
return /* @__PURE__ */ jsxs(Row, { justify: "start", align: "top", wrap: false, gutter: Size.BasePadding, children: [
|
|
96
|
+
/* @__PURE__ */ jsx(Col, { span: 7, children: /* @__PURE__ */ jsx(Card, { title: "Files", children: /* @__PURE__ */ jsx(
|
|
97
|
+
FileTree,
|
|
98
|
+
{
|
|
99
|
+
style: { width: "100%", height, overflow: "scroll" },
|
|
100
|
+
treeData: files,
|
|
101
|
+
defaultExpandedKeys: mapFileKey(
|
|
102
|
+
files,
|
|
103
|
+
allNodeModules ? 1 : 4,
|
|
104
|
+
allNodeModules ? void 0 : (node) => {
|
|
105
|
+
const resourcePath = get(node, inlinedResourcePathKey);
|
|
106
|
+
const isNodeModules = resourcePath.indexOf(n) > -1;
|
|
107
|
+
if (filterPaths.length && filterPaths.every((e) => e.indexOf(n) > -1)) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return !isNodeModules;
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
},
|
|
114
|
+
`tree_${props.filename}`
|
|
115
|
+
) }) }),
|
|
116
|
+
filepath && /* @__PURE__ */ jsx(ServerAPIProvider, { api: SDK.ServerAPI.API.GetResolverFileDetails, body: { filepath }, children: (resolvers) => /* @__PURE__ */ jsx(ResolverDetailsPanel, { ...resolvers }) })
|
|
117
|
+
] });
|
|
118
|
+
};
|
|
119
|
+
const ResolverAnalysisBase = ({ project }) => {
|
|
120
|
+
const { root: cwd } = project;
|
|
121
|
+
const [filename, setFilename] = useState("");
|
|
122
|
+
return /* @__PURE__ */ jsxs("div", { style: { width: "100%" }, children: [
|
|
123
|
+
/* @__PURE__ */ jsx(Space, { style: { marginTop: Size.BasePadding, marginBottom: Size.BasePadding }, children: /* @__PURE__ */ jsx(
|
|
124
|
+
KeywordInput,
|
|
125
|
+
{
|
|
126
|
+
icon: /* @__PURE__ */ jsx(FileSearchOutlined, {}),
|
|
127
|
+
label: "Filename",
|
|
128
|
+
placeholder: "search filename by keyword",
|
|
129
|
+
onChange: (e) => setFilename(e)
|
|
130
|
+
}
|
|
131
|
+
) }),
|
|
132
|
+
/* @__PURE__ */ jsx(ServerAPIProvider, { api: SDK.ServerAPI.API.GetResolverFileTree, children: (resolver) => /* @__PURE__ */ jsx(ResolverFiles, { filename, resolver, cwd }) })
|
|
133
|
+
] });
|
|
134
|
+
};
|
|
135
|
+
const ResolverAnalysis = withServerAPI({
|
|
136
|
+
api: SDK.ServerAPI.API.GetProjectInfo,
|
|
137
|
+
responsePropName: "project",
|
|
138
|
+
Component: ResolverAnalysisBase
|
|
139
|
+
});
|
|
140
|
+
export {
|
|
141
|
+
ResolverAnalysis,
|
|
142
|
+
ResolverAnalysisBase,
|
|
143
|
+
ResolverFiles
|
|
144
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface LoaderNamesSelectProps {
|
|
3
|
+
style?: React.CSSProperties;
|
|
4
|
+
onChange: (loaders: string[]) => void;
|
|
5
|
+
loaderNames: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare const LoaderNamesSelect: React.FC<LoaderNamesSelectProps>;
|
|
8
|
+
export declare const LoaderCommonSelect: React.FC<{
|
|
9
|
+
onChange(value: {
|
|
10
|
+
loaders: string[];
|
|
11
|
+
filename: string;
|
|
12
|
+
}): void;
|
|
13
|
+
loaderNames: string[];
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { Button, Input, Select, Space, Typography } from "antd";
|
|
4
|
+
import { FileSearchOutlined, SelectOutlined } from "@ant-design/icons";
|
|
5
|
+
import { KeywordInput } from "../Form/keyword";
|
|
6
|
+
import { Size } from "../../constants";
|
|
7
|
+
const LoaderNamesSelect = ({ style, onChange, loaderNames }) => {
|
|
8
|
+
const [selectLoaders, setSelectLoaders] = useState([]);
|
|
9
|
+
const labelStyle = { width: 120 };
|
|
10
|
+
return /* @__PURE__ */ jsxs(Input.Group, { compact: true, style, children: [
|
|
11
|
+
/* @__PURE__ */ jsxs(Button, { style: labelStyle, children: [
|
|
12
|
+
/* @__PURE__ */ jsx(SelectOutlined, {}),
|
|
13
|
+
/* @__PURE__ */ jsx(Typography.Text, { children: "Loaders" })
|
|
14
|
+
] }),
|
|
15
|
+
/* @__PURE__ */ jsx(
|
|
16
|
+
Select,
|
|
17
|
+
{
|
|
18
|
+
mode: "multiple",
|
|
19
|
+
allowClear: true,
|
|
20
|
+
defaultValue: selectLoaders,
|
|
21
|
+
style: { width: 350 },
|
|
22
|
+
dropdownMatchSelectWidth: true,
|
|
23
|
+
placeholder: "select loaders",
|
|
24
|
+
onChange: (e) => {
|
|
25
|
+
setSelectLoaders(e);
|
|
26
|
+
onChange(e);
|
|
27
|
+
},
|
|
28
|
+
children: loaderNames.map((e) => {
|
|
29
|
+
return /* @__PURE__ */ jsx(Select.Option, { label: e, value: e, children: e }, e);
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
] });
|
|
34
|
+
};
|
|
35
|
+
const LoaderCommonSelect = ({ onChange, loaderNames }) => {
|
|
36
|
+
const [selectLoaders, setSelectLoaders] = useState([]);
|
|
37
|
+
const [filename, setFilename] = useState("");
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
onChange({ loaders: selectLoaders, filename });
|
|
40
|
+
}, [selectLoaders, filename]);
|
|
41
|
+
return /* @__PURE__ */ jsxs(Space, { style: { marginBottom: Size.BasePadding }, children: [
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
LoaderNamesSelect,
|
|
44
|
+
{
|
|
45
|
+
loaderNames,
|
|
46
|
+
style: { marginRight: Size.BasePadding - 8 },
|
|
47
|
+
onChange: (e) => {
|
|
48
|
+
setSelectLoaders(e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
KeywordInput,
|
|
54
|
+
{
|
|
55
|
+
icon: /* @__PURE__ */ jsx(FileSearchOutlined, {}),
|
|
56
|
+
label: "Filename",
|
|
57
|
+
placeholder: "search filename by keyword",
|
|
58
|
+
onChange: (e) => {
|
|
59
|
+
setFilename(e);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
] });
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
LoaderCommonSelect,
|
|
67
|
+
LoaderNamesSelect
|
|
68
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Common } from '@rsdoctor/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface FailedStatusProps {
|
|
4
|
+
title?: string;
|
|
5
|
+
buttonText?: string;
|
|
6
|
+
retry: Common.Function;
|
|
7
|
+
}
|
|
8
|
+
export declare const FailedStatus: React.NamedExoticComponent<FailedStatusProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Empty, Space, Typography } from "antd";
|
|
3
|
+
import React from "react";
|
|
4
|
+
const defaultTitle = "Load data failed, please try again";
|
|
5
|
+
const defaultBottonText = "retry";
|
|
6
|
+
const FailedStatusComponent = ({
|
|
7
|
+
title = defaultTitle,
|
|
8
|
+
buttonText = defaultBottonText,
|
|
9
|
+
retry
|
|
10
|
+
}) => {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
Empty,
|
|
13
|
+
{
|
|
14
|
+
description: /* @__PURE__ */ jsxs(Space, { direction: "vertical", children: [
|
|
15
|
+
/* @__PURE__ */ jsx(Typography.Text, { children: title }),
|
|
16
|
+
/* @__PURE__ */ jsx(
|
|
17
|
+
Button,
|
|
18
|
+
{
|
|
19
|
+
type: "primary",
|
|
20
|
+
onClick: () => {
|
|
21
|
+
retry();
|
|
22
|
+
},
|
|
23
|
+
children: buttonText
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
] })
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
const FailedStatus = React.memo(FailedStatusComponent);
|
|
31
|
+
export {
|
|
32
|
+
FailedStatus
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './failed';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./failed";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Rule, SDK } from '@rsdoctor/types';
|
|
3
|
+
import { TextDrawerProps } from './index';
|
|
4
|
+
import { PackageRelationAlertProps } from '../Alert/types';
|
|
5
|
+
interface DuplicatePackageDrawerContentProps extends Omit<TextDrawerProps, 'text'> {
|
|
6
|
+
duplicatePackages: Rule.PackageRelationDiffRuleStoreData[];
|
|
7
|
+
cwd: string;
|
|
8
|
+
textStyle?: React.CSSProperties;
|
|
9
|
+
children: PackageRelationAlertProps['getPackageRelationContentComponent'];
|
|
10
|
+
}
|
|
11
|
+
interface DuplicatePackageDrawerProps extends Omit<DuplicatePackageDrawerContentProps, 'children'> {
|
|
12
|
+
moduleGraph: Pick<SDK.ModuleGraphData, 'dependencies' | 'modules'>;
|
|
13
|
+
moduleCodeMap: SDK.ModuleCodeData;
|
|
14
|
+
}
|
|
15
|
+
export declare const DuplicatePackageDrawer: React.FC<DuplicatePackageDrawerProps>;
|
|
16
|
+
export declare const DuplicatePackageDrawerWithServer: React.FC<Omit<DuplicatePackageDrawerContentProps, 'children'>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Col, Row, Space, Tooltip, Typography } from "antd";
|
|
3
|
+
import { SDK } from "@rsdoctor/types";
|
|
4
|
+
import { ExceptionOutlined } from "@ant-design/icons";
|
|
5
|
+
import { Alerts } from "@rsdoctor/utils/common";
|
|
6
|
+
import { Size } from "../../constants";
|
|
7
|
+
import { TextDrawer } from "./index";
|
|
8
|
+
import {
|
|
9
|
+
PackageRelationAlert,
|
|
10
|
+
PackageRelationReasons,
|
|
11
|
+
PackageRelationReasonsWithServer
|
|
12
|
+
} from "../Alert/package-relation";
|
|
13
|
+
import { ServerAPIProvider } from "../Manifest";
|
|
14
|
+
const DuplicatePackageDrawerContent = ({
|
|
15
|
+
duplicatePackages = [],
|
|
16
|
+
cwd,
|
|
17
|
+
children,
|
|
18
|
+
...props
|
|
19
|
+
}) => {
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
TextDrawer,
|
|
22
|
+
{
|
|
23
|
+
...props,
|
|
24
|
+
buttonStyle: { fontSize: "inherit", ...props.buttonStyle },
|
|
25
|
+
buttonProps: { type: "text", ...props.buttonProps },
|
|
26
|
+
text: /* @__PURE__ */ jsx(Tooltip, { title: "Click to show the details of duplicate packages", children: /* @__PURE__ */ jsxs(Space, { style: { fontSize: "inherit" }, children: [
|
|
27
|
+
/* @__PURE__ */ jsx(Typography.Text, { strong: true, style: { fontSize: "inherit", color: "inherit", ...props.textStyle }, children: duplicatePackages.length }),
|
|
28
|
+
/* @__PURE__ */ jsx(ExceptionOutlined, {})
|
|
29
|
+
] }) }),
|
|
30
|
+
drawerProps: { title: "Duplicate Packages Viewer", ...props.drawerProps },
|
|
31
|
+
children: /* @__PURE__ */ jsx(Row, { gutter: [Size.BasePadding, Size.BasePadding], children: duplicatePackages.map((err, i) => {
|
|
32
|
+
return /* @__PURE__ */ jsx(Col, { span: 24, children: /* @__PURE__ */ jsx(PackageRelationAlert, { data: err, cwd, getPackageRelationContentComponent: children }) }, i);
|
|
33
|
+
}) })
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
const DuplicatePackageDrawer = ({ moduleGraph, ...props }) => {
|
|
38
|
+
return /* @__PURE__ */ jsx(DuplicatePackageDrawerContent, { ...props, children: (res) => {
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
40
|
+
ServerAPIProvider,
|
|
41
|
+
{
|
|
42
|
+
api: SDK.ServerAPI.API.GetModuleCodeByModuleIds,
|
|
43
|
+
body: { moduleIds: moduleGraph.modules.map((mod) => mod.id) },
|
|
44
|
+
children: (moduleCodes) => /* @__PURE__ */ jsx(
|
|
45
|
+
PackageRelationReasons,
|
|
46
|
+
{
|
|
47
|
+
data: Alerts.getPackageRelationAlertDetails(
|
|
48
|
+
moduleGraph.modules,
|
|
49
|
+
moduleGraph.dependencies,
|
|
50
|
+
props.cwd,
|
|
51
|
+
res.package.dependencies,
|
|
52
|
+
moduleCodes
|
|
53
|
+
),
|
|
54
|
+
cwd: props.cwd
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
} });
|
|
60
|
+
};
|
|
61
|
+
const DuplicatePackageDrawerWithServer = (props) => {
|
|
62
|
+
return /* @__PURE__ */ jsx(DuplicatePackageDrawerContent, { ...props, children: (res) => {
|
|
63
|
+
return /* @__PURE__ */ jsx(PackageRelationReasonsWithServer, { body: { id: res.data.id, target: res.package.target }, cwd: props.cwd });
|
|
64
|
+
} });
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
DuplicatePackageDrawer,
|
|
68
|
+
DuplicatePackageDrawerWithServer
|
|
69
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ButtonProps, DrawerProps } from 'antd';
|
|
2
|
+
import React, { CSSProperties, PropsWithChildren } from 'react';
|
|
3
|
+
export interface TextDrawerProps {
|
|
4
|
+
text?: string | React.ReactNode;
|
|
5
|
+
button?: React.ReactNode;
|
|
6
|
+
buttonProps?: ButtonProps;
|
|
7
|
+
buttonStyle?: CSSProperties;
|
|
8
|
+
drawerProps?: DrawerProps;
|
|
9
|
+
}
|
|
10
|
+
export declare const TextDrawer: (props: PropsWithChildren<TextDrawerProps>) => JSX.Element;
|
|
11
|
+
export * from './duplicate';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Drawer } from "antd";
|
|
3
|
+
import React, { useState } from "react";
|
|
4
|
+
import { drawerWidth } from "../../constants";
|
|
5
|
+
const TextDrawer = (props) => {
|
|
6
|
+
const [visible, setVisible] = useState(false);
|
|
7
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
8
|
+
props.button ? /* @__PURE__ */ jsx("div", { onClick: () => setVisible(!visible), children: props.button }) : /* @__PURE__ */ jsx(
|
|
9
|
+
Button,
|
|
10
|
+
{
|
|
11
|
+
type: "link",
|
|
12
|
+
...props.buttonProps,
|
|
13
|
+
onClick: () => setVisible(!visible),
|
|
14
|
+
style: { padding: 0, ...props.buttonStyle },
|
|
15
|
+
children: props.text
|
|
16
|
+
}
|
|
17
|
+
),
|
|
18
|
+
/* @__PURE__ */ jsx(
|
|
19
|
+
Drawer,
|
|
20
|
+
{
|
|
21
|
+
maskClosable: true,
|
|
22
|
+
width: drawerWidth,
|
|
23
|
+
zIndex: 999,
|
|
24
|
+
...props.drawerProps,
|
|
25
|
+
open: visible,
|
|
26
|
+
onClose: () => setVisible(false),
|
|
27
|
+
destroyOnClose: true,
|
|
28
|
+
children: props.children
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
] });
|
|
32
|
+
};
|
|
33
|
+
export * from "./duplicate";
|
|
34
|
+
export {
|
|
35
|
+
TextDrawer
|
|
36
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
interface TitleProps {
|
|
3
|
+
/**
|
|
4
|
+
* @default true
|
|
5
|
+
*/
|
|
6
|
+
upperFisrt?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* @default 16
|
|
9
|
+
*/
|
|
10
|
+
fontSize?: number;
|
|
11
|
+
text: string | React.ReactNode;
|
|
12
|
+
hash?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const Title: React.FC<PropsWithChildren<TitleProps>>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Typography } from "antd";
|
|
3
|
+
import { upperFirst as upf } from "lodash-es";
|
|
4
|
+
const Title = ({ upperFisrt = true, fontSize = 16, text, hash }) => {
|
|
5
|
+
const t = typeof text === "string" ? upperFisrt ? upf(text) : text : text;
|
|
6
|
+
return /* @__PURE__ */ jsx(Typography.Text, { style: { fontSize }, strong: true, children: hash ? /* @__PURE__ */ jsx("a", { href: hash, id: hash.replace(/^#/, ""), style: { color: "inherit" }, children: t }) : t });
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
Title
|
|
10
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './Alert';
|
|
2
|
+
export * from './Alerts';
|
|
3
|
+
export * from './Badge';
|
|
4
|
+
export * from './Card';
|
|
5
|
+
export * from './CodeViewer';
|
|
6
|
+
export * from './Layout';
|
|
7
|
+
export * from './Overall';
|
|
8
|
+
export * from './Manifest';
|
|
9
|
+
export * from './Form/keyword';
|
|
10
|
+
export * from './TextDrawer';
|
|
11
|
+
export * from './BundleDiff';
|
|
12
|
+
export { TimelineCom } from './Charts/TimelineCharts';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./Alert";
|
|
2
|
+
export * from "./Alerts";
|
|
3
|
+
export * from "./Badge";
|
|
4
|
+
export * from "./Card";
|
|
5
|
+
export * from "./CodeViewer";
|
|
6
|
+
export * from "./Layout";
|
|
7
|
+
export * from "./Overall";
|
|
8
|
+
export * from "./Manifest";
|
|
9
|
+
export * from "./Form/keyword";
|
|
10
|
+
export * from "./TextDrawer";
|
|
11
|
+
export * from "./BundleDiff";
|
|
12
|
+
import { TimelineCom } from "./Charts/TimelineCharts";
|
|
13
|
+
export {
|
|
14
|
+
TimelineCom
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ECMAVersion } from '@rsdoctor/utils/ruleUtils';
|
|
3
|
+
export declare function useECMAVersionDetectWorker(props: {
|
|
4
|
+
code: string;
|
|
5
|
+
}): {
|
|
6
|
+
version: ECMAVersion | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare const ECMAVersionDetectTag: React.FC<{
|
|
9
|
+
code: string;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { BadgeColorMap, BadgeType } from "../../Badge";
|
|
4
|
+
import { ECMAVersion } from "@rsdoctor/utils/ruleUtils";
|
|
5
|
+
import { master } from "../../../utils/worker";
|
|
6
|
+
const getECMAVersionDetectWorker = () => new Worker(new URL("./worker.js", import.meta.url));
|
|
7
|
+
function useECMAVersionDetectWorker(props) {
|
|
8
|
+
const { code } = props;
|
|
9
|
+
const [version, setVersion] = useState();
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (!code)
|
|
12
|
+
return;
|
|
13
|
+
const worker = master.detectWorker(getECMAVersionDetectWorker);
|
|
14
|
+
const { abort } = worker.emit(code, (data) => {
|
|
15
|
+
setVersion(data);
|
|
16
|
+
});
|
|
17
|
+
return () => {
|
|
18
|
+
abort();
|
|
19
|
+
};
|
|
20
|
+
}, [code]);
|
|
21
|
+
return {
|
|
22
|
+
version
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const TagColor = {
|
|
26
|
+
[ECMAVersion.ES5]: BadgeColorMap[BadgeType.Success],
|
|
27
|
+
[ECMAVersion.ES6]: BadgeColorMap[BadgeType.Error],
|
|
28
|
+
[ECMAVersion.ES7P]: BadgeColorMap[BadgeType.Error]
|
|
29
|
+
};
|
|
30
|
+
const ECMAVersionDetectTag = ({ code }) => {
|
|
31
|
+
if (!code)
|
|
32
|
+
return null;
|
|
33
|
+
const height = 19.5;
|
|
34
|
+
const { version } = useECMAVersionDetectWorker({ code });
|
|
35
|
+
if (!version) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
"div",
|
|
40
|
+
{
|
|
41
|
+
style: {
|
|
42
|
+
display: "inline-block",
|
|
43
|
+
height,
|
|
44
|
+
padding: `0px 4px`,
|
|
45
|
+
width: 40,
|
|
46
|
+
fontSize: 10,
|
|
47
|
+
lineHeight: `${height}px`,
|
|
48
|
+
textAlign: "center",
|
|
49
|
+
color: "#fff",
|
|
50
|
+
background: TagColor[version] || BadgeColorMap[BadgeType.Default],
|
|
51
|
+
borderRadius: 4
|
|
52
|
+
},
|
|
53
|
+
children: version
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
ECMAVersionDetectTag,
|
|
59
|
+
useECMAVersionDetectWorker
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { parser, ECMAVersion } = require("@rsdoctor/utils/ruleUtils");
|
|
2
|
+
const { handleMessageInWorker } = require("../../../utils/worker");
|
|
3
|
+
const cache = /* @__PURE__ */ new Map();
|
|
4
|
+
handleMessageInWorker({
|
|
5
|
+
workerName: "ecmaversion",
|
|
6
|
+
handler: (code) => {
|
|
7
|
+
if (cache.has(code))
|
|
8
|
+
return cache.get(code) || "";
|
|
9
|
+
const version = parser.utils.detectECMAVersion(code);
|
|
10
|
+
cache.set(code, version);
|
|
11
|
+
return version;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { Tag } from "antd";
|
|
4
|
+
import { master } from "../../../utils/worker";
|
|
5
|
+
import { useI18n } from "../../../utils";
|
|
6
|
+
const getJSEqualWorker = () => new Worker(new URL("./worker.js", import.meta.url));
|
|
7
|
+
function useJSEqualWorker(props) {
|
|
8
|
+
const { input, output } = props;
|
|
9
|
+
const [isEqual, setIsEqual] = useState(false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (!input || !output)
|
|
12
|
+
return;
|
|
13
|
+
const worker = master.detectWorker(getJSEqualWorker);
|
|
14
|
+
const { abort } = worker.emit({ input, output }, (data) => {
|
|
15
|
+
setIsEqual(data);
|
|
16
|
+
});
|
|
17
|
+
return () => {
|
|
18
|
+
abort();
|
|
19
|
+
};
|
|
20
|
+
}, [input, output]);
|
|
21
|
+
return {
|
|
22
|
+
isEqual
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const JSIsEqualTag = ({ input, output }) => {
|
|
26
|
+
if (!input || !output)
|
|
27
|
+
return null;
|
|
28
|
+
const { isEqual } = useJSEqualWorker({ input, output });
|
|
29
|
+
const { t } = useI18n();
|
|
30
|
+
if (!isEqual) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsx(Tag, { color: "warning", children: t("the file content not changed after transpiled by this loader") });
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
JSIsEqualTag,
|
|
37
|
+
useJSEqualWorker
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const { minify: terserMinify } = require("terser");
|
|
2
|
+
const { handleMessageInWorker } = require("../../../utils/worker");
|
|
3
|
+
const cache = /* @__PURE__ */ new Map();
|
|
4
|
+
function minify(code) {
|
|
5
|
+
return terserMinify(code, {
|
|
6
|
+
module: true,
|
|
7
|
+
compress: false,
|
|
8
|
+
mangle: false,
|
|
9
|
+
sourceMap: false
|
|
10
|
+
}).then((res) => res.code);
|
|
11
|
+
}
|
|
12
|
+
handleMessageInWorker({
|
|
13
|
+
workerName: "jsequal",
|
|
14
|
+
handler: async ({ input = "", output = "" }) => {
|
|
15
|
+
const key = input + output;
|
|
16
|
+
if (cache.has(key))
|
|
17
|
+
return cache.get(key) || "";
|
|
18
|
+
const [inputMinified, outputMinified] = await Promise.all([minify(input), minify(output)]);
|
|
19
|
+
const isEqual = inputMinified === outputMinified;
|
|
20
|
+
cache.set(key, isEqual);
|
|
21
|
+
return isEqual;
|
|
22
|
+
}
|
|
23
|
+
});
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Manifest } from '@rsdoctor/types';
|
|
3
|
+
import { PageState, ViewMode, Language, Theme } from './constants';
|
|
4
|
+
export interface Config {
|
|
5
|
+
locale: Language;
|
|
6
|
+
theme: Theme;
|
|
7
|
+
pageState: PageState;
|
|
8
|
+
viewMode: {
|
|
9
|
+
bundleAlerts: ViewMode;
|
|
10
|
+
compileAlerts: ViewMode;
|
|
11
|
+
};
|
|
12
|
+
json: Manifest.RsdoctorManifest;
|
|
13
|
+
setTheme(theme: Config['theme']): void;
|
|
14
|
+
setManifest(json: Manifest.RsdoctorManifest): void;
|
|
15
|
+
setPageState(state: PageState): void;
|
|
16
|
+
setViewMode(mode: Partial<Config['viewMode']>, saveStorage?: boolean): void;
|
|
17
|
+
}
|
|
18
|
+
export declare const defaultConfig: Config;
|
|
19
|
+
export declare const ConfigContext: import("react").Context<Config>;
|