@rsdoctor/utils 1.5.4 → 1.5.6-canary.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.
@@ -0,0 +1,16 @@
1
+ import { Client, SDK } from '@rsdoctor/types';
2
+ /**
3
+ * Compute module diff between baseline and current.
4
+ * Modules are matched by their file path.
5
+ */
6
+ export declare function getModulesDiffResult(baseline: SDK.ModuleGraphData, current: SDK.ModuleGraphData): Client.RsdoctorClientModulesDiffResult;
7
+ /**
8
+ * Compute package diff between baseline and current.
9
+ * Packages are matched by name@version.
10
+ */
11
+ export declare function getPackagesDiffResult(baseline: SDK.PackageGraphData, current: SDK.PackageGraphData): Client.RsdoctorClientPackagesDiffResult;
12
+ /**
13
+ * Compute the full bundle diff result between baseline and current manifest data.
14
+ * Combines asset, module, and package diffs into a single result.
15
+ */
16
+ export declare function getBundleDiffResult(baseline: SDK.BuilderStoreData, current: SDK.BuilderStoreData): Client.RsdoctorClientBundleDiffResult;
@@ -1,4 +1,5 @@
1
1
  export * from './assets.js';
2
+ export * from './bundle-diff.js';
2
3
  export * from './chunk.js';
3
4
  export * from './modules.js';
4
5
  export * from './dependency.js';
package/dist/common.cjs CHANGED
@@ -416,6 +416,7 @@ for(var __rspack_i in (()=>{
416
416
  getAssetsDiffResult: ()=>getAssetsDiffResult,
417
417
  getAssetsSizeInfo: ()=>getAssetsSizeInfo,
418
418
  getAssetsSummary: ()=>getAssetsSummary,
419
+ getBundleDiffResult: ()=>getBundleDiffResult,
419
420
  getChunkByChunkId: ()=>graph_chunk.dH,
420
421
  getChunkIdsByAsset: ()=>graph_chunk.ZS,
421
422
  getChunksByAsset: ()=>graph_chunk.Ip,
@@ -434,6 +435,8 @@ for(var __rspack_i in (()=>{
434
435
  getModulesByAsset: ()=>getModulesByAsset,
435
436
  getModulesByChunk: ()=>getModulesByChunk,
436
437
  getModulesByChunks: ()=>getModulesByChunks,
438
+ getModulesDiffResult: ()=>getModulesDiffResult,
439
+ getPackagesDiffResult: ()=>getPackagesDiffResult,
437
440
  isAssetMatchExtension: ()=>isAssetMatchExtension,
438
441
  isAssetMatchExtensions: ()=>isAssetMatchExtensions,
439
442
  isInitialAsset: ()=>isInitialAsset
@@ -1022,6 +1025,91 @@ for(var __rspack_i in (()=>{
1022
1025
  let matches = filename.split('?')[0].match(/\.([0-9a-z]+)(?:[\?#]|$)/i);
1023
1026
  return matches ? `.${matches[1]}` : '';
1024
1027
  }
1028
+ function getModulesDiffResult(baseline, current) {
1029
+ let baselineMap = new Map();
1030
+ for (let m of baseline.modules)baselineMap.set(m.path, m);
1031
+ let currentMap = new Map();
1032
+ for (let m of current.modules)currentMap.set(m.path, m);
1033
+ let added = [], removed = [], changed = [];
1034
+ for (let [path, bModule] of baselineMap){
1035
+ let cModule = currentMap.get(path);
1036
+ if (cModule) {
1037
+ if (bModule.size.parsedSize !== cModule.size.parsedSize) {
1038
+ let { percent, state } = diffSize(bModule.size.parsedSize, cModule.size.parsedSize);
1039
+ changed.push({
1040
+ path,
1041
+ size: {
1042
+ baseline: bModule.size,
1043
+ current: cModule.size
1044
+ },
1045
+ percent,
1046
+ state
1047
+ });
1048
+ }
1049
+ } else removed.push({
1050
+ path,
1051
+ size: bModule.size
1052
+ });
1053
+ }
1054
+ for (let [path, cModule] of currentMap)baselineMap.has(path) || added.push({
1055
+ path,
1056
+ size: cModule.size
1057
+ });
1058
+ return {
1059
+ added,
1060
+ removed,
1061
+ changed
1062
+ };
1063
+ }
1064
+ function getPackagesDiffResult(baseline, current) {
1065
+ let toKey = (p)=>`${p.name}@${p.version}`, baselineMap = new Map();
1066
+ for (let p of baseline.packages)baselineMap.set(toKey(p), p);
1067
+ let currentMap = new Map();
1068
+ for (let p of current.packages)currentMap.set(toKey(p), p);
1069
+ let added = [], removed = [], changed = [];
1070
+ for (let [key, bPkg] of baselineMap){
1071
+ let cPkg = currentMap.get(key);
1072
+ if (cPkg) {
1073
+ if (bPkg.size.parsedSize !== cPkg.size.parsedSize) {
1074
+ let { percent, state } = diffSize(bPkg.size.parsedSize, cPkg.size.parsedSize);
1075
+ changed.push({
1076
+ name: bPkg.name,
1077
+ version: bPkg.version,
1078
+ root: bPkg.root,
1079
+ size: {
1080
+ baseline: bPkg.size,
1081
+ current: cPkg.size
1082
+ },
1083
+ percent,
1084
+ state
1085
+ });
1086
+ }
1087
+ } else removed.push({
1088
+ name: bPkg.name,
1089
+ version: bPkg.version,
1090
+ root: bPkg.root,
1091
+ size: bPkg.size
1092
+ });
1093
+ }
1094
+ for (let [key, cPkg] of currentMap)baselineMap.has(key) || added.push({
1095
+ name: cPkg.name,
1096
+ version: cPkg.version,
1097
+ root: cPkg.root,
1098
+ size: cPkg.size
1099
+ });
1100
+ return {
1101
+ added,
1102
+ removed,
1103
+ changed
1104
+ };
1105
+ }
1106
+ function getBundleDiffResult(baseline, current) {
1107
+ return {
1108
+ assets: getAssetsDiffResult(baseline.chunkGraph, current.chunkGraph),
1109
+ modules: getModulesDiffResult(baseline.moduleGraph, current.moduleGraph),
1110
+ packages: getPackagesDiffResult(baseline.packageGraph, current.packageGraph)
1111
+ };
1112
+ }
1025
1113
  var graph_entrypoints = __webpack_require__("./src/common/graph/entrypoints.ts");
1026
1114
  function getBundleDiffPageQueryString(files) {
1027
1115
  let qs = encodeURIComponent(files.join(','));
package/dist/common.js CHANGED
@@ -58,6 +58,7 @@ __webpack_require__.r(graph_namespaceObject), __webpack_require__.d(graph_namesp
58
58
  getAssetsDiffResult: ()=>getAssetsDiffResult,
59
59
  getAssetsSizeInfo: ()=>getAssetsSizeInfo,
60
60
  getAssetsSummary: ()=>getAssetsSummary,
61
+ getBundleDiffResult: ()=>getBundleDiffResult,
61
62
  getChunkByChunkId: ()=>getChunkByChunkId,
62
63
  getChunkIdsByAsset: ()=>getChunkIdsByAsset,
63
64
  getChunksByAsset: ()=>getChunksByAsset,
@@ -76,6 +77,8 @@ __webpack_require__.r(graph_namespaceObject), __webpack_require__.d(graph_namesp
76
77
  getModulesByAsset: ()=>getModulesByAsset,
77
78
  getModulesByChunk: ()=>getModulesByChunk,
78
79
  getModulesByChunks: ()=>getModulesByChunks,
80
+ getModulesDiffResult: ()=>getModulesDiffResult,
81
+ getPackagesDiffResult: ()=>getPackagesDiffResult,
79
82
  isAssetMatchExtension: ()=>isAssetMatchExtension,
80
83
  isAssetMatchExtensions: ()=>isAssetMatchExtensions,
81
84
  isInitialAsset: ()=>isInitialAsset
@@ -759,6 +762,91 @@ function extname(filename) {
759
762
  let matches = filename.split('?')[0].match(/\.([0-9a-z]+)(?:[\?#]|$)/i);
760
763
  return matches ? `.${matches[1]}` : '';
761
764
  }
765
+ function getModulesDiffResult(baseline, current) {
766
+ let baselineMap = new Map();
767
+ for (let m of baseline.modules)baselineMap.set(m.path, m);
768
+ let currentMap = new Map();
769
+ for (let m of current.modules)currentMap.set(m.path, m);
770
+ let added = [], removed = [], changed = [];
771
+ for (let [path, bModule] of baselineMap){
772
+ let cModule = currentMap.get(path);
773
+ if (cModule) {
774
+ if (bModule.size.parsedSize !== cModule.size.parsedSize) {
775
+ let { percent, state } = diffSize(bModule.size.parsedSize, cModule.size.parsedSize);
776
+ changed.push({
777
+ path,
778
+ size: {
779
+ baseline: bModule.size,
780
+ current: cModule.size
781
+ },
782
+ percent,
783
+ state
784
+ });
785
+ }
786
+ } else removed.push({
787
+ path,
788
+ size: bModule.size
789
+ });
790
+ }
791
+ for (let [path, cModule] of currentMap)baselineMap.has(path) || added.push({
792
+ path,
793
+ size: cModule.size
794
+ });
795
+ return {
796
+ added,
797
+ removed,
798
+ changed
799
+ };
800
+ }
801
+ function getPackagesDiffResult(baseline, current) {
802
+ let toKey = (p)=>`${p.name}@${p.version}`, baselineMap = new Map();
803
+ for (let p of baseline.packages)baselineMap.set(toKey(p), p);
804
+ let currentMap = new Map();
805
+ for (let p of current.packages)currentMap.set(toKey(p), p);
806
+ let added = [], removed = [], changed = [];
807
+ for (let [key, bPkg] of baselineMap){
808
+ let cPkg = currentMap.get(key);
809
+ if (cPkg) {
810
+ if (bPkg.size.parsedSize !== cPkg.size.parsedSize) {
811
+ let { percent, state } = diffSize(bPkg.size.parsedSize, cPkg.size.parsedSize);
812
+ changed.push({
813
+ name: bPkg.name,
814
+ version: bPkg.version,
815
+ root: bPkg.root,
816
+ size: {
817
+ baseline: bPkg.size,
818
+ current: cPkg.size
819
+ },
820
+ percent,
821
+ state
822
+ });
823
+ }
824
+ } else removed.push({
825
+ name: bPkg.name,
826
+ version: bPkg.version,
827
+ root: bPkg.root,
828
+ size: bPkg.size
829
+ });
830
+ }
831
+ for (let [key, cPkg] of currentMap)baselineMap.has(key) || added.push({
832
+ name: cPkg.name,
833
+ version: cPkg.version,
834
+ root: cPkg.root,
835
+ size: cPkg.size
836
+ });
837
+ return {
838
+ added,
839
+ removed,
840
+ changed
841
+ };
842
+ }
843
+ function getBundleDiffResult(baseline, current) {
844
+ return {
845
+ assets: getAssetsDiffResult(baseline.chunkGraph, current.chunkGraph),
846
+ modules: getModulesDiffResult(baseline.moduleGraph, current.moduleGraph),
847
+ packages: getPackagesDiffResult(baseline.packageGraph, current.packageGraph)
848
+ };
849
+ }
762
850
  function getEntryPoints(entrypoints) {
763
851
  return entrypoints;
764
852
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/utils",
3
- "version": "1.5.4",
3
+ "version": "1.5.6-canary.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -74,9 +74,9 @@
74
74
  "json-stream-stringify": "3.0.1",
75
75
  "lines-and-columns": "2.0.4",
76
76
  "picocolors": "^1.1.1",
77
- "rslog": "^1.2.11",
77
+ "rslog": "^1.3.2",
78
78
  "strip-ansi": "^6.0.1",
79
- "@rsdoctor/types": "1.5.4"
79
+ "@rsdoctor/types": "1.5.6-canary.0"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@types/babel__code-frame": "7.27.0",