@rsdoctor/utils 1.4.1-beta.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/build.cjs CHANGED
@@ -18,7 +18,7 @@ var __webpack_modules__ = {
18
18
  MODULE_PATH_PACKAGES: ()=>MODULE_PATH_PACKAGES,
19
19
  PACKAGE_PATH_NAME: ()=>PACKAGE_PATH_NAME,
20
20
  getPackageMetaFromModulePath: ()=>getPackageMetaFromModulePath
21
- }), __webpack_require__("./src/common/algorithm.ts"), __webpack_require__("path"), __webpack_require__("process"), __webpack_require__("@rsdoctor/types"), __webpack_require__("./src/logger.ts"), RegExp(`(.*)${/[-|.]/.source}${/[a-z|A-Z|0-9]{4,32}/.source}(${/(?:\.[a-z|A-Z|0-9]{2,}){1,}/.source})$`);
21
+ }), __webpack_require__("./src/common/algorithm.ts"), __webpack_require__("path"), __webpack_require__("process"), __webpack_require__("@rsdoctor/types"), __webpack_require__("./src/logger.ts"), RegExp(`(.*)${/[-|.]/.source}(${/(?:[a-f0-9]{4,32}|[a-zA-Z]{3,}[0-9]|[a-zA-Z]*[0-9][a-zA-Z]{2,}|[a-zA-Z]*[0-9][a-zA-Z0-9]{3,31})/.source})(${/(?:\.[a-z|A-Z|0-9]{2,}){1,}/.source})$`);
22
22
  var lodash = __webpack_require__("./src/common/lodash.ts");
23
23
  let PACKAGE_SLUG = /[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*/, MODULE_PATH_PACKAGES = RegExp(`(?:${/(?:node_modules|~)(?:\/\.pnpm)?/.source}/)(?:(?:@${PACKAGE_SLUG.source}[/|+])?(?:${PACKAGE_SLUG.source}\\+)*(?:${PACKAGE_SLUG.source})(?:${/@[\w|\-|_|.]+/.source})?)(?:_(?:@${PACKAGE_SLUG.source}[/|+])?(?:${PACKAGE_SLUG.source})(?:@${PACKAGE_SLUG.source})?)*/`, 'g'), PACKAGE_PATH_NAME = /(?:(?:node_modules|~)(?:\/\.pnpm)?\/)(?:((?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*[/|+])?(?:(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*\+)*)(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))(?:@[\w|\-|_|.]+)?)(?:_((?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*[/|+])?(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))(?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))*\//gm, getPackageMetaFromModulePath = (modulePath)=>{
24
24
  var data;
package/dist/build.js CHANGED
@@ -146,7 +146,7 @@ createLogger().override({
146
146
  debug: (message)=>{
147
147
  process.env.DEBUG && console.log(`${picocolors.blue('[RSDOCTOR DEBUG]')} ${message}`);
148
148
  }
149
- }), RegExp(`(.*)${/[-|.]/.source}${/[a-z|A-Z|0-9]{4,32}/.source}(${/(?:\.[a-z|A-Z|0-9]{2,}){1,}/.source})$`);
149
+ }), RegExp(`(.*)${/[-|.]/.source}(${/(?:[a-f0-9]{4,32}|[a-zA-Z]{3,}[0-9]|[a-zA-Z]*[0-9][a-zA-Z]{2,}|[a-zA-Z]*[0-9][a-zA-Z0-9]{3,31})/.source})(${/(?:\.[a-z|A-Z|0-9]{2,}){1,}/.source})$`);
150
150
  let PACKAGE_SLUG = /[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*/, MODULE_PATH_PACKAGES = RegExp(`(?:${/(?:node_modules|~)(?:\/\.pnpm)?/.source}/)(?:(?:@${PACKAGE_SLUG.source}[/|+])?(?:${PACKAGE_SLUG.source}\\+)*(?:${PACKAGE_SLUG.source})(?:${/@[\w|\-|_|.]+/.source})?)(?:_(?:@${PACKAGE_SLUG.source}[/|+])?(?:${PACKAGE_SLUG.source})(?:@${PACKAGE_SLUG.source})?)*/`, 'g'), PACKAGE_PATH_NAME = /(?:(?:node_modules|~)(?:\/\.pnpm)?\/)(?:((?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*[/|+])?(?:(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*\+)*)(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))(?:@[\w|\-|_|.]+)?)(?:_((?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*[/|+])?(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))(?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))*\//gm, getPackageMetaFromModulePath = (modulePath)=>{
151
151
  var data;
152
152
  let res, paths = modulePath.match(MODULE_PATH_PACKAGES);
package/dist/common.cjs CHANGED
@@ -817,10 +817,16 @@ for(var __rspack_i in (()=>{
817
817
  dependencies: (0, graph_dependency.NL)(module, dependencies)
818
818
  };
819
819
  }
820
- let filenamePattern = RegExp(`(.*)${/[-|.]/.source}${/[a-z|A-Z|0-9]{4,32}/.source}(${/(?:\.[a-z|A-Z|0-9]{2,}){1,}/.source})$`);
820
+ let filenamePattern = RegExp(`(.*)${/[-|.]/.source}(${/(?:[a-f0-9]{4,32}|[a-zA-Z]{3,}[0-9]|[a-zA-Z]*[0-9][a-zA-Z]{2,}|[a-zA-Z]*[0-9][a-zA-Z0-9]{3,31})/.source})(${/(?:\.[a-z|A-Z|0-9]{2,}){1,}/.source})$`);
821
821
  function formatAssetName(assetName, fileConfig) {
822
822
  let splitFilesList = fileConfig?.split('.'), outputFileTailName = '', unHashedFileName = assetName;
823
- return splitFilesList?.length && splitFilesList.length >= 3 && splitFilesList[splitFilesList.length - 2]?.indexOf('[') < 0 && 'js|css|html'.indexOf(splitFilesList[splitFilesList.length - 1]) > -1 ? (outputFileTailName = splitFilesList[splitFilesList.length - 2], unHashedFileName = assetName.replace(/(.*)(\.[a-f0-9]{4,32})([^.]*.[^.]+){2,}/g, '$1'), `${unHashedFileName}.${outputFileTailName}.${assetName.substring(assetName.lastIndexOf('.') + 1)}`) : assetName.replace(filenamePattern, '$1$2');
823
+ if (splitFilesList?.length && splitFilesList.length >= 3 && splitFilesList[splitFilesList.length - 2]?.indexOf('[') < 0 && 'js|css|html'.indexOf(splitFilesList[splitFilesList.length - 1]) > -1) {
824
+ outputFileTailName = splitFilesList[splitFilesList.length - 2];
825
+ let match = assetName.match(/(.*)(\.([a-f0-9]{4,32}|[a-zA-Z]*[0-9][a-zA-Z0-9]*))(\.[^.]+){2,}$/);
826
+ if (match && match[3].length >= 4 && match[3].length <= 32) return unHashedFileName = match[1], `${unHashedFileName}.${outputFileTailName}.${assetName.substring(assetName.lastIndexOf('.') + 1)}`;
827
+ }
828
+ let match = assetName.match(filenamePattern);
829
+ return match && match[2] && match[2].length >= 4 && match[2].length <= 32 ? assetName.replace(filenamePattern, '$1$3') : assetName;
824
830
  }
825
831
  function isAssetMatchExtension(asset, ext) {
826
832
  return asset.path.slice(-ext.length) === ext || extname(asset.path) === ext;
package/dist/common.js CHANGED
@@ -606,10 +606,16 @@ function getModuleDetails(moduleId, modules, dependencies) {
606
606
  dependencies: getDependenciesByModule(module, dependencies)
607
607
  };
608
608
  }
609
- let filenamePattern = RegExp(`(.*)${/[-|.]/.source}${/[a-z|A-Z|0-9]{4,32}/.source}(${/(?:\.[a-z|A-Z|0-9]{2,}){1,}/.source})$`);
609
+ let filenamePattern = RegExp(`(.*)${/[-|.]/.source}(${/(?:[a-f0-9]{4,32}|[a-zA-Z]{3,}[0-9]|[a-zA-Z]*[0-9][a-zA-Z]{2,}|[a-zA-Z]*[0-9][a-zA-Z0-9]{3,31})/.source})(${/(?:\.[a-z|A-Z|0-9]{2,}){1,}/.source})$`);
610
610
  function formatAssetName(assetName, fileConfig) {
611
611
  let splitFilesList = fileConfig?.split('.'), outputFileTailName = '', unHashedFileName = assetName;
612
- return splitFilesList?.length && splitFilesList.length >= 3 && splitFilesList[splitFilesList.length - 2]?.indexOf('[') < 0 && 'js|css|html'.indexOf(splitFilesList[splitFilesList.length - 1]) > -1 ? (outputFileTailName = splitFilesList[splitFilesList.length - 2], unHashedFileName = assetName.replace(/(.*)(\.[a-f0-9]{4,32})([^.]*.[^.]+){2,}/g, '$1'), `${unHashedFileName}.${outputFileTailName}.${assetName.substring(assetName.lastIndexOf('.') + 1)}`) : assetName.replace(filenamePattern, '$1$2');
612
+ if (splitFilesList?.length && splitFilesList.length >= 3 && splitFilesList[splitFilesList.length - 2]?.indexOf('[') < 0 && 'js|css|html'.indexOf(splitFilesList[splitFilesList.length - 1]) > -1) {
613
+ outputFileTailName = splitFilesList[splitFilesList.length - 2];
614
+ let match = assetName.match(/(.*)(\.([a-f0-9]{4,32}|[a-zA-Z]*[0-9][a-zA-Z0-9]*))(\.[^.]+){2,}$/);
615
+ if (match && match[3].length >= 4 && match[3].length <= 32) return unHashedFileName = match[1], `${unHashedFileName}.${outputFileTailName}.${assetName.substring(assetName.lastIndexOf('.') + 1)}`;
616
+ }
617
+ let match = assetName.match(filenamePattern);
618
+ return match && match[2] && match[2].length >= 4 && match[2].length <= 32 ? assetName.replace(filenamePattern, '$1$3') : assetName;
613
619
  }
614
620
  function isAssetMatchExtension(asset, ext) {
615
621
  return asset.path.slice(-ext.length) === ext || extname(asset.path) === ext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/utils",
3
- "version": "1.4.1-beta.0",
3
+ "version": "1.5.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -76,7 +76,7 @@
76
76
  "picocolors": "^1.1.1",
77
77
  "rslog": "^1.2.11",
78
78
  "strip-ansi": "^6.0.1",
79
- "@rsdoctor/types": "1.4.1-beta.0"
79
+ "@rsdoctor/types": "1.5.0"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@types/babel__code-frame": "7.0.6",