@rsdoctor/components 0.0.2-beta.0 → 0.0.2-beta.2

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 (113) hide show
  1. package/dist/components/Alert/change.js +2 -3
  2. package/dist/components/Alert/file-relation.js +1 -1
  3. package/dist/components/Alert/index.css +3 -0
  4. package/dist/components/Alert/link.js +1 -1
  5. package/dist/components/Alert/package-relation.js +8 -27
  6. package/dist/components/Alert/view.js +3 -4
  7. package/dist/components/Alerts/bundle.js +23 -9
  8. package/dist/components/Alerts/common.js +3 -20
  9. package/dist/components/Badge/index.js +11 -29
  10. package/dist/components/Card/diff.d.ts +2 -2
  11. package/dist/components/Card/diff.js +4 -33
  12. package/dist/components/Card/index.d.ts +1 -0
  13. package/dist/components/Card/index.js +6 -37
  14. package/dist/components/Card/size.d.ts +5 -0
  15. package/dist/components/Card/size.js +17 -9
  16. package/dist/components/Card/statistic.css +2 -1
  17. package/dist/components/Card/statistic.d.ts +3 -0
  18. package/dist/components/Card/statistic.js +6 -21
  19. package/dist/components/Charts/TimelineCharts/index.js +120 -127
  20. package/dist/components/Charts/common.js +1 -1
  21. package/dist/components/Charts/loader.js +9 -18
  22. package/dist/components/CodeViewer/diff.js +8 -26
  23. package/dist/components/CodeViewer/hightlight.js +3 -3
  24. package/dist/components/CodeViewer/viewer.js +4 -20
  25. package/dist/components/Configuration/{webpack.d.ts → builder.d.ts} +1 -1
  26. package/dist/components/Configuration/{webpack.js → builder.js} +6 -6
  27. package/dist/components/Configuration/index.d.ts +1 -1
  28. package/dist/components/Configuration/index.js +1 -1
  29. package/dist/components/FileTree/index.js +13 -24
  30. package/dist/components/Form/keyword.js +1 -17
  31. package/dist/components/Keyword/index.js +4 -36
  32. package/dist/components/Layout/builder-select.js +1 -1
  33. package/dist/components/Layout/header.js +2 -3
  34. package/dist/components/Layout/index.js +2 -2
  35. package/dist/components/Layout/menus.d.ts +1 -1
  36. package/dist/components/Layout/menus.js +11 -35
  37. package/dist/components/Loader/Analysis/files.js +8 -2
  38. package/dist/components/Loader/Analysis/index.d.ts +1 -1
  39. package/dist/components/Loader/executions.d.ts +1 -1
  40. package/dist/components/Loader/executions.js +62 -84
  41. package/dist/components/Manifest/api.d.ts +1 -1
  42. package/dist/components/Manifest/api.js +5 -35
  43. package/dist/components/Manifest/data.d.ts +1 -1
  44. package/dist/components/Manifest/data.js +1 -17
  45. package/dist/components/Opener/vscode.js +4 -19
  46. package/dist/components/Overall/bundle.js +2 -2
  47. package/dist/components/Overall/compile.js +1 -2
  48. package/dist/components/Resolver/analysis.js +1 -17
  49. package/dist/components/TextDrawer/duplicate.js +18 -56
  50. package/dist/components/TextDrawer/index.js +9 -28
  51. package/dist/components/worker/ecmaversion/client.js +1 -2
  52. package/dist/components/worker/ecmaversion/worker.js +3 -3
  53. package/dist/components/worker/jsequal/client.js +1 -2
  54. package/dist/components/worker/jsequal/worker.js +21 -50
  55. package/dist/config.d.ts +2 -2
  56. package/dist/config.js +3 -17
  57. package/dist/constants.d.ts +4 -2
  58. package/dist/constants.js +5 -1
  59. package/dist/pages/BundleSize/components/asset.js +74 -101
  60. package/dist/pages/BundleSize/components/cards.js +16 -27
  61. package/dist/pages/BundleSize/components/index.d.ts +1 -1
  62. package/dist/pages/BundleSize/components/index.js +57 -5
  63. package/dist/pages/BundleSize/constants.d.ts +1 -1
  64. package/dist/pages/BundleSize/constants.js +1 -1
  65. package/dist/pages/ModuleAnalyze/chunks.js +1 -1
  66. package/dist/pages/ModuleAnalyze/components/fileTreeCom.css +16 -7
  67. package/dist/pages/ModuleAnalyze/components/fileTreeCom.js +6 -24
  68. package/dist/pages/ModuleAnalyze/constants.d.ts +1 -1
  69. package/dist/pages/ModuleAnalyze/constants.js +1 -1
  70. package/dist/pages/ModuleAnalyze/utils/hooks.js +5 -8
  71. package/dist/pages/ModuleAnalyze/utils/index.js +2 -4
  72. package/dist/pages/ModuleResolve/constants.d.ts +1 -1
  73. package/dist/pages/ModuleResolve/constants.js +1 -1
  74. package/dist/pages/Overall/constants.d.ts +1 -1
  75. package/dist/pages/Overall/constants.js +1 -1
  76. package/dist/pages/Resources/RuleIndex/constants.d.ts +3 -0
  77. package/dist/pages/Resources/RuleIndex/constants.js +7 -0
  78. package/dist/pages/Resources/RuleIndex/index.d.ts +3 -0
  79. package/dist/pages/Resources/RuleIndex/index.js +53 -0
  80. package/dist/pages/WebpackLoaders/Analysis/constants.d.ts +1 -1
  81. package/dist/pages/WebpackLoaders/Analysis/constants.js +1 -1
  82. package/dist/pages/WebpackLoaders/Overall/constants.d.ts +2 -2
  83. package/dist/pages/WebpackLoaders/Overall/constants.js +2 -2
  84. package/dist/pages/WebpackLoaders/Overall/index.js +1 -1
  85. package/dist/pages/WebpackPlugins/constants.d.ts +2 -2
  86. package/dist/pages/WebpackPlugins/constants.js +2 -2
  87. package/dist/pages/index.d.ts +2 -1
  88. package/dist/pages/index.js +3 -1
  89. package/dist/utils/data/base.d.ts +7 -7
  90. package/dist/utils/data/base.js +2 -24
  91. package/dist/utils/data/index.d.ts +1 -1
  92. package/dist/utils/data/index.js +14 -36
  93. package/dist/utils/data/local.d.ts +1 -1
  94. package/dist/utils/data/local.js +32 -56
  95. package/dist/utils/data/remote.d.ts +1 -1
  96. package/dist/utils/data/remote.js +22 -46
  97. package/dist/utils/file.js +4 -4
  98. package/dist/utils/hooks.d.ts +16 -15
  99. package/dist/utils/hooks.js +33 -73
  100. package/dist/utils/i18n/cn.js +1 -1
  101. package/dist/utils/i18n/en.d.ts +1 -1
  102. package/dist/utils/i18n/en.js +1 -1
  103. package/dist/utils/manifest.d.ts +2 -2
  104. package/dist/utils/monaco.d.ts +4 -1
  105. package/dist/utils/monaco.js +26 -3
  106. package/dist/utils/request.d.ts +10 -10
  107. package/dist/utils/request.js +52 -101
  108. package/dist/utils/routes.d.ts +2 -2
  109. package/dist/utils/routes.js +2 -2
  110. package/dist/utils/storage.js +3 -3
  111. package/dist/utils/url.js +10 -28
  112. package/package.json +7 -4
  113. package/dist/assets/icon.7509d763.svg +0 -21
@@ -3,7 +3,7 @@ import { BaseDataLoader } from './base';
3
3
  export declare class LocalServerDataLoader extends BaseDataLoader {
4
4
  protected events: Map<SDK.ServerAPI.API | SDK.ServerAPI.APIExtends, Set<Common.Function>>;
5
5
  isLocal(): boolean;
6
- loadData<T extends keyof Manifest.DoctorManifestData>(key: T): Promise<void | Manifest.DoctorManifestData[T]>;
6
+ loadData<T extends keyof Manifest.RsdoctorManifestData>(key: T): Promise<void | Manifest.RsdoctorManifestData[T]>;
7
7
  loadAPI<T extends SDK.ServerAPI.API, B extends SDK.ServerAPI.InferRequestBodyType<T> = SDK.ServerAPI.InferRequestBodyType<T>, R extends SDK.ServerAPI.InferResponseType<T> = SDK.ServerAPI.InferResponseType<T>>(...args: B extends void ? [api: T] : [api: T, body: B]): Promise<R>;
8
8
  dispose(): void;
9
9
  /**
@@ -1,23 +1,3 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
1
  import { Manifest as ManifestShared } from "@rsdoctor/utils/common";
22
2
  import { SDK } from "@rsdoctor/types";
23
3
  import { get } from "lodash-es";
@@ -31,46 +11,42 @@ class LocalServerDataLoader extends BaseDataLoader {
31
11
  isLocal() {
32
12
  return true;
33
13
  }
34
- loadData(key) {
35
- return __async(this, null, function* () {
36
- return this.limit(key, () => __async(this, null, function* () {
37
- const [scope, ...rest] = this.getKeys(key);
38
- const data = this.getData(scope);
39
- if (!data)
40
- return;
41
- let res = data;
42
- if (ManifestShared.isShardingData(res)) {
43
- if (!this.shardingDataMap.has(key)) {
44
- const task = new Promise((resolve) => {
45
- getSocket(this.manifest.__SOCKET__URL__).emit(
46
- SDK.ServerAPI.API.LoadDataByKey,
47
- { key },
48
- (res2) => {
49
- resolve(res2.res);
50
- }
51
- );
52
- });
53
- this.shardingDataMap.set(key, task);
54
- }
55
- res = yield this.shardingDataMap.get(key);
56
- this.shardingDataMap.delete(key);
57
- return res;
14
+ async loadData(key) {
15
+ return this.limit(key, async () => {
16
+ const [scope, ...rest] = this.getKeys(key);
17
+ const data = this.getData(scope);
18
+ if (!data)
19
+ return;
20
+ let res = data;
21
+ if (ManifestShared.isShardingData(res)) {
22
+ if (!this.shardingDataMap.has(key)) {
23
+ const task = new Promise((resolve) => {
24
+ getSocket(this.manifest.__SOCKET__URL__).emit(
25
+ SDK.ServerAPI.API.LoadDataByKey,
26
+ { key },
27
+ (res2) => {
28
+ resolve(res2.res);
29
+ }
30
+ );
31
+ });
32
+ this.shardingDataMap.set(key, task);
58
33
  }
59
- return rest.length > 0 ? get(res, this.joinKeys(rest)) : res;
60
- }));
34
+ res = await this.shardingDataMap.get(key);
35
+ this.shardingDataMap.delete(key);
36
+ return res;
37
+ }
38
+ return rest.length > 0 ? get(res, this.joinKeys(rest)) : res;
61
39
  });
62
40
  }
63
- loadAPI(...args) {
64
- return __async(this, null, function* () {
65
- const [api, body] = args;
66
- const key = body ? `${api}_${JSON.stringify(body)}` : `${api}`;
67
- return this.limit(key, () => __async(this, null, function* () {
68
- return new Promise((resolve) => {
69
- getSocket(this.manifest.__SOCKET__URL__).emit(api, body, (res) => {
70
- resolve(res.res);
71
- });
41
+ async loadAPI(...args) {
42
+ const [api, body] = args;
43
+ const key = body ? `${api}_${JSON.stringify(body)}` : `${api}`;
44
+ return this.limit(key, async () => {
45
+ return new Promise((resolve) => {
46
+ getSocket(this.manifest.__SOCKET__URL__).emit(api, body, (res) => {
47
+ resolve(res.res);
72
48
  });
73
- }));
49
+ });
74
50
  });
75
51
  }
76
52
  dispose() {
@@ -2,7 +2,7 @@ import { Manifest, SDK } from '@rsdoctor/types';
2
2
  import { BaseDataLoader } from './base';
3
3
  export declare class RemoteDataLoader extends BaseDataLoader {
4
4
  isLocal(): boolean;
5
- loadData<T extends Manifest.DoctorManifestMappingKeys>(key: T): Promise<Manifest.InferManifestDataValue<T>>;
5
+ loadData<T extends Manifest.RsdoctorManifestMappingKeys>(key: T): Promise<Manifest.InferManifestDataValue<T>>;
6
6
  loadAPI<T extends SDK.ServerAPI.API, B extends SDK.ServerAPI.InferRequestBodyType<T> = SDK.ServerAPI.InferRequestBodyType<T>, R extends SDK.ServerAPI.InferResponseType<T> = SDK.ServerAPI.InferResponseType<T>>(...args: B extends void ? [api: T] : [api: T, body: B]): Promise<R>;
7
7
  dispose(): void;
8
8
  onDataUpdate(): void;
@@ -1,23 +1,3 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
1
  import { Manifest as ManifestShared } from "@rsdoctor/utils/common";
22
2
  import { get } from "lodash-es";
23
3
  import { BaseDataLoader } from "./base";
@@ -26,35 +6,31 @@ class RemoteDataLoader extends BaseDataLoader {
26
6
  isLocal() {
27
7
  return false;
28
8
  }
29
- loadData(key) {
30
- return __async(this, null, function* () {
31
- return this.limit(key, () => __async(this, null, function* () {
32
- const [scope, ...rest] = this.getKeys(key);
33
- const data = this.getData(scope);
34
- if (!data)
35
- return;
36
- let res = data;
37
- if (ManifestShared.isShardingData(res)) {
38
- if (!this.shardingDataMap.has(scope)) {
39
- const task = ManifestShared.fetchShardingData(res, fetchShardingFile).catch((err) => {
40
- this.log(`loadData error: `, res, key);
41
- throw err;
42
- });
43
- this.shardingDataMap.set(scope, task);
44
- }
45
- res = yield this.shardingDataMap.get(scope);
9
+ async loadData(key) {
10
+ return this.limit(key, async () => {
11
+ const [scope, ...rest] = this.getKeys(key);
12
+ const data = this.getData(scope);
13
+ if (!data)
14
+ return;
15
+ let res = data;
16
+ if (ManifestShared.isShardingData(res)) {
17
+ if (!this.shardingDataMap.has(scope)) {
18
+ const task = ManifestShared.fetchShardingData(res, fetchShardingFile).catch((err) => {
19
+ this.log(`loadData error: `, res, key);
20
+ throw err;
21
+ });
22
+ this.shardingDataMap.set(scope, task);
46
23
  }
47
- return rest.length > 0 ? get(res, this.joinKeys(rest)) : res;
48
- }));
24
+ res = await this.shardingDataMap.get(scope);
25
+ }
26
+ return rest.length > 0 ? get(res, this.joinKeys(rest)) : res;
49
27
  });
50
28
  }
51
- loadAPI(...args) {
52
- return __async(this, null, function* () {
53
- const [api, body] = args;
54
- const key = body ? `${api}_${JSON.stringify(body)}` : `${api}`;
55
- return this.limit(key, () => __async(this, null, function* () {
56
- return this.loader.loadAPI(...args);
57
- }));
29
+ async loadAPI(...args) {
30
+ const [api, body] = args;
31
+ const key = body ? `${api}_${JSON.stringify(body)}` : `${api}`;
32
+ return this.limit(key, async () => {
33
+ return this.loader.loadAPI(...args);
58
34
  });
59
35
  }
60
36
  dispose() {
@@ -1,14 +1,14 @@
1
1
  import { get, startsWith } from "lodash-es";
2
2
  import { message } from "antd";
3
3
  const rootDirname = (file, sep = "/") => {
4
- const idx = file == null ? void 0 : file.indexOf(sep);
4
+ const idx = file?.indexOf(sep);
5
5
  if (idx === -1) {
6
6
  return null;
7
7
  }
8
8
  if (idx === 0) {
9
- return sep + (rootDirname(file == null ? void 0 : file.slice(1)) || "");
9
+ return sep + (rootDirname(file?.slice(1)) || "");
10
10
  }
11
- return file == null ? void 0 : file.slice(0, idx);
11
+ return file?.slice(0, idx);
12
12
  };
13
13
  function mapFileKey(arr, depth = 2, filter = () => true) {
14
14
  let d = 0;
@@ -59,7 +59,7 @@ function createFileStructures({
59
59
  const res = files.reduce(
60
60
  (t, file) => {
61
61
  let dir = rootDirname(file, sep);
62
- let basename = dir ? file == null ? void 0 : file.slice(dir.length + 1) : file;
62
+ let basename = dir ? file?.slice(dir.length + 1) : file;
63
63
  let parent = t;
64
64
  while (dir) {
65
65
  let exist = parent.children.find((e) => e.title === dir);
@@ -10,21 +10,22 @@ export declare function useLoading(defaultLoading?: boolean): {
10
10
  setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
11
11
  withLoading(func: (...args: unknown[]) => Promise<unknown> | unknown): Promise<void>;
12
12
  };
13
- export declare function useProjectRootByManifest(manifest: Manifest.DoctorManifest): string;
14
- export declare function useHashByManifest(manifest: Manifest.DoctorManifest): string;
15
- export declare function useCloudManifestUrlByManifest(manifest: Manifest.DoctorManifest | Manifest.DoctorManifestWithShardingFiles | void): void;
16
- export declare function useChunkGraphByManifest(manifest: Manifest.DoctorManifest): SDK.ChunkGraphData;
17
- export declare function useConfigOutputFileNameByManifest(manifest: Manifest.DoctorManifest): string;
18
- export declare function useModuleGraphByManifest(manifest: Manifest.DoctorManifest): SDK.ModuleGraphData;
13
+ export declare function useProjectRootByManifest(manifest: Manifest.RsdoctorManifest): string;
14
+ export declare function useHashByManifest(manifest: Manifest.RsdoctorManifest): string;
15
+ export declare function useCloudManifestUrlByManifest(manifest: Manifest.RsdoctorManifest | Manifest.RsdoctorManifestWithShardingFiles | void): void;
16
+ export declare function useChunkGraphByManifest(manifest: Manifest.RsdoctorManifest): SDK.ChunkGraphData;
17
+ export declare function useConfigOutputFileNameByManifest(manifest: Manifest.RsdoctorManifest): string;
18
+ export declare function useModuleGraphByManifest(manifest: Manifest.RsdoctorManifest): SDK.ModuleGraphData;
19
19
  export declare function useModuleGraph(moduleGraph: SDK.ModuleGraphData): SDK.ModuleGraphData;
20
- export declare function usePackageGraphByManifest(manifest: Manifest.DoctorManifest): SDK.PackageGraphData;
21
- export declare function useUniqModulesByManifest(manifest: Manifest.DoctorManifest): SDK.ModuleData[];
20
+ export declare function usePackageGraphByManifest(manifest: Manifest.RsdoctorManifest): SDK.PackageGraphData;
21
+ export declare function useUniqModulesByManifest(manifest: Manifest.RsdoctorManifest): SDK.ModuleData[];
22
22
  export declare function useUniqModules(modules: SDK.ModuleData[]): SDK.ModuleData[];
23
- export declare function useErrorsByManifest(manifest: Manifest.DoctorManifest): Rule.RuleStoreData;
24
- export declare function useBundleAlertsByManifest(manifest: Manifest.DoctorManifest): Rule.RuleStoreDataItem[];
25
- export declare function useDuplicatePackagesByManifest(manifest: Manifest.DoctorManifest): Rule.PackageRelationDiffRuleStoreData[];
26
- export declare function useCompileAlertsByErrors(errors: Manifest.DoctorManifestData['errors']): Rule.RuleStoreDataItem[];
27
- export declare function useBundleAlertsByErrors(errors: Manifest.DoctorManifestData['errors']): Rule.RuleStoreDataItem[];
28
- export declare function useDuplicatePackagesByErrors(errors: Manifest.DoctorManifestData['errors']): Rule.PackageRelationDiffRuleStoreData[];
23
+ export declare function useErrorsByManifest(manifest: Manifest.RsdoctorManifest): Rule.RuleStoreData;
24
+ export declare function useBundleAlertsByManifest(manifest: Manifest.RsdoctorManifest): Rule.RuleStoreDataItem[];
25
+ export declare function useDuplicatePackagesByManifest(manifest: Manifest.RsdoctorManifest): Rule.PackageRelationDiffRuleStoreData[];
26
+ export declare function useCompileAlertsByErrors(errors: Manifest.RsdoctorManifestData['errors']): Rule.RuleStoreDataItem[];
27
+ export declare function useBundleAlertsByErrors(errors: Manifest.RsdoctorManifestData['errors']): Rule.RuleStoreDataItem[];
28
+ export declare function useDuplicatePackagesByErrors(errors: Manifest.RsdoctorManifestData['errors']): Rule.PackageRelationDiffRuleStoreData[];
29
29
  export declare function useWebpackConfigurationByConfigs(configs?: SDK.ConfigData): SDK.WebpackConfigData | null | undefined;
30
- export declare function useDetectIfCloudIdeEnv(): boolean;
30
+ export declare function useDetectIfCloudIdeEnv(): boolean;
31
+ export declare function useWindowWidth(): number;
@@ -1,68 +1,19 @@
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
- var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
34
- var fulfilled = (value) => {
35
- try {
36
- step(generator.next(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- };
41
- var rejected = (value) => {
42
- try {
43
- step(generator.throw(value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
- step((generator = generator.apply(__this, __arguments)).next());
50
- });
51
- };
52
1
  import { Algorithm } from "@rsdoctor/utils/common";
53
2
  import { Client, Rule } from "@rsdoctor/types";
54
3
  import { uniqBy, isArray, defaults } from "lodash-es";
55
- import { useState } from "react";
4
+ import { useEffect, useState } from "react";
56
5
  import { useTranslation } from "react-i18next";
57
6
  import { useNavigate, useLocation } from "react-router-dom";
58
7
  import parse from "url-parse";
59
8
  import "./i18n";
60
9
  import { setLocaleToStorage } from "./storage";
61
- const route = Client.DoctorClientRoutes.RuleIndex;
10
+ const route = Client.RsdoctorClientRoutes.RuleIndex;
62
11
  const useI18n = () => {
63
- const _a = useTranslation(), { i18n } = _a, rest = __objRest(_a, ["i18n"]);
64
- return __spreadProps(__spreadValues({}, rest), {
65
- i18n: __spreadProps(__spreadValues({}, i18n), {
12
+ const { i18n, ...rest } = useTranslation();
13
+ return {
14
+ ...rest,
15
+ i18n: {
16
+ ...i18n,
66
17
  changeLanguage(lng, callback) {
67
18
  return i18n.changeLanguage(lng, (error, t) => {
68
19
  if (!error) {
@@ -71,8 +22,8 @@ const useI18n = () => {
71
22
  callback && callback(error, t);
72
23
  });
73
24
  }
74
- })
75
- });
25
+ }
26
+ };
76
27
  };
77
28
  function useRuleIndexNavigate(code, link) {
78
29
  const navigate = useNavigate();
@@ -80,7 +31,7 @@ function useRuleIndexNavigate(code, link) {
80
31
  return () => window.open(link, "__blank");
81
32
  }
82
33
  return () => {
83
- navigate(`${route}?${Rule.DoctorRuleClientConstant.UrlQueryForErrorCode}=${code}`);
34
+ navigate(`${route}?${Rule.RsdoctorRuleClientConstant.UrlQueryForErrorCode}=${code}`);
84
35
  };
85
36
  }
86
37
  function useUrlQuery() {
@@ -93,15 +44,13 @@ function useLoading(defaultLoading = false) {
93
44
  return {
94
45
  loading,
95
46
  setLoading,
96
- withLoading(func) {
97
- return __async(this, null, function* () {
98
- try {
99
- setLoading(true);
100
- yield func();
101
- } finally {
102
- setLoading(false);
103
- }
104
- });
47
+ async withLoading(func) {
48
+ try {
49
+ setLoading(true);
50
+ await func();
51
+ } finally {
52
+ setLoading(false);
53
+ }
105
54
  }
106
55
  };
107
56
  }
@@ -132,9 +81,8 @@ function useChunkGraphByManifest(manifest) {
132
81
  return ensurePlainObject(manifest.data.chunkGraph, { assets: [], chunks: [], entrypoints: [] });
133
82
  }
134
83
  function useConfigOutputFileNameByManifest(manifest) {
135
- var _a, _b, _c, _d, _e, _f, _g, _h;
136
- if (typeof ((_d = (_c = (_b = (_a = manifest.data.configs) == null ? void 0 : _a[0]) == null ? void 0 : _b.config) == null ? void 0 : _c.output) == null ? void 0 : _d.filename) === "string") {
137
- return (_h = (_g = (_f = (_e = manifest.data.configs) == null ? void 0 : _e[0]) == null ? void 0 : _f.config) == null ? void 0 : _g.output) == null ? void 0 : _h.filename;
84
+ if (typeof manifest.data.configs?.[0]?.config?.output?.filename === "string") {
85
+ return manifest.data.configs?.[0]?.config?.output?.filename;
138
86
  }
139
87
  return "";
140
88
  }
@@ -220,7 +168,7 @@ function useDuplicatePackagesByErrors(errors) {
220
168
  }
221
169
  function useWebpackConfigurationByConfigs(configs = []) {
222
170
  if (isArray(configs)) {
223
- return configs.find((e) => e.name === "webpack");
171
+ return configs.find((e) => e.name === "webpack" || e.name === "rspack");
224
172
  }
225
173
  return null;
226
174
  }
@@ -230,6 +178,17 @@ function useDetectIfCloudIdeEnv() {
230
178
  }
231
179
  return false;
232
180
  }
181
+ function useWindowWidth() {
182
+ const [windowWidth, setWindowWidth] = useState(window.innerWidth);
183
+ useEffect(() => {
184
+ const handleResize = () => setWindowWidth(window.innerWidth);
185
+ window.addEventListener("resize", handleResize);
186
+ return () => {
187
+ window.removeEventListener("resize", handleResize);
188
+ };
189
+ }, []);
190
+ return windowWidth;
191
+ }
233
192
  export {
234
193
  useBundleAlertsByErrors,
235
194
  useBundleAlertsByManifest,
@@ -252,5 +211,6 @@ export {
252
211
  useUniqModules,
253
212
  useUniqModulesByManifest,
254
213
  useUrlQuery,
255
- useWebpackConfigurationByConfigs
214
+ useWebpackConfigurationByConfigs,
215
+ useWindowWidth
256
216
  };
@@ -2,7 +2,7 @@ const cn = {
2
2
  Overall: "概览",
3
3
  "Compile Analysis": "编译分析",
4
4
  LoadersAnalysis: "Loaders 分析",
5
- "Loaders Overall": "Loaders 概览",
5
+ "Loaders Timeline": "Loaders 概览",
6
6
  "Loaders Analysis": "Loaders 分析",
7
7
  PluginsAnalysis: "Plugins 分析",
8
8
  ModuleResolve: "Module Resolve 分析",
@@ -2,7 +2,7 @@ declare const en: {
2
2
  Overall: string;
3
3
  'Compile Analysis': string;
4
4
  LoadersAnalysis: string;
5
- 'Loaders Overall': string;
5
+ 'Loaders Timeline': string;
6
6
  'Loaders Analysis': string;
7
7
  PluginsAnalysis: string;
8
8
  ModuleResolve: string;
@@ -2,7 +2,7 @@ const en = {
2
2
  Overall: "Overall",
3
3
  "Compile Analysis": "Compile Analysis",
4
4
  LoadersAnalysis: "Loaders Analysis",
5
- "Loaders Overall": "Loaders Overall",
5
+ "Loaders Timeline": "Loaders Timeline",
6
6
  "Loaders Analysis": "Loaders Analysis",
7
7
  PluginsAnalysis: "Plugins Analysis",
8
8
  ModuleResolve: "Module Resolve",
@@ -1,7 +1,7 @@
1
1
  import { ModuleGraph } from '@rsdoctor/graph';
2
2
  import { Manifest, SDK } from '@rsdoctor/types';
3
3
  import { Theme, ViewMode } from '../constants';
4
- export declare function useManifestJson(): Manifest.DoctorManifest;
4
+ export declare function useManifestJson(): Manifest.RsdoctorManifest;
5
5
  export declare function useLocale(): import("../constants").Language;
6
6
  export declare function useTheme(): {
7
7
  theme: Theme;
@@ -23,5 +23,5 @@ export declare function useViewMode(): {
23
23
  isCompileList: boolean;
24
24
  isBundleList: boolean;
25
25
  };
26
- export declare function useManifest(url: string): Manifest.DoctorManifestWithShardingFiles | undefined;
26
+ export declare function useManifest(url: string): Manifest.RsdoctorManifestWithShardingFiles | undefined;
27
27
  export declare function useModuleGraphInstanceByModuleGraph(moduleGraph: SDK.ModuleGraphData): ModuleGraph;
@@ -6,4 +6,7 @@ export declare function getRevealPositionForViewer(startLineNumber: number, star
6
6
  lineNumber: number;
7
7
  column: number;
8
8
  };
9
- export declare function getSelectionRange(source: SDK.SourceRange, Range: typeof RangeClass): RangeClass;
9
+ export declare function getSelectionRange(source: SDK.SourceRange, Range: typeof RangeClass): RangeClass;
10
+ export declare function useMonacoEditor(): {
11
+ initMonaco: (monacoRef: any) => Promise<void>;
12
+ };
@@ -1,5 +1,7 @@
1
1
  import { extname } from "path";
2
+ import { loader } from "@monaco-editor/react";
2
3
  import { isJsDataUrl } from "./url";
4
+ const monacoLoader = loader.init();
3
5
  function getOriginalLanguage(filepath) {
4
6
  if (isJsDataUrl(filepath)) {
5
7
  return "javascript";
@@ -35,14 +37,35 @@ function getRevealPositionForViewer(startLineNumber, startColumn) {
35
37
  };
36
38
  }
37
39
  function getSelectionRange(source, Range) {
38
- var _a, _b;
39
40
  const { start, end } = source;
40
41
  const { line = 1, column = 0 } = start;
41
- return new Range(line, column + 1, (_a = end == null ? void 0 : end.line) != null ? _a : line, ((_b = end == null ? void 0 : end.column) != null ? _b : 9999) + 1);
42
+ return new Range(line, column + 1, end?.line ?? line, (end?.column ?? 9999) + 1);
43
+ }
44
+ const initMonaco = (monacoRef) => {
45
+ return new Promise((resolve, reject) => {
46
+ if (monacoRef.value) {
47
+ resolve();
48
+ return;
49
+ }
50
+ monacoLoader.then((monacoInstance) => {
51
+ monacoRef.value = monacoInstance;
52
+ }).catch((error) => {
53
+ if (error?.type !== "cancelation") {
54
+ console.error("Monaco initialization error:", error);
55
+ reject();
56
+ }
57
+ });
58
+ });
59
+ };
60
+ function useMonacoEditor() {
61
+ return {
62
+ initMonaco
63
+ };
42
64
  }
43
65
  export {
44
66
  getModifiedLanguage,
45
67
  getOriginalLanguage,
46
68
  getRevealPositionForViewer,
47
- getSelectionRange
69
+ getSelectionRange,
70
+ useMonacoEditor
48
71
  };
@@ -1,23 +1,23 @@
1
1
  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
- data: Manifest.DoctorManifestData;
4
+ data: Manifest.RsdoctorManifestData;
5
5
  __LOCAL__SERVER__?: boolean | undefined;
6
6
  __SOCKET__URL__?: string | undefined;
7
- client: Manifest.DoctorManifestClient;
7
+ client: Manifest.RsdoctorManifestClient;
8
8
  name?: string | undefined;
9
- series?: Manifest.DoctorManifestSeriesData[] | undefined;
9
+ series?: Manifest.RsdoctorManifestSeriesData[] | undefined;
10
10
  }>;
11
- export declare function fetchJSONByUrl(url: string): Promise<Manifest.DoctorManifestWithShardingFiles>;
12
- export declare function fetchJSONByUrls(urls: string[]): Promise<Manifest.DoctorManifestWithShardingFiles[]>;
13
- export declare function parseManifest(json: Manifest.DoctorManifestWithShardingFiles): Promise<{
14
- data: Manifest.DoctorManifestData;
11
+ export declare function fetchJSONByUrl(url: string): Promise<Manifest.RsdoctorManifestWithShardingFiles>;
12
+ export declare function fetchJSONByUrls(urls: string[]): Promise<Manifest.RsdoctorManifestWithShardingFiles[]>;
13
+ export declare function parseManifest(json: Manifest.RsdoctorManifestWithShardingFiles): Promise<{
14
+ data: Manifest.RsdoctorManifestData;
15
15
  __LOCAL__SERVER__?: boolean | undefined;
16
16
  __SOCKET__URL__?: string | undefined;
17
- client: Manifest.DoctorManifestClient;
17
+ client: Manifest.RsdoctorManifestClient;
18
18
  name?: string | undefined;
19
- series?: Manifest.DoctorManifestSeriesData[] | undefined;
19
+ series?: Manifest.RsdoctorManifestSeriesData[] | undefined;
20
20
  }>;
21
21
  export declare function getManifestUrl(): string;
22
- export declare function fetchManifest(url?: string): Promise<Manifest.DoctorManifestWithShardingFiles>;
22
+ export declare function fetchManifest(url?: string): Promise<Manifest.RsdoctorManifestWithShardingFiles>;
23
23
  export declare function postServerAPI<T extends SDK.ServerAPI.API, B extends SDK.ServerAPI.InferRequestBodyType<T> = SDK.ServerAPI.InferRequestBodyType<T>, R extends SDK.ServerAPI.InferResponseType<T> = SDK.ServerAPI.InferResponseType<T>>(...args: B extends void ? [api: T] : [api: T, body: B]): Promise<R>;