deslop-js 0.9.2 → 0.9.4

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.
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_constants = require('./constants-CD9NXHxi.cjs');
2
+ const require_constants = require('./constants-DL5OyI3b.cjs');
3
3
 
4
4
  exports.ANALYZED_MANIFEST_FILENAMES = require_constants.ANALYZED_MANIFEST_FILENAMES;
5
5
  exports.DEFAULT_EXTENSIONS = require_constants.DEFAULT_EXTENSIONS;
@@ -1,3 +1,3 @@
1
- import { o as DEFAULT_EXTENSIONS, t as ANALYZED_MANIFEST_FILENAMES } from "./constants-oYYofMhb.mjs";
1
+ import { o as DEFAULT_EXTENSIONS, t as ANALYZED_MANIFEST_FILENAMES } from "./constants-DBVadY0c.mjs";
2
2
 
3
3
  export { ANALYZED_MANIFEST_FILENAMES, DEFAULT_EXTENSIONS };
@@ -86,7 +86,6 @@ const DEFAULT_EXCLUSIONS = [
86
86
  const SCRIPT_FILE_PATTERN = /(?:^|\s)(?:node|tsx|ts-node|tsc|npx|bun|esr|esno|jiti|babel-node|zx)\s+(?:\S+\s+)*?([\w./@-]+\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs))(?:\s|$)/;
87
87
  const SCRIPT_EXTENSIONLESS_FILE_PATTERN = /(?:^|\s)(?:node|tsx|ts-node|bun|esr|esno|jiti|babel-node|zx)\s+(?:\S+\s+)*?((?:[./]|[\w@][\w@-]*\/)[\w./@-]+)(?:\s|$)/;
88
88
  const SCRIPT_CONFIG_FILE_PATTERN = /--config\s+([\w./@-]+\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs))/;
89
- const SCRIPT_ENTRY_PATTERNS = [];
90
89
  const DEFAULT_ENTRY_GLOBS = [
91
90
  "src/index.{ts,tsx,js,jsx}",
92
91
  "src/main.{ts,tsx,js,jsx}",
@@ -341,4 +340,4 @@ const DEFAULT_SEMANTIC_TSCONFIG_NAMES = [
341
340
  const GIT_CHECK_IGNORE_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
342
341
 
343
342
  //#endregion
344
- export { STANDALONE_PROJECT_LOCKFILES as A, RESOLVER_EXTENSIONS as C, SCRIPT_FILE_PATTERN as D, SCRIPT_EXTENSIONLESS_FILE_PATTERN as E, SEMANTIC_MAX_PROGRAM_FILES as O, REACT_NATIVE_PLATFORM_EXTENSIONS as S, SCRIPT_ENTRY_PATTERNS as T, MINIFIED_DETECTION_MIN_BYTES as _, DEFAULT_EXCLUSIONS as a, OUTPUT_DIRECTORIES as b, DEFAULT_SEMANTIC_TSCONFIG_NAMES as c, IMPLICIT_DEPENDENCIES as d, KNOWN_CONFIG_PREFIXES as f, MAX_PARSE_FILE_SIZE_BYTES as g, MAX_ERROR_DETAIL_LENGTH as h, DEFAULT_ENTRY_GLOBS as i, SUMMARY_CACHE_MAX_BYTES as j, SOURCE_EXTENSIONS as k, GIT_CHECK_IGNORE_MAX_BUFFER_BYTES as l, MAX_ANALYSIS_ERRORS as m, BINARY_DETECTION_SAMPLE_BYTES as n, DEFAULT_EXTENSIONS as o, LOCKFILE_MARKERS as p, BUILTIN_MODULES as r, DEFAULT_SEMANTIC_DECORATOR_ALLOWLIST as s, ANALYZED_MANIFEST_FILENAMES as t, HIDDEN_DIRECTORY_ALLOWLIST as u, MIN_NUMERIC_LITERAL_MAGNITUDE_FOR_DUPLICATE as v, SCRIPT_CONFIG_FILE_PATTERN as w, PLATFORM_SUFFIXES as x, MONOREPO_ROOT_MARKERS as y };
343
+ export { SUMMARY_CACHE_MAX_BYTES as A, RESOLVER_EXTENSIONS as C, SEMANTIC_MAX_PROGRAM_FILES as D, SCRIPT_FILE_PATTERN as E, SOURCE_EXTENSIONS as O, REACT_NATIVE_PLATFORM_EXTENSIONS as S, SCRIPT_EXTENSIONLESS_FILE_PATTERN as T, MINIFIED_DETECTION_MIN_BYTES as _, DEFAULT_EXCLUSIONS as a, OUTPUT_DIRECTORIES as b, DEFAULT_SEMANTIC_TSCONFIG_NAMES as c, IMPLICIT_DEPENDENCIES as d, KNOWN_CONFIG_PREFIXES as f, MAX_PARSE_FILE_SIZE_BYTES as g, MAX_ERROR_DETAIL_LENGTH as h, DEFAULT_ENTRY_GLOBS as i, STANDALONE_PROJECT_LOCKFILES as k, GIT_CHECK_IGNORE_MAX_BUFFER_BYTES as l, MAX_ANALYSIS_ERRORS as m, BINARY_DETECTION_SAMPLE_BYTES as n, DEFAULT_EXTENSIONS as o, LOCKFILE_MARKERS as p, BUILTIN_MODULES as r, DEFAULT_SEMANTIC_DECORATOR_ALLOWLIST as s, ANALYZED_MANIFEST_FILENAMES as t, HIDDEN_DIRECTORY_ALLOWLIST as u, MIN_NUMERIC_LITERAL_MAGNITUDE_FOR_DUPLICATE as v, SCRIPT_CONFIG_FILE_PATTERN as w, PLATFORM_SUFFIXES as x, MONOREPO_ROOT_MARKERS as y };
@@ -87,7 +87,6 @@ const DEFAULT_EXCLUSIONS = [
87
87
  const SCRIPT_FILE_PATTERN = /(?:^|\s)(?:node|tsx|ts-node|tsc|npx|bun|esr|esno|jiti|babel-node|zx)\s+(?:\S+\s+)*?([\w./@-]+\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs))(?:\s|$)/;
88
88
  const SCRIPT_EXTENSIONLESS_FILE_PATTERN = /(?:^|\s)(?:node|tsx|ts-node|bun|esr|esno|jiti|babel-node|zx)\s+(?:\S+\s+)*?((?:[./]|[\w@][\w@-]*\/)[\w./@-]+)(?:\s|$)/;
89
89
  const SCRIPT_CONFIG_FILE_PATTERN = /--config\s+([\w./@-]+\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs))/;
90
- const SCRIPT_ENTRY_PATTERNS = [];
91
90
  const DEFAULT_ENTRY_GLOBS = [
92
91
  "src/index.{ts,tsx,js,jsx}",
93
92
  "src/main.{ts,tsx,js,jsx}",
@@ -486,12 +485,6 @@ Object.defineProperty(exports, 'SCRIPT_CONFIG_FILE_PATTERN', {
486
485
  return SCRIPT_CONFIG_FILE_PATTERN;
487
486
  }
488
487
  });
489
- Object.defineProperty(exports, 'SCRIPT_ENTRY_PATTERNS', {
490
- enumerable: true,
491
- get: function () {
492
- return SCRIPT_ENTRY_PATTERNS;
493
- }
494
- });
495
488
  Object.defineProperty(exports, 'SCRIPT_EXTENSIONLESS_FILE_PATTERN', {
496
489
  enumerable: true,
497
490
  get: function () {
@@ -1,4 +1,4 @@
1
- import { a as OUTPUT_DIRECTORIES, c as SCRIPT_ENTRY_PATTERNS, d as SOURCE_EXTENSIONS$3, f as STANDALONE_PROJECT_LOCKFILES, i as MONOREPO_ROOT_MARKERS, l as SCRIPT_EXTENSIONLESS_FILE_PATTERN, o as RESOLVER_EXTENSIONS, r as LOCKFILE_MARKERS, s as SCRIPT_CONFIG_FILE_PATTERN, t as extractReactRouterRouteModuleEntries, u as SCRIPT_FILE_PATTERN } from "./parse-CDdo_Ppt.mjs";
1
+ import { a as OUTPUT_DIRECTORIES, c as SCRIPT_EXTENSIONLESS_FILE_PATTERN, d as STANDALONE_PROJECT_LOCKFILES, i as MONOREPO_ROOT_MARKERS, l as SCRIPT_FILE_PATTERN, o as RESOLVER_EXTENSIONS, r as LOCKFILE_MARKERS, s as SCRIPT_CONFIG_FILE_PATTERN, t as extractReactRouterRouteModuleEntries, u as SOURCE_EXTENSIONS$3 } from "./parse-C6-m3QMJ.mjs";
2
2
  import { parentPort } from "node:worker_threads";
3
3
  import { existsSync, readFileSync, statSync } from "node:fs";
4
4
  import fg from "fast-glob";
@@ -1868,13 +1868,6 @@ const extractScriptEntries = (directory) => {
1868
1868
  entries.push(...extractScriptFileArguments(scriptCommand, directory));
1869
1869
  }
1870
1870
  } catch {}
1871
- const scriptDirectoryFiles = fg.sync(SCRIPT_ENTRY_PATTERNS, {
1872
- cwd: directory,
1873
- absolute: true,
1874
- onlyFiles: true,
1875
- ignore: ["**/node_modules/**"]
1876
- });
1877
- entries.push(...scriptDirectoryFiles);
1878
1871
  return entries;
1879
1872
  };
1880
1873
  const isYamlMapping = (line) => {
package/dist/index.cjs CHANGED
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  }) : target, mod));
27
27
 
28
28
  //#endregion
29
- const require_constants = require('./constants-CD9NXHxi.cjs');
29
+ const require_constants = require('./constants-DL5OyI3b.cjs');
30
30
  let node_path = require("node:path");
31
31
  node_path = __toESM(node_path, 1);
32
32
  let node_fs = require("node:fs");
@@ -1777,7 +1777,7 @@ const parseSourceFile = (filePath) => {
1777
1777
  wholeObjectUses,
1778
1778
  localIdentifierReferences,
1779
1779
  topLevelImportReferences,
1780
- referencedFilenames: extractReferencedFilenames(sourceText),
1780
+ referencedFilenames: extractReferencedFilenames(sourceText, program.body),
1781
1781
  redundantTypePatterns,
1782
1782
  identityWrappers,
1783
1783
  typeDefinitionHashes,
@@ -1789,11 +1789,33 @@ const parseSourceFile = (filePath) => {
1789
1789
  };
1790
1790
  };
1791
1791
  const REFERENCED_FILENAME_LITERAL_PATTERN = /(?<![./@\w-])(?:["'`])([a-z][\w-]*\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs))(?:["'`])/g;
1792
- const extractReferencedFilenames = (sourceText) => {
1792
+ const REFERENCED_MODULE_PATH_PATTERN = /^[a-zA-Z0-9_@-][a-zA-Z0-9_@.-]*(?:\/[a-zA-Z0-9_@.-]+)+$/;
1793
+ const extractReferencedFilenames = (sourceText, bodyNodes = []) => {
1793
1794
  const captured = /* @__PURE__ */ new Set();
1794
1795
  REFERENCED_FILENAME_LITERAL_PATTERN.lastIndex = 0;
1795
1796
  let match;
1796
1797
  while ((match = REFERENCED_FILENAME_LITERAL_PATTERN.exec(sourceText)) !== null) captured.add(match[1]);
1798
+ const visitNode = (node) => {
1799
+ if (node.type === "ImportExpression") {
1800
+ const sourceExpression = node.source;
1801
+ if (isWalkableNode(sourceExpression) && sourceExpression.type === "Literal") {
1802
+ const literalValue = sourceExpression.value;
1803
+ if (typeof literalValue === "string" && REFERENCED_MODULE_PATH_PATTERN.test(literalValue)) captured.add(literalValue);
1804
+ }
1805
+ }
1806
+ if (node.type === "CallExpression" || node.type === "NewExpression") {
1807
+ const callArguments = node.arguments;
1808
+ for (const callArgument of Array.isArray(callArguments) ? callArguments : []) {
1809
+ if (!isWalkableNode(callArgument) || callArgument.type !== "Literal") continue;
1810
+ const literalValue = callArgument.value;
1811
+ if (typeof literalValue === "string" && REFERENCED_MODULE_PATH_PATTERN.test(literalValue)) captured.add(literalValue);
1812
+ }
1813
+ }
1814
+ for (const value of Object.values(node)) if (Array.isArray(value)) {
1815
+ for (const element of value) if (isWalkableNode(element)) visitNode(element);
1816
+ } else if (isWalkableNode(value)) visitNode(value);
1817
+ };
1818
+ for (const bodyNode of bodyNodes) if (isWalkableNode(bodyNode)) visitNode(bodyNode);
1797
1819
  return [...captured];
1798
1820
  };
1799
1821
  const collectDryPatterns = (bodyNodes, sourceText, redundantTypePatterns, identityWrappers, typeDefinitionHashes) => {
@@ -5225,13 +5247,6 @@ const extractScriptEntries = (directory) => {
5225
5247
  entries.push(...extractScriptFileArguments(scriptCommand, directory));
5226
5248
  }
5227
5249
  } catch {}
5228
- const scriptDirectoryFiles = fast_glob.default.sync(require_constants.SCRIPT_ENTRY_PATTERNS, {
5229
- cwd: directory,
5230
- absolute: true,
5231
- onlyFiles: true,
5232
- ignore: ["**/node_modules/**"]
5233
- });
5234
- entries.push(...scriptDirectoryFiles);
5235
5250
  return entries;
5236
5251
  };
5237
5252
  const isYamlMapping = (line) => {
@@ -8030,6 +8045,7 @@ const detectStalePackages = (graph, config, summaryCache) => {
8030
8045
  "react-app-rewired"
8031
8046
  ].some((framework) => declaredNames.has(framework) || usedPackageNames.has(framework))) usedPackageNames.add("react-dom");
8032
8047
  }
8048
+ if (declaredNames.has("astro") && declaredNames.has("sharp")) usedPackageNames.add("sharp");
8033
8049
  if (declaredNames.has("react") && declaredNames.has("react-dom")) {
8034
8050
  const packageJsonPath = (0, node_path.resolve)(config.rootDir, "package.json");
8035
8051
  try {
@@ -12370,8 +12386,7 @@ const createDisabledSemanticResult = () => ({
12370
12386
  unusedClassMembers: [],
12371
12387
  misclassifiedDependencies: [],
12372
12388
  redundantAliases: [],
12373
- errors: [],
12374
- contextStatus: "disabled"
12389
+ errors: []
12375
12390
  });
12376
12391
  const runSemanticAnalysis = (graph, config) => {
12377
12392
  const semanticConfig = config.semantic;
@@ -12392,8 +12407,7 @@ const runSemanticAnalysis = (graph, config) => {
12392
12407
  unusedClassMembers: [],
12393
12408
  misclassifiedDependencies,
12394
12409
  redundantAliases: [],
12395
- errors,
12396
- contextStatus: "no-context-required"
12410
+ errors
12397
12411
  };
12398
12412
  let contextResult;
12399
12413
  try {
@@ -12409,8 +12423,7 @@ const runSemanticAnalysis = (graph, config) => {
12409
12423
  code: "ts-not-loadable",
12410
12424
  message: "createSemanticContext threw before returning a result",
12411
12425
  detail: describeUnknownError(contextError)
12412
- })],
12413
- contextStatus: "typescript-load-failed"
12426
+ })]
12414
12427
  };
12415
12428
  }
12416
12429
  if (!contextResult.ok) return {
@@ -12419,9 +12432,7 @@ const runSemanticAnalysis = (graph, config) => {
12419
12432
  unusedClassMembers: [],
12420
12433
  misclassifiedDependencies,
12421
12434
  redundantAliases: [],
12422
- errors: [...errors, contextResult.failure.error],
12423
- contextStatus: contextResult.failure.reason,
12424
- contextMessage: contextResult.failure.message
12435
+ errors: [...errors, contextResult.failure.error]
12425
12436
  };
12426
12437
  const { context } = contextResult;
12427
12438
  let referenceIndex;
@@ -12440,8 +12451,7 @@ const runSemanticAnalysis = (graph, config) => {
12440
12451
  unusedClassMembers,
12441
12452
  misclassifiedDependencies,
12442
12453
  redundantAliases: [...variableAliases, ...roundTripAliases],
12443
- errors,
12444
- contextStatus: "ready"
12454
+ errors
12445
12455
  };
12446
12456
  };
12447
12457
 
@@ -12512,8 +12522,7 @@ const generateReport = (graph, config, summaryCache) => {
12512
12522
  unusedClassMembers: [],
12513
12523
  misclassifiedDependencies: [],
12514
12524
  redundantAliases: [],
12515
- errors: [],
12516
- contextStatus: "typescript-load-failed"
12525
+ errors: []
12517
12526
  };
12518
12527
  }
12519
12528
  for (const semanticError of semanticResult.errors) {
@@ -12724,7 +12733,7 @@ const isRecordValue = (value) => typeof value === "object" && value !== null &&
12724
12733
  const isStringArray = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string");
12725
12734
  const isOptionalArray = (value) => value === void 0 || Array.isArray(value);
12726
12735
  const emptyStore = (scopeHash) => ({
12727
- version: 3,
12736
+ version: 4,
12728
12737
  scopeHash,
12729
12738
  fileList: null,
12730
12739
  resolutions: null,
@@ -12734,10 +12743,10 @@ const emptyStore = (scopeHash) => ({
12734
12743
  const readPersistedStore = (cachePath, scopeHash) => {
12735
12744
  try {
12736
12745
  const parsed = JSON.parse((0, node_fs.readFileSync)(cachePath, "utf-8"));
12737
- if (isRecordValue(parsed) && parsed.version === 3 && parsed.scopeHash === scopeHash && isRecordValue(parsed.summaries) && isRecordValue(parsed.packageFacts)) {
12746
+ if (isRecordValue(parsed) && parsed.version === 4 && parsed.scopeHash === scopeHash && isRecordValue(parsed.summaries) && isRecordValue(parsed.packageFacts)) {
12738
12747
  const persisted = parsed;
12739
12748
  return {
12740
- version: 3,
12749
+ version: 4,
12741
12750
  scopeHash,
12742
12751
  fileList: isRecordValue(persisted.fileList) ? persisted.fileList : null,
12743
12752
  resolutions: isRecordValue(persisted.resolutions) && typeof persisted.resolutions.hash === "string" && isRecordValue(persisted.resolutions.entries) ? persisted.resolutions : null,
@@ -13007,7 +13016,7 @@ const createSummaryCache = (cachePath, config) => {
13007
13016
  if (resolutionEntry !== void 0) compactedResolutions[resolutionKey] = resolutionEntry;
13008
13017
  }
13009
13018
  const serialized = JSON.stringify({
13010
- version: 3,
13019
+ version: 4,
13011
13020
  scopeHash,
13012
13021
  fileList: store.fileList,
13013
13022
  resolutions: {
@@ -13094,6 +13103,10 @@ const collectGitIgnoredPaths = (rootDirectory, candidatePaths) => {
13094
13103
  };
13095
13104
  };
13096
13105
 
13106
+ //#endregion
13107
+ //#region src/utils/normalize-registry-module-path.ts
13108
+ const normalizeRegistryModulePath = (modulePath) => modulePath.replace(/^\.\//, "").replace(/\.(?:[cm]?[jt]sx?)$/, "");
13109
+
13097
13110
  //#endregion
13098
13111
  //#region src/index.ts
13099
13112
  const STYLE_EXTENSIONS = [".css", ".scss"];
@@ -13109,21 +13122,35 @@ const basenameFromPath = (filePath) => {
13109
13122
  * analysis can't follow the indirection, so those targets get falsely
13110
13123
  * flagged as unused.
13111
13124
  *
13112
- * Heuristic: if a parsed string literal exactly matches the basename of
13113
- * exactly one file in the project, treat that file as an entry point.
13114
- * Uniqueness guards against false-positives from common names like
13115
- * `index.ts` matching dozens of unrelated files.
13125
+ * Heuristic: if a parsed string literal exactly matches the basename or
13126
+ * extensionless path suffix of exactly one file in the project, treat that
13127
+ * file as an entry point. Uniqueness guards against false-positives from
13128
+ * common names like `index.ts` matching dozens of unrelated files.
13116
13129
  */
13117
13130
  const markFilenameRegistryEntries = (moduleGraph) => {
13118
13131
  const basenameToModuleIndex = /* @__PURE__ */ new Map();
13132
+ const pathSuffixToModuleIndex = /* @__PURE__ */ new Map();
13133
+ const referencedPathSet = /* @__PURE__ */ new Set();
13134
+ for (const module of moduleGraph.modules) for (const referencedFilename of module.referencedFilenames) if (referencedFilename.includes("/")) referencedPathSet.add(normalizeRegistryModulePath(referencedFilename));
13119
13135
  for (const module of moduleGraph.modules) {
13120
13136
  const basename = basenameFromPath(module.fileId.path);
13121
13137
  const existing = basenameToModuleIndex.get(basename);
13122
13138
  if (existing === void 0) basenameToModuleIndex.set(basename, module.fileId.index);
13123
13139
  else if (existing !== "ambiguous") basenameToModuleIndex.set(basename, "ambiguous");
13140
+ const extensionlessPath = normalizeRegistryModulePath(module.fileId.path);
13141
+ let slashIndex = extensionlessPath.indexOf("/");
13142
+ while (slashIndex !== -1) {
13143
+ const pathSuffix = extensionlessPath.slice(slashIndex + 1);
13144
+ slashIndex = extensionlessPath.indexOf("/", slashIndex + 1);
13145
+ if (!referencedPathSet.has(pathSuffix)) continue;
13146
+ const existingPathIndex = pathSuffixToModuleIndex.get(pathSuffix);
13147
+ if (existingPathIndex === void 0) pathSuffixToModuleIndex.set(pathSuffix, module.fileId.index);
13148
+ else if (existingPathIndex !== "ambiguous") pathSuffixToModuleIndex.set(pathSuffix, "ambiguous");
13149
+ }
13124
13150
  }
13125
13151
  for (const module of moduleGraph.modules) for (const referencedFilename of module.referencedFilenames) {
13126
- const targetIndex = basenameToModuleIndex.get(referencedFilename);
13152
+ const normalizedReference = normalizeRegistryModulePath(referencedFilename);
13153
+ const targetIndex = referencedFilename.includes("/") ? pathSuffixToModuleIndex.get(normalizedReference) : basenameToModuleIndex.get(referencedFilename);
13127
13154
  if (typeof targetIndex !== "number") continue;
13128
13155
  const targetModule = moduleGraph.modules[targetIndex];
13129
13156
  if (!targetModule || targetModule.isEntryPoint) continue;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as STANDALONE_PROJECT_LOCKFILES, C as RESOLVER_EXTENSIONS, D as SCRIPT_FILE_PATTERN, E as SCRIPT_EXTENSIONLESS_FILE_PATTERN, O as SEMANTIC_MAX_PROGRAM_FILES, S as REACT_NATIVE_PLATFORM_EXTENSIONS, T as SCRIPT_ENTRY_PATTERNS, _ as MINIFIED_DETECTION_MIN_BYTES, a as DEFAULT_EXCLUSIONS, b as OUTPUT_DIRECTORIES, c as DEFAULT_SEMANTIC_TSCONFIG_NAMES, d as IMPLICIT_DEPENDENCIES, f as KNOWN_CONFIG_PREFIXES, g as MAX_PARSE_FILE_SIZE_BYTES, h as MAX_ERROR_DETAIL_LENGTH, i as DEFAULT_ENTRY_GLOBS, j as SUMMARY_CACHE_MAX_BYTES, k as SOURCE_EXTENSIONS$3, l as GIT_CHECK_IGNORE_MAX_BUFFER_BYTES, m as MAX_ANALYSIS_ERRORS, n as BINARY_DETECTION_SAMPLE_BYTES, o as DEFAULT_EXTENSIONS, p as LOCKFILE_MARKERS, r as BUILTIN_MODULES, s as DEFAULT_SEMANTIC_DECORATOR_ALLOWLIST, t as ANALYZED_MANIFEST_FILENAMES, u as HIDDEN_DIRECTORY_ALLOWLIST, v as MIN_NUMERIC_LITERAL_MAGNITUDE_FOR_DUPLICATE, w as SCRIPT_CONFIG_FILE_PATTERN, x as PLATFORM_SUFFIXES, y as MONOREPO_ROOT_MARKERS } from "./constants-oYYofMhb.mjs";
1
+ import { A as SUMMARY_CACHE_MAX_BYTES, C as RESOLVER_EXTENSIONS, D as SEMANTIC_MAX_PROGRAM_FILES, E as SCRIPT_FILE_PATTERN, O as SOURCE_EXTENSIONS$3, S as REACT_NATIVE_PLATFORM_EXTENSIONS, T as SCRIPT_EXTENSIONLESS_FILE_PATTERN, _ as MINIFIED_DETECTION_MIN_BYTES, a as DEFAULT_EXCLUSIONS, b as OUTPUT_DIRECTORIES, c as DEFAULT_SEMANTIC_TSCONFIG_NAMES, d as IMPLICIT_DEPENDENCIES, f as KNOWN_CONFIG_PREFIXES, g as MAX_PARSE_FILE_SIZE_BYTES, h as MAX_ERROR_DETAIL_LENGTH, i as DEFAULT_ENTRY_GLOBS, k as STANDALONE_PROJECT_LOCKFILES, l as GIT_CHECK_IGNORE_MAX_BUFFER_BYTES, m as MAX_ANALYSIS_ERRORS, n as BINARY_DETECTION_SAMPLE_BYTES, o as DEFAULT_EXTENSIONS, p as LOCKFILE_MARKERS, r as BUILTIN_MODULES, s as DEFAULT_SEMANTIC_DECORATOR_ALLOWLIST, t as ANALYZED_MANIFEST_FILENAMES, u as HIDDEN_DIRECTORY_ALLOWLIST, v as MIN_NUMERIC_LITERAL_MAGNITUDE_FOR_DUPLICATE, w as SCRIPT_CONFIG_FILE_PATTERN, x as PLATFORM_SUFFIXES, y as MONOREPO_ROOT_MARKERS } from "./constants-DBVadY0c.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import path, { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
4
4
  import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
@@ -1744,7 +1744,7 @@ const parseSourceFile = (filePath) => {
1744
1744
  wholeObjectUses,
1745
1745
  localIdentifierReferences,
1746
1746
  topLevelImportReferences,
1747
- referencedFilenames: extractReferencedFilenames(sourceText),
1747
+ referencedFilenames: extractReferencedFilenames(sourceText, program.body),
1748
1748
  redundantTypePatterns,
1749
1749
  identityWrappers,
1750
1750
  typeDefinitionHashes,
@@ -1756,11 +1756,33 @@ const parseSourceFile = (filePath) => {
1756
1756
  };
1757
1757
  };
1758
1758
  const REFERENCED_FILENAME_LITERAL_PATTERN = /(?<![./@\w-])(?:["'`])([a-z][\w-]*\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs))(?:["'`])/g;
1759
- const extractReferencedFilenames = (sourceText) => {
1759
+ const REFERENCED_MODULE_PATH_PATTERN = /^[a-zA-Z0-9_@-][a-zA-Z0-9_@.-]*(?:\/[a-zA-Z0-9_@.-]+)+$/;
1760
+ const extractReferencedFilenames = (sourceText, bodyNodes = []) => {
1760
1761
  const captured = /* @__PURE__ */ new Set();
1761
1762
  REFERENCED_FILENAME_LITERAL_PATTERN.lastIndex = 0;
1762
1763
  let match;
1763
1764
  while ((match = REFERENCED_FILENAME_LITERAL_PATTERN.exec(sourceText)) !== null) captured.add(match[1]);
1765
+ const visitNode = (node) => {
1766
+ if (node.type === "ImportExpression") {
1767
+ const sourceExpression = node.source;
1768
+ if (isWalkableNode(sourceExpression) && sourceExpression.type === "Literal") {
1769
+ const literalValue = sourceExpression.value;
1770
+ if (typeof literalValue === "string" && REFERENCED_MODULE_PATH_PATTERN.test(literalValue)) captured.add(literalValue);
1771
+ }
1772
+ }
1773
+ if (node.type === "CallExpression" || node.type === "NewExpression") {
1774
+ const callArguments = node.arguments;
1775
+ for (const callArgument of Array.isArray(callArguments) ? callArguments : []) {
1776
+ if (!isWalkableNode(callArgument) || callArgument.type !== "Literal") continue;
1777
+ const literalValue = callArgument.value;
1778
+ if (typeof literalValue === "string" && REFERENCED_MODULE_PATH_PATTERN.test(literalValue)) captured.add(literalValue);
1779
+ }
1780
+ }
1781
+ for (const value of Object.values(node)) if (Array.isArray(value)) {
1782
+ for (const element of value) if (isWalkableNode(element)) visitNode(element);
1783
+ } else if (isWalkableNode(value)) visitNode(value);
1784
+ };
1785
+ for (const bodyNode of bodyNodes) if (isWalkableNode(bodyNode)) visitNode(bodyNode);
1764
1786
  return [...captured];
1765
1787
  };
1766
1788
  const collectDryPatterns = (bodyNodes, sourceText, redundantTypePatterns, identityWrappers, typeDefinitionHashes) => {
@@ -5192,13 +5214,6 @@ const extractScriptEntries = (directory) => {
5192
5214
  entries.push(...extractScriptFileArguments(scriptCommand, directory));
5193
5215
  }
5194
5216
  } catch {}
5195
- const scriptDirectoryFiles = fg.sync(SCRIPT_ENTRY_PATTERNS, {
5196
- cwd: directory,
5197
- absolute: true,
5198
- onlyFiles: true,
5199
- ignore: ["**/node_modules/**"]
5200
- });
5201
- entries.push(...scriptDirectoryFiles);
5202
5217
  return entries;
5203
5218
  };
5204
5219
  const isYamlMapping = (line) => {
@@ -7997,6 +8012,7 @@ const detectStalePackages = (graph, config, summaryCache) => {
7997
8012
  "react-app-rewired"
7998
8013
  ].some((framework) => declaredNames.has(framework) || usedPackageNames.has(framework))) usedPackageNames.add("react-dom");
7999
8014
  }
8015
+ if (declaredNames.has("astro") && declaredNames.has("sharp")) usedPackageNames.add("sharp");
8000
8016
  if (declaredNames.has("react") && declaredNames.has("react-dom")) {
8001
8017
  const packageJsonPath = resolve(config.rootDir, "package.json");
8002
8018
  try {
@@ -12337,8 +12353,7 @@ const createDisabledSemanticResult = () => ({
12337
12353
  unusedClassMembers: [],
12338
12354
  misclassifiedDependencies: [],
12339
12355
  redundantAliases: [],
12340
- errors: [],
12341
- contextStatus: "disabled"
12356
+ errors: []
12342
12357
  });
12343
12358
  const runSemanticAnalysis = (graph, config) => {
12344
12359
  const semanticConfig = config.semantic;
@@ -12359,8 +12374,7 @@ const runSemanticAnalysis = (graph, config) => {
12359
12374
  unusedClassMembers: [],
12360
12375
  misclassifiedDependencies,
12361
12376
  redundantAliases: [],
12362
- errors,
12363
- contextStatus: "no-context-required"
12377
+ errors
12364
12378
  };
12365
12379
  let contextResult;
12366
12380
  try {
@@ -12376,8 +12390,7 @@ const runSemanticAnalysis = (graph, config) => {
12376
12390
  code: "ts-not-loadable",
12377
12391
  message: "createSemanticContext threw before returning a result",
12378
12392
  detail: describeUnknownError(contextError)
12379
- })],
12380
- contextStatus: "typescript-load-failed"
12393
+ })]
12381
12394
  };
12382
12395
  }
12383
12396
  if (!contextResult.ok) return {
@@ -12386,9 +12399,7 @@ const runSemanticAnalysis = (graph, config) => {
12386
12399
  unusedClassMembers: [],
12387
12400
  misclassifiedDependencies,
12388
12401
  redundantAliases: [],
12389
- errors: [...errors, contextResult.failure.error],
12390
- contextStatus: contextResult.failure.reason,
12391
- contextMessage: contextResult.failure.message
12402
+ errors: [...errors, contextResult.failure.error]
12392
12403
  };
12393
12404
  const { context } = contextResult;
12394
12405
  let referenceIndex;
@@ -12407,8 +12418,7 @@ const runSemanticAnalysis = (graph, config) => {
12407
12418
  unusedClassMembers,
12408
12419
  misclassifiedDependencies,
12409
12420
  redundantAliases: [...variableAliases, ...roundTripAliases],
12410
- errors,
12411
- contextStatus: "ready"
12421
+ errors
12412
12422
  };
12413
12423
  };
12414
12424
 
@@ -12479,8 +12489,7 @@ const generateReport = (graph, config, summaryCache) => {
12479
12489
  unusedClassMembers: [],
12480
12490
  misclassifiedDependencies: [],
12481
12491
  redundantAliases: [],
12482
- errors: [],
12483
- contextStatus: "typescript-load-failed"
12492
+ errors: []
12484
12493
  };
12485
12494
  }
12486
12495
  for (const semanticError of semanticResult.errors) {
@@ -12691,7 +12700,7 @@ const isRecordValue = (value) => typeof value === "object" && value !== null &&
12691
12700
  const isStringArray = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string");
12692
12701
  const isOptionalArray = (value) => value === void 0 || Array.isArray(value);
12693
12702
  const emptyStore = (scopeHash) => ({
12694
- version: 3,
12703
+ version: 4,
12695
12704
  scopeHash,
12696
12705
  fileList: null,
12697
12706
  resolutions: null,
@@ -12701,10 +12710,10 @@ const emptyStore = (scopeHash) => ({
12701
12710
  const readPersistedStore = (cachePath, scopeHash) => {
12702
12711
  try {
12703
12712
  const parsed = JSON.parse(readFileSync(cachePath, "utf-8"));
12704
- if (isRecordValue(parsed) && parsed.version === 3 && parsed.scopeHash === scopeHash && isRecordValue(parsed.summaries) && isRecordValue(parsed.packageFacts)) {
12713
+ if (isRecordValue(parsed) && parsed.version === 4 && parsed.scopeHash === scopeHash && isRecordValue(parsed.summaries) && isRecordValue(parsed.packageFacts)) {
12705
12714
  const persisted = parsed;
12706
12715
  return {
12707
- version: 3,
12716
+ version: 4,
12708
12717
  scopeHash,
12709
12718
  fileList: isRecordValue(persisted.fileList) ? persisted.fileList : null,
12710
12719
  resolutions: isRecordValue(persisted.resolutions) && typeof persisted.resolutions.hash === "string" && isRecordValue(persisted.resolutions.entries) ? persisted.resolutions : null,
@@ -12974,7 +12983,7 @@ const createSummaryCache = (cachePath, config) => {
12974
12983
  if (resolutionEntry !== void 0) compactedResolutions[resolutionKey] = resolutionEntry;
12975
12984
  }
12976
12985
  const serialized = JSON.stringify({
12977
- version: 3,
12986
+ version: 4,
12978
12987
  scopeHash,
12979
12988
  fileList: store.fileList,
12980
12989
  resolutions: {
@@ -13061,6 +13070,10 @@ const collectGitIgnoredPaths = (rootDirectory, candidatePaths) => {
13061
13070
  };
13062
13071
  };
13063
13072
 
13073
+ //#endregion
13074
+ //#region src/utils/normalize-registry-module-path.ts
13075
+ const normalizeRegistryModulePath = (modulePath) => modulePath.replace(/^\.\//, "").replace(/\.(?:[cm]?[jt]sx?)$/, "");
13076
+
13064
13077
  //#endregion
13065
13078
  //#region src/index.ts
13066
13079
  const STYLE_EXTENSIONS = [".css", ".scss"];
@@ -13076,21 +13089,35 @@ const basenameFromPath = (filePath) => {
13076
13089
  * analysis can't follow the indirection, so those targets get falsely
13077
13090
  * flagged as unused.
13078
13091
  *
13079
- * Heuristic: if a parsed string literal exactly matches the basename of
13080
- * exactly one file in the project, treat that file as an entry point.
13081
- * Uniqueness guards against false-positives from common names like
13082
- * `index.ts` matching dozens of unrelated files.
13092
+ * Heuristic: if a parsed string literal exactly matches the basename or
13093
+ * extensionless path suffix of exactly one file in the project, treat that
13094
+ * file as an entry point. Uniqueness guards against false-positives from
13095
+ * common names like `index.ts` matching dozens of unrelated files.
13083
13096
  */
13084
13097
  const markFilenameRegistryEntries = (moduleGraph) => {
13085
13098
  const basenameToModuleIndex = /* @__PURE__ */ new Map();
13099
+ const pathSuffixToModuleIndex = /* @__PURE__ */ new Map();
13100
+ const referencedPathSet = /* @__PURE__ */ new Set();
13101
+ for (const module of moduleGraph.modules) for (const referencedFilename of module.referencedFilenames) if (referencedFilename.includes("/")) referencedPathSet.add(normalizeRegistryModulePath(referencedFilename));
13086
13102
  for (const module of moduleGraph.modules) {
13087
13103
  const basename = basenameFromPath(module.fileId.path);
13088
13104
  const existing = basenameToModuleIndex.get(basename);
13089
13105
  if (existing === void 0) basenameToModuleIndex.set(basename, module.fileId.index);
13090
13106
  else if (existing !== "ambiguous") basenameToModuleIndex.set(basename, "ambiguous");
13107
+ const extensionlessPath = normalizeRegistryModulePath(module.fileId.path);
13108
+ let slashIndex = extensionlessPath.indexOf("/");
13109
+ while (slashIndex !== -1) {
13110
+ const pathSuffix = extensionlessPath.slice(slashIndex + 1);
13111
+ slashIndex = extensionlessPath.indexOf("/", slashIndex + 1);
13112
+ if (!referencedPathSet.has(pathSuffix)) continue;
13113
+ const existingPathIndex = pathSuffixToModuleIndex.get(pathSuffix);
13114
+ if (existingPathIndex === void 0) pathSuffixToModuleIndex.set(pathSuffix, module.fileId.index);
13115
+ else if (existingPathIndex !== "ambiguous") pathSuffixToModuleIndex.set(pathSuffix, "ambiguous");
13116
+ }
13091
13117
  }
13092
13118
  for (const module of moduleGraph.modules) for (const referencedFilename of module.referencedFilenames) {
13093
- const targetIndex = basenameToModuleIndex.get(referencedFilename);
13119
+ const normalizedReference = normalizeRegistryModulePath(referencedFilename);
13120
+ const targetIndex = referencedFilename.includes("/") ? pathSuffixToModuleIndex.get(normalizedReference) : basenameToModuleIndex.get(referencedFilename);
13094
13121
  if (typeof targetIndex !== "number") continue;
13095
13122
  const targetModule = moduleGraph.modules[targetIndex];
13096
13123
  if (!targetModule || targetModule.isEntryPoint) continue;
@@ -72,7 +72,6 @@ const SOURCE_EXTENSIONS = [
72
72
  const SCRIPT_FILE_PATTERN = /(?:^|\s)(?:node|tsx|ts-node|tsc|npx|bun|esr|esno|jiti|babel-node|zx)\s+(?:\S+\s+)*?([\w./@-]+\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs))(?:\s|$)/;
73
73
  const SCRIPT_EXTENSIONLESS_FILE_PATTERN = /(?:^|\s)(?:node|tsx|ts-node|bun|esr|esno|jiti|babel-node|zx)\s+(?:\S+\s+)*?((?:[./]|[\w@][\w@-]*\/)[\w./@-]+)(?:\s|$)/;
74
74
  const SCRIPT_CONFIG_FILE_PATTERN = /--config\s+([\w./@-]+\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs))/;
75
- const SCRIPT_ENTRY_PATTERNS = [];
76
75
  const RESOLVER_EXTENSIONS = [
77
76
  ...DEFAULT_EXTENSIONS,
78
77
  ".d.ts",
@@ -1787,7 +1786,7 @@ const parseSourceFile = (filePath) => {
1787
1786
  wholeObjectUses,
1788
1787
  localIdentifierReferences,
1789
1788
  topLevelImportReferences,
1790
- referencedFilenames: extractReferencedFilenames(sourceText),
1789
+ referencedFilenames: extractReferencedFilenames(sourceText, program.body),
1791
1790
  redundantTypePatterns,
1792
1791
  identityWrappers,
1793
1792
  typeDefinitionHashes,
@@ -1799,11 +1798,33 @@ const parseSourceFile = (filePath) => {
1799
1798
  };
1800
1799
  };
1801
1800
  const REFERENCED_FILENAME_LITERAL_PATTERN = /(?<![./@\w-])(?:["'`])([a-z][\w-]*\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs))(?:["'`])/g;
1802
- const extractReferencedFilenames = (sourceText) => {
1801
+ const REFERENCED_MODULE_PATH_PATTERN = /^[a-zA-Z0-9_@-][a-zA-Z0-9_@.-]*(?:\/[a-zA-Z0-9_@.-]+)+$/;
1802
+ const extractReferencedFilenames = (sourceText, bodyNodes = []) => {
1803
1803
  const captured = /* @__PURE__ */ new Set();
1804
1804
  REFERENCED_FILENAME_LITERAL_PATTERN.lastIndex = 0;
1805
1805
  let match;
1806
1806
  while ((match = REFERENCED_FILENAME_LITERAL_PATTERN.exec(sourceText)) !== null) captured.add(match[1]);
1807
+ const visitNode = (node) => {
1808
+ if (node.type === "ImportExpression") {
1809
+ const sourceExpression = node.source;
1810
+ if (isWalkableNode(sourceExpression) && sourceExpression.type === "Literal") {
1811
+ const literalValue = sourceExpression.value;
1812
+ if (typeof literalValue === "string" && REFERENCED_MODULE_PATH_PATTERN.test(literalValue)) captured.add(literalValue);
1813
+ }
1814
+ }
1815
+ if (node.type === "CallExpression" || node.type === "NewExpression") {
1816
+ const callArguments = node.arguments;
1817
+ for (const callArgument of Array.isArray(callArguments) ? callArguments : []) {
1818
+ if (!isWalkableNode(callArgument) || callArgument.type !== "Literal") continue;
1819
+ const literalValue = callArgument.value;
1820
+ if (typeof literalValue === "string" && REFERENCED_MODULE_PATH_PATTERN.test(literalValue)) captured.add(literalValue);
1821
+ }
1822
+ }
1823
+ for (const value of Object.values(node)) if (Array.isArray(value)) {
1824
+ for (const element of value) if (isWalkableNode(element)) visitNode(element);
1825
+ } else if (isWalkableNode(value)) visitNode(value);
1826
+ };
1827
+ for (const bodyNode of bodyNodes) if (isWalkableNode(bodyNode)) visitNode(bodyNode);
1807
1828
  return [...captured];
1808
1829
  };
1809
1830
  const collectDryPatterns = (bodyNodes, sourceText, redundantTypePatterns, identityWrappers, typeDefinitionHashes) => {
@@ -2455,4 +2476,4 @@ const extractReactRouterRouteModuleEntries = (routesFilePath) => {
2455
2476
  };
2456
2477
 
2457
2478
  //#endregion
2458
- export { OUTPUT_DIRECTORIES as a, SCRIPT_ENTRY_PATTERNS as c, SOURCE_EXTENSIONS as d, STANDALONE_PROJECT_LOCKFILES as f, MONOREPO_ROOT_MARKERS as i, SCRIPT_EXTENSIONLESS_FILE_PATTERN as l, parseSourceFile as n, RESOLVER_EXTENSIONS as o, LOCKFILE_MARKERS as r, SCRIPT_CONFIG_FILE_PATTERN as s, extractReactRouterRouteModuleEntries as t, SCRIPT_FILE_PATTERN as u };
2479
+ export { OUTPUT_DIRECTORIES as a, SCRIPT_EXTENSIONLESS_FILE_PATTERN as c, STANDALONE_PROJECT_LOCKFILES as d, MONOREPO_ROOT_MARKERS as i, SCRIPT_FILE_PATTERN as l, parseSourceFile as n, RESOLVER_EXTENSIONS as o, LOCKFILE_MARKERS as r, SCRIPT_CONFIG_FILE_PATTERN as s, extractReactRouterRouteModuleEntries as t, SOURCE_EXTENSIONS as u };
@@ -1,4 +1,4 @@
1
- import { n as parseSourceFile } from "./parse-CDdo_Ppt.mjs";
1
+ import { n as parseSourceFile } from "./parse-C6-m3QMJ.mjs";
2
2
  import { parentPort } from "node:worker_threads";
3
3
 
4
4
  //#region src/collect/parse-worker.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deslop-js",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
4
4
  "description": "Remove AI slop from JavaScript code.",
5
5
  "keywords": [
6
6
  "dead-code",
@@ -63,10 +63,10 @@
63
63
  "access": "public"
64
64
  },
65
65
  "dependencies": {
66
- "@oxc-project/types": "^0.141.0",
66
+ "@oxc-project/types": "^0.142.0",
67
67
  "fast-glob": "^3.3.3",
68
68
  "minimatch": "^10.2.5",
69
- "oxc-parser": "^0.141.0",
69
+ "oxc-parser": "^0.142.0",
70
70
  "oxc-resolver": "^11.24.2",
71
71
  "typescript": ">=5.0.4 <6"
72
72
  },