@rsdoctor/components 0.3.11 → 0.3.12-alpha.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/dist/components/Alert/package-relation.d.ts +2 -2
- package/dist/components/Alerts/overlay.d.ts +1 -1
- package/dist/components/BundleDiff/DiffContainer/packages.d.ts +2 -2
- package/dist/components/BundleDiff/DiffContainer/row.d.ts +2 -2
- package/dist/components/BundleDiff/DiffContainer/types.d.ts +0 -1
- package/dist/components/BundleDiff/DiffServerAPIProvider/index.d.ts +0 -1
- package/dist/components/Charts/TimelineCharts/index.js +16 -2
- package/dist/components/CodeViewer/hightlight.js +24 -8
- package/dist/components/Layout/menus.d.ts +1 -1
- package/dist/config.d.ts +0 -1
- package/dist/pages/BundleSize/config.d.ts +0 -1
- package/dist/pages/TreeShaking/editor.js +8 -5
- package/dist/pages/TreeShaking/range.d.ts +282 -0
- package/dist/pages/TreeShaking/range.js +542 -0
- package/dist/pages/TreeShaking/utils.d.ts +1 -1
- package/dist/pages/TreeShaking/utils.js +1 -1
- package/dist/utils/file.d.ts +0 -1
- package/dist/utils/hooks.d.ts +0 -1
- package/dist/utils/manifest.d.ts +2 -5
- package/dist/utils/monaco.js +6 -1
- package/dist/utils/request.d.ts +6 -6
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SDK } from '@rsdoctor/types';
|
|
2
|
+
import { Rule, SDK } from '@rsdoctor/types';
|
|
3
3
|
import { PackageRelationAlertProps } from './types';
|
|
4
4
|
export declare const PackageRelationReasons: React.FC<{
|
|
5
5
|
data: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetPackageRelationAlertDetails>;
|
|
@@ -10,7 +10,7 @@ export declare const PackageRelationReasonsWithServer: React.FC<Omit<{
|
|
|
10
10
|
cwd: string;
|
|
11
11
|
}, "data"> & Partial<{
|
|
12
12
|
body: {
|
|
13
|
-
id:
|
|
13
|
+
id: Rule.RuleStoreDataItem["id"];
|
|
14
14
|
target: SDK.PackageBasicData;
|
|
15
15
|
};
|
|
16
16
|
}>>;
|
|
@@ -20,7 +20,7 @@ export declare const OverlayAlertsWithButton: React.FC<Omit<{
|
|
|
20
20
|
}>>;
|
|
21
21
|
export declare const OverlayAlertsWithTips: React.FC<Omit<{
|
|
22
22
|
alerts: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetOverlayAlerts>;
|
|
23
|
-
defaultOpen?: boolean
|
|
23
|
+
defaultOpen?: boolean;
|
|
24
24
|
}, "alerts"> & Partial<{
|
|
25
25
|
body?: any;
|
|
26
26
|
}>>;
|
|
@@ -10,8 +10,8 @@ export declare const getPackagesTableDataSource: ({ baseline, current, }: {
|
|
|
10
10
|
}) => {
|
|
11
11
|
updateType: UpdateType;
|
|
12
12
|
name: string;
|
|
13
|
-
baseline?: SDK.PackageData[]
|
|
14
|
-
current?: SDK.PackageData[]
|
|
13
|
+
baseline?: SDK.PackageData[];
|
|
14
|
+
current?: SDK.PackageData[];
|
|
15
15
|
}[];
|
|
16
16
|
export declare const Packages: React.FC<{
|
|
17
17
|
baseline: SDK.PackageGraphData;
|
|
@@ -2,8 +2,8 @@ import { ColumnGroupType, ColumnType } from 'antd/es/table/interface';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { BundleDiffComponentCardProps, BundleDiffTableAssetsData, BundleDiffTableModulesData } from './types';
|
|
4
4
|
export declare const ModuleHashPattern: RegExp;
|
|
5
|
-
export declare const getSizeColumnPropsForModuleRow: (key:
|
|
6
|
-
export declare const getTargetColumnPropsForModuleRow: (key:
|
|
5
|
+
export declare const getSizeColumnPropsForModuleRow: (key: "baseline" | "current", sizeKey: "parsedSize" | "sourceSize") => ColumnType<BundleDiffTableModulesData>;
|
|
6
|
+
export declare const getTargetColumnPropsForModuleRow: (key: "baseline" | "current", bMoudlesCount: number, cMoudlesCount: number) => ColumnGroupType<BundleDiffTableModulesData>;
|
|
7
7
|
export declare const ModuleRowForAsset: React.FC<{
|
|
8
8
|
data: BundleDiffTableAssetsData;
|
|
9
9
|
} & Pick<BundleDiffComponentCardProps, 'baseline' | 'current'>>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { SDK } from '@rsdoctor/types';
|
|
3
2
|
import { BundleDiffServerAPIProviderComponentCommonProps } from '../DiffContainer/types';
|
|
4
3
|
export declare const DiffServerAPIProvider: <T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(props: BundleDiffServerAPIProviderComponentCommonProps<T>) => JSX.Element;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect, memo } from "react";
|
|
3
|
-
import
|
|
3
|
+
import ReactEChartsCore from "echarts-for-react/lib/core";
|
|
4
4
|
import * as echarts from "echarts/core";
|
|
5
|
+
import { CustomChart } from "echarts/charts";
|
|
6
|
+
import {
|
|
7
|
+
TooltipComponent,
|
|
8
|
+
GridComponent,
|
|
9
|
+
DataZoomComponent
|
|
10
|
+
} from "echarts/components";
|
|
11
|
+
import { CanvasRenderer } from "echarts/renderers";
|
|
5
12
|
import dayjs from "dayjs";
|
|
6
13
|
import { groupBy } from "lodash-es";
|
|
7
14
|
import { LITTLE_PALETTE_COLORS, PALETTE_COLORS } from "../constants";
|
|
@@ -10,6 +17,13 @@ const TimelineCom = memo(({ loaderData, pluginsData, formatterFn, chartType = "n
|
|
|
10
17
|
const data = [];
|
|
11
18
|
let categories = [];
|
|
12
19
|
const [optionsData, setOptinsData] = useState({});
|
|
20
|
+
echarts.use([
|
|
21
|
+
CustomChart,
|
|
22
|
+
TooltipComponent,
|
|
23
|
+
GridComponent,
|
|
24
|
+
DataZoomComponent,
|
|
25
|
+
CanvasRenderer
|
|
26
|
+
]);
|
|
13
27
|
useEffect(() => {
|
|
14
28
|
if (!loaderData)
|
|
15
29
|
return;
|
|
@@ -199,7 +213,7 @@ const TimelineCom = memo(({ loaderData, pluginsData, formatterFn, chartType = "n
|
|
|
199
213
|
setOptinsData(option);
|
|
200
214
|
}, [loaderData, pluginsData]);
|
|
201
215
|
return /* @__PURE__ */ jsx(
|
|
202
|
-
|
|
216
|
+
ReactEChartsCore,
|
|
203
217
|
{
|
|
204
218
|
option: optionsData,
|
|
205
219
|
echarts,
|
|
@@ -3,9 +3,19 @@ import { useRef } from "react";
|
|
|
3
3
|
import { Space, Card, Tooltip } from "antd";
|
|
4
4
|
import { InfoCircleOutlined } from "@ant-design/icons";
|
|
5
5
|
import Editor from "@monaco-editor/react";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getOriginalLanguage,
|
|
8
|
+
beautifyModulePath,
|
|
9
|
+
getSelectionRange,
|
|
10
|
+
getRevealPositionForViewer
|
|
11
|
+
} from "../../utils";
|
|
7
12
|
import { CodeOpener } from "../Opener";
|
|
8
|
-
const FileHightLightViewer = ({
|
|
13
|
+
const FileHightLightViewer = ({
|
|
14
|
+
dependency,
|
|
15
|
+
module,
|
|
16
|
+
cwd,
|
|
17
|
+
moduleCode
|
|
18
|
+
}) => {
|
|
9
19
|
const editorRef = useRef(null);
|
|
10
20
|
if (!dependency)
|
|
11
21
|
return null;
|
|
@@ -14,12 +24,18 @@ const FileHightLightViewer = ({ dependency, module, cwd, moduleCode }) => {
|
|
|
14
24
|
const { start, end } = statements?.[0]?.position ? hasSourceRange ? statements[0].position.source : statements[0].position.transformed : { start: { line: 0, column: 0 }, end: { line: 0, column: 0 } };
|
|
15
25
|
const content = hasSourceRange ? moduleCode?.source : moduleCode?.transformed || moduleCode?.source;
|
|
16
26
|
const modulePath = module.path;
|
|
17
|
-
const handleEditorDidMount = (
|
|
18
|
-
editorRef.current =
|
|
19
|
-
const range = getSelectionRange(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
const handleEditorDidMount = (editor, monaco) => {
|
|
28
|
+
editorRef.current = editor;
|
|
29
|
+
const range = getSelectionRange(
|
|
30
|
+
{ start, end },
|
|
31
|
+
monaco.Range
|
|
32
|
+
);
|
|
33
|
+
const position = getRevealPositionForViewer(
|
|
34
|
+
range.startLineNumber,
|
|
35
|
+
range.startColumn
|
|
36
|
+
);
|
|
37
|
+
editor.revealPositionInCenter(position);
|
|
38
|
+
editor.deltaDecorations(
|
|
23
39
|
[],
|
|
24
40
|
[
|
|
25
41
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Manifest } from '@rsdoctor/types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export declare const Menus: React.FC<Omit<{
|
|
4
|
-
style?: React.CSSProperties
|
|
4
|
+
style?: React.CSSProperties;
|
|
5
5
|
routes: Manifest.RsdoctorManifestClientRoutes[];
|
|
6
6
|
}, "routes"> & Partial<{
|
|
7
7
|
body?: any;
|
package/dist/config.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import path from "path-browserify";
|
|
|
4
4
|
import { Card, Space, Tooltip, Typography } from "antd";
|
|
5
5
|
import { InfoCircleOutlined, LoadingOutlined } from "@ant-design/icons";
|
|
6
6
|
import Editor from "@monaco-editor/react";
|
|
7
|
-
import { Range
|
|
7
|
+
import { Range } from "./range";
|
|
8
8
|
import { parseOpenTag } from "./open-tag";
|
|
9
9
|
import { getHoverMessageInModule } from "./utils";
|
|
10
10
|
import { getOriginalLanguage, getSelectionRange } from "../../utils";
|
|
@@ -40,7 +40,10 @@ function CodeEditor(props) {
|
|
|
40
40
|
oldRanges.current,
|
|
41
41
|
ranges.map((arr) => {
|
|
42
42
|
return {
|
|
43
|
-
range: getSelectionRange(
|
|
43
|
+
range: getSelectionRange(
|
|
44
|
+
arr,
|
|
45
|
+
Range
|
|
46
|
+
),
|
|
44
47
|
options: {
|
|
45
48
|
stickiness: 1,
|
|
46
49
|
inlineClassName: "tree-shaking-statement-side-effect",
|
|
@@ -52,7 +55,7 @@ function CodeEditor(props) {
|
|
|
52
55
|
);
|
|
53
56
|
if (editorRef.current && typeof toLine === "number" && oldToLine.current !== toLine) {
|
|
54
57
|
oldToLine.current = toLine;
|
|
55
|
-
editorRef.current.revealLine(toLine,
|
|
58
|
+
editorRef.current.revealLine(toLine, 0);
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
if (changeModule) {
|
|
@@ -80,8 +83,8 @@ function CodeEditor(props) {
|
|
|
80
83
|
if (!module) {
|
|
81
84
|
return /* @__PURE__ */ jsx("div", { children: "请选择要查看的模块" });
|
|
82
85
|
}
|
|
83
|
-
const handleEditorDidMount = (
|
|
84
|
-
editorRef.current =
|
|
86
|
+
const handleEditorDidMount = (editor) => {
|
|
87
|
+
editorRef.current = editor;
|
|
85
88
|
};
|
|
86
89
|
return /* @__PURE__ */ jsx(
|
|
87
90
|
Card,
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The following is modified based on source found in
|
|
3
|
+
* https://github.com/microsoft/monaco-editor
|
|
4
|
+
*
|
|
5
|
+
* MIT Licensed
|
|
6
|
+
* Copyright (c) 2016 - present Microsoft Corporation
|
|
7
|
+
* https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
|
|
8
|
+
*/
|
|
9
|
+
export declare class Range {
|
|
10
|
+
startLineNumber: number;
|
|
11
|
+
startColumn: number;
|
|
12
|
+
endLineNumber: number;
|
|
13
|
+
endColumn: number;
|
|
14
|
+
constructor(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number);
|
|
15
|
+
/**
|
|
16
|
+
* Test if this range is empty.
|
|
17
|
+
*/
|
|
18
|
+
isEmpty(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Test if `range` is empty.
|
|
21
|
+
*/
|
|
22
|
+
static isEmpty(range: Range): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Test if position is in this range. If the position is at the edges, will return true.
|
|
25
|
+
*/
|
|
26
|
+
containsPosition(position: any): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Test if `position` is in `range`. If the position is at the edges, will return true.
|
|
29
|
+
*/
|
|
30
|
+
static containsPosition(range: Range, position: {
|
|
31
|
+
lineNumber: number;
|
|
32
|
+
column: number;
|
|
33
|
+
}): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Test if `position` is in `range`. If the position is at the edges, will return false.
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
static strictContainsPosition(range: Range, position: {
|
|
39
|
+
lineNumber: number;
|
|
40
|
+
column: number;
|
|
41
|
+
}): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Test if range is in this range. If the range is equal to this range, will return true.
|
|
44
|
+
*/
|
|
45
|
+
containsRange(range: Range): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Test if `otherRange` is in `range`. If the ranges are equal, will return true.
|
|
48
|
+
*/
|
|
49
|
+
static containsRange(range: Range, otherRange: {
|
|
50
|
+
startLineNumber: number;
|
|
51
|
+
endLineNumber: number;
|
|
52
|
+
startColumn: number;
|
|
53
|
+
endColumn: number;
|
|
54
|
+
}): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Test if `range` is strictly in this range. `range` must start after and end before this range for the result to be true.
|
|
57
|
+
*/
|
|
58
|
+
strictContainsRange(range: Range): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Test if `otherRange` is strictly in `range` (must start after, and end before). If the ranges are equal, will return false.
|
|
61
|
+
*/
|
|
62
|
+
static strictContainsRange(range: Range, otherRange: {
|
|
63
|
+
startLineNumber: number;
|
|
64
|
+
endLineNumber: number;
|
|
65
|
+
startColumn: number;
|
|
66
|
+
endColumn: number;
|
|
67
|
+
}): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* A reunion of the two ranges.
|
|
70
|
+
* The smallest position will be used as the start point, and the largest one as the end point.
|
|
71
|
+
*/
|
|
72
|
+
plusRange(range: Range): Range;
|
|
73
|
+
/**
|
|
74
|
+
* A reunion of the two ranges.
|
|
75
|
+
* The smallest position will be used as the start point, and the largest one as the end point.
|
|
76
|
+
*/
|
|
77
|
+
static plusRange(a: Range, b: Range): Range;
|
|
78
|
+
/**
|
|
79
|
+
* A intersection of the two ranges.
|
|
80
|
+
*/
|
|
81
|
+
intersectRanges(range: Range): Range | null;
|
|
82
|
+
/**
|
|
83
|
+
* A intersection of the two ranges.
|
|
84
|
+
*/
|
|
85
|
+
static intersectRanges(a: Range, b: Range): Range | null;
|
|
86
|
+
/**
|
|
87
|
+
* Test if this range equals other.
|
|
88
|
+
*/
|
|
89
|
+
equalsRange(other: Range): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Test if range `a` equals `b`.
|
|
92
|
+
*/
|
|
93
|
+
static equalsRange(a: Range, b: Range): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Return the end position (which will be after or equal to the start position)
|
|
96
|
+
*/
|
|
97
|
+
getEndPosition(): Position;
|
|
98
|
+
/**
|
|
99
|
+
* Return the end position (which will be after or equal to the start position)
|
|
100
|
+
*/
|
|
101
|
+
static getEndPosition(range: Range): Position;
|
|
102
|
+
/**
|
|
103
|
+
* Return the start position (which will be before or equal to the end position)
|
|
104
|
+
*/
|
|
105
|
+
getStartPosition(): Position;
|
|
106
|
+
/**
|
|
107
|
+
* Return the start position (which will be before or equal to the end position)
|
|
108
|
+
*/
|
|
109
|
+
static getStartPosition(range: Range): Position;
|
|
110
|
+
/**
|
|
111
|
+
* Transform to a user presentable string representation.
|
|
112
|
+
*/
|
|
113
|
+
toString(): string;
|
|
114
|
+
/**
|
|
115
|
+
* Create a new range using this range's start position, and using endLineNumber and endColumn as the end position.
|
|
116
|
+
*/
|
|
117
|
+
setEndPosition(endLineNumber: number, endColumn: number): Range;
|
|
118
|
+
/**
|
|
119
|
+
* Create a new range using this range's end position, and using startLineNumber and startColumn as the start position.
|
|
120
|
+
*/
|
|
121
|
+
setStartPosition(startLineNumber: number, startColumn: number): Range;
|
|
122
|
+
/**
|
|
123
|
+
* Create a new empty range using this range's start position.
|
|
124
|
+
*/
|
|
125
|
+
collapseToStart(): Range;
|
|
126
|
+
/**
|
|
127
|
+
* Create a new empty range using this range's start position.
|
|
128
|
+
*/
|
|
129
|
+
static collapseToStart(range: Range): Range;
|
|
130
|
+
/**
|
|
131
|
+
* Create a new empty range using this range's end position.
|
|
132
|
+
*/
|
|
133
|
+
collapseToEnd(): Range;
|
|
134
|
+
/**
|
|
135
|
+
* Create a new empty range using this range's end position.
|
|
136
|
+
*/
|
|
137
|
+
static collapseToEnd(range: Range): Range;
|
|
138
|
+
/**
|
|
139
|
+
* Moves the range by the given amount of lines.
|
|
140
|
+
*/
|
|
141
|
+
delta(lineCount: number): Range;
|
|
142
|
+
static fromPositions(start: {
|
|
143
|
+
lineNumber: number;
|
|
144
|
+
column: number;
|
|
145
|
+
}, end?: {
|
|
146
|
+
lineNumber: number;
|
|
147
|
+
column: number;
|
|
148
|
+
}): Range;
|
|
149
|
+
static lift(range: Range): Range | null;
|
|
150
|
+
/**
|
|
151
|
+
* Test if `obj` is an `IRange`.
|
|
152
|
+
*/
|
|
153
|
+
static isIRange(obj: Range): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Test if the two ranges are touching in any way.
|
|
156
|
+
*/
|
|
157
|
+
static areIntersectingOrTouching(a: Range, b: Range): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Test if the two ranges are intersecting. If the ranges are touching it returns true.
|
|
160
|
+
*/
|
|
161
|
+
static areIntersecting(a: Range, b: Range): boolean;
|
|
162
|
+
/**
|
|
163
|
+
* A function that compares ranges, useful for sorting ranges
|
|
164
|
+
* It will first compare ranges on the startPosition and then on the endPosition
|
|
165
|
+
*/
|
|
166
|
+
static compareRangesUsingStarts(a: Range, b: Range): number;
|
|
167
|
+
/**
|
|
168
|
+
* A function that compares ranges, useful for sorting ranges
|
|
169
|
+
* It will first compare ranges on the endPosition and then on the startPosition
|
|
170
|
+
*/
|
|
171
|
+
static compareRangesUsingEnds(a: {
|
|
172
|
+
endLineNumber: number;
|
|
173
|
+
endColumn: number;
|
|
174
|
+
startLineNumber: number;
|
|
175
|
+
startColumn: number;
|
|
176
|
+
}, b: {
|
|
177
|
+
endLineNumber: number;
|
|
178
|
+
endColumn: number;
|
|
179
|
+
startLineNumber: number;
|
|
180
|
+
startColumn: number;
|
|
181
|
+
}): number;
|
|
182
|
+
/**
|
|
183
|
+
* Test if the range spans multiple lines.
|
|
184
|
+
*/
|
|
185
|
+
static spansMultipleLines(range: Range): boolean;
|
|
186
|
+
toJSON(): this;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* A position in the editor.
|
|
190
|
+
*/
|
|
191
|
+
export declare class Position {
|
|
192
|
+
lineNumber: number;
|
|
193
|
+
column: number;
|
|
194
|
+
constructor(lineNumber: number, column: number);
|
|
195
|
+
/**
|
|
196
|
+
* Create a new position from this position.
|
|
197
|
+
*
|
|
198
|
+
* @param newLineNumber new line number
|
|
199
|
+
* @param newColumn new column
|
|
200
|
+
*/
|
|
201
|
+
with(newLineNumber?: number, newColumn?: number): Position;
|
|
202
|
+
/**
|
|
203
|
+
* Derive a new position from this position.
|
|
204
|
+
*
|
|
205
|
+
* @param deltaLineNumber line number delta
|
|
206
|
+
* @param deltaColumn column delta
|
|
207
|
+
*/
|
|
208
|
+
delta(deltaLineNumber?: number, deltaColumn?: number): Position;
|
|
209
|
+
/**
|
|
210
|
+
* Test if this position equals other position
|
|
211
|
+
*/
|
|
212
|
+
equals(other: any): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Test if position `a` equals position `b`
|
|
215
|
+
*/
|
|
216
|
+
static equals(a: any, b: {
|
|
217
|
+
lineNumber: any;
|
|
218
|
+
column: any;
|
|
219
|
+
}): boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Test if this position is before other position.
|
|
222
|
+
* If the two positions are equal, the result will be false.
|
|
223
|
+
*/
|
|
224
|
+
isBefore(other: any): boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Test if position `a` is before position `b`.
|
|
227
|
+
* If the two positions are equal, the result will be false.
|
|
228
|
+
*/
|
|
229
|
+
static isBefore(a: any, b: {
|
|
230
|
+
lineNumber: number;
|
|
231
|
+
column: number;
|
|
232
|
+
}): boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Test if this position is before other position.
|
|
235
|
+
* If the two positions are equal, the result will be true.
|
|
236
|
+
*/
|
|
237
|
+
isBeforeOrEqual(other: any): boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Test if position `a` is before position `b`.
|
|
240
|
+
* If the two positions are equal, the result will be true.
|
|
241
|
+
*/
|
|
242
|
+
static isBeforeOrEqual(a: any, b: {
|
|
243
|
+
lineNumber: number;
|
|
244
|
+
column: number;
|
|
245
|
+
}): boolean;
|
|
246
|
+
/**
|
|
247
|
+
* A function that compares positions, useful for sorting
|
|
248
|
+
*/
|
|
249
|
+
static compare(a: {
|
|
250
|
+
lineNumber: number;
|
|
251
|
+
column: number;
|
|
252
|
+
}, b: {
|
|
253
|
+
lineNumber: number;
|
|
254
|
+
column: number;
|
|
255
|
+
}): number;
|
|
256
|
+
/**
|
|
257
|
+
* Clone this position.
|
|
258
|
+
*/
|
|
259
|
+
clone(): Position;
|
|
260
|
+
/**
|
|
261
|
+
* Convert to a human-readable representation.
|
|
262
|
+
*/
|
|
263
|
+
toString(): string;
|
|
264
|
+
/**
|
|
265
|
+
* Create a `Position` from an `IPosition`.
|
|
266
|
+
*/
|
|
267
|
+
static lift(pos: {
|
|
268
|
+
lineNumber: any;
|
|
269
|
+
column: any;
|
|
270
|
+
}): Position;
|
|
271
|
+
/**
|
|
272
|
+
* Test if `obj` is an `IPosition`.
|
|
273
|
+
*/
|
|
274
|
+
static isIPosition(obj: {
|
|
275
|
+
lineNumber: any;
|
|
276
|
+
column: any;
|
|
277
|
+
}): boolean;
|
|
278
|
+
toJSON(): {
|
|
279
|
+
lineNumber: number;
|
|
280
|
+
column: number;
|
|
281
|
+
};
|
|
282
|
+
}
|
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
class Range {
|
|
2
|
+
constructor(startLineNumber, startColumn, endLineNumber, endColumn) {
|
|
3
|
+
if (startLineNumber > endLineNumber || startLineNumber === endLineNumber && startColumn > endColumn) {
|
|
4
|
+
this.startLineNumber = endLineNumber;
|
|
5
|
+
this.startColumn = endColumn;
|
|
6
|
+
this.endLineNumber = startLineNumber;
|
|
7
|
+
this.endColumn = startColumn;
|
|
8
|
+
} else {
|
|
9
|
+
this.startLineNumber = startLineNumber;
|
|
10
|
+
this.startColumn = startColumn;
|
|
11
|
+
this.endLineNumber = endLineNumber;
|
|
12
|
+
this.endColumn = endColumn;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Test if this range is empty.
|
|
17
|
+
*/
|
|
18
|
+
isEmpty() {
|
|
19
|
+
return Range.isEmpty(this);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Test if `range` is empty.
|
|
23
|
+
*/
|
|
24
|
+
static isEmpty(range) {
|
|
25
|
+
return range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Test if position is in this range. If the position is at the edges, will return true.
|
|
29
|
+
*/
|
|
30
|
+
containsPosition(position) {
|
|
31
|
+
return Range.containsPosition(this, position);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Test if `position` is in `range`. If the position is at the edges, will return true.
|
|
35
|
+
*/
|
|
36
|
+
static containsPosition(range, position) {
|
|
37
|
+
if (position.lineNumber < range.startLineNumber || position.lineNumber > range.endLineNumber) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (position.lineNumber === range.startLineNumber && position.column < range.startColumn) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (position.lineNumber === range.endLineNumber && position.column > range.endColumn) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Test if `position` is in `range`. If the position is at the edges, will return false.
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
static strictContainsPosition(range, position) {
|
|
53
|
+
if (position.lineNumber < range.startLineNumber || position.lineNumber > range.endLineNumber) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (position.lineNumber === range.startLineNumber && position.column <= range.startColumn) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (position.lineNumber === range.endLineNumber && position.column >= range.endColumn) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Test if range is in this range. If the range is equal to this range, will return true.
|
|
66
|
+
*/
|
|
67
|
+
containsRange(range) {
|
|
68
|
+
return Range.containsRange(this, range);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Test if `otherRange` is in `range`. If the ranges are equal, will return true.
|
|
72
|
+
*/
|
|
73
|
+
static containsRange(range, otherRange) {
|
|
74
|
+
if (otherRange.startLineNumber < range.startLineNumber || otherRange.endLineNumber < range.startLineNumber) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (otherRange.startLineNumber > range.endLineNumber || otherRange.endLineNumber > range.endLineNumber) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (otherRange.startLineNumber === range.startLineNumber && otherRange.startColumn < range.startColumn) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (otherRange.endLineNumber === range.endLineNumber && otherRange.endColumn > range.endColumn) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Test if `range` is strictly in this range. `range` must start after and end before this range for the result to be true.
|
|
90
|
+
*/
|
|
91
|
+
strictContainsRange(range) {
|
|
92
|
+
return Range.strictContainsRange(this, range);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Test if `otherRange` is strictly in `range` (must start after, and end before). If the ranges are equal, will return false.
|
|
96
|
+
*/
|
|
97
|
+
static strictContainsRange(range, otherRange) {
|
|
98
|
+
if (otherRange.startLineNumber < range.startLineNumber || otherRange.endLineNumber < range.startLineNumber) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if (otherRange.startLineNumber > range.endLineNumber || otherRange.endLineNumber > range.endLineNumber) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
if (otherRange.startLineNumber === range.startLineNumber && otherRange.startColumn <= range.startColumn) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (otherRange.endLineNumber === range.endLineNumber && otherRange.endColumn >= range.endColumn) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A reunion of the two ranges.
|
|
114
|
+
* The smallest position will be used as the start point, and the largest one as the end point.
|
|
115
|
+
*/
|
|
116
|
+
plusRange(range) {
|
|
117
|
+
return Range.plusRange(this, range);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A reunion of the two ranges.
|
|
121
|
+
* The smallest position will be used as the start point, and the largest one as the end point.
|
|
122
|
+
*/
|
|
123
|
+
static plusRange(a, b) {
|
|
124
|
+
let startLineNumber;
|
|
125
|
+
let startColumn;
|
|
126
|
+
let endLineNumber;
|
|
127
|
+
let endColumn;
|
|
128
|
+
if (b.startLineNumber < a.startLineNumber) {
|
|
129
|
+
startLineNumber = b.startLineNumber;
|
|
130
|
+
startColumn = b.startColumn;
|
|
131
|
+
} else if (b.startLineNumber === a.startLineNumber) {
|
|
132
|
+
startLineNumber = b.startLineNumber;
|
|
133
|
+
startColumn = Math.min(b.startColumn, a.startColumn);
|
|
134
|
+
} else {
|
|
135
|
+
startLineNumber = a.startLineNumber;
|
|
136
|
+
startColumn = a.startColumn;
|
|
137
|
+
}
|
|
138
|
+
if (b.endLineNumber > a.endLineNumber) {
|
|
139
|
+
endLineNumber = b.endLineNumber;
|
|
140
|
+
endColumn = b.endColumn;
|
|
141
|
+
} else if (b.endLineNumber === a.endLineNumber) {
|
|
142
|
+
endLineNumber = b.endLineNumber;
|
|
143
|
+
endColumn = Math.max(b.endColumn, a.endColumn);
|
|
144
|
+
} else {
|
|
145
|
+
endLineNumber = a.endLineNumber;
|
|
146
|
+
endColumn = a.endColumn;
|
|
147
|
+
}
|
|
148
|
+
return new Range(startLineNumber, startColumn, endLineNumber, endColumn);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* A intersection of the two ranges.
|
|
152
|
+
*/
|
|
153
|
+
intersectRanges(range) {
|
|
154
|
+
return Range.intersectRanges(this, range);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A intersection of the two ranges.
|
|
158
|
+
*/
|
|
159
|
+
static intersectRanges(a, b) {
|
|
160
|
+
let resultStartLineNumber = a.startLineNumber;
|
|
161
|
+
let resultStartColumn = a.startColumn;
|
|
162
|
+
let resultEndLineNumber = a.endLineNumber;
|
|
163
|
+
let resultEndColumn = a.endColumn;
|
|
164
|
+
const otherStartLineNumber = b.startLineNumber;
|
|
165
|
+
const otherStartColumn = b.startColumn;
|
|
166
|
+
const otherEndLineNumber = b.endLineNumber;
|
|
167
|
+
const otherEndColumn = b.endColumn;
|
|
168
|
+
if (resultStartLineNumber < otherStartLineNumber) {
|
|
169
|
+
resultStartLineNumber = otherStartLineNumber;
|
|
170
|
+
resultStartColumn = otherStartColumn;
|
|
171
|
+
} else if (resultStartLineNumber === otherStartLineNumber) {
|
|
172
|
+
resultStartColumn = Math.max(resultStartColumn, otherStartColumn);
|
|
173
|
+
}
|
|
174
|
+
if (resultEndLineNumber > otherEndLineNumber) {
|
|
175
|
+
resultEndLineNumber = otherEndLineNumber;
|
|
176
|
+
resultEndColumn = otherEndColumn;
|
|
177
|
+
} else if (resultEndLineNumber === otherEndLineNumber) {
|
|
178
|
+
resultEndColumn = Math.min(resultEndColumn, otherEndColumn);
|
|
179
|
+
}
|
|
180
|
+
if (resultStartLineNumber > resultEndLineNumber) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
if (resultStartLineNumber === resultEndLineNumber && resultStartColumn > resultEndColumn) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
return new Range(
|
|
187
|
+
resultStartLineNumber,
|
|
188
|
+
resultStartColumn,
|
|
189
|
+
resultEndLineNumber,
|
|
190
|
+
resultEndColumn
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Test if this range equals other.
|
|
195
|
+
*/
|
|
196
|
+
equalsRange(other) {
|
|
197
|
+
return Range.equalsRange(this, other);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Test if range `a` equals `b`.
|
|
201
|
+
*/
|
|
202
|
+
static equalsRange(a, b) {
|
|
203
|
+
if (!a && !b) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
return !!a && !!b && a.startLineNumber === b.startLineNumber && a.startColumn === b.startColumn && a.endLineNumber === b.endLineNumber && a.endColumn === b.endColumn;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Return the end position (which will be after or equal to the start position)
|
|
210
|
+
*/
|
|
211
|
+
getEndPosition() {
|
|
212
|
+
return Range.getEndPosition(this);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Return the end position (which will be after or equal to the start position)
|
|
216
|
+
*/
|
|
217
|
+
static getEndPosition(range) {
|
|
218
|
+
return new Position(range.endLineNumber, range.endColumn);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Return the start position (which will be before or equal to the end position)
|
|
222
|
+
*/
|
|
223
|
+
getStartPosition() {
|
|
224
|
+
return Range.getStartPosition(this);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Return the start position (which will be before or equal to the end position)
|
|
228
|
+
*/
|
|
229
|
+
static getStartPosition(range) {
|
|
230
|
+
return new Position(range.startLineNumber, range.startColumn);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Transform to a user presentable string representation.
|
|
234
|
+
*/
|
|
235
|
+
toString() {
|
|
236
|
+
return `[${this.startLineNumber},${this.startColumn} -> ${this.endLineNumber},${this.endColumn}]`;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Create a new range using this range's start position, and using endLineNumber and endColumn as the end position.
|
|
240
|
+
*/
|
|
241
|
+
setEndPosition(endLineNumber, endColumn) {
|
|
242
|
+
return new Range(
|
|
243
|
+
this.startLineNumber,
|
|
244
|
+
this.startColumn,
|
|
245
|
+
endLineNumber,
|
|
246
|
+
endColumn
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Create a new range using this range's end position, and using startLineNumber and startColumn as the start position.
|
|
251
|
+
*/
|
|
252
|
+
setStartPosition(startLineNumber, startColumn) {
|
|
253
|
+
return new Range(
|
|
254
|
+
startLineNumber,
|
|
255
|
+
startColumn,
|
|
256
|
+
this.endLineNumber,
|
|
257
|
+
this.endColumn
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Create a new empty range using this range's start position.
|
|
262
|
+
*/
|
|
263
|
+
collapseToStart() {
|
|
264
|
+
return Range.collapseToStart(this);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Create a new empty range using this range's start position.
|
|
268
|
+
*/
|
|
269
|
+
static collapseToStart(range) {
|
|
270
|
+
return new Range(
|
|
271
|
+
range.startLineNumber,
|
|
272
|
+
range.startColumn,
|
|
273
|
+
range.startLineNumber,
|
|
274
|
+
range.startColumn
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Create a new empty range using this range's end position.
|
|
279
|
+
*/
|
|
280
|
+
collapseToEnd() {
|
|
281
|
+
return Range.collapseToEnd(this);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Create a new empty range using this range's end position.
|
|
285
|
+
*/
|
|
286
|
+
static collapseToEnd(range) {
|
|
287
|
+
return new Range(
|
|
288
|
+
range.endLineNumber,
|
|
289
|
+
range.endColumn,
|
|
290
|
+
range.endLineNumber,
|
|
291
|
+
range.endColumn
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Moves the range by the given amount of lines.
|
|
296
|
+
*/
|
|
297
|
+
delta(lineCount) {
|
|
298
|
+
return new Range(
|
|
299
|
+
this.startLineNumber + lineCount,
|
|
300
|
+
this.startColumn,
|
|
301
|
+
this.endLineNumber + lineCount,
|
|
302
|
+
this.endColumn
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
// ---
|
|
306
|
+
static fromPositions(start, end = start) {
|
|
307
|
+
return new Range(
|
|
308
|
+
start.lineNumber,
|
|
309
|
+
start.column,
|
|
310
|
+
end.lineNumber,
|
|
311
|
+
end.column
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
static lift(range) {
|
|
315
|
+
if (!range) {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
return new Range(
|
|
319
|
+
range.startLineNumber,
|
|
320
|
+
range.startColumn,
|
|
321
|
+
range.endLineNumber,
|
|
322
|
+
range.endColumn
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Test if `obj` is an `IRange`.
|
|
327
|
+
*/
|
|
328
|
+
static isIRange(obj) {
|
|
329
|
+
return obj && typeof obj.startLineNumber === "number" && typeof obj.startColumn === "number" && typeof obj.endLineNumber === "number" && typeof obj.endColumn === "number";
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Test if the two ranges are touching in any way.
|
|
333
|
+
*/
|
|
334
|
+
static areIntersectingOrTouching(a, b) {
|
|
335
|
+
if (a.endLineNumber < b.startLineNumber || a.endLineNumber === b.startLineNumber && a.endColumn < b.startColumn) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
if (b.endLineNumber < a.startLineNumber || b.endLineNumber === a.startLineNumber && b.endColumn < a.startColumn) {
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Test if the two ranges are intersecting. If the ranges are touching it returns true.
|
|
345
|
+
*/
|
|
346
|
+
static areIntersecting(a, b) {
|
|
347
|
+
if (a.endLineNumber < b.startLineNumber || a.endLineNumber === b.startLineNumber && a.endColumn <= b.startColumn) {
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
if (b.endLineNumber < a.startLineNumber || b.endLineNumber === a.startLineNumber && b.endColumn <= a.startColumn) {
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* A function that compares ranges, useful for sorting ranges
|
|
357
|
+
* It will first compare ranges on the startPosition and then on the endPosition
|
|
358
|
+
*/
|
|
359
|
+
static compareRangesUsingStarts(a, b) {
|
|
360
|
+
if (a && b) {
|
|
361
|
+
const aStartLineNumber = a.startLineNumber | 0;
|
|
362
|
+
const bStartLineNumber = b.startLineNumber | 0;
|
|
363
|
+
if (aStartLineNumber === bStartLineNumber) {
|
|
364
|
+
const aStartColumn = a.startColumn | 0;
|
|
365
|
+
const bStartColumn = b.startColumn | 0;
|
|
366
|
+
if (aStartColumn === bStartColumn) {
|
|
367
|
+
const aEndLineNumber = a.endLineNumber | 0;
|
|
368
|
+
const bEndLineNumber = b.endLineNumber | 0;
|
|
369
|
+
if (aEndLineNumber === bEndLineNumber) {
|
|
370
|
+
const aEndColumn = a.endColumn | 0;
|
|
371
|
+
const bEndColumn = b.endColumn | 0;
|
|
372
|
+
return aEndColumn - bEndColumn;
|
|
373
|
+
}
|
|
374
|
+
return aEndLineNumber - bEndLineNumber;
|
|
375
|
+
}
|
|
376
|
+
return aStartColumn - bStartColumn;
|
|
377
|
+
}
|
|
378
|
+
return aStartLineNumber - bStartLineNumber;
|
|
379
|
+
}
|
|
380
|
+
const aExists = a ? 1 : 0;
|
|
381
|
+
const bExists = b ? 1 : 0;
|
|
382
|
+
return aExists - bExists;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* A function that compares ranges, useful for sorting ranges
|
|
386
|
+
* It will first compare ranges on the endPosition and then on the startPosition
|
|
387
|
+
*/
|
|
388
|
+
static compareRangesUsingEnds(a, b) {
|
|
389
|
+
if (a.endLineNumber === b.endLineNumber) {
|
|
390
|
+
if (a.endColumn === b.endColumn) {
|
|
391
|
+
if (a.startLineNumber === b.startLineNumber) {
|
|
392
|
+
return a.startColumn - b.startColumn;
|
|
393
|
+
}
|
|
394
|
+
return a.startLineNumber - b.startLineNumber;
|
|
395
|
+
}
|
|
396
|
+
return a.endColumn - b.endColumn;
|
|
397
|
+
}
|
|
398
|
+
return a.endLineNumber - b.endLineNumber;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Test if the range spans multiple lines.
|
|
402
|
+
*/
|
|
403
|
+
static spansMultipleLines(range) {
|
|
404
|
+
return range.endLineNumber > range.startLineNumber;
|
|
405
|
+
}
|
|
406
|
+
toJSON() {
|
|
407
|
+
return this;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
class Position {
|
|
411
|
+
constructor(lineNumber, column) {
|
|
412
|
+
this.lineNumber = lineNumber;
|
|
413
|
+
this.column = column;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Create a new position from this position.
|
|
417
|
+
*
|
|
418
|
+
* @param newLineNumber new line number
|
|
419
|
+
* @param newColumn new column
|
|
420
|
+
*/
|
|
421
|
+
with(newLineNumber = this.lineNumber, newColumn = this.column) {
|
|
422
|
+
if (newLineNumber === this.lineNumber && newColumn === this.column) {
|
|
423
|
+
return this;
|
|
424
|
+
}
|
|
425
|
+
return new Position(newLineNumber, newColumn);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Derive a new position from this position.
|
|
429
|
+
*
|
|
430
|
+
* @param deltaLineNumber line number delta
|
|
431
|
+
* @param deltaColumn column delta
|
|
432
|
+
*/
|
|
433
|
+
delta(deltaLineNumber = 0, deltaColumn = 0) {
|
|
434
|
+
return this.with(
|
|
435
|
+
this.lineNumber + deltaLineNumber,
|
|
436
|
+
this.column + deltaColumn
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Test if this position equals other position
|
|
441
|
+
*/
|
|
442
|
+
equals(other) {
|
|
443
|
+
return Position.equals(this, other);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Test if position `a` equals position `b`
|
|
447
|
+
*/
|
|
448
|
+
static equals(a, b) {
|
|
449
|
+
if (!a && !b) {
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
return !!a && !!b && a.lineNumber === b.lineNumber && a.column === b.column;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Test if this position is before other position.
|
|
456
|
+
* If the two positions are equal, the result will be false.
|
|
457
|
+
*/
|
|
458
|
+
isBefore(other) {
|
|
459
|
+
return Position.isBefore(this, other);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Test if position `a` is before position `b`.
|
|
463
|
+
* If the two positions are equal, the result will be false.
|
|
464
|
+
*/
|
|
465
|
+
static isBefore(a, b) {
|
|
466
|
+
if (a.lineNumber < b.lineNumber) {
|
|
467
|
+
return true;
|
|
468
|
+
}
|
|
469
|
+
if (b.lineNumber < a.lineNumber) {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
return a.column < b.column;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Test if this position is before other position.
|
|
476
|
+
* If the two positions are equal, the result will be true.
|
|
477
|
+
*/
|
|
478
|
+
isBeforeOrEqual(other) {
|
|
479
|
+
return Position.isBeforeOrEqual(this, other);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Test if position `a` is before position `b`.
|
|
483
|
+
* If the two positions are equal, the result will be true.
|
|
484
|
+
*/
|
|
485
|
+
static isBeforeOrEqual(a, b) {
|
|
486
|
+
if (a.lineNumber < b.lineNumber) {
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
if (b.lineNumber < a.lineNumber) {
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
return a.column <= b.column;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* A function that compares positions, useful for sorting
|
|
496
|
+
*/
|
|
497
|
+
static compare(a, b) {
|
|
498
|
+
const aLineNumber = a.lineNumber | 0;
|
|
499
|
+
const bLineNumber = b.lineNumber | 0;
|
|
500
|
+
if (aLineNumber === bLineNumber) {
|
|
501
|
+
const aColumn = a.column | 0;
|
|
502
|
+
const bColumn = b.column | 0;
|
|
503
|
+
return aColumn - bColumn;
|
|
504
|
+
}
|
|
505
|
+
return aLineNumber - bLineNumber;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Clone this position.
|
|
509
|
+
*/
|
|
510
|
+
clone() {
|
|
511
|
+
return new Position(this.lineNumber, this.column);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Convert to a human-readable representation.
|
|
515
|
+
*/
|
|
516
|
+
toString() {
|
|
517
|
+
return `(${this.lineNumber},${this.column})`;
|
|
518
|
+
}
|
|
519
|
+
// ---
|
|
520
|
+
/**
|
|
521
|
+
* Create a `Position` from an `IPosition`.
|
|
522
|
+
*/
|
|
523
|
+
static lift(pos) {
|
|
524
|
+
return new Position(pos.lineNumber, pos.column);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Test if `obj` is an `IPosition`.
|
|
528
|
+
*/
|
|
529
|
+
static isIPosition(obj) {
|
|
530
|
+
return obj && typeof obj.lineNumber === "number" && typeof obj.column === "number";
|
|
531
|
+
}
|
|
532
|
+
toJSON() {
|
|
533
|
+
return {
|
|
534
|
+
lineNumber: this.lineNumber,
|
|
535
|
+
column: this.column
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
export {
|
|
540
|
+
Position,
|
|
541
|
+
Range
|
|
542
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Module, ModuleGraph, Statement } from '@rsdoctor/graph';
|
|
2
|
-
import { editor } from 'monaco-editor';
|
|
2
|
+
import type { editor } from 'monaco-editor';
|
|
3
3
|
export declare function useFileStructures(modules: Module[], moduleGraph: ModuleGraph, searchInput: string, selectedModule: Module, onItemClick: (file: string) => void, cwd: string): import("../../utils").DataNode[];
|
|
4
4
|
export declare function getTreeFilesDefaultExpandedKeys(files: any[]): (string | number)[];
|
|
5
5
|
export declare function ellipsisPath(full: string): string;
|
|
@@ -4,7 +4,7 @@ import path from "path-browserify";
|
|
|
4
4
|
import { escape, get } from "lodash-es";
|
|
5
5
|
import { Module } from "@rsdoctor/graph";
|
|
6
6
|
import { Tag, Space } from "antd";
|
|
7
|
-
import { Range } from "
|
|
7
|
+
import { Range } from "./range";
|
|
8
8
|
import { getOpenTagText } from "./open-tag";
|
|
9
9
|
import {
|
|
10
10
|
createFileStructures,
|
package/dist/utils/file.d.ts
CHANGED
package/dist/utils/hooks.d.ts
CHANGED
package/dist/utils/manifest.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ 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;
|
|
8
|
-
setTheme: (theme:
|
|
8
|
+
setTheme: (theme: import("../config").Config["theme"]) => void;
|
|
9
9
|
isDark: boolean;
|
|
10
10
|
isLight: boolean;
|
|
11
11
|
};
|
|
@@ -14,10 +14,7 @@ export declare function useViewMode(): {
|
|
|
14
14
|
bundleAlerts: ViewMode;
|
|
15
15
|
compileAlerts: ViewMode;
|
|
16
16
|
};
|
|
17
|
-
setViewMode: (mode: Partial<
|
|
18
|
-
bundleAlerts: ViewMode;
|
|
19
|
-
compileAlerts: ViewMode;
|
|
20
|
-
}>, saveStorage?: boolean | undefined) => void;
|
|
17
|
+
setViewMode: (mode: Partial<import("../config").Config["viewMode"]>, saveStorage?: boolean) => void;
|
|
21
18
|
setCompileAlertsViewMode(mode: ViewMode): void;
|
|
22
19
|
setBundleAlertsViewMode(mode: ViewMode): void;
|
|
23
20
|
isCompileList: boolean;
|
package/dist/utils/monaco.js
CHANGED
|
@@ -39,7 +39,12 @@ function getRevealPositionForViewer(startLineNumber, startColumn) {
|
|
|
39
39
|
function getSelectionRange(source, Range) {
|
|
40
40
|
const { start, end } = source;
|
|
41
41
|
const { line = 1, column = 0 } = start;
|
|
42
|
-
return new Range(
|
|
42
|
+
return new Range(
|
|
43
|
+
line,
|
|
44
|
+
column + 1,
|
|
45
|
+
end?.line ?? line,
|
|
46
|
+
(end?.column ?? 9999) + 1
|
|
47
|
+
);
|
|
43
48
|
}
|
|
44
49
|
const initMonaco = (monacoRef) => {
|
|
45
50
|
return new Promise((resolve, reject) => {
|
package/dist/utils/request.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { Manifest, SDK } from '@rsdoctor/types';
|
|
|
2
2
|
export declare function fetchShardingFile(url: string): Promise<string>;
|
|
3
3
|
export declare function loadManifestByUrl(url: string): Promise<{
|
|
4
4
|
data: Manifest.RsdoctorManifestData;
|
|
5
|
-
cloudData?: Record<keyof Manifest.RsdoctorManifestData, string
|
|
6
|
-
__LOCAL__SERVER__?: boolean
|
|
7
|
-
__SOCKET__URL__?: string
|
|
5
|
+
cloudData?: Record<keyof Manifest.RsdoctorManifestData, string[] | string>;
|
|
6
|
+
__LOCAL__SERVER__?: boolean;
|
|
7
|
+
__SOCKET__URL__?: string;
|
|
8
8
|
client: Manifest.RsdoctorManifestClient;
|
|
9
9
|
cloudManifestUrl?: string | undefined;
|
|
10
10
|
name?: string | undefined;
|
|
@@ -14,9 +14,9 @@ export declare function fetchJSONByUrl(url: string): Promise<Manifest.RsdoctorMa
|
|
|
14
14
|
export declare function fetchJSONByUrls(urls: string[]): Promise<Manifest.RsdoctorManifestWithShardingFiles[]>;
|
|
15
15
|
export declare function parseManifest(json: Manifest.RsdoctorManifestWithShardingFiles): Promise<{
|
|
16
16
|
data: Manifest.RsdoctorManifestData;
|
|
17
|
-
cloudData?: Record<keyof Manifest.RsdoctorManifestData, string
|
|
18
|
-
__LOCAL__SERVER__?: boolean
|
|
19
|
-
__SOCKET__URL__?: string
|
|
17
|
+
cloudData?: Record<keyof Manifest.RsdoctorManifestData, string[] | string>;
|
|
18
|
+
__LOCAL__SERVER__?: boolean;
|
|
19
|
+
__SOCKET__URL__?: string;
|
|
20
20
|
client: Manifest.RsdoctorManifestClient;
|
|
21
21
|
cloudManifestUrl?: string | undefined;
|
|
22
22
|
name?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/components",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12-alpha.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dist/"
|
|
45
45
|
],
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@ant-design/icons": "
|
|
47
|
+
"@ant-design/icons": "5.3.5",
|
|
48
48
|
"@monaco-editor/react": "4.6.0",
|
|
49
49
|
"@types/lodash-es": "4.17.12",
|
|
50
50
|
"@types/node": "^16",
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"terser": "^5.31.3",
|
|
76
76
|
"typescript": "^5.2.2",
|
|
77
77
|
"url-parse": "1.5.10",
|
|
78
|
-
"@rsdoctor/graph": "0.3.
|
|
79
|
-
"@rsdoctor/types": "0.3.
|
|
80
|
-
"@rsdoctor/utils": "0.3.
|
|
78
|
+
"@rsdoctor/graph": "0.3.12-alpha.0",
|
|
79
|
+
"@rsdoctor/types": "0.3.12-alpha.0",
|
|
80
|
+
"@rsdoctor/utils": "0.3.12-alpha.0"
|
|
81
81
|
},
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public",
|