@rsdoctor/components 0.0.2-beta.0
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 +15 -0
- package/dist/assets/connection-point.3b3c78ca.svg +1 -0
- package/dist/assets/icon.7509d763.svg +21 -0
- package/dist/assets/webpack.98604d64.svg +1 -0
- package/dist/components/Alert/change.d.ts +8 -0
- package/dist/components/Alert/change.js +94 -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 +29 -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 +206 -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 +59 -0
- package/dist/components/Alerts/bundle.d.ts +11 -0
- package/dist/components/Alerts/bundle.js +47 -0
- package/dist/components/Alerts/common.d.ts +15 -0
- package/dist/components/Alerts/common.js +106 -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 +105 -0
- package/dist/components/Card/diff.d.ts +23 -0
- package/dist/components/Card/diff.js +131 -0
- package/dist/components/Card/index.d.ts +7 -0
- package/dist/components/Card/index.js +62 -0
- package/dist/components/Card/size.d.ts +16 -0
- package/dist/components/Card/size.js +71 -0
- package/dist/components/Card/statistic.css +16 -0
- package/dist/components/Card/statistic.d.ts +9 -0
- package/dist/components/Card/statistic.js +34 -0
- package/dist/components/Charts/TimelineCharts/index.d.ts +8 -0
- package/dist/components/Charts/TimelineCharts/index.js +197 -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/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 +68 -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 +203 -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 +53 -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 +76 -0
- package/dist/components/Configuration/index.d.ts +1 -0
- package/dist/components/Configuration/index.js +1 -0
- package/dist/components/Configuration/webpack.d.ts +13 -0
- package/dist/components/Configuration/webpack.js +70 -0
- package/dist/components/FileTree/index.css +58 -0
- package/dist/components/FileTree/index.d.ts +4 -0
- package/dist/components/FileTree/index.js +53 -0
- package/dist/components/Form/keyword.d.ts +14 -0
- package/dist/components/Form/keyword.js +76 -0
- package/dist/components/Keyword/index.d.ts +6 -0
- package/dist/components/Keyword/index.js +68 -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 +87 -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 +155 -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 +187 -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 +13 -0
- package/dist/components/Loader/executions.js +221 -0
- package/dist/components/Manifest/api.d.ts +41 -0
- package/dist/components/Manifest/api.js +157 -0
- package/dist/components/Manifest/data.d.ts +8 -0
- package/dist/components/Manifest/data.js +81 -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 +28 -0
- package/dist/components/Opener/code.js +69 -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 +16 -0
- package/dist/components/Opener/vscode.js +57 -0
- package/dist/components/Overall/NumberButton.d.ts +14 -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 +68 -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 +160 -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 +107 -0
- package/dist/components/TextDrawer/index.d.ts +11 -0
- package/dist/components/TextDrawer/index.js +55 -0
- package/dist/components/Title/index.d.ts +15 -0
- package/dist/components/Title/index.js +10 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.js +11 -0
- package/dist/components/worker/ecmaversion/client.d.ts +10 -0
- package/dist/components/worker/ecmaversion/client.js +61 -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 +39 -0
- package/dist/components/worker/jsequal/worker.d.ts +1 -0
- package/dist/components/worker/jsequal/worker.js +52 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +39 -0
- package/dist/constants.d.ts +48 -0
- package/dist/constants.js +71 -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 +405 -0
- package/dist/pages/BundleSize/components/cards.d.ts +7 -0
- package/dist/pages/BundleSize/components/cards.js +154 -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 +314 -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 +88 -0
- package/dist/pages/ModuleAnalyze/components/fileTreeCom.d.ts +15 -0
- package/dist/pages/ModuleAnalyze/components/fileTreeCom.js +138 -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 +65 -0
- package/dist/pages/ModuleAnalyze/utils/index.d.ts +3 -0
- package/dist/pages/ModuleAnalyze/utils/index.js +36 -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 +28 -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 +7 -0
- package/dist/pages/index.js +16 -0
- package/dist/utils/data/base.d.ts +24 -0
- package/dist/utils/data/base.js +70 -0
- package/dist/utils/data/index.d.ts +5 -0
- package/dist/utils/data/index.js +66 -0
- package/dist/utils/data/local.d.ts +14 -0
- package/dist/utils/data/local.js +106 -0
- package/dist/utils/data/remote.d.ts +10 -0
- package/dist/utils/data/remote.js +70 -0
- package/dist/utils/file.d.ts +39 -0
- package/dist/utils/file.js +154 -0
- package/dist/utils/hooks.d.ts +30 -0
- package/dist/utils/hooks.js +256 -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 +29 -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 +9 -0
- package/dist/utils/monaco.js +48 -0
- package/dist/utils/request.d.ts +23 -0
- package/dist/utils/request.js +162 -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 +20 -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 +6 -0
- package/dist/utils/url.js +89 -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 +9 -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 +87 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
33
|
+
import { ClockCircleOutlined } from "@ant-design/icons";
|
|
34
|
+
import { Row, Space, Badge, Col, Typography, Button, Divider, Timeline, Tooltip, Empty, Tag } from "antd";
|
|
35
|
+
import { useState } from "react";
|
|
36
|
+
import { Constants } from "@rsdoctor/types";
|
|
37
|
+
import Editor from "@monaco-editor/react";
|
|
38
|
+
import dayjs from "dayjs";
|
|
39
|
+
import { endsWith } from "lodash-es";
|
|
40
|
+
import { formatCosts, getModifiedLanguage, useTheme, beautifyPath } from "../../utils";
|
|
41
|
+
import { Title } from "../Title";
|
|
42
|
+
import { Size } from "../../constants";
|
|
43
|
+
import { CodeOpener } from "../Opener";
|
|
44
|
+
import { DiffViewer } from "../CodeViewer";
|
|
45
|
+
import { JSIsEqualTag } from "../worker/jsequal/client";
|
|
46
|
+
const LoaderInfoItem = (_a) => {
|
|
47
|
+
var _b = _a, {
|
|
48
|
+
label,
|
|
49
|
+
value,
|
|
50
|
+
ellipsis = false
|
|
51
|
+
} = _b, textProps = __objRest(_b, [
|
|
52
|
+
"label",
|
|
53
|
+
"value",
|
|
54
|
+
"ellipsis"
|
|
55
|
+
]);
|
|
56
|
+
return /* @__PURE__ */ jsxs(Row, { children: [
|
|
57
|
+
/* @__PURE__ */ jsx(Col, { span: 6, children: /* @__PURE__ */ jsxs(Space, { children: [
|
|
58
|
+
/* @__PURE__ */ jsx(Badge, { status: "processing" }),
|
|
59
|
+
/* @__PURE__ */ jsx("div", { style: { width: 180 }, children: /* @__PURE__ */ jsx(Typography.Text, { strong: true, code: true, children: label }) }),
|
|
60
|
+
/* @__PURE__ */ jsx(Divider, { type: "vertical" })
|
|
61
|
+
] }) }),
|
|
62
|
+
/* @__PURE__ */ jsx(Col, { span: 18, children: /* @__PURE__ */ jsx(Typography.Paragraph, __spreadProps(__spreadValues({ ellipsis, strong: true }, textProps), { children: value })) })
|
|
63
|
+
] });
|
|
64
|
+
};
|
|
65
|
+
const LoaderExecutions = ({ data, cwd, index }) => {
|
|
66
|
+
const { loaders, resource } = data;
|
|
67
|
+
const [currentIndex, setCurrentIndex] = useState(index || 0);
|
|
68
|
+
const { theme } = useTheme();
|
|
69
|
+
const isLight = theme === "light";
|
|
70
|
+
const loader = loaders[currentIndex];
|
|
71
|
+
const before = loader.input || "";
|
|
72
|
+
const leftSpan = 5;
|
|
73
|
+
const hasError = loader.errors && loader.errors.length;
|
|
74
|
+
return /* @__PURE__ */ jsxs(Row, { style: { height: "100%" }, children: [
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
Col,
|
|
77
|
+
{
|
|
78
|
+
span: leftSpan,
|
|
79
|
+
style: { borderRight: isLight ? `1px solid #f0f0f0` : void 0, padding: Size.BasePadding },
|
|
80
|
+
children: /* @__PURE__ */ jsxs(Space, { direction: "vertical", style: { width: "100%" }, children: [
|
|
81
|
+
/* @__PURE__ */ jsx(Title, { text: "Executions" }),
|
|
82
|
+
/* @__PURE__ */ jsx(Timeline, { mode: "left", style: { marginTop: Size.BasePadding }, children: loaders.map((e, i, arr) => {
|
|
83
|
+
const { loader: loader2, isPitch } = e;
|
|
84
|
+
return /* @__PURE__ */ jsxs(
|
|
85
|
+
Timeline.Item,
|
|
86
|
+
{
|
|
87
|
+
dot: isPitch ? /* @__PURE__ */ jsx(Tag, { style: { marginLeft: 1, fontWeight: 500 }, children: "pitch" }) : /* @__PURE__ */ jsx(ClockCircleOutlined, {}),
|
|
88
|
+
style: { paddingBottom: 10, textAlign: "center" },
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsx(Row, { align: "middle", justify: "space-between", gutter: [0, 10], children: /* @__PURE__ */ jsx(Col, { span: 24, children: /* @__PURE__ */ jsx(Tooltip, { title: loader2, trigger: "hover", children: /* @__PURE__ */ jsx(
|
|
91
|
+
Button,
|
|
92
|
+
{
|
|
93
|
+
type: i === currentIndex ? "primary" : "default",
|
|
94
|
+
block: true,
|
|
95
|
+
onClick: () => {
|
|
96
|
+
setCurrentIndex(i);
|
|
97
|
+
},
|
|
98
|
+
style: { textAlign: "left" },
|
|
99
|
+
children: /* @__PURE__ */ jsxs(Typography.Text, { ellipsis: true, style: { color: "inherit" }, children: [
|
|
100
|
+
/* @__PURE__ */ jsx(Typography.Text, { strong: true, style: { color: "inherit" }, children: formatCosts(e.costs) }),
|
|
101
|
+
/* @__PURE__ */ jsx(Divider, { type: "vertical" }),
|
|
102
|
+
loader2
|
|
103
|
+
] })
|
|
104
|
+
}
|
|
105
|
+
) }) }) }),
|
|
106
|
+
i === arr.length - 1 ? null : /* @__PURE__ */ jsx("div", { style: { paddingTop: 10 }, children: /* @__PURE__ */ jsx(Typography.Text, { children: "⬇️" }) })
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
i
|
|
110
|
+
);
|
|
111
|
+
}) })
|
|
112
|
+
] })
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ jsxs(Col, { span: 24 - leftSpan, style: { height: "100%" }, children: [
|
|
116
|
+
/* @__PURE__ */ jsx(Col, { span: 24, children: /* @__PURE__ */ jsxs(Space, { direction: "vertical", style: { padding: Size.BasePadding, wordBreak: "break-all" }, children: [
|
|
117
|
+
/* @__PURE__ */ jsxs(Row, { justify: "space-between", align: "middle", style: { paddingBottom: Size.BasePadding / 2 }, children: [
|
|
118
|
+
/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsxs(Space, { children: [
|
|
119
|
+
/* @__PURE__ */ jsx(Title, { text: "Loader Details" }),
|
|
120
|
+
loader.isPitch ? /* @__PURE__ */ jsx(Typography.Text, { code: true, children: "pitch" }) : null,
|
|
121
|
+
loader.isPitch || hasError || !endsWith(resource.path, Constants.JSExtension) ? null : /* @__PURE__ */ jsx(JSIsEqualTag, { input: before, output: loader.result || "" })
|
|
122
|
+
] }) }),
|
|
123
|
+
/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(Tag, { icon: /* @__PURE__ */ jsx(ClockCircleOutlined, {}), color: "default", children: dayjs(loader.startAt).format("YYYY-MM-DD HH:mm:ss") }) })
|
|
124
|
+
] }),
|
|
125
|
+
/* @__PURE__ */ jsx(LoaderInfoItem, { label: "file path", value: beautifyPath(resource.path, cwd), code: true }),
|
|
126
|
+
/* @__PURE__ */ jsx(
|
|
127
|
+
LoaderInfoItem,
|
|
128
|
+
{
|
|
129
|
+
label: "resource path",
|
|
130
|
+
value: /* @__PURE__ */ jsx(CodeOpener, { cwd, url: resource.path, loc: "", disabled: true })
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
/* @__PURE__ */ jsx(LoaderInfoItem, { label: "resource query", value: resource.queryRaw || "-" }),
|
|
134
|
+
/* @__PURE__ */ jsx(LoaderInfoItem, { label: "duration", value: formatCosts(loader.costs), mark: true }),
|
|
135
|
+
/* @__PURE__ */ jsx(LoaderInfoItem, { label: "loader name", value: loader.loader, code: true }),
|
|
136
|
+
/* @__PURE__ */ jsx(LoaderInfoItem, { label: "loader index", value: `${loader.loaderIndex}` }),
|
|
137
|
+
/* @__PURE__ */ jsx(LoaderInfoItem, { label: "loader path", value: /* @__PURE__ */ jsx(CodeOpener, { cwd, url: loader.path, loc: "", disabled: true }) }),
|
|
138
|
+
/* @__PURE__ */ jsx(
|
|
139
|
+
LoaderInfoItem,
|
|
140
|
+
{
|
|
141
|
+
label: "options",
|
|
142
|
+
value: JSON.stringify(loader.options || "-"),
|
|
143
|
+
copyable: true,
|
|
144
|
+
ellipsis: {
|
|
145
|
+
rows: 2,
|
|
146
|
+
expandable: true,
|
|
147
|
+
symbol: "more"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
] }) }),
|
|
152
|
+
hasError ? /* @__PURE__ */ jsxs(Col, { span: 24, style: { height: "53%", minHeight: 400 }, children: [
|
|
153
|
+
/* @__PURE__ */ jsx(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
style: {
|
|
157
|
+
padding: Size.BasePadding,
|
|
158
|
+
borderTop: `1px solid ${isLight ? "#f0f0f0" : "rgba(253, 253, 253, 0.12)"}`,
|
|
159
|
+
borderBottom: `1px solid ${isLight ? "#f0f0f0" : "rgba(253, 253, 253, 0.12)"}`
|
|
160
|
+
},
|
|
161
|
+
children: /* @__PURE__ */ jsx(Title, { text: `the error stack of [${loader.loader}] ${loader.isPitch ? "pitch" : ""}` })
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
/* @__PURE__ */ jsx("div", { style: { height: "90%" }, children: /* @__PURE__ */ jsx(
|
|
165
|
+
Editor,
|
|
166
|
+
{
|
|
167
|
+
theme: "vs-dark",
|
|
168
|
+
options: {
|
|
169
|
+
readOnly: true,
|
|
170
|
+
domReadOnly: true,
|
|
171
|
+
fontSize: 14,
|
|
172
|
+
minimap: { enabled: false },
|
|
173
|
+
lineNumbers: "off"
|
|
174
|
+
},
|
|
175
|
+
value: loader.errors[0].message,
|
|
176
|
+
language: "javascript"
|
|
177
|
+
}
|
|
178
|
+
) })
|
|
179
|
+
] }) : /* @__PURE__ */ jsxs(Col, { span: 24, style: { height: "53%", minHeight: 400 }, children: [
|
|
180
|
+
/* @__PURE__ */ jsx(
|
|
181
|
+
"div",
|
|
182
|
+
{
|
|
183
|
+
style: {
|
|
184
|
+
padding: Size.BasePadding,
|
|
185
|
+
borderTop: `1px solid ${isLight ? "#f0f0f0" : "rgba(253, 253, 253, 0.12)"}`,
|
|
186
|
+
borderBottom: `1px solid ${isLight ? "#f0f0f0" : "rgba(253, 253, 253, 0.12)"}`
|
|
187
|
+
},
|
|
188
|
+
children: /* @__PURE__ */ jsx(Title, { text: `the result of [${loader.loader}] ${loader.isPitch ? "pitch" : ""}` })
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
loader.isPitch ? loader.result ? /* @__PURE__ */ jsx("div", { style: { height: "90%" }, children: /* @__PURE__ */ jsx(
|
|
192
|
+
Editor,
|
|
193
|
+
{
|
|
194
|
+
theme: "vs-dark",
|
|
195
|
+
options: { readOnly: true, domReadOnly: true, fontSize: 14 },
|
|
196
|
+
value: loader.result,
|
|
197
|
+
language: getModifiedLanguage(resource.path)
|
|
198
|
+
}
|
|
199
|
+
) }) : /* @__PURE__ */ jsx(Empty, {}) : /* @__PURE__ */ jsxs("div", { style: { height: "90%" }, children: [
|
|
200
|
+
/* @__PURE__ */ jsxs(Row, { children: [
|
|
201
|
+
/* @__PURE__ */ jsx(Col, { span: 12, style: { padding: `${Size.BasePadding / 2}px ${Size.BasePadding}px` }, children: /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "Input" }) }),
|
|
202
|
+
/* @__PURE__ */ jsx(
|
|
203
|
+
Col,
|
|
204
|
+
{
|
|
205
|
+
span: 12,
|
|
206
|
+
style: {
|
|
207
|
+
padding: `${Size.BasePadding / 2}px ${Size.BasePadding}px`
|
|
208
|
+
},
|
|
209
|
+
children: /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "Output" })
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
] }),
|
|
213
|
+
/* @__PURE__ */ jsx("div", { style: { height: "86%" }, children: /* @__PURE__ */ jsx(DiffViewer, { filepath: resource.path, before, after: loader.result || "" }) })
|
|
214
|
+
] })
|
|
215
|
+
] })
|
|
216
|
+
] })
|
|
217
|
+
] });
|
|
218
|
+
};
|
|
219
|
+
export {
|
|
220
|
+
LoaderExecutions
|
|
221
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Manifest, SDK } from '@rsdoctor/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type InferServerAPIBody<T> = SDK.ServerAPI.InferRequestBodyType<T> extends void ? {
|
|
4
|
+
body?: any;
|
|
5
|
+
} : {
|
|
6
|
+
body: SDK.ServerAPI.InferRequestBodyType<T>;
|
|
7
|
+
};
|
|
8
|
+
type ServerAPIProviderProps<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends> = {
|
|
9
|
+
manifestLoader?: () => Promise<Manifest.DoctorManifestWithShardingFiles>;
|
|
10
|
+
api: T;
|
|
11
|
+
children: (response: SDK.ServerAPI.InferResponseType<T>) => JSX.Element;
|
|
12
|
+
fallbackComponent?: React.FC;
|
|
13
|
+
showSkeleton?: boolean;
|
|
14
|
+
} & InferServerAPIBody<T>;
|
|
15
|
+
/**
|
|
16
|
+
* this component will request server api to the sdk of Rsdoctor in local development.
|
|
17
|
+
* otherwise it will fallback to load full manifest for the data.
|
|
18
|
+
*
|
|
19
|
+
* @example usage
|
|
20
|
+
* <ServerAPIProvider {...props}>
|
|
21
|
+
* {(response) => {
|
|
22
|
+
* <Component {...}></Component>
|
|
23
|
+
* }}
|
|
24
|
+
* </ServerAPIProvider>
|
|
25
|
+
*/
|
|
26
|
+
export declare const ServerAPIProvider: <T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(props: ServerAPIProviderProps<T>) => JSX.Element | null;
|
|
27
|
+
export declare function withServerAPI<T, P extends keyof T, A extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>({
|
|
28
|
+
Component,
|
|
29
|
+
api,
|
|
30
|
+
responsePropName,
|
|
31
|
+
body: bodyInRoot,
|
|
32
|
+
fallbackComponent,
|
|
33
|
+
showSkeleton
|
|
34
|
+
}: {
|
|
35
|
+
Component: React.FC<T>;
|
|
36
|
+
api: A;
|
|
37
|
+
responsePropName: P;
|
|
38
|
+
fallbackComponent?: React.FC;
|
|
39
|
+
showSkeleton?: boolean;
|
|
40
|
+
} & Partial<Partial<InferServerAPIBody<A>>>): React.FC<Omit<T, P> & Partial<InferServerAPIBody<A>>>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { jsx } from "react/jsx-runtime";
|
|
33
|
+
import { SDK } from "@rsdoctor/types";
|
|
34
|
+
import { Skeleton, Spin } from "antd";
|
|
35
|
+
import { useCallback, useEffect, useState } from "react";
|
|
36
|
+
import { includes, isEqual, isNil, values } from "lodash-es";
|
|
37
|
+
import { fetchManifest, useDataLoader } from "../../utils";
|
|
38
|
+
import { ComponentState } from "../../constants";
|
|
39
|
+
import { FailedStatus } from "../Status";
|
|
40
|
+
const ServerAPIProvider = (props) => {
|
|
41
|
+
const {
|
|
42
|
+
manifestLoader = fetchManifest,
|
|
43
|
+
api,
|
|
44
|
+
children,
|
|
45
|
+
// default value of "body" must be "null" to avoid the response type not match when the socket received message.
|
|
46
|
+
body = null,
|
|
47
|
+
showSkeleton = true,
|
|
48
|
+
fallbackComponent
|
|
49
|
+
} = props;
|
|
50
|
+
let promise = manifestLoader();
|
|
51
|
+
const [manifest, setManifest] = useState();
|
|
52
|
+
const [state, setState] = useState(ComponentState.Pending);
|
|
53
|
+
const [res, setRes] = useState({});
|
|
54
|
+
const { loader } = useDataLoader(manifest);
|
|
55
|
+
function init(loader2) {
|
|
56
|
+
ensureManifest(promise).then(() => {
|
|
57
|
+
executeLoader(loader2);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const update = useCallback(
|
|
61
|
+
({ req, res: response }) => {
|
|
62
|
+
if (req.api === api) {
|
|
63
|
+
if (isEqual(req.body, body) || isNil(req.body) && isNil(body)) {
|
|
64
|
+
if (!isEqual(res, response)) {
|
|
65
|
+
setRes(response);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
setState(ComponentState.Success);
|
|
70
|
+
},
|
|
71
|
+
[res, api, body]
|
|
72
|
+
);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
init(loader);
|
|
75
|
+
}, [loader, api, body]);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!loader)
|
|
78
|
+
return;
|
|
79
|
+
loader.onDataUpdate(api, update);
|
|
80
|
+
return () => {
|
|
81
|
+
loader.removeOnDataUpdate(api, update);
|
|
82
|
+
};
|
|
83
|
+
}, [loader, api, body]);
|
|
84
|
+
function ensureManifest(pro) {
|
|
85
|
+
return pro.then((manifest2) => {
|
|
86
|
+
setManifest(manifest2);
|
|
87
|
+
}).catch((err) => {
|
|
88
|
+
setState(ComponentState.Fail);
|
|
89
|
+
throw err;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function executeLoader(loader2) {
|
|
93
|
+
if (!loader2)
|
|
94
|
+
return;
|
|
95
|
+
const exts = values(SDK.ServerAPI.APIExtends);
|
|
96
|
+
if (includes(exts, api)) {
|
|
97
|
+
setState(ComponentState.Success);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
loader2.loadAPI(api, body).then((e) => {
|
|
101
|
+
if (isNil(e)) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
setRes(e);
|
|
105
|
+
setState(ComponentState.Success);
|
|
106
|
+
}).catch((err) => {
|
|
107
|
+
console.error(err);
|
|
108
|
+
setState(ComponentState.Fail);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (state === ComponentState.Pending) {
|
|
112
|
+
return showSkeleton ? /* @__PURE__ */ jsx(Skeleton, { active: true }) : null;
|
|
113
|
+
}
|
|
114
|
+
if (state === ComponentState.Fail) {
|
|
115
|
+
if (fallbackComponent)
|
|
116
|
+
return fallbackComponent;
|
|
117
|
+
return /* @__PURE__ */ jsx(
|
|
118
|
+
FailedStatus,
|
|
119
|
+
{
|
|
120
|
+
retry: () => {
|
|
121
|
+
setState(ComponentState.Pending);
|
|
122
|
+
promise = manifestLoader();
|
|
123
|
+
init();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
if (state === ComponentState.Updating) {
|
|
129
|
+
return /* @__PURE__ */ jsx(Spin, { spinning: true, children: children(res) });
|
|
130
|
+
}
|
|
131
|
+
return children(res);
|
|
132
|
+
};
|
|
133
|
+
function withServerAPI({
|
|
134
|
+
Component,
|
|
135
|
+
api,
|
|
136
|
+
responsePropName,
|
|
137
|
+
body: bodyInRoot,
|
|
138
|
+
fallbackComponent,
|
|
139
|
+
showSkeleton
|
|
140
|
+
}) {
|
|
141
|
+
return function _(props) {
|
|
142
|
+
const _a = props, { body = bodyInRoot } = _a, rest = __objRest(_a, ["body"]);
|
|
143
|
+
return (
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
/* @__PURE__ */ jsx(ServerAPIProvider, { api, body, showSkeleton, fallbackComponent, children: (res) => {
|
|
146
|
+
const _props = __spreadProps(__spreadValues({}, rest), {
|
|
147
|
+
[responsePropName]: res
|
|
148
|
+
});
|
|
149
|
+
return /* @__PURE__ */ jsx(Component, __spreadValues({}, _props));
|
|
150
|
+
} })
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
ServerAPIProvider,
|
|
156
|
+
withServerAPI
|
|
157
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Manifest } from '@rsdoctor/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type ExtractAlias<T> = T extends [property: string, alias: infer P][] ? `${P extends string ? P : never}` : never;
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated
|
|
6
|
+
*/
|
|
7
|
+
export declare function ConnectManifestData<Props extends object, Keys extends [property: `${Manifest.DoctorManifestMappingKeys}`, alias: keyof Props][] | [property: string, alias: keyof Props][]>(manifestLoader: () => Promise<Manifest.DoctorManifestWithShardingFiles>, keys: Keys, Component: React.FC<Props>): React.FC<Omit<Props, ExtractAlias<Keys>>>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import { jsx } from "react/jsx-runtime";
|
|
18
|
+
import { Skeleton } from "antd";
|
|
19
|
+
import { useEffect, useState } from "react";
|
|
20
|
+
import { useDataLoader } from "../../utils";
|
|
21
|
+
import { PageState } from "../../constants";
|
|
22
|
+
import { FailedStatus } from "../Status";
|
|
23
|
+
function ConnectManifestData(manifestLoader, keys, Component) {
|
|
24
|
+
const promise = manifestLoader();
|
|
25
|
+
return function _() {
|
|
26
|
+
const [manifest, setManifest] = useState();
|
|
27
|
+
const [state, setState] = useState(PageState.Pending);
|
|
28
|
+
const [props, setProps] = useState({});
|
|
29
|
+
const { loader } = useDataLoader(manifest);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
ensureManifest(promise).then(() => {
|
|
32
|
+
executeLoader(loader);
|
|
33
|
+
});
|
|
34
|
+
}, [loader]);
|
|
35
|
+
function ensureManifest(pro) {
|
|
36
|
+
return pro.then((manifest2) => {
|
|
37
|
+
setManifest(manifest2);
|
|
38
|
+
}).catch(() => {
|
|
39
|
+
setState(PageState.Fail);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function executeLoader(loader2) {
|
|
43
|
+
if (!loader2)
|
|
44
|
+
return;
|
|
45
|
+
Promise.all(keys.map(([key]) => loader2.loadData(key))).then((e) => {
|
|
46
|
+
const p = e.reduce((t, val, i) => {
|
|
47
|
+
const [_key, alias] = keys[i];
|
|
48
|
+
t[alias] = val;
|
|
49
|
+
return t;
|
|
50
|
+
}, {});
|
|
51
|
+
setProps(p);
|
|
52
|
+
setState(PageState.Success);
|
|
53
|
+
}).catch((err) => {
|
|
54
|
+
console.error(err);
|
|
55
|
+
setState(PageState.Fail);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (state === PageState.Pending) {
|
|
59
|
+
return /* @__PURE__ */ jsx(Skeleton, { active: true });
|
|
60
|
+
}
|
|
61
|
+
if (state === PageState.Fail) {
|
|
62
|
+
return /* @__PURE__ */ jsx(
|
|
63
|
+
FailedStatus,
|
|
64
|
+
{
|
|
65
|
+
retry: () => {
|
|
66
|
+
setState(PageState.Pending);
|
|
67
|
+
promise.then(() => {
|
|
68
|
+
executeLoader(loader);
|
|
69
|
+
}).catch(() => {
|
|
70
|
+
ensureManifest(manifestLoader());
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return /* @__PURE__ */ jsx(Component, __spreadValues({}, props));
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
ConnectManifestData
|
|
81
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
interface CodeOpenerProps {
|
|
3
|
+
windowId?: number;
|
|
4
|
+
/**
|
|
5
|
+
* @example /xx/src/pages/home/index.ts + 100 modules
|
|
6
|
+
* @example /xx/src/pages/b/index.ts
|
|
7
|
+
*/
|
|
8
|
+
url: string;
|
|
9
|
+
/**
|
|
10
|
+
* @example 1:0-10
|
|
11
|
+
* @example 1:1
|
|
12
|
+
*/
|
|
13
|
+
loc?: string;
|
|
14
|
+
cwd: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
code?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const CodeOpener: ({
|
|
20
|
+
cwd,
|
|
21
|
+
url,
|
|
22
|
+
loc,
|
|
23
|
+
windowId,
|
|
24
|
+
label,
|
|
25
|
+
disabled,
|
|
26
|
+
code
|
|
27
|
+
}: PropsWithChildren<CodeOpenerProps>) => JSX.Element | null;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Typography } from "antd";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { startsWith } from "lodash-es";
|
|
5
|
+
import { VSCode, openVSCode } from "./vscode";
|
|
6
|
+
function parseUrl(url) {
|
|
7
|
+
const strs = url.split(" ");
|
|
8
|
+
let res = "";
|
|
9
|
+
if (strs.length === 1) {
|
|
10
|
+
[res] = strs;
|
|
11
|
+
} else {
|
|
12
|
+
[res] = strs.filter((e) => path.isAbsolute(e) || startsWith(e, "./"));
|
|
13
|
+
}
|
|
14
|
+
return res || url;
|
|
15
|
+
}
|
|
16
|
+
function parseLoc(loc) {
|
|
17
|
+
if (!loc)
|
|
18
|
+
return { line: 1, column: 1 };
|
|
19
|
+
const [line, col = ""] = loc.split(":");
|
|
20
|
+
const [start = 1, end] = col.split("-");
|
|
21
|
+
return {
|
|
22
|
+
line,
|
|
23
|
+
columnStart: start,
|
|
24
|
+
columnEnd: end || start
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const defaultWindowId = +Date.now().toString().slice(-4) + 1e3;
|
|
28
|
+
const CodeOpener = ({
|
|
29
|
+
cwd,
|
|
30
|
+
url,
|
|
31
|
+
loc,
|
|
32
|
+
windowId = defaultWindowId,
|
|
33
|
+
label,
|
|
34
|
+
disabled,
|
|
35
|
+
code = false
|
|
36
|
+
}) => {
|
|
37
|
+
const file = path.resolve(cwd, parseUrl(url));
|
|
38
|
+
const { line, columnStart } = parseLoc(loc);
|
|
39
|
+
return /* @__PURE__ */ jsxs("span", { style: { wordBreak: "break-all" }, children: [
|
|
40
|
+
/* @__PURE__ */ jsx(
|
|
41
|
+
Typography.Text,
|
|
42
|
+
{
|
|
43
|
+
copyable: {
|
|
44
|
+
text: file
|
|
45
|
+
},
|
|
46
|
+
children: /* @__PURE__ */ jsxs(
|
|
47
|
+
Typography.Text,
|
|
48
|
+
{
|
|
49
|
+
code,
|
|
50
|
+
onClick: () => {
|
|
51
|
+
if (disabled)
|
|
52
|
+
return;
|
|
53
|
+
openVSCode({ file, line, column: columnStart, windowId });
|
|
54
|
+
},
|
|
55
|
+
style: { cursor: disabled ? "revert" : "pointer" },
|
|
56
|
+
children: [
|
|
57
|
+
label || url,
|
|
58
|
+
loc ? `:${loc}` : ""
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
process.env.NODE_ENV === "development" ? /* @__PURE__ */ jsx(VSCode, { file, line, column: columnStart, windowId, style: { marginLeft: 3 } }) : /* @__PURE__ */ jsx("div", { style: { display: "inline-block" } })
|
|
65
|
+
] });
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
CodeOpener
|
|
69
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface VSCodeProps {
|
|
3
|
+
file: string;
|
|
4
|
+
line?: number | string;
|
|
5
|
+
column?: number | string;
|
|
6
|
+
windowId?: number;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
export declare function openVSCode({
|
|
10
|
+
file,
|
|
11
|
+
line,
|
|
12
|
+
column,
|
|
13
|
+
windowId
|
|
14
|
+
}: VSCodeProps): void;
|
|
15
|
+
export declare const VSCode: (props: VSCodeProps) => JSX.Element;
|
|
16
|
+
export {};
|