@rsdoctor/components 1.5.11 → 1.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/components/Alert/types.d.ts +2 -2
  2. package/dist/components/Alerts/bundle-alert.d.ts +1 -1
  3. package/dist/components/Alerts/bundle-alert.mjs.map +1 -1
  4. package/dist/components/Alerts/collapse-cjs-require.d.ts +1 -1
  5. package/dist/components/Alerts/collapse-cross-chunks.d.ts +1 -1
  6. package/dist/components/Alerts/collapse-esm-cjs.d.ts +1 -1
  7. package/dist/components/Alerts/collapse-module-mixed-chunks.d.ts +1 -1
  8. package/dist/components/Alerts/collapse-shared.d.ts +2 -2
  9. package/dist/components/Alerts/collapse-side-effects-only-imports.d.ts +1 -1
  10. package/dist/components/Alerts/collapse.d.ts +1 -1
  11. package/dist/components/Alerts/list.d.ts +1 -1
  12. package/dist/components/Alerts/overlay.mjs.map +1 -1
  13. package/dist/components/Charts/done.mjs.map +1 -1
  14. package/dist/components/Configuration/builder.d.ts +1 -5
  15. package/dist/components/Configuration/builder.mjs.map +1 -1
  16. package/dist/components/FileTree/index.d.ts +1 -1
  17. package/dist/components/Layout/index.d.ts +2 -2
  18. package/dist/components/Layout/index.mjs.map +1 -1
  19. package/dist/components/Loader/Analysis/files.mjs.map +1 -1
  20. package/dist/components/Loader/Analysis/index.d.ts +1 -7
  21. package/dist/components/Loader/Analysis/index.mjs.map +1 -1
  22. package/dist/components/Loader/executions.d.ts +1 -1
  23. package/dist/components/Loader/executions.mjs.map +1 -1
  24. package/dist/components/Manifest/api.d.ts +2 -2
  25. package/dist/components/Manifest/api.mjs.map +1 -1
  26. package/dist/components/Opener/code.d.ts +1 -1
  27. package/dist/components/Opener/code.mjs.map +1 -1
  28. package/dist/components/Opener/ide.d.ts +1 -1
  29. package/dist/components/Opener/ide.mjs.map +1 -1
  30. package/dist/components/Overall/DataSummary.d.ts +1 -1
  31. package/dist/components/Overall/bundle.d.ts +1 -1
  32. package/dist/components/Overall/bundle.mjs.map +1 -1
  33. package/dist/components/Overall/help-center.d.ts +1 -1
  34. package/dist/components/Overall/overview.d.ts +1 -1
  35. package/dist/components/TextDrawer/index.d.ts +1 -1
  36. package/dist/components/TextDrawer/index.mjs.map +1 -1
  37. package/dist/components/base/CodeViewer/index.d.ts +1 -1
  38. package/dist/components/base/CodeViewer/index.mjs +2 -2
  39. package/dist/components/base/CodeViewer/index.mjs.map +1 -1
  40. package/dist/components/base/CodeViewer/useCodeDrawer.d.ts +1 -1
  41. package/dist/components/base/DiffViewer/index.d.ts +1 -1
  42. package/dist/components/base/DiffViewer/index.mjs +1 -1
  43. package/dist/components/base/DiffViewer/index.mjs.map +1 -1
  44. package/dist/components/base/DiffViewer/useDiffDrawer.d.ts +1 -1
  45. package/dist/pages/BundleSize/components/asset.mjs +390 -323
  46. package/dist/pages/BundleSize/components/asset.mjs.map +1 -1
  47. package/dist/pages/BundleSize/components/asset.module.mjs +16 -0
  48. package/dist/pages/BundleSize/components/asset.module.mjs.map +1 -0
  49. package/dist/pages/BundleSize/components/asset_module.css +103 -0
  50. package/dist/pages/BundleSize/components/asset_module.css.map +1 -0
  51. package/dist/pages/BundleSize/components/index.mjs +3 -0
  52. package/dist/pages/BundleSize/components/index.mjs.map +1 -1
  53. package/dist/pages/BundleSize/components/index.module.mjs +0 -7
  54. package/dist/pages/BundleSize/components/index.module.mjs.map +1 -1
  55. package/dist/pages/BundleSize/components/index_module.css +0 -61
  56. package/dist/pages/BundleSize/components/index_module.css.map +1 -1
  57. package/dist/pages/ModuleAnalyze/chunks.mjs.map +1 -1
  58. package/dist/pages/Overall/responsiveLayout.d.ts +1 -1
  59. package/dist/pages/Resources/BundleDiff/DiffContainer/types.d.ts +1 -1
  60. package/dist/pages/Resources/BundleDiff/DiffContainer/utils.d.ts +1 -1
  61. package/dist/pages/Resources/BundleDiff/DiffServerAPIProvider/index.d.ts +1 -1
  62. package/dist/pages/Resources/BundleDiff/DiffServerAPIProvider/index.mjs.map +1 -1
  63. package/dist/pages/TreeShaking/editor.d.ts +1 -1
  64. package/dist/pages/TreeShaking/editor.mjs +2 -2
  65. package/dist/pages/TreeShaking/editor.mjs.map +1 -1
  66. package/dist/pages/TreeShaking/space.d.ts +1 -1
  67. package/dist/utils/file.d.ts +4 -4
  68. package/dist/utils/file.mjs.map +1 -1
  69. package/dist/utils/hooks.d.ts +4 -0
  70. package/dist/utils/hooks.mjs +42 -3
  71. package/dist/utils/hooks.mjs.map +1 -1
  72. package/package.json +18 -17
@@ -1,31 +1,51 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { CodepenCircleOutlined, ColumnHeightOutlined, InfoCircleOutlined } from "@ant-design/icons";
3
3
  import { SDK } from "@rsdoctor/types";
4
- import { Button, Card, Col, Divider, Empty, Popover, Row, Space, Tag, Tooltip, Tree, Typography } from "antd";
5
- import { omitBy, sumBy } from "es-toolkit/compat";
4
+ import { Button, Card, Divider, Empty, Popover, Space, Tag, Tooltip, Tree, Typography } from "antd";
5
+ import { debounce, omitBy, sumBy } from "es-toolkit/compat";
6
6
  import { dirname, relative } from "path";
7
- import { useEffect, useMemo, useState } from "react";
7
+ import { createContext, memo, use, useCallback, useEffect, useMemo, useState } from "react";
8
8
  import { CodeViewer } from "../../../components/base/index.mjs";
9
9
  import { Badge } from "../../../components/Badge/index.mjs";
10
10
  import { KeywordInput } from "../../../components/Form/keyword.mjs";
11
- import { Keyword } from "../../../components/Keyword/index.mjs";
12
11
  import { ServerAPIProvider } from "../../../components/Manifest/index.mjs";
13
12
  import { TextDrawer } from "../../../components/TextDrawer/index.mjs";
14
13
  import { Size } from "../../../constants.mjs";
15
- import { createFileStructures, formatSize, isJsDataUrl, useI18n } from "../../../utils/index.mjs";
14
+ import { createFileStructures, formatSize, isJsDataUrl, useElementSize, useI18n } from "../../../utils/index.mjs";
16
15
  import { ModuleAnalyzeComponent } from "../../ModuleAnalyze/index.mjs";
17
16
  import { ModuleGraphListContext } from "../config.mjs";
18
- import index_module from "./index.module.mjs";
17
+ import asset_module from "./asset.module.mjs";
18
+ import { ErrorBoundary } from "react-error-boundary";
19
19
  const { DirectoryTree: DirectoryTree } = Tree;
20
- let expandedModulesKeys = [];
21
20
  const TAB_MAP = {
22
21
  source: 'source code',
23
22
  transformed: 'Transformed Code (After compile)',
24
23
  parsedSource: 'Bundled Code (After bundle and tree-shaking)'
25
24
  };
26
- const tagStyle = {
27
- margin: 'none',
28
- marginInlineEnd: 0
25
+ const POPUPS_ENABLED_BY_DEFAULT = true;
26
+ const PopupContext = /*#__PURE__*/ createContext({
27
+ enabled: POPUPS_ENABLED_BY_DEFAULT
28
+ });
29
+ const DisablePopups = ({ children })=>/*#__PURE__*/ jsx(PopupContext.Provider, {
30
+ value: {
31
+ enabled: false
32
+ },
33
+ children: children
34
+ });
35
+ const usePopupsEnabled = ()=>use(PopupContext)?.enabled ?? true;
36
+ const asset_Tooltip = (props)=>{
37
+ const enabled = usePopupsEnabled();
38
+ if (enabled) return /*#__PURE__*/ jsx(Tooltip, {
39
+ ...props
40
+ });
41
+ return props.children ?? null;
42
+ };
43
+ const asset_Popover = (props)=>{
44
+ const enabled = usePopupsEnabled();
45
+ if (enabled) return /*#__PURE__*/ jsx(Popover, {
46
+ ...props
47
+ });
48
+ return props.children ?? null;
29
49
  };
30
50
  const EmptyCodeItem = ()=>/*#__PURE__*/ jsx(Empty, {
31
51
  description: `Do not have the module code.
@@ -46,7 +66,7 @@ const ModuleCodeViewer = ({ data })=>{
46
66
  text: "",
47
67
  buttonProps: {
48
68
  size: 'small',
49
- icon: /*#__PURE__*/ jsx(Popover, {
69
+ icon: /*#__PURE__*/ jsx(asset_Popover, {
50
70
  content: "Open the Codes Box",
51
71
  children: /*#__PURE__*/ jsx(CodepenCircleOutlined, {})
52
72
  }),
@@ -79,7 +99,7 @@ const ModuleCodeViewer = ({ data })=>{
79
99
  })),
80
100
  defaultActiveTabKey: source['parsedSource'] ? 'parsedSource' : 'source',
81
101
  onTabChange: (v)=>setTab(v),
82
- tabBarExtraContent: /*#__PURE__*/ jsx(Popover, {
102
+ tabBarExtraContent: /*#__PURE__*/ jsx(asset_Popover, {
83
103
  placement: "bottom",
84
104
  title: /*#__PURE__*/ jsx(Typography.Title, {
85
105
  level: 5,
@@ -181,7 +201,7 @@ function getChildrenModule(node, mods) {
181
201
  });
182
202
  return mods;
183
203
  }
184
- const ModulesStatistics = ({ modules, chunks, filteredModules })=>{
204
+ const ModulesStatistics = /*#__PURE__*/ memo(({ modules, chunks, filteredModules })=>{
185
205
  const { sourceSize, parsedSize, filteredParsedSize, filteredSourceSize } = useMemo(()=>({
186
206
  sourceSize: sumBy(modules, (e)=>e.size.sourceSize),
187
207
  parsedSize: sumBy(modules, (e)=>e.size.parsedSize),
@@ -193,7 +213,7 @@ const ModulesStatistics = ({ modules, chunks, filteredModules })=>{
193
213
  ]);
194
214
  return /*#__PURE__*/ jsxs(Space, {
195
215
  children: [
196
- /*#__PURE__*/ jsx(Tooltip, {
216
+ /*#__PURE__*/ jsx(asset_Tooltip, {
197
217
  title: `total modules count is ${modules.length}, the filtered modules count is ${filteredModules.length}`,
198
218
  children: /*#__PURE__*/ jsxs(Space, {
199
219
  children: [
@@ -217,7 +237,7 @@ const ModulesStatistics = ({ modules, chunks, filteredModules })=>{
217
237
  /*#__PURE__*/ jsx(Divider, {
218
238
  type: "vertical"
219
239
  }),
220
- /*#__PURE__*/ jsx(Tooltip, {
240
+ /*#__PURE__*/ jsx(asset_Tooltip, {
221
241
  title: /*#__PURE__*/ jsxs(Space, {
222
242
  direction: "vertical",
223
243
  children: [
@@ -279,7 +299,7 @@ const ModulesStatistics = ({ modules, chunks, filteredModules })=>{
279
299
  /*#__PURE__*/ jsx(Divider, {
280
300
  type: "vertical"
281
301
  }),
282
- /*#__PURE__*/ jsx(Tooltip, {
302
+ /*#__PURE__*/ jsx(asset_Tooltip, {
283
303
  title: /*#__PURE__*/ jsxs(Space, {
284
304
  direction: "vertical",
285
305
  children: [
@@ -318,104 +338,64 @@ const ModulesStatistics = ({ modules, chunks, filteredModules })=>{
318
338
  })
319
339
  ]
320
340
  });
341
+ });
342
+ const defaultTagStyle = {
343
+ margin: 'none',
344
+ marginInlineEnd: 0
321
345
  };
322
- const ConcatenatedTag = ({ moduleCount })=>/*#__PURE__*/ jsx(Tooltip, {
323
- title: /*#__PURE__*/ jsx(Space, {
324
- children: /*#__PURE__*/ jsxs(Typography.Text, {
325
- style: {
326
- color: 'inherit'
327
- },
328
- children: [
329
- "This is a concatenated container module that includes ",
330
- moduleCount,
331
- ' ',
332
- "modules"
333
- ]
334
- })
335
- }),
336
- children: /*#__PURE__*/ jsx(Tag, {
337
- color: "blue",
338
- style: tagStyle,
339
- children: "concatenated container"
340
- })
341
- });
342
- const TotalBundledSizeTag = ({ size })=>/*#__PURE__*/ jsx(Tooltip, {
346
+ const AbstractTag = ({ color, tooltipTitle, style = defaultTagStyle, children })=>/*#__PURE__*/ jsx(asset_Tooltip, {
343
347
  title: /*#__PURE__*/ jsx(Space, {
344
348
  children: /*#__PURE__*/ jsx(Typography.Text, {
345
349
  style: {
346
350
  color: 'inherit'
347
351
  },
348
- children: "The total output size of all the files in this folder. If you enabled minification, this value shows the minified size."
352
+ children: tooltipTitle
349
353
  })
350
354
  }),
351
355
  children: /*#__PURE__*/ jsx(Tag, {
352
- style: tagStyle,
353
- color: 'geekblue',
354
- children: `bundled size: ${formatSize(size)}`
356
+ color: color,
357
+ style: style || void 0,
358
+ children: children
355
359
  })
356
360
  });
357
- const BundledSizeTag = ({ size })=>/*#__PURE__*/ jsx(Tooltip, {
358
- title: /*#__PURE__*/ jsx(Space, {
359
- children: /*#__PURE__*/ jsx(Typography.Text, {
360
- style: {
361
- color: 'inherit'
362
- },
363
- children: "The final output size of this file. If you enabled minification, this value shows the minified size."
364
- })
365
- }),
366
- children: /*#__PURE__*/ jsx(Tag, {
367
- color: 'geekblue',
368
- children: `bundled size: ${formatSize(size)}`
369
- })
361
+ const ConcatenatedTag = ({ moduleCount })=>/*#__PURE__*/ jsx(AbstractTag, {
362
+ color: "blue",
363
+ tooltipTitle: `This is a concatenated container module that includes ${moduleCount} modules`,
364
+ children: "concatenated container"
370
365
  });
371
- const GzippedSizeTag = ({ size })=>/*#__PURE__*/ jsx(Tooltip, {
372
- title: /*#__PURE__*/ jsx(Space, {
373
- children: /*#__PURE__*/ jsx(Typography.Text, {
374
- style: {
375
- color: 'inherit'
376
- },
377
- children: "The compressed file size that users actually download, as most web servers use gzip compression."
378
- })
379
- }),
380
- children: /*#__PURE__*/ jsx(Tag, {
381
- color: 'orange',
382
- children: `gzipped: ${formatSize(size)}`
383
- })
366
+ const TotalBundledSizeTag = ({ size })=>/*#__PURE__*/ jsx(AbstractTag, {
367
+ color: "geekblue",
368
+ tooltipTitle: "The total output size of all the files in this folder. If you enabled minification, this value shows the minified size.",
369
+ children: `bundled size: ${formatSize(size)}`
384
370
  });
385
- const TotalSourceSizeTag = ({ size })=>/*#__PURE__*/ jsx(Tooltip, {
386
- title: /*#__PURE__*/ jsx(Space, {
387
- children: /*#__PURE__*/ jsx(Typography.Text, {
388
- style: {
389
- color: 'inherit'
390
- },
391
- children: "The total original size of all the files in this folder, before any transformations and minification."
392
- })
393
- }),
394
- children: /*#__PURE__*/ jsx(Tag, {
395
- style: tagStyle,
396
- color: 'cyan',
397
- children: `source size: ${formatSize(size)}`
398
- })
371
+ const BundledSizeTag = ({ size })=>/*#__PURE__*/ jsx(AbstractTag, {
372
+ color: "geekblue",
373
+ style: null,
374
+ tooltipTitle: "The final output size of this file. If you enabled minification, this value shows the minified size.",
375
+ children: `bundled size: ${formatSize(size)}`
399
376
  });
400
- const SourceSizeTag = ({ size })=>/*#__PURE__*/ jsx(Tooltip, {
401
- title: /*#__PURE__*/ jsx(Space, {
402
- children: /*#__PURE__*/ jsx(Typography.Text, {
403
- style: {
404
- color: 'inherit'
405
- },
406
- children: "The original size of this file, before any transformations and minification."
407
- })
408
- }),
409
- children: /*#__PURE__*/ jsx(Tag, {
410
- color: 'cyan',
411
- children: `source size: ${formatSize(size)}`
412
- })
377
+ const GzippedSizeTag = ({ size })=>/*#__PURE__*/ jsx(AbstractTag, {
378
+ color: "orange",
379
+ style: null,
380
+ tooltipTitle: "The compressed file size that users actually download, as most web servers use gzip compression.",
381
+ children: `gzipped: ${formatSize(size)}`
382
+ });
383
+ const TotalSourceSizeTag = ({ size })=>/*#__PURE__*/ jsx(AbstractTag, {
384
+ tooltipTitle: "The total original size of all the files in this folder, before any transformations and minification.",
385
+ color: "cyan",
386
+ children: `source size: ${formatSize(size)}`
387
+ });
388
+ const SourceSizeTag = ({ size })=>/*#__PURE__*/ jsx(AbstractTag, {
389
+ color: "cyan",
390
+ style: null,
391
+ tooltipTitle: "The original size of this file, before any transformations and minification.",
392
+ children: `source size: ${formatSize(size)}`
413
393
  });
414
394
  const AssetDetail = ({ asset, chunks: includeChunks, modules: includeModules, moduleSizeLimit, height, root })=>{
415
395
  const [moduleKeyword, setModuleKeyword] = useState('');
416
396
  const [defaultExpandAll, setDefaultExpandAll] = useState(false);
417
397
  const [moduleJumpList, setModuleJumpList] = useState([]);
418
- const [show, setShow] = useState(false);
398
+ const [showModuleGraphViewer, setShowModuleGraphViewer] = useState(false);
419
399
  const filteredModules = useMemo(()=>{
420
400
  let res = includeModules.slice();
421
401
  if (moduleKeyword) {
@@ -429,197 +409,11 @@ const AssetDetail = ({ asset, chunks: includeChunks, modules: includeModules, mo
429
409
  moduleKeyword,
430
410
  moduleSizeLimit
431
411
  ]);
432
- const fileStructures = useMemo(()=>{
433
- const normalizePath = (path)=>path.replace(/\\/g, '/');
434
- const res = createFileStructures({
435
- files: filteredModules.map((e)=>e.path).filter(Boolean),
436
- inlinedResourcePathKey: inlinedResourcePathKey,
437
- fileTitle (file, basename) {
438
- const mod = filteredModules.find((e)=>normalizePath(e.path) === normalizePath(file));
439
- if (!mod) return basename;
440
- const { parsedSize = 0, sourceSize = 0, gzipSize = 0 } = mod.size;
441
- const isConcatenation = mod.kind === SDK.ModuleKind.Concatenation;
442
- const containedOtherModules = !isConcatenation && 0 === parsedSize && includeModules.filter((e)=>e !== mod && e.modules && e.modules.indexOf(mod.id) > -1);
443
- return /*#__PURE__*/ jsxs("div", {
444
- className: index_module["bundle-tree"],
445
- children: [
446
- /*#__PURE__*/ jsx(Popover, {
447
- content: `Open the ${basename}’s module reasons tree.`,
448
- placement: "bottom",
449
- children: /*#__PURE__*/ jsxs("div", {
450
- className: index_module.box,
451
- onClick: ()=>{
452
- setModuleJumpList([
453
- mod.id
454
- ]);
455
- setShow(true);
456
- },
457
- children: [
458
- /*#__PURE__*/ jsx("div", {
459
- className: index_module.keywords,
460
- children: /*#__PURE__*/ jsx(Keyword, {
461
- ellipsis: true,
462
- text: basename,
463
- keyword: ''
464
- })
465
- }),
466
- /*#__PURE__*/ jsx("div", {
467
- className: index_module.dividerDiv,
468
- children: /*#__PURE__*/ jsx(Divider, {
469
- className: index_module.divider,
470
- dashed: true
471
- })
472
- })
473
- ]
474
- })
475
- }),
476
- /*#__PURE__*/ jsxs(Space, {
477
- children: [
478
- 0 !== parsedSize ? /*#__PURE__*/ jsx(Fragment, {
479
- children: 'number' == typeof gzipSize ? /*#__PURE__*/ jsx(Popover, {
480
- placement: "bottom",
481
- content: /*#__PURE__*/ jsx(SourceSizeTag, {
482
- size: sourceSize
483
- }),
484
- children: /*#__PURE__*/ jsxs(Space, {
485
- direction: "horizontal",
486
- children: [
487
- /*#__PURE__*/ jsx(BundledSizeTag, {
488
- size: parsedSize
489
- }),
490
- /*#__PURE__*/ jsx(GzippedSizeTag, {
491
- size: gzipSize
492
- })
493
- ]
494
- })
495
- }) : /*#__PURE__*/ jsxs(Space, {
496
- direction: "horizontal",
497
- children: [
498
- /*#__PURE__*/ jsx(BundledSizeTag, {
499
- size: parsedSize
500
- }),
501
- /*#__PURE__*/ jsx(SourceSizeTag, {
502
- size: sourceSize
503
- })
504
- ]
505
- })
506
- }) : 0 !== sourceSize ? /*#__PURE__*/ jsx(SourceSizeTag, {
507
- size: sourceSize
508
- }) : null,
509
- isConcatenation ? /*#__PURE__*/ jsx(ConcatenatedTag, {
510
- moduleCount: mod.modules?.length || 0
511
- }) : null,
512
- containedOtherModules && containedOtherModules.length ? /*#__PURE__*/ jsx(Tooltip, {
513
- title: /*#__PURE__*/ jsxs(Space, {
514
- direction: "vertical",
515
- children: [
516
- /*#__PURE__*/ jsx(Typography.Text, {
517
- style: {
518
- color: 'inherit'
519
- },
520
- children: "This module is concatenated into another container module:"
521
- }),
522
- containedOtherModules.map(({ id, path })=>{
523
- if (isJsDataUrl(path)) return /*#__PURE__*/ jsx(Typography.Paragraph, {
524
- ellipsis: {
525
- rows: 4
526
- },
527
- style: {
528
- color: 'inherit',
529
- maxWidth: '100%'
530
- },
531
- code: true,
532
- children: path
533
- }, id);
534
- const p = relative(dirname(mod.path), path);
535
- if (p.startsWith("javascript;charset=utf-8;base64,")) return /*#__PURE__*/ jsx(Typography.Text, {
536
- style: {
537
- color: 'inherit',
538
- maxWidth: '100%'
539
- },
540
- code: true,
541
- children: '.' === p[0] ? p : `./${p}`
542
- }, id);
543
- return /*#__PURE__*/ jsx(Typography.Text, {
544
- style: {
545
- color: 'inherit'
546
- },
547
- code: true,
548
- children: '.' === p[0] ? p : `./${p}`
549
- }, id);
550
- })
551
- ]
552
- }),
553
- children: /*#__PURE__*/ jsx(Tag, {
554
- color: "green",
555
- children: "concatenated"
556
- })
557
- }) : null,
558
- /*#__PURE__*/ jsx(ModuleCodeViewer, {
559
- data: mod
560
- })
561
- ]
562
- })
563
- ]
564
- });
565
- },
566
- dirTitle (dir, defaultTitle) {
567
- const mods = [];
568
- const paths = getChildrenModule(dir, mods);
569
- if (paths.length) {
570
- const normalizePath = (path)=>path.replace(/\\/g, '/');
571
- const mods = paths.map((e)=>includeModules.find((m)=>normalizePath(m.path) === normalizePath(e)));
572
- const parsedSize = sumBy(mods, (e)=>e?.size?.parsedSize || 0);
573
- const sourceSize = sumBy(mods, (e)=>e?.size?.sourceSize || 0);
574
- return /*#__PURE__*/ jsxs("div", {
575
- className: index_module["bundle-tree"],
576
- children: [
577
- /*#__PURE__*/ jsxs("div", {
578
- className: index_module.box,
579
- children: [
580
- /*#__PURE__*/ jsx("div", {
581
- className: index_module.keywords,
582
- children: /*#__PURE__*/ jsx(Keyword, {
583
- ellipsis: true,
584
- text: defaultTitle,
585
- keyword: ''
586
- })
587
- }),
588
- /*#__PURE__*/ jsx("div", {
589
- className: index_module.dividerDiv,
590
- children: /*#__PURE__*/ jsx(Divider, {
591
- className: index_module.divider,
592
- dashed: true
593
- })
594
- })
595
- ]
596
- }),
597
- /*#__PURE__*/ jsx(Space, {
598
- children: parsedSize > 0 ? /*#__PURE__*/ jsxs(Fragment, {
599
- children: [
600
- /*#__PURE__*/ jsx(TotalBundledSizeTag, {
601
- size: parsedSize
602
- }),
603
- /*#__PURE__*/ jsx(TotalSourceSizeTag, {
604
- size: sourceSize
605
- })
606
- ]
607
- }) : /*#__PURE__*/ jsx(TotalSourceSizeTag, {
608
- size: sourceSize
609
- })
610
- })
611
- ]
612
- });
613
- }
614
- return defaultTitle;
615
- },
616
- page: 'bundle'
617
- });
618
- return res;
619
- }, [
620
- filteredModules
621
- ]);
622
412
  const onSearch = (value)=>setModuleKeyword(value);
413
+ const openModuleGraphViewer = useCallback((modId)=>{
414
+ setShowModuleGraphViewer(true);
415
+ setModuleJumpList(modId);
416
+ }, []);
623
417
  useEffect(()=>{
624
418
  setModuleKeyword('');
625
419
  setDefaultExpandAll(false);
@@ -637,25 +431,26 @@ const AssetDetail = ({ asset, chunks: includeChunks, modules: includeModules, mo
637
431
  setModuleJumpList
638
432
  },
639
433
  children: /*#__PURE__*/ jsxs(Card, {
640
- className: index_module.bundle,
434
+ className: asset_module.bundle,
641
435
  title: `Modules of "${asset.path}"`,
642
- bodyStyle: {
643
- minHeight: height
436
+ style: {
437
+ '--body-min-height': height + 'px'
438
+ },
439
+ classNames: {
440
+ body: asset_module.bundleBody
644
441
  },
645
442
  size: "small",
646
443
  children: [
647
- includeModules.length ? /*#__PURE__*/ jsxs(Row, {
444
+ includeModules.length ? /*#__PURE__*/ jsxs(Fragment, {
648
445
  children: [
649
- /*#__PURE__*/ jsx(Col, {
650
- span: 24,
446
+ /*#__PURE__*/ jsx("div", {
651
447
  children: /*#__PURE__*/ jsx(ModulesStatistics, {
652
448
  modules: includeModules,
653
449
  chunks: includeChunks,
654
450
  filteredModules: filteredModules
655
451
  })
656
452
  }),
657
- /*#__PURE__*/ jsx(Col, {
658
- span: 24,
453
+ /*#__PURE__*/ jsx("div", {
659
454
  children: /*#__PURE__*/ jsxs(Space, {
660
455
  children: [
661
456
  /*#__PURE__*/ jsx(KeywordInput, {
@@ -670,34 +465,13 @@ const AssetDetail = ({ asset, chunks: includeChunks, modules: includeModules, mo
670
465
  ]
671
466
  })
672
467
  }),
673
- /*#__PURE__*/ jsx(Col, {
674
- span: 24,
675
- style: {
676
- marginTop: Size.BasePadding
677
- },
678
- children: filteredModules.length ? /*#__PURE__*/ jsx(DirectoryTree, {
679
- selectable: false,
680
- defaultExpandAll: defaultExpandAll || filteredModules.length <= 20,
681
- onExpand: (expandedKeys)=>{
682
- expandedModulesKeys = expandedKeys;
683
- },
684
- defaultExpandParent: true,
685
- defaultExpandedKeys: expandedModulesKeys?.length ? expandedModulesKeys : 1 === fileStructures.length ? [
686
- fileStructures[0].key
687
- ] : [],
688
- treeData: fileStructures,
689
- rootStyle: {
690
- maxHeight: '500px',
691
- overflow: 'auto',
692
- border: '1px solid rgba(235, 237, 241)',
693
- padding: '14px 20px'
694
- }
695
- }, `tree_${moduleKeyword}_${defaultExpandAll}_${asset.path}`) : /*#__PURE__*/ jsx(Empty, {
696
- description: /*#__PURE__*/ jsx(Typography.Text, {
697
- strong: true,
698
- children: `"${moduleKeyword}" can't match any modules`
699
- })
700
- })
468
+ /*#__PURE__*/ jsx(AssetDetailTree, {
469
+ assetPath: asset.path,
470
+ includeModules: includeModules,
471
+ filteredModules: filteredModules,
472
+ defaultExpandAll: defaultExpandAll,
473
+ moduleKeyword: moduleKeyword,
474
+ openModuleGraphViewer: openModuleGraphViewer
701
475
  })
702
476
  ]
703
477
  }) : /*#__PURE__*/ jsx(Empty, {
@@ -708,14 +482,307 @@ const AssetDetail = ({ asset, chunks: includeChunks, modules: includeModules, mo
708
482
  }),
709
483
  /*#__PURE__*/ jsx(ModuleGraphViewer, {
710
484
  id: moduleJumpList?.length ? moduleJumpList[moduleJumpList.length - 1] : '',
711
- show: show,
712
- setShow: setShow,
485
+ show: showModuleGraphViewer,
486
+ setShow: setShowModuleGraphViewer,
713
487
  cwd: root
714
488
  })
715
489
  ]
716
490
  })
717
491
  });
718
492
  };
493
+ let defaultExpandedModulesKeys = [];
494
+ const AssetDetailTree = /*#__PURE__*/ memo(({ filteredModules, includeModules, defaultExpandAll, moduleKeyword, openModuleGraphViewer, assetPath })=>{
495
+ const ITEM_HEIGHT = 30;
496
+ const PERMANENT_PERF_MODE = false;
497
+ const DISABLE_PERF_MODE_SCROLL_DELAY = 150;
498
+ const [performanceMode, setPerformanceMode] = useState(PERMANENT_PERF_MODE);
499
+ const [bundleTreeRef, { height: bundleTreeHeight, width: bundleTreeWidth }] = useElementSize();
500
+ const onScroll = useMemo(()=>{
501
+ if (PERMANENT_PERF_MODE) return;
502
+ const disablePerformanceMode = debounce(()=>{
503
+ setPerformanceMode(false);
504
+ }, DISABLE_PERF_MODE_SCROLL_DELAY);
505
+ const onScroll = ()=>{
506
+ setPerformanceMode(true);
507
+ disablePerformanceMode();
508
+ };
509
+ return onScroll;
510
+ }, []);
511
+ const treeData = useMemo(()=>{
512
+ const normalizePath = (path)=>path.replace(/\\/g, '/');
513
+ const filteredModulesMap = new Map();
514
+ const files = [];
515
+ for (const mod of filteredModules)if (mod.path) {
516
+ filteredModulesMap.set(normalizePath(mod.path), mod);
517
+ files.push(mod.path);
518
+ }
519
+ const includeModulesMap = new Map();
520
+ for (const mod of includeModules)if (mod.path) includeModulesMap.set(normalizePath(mod.path), mod);
521
+ const onFileEntryClick = (modId)=>openModuleGraphViewer([
522
+ modId
523
+ ]);
524
+ const treeData = createFileStructures({
525
+ files,
526
+ inlinedResourcePathKey: inlinedResourcePathKey,
527
+ fileTitle (file, basename) {
528
+ const mod = filteredModulesMap.get(normalizePath(file));
529
+ if (!mod) return basename;
530
+ return /*#__PURE__*/ jsx(AssetDetailTreeFileEntry, {
531
+ mod: mod,
532
+ basename: basename,
533
+ includeModules: includeModules,
534
+ onClick: onFileEntryClick
535
+ });
536
+ },
537
+ dirTitle (dir, defaultTitle) {
538
+ const paths = getChildrenModule(dir, []);
539
+ if (!paths.length) return defaultTitle;
540
+ const { parsedSize, sourceSize } = paths.reduce((acc, path)=>{
541
+ const mod = includeModulesMap.get(normalizePath(path));
542
+ if (mod) {
543
+ acc.sourceSize += mod.size?.sourceSize || 0;
544
+ acc.parsedSize += mod.size?.parsedSize || 0;
545
+ }
546
+ return acc;
547
+ }, {
548
+ sourceSize: 0,
549
+ parsedSize: 0
550
+ });
551
+ return /*#__PURE__*/ jsx(AssetDetailTreeDirEntry, {
552
+ title: defaultTitle,
553
+ parsedSize: parsedSize,
554
+ sourceSize: sourceSize
555
+ });
556
+ },
557
+ page: 'bundle'
558
+ });
559
+ return treeData;
560
+ }, [
561
+ filteredModules,
562
+ openModuleGraphViewer
563
+ ]);
564
+ return /*#__PURE__*/ jsx(PopupContext.Provider, {
565
+ value: {
566
+ enabled: !performanceMode
567
+ },
568
+ children: /*#__PURE__*/ jsx("div", {
569
+ className: asset_module.bundleTree,
570
+ style: {
571
+ marginTop: Size.BasePadding,
572
+ '--item-height': ITEM_HEIGHT + 'px'
573
+ },
574
+ children: /*#__PURE__*/ jsx("div", {
575
+ className: asset_module.bundleTreeViewport,
576
+ children: /*#__PURE__*/ jsx("div", {
577
+ className: asset_module.bundleTreeInnerViewport,
578
+ ref: bundleTreeRef,
579
+ children: bundleTreeHeight > 0 && /*#__PURE__*/ jsx(Fragment, {
580
+ children: filteredModules.length ? /*#__PURE__*/ jsx(DirectoryTree, {
581
+ onScroll: onScroll,
582
+ selectable: false,
583
+ virtual: true,
584
+ itemHeight: ITEM_HEIGHT,
585
+ height: bundleTreeHeight,
586
+ style: bundleTreeWidth ? {
587
+ width: bundleTreeWidth + 'px'
588
+ } : void 0,
589
+ defaultExpandAll: defaultExpandAll || filteredModules.length <= 20,
590
+ onExpand: (expandedKeys)=>{
591
+ defaultExpandedModulesKeys = expandedKeys;
592
+ },
593
+ defaultExpandParent: true,
594
+ defaultExpandedKeys: defaultExpandedModulesKeys?.length ? defaultExpandedModulesKeys : 1 === treeData.length ? [
595
+ treeData[0].key
596
+ ] : [],
597
+ treeData: treeData
598
+ }, `tree_${moduleKeyword}_${defaultExpandAll}_${assetPath}`) : /*#__PURE__*/ jsx(Empty, {
599
+ description: /*#__PURE__*/ jsx(Typography.Text, {
600
+ strong: true,
601
+ children: `"${moduleKeyword}" can't match any modules`
602
+ })
603
+ })
604
+ })
605
+ })
606
+ })
607
+ })
608
+ });
609
+ });
610
+ const AssetDetailTreeDirEntry = /*#__PURE__*/ memo(({ title, parsedSize, sourceSize })=>{
611
+ const render = ()=>/*#__PURE__*/ jsxs("div", {
612
+ className: asset_module.bundleTreeEntryContent,
613
+ children: [
614
+ /*#__PURE__*/ jsx(asset_Popover, {
615
+ content: title,
616
+ children: /*#__PURE__*/ jsx(Typography.Text, {
617
+ className: asset_module.bundleTreeEntryTitle,
618
+ children: title
619
+ })
620
+ }),
621
+ /*#__PURE__*/ jsx("div", {
622
+ className: asset_module.divider
623
+ }),
624
+ /*#__PURE__*/ jsx(Space, {
625
+ children: parsedSize > 0 ? /*#__PURE__*/ jsxs(Fragment, {
626
+ children: [
627
+ /*#__PURE__*/ jsx(TotalBundledSizeTag, {
628
+ size: parsedSize
629
+ }),
630
+ /*#__PURE__*/ jsx(TotalSourceSizeTag, {
631
+ size: sourceSize
632
+ })
633
+ ]
634
+ }) : /*#__PURE__*/ jsx(TotalSourceSizeTag, {
635
+ size: sourceSize
636
+ })
637
+ })
638
+ ]
639
+ });
640
+ const renderWithoutPopups = ()=>/*#__PURE__*/ jsx(DisablePopups, {
641
+ children: render()
642
+ });
643
+ return /*#__PURE__*/ jsx("div", {
644
+ className: asset_module.bundleTreeEntry,
645
+ children: /*#__PURE__*/ jsx(ErrorBoundary, {
646
+ fallbackRender: renderWithoutPopups,
647
+ children: render()
648
+ })
649
+ });
650
+ });
651
+ const AssetDetailTreeFileEntry = /*#__PURE__*/ memo(({ mod, basename, includeModules, onClick })=>{
652
+ const isConcatenation = mod.kind === SDK.ModuleKind.Concatenation;
653
+ const { parsedSize = 0, sourceSize = 0, gzipSize = 0 } = mod.size;
654
+ const renderSize = ()=>{
655
+ if (0 !== parsedSize) {
656
+ const sourceSizeTag = /*#__PURE__*/ jsx(SourceSizeTag, {
657
+ size: sourceSize
658
+ });
659
+ const bundledSizeTag = /*#__PURE__*/ jsx(BundledSizeTag, {
660
+ size: parsedSize
661
+ });
662
+ if ('number' == typeof gzipSize) return /*#__PURE__*/ jsx(asset_Popover, {
663
+ placement: "bottom",
664
+ content: sourceSizeTag,
665
+ children: /*#__PURE__*/ jsxs(Space, {
666
+ direction: "horizontal",
667
+ children: [
668
+ bundledSizeTag,
669
+ /*#__PURE__*/ jsx(GzippedSizeTag, {
670
+ size: gzipSize
671
+ })
672
+ ]
673
+ })
674
+ });
675
+ return /*#__PURE__*/ jsxs(Space, {
676
+ direction: "horizontal",
677
+ children: [
678
+ bundledSizeTag,
679
+ sourceSizeTag
680
+ ]
681
+ });
682
+ }
683
+ if (0 !== sourceSize) return /*#__PURE__*/ jsx(SourceSizeTag, {
684
+ size: sourceSize
685
+ });
686
+ return null;
687
+ };
688
+ const renderContainedOtherModules = ()=>{
689
+ const containedOtherModules = !isConcatenation && 0 === parsedSize && includeModules.filter((e)=>e !== mod && e.modules && e.modules.indexOf(mod.id) > -1);
690
+ if (containedOtherModules && containedOtherModules.length) return /*#__PURE__*/ jsx(asset_Tooltip, {
691
+ title: /*#__PURE__*/ jsxs(Space, {
692
+ direction: "vertical",
693
+ children: [
694
+ /*#__PURE__*/ jsx(Typography.Text, {
695
+ style: {
696
+ color: 'inherit'
697
+ },
698
+ children: "This module is concatenated into another container module:"
699
+ }),
700
+ containedOtherModules.map(({ id, path })=>{
701
+ if (isJsDataUrl(path)) return /*#__PURE__*/ jsx(Typography.Paragraph, {
702
+ ellipsis: {
703
+ rows: 4
704
+ },
705
+ style: {
706
+ color: 'inherit',
707
+ maxWidth: '100%'
708
+ },
709
+ code: true,
710
+ children: path
711
+ }, id);
712
+ const p = relative(dirname(mod.path), path);
713
+ if (p.startsWith("javascript;charset=utf-8;base64,")) return /*#__PURE__*/ jsx(Typography.Text, {
714
+ style: {
715
+ color: 'inherit',
716
+ maxWidth: '100%'
717
+ },
718
+ code: true,
719
+ children: '.' === p[0] ? p : `./${p}`
720
+ }, id);
721
+ return /*#__PURE__*/ jsx(Typography.Text, {
722
+ style: {
723
+ color: 'inherit'
724
+ },
725
+ code: true,
726
+ children: '.' === p[0] ? p : `./${p}`
727
+ }, id);
728
+ })
729
+ ]
730
+ }),
731
+ children: /*#__PURE__*/ jsx(Tag, {
732
+ color: "green",
733
+ children: "concatenated"
734
+ })
735
+ });
736
+ return null;
737
+ };
738
+ const render = ()=>/*#__PURE__*/ jsxs("div", {
739
+ className: asset_module.bundleTreeEntryContent,
740
+ children: [
741
+ /*#__PURE__*/ jsx(asset_Popover, {
742
+ content: `Open the ${basename}’s module reasons tree.`,
743
+ placement: "bottom",
744
+ children: /*#__PURE__*/ jsxs("div", {
745
+ className: asset_module.bundleTreeEntryTitleWrap,
746
+ onClick: ()=>onClick(mod.id),
747
+ children: [
748
+ /*#__PURE__*/ jsx(asset_Popover, {
749
+ content: basename,
750
+ children: /*#__PURE__*/ jsx(Typography.Text, {
751
+ className: asset_module.bundleTreeEntryTitle,
752
+ children: basename
753
+ })
754
+ }),
755
+ /*#__PURE__*/ jsx("div", {
756
+ className: asset_module.divider
757
+ })
758
+ ]
759
+ })
760
+ }),
761
+ /*#__PURE__*/ jsxs(Space, {
762
+ children: [
763
+ renderSize(),
764
+ isConcatenation && /*#__PURE__*/ jsx(ConcatenatedTag, {
765
+ moduleCount: mod.modules?.length || 0
766
+ }),
767
+ renderContainedOtherModules(),
768
+ /*#__PURE__*/ jsx(ModuleCodeViewer, {
769
+ data: mod
770
+ })
771
+ ]
772
+ })
773
+ ]
774
+ });
775
+ const renderWithoutPopups = ()=>/*#__PURE__*/ jsx(DisablePopups, {
776
+ children: render()
777
+ });
778
+ return /*#__PURE__*/ jsx("div", {
779
+ className: asset_module.bundleTreeEntry,
780
+ children: /*#__PURE__*/ jsx(ErrorBoundary, {
781
+ fallbackRender: renderWithoutPopups,
782
+ children: render()
783
+ })
784
+ });
785
+ });
719
786
  export { AssetDetail, ModuleCodeViewer, ModuleGraphViewer, ModulesStatistics, getChildrenModule };
720
787
 
721
788
  //# sourceMappingURL=asset.mjs.map