layermap 0.1.33 → 0.1.35

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.
@@ -3452,7 +3452,7 @@ var require_main = __commonJS({
3452
3452
  exports.createMessageConnection = createMessageConnection2;
3453
3453
  var ril_1 = __importDefault(require_ril());
3454
3454
  ril_1.default.install();
3455
- var path8 = __importStar(__require("path"));
3455
+ var path10 = __importStar(__require("path"));
3456
3456
  var os = __importStar(__require("os"));
3457
3457
  var fs2 = __importStar(__require("fs"));
3458
3458
  var crypto_1 = __require("crypto");
@@ -3604,7 +3604,7 @@ var require_main = __commonJS({
3604
3604
  throw new Error(`Unable to generate a random pipe name with ${randomLength} characters.`);
3605
3605
  }
3606
3606
  const randomSuffix = (0, crypto_1.randomBytes)(Math.floor(randomLength / 2)).toString("hex");
3607
- return path8.join(tmpDir, `lsp-${randomSuffix}.sock`);
3607
+ return path10.join(tmpDir, `lsp-${randomSuffix}.sock`);
3608
3608
  }
3609
3609
  function createClientPipeTransport(pipeName, encoding = "utf-8") {
3610
3610
  let connectResolve;
@@ -3690,6 +3690,9 @@ var require_main = __commonJS({
3690
3690
  }
3691
3691
  });
3692
3692
 
3693
+ // src/project-map-worker.ts
3694
+ import path9 from "node:path";
3695
+
3693
3696
  // src/platform.ts
3694
3697
  import { spawnSync } from "node:child_process";
3695
3698
  import path from "node:path";
@@ -4932,9 +4935,15 @@ function isPropertyAssignment(node) {
4932
4935
  function isShorthandPropertyAssignment(node) {
4933
4936
  return node.kind === SyntaxKind.ShorthandPropertyAssignment;
4934
4937
  }
4938
+ function isIndexedAccessTypeNode(node) {
4939
+ return node.kind === SyntaxKind.IndexedAccessType;
4940
+ }
4935
4941
  function isExpressionWithTypeArguments(node) {
4936
4942
  return node.kind === SyntaxKind.ExpressionWithTypeArguments;
4937
4943
  }
4944
+ function isLiteralTypeNode(node) {
4945
+ return node.kind === SyntaxKind.LiteralType;
4946
+ }
4938
4947
  function isImportAttributes(node) {
4939
4948
  return node.kind === SyntaxKind.ImportAttributes;
4940
4949
  }
@@ -13014,116 +13023,116 @@ function getFileUrlVolumeSeparatorEnd(url2, start) {
13014
13023
  }
13015
13024
  return -1;
13016
13025
  }
13017
- function getRootLength(path8) {
13018
- const rootLength = getEncodedRootLength(path8);
13026
+ function getRootLength(path10) {
13027
+ const rootLength = getEncodedRootLength(path10);
13019
13028
  return rootLength < 0 ? ~rootLength : rootLength;
13020
13029
  }
13021
- function getEncodedRootLength(path8) {
13022
- if (!path8)
13030
+ function getEncodedRootLength(path10) {
13031
+ if (!path10)
13023
13032
  return 0;
13024
- const ch0 = path8.charCodeAt(0);
13033
+ const ch0 = path10.charCodeAt(0);
13025
13034
  if (ch0 === CharacterCodesSlash || ch0 === CharacterCodesBackslash) {
13026
- if (path8.charCodeAt(1) !== ch0)
13035
+ if (path10.charCodeAt(1) !== ch0)
13027
13036
  return 1;
13028
- const p1 = path8.indexOf(ch0 === CharacterCodesSlash ? directorySeparator : altDirectorySeparator, 2);
13037
+ const p1 = path10.indexOf(ch0 === CharacterCodesSlash ? directorySeparator : altDirectorySeparator, 2);
13029
13038
  if (p1 < 0)
13030
- return path8.length;
13039
+ return path10.length;
13031
13040
  return p1 + 1;
13032
13041
  }
13033
- if (isVolumeCharacter(ch0) && path8.charCodeAt(1) === CharacterCodesColon) {
13034
- const ch2 = path8.charCodeAt(2);
13042
+ if (isVolumeCharacter(ch0) && path10.charCodeAt(1) === CharacterCodesColon) {
13043
+ const ch2 = path10.charCodeAt(2);
13035
13044
  if (ch2 === CharacterCodesSlash || ch2 === CharacterCodesBackslash)
13036
13045
  return 3;
13037
- if (path8.length === 2)
13046
+ if (path10.length === 2)
13038
13047
  return 2;
13039
13048
  }
13040
- const schemeEnd = path8.indexOf(urlSchemeSeparator);
13049
+ const schemeEnd = path10.indexOf(urlSchemeSeparator);
13041
13050
  if (schemeEnd !== -1) {
13042
13051
  const authorityStart = schemeEnd + urlSchemeSeparator.length;
13043
- const authorityEnd = path8.indexOf(directorySeparator, authorityStart);
13052
+ const authorityEnd = path10.indexOf(directorySeparator, authorityStart);
13044
13053
  if (authorityEnd !== -1) {
13045
- const scheme = path8.slice(0, schemeEnd);
13046
- const authority = path8.slice(authorityStart, authorityEnd);
13047
- if (scheme === "file" && (authority === "" || authority === "localhost") && isVolumeCharacter(path8.charCodeAt(authorityEnd + 1))) {
13048
- const volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path8, authorityEnd + 2);
13054
+ const scheme = path10.slice(0, schemeEnd);
13055
+ const authority = path10.slice(authorityStart, authorityEnd);
13056
+ if (scheme === "file" && (authority === "" || authority === "localhost") && isVolumeCharacter(path10.charCodeAt(authorityEnd + 1))) {
13057
+ const volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path10, authorityEnd + 2);
13049
13058
  if (volumeSeparatorEnd !== -1) {
13050
- if (path8.charCodeAt(volumeSeparatorEnd) === CharacterCodesSlash) {
13059
+ if (path10.charCodeAt(volumeSeparatorEnd) === CharacterCodesSlash) {
13051
13060
  return ~(volumeSeparatorEnd + 1);
13052
13061
  }
13053
- if (volumeSeparatorEnd === path8.length) {
13062
+ if (volumeSeparatorEnd === path10.length) {
13054
13063
  return ~volumeSeparatorEnd;
13055
13064
  }
13056
13065
  }
13057
13066
  }
13058
13067
  return ~(authorityEnd + 1);
13059
13068
  }
13060
- return ~path8.length;
13069
+ return ~path10.length;
13061
13070
  }
13062
13071
  return 0;
13063
13072
  }
13064
- function hasTrailingDirectorySeparator(path8) {
13065
- return path8.length > 0 && isAnyDirectorySeparator(path8.charCodeAt(path8.length - 1));
13073
+ function hasTrailingDirectorySeparator(path10) {
13074
+ return path10.length > 0 && isAnyDirectorySeparator(path10.charCodeAt(path10.length - 1));
13066
13075
  }
13067
- function removeTrailingDirectorySeparator(path8) {
13068
- if (hasTrailingDirectorySeparator(path8)) {
13069
- return path8.substr(0, path8.length - 1);
13076
+ function removeTrailingDirectorySeparator(path10) {
13077
+ if (hasTrailingDirectorySeparator(path10)) {
13078
+ return path10.substr(0, path10.length - 1);
13070
13079
  }
13071
- return path8;
13080
+ return path10;
13072
13081
  }
13073
- function ensureTrailingDirectorySeparator(path8) {
13074
- if (!hasTrailingDirectorySeparator(path8)) {
13075
- return path8 + directorySeparator;
13082
+ function ensureTrailingDirectorySeparator(path10) {
13083
+ if (!hasTrailingDirectorySeparator(path10)) {
13084
+ return path10 + directorySeparator;
13076
13085
  }
13077
- return path8;
13086
+ return path10;
13078
13087
  }
13079
- function normalizeSlashes(path8) {
13080
- return path8.includes("\\") ? path8.replace(backslashRegExp, directorySeparator) : path8;
13088
+ function normalizeSlashes(path10) {
13089
+ return path10.includes("\\") ? path10.replace(backslashRegExp, directorySeparator) : path10;
13081
13090
  }
13082
- function combinePaths(path8, ...paths) {
13083
- if (path8)
13084
- path8 = normalizeSlashes(path8);
13091
+ function combinePaths(path10, ...paths) {
13092
+ if (path10)
13093
+ path10 = normalizeSlashes(path10);
13085
13094
  for (let relativePath of paths) {
13086
13095
  if (!relativePath)
13087
13096
  continue;
13088
13097
  relativePath = normalizeSlashes(relativePath);
13089
- if (!path8 || getRootLength(relativePath) !== 0) {
13090
- path8 = relativePath;
13098
+ if (!path10 || getRootLength(relativePath) !== 0) {
13099
+ path10 = relativePath;
13091
13100
  } else {
13092
- path8 = ensureTrailingDirectorySeparator(path8) + relativePath;
13101
+ path10 = ensureTrailingDirectorySeparator(path10) + relativePath;
13093
13102
  }
13094
13103
  }
13095
- return path8;
13104
+ return path10;
13096
13105
  }
13097
- function simpleNormalizePath(path8) {
13098
- if (!relativePathSegmentRegExp.test(path8)) {
13099
- return path8;
13106
+ function simpleNormalizePath(path10) {
13107
+ if (!relativePathSegmentRegExp.test(path10)) {
13108
+ return path10;
13100
13109
  }
13101
- let simplified = path8.replace(/\/\.\//g, "/");
13110
+ let simplified = path10.replace(/\/\.\//g, "/");
13102
13111
  if (simplified.startsWith("./")) {
13103
13112
  simplified = simplified.slice(2);
13104
13113
  }
13105
- if (simplified !== path8) {
13106
- path8 = simplified;
13107
- if (!relativePathSegmentRegExp.test(path8)) {
13108
- return path8;
13114
+ if (simplified !== path10) {
13115
+ path10 = simplified;
13116
+ if (!relativePathSegmentRegExp.test(path10)) {
13117
+ return path10;
13109
13118
  }
13110
13119
  }
13111
13120
  return void 0;
13112
13121
  }
13113
- function getNormalizedAbsolutePath(path8, currentDirectory) {
13114
- let rootLength = getRootLength(path8);
13122
+ function getNormalizedAbsolutePath(path10, currentDirectory) {
13123
+ let rootLength = getRootLength(path10);
13115
13124
  if (rootLength === 0 && currentDirectory) {
13116
- path8 = combinePaths(currentDirectory, path8);
13117
- rootLength = getRootLength(path8);
13125
+ path10 = combinePaths(currentDirectory, path10);
13126
+ rootLength = getRootLength(path10);
13118
13127
  } else {
13119
- path8 = normalizeSlashes(path8);
13128
+ path10 = normalizeSlashes(path10);
13120
13129
  }
13121
- const simpleNormalized = simpleNormalizePath(path8);
13130
+ const simpleNormalized = simpleNormalizePath(path10);
13122
13131
  if (simpleNormalized !== void 0) {
13123
13132
  return simpleNormalized.length > rootLength ? removeTrailingDirectorySeparator(simpleNormalized) : simpleNormalized;
13124
13133
  }
13125
- const length = path8.length;
13126
- const root = path8.substring(0, rootLength);
13134
+ const length = path10.length;
13135
+ const root = path10.substring(0, rootLength);
13127
13136
  let normalized;
13128
13137
  let index = rootLength;
13129
13138
  let segmentStart = index;
@@ -13131,23 +13140,23 @@ function getNormalizedAbsolutePath(path8, currentDirectory) {
13131
13140
  let seenNonDotDotSegment = rootLength !== 0;
13132
13141
  while (index < length) {
13133
13142
  segmentStart = index;
13134
- let ch = path8.charCodeAt(index);
13143
+ let ch = path10.charCodeAt(index);
13135
13144
  while (ch === CharacterCodesSlash && index + 1 < length) {
13136
13145
  index++;
13137
- ch = path8.charCodeAt(index);
13146
+ ch = path10.charCodeAt(index);
13138
13147
  }
13139
13148
  if (index > segmentStart) {
13140
- normalized ??= path8.substring(0, segmentStart - 1);
13149
+ normalized ??= path10.substring(0, segmentStart - 1);
13141
13150
  segmentStart = index;
13142
13151
  }
13143
- let segmentEnd = path8.indexOf(directorySeparator, index + 1);
13152
+ let segmentEnd = path10.indexOf(directorySeparator, index + 1);
13144
13153
  if (segmentEnd === -1) {
13145
13154
  segmentEnd = length;
13146
13155
  }
13147
13156
  const segmentLength = segmentEnd - segmentStart;
13148
- if (segmentLength === 1 && path8.charCodeAt(index) === CharacterCodesDot) {
13149
- normalized ??= path8.substring(0, normalizedUpTo);
13150
- } else if (segmentLength === 2 && path8.charCodeAt(index) === CharacterCodesDot && path8.charCodeAt(index + 1) === CharacterCodesDot) {
13157
+ if (segmentLength === 1 && path10.charCodeAt(index) === CharacterCodesDot) {
13158
+ normalized ??= path10.substring(0, normalizedUpTo);
13159
+ } else if (segmentLength === 2 && path10.charCodeAt(index) === CharacterCodesDot && path10.charCodeAt(index + 1) === CharacterCodesDot) {
13151
13160
  if (!seenNonDotDotSegment) {
13152
13161
  if (normalized !== void 0) {
13153
13162
  normalized += normalized.length === rootLength ? ".." : "/..";
@@ -13156,9 +13165,9 @@ function getNormalizedAbsolutePath(path8, currentDirectory) {
13156
13165
  }
13157
13166
  } else if (normalized === void 0) {
13158
13167
  if (normalizedUpTo - 2 >= 0) {
13159
- normalized = path8.substring(0, Math.max(rootLength, path8.lastIndexOf(directorySeparator, normalizedUpTo - 2)));
13168
+ normalized = path10.substring(0, Math.max(rootLength, path10.lastIndexOf(directorySeparator, normalizedUpTo - 2)));
13160
13169
  } else {
13161
- normalized = path8.substring(0, normalizedUpTo);
13170
+ normalized = path10.substring(0, normalizedUpTo);
13162
13171
  }
13163
13172
  } else {
13164
13173
  const lastSlash = normalized.lastIndexOf(directorySeparator);
@@ -13176,26 +13185,26 @@ function getNormalizedAbsolutePath(path8, currentDirectory) {
13176
13185
  normalized += directorySeparator;
13177
13186
  }
13178
13187
  seenNonDotDotSegment = true;
13179
- normalized += path8.substring(segmentStart, segmentEnd);
13188
+ normalized += path10.substring(segmentStart, segmentEnd);
13180
13189
  } else {
13181
13190
  seenNonDotDotSegment = true;
13182
13191
  normalizedUpTo = segmentEnd;
13183
13192
  }
13184
13193
  index = segmentEnd + 1;
13185
13194
  }
13186
- return normalized ?? (length > rootLength ? removeTrailingDirectorySeparator(path8) : path8);
13195
+ return normalized ?? (length > rootLength ? removeTrailingDirectorySeparator(path10) : path10);
13187
13196
  }
13188
- function normalizePath(path8) {
13189
- path8 = normalizeSlashes(path8);
13190
- let normalized = simpleNormalizePath(path8);
13197
+ function normalizePath(path10) {
13198
+ path10 = normalizeSlashes(path10);
13199
+ let normalized = simpleNormalizePath(path10);
13191
13200
  if (normalized !== void 0) {
13192
13201
  return normalized;
13193
13202
  }
13194
- normalized = getNormalizedAbsolutePath(path8, "");
13195
- return normalized && hasTrailingDirectorySeparator(path8) ? ensureTrailingDirectorySeparator(normalized) : normalized;
13203
+ normalized = getNormalizedAbsolutePath(path10, "");
13204
+ return normalized && hasTrailingDirectorySeparator(path10) ? ensureTrailingDirectorySeparator(normalized) : normalized;
13196
13205
  }
13197
- function isRootedDiskPath(path8) {
13198
- return getEncodedRootLength(path8) > 0;
13206
+ function isRootedDiskPath(path10) {
13207
+ return getEncodedRootLength(path10) > 0;
13199
13208
  }
13200
13209
  function toPath(fileName, basePath, getCanonicalFileName) {
13201
13210
  const nonCanonicalizedPath = isRootedDiskPath(fileName) ? normalizePath(fileName) : getNormalizedAbsolutePath(fileName, basePath);
@@ -13211,14 +13220,14 @@ function toLowerCase(s) {
13211
13220
  return s.toLowerCase();
13212
13221
  }
13213
13222
  var bundledScheme = "bundled:///";
13214
- function isBundled(path8) {
13215
- return path8.startsWith(bundledScheme);
13223
+ function isBundled(path10) {
13224
+ return path10.startsWith(bundledScheme);
13216
13225
  }
13217
- function splitVolumePath(path8) {
13218
- if (path8.length >= 2 && isVolumeCharacter(path8.charCodeAt(0)) && path8.charCodeAt(1) === CharacterCodesColon) {
13219
- return [path8.substring(0, 2).toLowerCase(), path8.substring(2), true];
13226
+ function splitVolumePath(path10) {
13227
+ if (path10.length >= 2 && isVolumeCharacter(path10.charCodeAt(0)) && path10.charCodeAt(1) === CharacterCodesColon) {
13228
+ return [path10.substring(0, 2).toLowerCase(), path10.substring(2), true];
13220
13229
  }
13221
- return ["", path8, false];
13230
+ return ["", path10, false];
13222
13231
  }
13223
13232
  function documentURIToFileName(uri) {
13224
13233
  if (isBundled(uri)) {
@@ -13234,32 +13243,32 @@ function documentURIToFileName(uri) {
13234
13243
  if (parsed.host !== "") {
13235
13244
  return "//" + parsed.host + parsed.pathname;
13236
13245
  }
13237
- const path9 = decodeURIComponent(parsed.pathname);
13238
- if (path9.length >= 3 && path9.charCodeAt(0) === CharacterCodesSlash) {
13239
- const [volume, rest, ok] = splitVolumePath(path9.substring(1));
13246
+ const path11 = decodeURIComponent(parsed.pathname);
13247
+ if (path11.length >= 3 && path11.charCodeAt(0) === CharacterCodesSlash) {
13248
+ const [volume, rest, ok] = splitVolumePath(path11.substring(1));
13240
13249
  if (ok) {
13241
13250
  return volume + rest;
13242
13251
  }
13243
13252
  }
13244
- return path9;
13253
+ return path11;
13245
13254
  }
13246
13255
  const colonIndex = uri.indexOf(":");
13247
13256
  if (colonIndex === -1) {
13248
13257
  throw new Error("invalid URI: " + uri);
13249
13258
  }
13250
13259
  const scheme = uri.substring(0, colonIndex);
13251
- let path8 = uri.substring(colonIndex + 1);
13260
+ let path10 = uri.substring(colonIndex + 1);
13252
13261
  let authority = "ts-nul-authority";
13253
- if (path8.startsWith("//")) {
13254
- const rest = path8.substring(2);
13262
+ if (path10.startsWith("//")) {
13263
+ const rest = path10.substring(2);
13255
13264
  const slashIndex = rest.indexOf("/");
13256
13265
  if (slashIndex === -1) {
13257
13266
  throw new Error("invalid URI: " + uri);
13258
13267
  }
13259
13268
  authority = rest.substring(0, slashIndex);
13260
- path8 = rest.substring(slashIndex + 1);
13269
+ path10 = rest.substring(slashIndex + 1);
13261
13270
  }
13262
- return "^/" + scheme + "/" + authority + "/" + path8;
13271
+ return "^/" + scheme + "/" + authority + "/" + path10;
13263
13272
  }
13264
13273
 
13265
13274
  // node_modules/.pnpm/typescript@7.0.2/node_modules/typescript/dist/api/proto.js
@@ -13296,8 +13305,8 @@ var SourceFileCache = class {
13296
13305
  * A given (snapshot, project) pair always parses a file the same way, so there is
13297
13306
  * at most one matching entry per ref.
13298
13307
  */
13299
- getRetained(path8, snapshotId, projectId) {
13300
- const entries = this.cache.get(path8);
13308
+ getRetained(path10, snapshotId, projectId) {
13309
+ const entries = this.cache.get(path10);
13301
13310
  if (!entries)
13302
13311
  return void 0;
13303
13312
  const key2 = refKey(snapshotId, projectId);
@@ -13308,21 +13317,21 @@ var SourceFileCache = class {
13308
13317
  * Store a source file in the cache and retain it for the given (snapshot, project) pair.
13309
13318
  * Returns the cached file — which may be an existing entry if the hash matches.
13310
13319
  */
13311
- set(path8, file2, parseOptionsKey, contentHash, snapshotId, projectId) {
13312
- let entries = this.cache.get(path8);
13320
+ set(path10, file2, parseOptionsKey, contentHash, snapshotId, projectId) {
13321
+ let entries = this.cache.get(path10);
13313
13322
  if (!entries) {
13314
13323
  entries = [];
13315
- this.cache.set(path8, entries);
13324
+ this.cache.set(path10, entries);
13316
13325
  }
13317
13326
  const ref = refKey(snapshotId, projectId);
13318
13327
  const existing = entries.find((e) => e.parseOptionsKey === parseOptionsKey && e.contentHash === contentHash);
13319
13328
  if (existing) {
13320
13329
  existing.refs.add(ref);
13321
- this.trackPath(snapshotId, projectId, path8);
13330
+ this.trackPath(snapshotId, projectId, path10);
13322
13331
  return existing.file;
13323
13332
  }
13324
13333
  entries.push({ file: file2, contentHash, parseOptionsKey, refs: /* @__PURE__ */ new Set([ref]) });
13325
- this.trackPath(snapshotId, projectId, path8);
13334
+ this.trackPath(snapshotId, projectId, path10);
13326
13335
  return file2;
13327
13336
  }
13328
13337
  /**
@@ -13352,16 +13361,16 @@ var SourceFileCache = class {
13352
13361
  }
13353
13362
  const prevRef = refKey(previousSnapshotId, projectId);
13354
13363
  const newRef = refKey(newSnapshotId, projectId);
13355
- for (const path8 of paths) {
13356
- if (invalidPaths?.has(path8))
13364
+ for (const path10 of paths) {
13365
+ if (invalidPaths?.has(path10))
13357
13366
  continue;
13358
- const entries = this.cache.get(path8);
13367
+ const entries = this.cache.get(path10);
13359
13368
  if (!entries)
13360
13369
  continue;
13361
13370
  for (const entry of entries) {
13362
13371
  if (entry.refs.has(prevRef)) {
13363
13372
  entry.refs.add(newRef);
13364
- this.trackPath(newSnapshotId, projectId, path8);
13373
+ this.trackPath(newSnapshotId, projectId, path10);
13365
13374
  }
13366
13375
  }
13367
13376
  }
@@ -13378,8 +13387,8 @@ var SourceFileCache = class {
13378
13387
  return;
13379
13388
  for (const [projectId, paths] of projectMap) {
13380
13389
  const key2 = refKey(snapshotId, projectId);
13381
- for (const path8 of paths) {
13382
- const entries = this.cache.get(path8);
13390
+ for (const path10 of paths) {
13391
+ const entries = this.cache.get(path10);
13383
13392
  if (!entries)
13384
13393
  continue;
13385
13394
  for (let i = entries.length - 1; i >= 0; i--) {
@@ -13389,13 +13398,13 @@ var SourceFileCache = class {
13389
13398
  }
13390
13399
  }
13391
13400
  if (entries.length === 0) {
13392
- this.cache.delete(path8);
13401
+ this.cache.delete(path10);
13393
13402
  }
13394
13403
  }
13395
13404
  }
13396
13405
  this.snapshotProjectPaths.delete(snapshotId);
13397
13406
  }
13398
- trackPath(snapshotId, projectId, path8) {
13407
+ trackPath(snapshotId, projectId, path10) {
13399
13408
  let projectMap = this.snapshotProjectPaths.get(snapshotId);
13400
13409
  if (!projectMap) {
13401
13410
  projectMap = /* @__PURE__ */ new Map();
@@ -13406,7 +13415,7 @@ var SourceFileCache = class {
13406
13415
  paths = /* @__PURE__ */ new Set();
13407
13416
  projectMap.set(projectId, paths);
13408
13417
  }
13409
- paths.add(path8);
13418
+ paths.add(path10);
13410
13419
  }
13411
13420
  /**
13412
13421
  * Clear all entries from the cache.
@@ -13424,8 +13433,8 @@ var SourceFileCache = class {
13424
13433
  /**
13425
13434
  * Check if a path is in the cache.
13426
13435
  */
13427
- has(path8) {
13428
- return this.cache.has(path8);
13436
+ has(path10) {
13437
+ return this.cache.has(path10);
13429
13438
  }
13430
13439
  };
13431
13440
 
@@ -14208,8 +14217,8 @@ var Program = class {
14208
14217
  }
14209
14218
  async getSourceFile(file2) {
14210
14219
  const fileName = resolveFileName(file2);
14211
- const path8 = this.toPath(fileName);
14212
- const retained = this.sourceFileCache.getRetained(path8, this.snapshotId, this.project.id);
14220
+ const path10 = this.toPath(fileName);
14221
+ const retained = this.sourceFileCache.getRetained(path10, this.snapshotId, this.project.id);
14213
14222
  if (retained) {
14214
14223
  return retained;
14215
14224
  }
@@ -14225,7 +14234,7 @@ var Program = class {
14225
14234
  const contentHash = readSourceFileHash(view);
14226
14235
  const parseOptionsKey = readParseOptionsKey(view);
14227
14236
  const sourceFile = new RemoteSourceFile(binaryData, this.decoder, this.client.getTimingCollector());
14228
- return this.sourceFileCache.set(path8, sourceFile, parseOptionsKey, contentHash, this.snapshotId, this.project.id);
14237
+ return this.sourceFileCache.set(path10, sourceFile, parseOptionsKey, contentHash, this.snapshotId, this.project.id);
14229
14238
  }
14230
14239
  async getSourceFileNames() {
14231
14240
  const data = await this.client.apiRequest("getSourceFileNames", {
@@ -14248,19 +14257,19 @@ var Program = class {
14248
14257
  * the file name to path conversion. Metadata is fetched lazily per file and cached on
14249
14258
  * this `Program` instance.
14250
14259
  */
14251
- getSourceFileMetadataByPath(path8) {
14252
- let metadata = this.sourceFileMetadataCache.get(path8);
14260
+ getSourceFileMetadataByPath(path10) {
14261
+ let metadata = this.sourceFileMetadataCache.get(path10);
14253
14262
  if (metadata === void 0) {
14254
- metadata = this.fetchSourceFileMetadata(path8);
14255
- this.sourceFileMetadataCache.set(path8, metadata);
14263
+ metadata = this.fetchSourceFileMetadata(path10);
14264
+ this.sourceFileMetadataCache.set(path10, metadata);
14256
14265
  }
14257
14266
  return metadata;
14258
14267
  }
14259
- async fetchSourceFileMetadata(path8) {
14268
+ async fetchSourceFileMetadata(path10) {
14260
14269
  const data = await this.client.apiRequest("getSourceFileMetadata", {
14261
14270
  snapshot: this.snapshotId,
14262
14271
  project: this.project.id,
14263
- file: path8
14272
+ file: path10
14264
14273
  });
14265
14274
  return data ?? void 0;
14266
14275
  }
@@ -15485,26 +15494,94 @@ async function withMapCompiler(options, operation) {
15485
15494
  }
15486
15495
 
15487
15496
  // src/project-map-configuration.ts
15488
- import path5 from "node:path";
15497
+ import path6 from "node:path";
15489
15498
 
15490
15499
  // src/project-map-virtual-files.ts
15491
- import { readdirSync, readFileSync } from "node:fs";
15500
+ import { readdirSync as readdirSync2, readFileSync as readFileSync2, realpathSync as realpathSync2, statSync } from "node:fs";
15501
+ import path4 from "node:path";
15502
+
15503
+ // src/project-map-installed.ts
15504
+ import { existsSync, readdirSync, readFileSync, realpathSync } from "node:fs";
15505
+ import { isBuiltin } from "node:module";
15492
15506
  import path3 from "node:path";
15507
+
15508
+ // src/digest.ts
15509
+ import { createHash } from "node:crypto";
15510
+ var normalize = (value, seen) => {
15511
+ if (value === null || typeof value === "string" || typeof value === "boolean") return value;
15512
+ if (typeof value === "number") {
15513
+ if (!Number.isFinite(value))
15514
+ throw new TypeError("Canonical JSON values must contain finite numbers.");
15515
+ return Object.is(value, -0) ? 0 : value;
15516
+ }
15517
+ if (Array.isArray(value)) {
15518
+ if (seen.has(value)) throw new TypeError("Canonical JSON values must not contain cycles.");
15519
+ seen.add(value);
15520
+ const normalized = value.map((entry) => normalize(entry, seen));
15521
+ seen.delete(value);
15522
+ return normalized;
15523
+ }
15524
+ if (typeof value === "object") {
15525
+ if (seen.has(value)) throw new TypeError("Canonical JSON values must not contain cycles.");
15526
+ const prototype = Object.getPrototypeOf(value);
15527
+ if (prototype !== Object.prototype && prototype !== null) {
15528
+ throw new TypeError("Canonical JSON values must be plain JSON-compatible objects.");
15529
+ }
15530
+ seen.add(value);
15531
+ const normalized = {};
15532
+ for (const key2 of Object.keys(value).sort()) {
15533
+ const entry = value[key2];
15534
+ if (entry === void 0) {
15535
+ throw new TypeError("Canonical JSON values must not contain undefined fields.");
15536
+ }
15537
+ normalized[key2] = normalize(entry, seen);
15538
+ }
15539
+ seen.delete(value);
15540
+ return normalized;
15541
+ }
15542
+ throw new TypeError(`Canonical JSON values cannot contain ${typeof value}.`);
15543
+ };
15544
+ var canonicalJson = (value) => JSON.stringify(normalize(value, /* @__PURE__ */ new Set()));
15545
+ var digestValue = (value) => createHash("sha256").update(canonicalJson(value)).digest("hex");
15546
+
15547
+ // src/project-map-installed.ts
15548
+ var mapInNodeModules = (relative) => relative.split("/").includes("node_modules");
15549
+ var MAP_DEPENDENCY_NOT_INSTALLED = "DEPENDENCY_NOT_INSTALLED";
15550
+ function mapPackageOf(specifier) {
15551
+ if (isBuiltin(specifier)) return void 0;
15552
+ return /^(?:@[a-z0-9~][\w.~-]*\/)?[a-z0-9~][\w.~-]*(?=\/|$)/iu.exec(specifier)?.[0];
15553
+ }
15554
+ function mapMissingPackage(code, text2) {
15555
+ if (code !== 2307 && code !== 2792 && code !== 2688) return void 0;
15556
+ const named = /'([^']+)'/u.exec(text2)?.[1];
15557
+ return named ? mapPackageOf(named) : void 0;
15558
+ }
15559
+ function mapInstalledPath(realRoot, relative) {
15560
+ try {
15561
+ const real = realpathSync.native(path3.join(realRoot, relative));
15562
+ return real.startsWith(`${realRoot}${path3.sep}`) ? real : void 0;
15563
+ } catch {
15564
+ return void 0;
15565
+ }
15566
+ }
15567
+
15568
+ // src/project-map-virtual-files.ts
15493
15569
  var MAP_WORKSPACE = "/layermap/";
15494
15570
  var mapVirtualPath = (relative) => `${MAP_WORKSPACE}${relative}`;
15495
15571
  var mapRelativePath = (absolute) => absolute.startsWith(MAP_WORKSPACE) ? absolute.slice(MAP_WORKSPACE.length) : void 0;
15496
15572
  var mapForwardSlashes = (file2) => file2.replaceAll("\\", "/");
15573
+ var LIBRARY_FILE = /^lib(?:\.[a-z0-9_-]+)*\.d\.ts$/u;
15497
15574
  var MapVirtualFiles = class {
15498
15575
  constructor(input) {
15499
15576
  this.input = input;
15500
15577
  for (const [relative, text2] of Object.entries(input.files))
15501
15578
  this.files.set(mapVirtualPath(relative), text2);
15502
15579
  for (const relative of input.inventory) this.inventory.set(mapVirtualPath(relative), relative);
15503
- const libraryDirectory = path3.dirname(input.compilerPath);
15504
- for (const name of readdirSync(libraryDirectory)) {
15505
- if (!/^lib(?:\.[a-z0-9_-]+)*\.d\.ts$/u.test(name)) continue;
15506
- const text2 = readFileSync(path3.join(libraryDirectory, name), "utf8");
15507
- this.files.set(mapForwardSlashes(path3.join(libraryDirectory, name)), text2);
15580
+ const libraryDirectory = path4.dirname(realpathSync2.native(input.compilerPath));
15581
+ for (const name of readdirSync2(libraryDirectory)) {
15582
+ if (!LIBRARY_FILE.test(name)) continue;
15583
+ const text2 = readFileSync2(path4.join(libraryDirectory, name), "utf8");
15584
+ this.files.set(mapForwardSlashes(path4.join(libraryDirectory, name)), text2);
15508
15585
  }
15509
15586
  for (const file2 of /* @__PURE__ */ new Set([...this.files.keys(), ...this.inventory.keys()]))
15510
15587
  this.addPath(file2);
@@ -15513,10 +15590,13 @@ var MapVirtualFiles = class {
15513
15590
  required = /* @__PURE__ */ new Set();
15514
15591
  readInputs = /* @__PURE__ */ new Set();
15515
15592
  configurations = /* @__PURE__ */ new Set();
15593
+ // The compiler asked for a standard library file that is not there. It reports no error for one.
15594
+ libraryMissing = false;
15516
15595
  files = /* @__PURE__ */ new Map();
15517
15596
  inventory = /* @__PURE__ */ new Map();
15518
15597
  directories = /* @__PURE__ */ new Map();
15519
15598
  aliases = /* @__PURE__ */ new Map();
15599
+ hostPaths = /* @__PURE__ */ new Map();
15520
15600
  set(relative, text2) {
15521
15601
  this.files.set(mapVirtualPath(relative), text2);
15522
15602
  this.addPath(mapVirtualPath(relative));
@@ -15551,7 +15631,23 @@ var MapVirtualFiles = class {
15551
15631
  child = parent;
15552
15632
  }
15553
15633
  }
15554
- // Every miss is explicit. The compiler cannot fall back to the host filesystem.
15634
+ get realRoot() {
15635
+ const value = this.input.dependencies === void 0 ? void 0 : realpathSync2.native(this.input.dependencies);
15636
+ Object.defineProperty(this, "realRoot", { value });
15637
+ return value;
15638
+ }
15639
+ // Where an installed package's file or directory really is. A link out of the project is a miss.
15640
+ installed(file2) {
15641
+ const relative = mapRelativePath(file2);
15642
+ const root = this.realRoot;
15643
+ if (relative === void 0 || root === void 0 || !mapInNodeModules(relative))
15644
+ return void 0;
15645
+ if (!this.hostPaths.has(relative))
15646
+ this.hostPaths.set(relative, mapInstalledPath(root, relative));
15647
+ return this.hostPaths.get(relative);
15648
+ }
15649
+ // Every miss is explicit. The compiler falls back to the host filesystem for the packages the
15650
+ // project has installed and for nothing else, and reads only what it needs to resolve types.
15555
15651
  fs = {
15556
15652
  readFile: (file2) => {
15557
15653
  file2 = this.canonical(file2);
@@ -15564,23 +15660,54 @@ var MapVirtualFiles = class {
15564
15660
  this.required.add(relative);
15565
15661
  return "";
15566
15662
  }
15663
+ const host = this.installed(file2);
15664
+ if (host && statSync(host, { throwIfNoEntry: false })?.isFile())
15665
+ return readFileSync2(host, "utf8");
15666
+ if (mapRelativePath(file2) === void 0 && LIBRARY_FILE.test(path4.posix.basename(file2)))
15667
+ this.libraryMissing = true;
15567
15668
  return null;
15568
15669
  },
15569
15670
  fileExists: (file2) => {
15570
15671
  file2 = this.canonical(file2);
15571
- return this.files.has(file2) || this.inventory.has(file2);
15672
+ if (this.files.has(file2) || this.inventory.has(file2)) return true;
15673
+ const host = this.installed(file2);
15674
+ return host !== void 0 && statSync(host, { throwIfNoEntry: false })?.isFile() === true;
15675
+ },
15676
+ directoryExists: (directory) => {
15677
+ directory = this.canonical(directory);
15678
+ if (this.directories.has(directory)) return true;
15679
+ const host = this.installed(directory);
15680
+ return host !== void 0 && statSync(host, { throwIfNoEntry: false })?.isDirectory() === true;
15681
+ },
15682
+ realpath: (file2) => {
15683
+ file2 = this.canonical(file2);
15684
+ const host = this.installed(file2);
15685
+ const root = this.realRoot;
15686
+ if (!host || root === void 0) return file2;
15687
+ const real = mapForwardSlashes(path4.relative(root, host));
15688
+ return mapInNodeModules(real) ? mapVirtualPath(real) : file2;
15572
15689
  },
15573
- directoryExists: (directory) => this.directories.has(this.canonical(directory)),
15574
- realpath: (file2) => this.canonical(file2),
15575
15690
  getAccessibleEntries: (directory) => {
15576
- const entry = this.directories.get(this.canonical(directory));
15577
- return { files: [...entry?.files ?? []], directories: [...entry?.directories ?? []] };
15691
+ directory = this.canonical(directory);
15692
+ const entry = this.directories.get(directory);
15693
+ const files = new Set(entry?.files);
15694
+ const directories = new Set(entry?.directories);
15695
+ const host = this.installed(directory);
15696
+ const stat = host ? statSync(host, { throwIfNoEntry: false }) : void 0;
15697
+ if (host && stat?.isDirectory())
15698
+ for (const name of readdirSync2(host)) {
15699
+ const inner = this.installed(`${directory}/${name}`);
15700
+ const kind = inner ? statSync(inner, { throwIfNoEntry: false }) : void 0;
15701
+ if (kind?.isDirectory()) directories.add(name);
15702
+ else if (kind?.isFile()) files.add(name);
15703
+ }
15704
+ return { files: [...files], directories: [...directories] };
15578
15705
  }
15579
15706
  };
15580
15707
  };
15581
15708
 
15582
15709
  // src/project-map-workspace-membership.ts
15583
- import path4 from "node:path";
15710
+ import path5 from "node:path";
15584
15711
  function pnpmPackages(text2) {
15585
15712
  const lines = text2.replace(/^\uFEFF/u, "").split(/\r?\n/u).filter((line) => line.trim() && !line.trimStart().startsWith("#"));
15586
15713
  if (!/^packages:\s*(?:#.*)?$/u.test(lines[0] ?? "")) return void 0;
@@ -15615,7 +15742,7 @@ function mapWorkspaceMembership(files) {
15615
15742
  }
15616
15743
  }
15617
15744
  const valid = Array.isArray(patterns) && patterns.every(
15618
- (entry) => typeof entry === "string" && entry.length > 0 && !path4.posix.isAbsolute(entry.replace(/^!/u, "")) && !entry.split("/").some((segment) => segment === "..")
15745
+ (entry) => typeof entry === "string" && entry.length > 0 && !path5.posix.isAbsolute(entry.replace(/^!/u, "")) && !entry.split("/").some((segment) => segment === "..")
15619
15746
  );
15620
15747
  const accepted = valid ? patterns : [];
15621
15748
  const code = valid ? void 0 : pnpm !== void 0 ? "WORKSPACE_CONFIGURATION_UNSUPPORTED" : "WORKSPACE_MEMBERSHIP_NOT_ADMITTED";
@@ -15623,9 +15750,9 @@ function mapWorkspaceMembership(files) {
15623
15750
  configurationFiles,
15624
15751
  code,
15625
15752
  contains: (directory) => accepted.some(
15626
- (pattern) => !pattern.startsWith("!") && path4.posix.matchesGlob(directory, pattern)
15753
+ (pattern) => !pattern.startsWith("!") && path5.posix.matchesGlob(directory, pattern)
15627
15754
  ) && !accepted.some(
15628
- (pattern) => pattern.startsWith("!") && path4.posix.matchesGlob(directory, pattern.slice(1))
15755
+ (pattern) => pattern.startsWith("!") && path5.posix.matchesGlob(directory, pattern.slice(1))
15629
15756
  )
15630
15757
  };
15631
15758
  }
@@ -15670,7 +15797,7 @@ async function discoverMapConfiguration(api, files) {
15670
15797
  issues.add(membership.code);
15671
15798
  continue;
15672
15799
  }
15673
- if (!membership.contains(path5.posix.dirname(definition.path)) && definition.path !== "package.json")
15800
+ if (!membership.contains(path6.posix.dirname(definition.path)) && definition.path !== "package.json")
15674
15801
  continue;
15675
15802
  const targets = manifests.get(name);
15676
15803
  if (targets?.length !== 1) {
@@ -15679,13 +15806,13 @@ async function discoverMapConfiguration(api, files) {
15679
15806
  }
15680
15807
  const target = targets[0];
15681
15808
  if (!target) continue;
15682
- if (!membership.contains(path5.posix.dirname(target.path))) {
15809
+ if (!membership.contains(path6.posix.dirname(target.path))) {
15683
15810
  issues.add("WORKSPACE_DEPENDENCY_TARGET_NOT_AVAILABLE");
15684
15811
  continue;
15685
15812
  }
15686
15813
  links.push({
15687
- from: path5.posix.join(path5.posix.dirname(definition.path), "node_modules", name),
15688
- to: path5.posix.dirname(target.path)
15814
+ from: path6.posix.join(path6.posix.dirname(definition.path), "node_modules", name),
15815
+ to: path6.posix.dirname(target.path)
15689
15816
  });
15690
15817
  }
15691
15818
  }
@@ -15703,10 +15830,10 @@ async function discoverMapConfiguration(api, files) {
15703
15830
  continue;
15704
15831
  const relative = mapRelativePath(source);
15705
15832
  if (!relative || !files.input.inventory.includes(relative)) continue;
15706
- const stem = path5.posix.join(outDir, source.slice(rootDir.length + 1)).replace(/\.[cm]?tsx?$/u, "");
15833
+ const stem = path6.posix.join(outDir, source.slice(rootDir.length + 1)).replace(/\.[cm]?tsx?$/u, "");
15707
15834
  const extensions = source.endsWith(".mts") ? [".mjs", ".d.mts"] : source.endsWith(".cts") ? [".cjs", ".d.cts"] : [source.endsWith(".tsx") && parsed.options.jsx === 1 ? ".jsx" : ".js", ".d.ts"];
15708
15835
  for (const extension of extensions) {
15709
- const location = extension.startsWith(".d.") && typeof declarationDir === "string" ? path5.posix.join(declarationDir, source.slice(rootDir.length + 1)).replace(/\.[cm]?tsx?$/u, "") : stem;
15836
+ const location = extension.startsWith(".d.") && typeof declarationDir === "string" ? path6.posix.join(declarationDir, source.slice(rootDir.length + 1)).replace(/\.[cm]?tsx?$/u, "") : stem;
15710
15837
  const output = mapRelativePath(location + extension);
15711
15838
  if (!output) continue;
15712
15839
  const into = outputs.get(output);
@@ -15722,7 +15849,7 @@ async function discoverMapConfiguration(api, files) {
15722
15849
  if (!manifest) continue;
15723
15850
  const visit = (value) => {
15724
15851
  if (typeof value === "string" && value.startsWith("./")) {
15725
- const output = path5.posix.join(path5.posix.dirname(manifest.path), value);
15852
+ const output = path6.posix.join(path6.posix.dirname(manifest.path), value);
15726
15853
  const candidates = outputs.get(output) ?? [];
15727
15854
  const sources = new Set(candidates.map((candidate2) => candidate2.source));
15728
15855
  const candidate = candidates[0];
@@ -15796,8 +15923,8 @@ function applyMapWorkspaceContents(files, workspace) {
15796
15923
  );
15797
15924
  const rewrite = (entry) => {
15798
15925
  if (typeof entry === "string" && entry.startsWith("./")) {
15799
- const source = replacements.get(path5.posix.join(path5.posix.dirname(manifest), entry));
15800
- return source ? `./${path5.posix.relative(path5.posix.dirname(manifest), source)}` : entry;
15926
+ const source = replacements.get(path6.posix.join(path6.posix.dirname(manifest), entry));
15927
+ return source ? `./${path6.posix.relative(path6.posix.dirname(manifest), source)}` : entry;
15801
15928
  }
15802
15929
  if (Array.isArray(entry)) return entry.map(rewrite);
15803
15930
  if (entry && typeof entry === "object")
@@ -15813,45 +15940,6 @@ function applyMapWorkspaceContents(files, workspace) {
15813
15940
  for (const config2 of workspace.configurationFiles) files.configurations.add(config2);
15814
15941
  }
15815
15942
 
15816
- // src/digest.ts
15817
- import { createHash } from "node:crypto";
15818
- var normalize = (value, seen) => {
15819
- if (value === null || typeof value === "string" || typeof value === "boolean") return value;
15820
- if (typeof value === "number") {
15821
- if (!Number.isFinite(value))
15822
- throw new TypeError("Canonical JSON values must contain finite numbers.");
15823
- return Object.is(value, -0) ? 0 : value;
15824
- }
15825
- if (Array.isArray(value)) {
15826
- if (seen.has(value)) throw new TypeError("Canonical JSON values must not contain cycles.");
15827
- seen.add(value);
15828
- const normalized = value.map((entry) => normalize(entry, seen));
15829
- seen.delete(value);
15830
- return normalized;
15831
- }
15832
- if (typeof value === "object") {
15833
- if (seen.has(value)) throw new TypeError("Canonical JSON values must not contain cycles.");
15834
- const prototype = Object.getPrototypeOf(value);
15835
- if (prototype !== Object.prototype && prototype !== null) {
15836
- throw new TypeError("Canonical JSON values must be plain JSON-compatible objects.");
15837
- }
15838
- seen.add(value);
15839
- const normalized = {};
15840
- for (const key2 of Object.keys(value).sort()) {
15841
- const entry = value[key2];
15842
- if (entry === void 0) {
15843
- throw new TypeError("Canonical JSON values must not contain undefined fields.");
15844
- }
15845
- normalized[key2] = normalize(entry, seen);
15846
- }
15847
- seen.delete(value);
15848
- return normalized;
15849
- }
15850
- throw new TypeError(`Canonical JSON values cannot contain ${typeof value}.`);
15851
- };
15852
- var canonicalJson = (value) => JSON.stringify(normalize(value, /* @__PURE__ */ new Set()));
15853
- var digestValue = (value) => createHash("sha256").update(canonicalJson(value)).digest("hex");
15854
-
15855
15943
  // src/project-map-context.ts
15856
15944
  function mapParsingContext(project, input) {
15857
15945
  return {
@@ -16056,15 +16144,15 @@ function mapChildExecutionOwner(node, child, scope, enclosing, declarationExecut
16056
16144
  }
16057
16145
 
16058
16146
  // src/project-map-miniprogram.ts
16059
- import path6 from "node:path";
16147
+ import path7 from "node:path";
16060
16148
  var templateOf = (script) => script.replace(/\.[cm]?[jt]sx?$/u, ".wxml");
16061
16149
  var miniprogramTemplateOf = (script, inventory) => /\.[cm]?[jt]sx?$/u.test(script) && inventory.has(templateOf(script)) ? templateOf(script) : void 0;
16062
16150
  function miniprogramConfiguration(template, inventory) {
16063
16151
  const own = template.replace(/\.wxml$/u, ".json");
16064
16152
  const configuration2 = inventory.has(own) ? { own } : {};
16065
- for (let directory = path6.posix.dirname(template); ; directory = path6.posix.dirname(directory)) {
16153
+ for (let directory = path7.posix.dirname(template); ; directory = path7.posix.dirname(directory)) {
16066
16154
  const root = directory === "." ? "" : directory;
16067
- const app = path6.posix.join(root, "app.json");
16155
+ const app = path7.posix.join(root, "app.json");
16068
16156
  if (inventory.has(app)) return { ...configuration2, app, root };
16069
16157
  if (!root) return configuration2;
16070
16158
  }
@@ -16225,10 +16313,10 @@ var usingComponents = (text2) => {
16225
16313
  };
16226
16314
  function componentTemplate(value, registeredIn, root, inventory) {
16227
16315
  if (/^plugin(?:-private)?:\/\//u.test(value)) return void 0;
16228
- const from = (base) => path6.posix.normalize(path6.posix.join(base || ".", value));
16316
+ const from = (base) => path7.posix.normalize(path7.posix.join(base || ".", value));
16229
16317
  const bases = value.startsWith("/") ? root !== void 0 ? [from(root)] : [] : [
16230
- from(path6.posix.dirname(registeredIn)),
16231
- ...root !== void 0 ? [from(root), from(path6.posix.join(root, "miniprogram_npm"))] : []
16318
+ from(path7.posix.dirname(registeredIn)),
16319
+ ...root !== void 0 ? [from(root), from(path7.posix.join(root, "miniprogram_npm"))] : []
16232
16320
  ];
16233
16321
  for (const base of bases)
16234
16322
  for (const candidate of [`${base}.wxml`, `${base}/index.wxml`])
@@ -16307,6 +16395,7 @@ function linkMiniprogramTemplates(scripts, context) {
16307
16395
  kind: "CALLS",
16308
16396
  anchor: emit.anchor,
16309
16397
  target: target.name,
16398
+ event: binding.event,
16310
16399
  basis: "SYNTAX_DECLARED"
16311
16400
  });
16312
16401
  }
@@ -16486,8 +16575,8 @@ var pathText = (node) => {
16486
16575
  };
16487
16576
  var isFunction = (node) => node.kind === SyntaxKind.ArrowFunction || node.kind === SyntaxKind.FunctionExpression;
16488
16577
  var isDeclaration = (node) => node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.SourceFile;
16489
- function joinRoute(prefix, path8) {
16490
- const joined = !prefix ? path8 : !path8 ? prefix : `${prefix.replace(/\/+$/u, "")}/${path8.replace(/^\/+/u, "")}`;
16578
+ function joinRoute(prefix, path10) {
16579
+ const joined = !prefix ? path10 : !path10 ? prefix : `${prefix.replace(/\/+$/u, "")}/${path10.replace(/^\/+/u, "")}`;
16491
16580
  return joined.startsWith("/") || joined.startsWith("$") ? joined : `/${joined}`;
16492
16581
  }
16493
16582
  var httpMethod = (name) => HTTP_METHODS.has(name.toUpperCase()) ? name.toUpperCase() : void 0;
@@ -16505,25 +16594,25 @@ function registeredRoute(node, kind) {
16505
16594
  function routeOf(call, index) {
16506
16595
  const callee = call.expression;
16507
16596
  const name = isPropertyAccessExpression(callee) ? callee.name.text : void 0;
16508
- let path8;
16597
+ let path10;
16509
16598
  let receiver = isPropertyAccessExpression(callee) ? callee.expression : void 0;
16510
16599
  const at = call.arguments.findIndex((argument) => pathText(argument) !== void 0);
16511
16600
  if (at >= 0) {
16512
16601
  if (index <= at) return void 0;
16513
- path8 = pathText(call.arguments[at]);
16602
+ path10 = pathText(call.arguments[at]);
16514
16603
  } else if (name && httpMethod(name) && receiver && isCallExpression(receiver) && isPropertyAccessExpression(receiver.expression) && receiver.arguments.length === 1) {
16515
- path8 = pathText(receiver.arguments[0]);
16604
+ path10 = pathText(receiver.arguments[0]);
16516
16605
  receiver = receiver.expression.expression;
16517
16606
  }
16518
- if (path8 === void 0) return void 0;
16607
+ if (path10 === void 0) return void 0;
16519
16608
  let method;
16520
- const space = path8.indexOf(" ");
16521
- if (space > 0) [method, path8] = [path8.slice(0, space), path8.slice(space).trimStart()];
16609
+ const space = path10.indexOf(" ");
16610
+ if (space > 0) [method, path10] = [path10.slice(0, space), path10.slice(space).trimStart()];
16522
16611
  method ??= name ? httpMethod(name) : void 0;
16523
- if (path8 === "/" && !method) return void 0;
16524
- const full = joinRoute(receiver ? routerPrefix(receiver, 0) : "", path8);
16612
+ if (path10 === "/" && !method) return void 0;
16613
+ const full = joinRoute(receiver ? routerPrefix(receiver, 0) : "", path10);
16525
16614
  const label = method ? `${method} ${full}` : full;
16526
- return label.length <= 256 ? { label, ...method ? { method } : {} } : { label: path8 };
16615
+ return label.length <= 256 ? { label, ...method ? { method } : {} } : { label: path10 };
16527
16616
  }
16528
16617
  function routerPrefix(expression, depth) {
16529
16618
  if (depth > 8) return "";
@@ -16531,8 +16620,8 @@ function routerPrefix(expression, depth) {
16531
16620
  const callee = expression.expression;
16532
16621
  if (!isPropertyAccessExpression(callee)) return "";
16533
16622
  const base = routerPrefix(callee.expression, depth + 1);
16534
- const path8 = expression.arguments.length === 1 ? pathText(expression.arguments[0]) : void 0;
16535
- return path8 === void 0 || path8.includes(" ") ? base : joinRoute(base, path8);
16623
+ const path10 = expression.arguments.length === 1 ? pathText(expression.arguments[0]) : void 0;
16624
+ return path10 === void 0 || path10.includes(" ") ? base : joinRoute(base, path10);
16536
16625
  }
16537
16626
  if (isIdentifier(expression)) {
16538
16627
  const declaration = constDeclaration(expression);
@@ -16574,8 +16663,8 @@ function decoratorRoute(decorator, argument) {
16574
16663
  break;
16575
16664
  }
16576
16665
  }
16577
- const path8 = argument ?? (call && text(call.arguments[0])) ?? "";
16578
- const route = `${method} ${joinRoute(prefix, path8)}`;
16666
+ const path10 = argument ?? (call && text(call.arguments[0])) ?? "";
16667
+ const route = `${method} ${joinRoute(prefix, path10)}`;
16579
16668
  return route.length <= 256 ? route : void 0;
16580
16669
  }
16581
16670
 
@@ -17416,10 +17505,10 @@ function mergeDefs(...defs) {
17416
17505
  function cloneDef(schema) {
17417
17506
  return mergeDefs(schema._zod.def);
17418
17507
  }
17419
- function getElementAtPath(obj, path8) {
17420
- if (!path8)
17508
+ function getElementAtPath(obj, path10) {
17509
+ if (!path10)
17421
17510
  return obj;
17422
- return path8.reduce((acc, key2) => acc?.[key2], obj);
17511
+ return path10.reduce((acc, key2) => acc?.[key2], obj);
17423
17512
  }
17424
17513
  function promiseAllObject(promisesObj) {
17425
17514
  const keys = Object.keys(promisesObj);
@@ -17828,11 +17917,11 @@ function explicitlyAborted(x, startIndex = 0) {
17828
17917
  }
17829
17918
  return false;
17830
17919
  }
17831
- function prefixIssues(path8, issues) {
17920
+ function prefixIssues(path10, issues) {
17832
17921
  return issues.map((iss) => {
17833
17922
  var _a3;
17834
17923
  (_a3 = iss).path ?? (_a3.path = []);
17835
- iss.path.unshift(path8);
17924
+ iss.path.unshift(path10);
17836
17925
  return iss;
17837
17926
  });
17838
17927
  }
@@ -17979,16 +18068,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
17979
18068
  }
17980
18069
  function formatError(error51, mapper = (issue2) => issue2.message) {
17981
18070
  const fieldErrors = { _errors: [] };
17982
- const processError = (error52, path8 = []) => {
18071
+ const processError = (error52, path10 = []) => {
17983
18072
  for (const issue2 of error52.issues) {
17984
18073
  if (issue2.code === "invalid_union" && issue2.errors.length) {
17985
- issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
18074
+ issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
17986
18075
  } else if (issue2.code === "invalid_key") {
17987
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
18076
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
17988
18077
  } else if (issue2.code === "invalid_element") {
17989
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
18078
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
17990
18079
  } else {
17991
- const fullpath = [...path8, ...issue2.path];
18080
+ const fullpath = [...path10, ...issue2.path];
17992
18081
  if (fullpath.length === 0) {
17993
18082
  fieldErrors._errors.push(mapper(issue2));
17994
18083
  } else {
@@ -18015,17 +18104,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
18015
18104
  }
18016
18105
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
18017
18106
  const result = { errors: [] };
18018
- const processError = (error52, path8 = []) => {
18107
+ const processError = (error52, path10 = []) => {
18019
18108
  var _a3, _b;
18020
18109
  for (const issue2 of error52.issues) {
18021
18110
  if (issue2.code === "invalid_union" && issue2.errors.length) {
18022
- issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
18111
+ issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
18023
18112
  } else if (issue2.code === "invalid_key") {
18024
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
18113
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
18025
18114
  } else if (issue2.code === "invalid_element") {
18026
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
18115
+ processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
18027
18116
  } else {
18028
- const fullpath = [...path8, ...issue2.path];
18117
+ const fullpath = [...path10, ...issue2.path];
18029
18118
  if (fullpath.length === 0) {
18030
18119
  result.errors.push(mapper(issue2));
18031
18120
  continue;
@@ -18057,8 +18146,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
18057
18146
  }
18058
18147
  function toDotPath(_path) {
18059
18148
  const segs = [];
18060
- const path8 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
18061
- for (const seg of path8) {
18149
+ const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
18150
+ for (const seg of path10) {
18062
18151
  if (typeof seg === "number")
18063
18152
  segs.push(`[${seg}]`);
18064
18153
  else if (typeof seg === "symbol")
@@ -30750,13 +30839,13 @@ function resolveRef(ref, ctx) {
30750
30839
  if (!ref.startsWith("#")) {
30751
30840
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
30752
30841
  }
30753
- const path8 = ref.slice(1).split("/").filter(Boolean);
30754
- if (path8.length === 0) {
30842
+ const path10 = ref.slice(1).split("/").filter(Boolean);
30843
+ if (path10.length === 0) {
30755
30844
  return ctx.rootSchema;
30756
30845
  }
30757
30846
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
30758
- if (path8[0] === defsKey) {
30759
- const key2 = path8[1];
30847
+ if (path10[0] === defsKey) {
30848
+ const key2 = path10[1];
30760
30849
  if (!key2 || !ctx.defs[key2]) {
30761
30850
  throw new Error(`Reference not found: ${ref}`);
30762
30851
  }
@@ -31280,6 +31369,9 @@ var MapRelationSchema = external_exports.object({
31280
31369
  // The full route a decorator registers its declaration under, when it says more than the
31281
31370
  // argument: the HTTP methods, then the class's path joined with the member's.
31282
31371
  route: external_exports.string().min(1).max(256).optional(),
31372
+ // The event a component emits to the handler a template binds to it. The handler runs only
31373
+ // where that template is, which the template's own relation to it says.
31374
+ event: external_exports.string().min(1).max(256).optional(),
31283
31375
  basis: external_exports.enum(["TYPE_RESOLVED", "SYNTAX_DECLARED", "UNRESOLVED"]),
31284
31376
  unresolvedReason: external_exports.enum([
31285
31377
  "SYNTAX_ONLY",
@@ -31313,7 +31405,9 @@ var MapNoteSchema = external_exports.object({
31313
31405
  var MapGapSchema = external_exports.object({
31314
31406
  code: external_exports.string().min(1).max(128),
31315
31407
  path: external_exports.string().optional(),
31316
- count: external_exports.number().int().positive().optional()
31408
+ count: external_exports.number().int().positive().optional(),
31409
+ // The package a gap is about, such as one the code imports that is not installed.
31410
+ package: external_exports.string().min(1).max(256).optional()
31317
31411
  }).strict();
31318
31412
  var MapSearchRankingSignalSchema = external_exports.enum([
31319
31413
  "EXACT_SYMBOL",
@@ -31379,6 +31473,7 @@ function isMapWrite(node) {
31379
31473
 
31380
31474
  // src/project-map-extract.ts
31381
31475
  var key = (node) => `${node.getSourceFile().fileName}:${node.pos}:${node.kind}`;
31476
+ var IMPORT_RELATIONS = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
31382
31477
  var declares = (node) => Boolean(mapExecutionDeclaration(node) || mapDeclarationKind(node, true) && mapDeclarationName(node));
31383
31478
  var declarationName = (node) => {
31384
31479
  const execution = mapExecutionDeclaration(node);
@@ -31386,7 +31481,6 @@ var declarationName = (node) => {
31386
31481
  return execution?.name ?? (name ? mapNodeLabel(name) : "");
31387
31482
  };
31388
31483
  var NOT_STATE_READS = /* @__PURE__ */ new Set([
31389
- SyntaxKind.PropertyAssignment,
31390
31484
  SyntaxKind.ImportClause,
31391
31485
  SyntaxKind.ExportSpecifier,
31392
31486
  SyntaxKind.TypeReference,
@@ -31415,7 +31509,7 @@ function moduleStateNames(file2) {
31415
31509
  }
31416
31510
  return { names, namespaces };
31417
31511
  }
31418
- async function extractProjectMap(project, input, trace, read) {
31512
+ async function extractProjectMap(project, input, trace, read, installed) {
31419
31513
  const output = {
31420
31514
  contexts: [],
31421
31515
  objects: [],
@@ -31423,7 +31517,6 @@ async function extractProjectMap(project, input, trace, read) {
31423
31517
  notes: [],
31424
31518
  gaps: [
31425
31519
  ...!input.configPath ? [{ code: "NO_ADMITTED_TSCONFIG" }] : [],
31426
- { code: "EXTERNAL_DEPENDENCIES_NOT_LOADED" },
31427
31520
  { code: "DYNAMIC_AND_FRAMEWORK_LINKS_REQUIRE_SOURCE_INVESTIGATION" },
31428
31521
  { code: "UNMODELED_LANGUAGE_CONSTRUCTS_REQUIRE_SOURCE_INVESTIGATION" },
31429
31522
  { code: "DETAILED_REFERENCES_AVAILABLE_ON_DEMAND" },
@@ -31487,8 +31580,8 @@ async function extractProjectMap(project, input, trace, read) {
31487
31580
  identities.set(key(node), value);
31488
31581
  return value;
31489
31582
  };
31490
- const gap = (code, path8) => {
31491
- output.gaps.push({ code, ...path8 ? { path: path8 } : {} });
31583
+ const gap = (code, path10) => {
31584
+ output.gaps.push({ code, ...path10 ? { path: path10 } : {} });
31492
31585
  };
31493
31586
  const addObject = (node, file2, kind, name) => {
31494
31587
  const location = anchor(node, file2);
@@ -31516,19 +31609,19 @@ async function extractProjectMap(project, input, trace, read) {
31516
31609
  return object2;
31517
31610
  };
31518
31611
  trace.phase = "SOURCE_FILES";
31519
- for await (const { file: file2, path: path8, syntaxErrors, exports } of mapSourceFiles(project, input, trace)) {
31612
+ for await (const { file: file2, path: path10, syntaxErrors, exports } of mapSourceFiles(project, input, trace)) {
31520
31613
  if (!file2) {
31521
- gap("SOURCE_NOT_PARSED", path8);
31614
+ gap("SOURCE_NOT_PARSED", path10);
31522
31615
  continue;
31523
31616
  }
31524
31617
  if (syntaxErrors) {
31525
- gap("SYNTAX_ERROR", path8);
31618
+ gap("SYNTAX_ERROR", path10);
31526
31619
  continue;
31527
31620
  }
31528
- output.parsedFiles.push(path8);
31529
- const fileObject = addObject(file2, file2, "FILE", path8);
31530
- if (!owned.has(path8)) continue;
31531
- const template = miniprogramTemplateOf(path8, inventory);
31621
+ output.parsedFiles.push(path10);
31622
+ const fileObject = addObject(file2, file2, "FILE", path10);
31623
+ if (!owned.has(path10)) continue;
31624
+ const template = miniprogramTemplateOf(path10, inventory);
31532
31625
  if (template) pages.push({ file: file2, template });
31533
31626
  exportedSymbols.set(file2.fileName, exports);
31534
31627
  const state = moduleStateNames(file2);
@@ -31556,7 +31649,7 @@ async function extractProjectMap(project, input, trace, read) {
31556
31649
  executionDeclaration?.kind ?? kind,
31557
31650
  executionDeclaration?.name ?? mapNodeLabel(name)
31558
31651
  );
31559
- if (owned.has(path8))
31652
+ if (owned.has(path10))
31560
31653
  collect.relation({
31561
31654
  from: owner.id,
31562
31655
  to: object2.id,
@@ -31565,11 +31658,11 @@ async function extractProjectMap(project, input, trace, read) {
31565
31658
  target: object2.name,
31566
31659
  basis: "SYNTAX_DECLARED"
31567
31660
  });
31568
- if (owned.has(path8) && name) declarations.push({ object: object2, name, node, file: file2 });
31661
+ if (owned.has(path10) && name) declarations.push({ object: object2, name, node, file: file2 });
31569
31662
  if (object2.kind === "VARIABLE" && !object2.execution && item.owner.kind === "FILE")
31570
31663
  moduleVariables.add(object2.id);
31571
31664
  owner = object2;
31572
- if (kind === "INTERFACE" && owned.has(path8)) {
31665
+ if (kind === "INTERFACE" && owned.has(path10)) {
31573
31666
  const note = {
31574
31667
  entityRef: object2.id,
31575
31668
  kind: "CONTRACT_DECLARATION",
@@ -31586,7 +31679,7 @@ async function extractProjectMap(project, input, trace, read) {
31586
31679
  reference = {
31587
31680
  node,
31588
31681
  lookup: moduleSpecifier,
31589
- kind: /(?:^|[/.])(?:test|spec|tests)(?:[/.]|$)/u.test(path8) ? "TEST_IMPORTS" : "IMPORTS",
31682
+ kind: /(?:^|[/.])(?:test|spec|tests)(?:[/.]|$)/u.test(path10) ? "TEST_IMPORTS" : "IMPORTS",
31590
31683
  target: moduleSpecifier.text
31591
31684
  };
31592
31685
  } else if (isCallExpression(node) || isNewExpression(node)) {
@@ -31668,7 +31761,8 @@ async function extractProjectMap(project, input, trace, read) {
31668
31761
  lookup: node.name,
31669
31762
  kind: "REFERENCES",
31670
31763
  target: mapNodeLabel(node.name),
31671
- holder: node
31764
+ holder: node,
31765
+ ...isIdentifier(node.name) && state.names.has(node.name.text) ? { readsState: true } : {}
31672
31766
  };
31673
31767
  } else if (isImportSpecifier(node)) {
31674
31768
  valueNames.add(node.name.text);
@@ -31689,7 +31783,7 @@ async function extractProjectMap(project, input, trace, read) {
31689
31783
  }
31690
31784
  if (isObjectLiteralExpression(node) || (isClassDeclaration(node) || node.kind === SyntaxKind.ClassExpression || isInterfaceDeclaration(node)) && node.heritageClauses?.length)
31691
31785
  contracts.push(node);
31692
- if (reference && owned.has(path8)) {
31786
+ if (reference && owned.has(path10)) {
31693
31787
  pending.push({
31694
31788
  ...reference,
31695
31789
  owner: ["CALLS", "WRITES"].includes(reference.kind) ? item.execution.id : owner.id,
@@ -31757,8 +31851,8 @@ async function extractProjectMap(project, input, trace, read) {
31757
31851
  const kind = mapDeclarationKind(node, true);
31758
31852
  const executionDeclaration = mapExecutionDeclaration(node);
31759
31853
  const file2 = node.getSourceFile();
31760
- const path8 = mapRelativePath(file2.fileName);
31761
- if (!executionDeclaration && (!name || !kind) || !path8 || !Object.hasOwn(input.files, path8))
31854
+ const path10 = mapRelativePath(file2.fileName);
31855
+ if (!executionDeclaration && (!name || !kind) || !path10 || !Object.hasOwn(input.files, path10))
31762
31856
  return void 0;
31763
31857
  const object2 = addObject(
31764
31858
  node,
@@ -31770,7 +31864,7 @@ async function extractProjectMap(project, input, trace, read) {
31770
31864
  while (parent && !declared.has(key(parent)) && !(mapDeclarationKind(parent) && mapDeclarationName(parent)) && !mapExecutionDeclaration(parent))
31771
31865
  parent = parent.parent;
31772
31866
  const owner = parent ? materialize(parent) : void 0;
31773
- if (owner && owned.has(path8))
31867
+ if (owner && owned.has(path10))
31774
31868
  collect.relation({
31775
31869
  from: owner.id,
31776
31870
  to: object2.id,
@@ -31835,7 +31929,7 @@ async function extractProjectMap(project, input, trace, read) {
31835
31929
  contextRef: input.contextRef,
31836
31930
  inventory,
31837
31931
  read,
31838
- span: (path8, start, end) => positions.span(path8, start, end),
31932
+ span: (path10, start, end) => positions.span(path10, start, end),
31839
31933
  materialize,
31840
31934
  composed
31841
31935
  });
@@ -31859,8 +31953,8 @@ async function extractProjectMap(project, input, trace, read) {
31859
31953
  const symbols = await project.checker.getSymbolAtLocation(batch.map((item) => item.lookup));
31860
31954
  trace.phase = "RELATION_TARGETS";
31861
31955
  for (const [index, item] of batch.entries()) {
31862
- const readState = async () => {
31863
- for (const destination of await targets.resolveMapped(symbols[index], moduleVariable)) {
31956
+ const readState = async (symbol2 = symbols[index]) => {
31957
+ for (const destination of await targets.resolveMapped(symbol2, moduleVariable)) {
31864
31958
  const read2 = `${item.owner}\0${destination.id}`;
31865
31959
  if (stateReads.has(read2)) continue;
31866
31960
  stateReads.add(read2);
@@ -31882,7 +31976,7 @@ async function extractProjectMap(project, input, trace, read) {
31882
31976
  const symbol2 = isShorthandPropertyAssignment(item.node) ? await project.checker.getShorthandAssignmentValueSymbol(item.node) : symbols[index];
31883
31977
  const callable = await targets.resolveCallable(symbol2);
31884
31978
  if (!callable?.objects.length && item.readsState) {
31885
- await readState();
31979
+ await readState(symbol2);
31886
31980
  continue;
31887
31981
  }
31888
31982
  const holder = callable && item.holder ? materialize(item.holder) : void 0;
@@ -32012,15 +32106,27 @@ async function extractProjectMap(project, input, trace, read) {
32012
32106
  for (const diagnostic of await project.program.getConfigFileParsingDiagnostics())
32013
32107
  gap(`TSC_CONFIG_${diagnostic.code}`, input.configPath);
32014
32108
  trace.phase = "PROGRAM_DIAGNOSTICS";
32015
- for (const diagnostic of await project.program.getProgramDiagnostics())
32109
+ const notInstalled = /* @__PURE__ */ new Set();
32110
+ for (const diagnostic of await project.program.getProgramDiagnostics()) {
32016
32111
  gap(`TSC_PROGRAM_${diagnostic.code}`, input.configPath);
32112
+ const name = mapMissingPackage(diagnostic.code, diagnostic.text);
32113
+ if (name) notInstalled.add(name);
32114
+ }
32115
+ for (const relation of output.relations) {
32116
+ if (!IMPORT_RELATIONS.has(relation.kind) || relation.unresolvedReason !== "SYMBOL_NOT_RESOLVED")
32117
+ continue;
32118
+ const name = mapPackageOf(relation.target);
32119
+ if (name && !installed(relation.anchor.path, name)) notInstalled.add(name);
32120
+ }
32121
+ for (const name of [...notInstalled].sort())
32122
+ output.gaps.push({ code: MAP_DEPENDENCY_NOT_INSTALLED, package: name });
32017
32123
  trace.phase = "CONTEXT";
32018
32124
  output.contexts.push(mapParsingContext(project, input));
32019
32125
  return output;
32020
32126
  }
32021
32127
 
32022
32128
  // src/core.ts
32023
- import path7 from "node:path";
32129
+ import path8 from "node:path";
32024
32130
  var ProjectEvidencePathError = class extends Error {
32025
32131
  constructor(code) {
32026
32132
  super(code);
@@ -32030,14 +32136,14 @@ var ProjectEvidencePathError = class extends Error {
32030
32136
  code;
32031
32137
  };
32032
32138
  var normalizeProjectEvidencePath = (value, allowRoot = false) => {
32033
- if (value.includes("\0") || path7.isAbsolute(value) || value.includes("\\")) {
32139
+ if (value.includes("\0") || path8.isAbsolute(value) || value.includes("\\")) {
32034
32140
  throw new ProjectEvidencePathError("PROJECT_PATH_INVALID");
32035
32141
  }
32036
32142
  if (value === ".") {
32037
32143
  if (allowRoot) return "";
32038
32144
  throw new ProjectEvidencePathError("PROJECT_PATH_INVALID");
32039
32145
  }
32040
- const normalized = path7.posix.normalize(value);
32146
+ const normalized = path8.posix.normalize(value);
32041
32147
  if (normalized.length === 0 || normalized !== value || normalized === ".." || normalized.startsWith("../") || value.split("/").some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
32042
32148
  throw new ProjectEvidencePathError("PROJECT_PATH_INVALID");
32043
32149
  }
@@ -32160,8 +32266,39 @@ function mapWorkerFailure(error51, trace, workerUrl) {
32160
32266
  });
32161
32267
  }
32162
32268
 
32269
+ // src/project-map-reference-diagnostics.ts
32270
+ async function extractMapDiagnostics(project, input, programFiles) {
32271
+ const diagnostics = [];
32272
+ const missing = /* @__PURE__ */ new Set();
32273
+ for (const item of await project.program.getProgramDiagnostics()) {
32274
+ const name = mapMissingPackage(item.code, item.text);
32275
+ if (name) missing.add(name);
32276
+ }
32277
+ for (const name of programFiles) {
32278
+ const relative = mapRelativePath(name);
32279
+ const text2 = relative === void 0 ? void 0 : input.files[relative];
32280
+ if (relative === void 0 || text2 === void 0) continue;
32281
+ for (const item of await project.program.getSemanticDiagnostics(name)) {
32282
+ if (item.category !== DiagnosticCategory.Error) continue;
32283
+ const missed = mapMissingPackage(item.code, item.text);
32284
+ if (missed) missing.add(missed);
32285
+ let line = 1;
32286
+ for (let at = text2.indexOf("\n"); at >= 0 && at < item.pos; at = text2.indexOf("\n", at + 1))
32287
+ line++;
32288
+ diagnostics.push({
32289
+ path: relative,
32290
+ line,
32291
+ code: item.code,
32292
+ text: item.text,
32293
+ span: text2.slice(item.pos, item.end).slice(0, 200)
32294
+ });
32295
+ }
32296
+ }
32297
+ return { diagnostics, missing: [...missing].sort(), requiredFiles: [] };
32298
+ }
32299
+
32163
32300
  // src/project-map-query-selection.ts
32164
- var mapQueryPathMatches = (path8, prefix) => prefix === "." || path8 === prefix || path8.startsWith(`${prefix}/`);
32301
+ var mapQueryPathMatches = (path10, prefix) => prefix === "." || path10 === prefix || path10.startsWith(`${prefix}/`);
32165
32302
 
32166
32303
  // src/project-map-reference-extract.ts
32167
32304
  function referenceKind(node) {
@@ -32185,33 +32322,62 @@ function referenceKind(node) {
32185
32322
  return "DECLARATION";
32186
32323
  return isPropertyAccessExpression(expression) || isElementAccessExpression(expression) ? "READ" : "REFERENCE";
32187
32324
  }
32188
- async function extractMapReferences(project, input, query) {
32325
+ async function indexedAccesses(project, input, token) {
32326
+ const target = await project.checker.getSymbolAtLocation(token);
32327
+ if (!target) return [];
32328
+ const name = token.text;
32329
+ const index = new RegExp(
32330
+ `\\[\\s*(["'\`])${name.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}\\1`,
32331
+ "gu"
32332
+ );
32333
+ const literals = [];
32334
+ for (const [path10, text2] of Object.entries(input.files)) {
32335
+ const matches = [...text2.matchAll(index)];
32336
+ const file2 = matches.length && await project.program.getSourceFile(mapVirtualPath(path10));
32337
+ if (!file2) continue;
32338
+ for (const match of matches) {
32339
+ const literal2 = getTokenAtPosition(file2, match.index + match[0].length - name.length - 2);
32340
+ const type = literal2.parent;
32341
+ if (isLiteralTypeNode(type) && isIndexedAccessTypeNode(type.parent)) literals.push(literal2);
32342
+ }
32343
+ }
32344
+ if (!literals.length) return [];
32345
+ const declarations = new Set(target.declarations.map((node) => `${node.path}:${node.index}`));
32346
+ const symbols = await project.checker.getSymbolAtLocation(literals);
32347
+ return literals.filter(
32348
+ (_, at) => symbols[at]?.declarations.some((node) => declarations.has(`${node.path}:${node.index}`))
32349
+ );
32350
+ }
32351
+ async function extractPage(project, input, positions, query) {
32189
32352
  const file2 = await project.program.getSourceFile(mapVirtualPath(query.targetPath));
32190
- if (!file2) throw new Error("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE");
32353
+ if (!file2) return null;
32191
32354
  const token = getTokenAtPosition(file2, query.symbolStart);
32192
32355
  if (!isIdentifier(token) && !isPrivateIdentifier(token) && token.kind !== SyntaxKind.StringLiteral)
32193
- throw new Error("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE");
32356
+ return null;
32194
32357
  const groups = await project.checker.getReferencedSymbolsForNode(token, query.symbolStart);
32195
- if (!groups.length) throw new Error("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE");
32196
- const positions = new MapSourcePositions(input.files);
32358
+ if (!groups.length) return null;
32197
32359
  const references = /* @__PURE__ */ new Map();
32360
+ const add = (node) => {
32361
+ const relative = mapRelativePath(node.getSourceFile().fileName);
32362
+ if (!relative || !Object.hasOwn(input.files, relative)) return;
32363
+ if (!mapQueryPathMatches(relative, query.path ?? ".")) return;
32364
+ const kind = referenceKind(node);
32365
+ if (query.kinds && !query.kinds.includes(kind)) return;
32366
+ const anchor = positions.anchor(node, node.getSourceFile());
32367
+ references.set(`${relative}:${anchor.start}:${anchor.end}`, {
32368
+ anchor,
32369
+ kind
32370
+ });
32371
+ };
32198
32372
  for (const group of groups) {
32199
32373
  for (const handle of group.references) {
32200
32374
  if (mapRelativePath(handle.path) === void 0) continue;
32201
32375
  const node = await handle.resolve(project);
32202
- if (!node) throw new Error("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE");
32203
- const relative = mapRelativePath(node.getSourceFile().fileName);
32204
- if (!relative || !Object.hasOwn(input.files, relative)) continue;
32205
- if (!mapQueryPathMatches(relative, query.path ?? ".")) continue;
32206
- const kind = referenceKind(node);
32207
- if (query.kinds && !query.kinds.includes(kind)) continue;
32208
- const anchor = positions.anchor(node, node.getSourceFile());
32209
- references.set(`${relative}:${anchor.start}:${anchor.end}`, {
32210
- anchor,
32211
- kind
32212
- });
32376
+ if (!node) return null;
32377
+ add(node);
32213
32378
  }
32214
32379
  }
32380
+ for (const node of await indexedAccesses(project, input, token)) add(node);
32215
32381
  const ordered = [...references.values()].sort(
32216
32382
  (left, right) => Buffer.compare(Buffer.from(left.anchor.path), Buffer.from(right.anchor.path)) || left.anchor.start - right.anchor.start || left.anchor.end - right.anchor.end
32217
32383
  );
@@ -32220,10 +32386,18 @@ async function extractMapReferences(project, input, query) {
32220
32386
  const next = query.offset + selected.length;
32221
32387
  return {
32222
32388
  references: selected,
32223
- ...next < ordered.length ? { nextOffset: next } : {},
32224
- requiredFiles: []
32389
+ ...next < ordered.length ? { nextOffset: next } : {}
32225
32390
  };
32226
32391
  }
32392
+ async function extractMapReferences(project, input, requests, until = Number.POSITIVE_INFINITY) {
32393
+ const positions = new MapSourcePositions(input.files);
32394
+ const pages = [];
32395
+ for (const query of requests) {
32396
+ if (pages.length && Date.now() > until) break;
32397
+ pages.push(await extractPage(project, input, positions, query));
32398
+ }
32399
+ return { pages, requiredFiles: [] };
32400
+ }
32227
32401
 
32228
32402
  // src/project-map-worker-timing.ts
32229
32403
  var MapWorkerTimingCollector = class {
@@ -32328,7 +32502,13 @@ process.once(
32328
32502
  await timing?.checkpoint(api, "OPEN_PROJECT");
32329
32503
  trace.phase = message.operation === "REFERENCES" ? "REFERENCES" : "SOURCE_FILES";
32330
32504
  const programFiles = await project.program.getSourceFileNames();
32331
- const result2 = message.operation === "REFERENCES" && message.reference ? await extractMapReferences(project, message, message.reference) : files.required.size ? {
32505
+ if (message.operation === "DIAGNOSTICS") {
32506
+ const result3 = await extractMapDiagnostics(project, message, programFiles);
32507
+ result3.requiredFiles = [...files.required].sort();
32508
+ await snapshot.dispose();
32509
+ return result3;
32510
+ }
32511
+ const result2 = message.operation === "REFERENCES" && message.references ? await extractMapReferences(project, message, message.references, message.until) : files.required.size ? {
32332
32512
  contexts: [mapParsingContext(project, message)],
32333
32513
  objects: [],
32334
32514
  relations: [],
@@ -32336,12 +32516,26 @@ process.once(
32336
32516
  gaps: [],
32337
32517
  parsedFiles: [],
32338
32518
  requiredFiles: []
32339
- } : await extractProjectMap(project, message, trace, (file2) => {
32340
- const text2 = files.fs.readFile?.(mapVirtualPath(file2));
32341
- return typeof text2 === "string" && Object.hasOwn(message.files, file2) ? text2 : void 0;
32342
- });
32519
+ } : await extractProjectMap(
32520
+ project,
32521
+ message,
32522
+ trace,
32523
+ (file2) => {
32524
+ const text2 = files.fs.readFile?.(mapVirtualPath(file2));
32525
+ return typeof text2 === "string" && Object.hasOwn(message.files, file2) ? text2 : void 0;
32526
+ },
32527
+ (file2, name) => {
32528
+ for (let at = path9.posix.dirname(file2); ; at = path9.posix.dirname(at)) {
32529
+ const modules = at === "." ? "node_modules" : `${at}/node_modules`;
32530
+ if (files.fs.directoryExists?.(mapVirtualPath(`${modules}/${name}`)))
32531
+ return true;
32532
+ if (at === ".") return false;
32533
+ }
32534
+ }
32535
+ );
32343
32536
  result2.requiredFiles = [...files.required].sort();
32344
- if ("contexts" in result2)
32537
+ if ("contexts" in result2) {
32538
+ if (files.libraryMissing) result2.gaps.push({ code: "STANDARD_LIBRARY_NOT_LOADED" });
32345
32539
  for (const context of result2.contexts) {
32346
32540
  const sourceInputs = new Set(
32347
32541
  programFiles.map(mapRelativePath).filter(
@@ -32358,6 +32552,7 @@ process.once(
32358
32552
  .../* @__PURE__ */ new Set([...sourceInputs, ...files.readInputs, ...context.configurationFiles])
32359
32553
  ].sort();
32360
32554
  }
32555
+ }
32361
32556
  trace.phase = "DISPOSE";
32362
32557
  await timing?.checkpoint(
32363
32558
  api,