@rsdoctor/components 1.5.2 → 1.5.3
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/common/svg/cursor.mjs +22 -0
- package/dist/common/svg/cursor.mjs.map +1 -0
- package/dist/common/svg/trae.mjs +21 -0
- package/dist/common/svg/trae.mjs.map +1 -0
- package/dist/common/svg/vscode.mjs +158 -0
- package/dist/common/svg/vscode.mjs.map +1 -0
- package/dist/components/Charts/TreeMap.d.ts +1 -2
- package/dist/components/Charts/TreeMap.mjs +1 -14
- package/dist/components/Charts/TreeMap.mjs.map +1 -1
- package/dist/components/Configuration/builder.d.ts +1 -1
- package/dist/components/Loader/Analysis/index.d.ts +1 -1
- package/dist/components/Loader/executions.mjs +138 -118
- package/dist/components/Loader/executions.mjs.map +1 -1
- package/dist/components/Opener/code.mjs +1 -1
- package/dist/components/Opener/code.mjs.map +1 -1
- package/dist/components/Opener/{vscode.d.ts → ide.d.ts} +2 -0
- package/dist/components/Opener/ide.mjs +62 -0
- package/dist/components/Opener/ide.mjs.map +1 -0
- package/dist/components/Opener/index.d.ts +1 -1
- package/dist/components/Opener/index.mjs +1 -1
- package/dist/components/base/CodeViewer/index.d.ts +1 -1
- package/dist/components/base/CodeViewer/index.mjs +9 -2
- package/dist/components/base/CodeViewer/index.mjs.map +1 -1
- package/dist/components/base/CodeViewer/interface.d.ts +5 -0
- package/dist/pages/BundleSize/components/index.mjs +390 -399
- package/dist/pages/BundleSize/components/index.mjs.map +1 -1
- package/dist/pages/BundleSize/components/index.module.mjs +0 -4
- package/dist/pages/BundleSize/components/index.module.mjs.map +1 -1
- package/dist/pages/BundleSize/components/index_module.css +0 -4
- package/dist/pages/BundleSize/components/index_module.css.map +1 -1
- package/dist/pages/ModuleAnalyze/fileTree.d.ts +2 -0
- package/dist/pages/ModuleAnalyze/fileTree.mjs +168 -33
- package/dist/pages/ModuleAnalyze/fileTree.mjs.map +1 -1
- package/dist/pages/ModuleAnalyze/index.mjs +87 -76
- package/dist/pages/ModuleAnalyze/index.mjs.map +1 -1
- package/package.json +10 -10
- package/dist/components/Opener/vscode.mjs +0 -33
- package/dist/components/Opener/vscode.mjs.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ClockCircleTwoTone } from "@ant-design/icons";
|
|
3
|
+
import { SDK } from "@rsdoctor/types";
|
|
3
4
|
import { Col, Divider, Empty, List, Row, Space, Tabs, Tag, Timeline, Tooltip, Typography } from "antd";
|
|
4
5
|
import dayjs from "dayjs";
|
|
5
6
|
import { useCallback, useState } from "react";
|
|
@@ -12,6 +13,7 @@ import { CodeViewer, DiffViewer } from "../base/index.mjs";
|
|
|
12
13
|
import { Card } from "../Card/index.mjs";
|
|
13
14
|
import { CodeOpener } from "../Opener/index.mjs";
|
|
14
15
|
import { Title } from "../Title/index.mjs";
|
|
16
|
+
import { ServerAPIProvider } from "../Manifest/index.mjs";
|
|
15
17
|
import style_module from "./Analysis/style.module.mjs";
|
|
16
18
|
const LoaderPropsItem = ({ loader, resource, cwd })=>/*#__PURE__*/ jsx(Card, {
|
|
17
19
|
title: 'Loader Details',
|
|
@@ -153,15 +155,135 @@ const LoaderPropsItem = ({ loader, resource, cwd })=>/*#__PURE__*/ jsx(Card, {
|
|
|
153
155
|
]
|
|
154
156
|
})
|
|
155
157
|
});
|
|
158
|
+
const LoaderDetailsContent = ({ loader, resource, isLight, codeData })=>{
|
|
159
|
+
const hasError = loader.errors && loader.errors.length;
|
|
160
|
+
const before = codeData?.input || '';
|
|
161
|
+
const loaderResult = codeData?.output || '';
|
|
162
|
+
return /*#__PURE__*/ jsx("div", {
|
|
163
|
+
style: {
|
|
164
|
+
height: '100%'
|
|
165
|
+
},
|
|
166
|
+
children: hasError ? /*#__PURE__*/ jsxs(Col, {
|
|
167
|
+
span: 24,
|
|
168
|
+
style: {
|
|
169
|
+
height: '53%',
|
|
170
|
+
minHeight: 400
|
|
171
|
+
},
|
|
172
|
+
children: [
|
|
173
|
+
/*#__PURE__*/ jsx("div", {
|
|
174
|
+
style: {
|
|
175
|
+
padding: Size.BasePadding,
|
|
176
|
+
borderTop: `1px solid ${isLight ? '#f0f0f0' : 'rgba(253, 253, 253, 0.12)'}`,
|
|
177
|
+
borderBottom: `1px solid ${isLight ? '#f0f0f0' : 'rgba(253, 253, 253, 0.12)'}`
|
|
178
|
+
},
|
|
179
|
+
children: /*#__PURE__*/ jsx(Title, {
|
|
180
|
+
text: `the error stack of [${loader.loader}] ${loader.isPitch ? 'pitch' : ''}`
|
|
181
|
+
})
|
|
182
|
+
}),
|
|
183
|
+
/*#__PURE__*/ jsx("div", {
|
|
184
|
+
style: {
|
|
185
|
+
height: '90%'
|
|
186
|
+
},
|
|
187
|
+
children: /*#__PURE__*/ jsx(CodeViewer, {
|
|
188
|
+
code: loader.errors[0].message,
|
|
189
|
+
lang: "javascript"
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
]
|
|
193
|
+
}) : /*#__PURE__*/ jsxs(Col, {
|
|
194
|
+
span: 24,
|
|
195
|
+
style: {
|
|
196
|
+
height: '53%',
|
|
197
|
+
minHeight: 400
|
|
198
|
+
},
|
|
199
|
+
children: [
|
|
200
|
+
/*#__PURE__*/ jsxs("div", {
|
|
201
|
+
style: {
|
|
202
|
+
display: 'flex',
|
|
203
|
+
alignItems: 'center',
|
|
204
|
+
padding: Size.BasePadding,
|
|
205
|
+
borderBottom: `1px solid ${isLight ? '#f0f0f0' : 'rgba(253, 253, 253, 0.12)'}`
|
|
206
|
+
},
|
|
207
|
+
children: [
|
|
208
|
+
/*#__PURE__*/ jsx(Title, {
|
|
209
|
+
text: /*#__PURE__*/ jsxs(Fragment, {
|
|
210
|
+
children: [
|
|
211
|
+
`the result of [${loader.loader}] ${loader.isPitch ? 'pitch' : ''}`,
|
|
212
|
+
!loader.isPitch && /*#__PURE__*/ jsxs("span", {
|
|
213
|
+
style: {
|
|
214
|
+
fontWeight: 400
|
|
215
|
+
},
|
|
216
|
+
children: [
|
|
217
|
+
"(",
|
|
218
|
+
/*#__PURE__*/ jsx(input, {
|
|
219
|
+
style: {
|
|
220
|
+
verticalAlign: 'middle',
|
|
221
|
+
margin: '0 2px'
|
|
222
|
+
}
|
|
223
|
+
}),
|
|
224
|
+
"Input ⟷",
|
|
225
|
+
/*#__PURE__*/ jsx(output, {
|
|
226
|
+
style: {
|
|
227
|
+
verticalAlign: 'middle',
|
|
228
|
+
position: 'relative',
|
|
229
|
+
top: -2
|
|
230
|
+
}
|
|
231
|
+
}),
|
|
232
|
+
"Output)"
|
|
233
|
+
]
|
|
234
|
+
})
|
|
235
|
+
]
|
|
236
|
+
})
|
|
237
|
+
}),
|
|
238
|
+
/*#__PURE__*/ jsx("div", {
|
|
239
|
+
style: {
|
|
240
|
+
flex: 1
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
]
|
|
244
|
+
}),
|
|
245
|
+
loader.isPitch ? loaderResult ? /*#__PURE__*/ jsx("div", {
|
|
246
|
+
style: {
|
|
247
|
+
height: '90%'
|
|
248
|
+
},
|
|
249
|
+
children: /*#__PURE__*/ jsx(CodeViewer, {
|
|
250
|
+
isEmbed: true,
|
|
251
|
+
code: loaderResult,
|
|
252
|
+
filePath: resource.path
|
|
253
|
+
})
|
|
254
|
+
}) : /*#__PURE__*/ jsx(Empty, {
|
|
255
|
+
description: 'No loader result. If you use the Brief Mode, there will not have loader results.'
|
|
256
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
257
|
+
style: {
|
|
258
|
+
minHeight: '700px'
|
|
259
|
+
},
|
|
260
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
261
|
+
style: {
|
|
262
|
+
height: '40rem',
|
|
263
|
+
overflow: 'hidden'
|
|
264
|
+
},
|
|
265
|
+
children: loaderResult || before ? /*#__PURE__*/ jsx(DiffViewer, {
|
|
266
|
+
isEmbed: true,
|
|
267
|
+
original: before,
|
|
268
|
+
modified: loaderResult || '',
|
|
269
|
+
originalFilePath: resource.path,
|
|
270
|
+
modifiedFilePath: resource.path
|
|
271
|
+
}) : /*#__PURE__*/ jsx(Empty, {
|
|
272
|
+
description: 'No loader result. If you use the Brief Mode, there will not have loader results.'
|
|
273
|
+
})
|
|
274
|
+
})
|
|
275
|
+
})
|
|
276
|
+
]
|
|
277
|
+
})
|
|
278
|
+
});
|
|
279
|
+
};
|
|
156
280
|
const LoaderExecutions = ({ data, cwd, index })=>{
|
|
157
281
|
const { loaders, resource } = data;
|
|
158
282
|
const [currentIndex, setCurrentIndex] = useState(index || 0);
|
|
159
283
|
const { theme } = useTheme();
|
|
160
284
|
const isLight = 'light' === theme;
|
|
161
285
|
const loader = loaders[currentIndex];
|
|
162
|
-
const before = loader.input || '';
|
|
163
286
|
const leftSpan = 5;
|
|
164
|
-
const hasError = loader.errors && loader.errors.length;
|
|
165
287
|
const [activeKey, setActiveKey] = useState('loaderDetails');
|
|
166
288
|
const onChange = useCallback((key)=>{
|
|
167
289
|
setActiveKey(key);
|
|
@@ -294,123 +416,21 @@ const LoaderExecutions = ({ data, cwd, index })=>{
|
|
|
294
416
|
{
|
|
295
417
|
label: 'Loader Details',
|
|
296
418
|
key: 'loaderDetails',
|
|
297
|
-
children: /*#__PURE__*/ jsx(
|
|
298
|
-
|
|
299
|
-
|
|
419
|
+
children: 'loaderDetails' === activeKey ? /*#__PURE__*/ jsx(ServerAPIProvider, {
|
|
420
|
+
api: SDK.ServerAPI.API.GetLoaderFileInputAndOutput,
|
|
421
|
+
body: {
|
|
422
|
+
file: resource.path,
|
|
423
|
+
loader: loader.loader,
|
|
424
|
+
loaderIndex: loader.loaderIndex
|
|
300
425
|
},
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
style: {
|
|
310
|
-
padding: Size.BasePadding,
|
|
311
|
-
borderTop: `1px solid ${isLight ? '#f0f0f0' : 'rgba(253, 253, 253, 0.12)'}`,
|
|
312
|
-
borderBottom: `1px solid ${isLight ? '#f0f0f0' : 'rgba(253, 253, 253, 0.12)'}`
|
|
313
|
-
},
|
|
314
|
-
children: /*#__PURE__*/ jsx(Title, {
|
|
315
|
-
text: `the error stack of [${loader.loader}] ${loader.isPitch ? 'pitch' : ''}`
|
|
316
|
-
})
|
|
317
|
-
}),
|
|
318
|
-
/*#__PURE__*/ jsx("div", {
|
|
319
|
-
style: {
|
|
320
|
-
height: '90%'
|
|
321
|
-
},
|
|
322
|
-
children: /*#__PURE__*/ jsx(CodeViewer, {
|
|
323
|
-
code: loader.errors[0].message,
|
|
324
|
-
lang: "javascript"
|
|
325
|
-
})
|
|
326
|
-
})
|
|
327
|
-
]
|
|
328
|
-
}) : /*#__PURE__*/ jsxs(Col, {
|
|
329
|
-
span: 24,
|
|
330
|
-
style: {
|
|
331
|
-
height: '53%',
|
|
332
|
-
minHeight: 400
|
|
333
|
-
},
|
|
334
|
-
children: [
|
|
335
|
-
/*#__PURE__*/ jsxs("div", {
|
|
336
|
-
style: {
|
|
337
|
-
display: 'flex',
|
|
338
|
-
alignItems: 'center',
|
|
339
|
-
padding: Size.BasePadding,
|
|
340
|
-
borderBottom: `1px solid ${isLight ? '#f0f0f0' : 'rgba(253, 253, 253, 0.12)'}`
|
|
341
|
-
},
|
|
342
|
-
children: [
|
|
343
|
-
/*#__PURE__*/ jsx(Title, {
|
|
344
|
-
text: /*#__PURE__*/ jsxs(Fragment, {
|
|
345
|
-
children: [
|
|
346
|
-
`the result of [${loader.loader}] ${loader.isPitch ? 'pitch' : ''}`,
|
|
347
|
-
!loader.isPitch && /*#__PURE__*/ jsxs("span", {
|
|
348
|
-
style: {
|
|
349
|
-
fontWeight: 400
|
|
350
|
-
},
|
|
351
|
-
children: [
|
|
352
|
-
"(",
|
|
353
|
-
/*#__PURE__*/ jsx(input, {
|
|
354
|
-
style: {
|
|
355
|
-
verticalAlign: 'middle',
|
|
356
|
-
margin: '0 2px'
|
|
357
|
-
}
|
|
358
|
-
}),
|
|
359
|
-
"Input ⟷",
|
|
360
|
-
/*#__PURE__*/ jsx(output, {
|
|
361
|
-
style: {
|
|
362
|
-
verticalAlign: 'middle',
|
|
363
|
-
position: 'relative',
|
|
364
|
-
top: -2
|
|
365
|
-
}
|
|
366
|
-
}),
|
|
367
|
-
"Output)"
|
|
368
|
-
]
|
|
369
|
-
})
|
|
370
|
-
]
|
|
371
|
-
})
|
|
372
|
-
}),
|
|
373
|
-
/*#__PURE__*/ jsx("div", {
|
|
374
|
-
style: {
|
|
375
|
-
flex: 1
|
|
376
|
-
}
|
|
377
|
-
})
|
|
378
|
-
]
|
|
379
|
-
}),
|
|
380
|
-
loader.isPitch ? loader.result ? /*#__PURE__*/ jsx("div", {
|
|
381
|
-
style: {
|
|
382
|
-
height: '90%'
|
|
383
|
-
},
|
|
384
|
-
children: /*#__PURE__*/ jsx(CodeViewer, {
|
|
385
|
-
isEmbed: true,
|
|
386
|
-
code: loader.result,
|
|
387
|
-
filePath: resource.path
|
|
388
|
-
})
|
|
389
|
-
}) : /*#__PURE__*/ jsx(Empty, {
|
|
390
|
-
description: 'No loader result. If you use the Brief Mode, there will not have loader results.'
|
|
391
|
-
}) : /*#__PURE__*/ jsx("div", {
|
|
392
|
-
style: {
|
|
393
|
-
minHeight: '700px'
|
|
394
|
-
},
|
|
395
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
396
|
-
style: {
|
|
397
|
-
height: '40rem',
|
|
398
|
-
overflow: 'hidden'
|
|
399
|
-
},
|
|
400
|
-
children: loader.result || before ? /*#__PURE__*/ jsx(DiffViewer, {
|
|
401
|
-
isEmbed: true,
|
|
402
|
-
original: before,
|
|
403
|
-
modified: loader.result || '',
|
|
404
|
-
originalFilePath: resource.path,
|
|
405
|
-
modifiedFilePath: resource.path
|
|
406
|
-
}) : /*#__PURE__*/ jsx(Empty, {
|
|
407
|
-
description: 'No loader result. If you use the Brief Mode, there will not have loader results.'
|
|
408
|
-
})
|
|
409
|
-
})
|
|
410
|
-
})
|
|
411
|
-
]
|
|
412
|
-
})
|
|
413
|
-
})
|
|
426
|
+
showSkeleton: false,
|
|
427
|
+
children: (codeData)=>/*#__PURE__*/ jsx(LoaderDetailsContent, {
|
|
428
|
+
loader: loader,
|
|
429
|
+
resource: resource,
|
|
430
|
+
isLight: isLight,
|
|
431
|
+
codeData: codeData
|
|
432
|
+
})
|
|
433
|
+
}) : null
|
|
414
434
|
}
|
|
415
435
|
],
|
|
416
436
|
onChange: onChange
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/Loader/executions.mjs","sources":["../../../src/components/Loader/executions.tsx"],"sourcesContent":["import { ClockCircleTwoTone } from '@ant-design/icons';\nimport { SDK } from '@rsdoctor/types';\nimport {\n Col,\n Divider,\n Empty,\n List,\n Row,\n Space,\n Tabs,\n Tag,\n Timeline,\n Tooltip,\n Typography,\n} from 'antd';\nimport dayjs from 'dayjs';\nimport { PropsWithChildren, useCallback, useState } from 'react';\nimport InputIcon from 'src/common/svg/loader/input.svg';\nimport OutputIcon from 'src/common/svg/loader/output.svg';\nimport StepIcon from 'src/common/svg/loader/step.svg';\nimport { Size } from '../../constants';\nimport { beautifyPath, formatCosts, useTheme } from '../../utils';\nimport { CodeViewer, DiffViewer } from '../base';\nimport { Card } from '../Card';\nimport { CodeOpener } from '../Opener';\nimport { Title } from '../Title';\nimport styles from './Analysis/style.module.scss';\n\ninterface LoaderExecutionsProps {\n cwd: string;\n data: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderFileDetails>;\n index?: number;\n}\n\nconst LoaderPropsItem = ({\n loader,\n resource,\n cwd,\n}: {\n loader: SDK.LoaderTransformData & {\n costs: number;\n };\n resource: SDK.ResourceData;\n cwd: string;\n}): JSX.Element => {\n return (\n <Card\n title={'Loader Details'}\n style={{ border: 'none' }}\n extra={\n <Tag icon={<ClockCircleTwoTone />} color=\"default\">\n {dayjs(loader.startAt).format('YYYY-MM-DD HH:mm:ss')}\n </Tag>\n }\n >\n <Space direction=\"vertical\" style={{ width: '100%' }}>\n {loader.isPitch ? <Typography.Text code>pitch</Typography.Text> : null}\n <List size=\"large\" bordered>\n <List.Item>\n <Typography.Text strong>{'File Path'}</Typography.Text>\n <div>{beautifyPath(resource.path, cwd)}</div>\n </List.Item>\n <List.Item>\n <Typography.Text strong>{'Resource Path'}</Typography.Text>\n <CodeOpener cwd={cwd} url={resource.path} loc=\"\" disabled />\n </List.Item>\n <List.Item>\n <Typography.Text strong>{'Resource Query'}</Typography.Text>\n <div>{resource.queryRaw || '-'}</div>\n </List.Item>\n <List.Item>\n <Typography.Text strong>{'Duration'}</Typography.Text>\n <div>{formatCosts(loader.costs)}</div>\n </List.Item>\n <List.Item>\n <Typography.Text strong>{'Loader'}</Typography.Text>\n <div>\n <Typography.Text code>{loader.loader}</Typography.Text>\n </div>\n </List.Item>\n <List.Item>\n <Typography.Text strong>{'Loader Index'}</Typography.Text>\n <div>{`${loader.loaderIndex}`}</div>\n </List.Item>\n <List.Item>\n <Typography.Text strong>{'Loader Path'}</Typography.Text>\n <CodeOpener cwd={cwd} url={loader.path} loc=\"\" disabled />\n </List.Item>\n <List.Item>\n <div style={{ width: 180 }}>\n <Typography.Text strong>{'Options'}</Typography.Text>\n </div>\n <Divider type=\"vertical\" />\n <Typography.Paragraph\n ellipsis={{\n rows: 2,\n expandable: true,\n symbol: 'more',\n }}\n copyable\n >\n {JSON.stringify(loader.options || '-')}\n </Typography.Paragraph>\n </List.Item>\n </List>\n </Space>\n </Card>\n );\n};\n\nexport const LoaderExecutions = ({\n data,\n cwd,\n index,\n}: PropsWithChildren<LoaderExecutionsProps>): JSX.Element => {\n const { loaders, resource } = data;\n const [currentIndex, setCurrentIndex] = useState(index || 0);\n const { theme } = useTheme();\n const isLight = theme === 'light';\n const loader = loaders[currentIndex];\n const before = loader.input || '';\n const leftSpan = 5;\n const hasError = loader.errors && loader.errors.length;\n const [activeKey, setActiveKey] = useState('loaderDetails');\n const onChange = useCallback((key: string) => {\n setActiveKey(key);\n }, []);\n\n return (\n <Row className={styles.executions} style={{ height: '100%' }}>\n <Col\n span={leftSpan}\n style={{\n borderRight: isLight ? `1px solid #f0f0f0` : undefined,\n padding: Size.BasePadding,\n }}\n >\n <Space direction=\"vertical\" style={{ width: '100%' }}>\n <Title text=\"Executions\" />\n <Timeline mode=\"left\" style={{ marginTop: Size.BasePadding }}>\n {loaders.map((e, i, arr) => {\n const { loader, isPitch } = e;\n const costs = formatCosts(e.costs);\n return (\n <Timeline.Item\n dot={\n isPitch ? (\n <Tag style={{ marginLeft: 1, fontWeight: 500 }}>\n pitch\n </Tag>\n ) : (\n <ClockCircleTwoTone />\n )\n }\n style={{ paddingBottom: 10, textAlign: 'center' }}\n key={i}\n >\n <Row align=\"middle\" justify=\"space-between\" gutter={[0, 10]}>\n <Col span={24} className={styles.timeline}>\n <Tooltip title={loader} trigger=\"hover\">\n <div\n className={`${styles.box} ${currentIndex === i ? styles.selected : ''}`}\n onClick={() => {\n setCurrentIndex(i);\n }}\n style={{ textAlign: 'left' }}\n >\n <div>\n <Typography.Text style={{ color: '#000' }}>\n {costs.match(/[0-9]*\\.?[0-9]+/g)?.[0]}\n </Typography.Text>\n {` `}\n <Typography.Text\n style={{ color: 'rgba(0,0,0,0.45)' }}\n >\n {costs.match(/[a-zA-Z]+/g)}\n </Typography.Text>\n </div>\n <Typography.Text\n style={{ color: 'rgba(0,0,0,0.65)' }}\n className={styles.loader}\n >\n {loader}\n </Typography.Text>\n </div>\n </Tooltip>\n </Col>\n </Row>\n {i === arr.length - 1 ? null : (\n <div style={{ paddingTop: 10 }}>\n <StepIcon />\n </div>\n )}\n </Timeline.Item>\n );\n })}\n </Timeline>\n </Space>\n </Col>\n <Col span={24 - leftSpan} style={{ height: '100%' }}>\n <Tabs\n type=\"card\"\n defaultActiveKey=\"loaderDetails\"\n activeKey={activeKey}\n items={[\n {\n label: 'Loader Props',\n key: 'loaderProps',\n children: (\n <LoaderPropsItem\n loader={loader}\n resource={resource}\n cwd={cwd}\n />\n ),\n },\n {\n label: 'Loader Details',\n key: 'loaderDetails',\n children: (\n <div style={{ height: '100%' }}>\n {hasError ? (\n <Col span={24} style={{ height: '53%', minHeight: 400 }}>\n <div\n style={{\n padding: Size.BasePadding,\n borderTop: `1px solid ${isLight ? '#f0f0f0' : 'rgba(253, 253, 253, 0.12)'}`,\n borderBottom: `1px solid ${isLight ? '#f0f0f0' : 'rgba(253, 253, 253, 0.12)'}`,\n }}\n >\n <Title\n text={`the error stack of [${loader.loader}] ${loader.isPitch ? 'pitch' : ''}`}\n />\n </div>\n <div style={{ height: '90%' }}>\n <CodeViewer\n code={loader.errors[0].message}\n lang=\"javascript\"\n />\n </div>\n </Col>\n ) : (\n <Col span={24} style={{ height: '53%', minHeight: 400 }}>\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n padding: Size.BasePadding,\n borderBottom: `1px solid ${isLight ? '#f0f0f0' : 'rgba(253, 253, 253, 0.12)'}`,\n }}\n >\n <Title\n text={\n <>\n {`the result of [${loader.loader}] ${loader.isPitch ? 'pitch' : ''}`}\n {!loader.isPitch && (\n <span style={{ fontWeight: 400 }}>\n (\n <InputIcon\n style={{\n verticalAlign: 'middle',\n margin: '0 2px',\n }}\n />\n Input ⟷\n <OutputIcon\n style={{\n verticalAlign: 'middle',\n position: 'relative',\n top: -2,\n }}\n />\n Output)\n </span>\n )}\n </>\n }\n />\n <div style={{ flex: 1 }} />\n </div>\n {loader.isPitch ? (\n loader.result ? (\n <div style={{ height: '90%' }}>\n <CodeViewer\n isEmbed\n code={loader.result}\n filePath={resource.path}\n />\n </div>\n ) : (\n <Empty\n description={\n 'No loader result. If you use the Brief Mode, there will not have loader results.'\n }\n />\n )\n ) : (\n <div style={{ minHeight: '700px' }}>\n <div style={{ height: '40rem', overflow: 'hidden' }}>\n {!loader.result && !before ? (\n <Empty\n description={\n 'No loader result. If you use the Brief Mode, there will not have loader results.'\n }\n />\n ) : (\n <DiffViewer\n isEmbed\n original={before}\n modified={loader.result || ''}\n originalFilePath={resource.path}\n modifiedFilePath={resource.path}\n />\n )}\n </div>\n </div>\n )}\n </Col>\n )}\n </div>\n ),\n },\n ]}\n onChange={onChange}\n />\n </Col>\n </Row>\n );\n};\n"],"names":["LoaderPropsItem","loader","resource","cwd","Card","Tag","ClockCircleTwoTone","dayjs","Space","Typography","List","beautifyPath","CodeOpener","formatCosts","Divider","JSON","LoaderExecutions","data","index","loaders","currentIndex","setCurrentIndex","useState","theme","useTheme","isLight","before","leftSpan","hasError","activeKey","setActiveKey","onChange","useCallback","key","Row","styles","Col","undefined","Size","Title","Timeline","e","i","arr","isPitch","costs","Tooltip","StepIcon","Tabs","CodeViewer","InputIcon","OutputIcon","Empty","DiffViewer"],"mappings":";;;;;;;;;;;;;;;AAkCA,MAAMA,kBAAkB,CAAC,EACvBC,MAAM,EACNC,QAAQ,EACRC,GAAG,EAOJ,GACQ,WAAP,GACE,IAACC,MAAIA;QACH,OAAO;QACP,OAAO;YAAE,QAAQ;QAAO;QACxB,qBACE,IAACC,KAAGA;YAAC,oBAAM,IAACC,oBAAkBA,CAAAA;YAAK,OAAM;sBACtCC,MAAMN,OAAO,OAAO,EAAE,MAAM,CAAC;;kBAIlC,mBAACO,OAAKA;YAAC,WAAU;YAAW,OAAO;gBAAE,OAAO;YAAO;;gBAChDP,OAAO,OAAO,GAAG,WAAH,GAAG,IAACQ,WAAW,IAAI;oBAAC,MAAI;8BAAC;qBAA0B;8BAClE,KAACC,MAAIA;oBAAC,MAAK;oBAAQ,UAAQ;;sCACzB,KAACA,KAAK,IAAI;;8CACR,IAACD,WAAW,IAAI;oCAAC,QAAM;8CAAE;;8CACzB,IAAC;8CAAKE,aAAaT,SAAS,IAAI,EAAEC;;;;sCAEpC,KAACO,KAAK,IAAI;;8CACR,IAACD,WAAW,IAAI;oCAAC,QAAM;8CAAE;;8CACzB,IAACG,YAAUA;oCAAC,KAAKT;oCAAK,KAAKD,S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IAAI;;2DAI3B,IAACkD,OAAKA;4CACJ,aACE;2DAKN,IAAC;4CAAI,OAAO;gDAAE,WAAW;4CAAQ;sDAC/B,kBAAC;gDAAI,OAAO;oDAAE,QAAQ;oDAAS,UAAU;gDAAS;0DAC/C,AAACnD,OAAO,MAAM,IAAKyB,S,cAOlB,IAAC2B,YAAUA;oDACT,SAAO;oDACP,UAAU3B;oDACV,UAAUzB,OAAO,MAAM,IAAI;oDAC3B,kBAAkBC,SAAS,IAAI;oDAC/B,kBAAkBA,SAAS,IAAI;qDAZN,WAATwB,GAClB,IAAC0B,OAAKA;oDACJ,aACE;;;;;;;wBAmBtB;qBACD;oBACD,UAAUrB;;;;;AAKpB"}
|
|
1
|
+
{"version":3,"file":"components/Loader/executions.mjs","sources":["../../../src/components/Loader/executions.tsx"],"sourcesContent":["import { ClockCircleTwoTone } from '@ant-design/icons';\nimport { SDK } from '@rsdoctor/types';\nimport {\n Col,\n Divider,\n Empty,\n List,\n Row,\n Space,\n Tabs,\n Tag,\n Timeline,\n Tooltip,\n Typography,\n} from 'antd';\nimport dayjs from 'dayjs';\nimport { PropsWithChildren, useCallback, useState } from 'react';\nimport InputIcon from 'src/common/svg/loader/input.svg';\nimport OutputIcon from 'src/common/svg/loader/output.svg';\nimport StepIcon from 'src/common/svg/loader/step.svg';\nimport { Size } from '../../constants';\nimport { beautifyPath, formatCosts, useTheme } from '../../utils';\nimport { CodeViewer, DiffViewer } from '../base';\nimport { Card } from '../Card';\nimport { CodeOpener } from '../Opener';\nimport { Title } from '../Title';\nimport { ServerAPIProvider } from '../Manifest';\nimport styles from './Analysis/style.module.scss';\n\ninterface LoaderExecutionsProps {\n cwd: string;\n data: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderFileDetails>;\n index?: number;\n}\n\nconst LoaderPropsItem = ({\n loader,\n resource,\n cwd,\n}: {\n loader: Omit<SDK.LoaderTransformData, 'input' | 'result'> & {\n costs: number;\n };\n resource: SDK.ResourceData;\n cwd: string;\n}): JSX.Element => {\n return (\n <Card\n title={'Loader Details'}\n style={{ border: 'none' }}\n extra={\n <Tag icon={<ClockCircleTwoTone />} color=\"default\">\n {dayjs(loader.startAt).format('YYYY-MM-DD HH:mm:ss')}\n </Tag>\n }\n >\n <Space direction=\"vertical\" style={{ width: '100%' }}>\n {loader.isPitch ? <Typography.Text code>pitch</Typography.Text> : null}\n <List size=\"large\" bordered>\n <List.Item>\n <Typography.Text strong>{'File Path'}</Typography.Text>\n <div>{beautifyPath(resource.path, cwd)}</div>\n </List.Item>\n <List.Item>\n <Typography.Text strong>{'Resource Path'}</Typography.Text>\n <CodeOpener cwd={cwd} url={resource.path} loc=\"\" disabled />\n </List.Item>\n <List.Item>\n <Typography.Text strong>{'Resource Query'}</Typography.Text>\n <div>{resource.queryRaw || '-'}</div>\n </List.Item>\n <List.Item>\n <Typography.Text strong>{'Duration'}</Typography.Text>\n <div>{formatCosts(loader.costs)}</div>\n </List.Item>\n <List.Item>\n <Typography.Text strong>{'Loader'}</Typography.Text>\n <div>\n <Typography.Text code>{loader.loader}</Typography.Text>\n </div>\n </List.Item>\n <List.Item>\n <Typography.Text strong>{'Loader Index'}</Typography.Text>\n <div>{`${loader.loaderIndex}`}</div>\n </List.Item>\n <List.Item>\n <Typography.Text strong>{'Loader Path'}</Typography.Text>\n <CodeOpener cwd={cwd} url={loader.path} loc=\"\" disabled />\n </List.Item>\n <List.Item>\n <div style={{ width: 180 }}>\n <Typography.Text strong>{'Options'}</Typography.Text>\n </div>\n <Divider type=\"vertical\" />\n <Typography.Paragraph\n ellipsis={{\n rows: 2,\n expandable: true,\n symbol: 'more',\n }}\n copyable\n >\n {JSON.stringify(loader.options || '-')}\n </Typography.Paragraph>\n </List.Item>\n </List>\n </Space>\n </Card>\n );\n};\n\n// Component to render Loader Details content with lazy-loaded code\nconst LoaderDetailsContent = ({\n loader,\n resource,\n isLight,\n codeData,\n}: {\n loader: Omit<SDK.LoaderTransformData, 'input' | 'result'> & { costs: number };\n resource: SDK.ResourceData;\n isLight: boolean;\n codeData: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderFileInputAndOutput>;\n}): JSX.Element => {\n const hasError = loader.errors && loader.errors.length;\n const before = codeData?.input || '';\n const loaderResult = codeData?.output || '';\n\n return (\n <div style={{ height: '100%' }}>\n {hasError ? (\n <Col span={24} style={{ height: '53%', minHeight: 400 }}>\n <div\n style={{\n padding: Size.BasePadding,\n borderTop: `1px solid ${isLight ? '#f0f0f0' : 'rgba(253, 253, 253, 0.12)'}`,\n borderBottom: `1px solid ${isLight ? '#f0f0f0' : 'rgba(253, 253, 253, 0.12)'}`,\n }}\n >\n <Title\n text={`the error stack of [${loader.loader}] ${loader.isPitch ? 'pitch' : ''}`}\n />\n </div>\n <div style={{ height: '90%' }}>\n <CodeViewer code={loader.errors[0].message} lang=\"javascript\" />\n </div>\n </Col>\n ) : (\n <Col span={24} style={{ height: '53%', minHeight: 400 }}>\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n padding: Size.BasePadding,\n borderBottom: `1px solid ${isLight ? '#f0f0f0' : 'rgba(253, 253, 253, 0.12)'}`,\n }}\n >\n <Title\n text={\n <>\n {`the result of [${loader.loader}] ${loader.isPitch ? 'pitch' : ''}`}\n {!loader.isPitch && (\n <span style={{ fontWeight: 400 }}>\n (\n <InputIcon\n style={{\n verticalAlign: 'middle',\n margin: '0 2px',\n }}\n />\n Input ⟷\n <OutputIcon\n style={{\n verticalAlign: 'middle',\n position: 'relative',\n top: -2,\n }}\n />\n Output)\n </span>\n )}\n </>\n }\n />\n <div style={{ flex: 1 }} />\n </div>\n {loader.isPitch ? (\n loaderResult ? (\n <div style={{ height: '90%' }}>\n <CodeViewer\n isEmbed\n code={loaderResult}\n filePath={resource.path}\n />\n </div>\n ) : (\n <Empty\n description={\n 'No loader result. If you use the Brief Mode, there will not have loader results.'\n }\n />\n )\n ) : (\n <div style={{ minHeight: '700px' }}>\n <div style={{ height: '40rem', overflow: 'hidden' }}>\n {!loaderResult && !before ? (\n <Empty\n description={\n 'No loader result. If you use the Brief Mode, there will not have loader results.'\n }\n />\n ) : (\n <DiffViewer\n isEmbed\n original={before}\n modified={loaderResult || ''}\n originalFilePath={resource.path}\n modifiedFilePath={resource.path}\n />\n )}\n </div>\n </div>\n )}\n </Col>\n )}\n </div>\n );\n};\n\nexport const LoaderExecutions = ({\n data,\n cwd,\n index,\n}: PropsWithChildren<LoaderExecutionsProps>): JSX.Element => {\n const { loaders, resource } = data;\n const [currentIndex, setCurrentIndex] = useState(index || 0);\n const { theme } = useTheme();\n const isLight = theme === 'light';\n const loader = loaders[currentIndex];\n const leftSpan = 5;\n const [activeKey, setActiveKey] = useState('loaderDetails');\n const onChange = useCallback((key: string) => {\n setActiveKey(key);\n }, []);\n\n return (\n <Row className={styles.executions} style={{ height: '100%' }}>\n <Col\n span={leftSpan}\n style={{\n borderRight: isLight ? `1px solid #f0f0f0` : undefined,\n padding: Size.BasePadding,\n }}\n >\n <Space direction=\"vertical\" style={{ width: '100%' }}>\n <Title text=\"Executions\" />\n <Timeline mode=\"left\" style={{ marginTop: Size.BasePadding }}>\n {loaders.map((e, i, arr) => {\n const { loader, isPitch } = e;\n const costs = formatCosts(e.costs);\n return (\n <Timeline.Item\n dot={\n isPitch ? (\n <Tag style={{ marginLeft: 1, fontWeight: 500 }}>\n pitch\n </Tag>\n ) : (\n <ClockCircleTwoTone />\n )\n }\n style={{ paddingBottom: 10, textAlign: 'center' }}\n key={i}\n >\n <Row align=\"middle\" justify=\"space-between\" gutter={[0, 10]}>\n <Col span={24} className={styles.timeline}>\n <Tooltip title={loader} trigger=\"hover\">\n <div\n className={`${styles.box} ${currentIndex === i ? styles.selected : ''}`}\n onClick={() => {\n setCurrentIndex(i);\n }}\n style={{ textAlign: 'left' }}\n >\n <div>\n <Typography.Text style={{ color: '#000' }}>\n {costs.match(/[0-9]*\\.?[0-9]+/g)?.[0]}\n </Typography.Text>\n {` `}\n <Typography.Text\n style={{ color: 'rgba(0,0,0,0.45)' }}\n >\n {costs.match(/[a-zA-Z]+/g)}\n </Typography.Text>\n </div>\n <Typography.Text\n style={{ color: 'rgba(0,0,0,0.65)' }}\n className={styles.loader}\n >\n {loader}\n </Typography.Text>\n </div>\n </Tooltip>\n </Col>\n </Row>\n {i === arr.length - 1 ? null : (\n <div style={{ paddingTop: 10 }}>\n <StepIcon />\n </div>\n )}\n </Timeline.Item>\n );\n })}\n </Timeline>\n </Space>\n </Col>\n <Col span={24 - leftSpan} style={{ height: '100%' }}>\n <Tabs\n type=\"card\"\n defaultActiveKey=\"loaderDetails\"\n activeKey={activeKey}\n items={[\n {\n label: 'Loader Props',\n key: 'loaderProps',\n children: (\n <LoaderPropsItem\n loader={loader}\n resource={resource}\n cwd={cwd}\n />\n ),\n },\n {\n label: 'Loader Details',\n key: 'loaderDetails',\n children:\n activeKey === 'loaderDetails' ? (\n <ServerAPIProvider\n api={SDK.ServerAPI.API.GetLoaderFileInputAndOutput}\n body={{\n file: resource.path,\n loader: loader.loader,\n loaderIndex: loader.loaderIndex,\n }}\n showSkeleton={false}\n >\n {(codeData) => (\n <LoaderDetailsContent\n loader={loader}\n resource={resource}\n isLight={isLight}\n codeData={codeData}\n />\n )}\n </ServerAPIProvider>\n ) : null,\n },\n ]}\n onChange={onChange}\n />\n </Col>\n </Row>\n );\n};\n"],"names":["LoaderPropsItem","loader","resource","cwd","Card","Tag","ClockCircleTwoTone","dayjs","Space","Typography","List","beautifyPath","CodeOpener","formatCosts","Divider","JSON","LoaderDetailsContent","isLight","codeData","hasError","before","loaderResult","Col","Size","Title","CodeViewer","InputIcon","OutputIcon","Empty","DiffViewer","LoaderExecutions","data","index","loaders","currentIndex","setCurrentIndex","useState","theme","useTheme","leftSpan","activeKey","setActiveKey","onChange","useCallback","key","Row","styles","undefined","Timeline","e","i","arr","isPitch","costs","Tooltip","StepIcon","Tabs","ServerAPIProvider","SDK"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,MAAMA,kBAAkB,CAAC,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IAAI,SAAS,CAAC,GAAG,CAAC,2BAA2B;gCAClD,MAAM;oCACJ,MAAMxD,SAAS,IAAI;oCACnB,QAAQD,OAAO,MAAM;oCACrB,aAAaA,OAAO,WAAW;gCACjC;gCACA,cAAc;0CAEb,CAACiB,WAAAA,WAAAA,GACA,IAACF,sBAAAA;wCACC,QAAQf;wCACR,UAAUC;wCACV,SAASe;wCACT,UAAUC;;iCAId;wBACR;qBACD;oBACD,UAAUwB;;;;;AAKpB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Typography } from "antd";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { VSCode, openVSCode } from "./
|
|
4
|
+
import { VSCode, openVSCode } from "./ide.mjs";
|
|
5
5
|
import { getShortPath } from "../../utils/index.mjs";
|
|
6
6
|
function parseUrl(url) {
|
|
7
7
|
const strs = url.split(' ');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/Opener/code.mjs","sources":["../../../src/components/Opener/code.tsx"],"sourcesContent":["import { PropsWithChildren } from 'react';\nimport { Typography } from 'antd';\nimport path from 'path';\nimport { VSCode, openVSCode } from './
|
|
1
|
+
{"version":3,"file":"components/Opener/code.mjs","sources":["../../../src/components/Opener/code.tsx"],"sourcesContent":["import { PropsWithChildren } from 'react';\nimport { Typography } from 'antd';\nimport path from 'path';\nimport { VSCode, openVSCode } from './ide';\nimport { getShortPath } from 'src/utils';\n\ninterface CodeOpenerProps {\n windowId?: number;\n /**\n * @example /foo/src/pages/home/index.ts + 100 modules\n * @example /foo/src/pages/b/index.ts\n */\n url: string;\n /**\n * @example 1:0-10\n * @example 1:1\n */\n loc?: string;\n cwd: string;\n label?: string;\n disabled?: boolean;\n code?: boolean;\n}\n\nfunction parseUrl(url: string) {\n const strs = url.split(' ');\n let res = '';\n if (strs.length === 1) {\n [res] = strs;\n } else {\n [res] = strs.filter((e) => path.isAbsolute(e) || e.startsWith('./'));\n }\n\n return res || url;\n}\n\nfunction parseLoc(loc?: string) {\n if (!loc) return { line: 1, column: 1 };\n\n const [line, col = ''] = loc.split(':');\n const [start = 1, end] = col.split('-');\n\n return {\n line,\n columnStart: start,\n columnEnd: end || start,\n };\n}\n\nconst defaultWindowId = +Date.now().toString().slice(-4) + 1000;\n\nexport const CodeOpener = ({\n cwd,\n url,\n loc,\n windowId = defaultWindowId,\n label,\n disabled,\n code = false,\n}: PropsWithChildren<CodeOpenerProps>): JSX.Element | null => {\n const file = path.resolve(cwd, parseUrl(url));\n\n const { line, columnStart } = parseLoc(loc);\n\n return (\n <span style={{ wordBreak: 'break-all' }}>\n <Typography.Text\n copyable={{\n text: file,\n }}\n >\n <Typography.Text\n code={code}\n onClick={() => {\n if (disabled) return;\n openVSCode({ file, line, column: columnStart, windowId });\n }}\n style={{ cursor: disabled ? 'revert' : 'pointer' }}\n >\n {label || getShortPath(url)}\n {loc ? `:${loc}` : ''}\n </Typography.Text>\n </Typography.Text>\n {process.env.NODE_ENV === 'development' ? (\n <VSCode\n file={file}\n line={line}\n column={columnStart}\n windowId={windowId}\n style={{ marginLeft: 3 }}\n />\n ) : (\n <div style={{ display: 'inline-block' }} />\n )}\n {/* TODO implement open cloud ide or codebase by git url + branch + relative filepath in production */}\n </span>\n );\n};\n"],"names":["parseUrl","url","strs","res","e","path","parseLoc","loc","line","col","start","end","defaultWindowId","Date","CodeOpener","cwd","windowId","label","disabled","code","file","columnStart","Typography","openVSCode","getShortPath","process","VSCode"],"mappings":";;;;;AAwBA,SAASA,SAASC,GAAW;IAC3B,MAAMC,OAAOD,IAAI,KAAK,CAAC;IACvB,IAAIE,MAAM;IACV,IAAID,AAAgB,MAAhBA,KAAK,MAAM,EACb,CAACC,IAAI,GAAGD;SAER,CAACC,IAAI,GAAGD,KAAK,MAAM,CAAC,CAACE,IAAMC,KAAK,UAAU,CAACD,MAAMA,EAAE,UAAU,CAAC;IAGhE,OAAOD,OAAOF;AAChB;AAEA,SAASK,S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
|
|
|
7
7
|
style?: React.CSSProperties;
|
|
8
8
|
}
|
|
9
9
|
export declare function openVSCode({ file, line, column, windowId, }: VSCodeProps): void;
|
|
10
|
+
export declare function openCursor({ file, line, column, }: Pick<VSCodeProps, 'file' | 'line' | 'column'>): void;
|
|
11
|
+
export declare function openTrae({ file, line, column, }: Pick<VSCodeProps, 'file' | 'line' | 'column'>): void;
|
|
10
12
|
export declare const VSCode: (props: VSCodeProps) => JSX.Element;
|
|
11
13
|
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Lodash } from "@rsdoctor/utils/common";
|
|
3
|
+
import "react";
|
|
4
|
+
import vscode from "../../common/svg/vscode.mjs";
|
|
5
|
+
const OPEN_IN_EDITOR_PATH = '/__open-in-editor';
|
|
6
|
+
async function openInEditor(file, line, column, editor, urlSchemeFallback) {
|
|
7
|
+
const fileSpec = `${file}:${line}:${column}`;
|
|
8
|
+
try {
|
|
9
|
+
const base = "u" > typeof window && window.location?.origin ? window.location.origin : '';
|
|
10
|
+
const url = `${base}${OPEN_IN_EDITOR_PATH}?file=${encodeURIComponent(fileSpec)}&editor=${editor}`;
|
|
11
|
+
const res = await fetch(url, {
|
|
12
|
+
method: 'GET'
|
|
13
|
+
});
|
|
14
|
+
if (!res.ok) urlSchemeFallback();
|
|
15
|
+
} catch {
|
|
16
|
+
urlSchemeFallback();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function openVSCode({ file, line = 1, column = 1, windowId }) {
|
|
20
|
+
const query = {
|
|
21
|
+
windowId
|
|
22
|
+
};
|
|
23
|
+
const queryString = Object.keys(query).map((k)=>{
|
|
24
|
+
const v = query[k];
|
|
25
|
+
if (Lodash.isNil(v) || '' === v) return null;
|
|
26
|
+
return `${k}=${v}`;
|
|
27
|
+
}).filter(Boolean).join('&');
|
|
28
|
+
const fallback = ()=>{
|
|
29
|
+
let url = `vscode://file/${file}:${line}:${column}`;
|
|
30
|
+
if (queryString) url += `?${queryString}`;
|
|
31
|
+
window.open(url);
|
|
32
|
+
};
|
|
33
|
+
openInEditor(file, line, column, 'code', fallback);
|
|
34
|
+
}
|
|
35
|
+
function openCursor({ file, line = 1, column = 1 }) {
|
|
36
|
+
const fallback = ()=>{
|
|
37
|
+
window.open(`cursor://file/${file}:${line}:${column}`);
|
|
38
|
+
};
|
|
39
|
+
openInEditor(file, line, column, 'cursor', fallback);
|
|
40
|
+
}
|
|
41
|
+
function openTrae({ file, line = 1, column = 1 }) {
|
|
42
|
+
const fallback = ()=>{
|
|
43
|
+
window.open(`trae://file/${file}:${line}:${column}`);
|
|
44
|
+
};
|
|
45
|
+
openInEditor(file, line, column, 'trae', fallback);
|
|
46
|
+
}
|
|
47
|
+
const VSCode = (props)=>/*#__PURE__*/ jsx(vscode, {
|
|
48
|
+
onClick: ()=>{
|
|
49
|
+
openVSCode(props);
|
|
50
|
+
},
|
|
51
|
+
style: {
|
|
52
|
+
width: 14,
|
|
53
|
+
cursor: 'pointer',
|
|
54
|
+
verticalAlign: 'middle',
|
|
55
|
+
display: 'inline',
|
|
56
|
+
transform: 'translateY(-1.5px)',
|
|
57
|
+
...props.style
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
export { VSCode, openCursor, openTrae, openVSCode };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=ide.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components/Opener/ide.mjs","sources":["../../../src/components/Opener/ide.tsx"],"sourcesContent":["import { Lodash } from '@rsdoctor/utils/common';\nimport React from 'react';\nimport VSCodeIcon from '../../common/svg/vscode.svg';\n\ninterface VSCodeProps {\n file: string;\n line?: number | string;\n column?: number | string;\n windowId?: number;\n style?: React.CSSProperties;\n}\n\nconst OPEN_IN_EDITOR_PATH = '/__open-in-editor';\n\ntype EditorKind = 'code' | 'cursor' | 'trae';\n\nasync function openInEditor(\n file: string,\n line: number | string,\n column: number | string,\n editor: EditorKind,\n urlSchemeFallback: () => void,\n) {\n const fileSpec = `${file}:${line}:${column}`;\n try {\n const base =\n typeof window !== 'undefined' && window.location?.origin\n ? window.location.origin\n : '';\n const url = `${base}${OPEN_IN_EDITOR_PATH}?file=${encodeURIComponent(fileSpec)}&editor=${editor}`;\n const res = await fetch(url, { method: 'GET' });\n if (!res.ok) {\n urlSchemeFallback();\n }\n } catch {\n urlSchemeFallback();\n }\n}\n\nexport function openVSCode({\n file,\n line = 1,\n column = 1,\n windowId,\n}: VSCodeProps) {\n const query: Record<string, unknown> = { windowId };\n const queryString = Object.keys(query)\n .map((k) => {\n const v = query[k];\n if (Lodash.isNil(v) || v === '') return null;\n return `${k}=${v}`;\n })\n .filter(Boolean)\n .join('&');\n\n const fallback = () => {\n let url = `vscode://file/${file}:${line}:${column}`;\n if (queryString) url += `?${queryString}`;\n window.open(url);\n };\n\n openInEditor(file, line, column, 'code', fallback);\n}\n\nexport function openCursor({\n file,\n line = 1,\n column = 1,\n}: Pick<VSCodeProps, 'file' | 'line' | 'column'>) {\n const fallback = () => {\n window.open(`cursor://file/${file}:${line}:${column}`);\n };\n openInEditor(file, line, column, 'cursor', fallback);\n}\n\nexport function openTrae({\n file,\n line = 1,\n column = 1,\n}: Pick<VSCodeProps, 'file' | 'line' | 'column'>) {\n const fallback = () => {\n window.open(`trae://file/${file}:${line}:${column}`);\n };\n\n openInEditor(file, line, column, 'trae', fallback);\n}\n\nexport const VSCode = (props: VSCodeProps): JSX.Element => {\n return (\n <VSCodeIcon\n onClick={() => {\n openVSCode(props);\n }}\n style={{\n width: 14,\n cursor: 'pointer',\n verticalAlign: 'middle',\n display: 'inline',\n transform: 'translateY(-1.5px)',\n ...props.style,\n }}\n />\n );\n};\n"],"names":["OPEN_IN_EDITOR_PATH","openInEditor","file","line","column","editor","urlSchemeFallback","fileSpec","base","window","url","encodeURIComponent","res","fetch","openVSCode","windowId","query","queryString","Object","k","v","Lodash","Boolean","fallback","openCursor","openTrae","VSCode","props","VS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MmB,WAAW;QACfd,OAAO,IAAI,CAAC,CAAC,cAAc,EAAEP,KAAK,CAAC,EAAEC,KAAK,CAAC,EAAEC,QAAQ;IACvD;IACAH,aAAaC,MAAMC,MAAMC,QAAQ,UAAUmB;AAC7C;AAEO,SAASE,SAAS,EACvBvB,IAAI,EACJC,OAAO,CAAC,EACRC,SAAS,CAAC,EACoC;IAC9C,MAAMmB,WAAW;QACfd,OAAO,IAAI,CAAC,CAAC,YAAY,EAAEP,KAAK,CAAC,EAAEC,KAAK,CAAC,EAAEC,QAAQ;IACrD;IAEAH,aAAaC,MAAMC,MAAMC,QAAQ,QAAQmB;AAC3C;AAEO,MAAMG,SAAS,CAACC,QACd,WAAP,GACE,IAACC,QAAUA;QACT,SAAS;YACPd,WAAWa;QACb;QACA,OAAO;YACL,OAAO;YACP,QAAQ;YACR,eAAe;YACf,SAAS;YACT,WAAW;YACX,GAAGA,MAAM,KAAK;QAChB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './code.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './ide.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./code.mjs";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./ide.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CodeViewerProps } from './interface.js';
|
|
2
|
-
export declare function CodeViewer({ className, style, code, lang, filePath, defaultLine, ranges, isEmbed, headerVisible, isLightTheme, }: CodeViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function CodeViewer({ className, style, code, lang, filePath, defaultLine, ranges, isEmbed, headerVisible, isLightTheme, formatOnMount, }: CodeViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export type { CodeViewerProps } from './interface.js';
|
|
4
4
|
export { useCodeDrawer } from './useCodeDrawer.js';
|
|
5
5
|
export { defineMonacoOptions } from './utils.js';
|
|
@@ -7,7 +7,7 @@ import { Checkbox } from "antd";
|
|
|
7
7
|
import index_module from "./index.module.mjs";
|
|
8
8
|
import { Lodash } from "@rsdoctor/utils/common";
|
|
9
9
|
import { useCodeDrawer } from "./useCodeDrawer.mjs";
|
|
10
|
-
function CodeViewer({ className, style, code = '', lang, filePath = '', defaultLine, ranges, isEmbed = false, headerVisible = true, isLightTheme = true }) {
|
|
10
|
+
function CodeViewer({ className, style, code = '', lang, filePath = '', defaultLine, ranges, isEmbed = false, headerVisible = true, isLightTheme = true, formatOnMount = false }) {
|
|
11
11
|
const editor = useRef();
|
|
12
12
|
const monaco = useRef();
|
|
13
13
|
const language = useMemo(()=>lang || getFilePathFormat(filePath) || 'plaintext', [
|
|
@@ -27,7 +27,14 @@ function CodeViewer({ className, style, code = '', lang, filePath = '', defaultL
|
|
|
27
27
|
if (Lodash.isNumber(defaultLine)) setTimeout(()=>{
|
|
28
28
|
editorInstance.revealLine(defaultLine);
|
|
29
29
|
});
|
|
30
|
-
|
|
30
|
+
if (formatOnMount) setTimeout(()=>{
|
|
31
|
+
editorInstance.getAction('editor.action.formatDocument')?.run();
|
|
32
|
+
}, 0);
|
|
33
|
+
}, [
|
|
34
|
+
ranges,
|
|
35
|
+
defaultLine,
|
|
36
|
+
formatOnMount
|
|
37
|
+
]);
|
|
31
38
|
const theme = isLightTheme ? 'vs-light' : 'vs-dark';
|
|
32
39
|
useEffect(()=>()=>{
|
|
33
40
|
editor.current?.setModel(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/base/CodeViewer/index.mjs","sources":["../../../../src/components/base/CodeViewer/index.tsx"],"sourcesContent":["import { Editor, Monaco, OnMount } from '@monaco-editor/react';\nimport clsx from 'clsx';\nimport { editor } from 'monaco-editor';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { CodeViewerProps } from './interface';\nimport {\n defineMonacoOptions,\n editorShowRange,\n getFileName,\n getFilePathFormat,\n} from './utils';\n\nimport { Checkbox } from 'antd';\nimport styles from './index.module.scss';\nimport { Lodash } from '@rsdoctor/utils/common';\n\nexport function CodeViewer({\n className,\n style,\n code = '',\n lang,\n filePath = '',\n defaultLine,\n ranges,\n isEmbed = false,\n headerVisible = true,\n isLightTheme = true,\n}: CodeViewerProps) {\n const editor = useRef<editor.IStandaloneCodeEditor>();\n const monaco = useRef<Monaco>();\n const language = useMemo(\n () => lang || getFilePathFormat(filePath) || 'plaintext',\n [lang, filePath],\n );\n const [isWordWrap, setIsWordWrap] = useState(true);\n const options = useMemo(\n () => defineMonacoOptions({ wordWrap: isWordWrap ? 'on' : 'off' }),\n [isWordWrap],\n );\n const onEditorMount = useCallback<OnMount>((editorInstance, monacoVal) => {\n
|
|
1
|
+
{"version":3,"file":"components/base/CodeViewer/index.mjs","sources":["../../../../src/components/base/CodeViewer/index.tsx"],"sourcesContent":["import { Editor, Monaco, OnMount } from '@monaco-editor/react';\nimport clsx from 'clsx';\nimport { editor } from 'monaco-editor';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { CodeViewerProps } from './interface';\nimport {\n defineMonacoOptions,\n editorShowRange,\n getFileName,\n getFilePathFormat,\n} from './utils';\n\nimport { Checkbox } from 'antd';\nimport styles from './index.module.scss';\nimport { Lodash } from '@rsdoctor/utils/common';\n\nexport function CodeViewer({\n className,\n style,\n code = '',\n lang,\n filePath = '',\n defaultLine,\n ranges,\n isEmbed = false,\n headerVisible = true,\n isLightTheme = true,\n formatOnMount = false,\n}: CodeViewerProps) {\n const editor = useRef<editor.IStandaloneCodeEditor>();\n const monaco = useRef<Monaco>();\n const language = useMemo(\n () => lang || getFilePathFormat(filePath) || 'plaintext',\n [lang, filePath],\n );\n const [isWordWrap, setIsWordWrap] = useState(true);\n const options = useMemo(\n () => defineMonacoOptions({ wordWrap: isWordWrap ? 'on' : 'off' }),\n [isWordWrap],\n );\n const onEditorMount = useCallback<OnMount>(\n (editorInstance, monacoVal) => {\n editor.current = editorInstance;\n monaco.current = monacoVal;\n\n editorShowRange(editorInstance, monacoVal, ranges);\n if (Lodash.isNumber(defaultLine)) {\n setTimeout(() => {\n editorInstance.revealLine(defaultLine);\n });\n }\n\n if (formatOnMount) {\n // Use Monaco's built-in formatter to format the whole document\n setTimeout(() => {\n editorInstance.getAction('editor.action.formatDocument')?.run();\n }, 0);\n }\n },\n [ranges, defaultLine, formatOnMount],\n );\n\n const theme = isLightTheme ? 'vs-light' : 'vs-dark';\n\n useEffect(\n () => () => {\n editor.current?.setModel(null);\n },\n [],\n );\n\n return (\n <div\n className={clsx(\n 'monaco-component',\n 'code-viewer',\n styles['code-viewer'],\n isEmbed && styles['embed'],\n className,\n )}\n style={style}\n >\n {headerVisible && Boolean(filePath) && (\n <div className={styles['header']}>\n <div>{getFileName(filePath)}</div>\n <div style={{ flex: 1 }} />\n <div>\n <Checkbox\n className={styles['text']}\n title=\"side-by-side\"\n checked={isWordWrap}\n onChange={(evt) => {\n setIsWordWrap(evt.target.checked);\n }}\n >\n word-wrap\n </Checkbox>\n </div>\n </div>\n )}\n <div className={clsx(styles['content'], 'editor-wrap')}>\n <Editor\n theme={theme}\n language={language}\n value={code}\n options={options}\n onMount={onEditorMount}\n />\n </div>\n </div>\n );\n}\n\nexport type { CodeViewerProps } from './interface';\nexport { useCodeDrawer } from './useCodeDrawer';\nexport { defineMonacoOptions } from './utils';\n"],"names":["CodeViewer","className","style","code","lang","filePath","defaultLine","ranges","isEmbed","headerVisible","isLightTheme","formatOnMount","editor","useRef","monaco","language","useMemo","getFilePathFormat","isWordWrap","setIsWordWrap","useState","options","defineMonacoOptions","onEditorMount","useCallback","editorInstance","monacoVal","editorShowRange","Lodash","setTimeout","theme","useEffect","clsx","styles","Boolean","getFileName","Checkbox","evt","Editor"],"mappings":";;;;;;;;;AAgBO,SAASA,WAAW,EACzBC,SAAS,EACTC,KAAK,EACLC,OAAO,EAAE,EACTC,IAAI,EACJC,WAAW,EAAE,EACbC,WAAW,EACXC,MAAM,EACNC,UAAU,KAAK,EACfC,gBAAgB,IAAI,EACpBC,eAAe,IAAI,EACn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