better-review 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +32 -12
  2. package/dist/cli.js +1044 -1598
  3. package/dist/web/assets/highlight.worker-BOqhB448.js +153 -0
  4. package/dist/web/assets/{html-Bv1KyTF7.js → html-B3xvRgDO.js} +1 -1
  5. package/dist/web/assets/html-BHZv6uqE.js +1 -0
  6. package/dist/web/assets/{index-DXvPQh0-.js → index--X0HmlXh.js} +4 -2
  7. package/dist/web/assets/{index-vJUACaoV.css → index-CZyRc3NX.css} +1 -1
  8. package/dist/web/assets/{json-B88Oqtu5.js → json-qhed-kSA.js} +1 -1
  9. package/dist/web/assets/{jsx-D3KKoC5L.js → jsx-Bz0zcwM4.js} +1 -1
  10. package/dist/web/assets/{markdown-CboqBxpY.js → markdown-BYOwaDjH.js} +1 -1
  11. package/dist/web/assets/scss-8bKmll0B.js +1 -0
  12. package/dist/web/assets/{tsx-BOvsFOI6.js → tsx-udAQXfEw.js} +1 -1
  13. package/dist/web/assets/{typescript-j_1H8WHN.js → typescript-bsJCZSQ-.js} +1 -1
  14. package/dist/web/index.html +2 -2
  15. package/package.json +1 -1
  16. package/dist/web/assets/astro-BGCLva2-.js +0 -1
  17. package/dist/web/assets/bat-qdxAdBWQ.js +0 -1
  18. package/dist/web/assets/c-Cz4nF6n_.js +0 -1
  19. package/dist/web/assets/c-SSSlmE39.js +0 -1
  20. package/dist/web/assets/clojure-DqKBuwfJ.js +0 -1
  21. package/dist/web/assets/cmake-Bj61d0ZC.js +0 -1
  22. package/dist/web/assets/cpp-DK5F0KO4.js +0 -1
  23. package/dist/web/assets/cpp-pF_afpy8.js +0 -1
  24. package/dist/web/assets/csharp-dmMxLVLW.js +0 -1
  25. package/dist/web/assets/dart-CHZY9Xhz.js +0 -1
  26. package/dist/web/assets/diff-woXpYk--.js +0 -1
  27. package/dist/web/assets/dockerfile-IyjqRm3v.js +0 -1
  28. package/dist/web/assets/dotenv-CuH5my32.js +0 -1
  29. package/dist/web/assets/elixir-DcSoMxCm.js +0 -1
  30. package/dist/web/assets/erlang-59ohNboI.js +0 -1
  31. package/dist/web/assets/fsharp-D2W_zG4w.js +0 -1
  32. package/dist/web/assets/gleam-CSRkHgEL.js +0 -1
  33. package/dist/web/assets/go-rLFTqkRN.js +0 -1
  34. package/dist/web/assets/graphql-BoW1g5X9.js +0 -1
  35. package/dist/web/assets/graphql-C2HCcBds.js +0 -1
  36. package/dist/web/assets/groovy-CacY0gHj.js +0 -1
  37. package/dist/web/assets/haskell-D8IpX4py.js +0 -1
  38. package/dist/web/assets/hcl-Dh228itO.js +0 -1
  39. package/dist/web/assets/highlight.worker-D2jBd466.js +0 -153
  40. package/dist/web/assets/html-DZNlqGBh.js +0 -1
  41. package/dist/web/assets/ini-0B7NLFlx.js +0 -1
  42. package/dist/web/assets/ini-DiZ1IqbV.js +0 -1
  43. package/dist/web/assets/java-BtIQNnN0.js +0 -1
  44. package/dist/web/assets/java-_ATy9zCa.js +0 -1
  45. package/dist/web/assets/json-C3WlssX3.js +0 -1
  46. package/dist/web/assets/json5-BR5RXkoi.js +0 -1
  47. package/dist/web/assets/jsx-C4yDKi0A.js +0 -1
  48. package/dist/web/assets/julia-CBcsyk3j.js +0 -1
  49. package/dist/web/assets/kotlin-DhhofPvG.js +0 -1
  50. package/dist/web/assets/lua-B0e3uOiv.js +0 -1
  51. package/dist/web/assets/lua-pjIdZuk8.js +0 -1
  52. package/dist/web/assets/makefile-Dixweg8N.js +0 -1
  53. package/dist/web/assets/markdown-CjQmuOi1.js +0 -1
  54. package/dist/web/assets/mdx-DQZ5AkYe.js +0 -1
  55. package/dist/web/assets/nginx-DbUAZ-J7.js +0 -1
  56. package/dist/web/assets/nix-Cl_7024t.js +0 -1
  57. package/dist/web/assets/objective-c-D1A_Heim.js +0 -1
  58. package/dist/web/assets/ocaml-O90oeIOV.js +0 -1
  59. package/dist/web/assets/perl-CCy4CjC0.js +0 -1
  60. package/dist/web/assets/php-3goRFXPs.js +0 -1
  61. package/dist/web/assets/postcss-D_Wz94rJ.js +0 -1
  62. package/dist/web/assets/powershell-QtSnmXcu.js +0 -1
  63. package/dist/web/assets/prisma-DMgNhnYS.js +0 -1
  64. package/dist/web/assets/properties-DiZ1IqbV.js +0 -1
  65. package/dist/web/assets/proto-DB4EqR-F.js +0 -1
  66. package/dist/web/assets/python-C5TF47hQ.js +0 -1
  67. package/dist/web/assets/python-CzFU0dpx.js +0 -1
  68. package/dist/web/assets/r-BXEss897.js +0 -1
  69. package/dist/web/assets/r-DWzjseEo.js +0 -1
  70. package/dist/web/assets/ruby-ChLscevq.js +0 -1
  71. package/dist/web/assets/rust-DpiIf5JO.js +0 -1
  72. package/dist/web/assets/scala-BiFt_7mu.js +0 -1
  73. package/dist/web/assets/shellscript-CVTB3cr6.js +0 -1
  74. package/dist/web/assets/shellscript-CqHdAlCp.js +0 -1
  75. package/dist/web/assets/sql-CNu3Or2W.js +0 -1
  76. package/dist/web/assets/sql-CfM2IJm3.js +0 -1
  77. package/dist/web/assets/svelte-Bte6OA2r.js +0 -1
  78. package/dist/web/assets/swift-CyEgAFGc.js +0 -1
  79. package/dist/web/assets/terraform-DswuEJGm.js +0 -1
  80. package/dist/web/assets/toml-CcmNWLt0.js +0 -1
  81. package/dist/web/assets/tsx-CGosfAUg.js +0 -1
  82. package/dist/web/assets/typescript-Bb1J8qyy.js +0 -1
  83. package/dist/web/assets/vue-CcmjViMa.js +0 -1
  84. package/dist/web/assets/xml-Bvlx11yh.js +0 -1
  85. package/dist/web/assets/xml-Byfru430.js +0 -1
  86. package/dist/web/assets/yaml-DDA_XMNu.js +0 -1
  87. package/dist/web/assets/yaml-DijMHRDA.js +0 -1
  88. package/dist/web/assets/zig-CMLA9XwU.js +0 -1
package/dist/cli.js CHANGED
@@ -1782,8 +1782,8 @@ function getStatusCodeFromKey(code) {
1782
1782
  var _JSONRPC2_TO_HTTP_COD;
1783
1783
  return (_JSONRPC2_TO_HTTP_COD = JSONRPC2_TO_HTTP_CODE[code]) !== null && _JSONRPC2_TO_HTTP_COD !== void 0 ? _JSONRPC2_TO_HTTP_COD : 500;
1784
1784
  }
1785
- function getHTTPStatusCode(json3) {
1786
- const httpStatuses = new Set((Array.isArray(json3) ? json3 : [json3]).map((res) => {
1785
+ function getHTTPStatusCode(json4) {
1786
+ const httpStatuses = new Set((Array.isArray(json4) ? json4 : [json4]).map((res) => {
1787
1787
  if ("error" in res && isObject(res.error.data)) {
1788
1788
  var _res$error$data;
1789
1789
  if (typeof ((_res$error$data = res.error.data) === null || _res$error$data === void 0 ? void 0 : _res$error$data["httpStatus"]) === "number") return res.error.data["httpStatus"];
@@ -4226,7 +4226,7 @@ var HonoRequest = class {
4226
4226
  * ```
4227
4227
  */
4228
4228
  json() {
4229
- return this.#cachedBody("text").then((text) => JSON.parse(text));
4229
+ return this.#cachedBody("text").then((text2) => JSON.parse(text2));
4230
4230
  }
4231
4231
  /**
4232
4232
  * `.text()` can parse Request body of type `text/plain`
@@ -4744,8 +4744,8 @@ var Context = class {
4744
4744
  * })
4745
4745
  * ```
4746
4746
  */
4747
- text = (text, arg, headers) => {
4748
- return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text) : this.#newResponse(text, arg, setDefaultContentType(TEXT_PLAIN, headers));
4747
+ text = (text2, arg, headers) => {
4748
+ return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text2) : this.#newResponse(text2, arg, setDefaultContentType(TEXT_PLAIN, headers));
4749
4749
  };
4750
4750
  /**
4751
4751
  * `.json()` can render JSON as `Content-Type:application/json`.
@@ -4762,9 +4762,9 @@ var Context = class {
4762
4762
  json = (object2, arg, headers) => {
4763
4763
  return this.#newResponse(JSON.stringify(object2), arg, setDefaultContentType("application/json", headers));
4764
4764
  };
4765
- html = (html, arg, headers) => {
4766
- const res = (html2) => this.#newResponse(html2, arg, setDefaultContentType("text/html; charset=UTF-8", headers));
4767
- return typeof html === "object" ? resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html);
4765
+ html = (html2, arg, headers) => {
4766
+ const res = (html3) => this.#newResponse(html3, arg, setDefaultContentType("text/html; charset=UTF-8", headers));
4767
+ return typeof html2 === "object" ? resolveCallback(html2, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html2);
4768
4768
  };
4769
4769
  /**
4770
4770
  * `.redirect()` can Redirect, default status code is 302.
@@ -5519,12 +5519,12 @@ var Node3 = class Node4 {
5519
5519
  const pattern = getPattern(p, nextP) || (nextP === void 0 && p && p.indexOf("*") === p.length - 1 ? p : null);
5520
5520
  const isParam = Array.isArray(pattern);
5521
5521
  const key = isParam ? pattern[0] : pattern || p;
5522
- const child2 = curNode.#children[key] ||= new Node4();
5523
- if (pattern && !child2.#pattern) {
5524
- child2.#pattern = pattern;
5525
- curNode.#patterns.push(child2);
5522
+ const child = curNode.#children[key] ||= new Node4();
5523
+ if (pattern && !child.#pattern) {
5524
+ child.#pattern = pattern;
5525
+ curNode.#patterns.push(child);
5526
5526
  }
5527
- curNode = child2;
5527
+ curNode = child;
5528
5528
  if (isParam) possibleKeys.add(pattern[1]);
5529
5529
  }
5530
5530
  curNode.#methods.push({ [method]: {
@@ -5569,15 +5569,15 @@ var Node3 = class Node4 {
5569
5569
  this.#pushHandlerSets(handlerSets, nextNode, method, node2.#params);
5570
5570
  } else tempNodes.push(nextNode);
5571
5571
  }
5572
- for (const child2 of node2.#patterns) {
5573
- const pattern = child2.#pattern;
5572
+ for (const child of node2.#patterns) {
5573
+ const pattern = child.#pattern;
5574
5574
  const params = node2.#params === emptyParams ? {} : { ...node2.#params };
5575
5575
  if (typeof pattern === "string") {
5576
5576
  if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
5577
- this.#pushHandlerSets(handlerSets, child2, method, node2.#params);
5577
+ this.#pushHandlerSets(handlerSets, child, method, node2.#params);
5578
5578
  if (pattern === "*") {
5579
- child2.#params = params;
5580
- tempNodes.push(child2);
5579
+ child.#params = params;
5580
+ tempNodes.push(child);
5581
5581
  }
5582
5582
  }
5583
5583
  continue;
@@ -5597,12 +5597,12 @@ var Node3 = class Node4 {
5597
5597
  const m = matcher.exec(restPathString);
5598
5598
  if (m) {
5599
5599
  params[name] = m[0];
5600
- this.#pushHandlerSets(handlerSets, child2, method, node2.#params, params);
5601
- if (m[0].length === restPathString.length && child2.#children["*"]) this.#pushHandlerSets(handlerSets, child2.#children["*"], method, node2.#params, params);
5602
- for (const _ in child2.#children) {
5603
- child2.#params = params;
5600
+ this.#pushHandlerSets(handlerSets, child, method, node2.#params, params);
5601
+ if (m[0].length === restPathString.length && child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, node2.#params, params);
5602
+ for (const _ in child.#children) {
5603
+ child.#params = params;
5604
5604
  const componentCount = m[0].match(/\//g)?.length ?? 0;
5605
- (curNodesQueue[componentCount] ||= []).push(child2);
5605
+ (curNodesQueue[componentCount] ||= []).push(child);
5606
5606
  break;
5607
5607
  }
5608
5608
  continue;
@@ -5611,11 +5611,11 @@ var Node3 = class Node4 {
5611
5611
  if (matcher === true || matcher.test(part)) {
5612
5612
  params[name] = part;
5613
5613
  if (isLast) {
5614
- this.#pushHandlerSets(handlerSets, child2, method, params, node2.#params);
5615
- if (child2.#children["*"]) this.#pushHandlerSets(handlerSets, child2.#children["*"], method, params, node2.#params);
5614
+ this.#pushHandlerSets(handlerSets, child, method, params, node2.#params);
5615
+ if (child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, params, node2.#params);
5616
5616
  } else {
5617
- child2.#params = params;
5618
- tempNodes.push(child2);
5617
+ child.#params = params;
5618
+ tempNodes.push(child);
5619
5619
  }
5620
5620
  }
5621
5621
  }
@@ -5742,9 +5742,9 @@ function hashString(input2, seed = 0) {
5742
5742
  }
5743
5743
  var LINE_PREFIX = { context: " ", add: "+", del: "-" };
5744
5744
  function hunkHash(path, lines) {
5745
- let text = path + "\n";
5746
- for (const line of lines) text += LINE_PREFIX[line.type] + line.content + "\n";
5747
- return hashString(text);
5745
+ let text2 = path + "\n";
5746
+ for (const line of lines) text2 += LINE_PREFIX[line.type] + line.content + "\n";
5747
+ return hashString(text2);
5748
5748
  }
5749
5749
  var HUNK_HEADER = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@ ?(.*)$/;
5750
5750
  function unquote(path) {
@@ -5786,9 +5786,9 @@ function pathsFromGitHeader(rest) {
5786
5786
  const idx = rest.indexOf(" b/");
5787
5787
  return idx === -1 ? [rest, rest] : [stripPrefix(rest.slice(0, idx)), stripPrefix(rest.slice(idx + 1))];
5788
5788
  }
5789
- function parseUnifiedDiff(text) {
5789
+ function parseUnifiedDiff(text2) {
5790
5790
  const files = [];
5791
- const lines = text.split("\n");
5791
+ const lines = text2.split("\n");
5792
5792
  let file2 = null;
5793
5793
  let hunk = null;
5794
5794
  let oldNo = 0;
@@ -5852,6 +5852,8 @@ function parseUnifiedDiff(text) {
5852
5852
  status: "modified",
5853
5853
  binary: false,
5854
5854
  truncated: false,
5855
+ oldBlob: null,
5856
+ newBlob: null,
5855
5857
  additions: 0,
5856
5858
  deletions: 0,
5857
5859
  hunks: []
@@ -5887,7 +5889,12 @@ function parseUnifiedDiff(text) {
5887
5889
  f.path = unquote(line.slice("rename to ".length));
5888
5890
  f.status = "renamed";
5889
5891
  } else if (line.startsWith("Binary files ") || line === "GIT binary patch") f.binary = true;
5890
- else if (line.startsWith("--- ")) {
5892
+ else if (line.startsWith("index ")) {
5893
+ const ids = /^index ([0-9a-f]+)\.\.([0-9a-f]+)/.exec(line);
5894
+ const blob = (id) => id === void 0 || /^0+$/.test(id) ? null : id;
5895
+ f.oldBlob = blob(ids?.[1]);
5896
+ f.newBlob = blob(ids?.[2]);
5897
+ } else if (line.startsWith("--- ")) {
5891
5898
  const p = line.slice(4);
5892
5899
  if (p !== "/dev/null") f.oldPath = stripPrefix(p);
5893
5900
  } else if (line.startsWith("+++ ")) {
@@ -10975,9 +10982,9 @@ function isRecursive(inst, stack, resolve) {
10975
10982
  return PROVEN;
10976
10983
  stack.add(inst);
10977
10984
  let result = NONE;
10978
- const check2 = (child2) => {
10979
- if (result !== PROVEN && child2?._zod) {
10980
- const answer = isRecursive(child2, stack, resolve);
10985
+ const check2 = (child) => {
10986
+ if (result !== PROVEN && child?._zod) {
10987
+ const answer = isRecursive(child, stack, resolve);
10981
10988
  if (answer > result)
10982
10989
  result = answer;
10983
10990
  }
@@ -10988,9 +10995,9 @@ function isRecursive(inst, stack, resolve) {
10988
10995
  const desc = Object.getOwnPropertyDescriptor(sh, key);
10989
10996
  if (spread && !desc.enumerable)
10990
10997
  continue;
10991
- const child2 = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
10992
- if (child2 > answer)
10993
- answer = child2;
10998
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
10999
+ if (child > answer)
11000
+ answer = child;
10994
11001
  }
10995
11002
  return answer;
10996
11003
  };
@@ -15250,8 +15257,8 @@ function ko_default() {
15250
15257
  }
15251
15258
 
15252
15259
  // ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/locales/lt.js
15253
- var capitalizeFirstCharacter = (text) => {
15254
- return text.charAt(0).toUpperCase() + text.slice(1);
15260
+ var capitalizeFirstCharacter = (text2) => {
15261
+ return text2.charAt(0).toUpperCase() + text2.slice(1);
15255
15262
  };
15256
15263
  function getUnitTypeFromNumber(number4) {
15257
15264
  const abs = Math.abs(number4);
@@ -21547,13 +21554,13 @@ function initializeContext(params) {
21547
21554
  external: params?.external ?? void 0
21548
21555
  };
21549
21556
  }
21550
- function handleUnrepresentable(schema, ctx, json3, params, message) {
21557
+ function handleUnrepresentable(schema, ctx, json4, params, message) {
21551
21558
  const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema: schema, path: params.path, message }) : ctx.unrepresentable;
21552
21559
  if (result === "any")
21553
21560
  return false;
21554
21561
  if (result === void 0 || result === "throw")
21555
21562
  throw new Error(message);
21556
- Object.assign(json3, result);
21563
+ Object.assign(json4, result);
21557
21564
  return true;
21558
21565
  }
21559
21566
  function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
@@ -21789,12 +21796,12 @@ function foldObjects(members2) {
21789
21796
  }
21790
21797
  return folded;
21791
21798
  }
21792
- function foldIntersection(json3) {
21793
- const allOf = json3.allOf;
21799
+ function foldIntersection(json4) {
21800
+ const allOf = json4.allOf;
21794
21801
  if (!Array.isArray(allOf) || allOf.length < 2)
21795
21802
  return;
21796
21803
  for (const key of FOLDABLE_KEYS)
21797
- if (key in json3)
21804
+ if (key in json4)
21798
21805
  return;
21799
21806
  const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
21800
21807
  let folded = null;
@@ -21813,8 +21820,8 @@ function foldIntersection(json3) {
21813
21820
  }
21814
21821
  if (!folded)
21815
21822
  return;
21816
- delete json3.allOf;
21817
- assignProps(json3, folded);
21823
+ delete json4.allOf;
21824
+ assignProps(json4, folded);
21818
21825
  }
21819
21826
  function finalize(ctx, schema) {
21820
21827
  const root = ctx.seen.get(schema);
@@ -21896,20 +21903,20 @@ function finalize(ctx, schema) {
21896
21903
  if (ctx.intersections.length) {
21897
21904
  const carriers = /* @__PURE__ */ new Map();
21898
21905
  for (const seen of ctx.seen.values()) {
21899
- for (const json3 of [seen.schema, seen.def]) {
21900
- const allOf = json3?.allOf;
21906
+ for (const json4 of [seen.schema, seen.def]) {
21907
+ const allOf = json4?.allOf;
21901
21908
  if (!Array.isArray(allOf))
21902
21909
  continue;
21903
21910
  const existing = carriers.get(allOf);
21904
21911
  if (existing)
21905
- existing.push(json3);
21912
+ existing.push(json4);
21906
21913
  else
21907
- carriers.set(allOf, [json3]);
21914
+ carriers.set(allOf, [json4]);
21908
21915
  }
21909
21916
  }
21910
21917
  for (const allOf of ctx.intersections) {
21911
- for (const json3 of carriers.get(allOf) ?? [])
21912
- foldIntersection(json3);
21918
+ for (const json4 of carriers.get(allOf) ?? [])
21919
+ foldIntersection(json4);
21913
21920
  }
21914
21921
  }
21915
21922
  }
@@ -22144,29 +22151,29 @@ var exactPatterns = /* @__PURE__ */ new Map([
22144
22151
  ]);
22145
22152
  var exactPattern = (p) => exactPatterns.get(p) ?? p;
22146
22153
  var stringProcessor = (schema, ctx, _json, _params) => {
22147
- const json3 = _json;
22148
- json3.type = "string";
22154
+ const json4 = _json;
22155
+ json4.type = "string";
22149
22156
  const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
22150
22157
  if (typeof minimum === "number")
22151
- json3.minLength = minimum;
22158
+ json4.minLength = minimum;
22152
22159
  if (typeof maximum === "number")
22153
- json3.maxLength = maximum;
22160
+ json4.maxLength = maximum;
22154
22161
  if (format) {
22155
- json3.format = formatMap[format] ?? format;
22156
- if (json3.format === "")
22157
- delete json3.format;
22162
+ json4.format = formatMap[format] ?? format;
22163
+ if (json4.format === "")
22164
+ delete json4.format;
22158
22165
  if (format === "time" || laxFormat) {
22159
- delete json3.format;
22166
+ delete json4.format;
22160
22167
  }
22161
22168
  }
22162
22169
  if (contentEncoding)
22163
- json3.contentEncoding = contentEncoding;
22170
+ json4.contentEncoding = contentEncoding;
22164
22171
  if (patterns && patterns.size > 0) {
22165
22172
  const patternList = [...patterns].map(exactPattern);
22166
22173
  if (patternList.length === 1)
22167
- json3.pattern = patternList[0].source;
22174
+ json4.pattern = patternList[0].source;
22168
22175
  else if (patternList.length > 1) {
22169
- json3.allOf = [
22176
+ json4.allOf = [
22170
22177
  ...patternList.map((regex) => ({
22171
22178
  ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
22172
22179
  pattern: regex.source
@@ -22176,31 +22183,31 @@ var stringProcessor = (schema, ctx, _json, _params) => {
22176
22183
  }
22177
22184
  };
22178
22185
  var numberProcessor = (schema, ctx, _json, params) => {
22179
- const json3 = _json;
22186
+ const json4 = _json;
22180
22187
  const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
22181
- json3.type = isInt ? "integer" : "number";
22188
+ json4.type = isInt ? "integer" : "number";
22182
22189
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
22183
22190
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
22184
22191
  const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
22185
22192
  if (exMin) {
22186
22193
  if (legacy) {
22187
- json3.minimum = exclusiveMinimum;
22188
- json3.exclusiveMinimum = true;
22194
+ json4.minimum = exclusiveMinimum;
22195
+ json4.exclusiveMinimum = true;
22189
22196
  } else {
22190
- json3.exclusiveMinimum = exclusiveMinimum;
22197
+ json4.exclusiveMinimum = exclusiveMinimum;
22191
22198
  }
22192
22199
  } else if (typeof minimum === "number") {
22193
- json3.minimum = minimum;
22200
+ json4.minimum = minimum;
22194
22201
  }
22195
22202
  if (exMax) {
22196
22203
  if (legacy) {
22197
- json3.maximum = exclusiveMaximum;
22198
- json3.exclusiveMaximum = true;
22204
+ json4.maximum = exclusiveMaximum;
22205
+ json4.exclusiveMaximum = true;
22199
22206
  } else {
22200
- json3.exclusiveMaximum = exclusiveMaximum;
22207
+ json4.exclusiveMaximum = exclusiveMaximum;
22201
22208
  }
22202
22209
  } else if (typeof maximum === "number") {
22203
- json3.maximum = maximum;
22210
+ json4.maximum = maximum;
22204
22211
  }
22205
22212
  if (multipleOf) {
22206
22213
  const divisors = /* @__PURE__ */ new Set();
@@ -22208,75 +22215,75 @@ var numberProcessor = (schema, ctx, _json, params) => {
22208
22215
  if (Number.isFinite(divisor) && divisor !== 0)
22209
22216
  divisors.add(Math.abs(divisor));
22210
22217
  else
22211
- handleUnrepresentable(schema, ctx, json3, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
22218
+ handleUnrepresentable(schema, ctx, json4, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
22212
22219
  }
22213
22220
  const [first, ...rest] = divisors;
22214
22221
  if (first !== void 0)
22215
- json3.multipleOf = first;
22222
+ json4.multipleOf = first;
22216
22223
  if (rest.length)
22217
- json3.allOf = [...json3.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
22224
+ json4.allOf = [...json4.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
22218
22225
  }
22219
22226
  };
22220
- var booleanProcessor = (_schema, _ctx, json3, _params) => {
22221
- json3.type = "boolean";
22227
+ var booleanProcessor = (_schema, _ctx, json4, _params) => {
22228
+ json4.type = "boolean";
22222
22229
  };
22223
- var bigintProcessor = (schema, ctx, json3, params) => {
22224
- handleUnrepresentable(schema, ctx, json3, params, "BigInt cannot be represented in JSON Schema");
22230
+ var bigintProcessor = (schema, ctx, json4, params) => {
22231
+ handleUnrepresentable(schema, ctx, json4, params, "BigInt cannot be represented in JSON Schema");
22225
22232
  };
22226
- var symbolProcessor = (schema, ctx, json3, params) => {
22227
- handleUnrepresentable(schema, ctx, json3, params, "Symbols cannot be represented in JSON Schema");
22233
+ var symbolProcessor = (schema, ctx, json4, params) => {
22234
+ handleUnrepresentable(schema, ctx, json4, params, "Symbols cannot be represented in JSON Schema");
22228
22235
  };
22229
- var nullProcessor = (_schema, ctx, json3, _params) => {
22236
+ var nullProcessor = (_schema, ctx, json4, _params) => {
22230
22237
  if (ctx.target === "openapi-3.0") {
22231
- json3.type = "string";
22232
- json3.nullable = true;
22233
- json3.enum = [null];
22238
+ json4.type = "string";
22239
+ json4.nullable = true;
22240
+ json4.enum = [null];
22234
22241
  } else {
22235
- json3.type = "null";
22242
+ json4.type = "null";
22236
22243
  }
22237
22244
  };
22238
- var undefinedProcessor = (schema, ctx, json3, params) => {
22239
- handleUnrepresentable(schema, ctx, json3, params, "Undefined cannot be represented in JSON Schema");
22245
+ var undefinedProcessor = (schema, ctx, json4, params) => {
22246
+ handleUnrepresentable(schema, ctx, json4, params, "Undefined cannot be represented in JSON Schema");
22240
22247
  };
22241
- var voidProcessor = (schema, ctx, json3, params) => {
22242
- handleUnrepresentable(schema, ctx, json3, params, "Void cannot be represented in JSON Schema");
22248
+ var voidProcessor = (schema, ctx, json4, params) => {
22249
+ handleUnrepresentable(schema, ctx, json4, params, "Void cannot be represented in JSON Schema");
22243
22250
  };
22244
- var neverProcessor = (_schema, _ctx, json3, _params) => {
22245
- json3.not = {};
22251
+ var neverProcessor = (_schema, _ctx, json4, _params) => {
22252
+ json4.not = {};
22246
22253
  };
22247
22254
  var anyProcessor = (_schema, _ctx, _json, _params) => {
22248
22255
  };
22249
22256
  var unknownProcessor = (_schema, _ctx, _json, _params) => {
22250
22257
  };
22251
- var dateProcessor = (schema, ctx, json3, params) => {
22252
- handleUnrepresentable(schema, ctx, json3, params, "Date cannot be represented in JSON Schema");
22258
+ var dateProcessor = (schema, ctx, json4, params) => {
22259
+ handleUnrepresentable(schema, ctx, json4, params, "Date cannot be represented in JSON Schema");
22253
22260
  };
22254
- var enumProcessor = (schema, _ctx, json3, _params) => {
22261
+ var enumProcessor = (schema, _ctx, json4, _params) => {
22255
22262
  const def = schema._zod.def;
22256
22263
  const values = getEnumValues(def.entries);
22257
22264
  if (values.length === 0) {
22258
- json3.not = {};
22265
+ json4.not = {};
22259
22266
  return;
22260
22267
  }
22261
22268
  if (values.every((v) => typeof v === "number"))
22262
- json3.type = "number";
22269
+ json4.type = "number";
22263
22270
  if (values.every((v) => typeof v === "string"))
22264
- json3.type = "string";
22265
- json3.enum = values;
22271
+ json4.type = "string";
22272
+ json4.enum = values;
22266
22273
  };
22267
- var literalProcessor = (schema, ctx, json3, params) => {
22274
+ var literalProcessor = (schema, ctx, json4, params) => {
22268
22275
  const def = schema._zod.def;
22269
22276
  if (def.values.length === 0) {
22270
- json3.not = {};
22277
+ json4.not = {};
22271
22278
  return;
22272
22279
  }
22273
22280
  const vals = [];
22274
22281
  for (const val of def.values) {
22275
22282
  if (val === void 0) {
22276
- if (handleUnrepresentable(schema, ctx, json3, params, "Literal `undefined` cannot be represented in JSON Schema"))
22283
+ if (handleUnrepresentable(schema, ctx, json4, params, "Literal `undefined` cannot be represented in JSON Schema"))
22277
22284
  return;
22278
22285
  } else if (typeof val === "bigint") {
22279
- if (handleUnrepresentable(schema, ctx, json3, params, "BigInt literals cannot be represented in JSON Schema"))
22286
+ if (handleUnrepresentable(schema, ctx, json4, params, "BigInt literals cannot be represented in JSON Schema"))
22280
22287
  return;
22281
22288
  vals.push(Number(val));
22282
22289
  } else {
@@ -22286,37 +22293,37 @@ var literalProcessor = (schema, ctx, json3, params) => {
22286
22293
  if (vals.length === 0) {
22287
22294
  } else if (vals.length === 1) {
22288
22295
  const val = vals[0];
22289
- json3.type = val === null ? "null" : typeof val;
22296
+ json4.type = val === null ? "null" : typeof val;
22290
22297
  if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
22291
- json3.enum = [val];
22298
+ json4.enum = [val];
22292
22299
  } else {
22293
- json3.const = val;
22300
+ json4.const = val;
22294
22301
  }
22295
22302
  } else {
22296
22303
  if (vals.every((v) => typeof v === "number"))
22297
- json3.type = "number";
22304
+ json4.type = "number";
22298
22305
  if (vals.every((v) => typeof v === "string"))
22299
- json3.type = "string";
22306
+ json4.type = "string";
22300
22307
  if (vals.every((v) => typeof v === "boolean"))
22301
- json3.type = "boolean";
22308
+ json4.type = "boolean";
22302
22309
  if (vals.every((v) => v === null))
22303
- json3.type = "null";
22304
- json3.enum = vals;
22310
+ json4.type = "null";
22311
+ json4.enum = vals;
22305
22312
  }
22306
22313
  };
22307
- var nanProcessor = (schema, ctx, json3, params) => {
22308
- handleUnrepresentable(schema, ctx, json3, params, "NaN cannot be represented in JSON Schema");
22314
+ var nanProcessor = (schema, ctx, json4, params) => {
22315
+ handleUnrepresentable(schema, ctx, json4, params, "NaN cannot be represented in JSON Schema");
22309
22316
  };
22310
- var templateLiteralProcessor = (schema, _ctx, json3, _params) => {
22311
- const _json = json3;
22317
+ var templateLiteralProcessor = (schema, _ctx, json4, _params) => {
22318
+ const _json = json4;
22312
22319
  const pattern = schema._zod.pattern;
22313
22320
  if (!pattern)
22314
22321
  throw new Error("Pattern not found in template literal");
22315
22322
  _json.type = "string";
22316
22323
  _json.pattern = pattern.source;
22317
22324
  };
22318
- var fileProcessor = (schema, _ctx, json3, _params) => {
22319
- const _json = json3;
22325
+ var fileProcessor = (schema, _ctx, json4, _params) => {
22326
+ const _json = json4;
22320
22327
  _json.type = "string";
22321
22328
  _json.format = "binary";
22322
22329
  _json.contentEncoding = "binary";
@@ -22334,34 +22341,34 @@ var fileProcessor = (schema, _ctx, json3, _params) => {
22334
22341
  else
22335
22342
  _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
22336
22343
  };
22337
- var successProcessor = (_schema, _ctx, json3, _params) => {
22338
- json3.type = "boolean";
22344
+ var successProcessor = (_schema, _ctx, json4, _params) => {
22345
+ json4.type = "boolean";
22339
22346
  };
22340
- var customProcessor = (schema, ctx, json3, params) => {
22341
- handleUnrepresentable(schema, ctx, json3, params, "Custom types cannot be represented in JSON Schema");
22347
+ var customProcessor = (schema, ctx, json4, params) => {
22348
+ handleUnrepresentable(schema, ctx, json4, params, "Custom types cannot be represented in JSON Schema");
22342
22349
  };
22343
- var functionProcessor = (schema, ctx, json3, params) => {
22344
- handleUnrepresentable(schema, ctx, json3, params, "Function types cannot be represented in JSON Schema");
22350
+ var functionProcessor = (schema, ctx, json4, params) => {
22351
+ handleUnrepresentable(schema, ctx, json4, params, "Function types cannot be represented in JSON Schema");
22345
22352
  };
22346
- var transformProcessor = (schema, ctx, json3, params) => {
22347
- handleUnrepresentable(schema, ctx, json3, params, "Transforms cannot be represented in JSON Schema");
22353
+ var transformProcessor = (schema, ctx, json4, params) => {
22354
+ handleUnrepresentable(schema, ctx, json4, params, "Transforms cannot be represented in JSON Schema");
22348
22355
  };
22349
- var mapProcessor = (schema, ctx, json3, params) => {
22350
- handleUnrepresentable(schema, ctx, json3, params, "Map cannot be represented in JSON Schema");
22356
+ var mapProcessor = (schema, ctx, json4, params) => {
22357
+ handleUnrepresentable(schema, ctx, json4, params, "Map cannot be represented in JSON Schema");
22351
22358
  };
22352
- var setProcessor = (schema, ctx, json3, params) => {
22353
- handleUnrepresentable(schema, ctx, json3, params, "Set cannot be represented in JSON Schema");
22359
+ var setProcessor = (schema, ctx, json4, params) => {
22360
+ handleUnrepresentable(schema, ctx, json4, params, "Set cannot be represented in JSON Schema");
22354
22361
  };
22355
22362
  var arrayProcessor = (schema, ctx, _json, params) => {
22356
- const json3 = _json;
22363
+ const json4 = _json;
22357
22364
  const def = schema._zod.def;
22358
22365
  const { minimum, maximum } = aggregateChecks(schema);
22359
22366
  if (typeof minimum === "number")
22360
- json3.minItems = minimum;
22367
+ json4.minItems = minimum;
22361
22368
  if (typeof maximum === "number")
22362
- json3.maxItems = maximum;
22363
- json3.type = "array";
22364
- json3.items = processSchema(def.element, ctx, {
22369
+ json4.maxItems = maximum;
22370
+ json4.type = "array";
22371
+ json4.items = processSchema(def.element, ctx, {
22365
22372
  ...params,
22366
22373
  path: [...params.path, "items"]
22367
22374
  });
@@ -22377,17 +22384,17 @@ function inputOptin(schema) {
22377
22384
  return schema._zod.optin;
22378
22385
  }
22379
22386
  var objectProcessor = (schema, ctx, _json, params) => {
22380
- const json3 = _json;
22387
+ const json4 = _json;
22381
22388
  const def = schema._zod.def;
22382
22389
  const shape = def.shape;
22383
22390
  const symbolKeys = Object.getOwnPropertySymbols(shape);
22384
- if (symbolKeys.length && handleUnrepresentable(schema, ctx, json3, params, "Symbol keys cannot be represented in JSON Schema")) {
22391
+ if (symbolKeys.length && handleUnrepresentable(schema, ctx, json4, params, "Symbol keys cannot be represented in JSON Schema")) {
22385
22392
  return;
22386
22393
  }
22387
- json3.type = "object";
22388
- json3.properties = {};
22394
+ json4.type = "object";
22395
+ json4.properties = {};
22389
22396
  for (const key in shape) {
22390
- assignProp(json3.properties, key, processSchema(shape[key], ctx, {
22397
+ assignProp(json4.properties, key, processSchema(shape[key], ctx, {
22391
22398
  ...params,
22392
22399
  path: [...params.path, "properties", key]
22393
22400
  }));
@@ -22400,21 +22407,21 @@ var objectProcessor = (schema, ctx, _json, params) => {
22400
22407
  }
22401
22408
  }
22402
22409
  if (requiredKeys.length > 0) {
22403
- json3.required = requiredKeys;
22410
+ json4.required = requiredKeys;
22404
22411
  }
22405
22412
  if (def.catchall?._zod.def.type === "never") {
22406
- json3.additionalProperties = false;
22413
+ json4.additionalProperties = false;
22407
22414
  } else if (!def.catchall) {
22408
22415
  if (ctx.io === "output")
22409
- json3.additionalProperties = false;
22416
+ json4.additionalProperties = false;
22410
22417
  } else if (def.catchall) {
22411
- json3.additionalProperties = processSchema(def.catchall, ctx, {
22418
+ json4.additionalProperties = processSchema(def.catchall, ctx, {
22412
22419
  ...params,
22413
22420
  path: [...params.path, "additionalProperties"]
22414
22421
  });
22415
22422
  }
22416
22423
  };
22417
- var unionProcessor = (schema, ctx, json3, params) => {
22424
+ var unionProcessor = (schema, ctx, json4, params) => {
22418
22425
  const def = schema._zod.def;
22419
22426
  const isExclusive = def.inclusive === false;
22420
22427
  const options = def.options.map((x, i) => processSchema(x, ctx, {
@@ -22422,12 +22429,12 @@ var unionProcessor = (schema, ctx, json3, params) => {
22422
22429
  path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
22423
22430
  }));
22424
22431
  if (isExclusive) {
22425
- json3.oneOf = options;
22432
+ json4.oneOf = options;
22426
22433
  } else {
22427
- json3.anyOf = options;
22434
+ json4.anyOf = options;
22428
22435
  }
22429
22436
  };
22430
- var intersectionProcessor = (schema, ctx, json3, params) => {
22437
+ var intersectionProcessor = (schema, ctx, json4, params) => {
22431
22438
  const def = schema._zod.def;
22432
22439
  const a = processSchema(def.left, ctx, {
22433
22440
  ...params,
@@ -22442,13 +22449,13 @@ var intersectionProcessor = (schema, ctx, json3, params) => {
22442
22449
  ...isSimpleIntersection(a) ? a.allOf : [a],
22443
22450
  ...isSimpleIntersection(b) ? b.allOf : [b]
22444
22451
  ];
22445
- json3.allOf = allOf;
22452
+ json4.allOf = allOf;
22446
22453
  ctx.intersections.push(allOf);
22447
22454
  };
22448
22455
  var tupleProcessor = (schema, ctx, _json, params) => {
22449
- const json3 = _json;
22456
+ const json4 = _json;
22450
22457
  const def = schema._zod.def;
22451
- json3.type = "array";
22458
+ json4.type = "array";
22452
22459
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
22453
22460
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
22454
22461
  const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
@@ -22470,70 +22477,70 @@ var tupleProcessor = (schema, ctx, _json, params) => {
22470
22477
  const maxItems = def.items.length;
22471
22478
  const isClosed = !def.rest;
22472
22479
  if (ctx.target === "draft-2020-12") {
22473
- json3.prefixItems = prefixItems;
22480
+ json4.prefixItems = prefixItems;
22474
22481
  if (isClosed) {
22475
- json3.items = false;
22482
+ json4.items = false;
22476
22483
  } else if (rest) {
22477
- json3.items = rest;
22484
+ json4.items = rest;
22478
22485
  }
22479
22486
  if (minItems > 0)
22480
- json3.minItems = minItems;
22487
+ json4.minItems = minItems;
22481
22488
  if (isClosed)
22482
- json3.maxItems = maxItems;
22489
+ json4.maxItems = maxItems;
22483
22490
  } else if (ctx.target === "openapi-3.0") {
22484
- json3.items = {
22491
+ json4.items = {
22485
22492
  anyOf: prefixItems
22486
22493
  };
22487
22494
  if (rest) {
22488
- json3.items.anyOf.push(rest);
22495
+ json4.items.anyOf.push(rest);
22489
22496
  }
22490
22497
  if (minItems > 0)
22491
- json3.minItems = minItems;
22498
+ json4.minItems = minItems;
22492
22499
  if (isClosed)
22493
- json3.maxItems = maxItems;
22500
+ json4.maxItems = maxItems;
22494
22501
  } else {
22495
- json3.items = prefixItems;
22502
+ json4.items = prefixItems;
22496
22503
  if (isClosed) {
22497
- json3.additionalItems = false;
22504
+ json4.additionalItems = false;
22498
22505
  } else if (rest) {
22499
- json3.additionalItems = rest;
22506
+ json4.additionalItems = rest;
22500
22507
  }
22501
22508
  if (minItems > 0)
22502
- json3.minItems = minItems;
22509
+ json4.minItems = minItems;
22503
22510
  if (isClosed)
22504
- json3.maxItems = maxItems;
22511
+ json4.maxItems = maxItems;
22505
22512
  }
22506
22513
  const { minimum, maximum } = aggregateChecks(schema);
22507
22514
  if (typeof minimum === "number")
22508
- json3.minItems = minimum;
22515
+ json4.minItems = minimum;
22509
22516
  if (typeof maximum === "number")
22510
- json3.maxItems = maximum;
22511
- };
22512
- function stringifyKeyNames(bySchema, json3, visited) {
22513
- if (json3.$ref) {
22514
- if (visited.has(json3))
22515
- return json3;
22516
- visited.add(json3);
22517
- const def = bySchema.get(json3)?.def;
22517
+ json4.maxItems = maximum;
22518
+ };
22519
+ function stringifyKeyNames(bySchema, json4, visited) {
22520
+ if (json4.$ref) {
22521
+ if (visited.has(json4))
22522
+ return json4;
22523
+ visited.add(json4);
22524
+ const def = bySchema.get(json4)?.def;
22518
22525
  if (!def)
22519
- return json3;
22526
+ return json4;
22520
22527
  const inlined = stringifyKeyNames(bySchema, def, visited);
22521
- return inlined === def ? json3 : inlined;
22528
+ return inlined === def ? json4 : inlined;
22522
22529
  }
22523
22530
  for (const keyword of ["anyOf", "oneOf"]) {
22524
- const branches = json3[keyword];
22531
+ const branches = json4[keyword];
22525
22532
  if (!Array.isArray(branches))
22526
22533
  continue;
22527
22534
  const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
22528
22535
  if (mapped.some((branch, i) => branch !== branches[i]))
22529
- json3 = { ...json3, [keyword]: mapped };
22536
+ json4 = { ...json4, [keyword]: mapped };
22530
22537
  }
22531
- const types = Array.isArray(json3.type) ? json3.type : [json3.type];
22538
+ const types = Array.isArray(json4.type) ? json4.type : [json4.type];
22532
22539
  const numericType = !types.includes("string") && types.some((t2) => t2 === "number" || t2 === "integer");
22533
- const values = json3.enum ?? (json3.const !== void 0 ? [json3.const] : void 0);
22540
+ const values = json4.enum ?? (json4.const !== void 0 ? [json4.const] : void 0);
22534
22541
  if (!numericType && !values?.some((v) => typeof v === "number"))
22535
- return json3;
22536
- const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json3;
22542
+ return json4;
22543
+ const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json4;
22537
22544
  if (rest.enum)
22538
22545
  rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
22539
22546
  else if (typeof rest.const === "number")
@@ -22573,9 +22580,9 @@ function rewriteKeyNames(ctx) {
22573
22580
  }
22574
22581
  }
22575
22582
  var recordProcessor = (schema, ctx, _json, params) => {
22576
- const json3 = _json;
22583
+ const json4 = _json;
22577
22584
  const def = schema._zod.def;
22578
- json3.type = "object";
22585
+ json4.type = "object";
22579
22586
  const keyType = def.keyType;
22580
22587
  const patterns = aggregateChecks(keyType).patterns;
22581
22588
  if (def.mode === "loose" && patterns && patterns.size > 0) {
@@ -22583,13 +22590,13 @@ var recordProcessor = (schema, ctx, _json, params) => {
22583
22590
  ...params,
22584
22591
  path: [...params.path, "patternProperties", "*"]
22585
22592
  });
22586
- json3.patternProperties = {};
22593
+ json4.patternProperties = {};
22587
22594
  for (const pattern of patterns) {
22588
- assignProp(json3.patternProperties, exactPattern(pattern).source, valueSchema);
22595
+ assignProp(json4.patternProperties, exactPattern(pattern).source, valueSchema);
22589
22596
  }
22590
22597
  } else {
22591
22598
  if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
22592
- json3.propertyNames = processSchema(def.keyType, ctx, {
22599
+ json4.propertyNames = processSchema(def.keyType, ctx, {
22593
22600
  ...params,
22594
22601
  path: [...params.path, "propertyNames"]
22595
22602
  });
@@ -22601,7 +22608,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
22601
22608
  }
22602
22609
  pending.push(schema);
22603
22610
  }
22604
- json3.additionalProperties = processSchema(def.valueType, ctx, {
22611
+ json4.additionalProperties = processSchema(def.valueType, ctx, {
22605
22612
  ...params,
22606
22613
  path: [...params.path, "additionalProperties"]
22607
22614
  });
@@ -22611,19 +22618,19 @@ var recordProcessor = (schema, ctx, _json, params) => {
22611
22618
  if (keyValues && !def.partial && !omittableOnInput) {
22612
22619
  const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
22613
22620
  if (validKeyValues.length > 0) {
22614
- json3.required = validKeyValues.map(String);
22621
+ json4.required = validKeyValues.map(String);
22615
22622
  }
22616
22623
  }
22617
22624
  };
22618
- var nullableProcessor = (schema, ctx, json3, params) => {
22625
+ var nullableProcessor = (schema, ctx, json4, params) => {
22619
22626
  const def = schema._zod.def;
22620
22627
  const inner = processSchema(def.innerType, ctx, params);
22621
22628
  const seen = ctx.seen.get(schema);
22622
22629
  if (ctx.target === "openapi-3.0") {
22623
22630
  seen.ref = def.innerType;
22624
- json3.nullable = true;
22631
+ json4.nullable = true;
22625
22632
  } else {
22626
- json3.anyOf = [inner, { type: "null" }];
22633
+ json4.anyOf = [inner, { type: "null" }];
22627
22634
  }
22628
22635
  };
22629
22636
  var nonoptionalProcessor = (schema, ctx, _json, params) => {
@@ -22633,7 +22640,7 @@ var nonoptionalProcessor = (schema, ctx, _json, params) => {
22633
22640
  seen.ref = def.innerType;
22634
22641
  };
22635
22642
  var UNREPRESENTABLE_DEFAULT = /* @__PURE__ */ Symbol();
22636
- function serializeDefaultValue(value, schema, ctx, json3, params) {
22643
+ function serializeDefaultValue(value, schema, ctx, json4, params) {
22637
22644
  let unrepresentable = false;
22638
22645
  const serialized = JSON.stringify(value, (_, val) => {
22639
22646
  if (typeof val !== "bigint")
@@ -22643,30 +22650,30 @@ function serializeDefaultValue(value, schema, ctx, json3, params) {
22643
22650
  });
22644
22651
  if (!unrepresentable)
22645
22652
  return JSON.parse(serialized);
22646
- handleUnrepresentable(schema, ctx, json3, params, "BigInt defaults cannot be represented in JSON Schema");
22653
+ handleUnrepresentable(schema, ctx, json4, params, "BigInt defaults cannot be represented in JSON Schema");
22647
22654
  return UNREPRESENTABLE_DEFAULT;
22648
22655
  }
22649
- var defaultProcessor = (schema, ctx, json3, params) => {
22656
+ var defaultProcessor = (schema, ctx, json4, params) => {
22650
22657
  const def = schema._zod.def;
22651
22658
  processSchema(def.innerType, ctx, params);
22652
22659
  const seen = ctx.seen.get(schema);
22653
22660
  seen.ref = def.innerType;
22654
- const value = serializeDefaultValue(def.defaultValue, schema, ctx, json3, params);
22661
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json4, params);
22655
22662
  if (value !== UNREPRESENTABLE_DEFAULT)
22656
- json3.default = value;
22663
+ json4.default = value;
22657
22664
  };
22658
- var prefaultProcessor = (schema, ctx, json3, params) => {
22665
+ var prefaultProcessor = (schema, ctx, json4, params) => {
22659
22666
  const def = schema._zod.def;
22660
22667
  processSchema(def.innerType, ctx, params);
22661
22668
  const seen = ctx.seen.get(schema);
22662
22669
  seen.ref = def.innerType;
22663
22670
  if (ctx.io !== "input")
22664
22671
  return;
22665
- const value = serializeDefaultValue(def.defaultValue, schema, ctx, json3, params);
22672
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json4, params);
22666
22673
  if (value !== UNREPRESENTABLE_DEFAULT)
22667
- json3._prefault = value;
22674
+ json4._prefault = value;
22668
22675
  };
22669
- var catchProcessor = (schema, ctx, json3, params) => {
22676
+ var catchProcessor = (schema, ctx, json4, params) => {
22670
22677
  const def = schema._zod.def;
22671
22678
  processSchema(def.innerType, ctx, params);
22672
22679
  const seen = ctx.seen.get(schema);
@@ -22675,10 +22682,10 @@ var catchProcessor = (schema, ctx, json3, params) => {
22675
22682
  try {
22676
22683
  catchValue = def.catchValue(void 0);
22677
22684
  } catch {
22678
- handleUnrepresentable(schema, ctx, json3, params, "Dynamic catch values are not supported in JSON Schema");
22685
+ handleUnrepresentable(schema, ctx, json4, params, "Dynamic catch values are not supported in JSON Schema");
22679
22686
  return;
22680
22687
  }
22681
- json3.default = catchValue;
22688
+ json4.default = catchValue;
22682
22689
  };
22683
22690
  var pipeProcessor = (schema, ctx, _json, params) => {
22684
22691
  const def = schema._zod.def;
@@ -22688,12 +22695,12 @@ var pipeProcessor = (schema, ctx, _json, params) => {
22688
22695
  const seen = ctx.seen.get(schema);
22689
22696
  seen.ref = innerType;
22690
22697
  };
22691
- var readonlyProcessor = (schema, ctx, json3, params) => {
22698
+ var readonlyProcessor = (schema, ctx, json4, params) => {
22692
22699
  const def = schema._zod.def;
22693
22700
  processSchema(def.innerType, ctx, params);
22694
22701
  const seen = ctx.seen.get(schema);
22695
22702
  seen.ref = def.innerType;
22696
- json3.readOnly = true;
22703
+ json4.readOnly = true;
22697
22704
  };
22698
22705
  var promiseProcessor = (schema, ctx, _json, params) => {
22699
22706
  const def = schema._zod.def;
@@ -23335,7 +23342,7 @@ var _ZodString = /* @__PURE__ */ $constructor(
23335
23342
  (inst, def) => {
23336
23343
  $ZodString.init(inst, def);
23337
23344
  ZodType.init(inst, def);
23338
- inst._zod.processJSONSchema = (ctx, json3, params) => stringProcessor(inst, ctx, json3, params);
23345
+ inst._zod.processJSONSchema = (ctx, json4, params) => stringProcessor(inst, ctx, json4, params);
23339
23346
  },
23340
23347
  /* @__PURE__ */ util_exports.derived({
23341
23348
  format: (inst) => aggregateChecks(inst).format ?? null,
@@ -23694,7 +23701,7 @@ var ZodNumber = /* @__PURE__ */ $constructor(
23694
23701
  (inst, def) => {
23695
23702
  $ZodNumber.init(inst, def);
23696
23703
  ZodType.init(inst, def);
23697
- inst._zod.processJSONSchema = (ctx, json3, params) => numberProcessor(inst, ctx, json3, params);
23704
+ inst._zod.processJSONSchema = (ctx, json4, params) => numberProcessor(inst, ctx, json4, params);
23698
23705
  inst.isFinite = true;
23699
23706
  },
23700
23707
  /* @__PURE__ */ util_exports.derived({
@@ -23784,7 +23791,7 @@ function uint32(params) {
23784
23791
  var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
23785
23792
  $ZodBoolean.init(inst, def);
23786
23793
  ZodType.init(inst, def);
23787
- inst._zod.processJSONSchema = (ctx, json3, params) => booleanProcessor(inst, ctx, json3, params);
23794
+ inst._zod.processJSONSchema = (ctx, json4, params) => booleanProcessor(inst, ctx, json4, params);
23788
23795
  });
23789
23796
  function boolean2(params) {
23790
23797
  return _boolean(ZodBoolean, params);
@@ -23794,7 +23801,7 @@ var ZodBigInt = /* @__PURE__ */ $constructor(
23794
23801
  (inst, def) => {
23795
23802
  $ZodBigInt.init(inst, def);
23796
23803
  ZodType.init(inst, def);
23797
- inst._zod.processJSONSchema = (ctx, json3, params) => bigintProcessor(inst, ctx, json3, params);
23804
+ inst._zod.processJSONSchema = (ctx, json4, params) => bigintProcessor(inst, ctx, json4, params);
23798
23805
  },
23799
23806
  /* @__PURE__ */ util_exports.derived({
23800
23807
  minValue: (inst) => aggregateChecks(inst).minimum ?? null,
@@ -23852,7 +23859,7 @@ function uint64(params) {
23852
23859
  var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
23853
23860
  $ZodSymbol.init(inst, def);
23854
23861
  ZodType.init(inst, def);
23855
- inst._zod.processJSONSchema = (ctx, json3, params) => symbolProcessor(inst, ctx, json3, params);
23862
+ inst._zod.processJSONSchema = (ctx, json4, params) => symbolProcessor(inst, ctx, json4, params);
23856
23863
  });
23857
23864
  function symbol(params) {
23858
23865
  return _symbol(ZodSymbol, params);
@@ -23860,7 +23867,7 @@ function symbol(params) {
23860
23867
  var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
23861
23868
  $ZodUndefined.init(inst, def);
23862
23869
  ZodType.init(inst, def);
23863
- inst._zod.processJSONSchema = (ctx, json3, params) => undefinedProcessor(inst, ctx, json3, params);
23870
+ inst._zod.processJSONSchema = (ctx, json4, params) => undefinedProcessor(inst, ctx, json4, params);
23864
23871
  });
23865
23872
  function _undefined3(params) {
23866
23873
  return _undefined2(ZodUndefined, params);
@@ -23868,7 +23875,7 @@ function _undefined3(params) {
23868
23875
  var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
23869
23876
  $ZodNull.init(inst, def);
23870
23877
  ZodType.init(inst, def);
23871
- inst._zod.processJSONSchema = (ctx, json3, params) => nullProcessor(inst, ctx, json3, params);
23878
+ inst._zod.processJSONSchema = (ctx, json4, params) => nullProcessor(inst, ctx, json4, params);
23872
23879
  });
23873
23880
  function _null3(params) {
23874
23881
  return _null2(ZodNull, params);
@@ -23876,7 +23883,7 @@ function _null3(params) {
23876
23883
  var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
23877
23884
  $ZodAny.init(inst, def);
23878
23885
  ZodType.init(inst, def);
23879
- inst._zod.processJSONSchema = (ctx, json3, params) => anyProcessor(inst, ctx, json3, params);
23886
+ inst._zod.processJSONSchema = (ctx, json4, params) => anyProcessor(inst, ctx, json4, params);
23880
23887
  });
23881
23888
  function any() {
23882
23889
  return _any(ZodAny);
@@ -23884,7 +23891,7 @@ function any() {
23884
23891
  var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
23885
23892
  $ZodUnknown.init(inst, def);
23886
23893
  ZodType.init(inst, def);
23887
- inst._zod.processJSONSchema = (ctx, json3, params) => unknownProcessor(inst, ctx, json3, params);
23894
+ inst._zod.processJSONSchema = (ctx, json4, params) => unknownProcessor(inst, ctx, json4, params);
23888
23895
  });
23889
23896
  function unknown() {
23890
23897
  return _unknown(ZodUnknown);
@@ -23892,7 +23899,7 @@ function unknown() {
23892
23899
  var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
23893
23900
  $ZodNever.init(inst, def);
23894
23901
  ZodType.init(inst, def);
23895
- inst._zod.processJSONSchema = (ctx, json3, params) => neverProcessor(inst, ctx, json3, params);
23902
+ inst._zod.processJSONSchema = (ctx, json4, params) => neverProcessor(inst, ctx, json4, params);
23896
23903
  });
23897
23904
  function never(params) {
23898
23905
  return _never(ZodNever, params);
@@ -23900,7 +23907,7 @@ function never(params) {
23900
23907
  var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
23901
23908
  $ZodVoid.init(inst, def);
23902
23909
  ZodType.init(inst, def);
23903
- inst._zod.processJSONSchema = (ctx, json3, params) => voidProcessor(inst, ctx, json3, params);
23910
+ inst._zod.processJSONSchema = (ctx, json4, params) => voidProcessor(inst, ctx, json4, params);
23904
23911
  });
23905
23912
  function _void2(params) {
23906
23913
  return _void(ZodVoid, params);
@@ -23910,7 +23917,7 @@ var ZodDate = /* @__PURE__ */ $constructor(
23910
23917
  (inst, def) => {
23911
23918
  $ZodDate.init(inst, def);
23912
23919
  ZodType.init(inst, def);
23913
- inst._zod.processJSONSchema = (ctx, json3, params) => dateProcessor(inst, ctx, json3, params);
23920
+ inst._zod.processJSONSchema = (ctx, json4, params) => dateProcessor(inst, ctx, json4, params);
23914
23921
  inst.min = (value, params) => inst.check(_gte(value, params));
23915
23922
  inst.max = (value, params) => inst.check(_lte(value, params));
23916
23923
  },
@@ -23932,7 +23939,7 @@ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
23932
23939
  _ensureDefaultMemoizer();
23933
23940
  $ZodArray.init(inst, def);
23934
23941
  ZodType.init(inst, def);
23935
- inst._zod.processJSONSchema = (ctx, json3, params) => arrayProcessor(inst, ctx, json3, params);
23942
+ inst._zod.processJSONSchema = (ctx, json4, params) => arrayProcessor(inst, ctx, json4, params);
23936
23943
  inst.element = def.element;
23937
23944
  }, {
23938
23945
  min(n, params) {
@@ -23962,7 +23969,7 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
23962
23969
  _ensureDefaultMemoizer();
23963
23970
  $ZodObjectJIT.init(inst, def);
23964
23971
  ZodType.init(inst, def);
23965
- inst._zod.processJSONSchema = (ctx, json3, params) => objectProcessor(inst, ctx, json3, params);
23972
+ inst._zod.processJSONSchema = (ctx, json4, params) => objectProcessor(inst, ctx, json4, params);
23966
23973
  util_exports.installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
23967
23974
  }, {
23968
23975
  keyof() {
@@ -24035,7 +24042,7 @@ function looseObject(shape, params) {
24035
24042
  var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
24036
24043
  $ZodUnion.init(inst, def);
24037
24044
  ZodType.init(inst, def);
24038
- inst._zod.processJSONSchema = (ctx, json3, params) => unionProcessor(inst, ctx, json3, params);
24045
+ inst._zod.processJSONSchema = (ctx, json4, params) => unionProcessor(inst, ctx, json4, params);
24039
24046
  inst.options = def.options;
24040
24047
  });
24041
24048
  function union(options, params) {
@@ -24048,7 +24055,7 @@ function union(options, params) {
24048
24055
  var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
24049
24056
  ZodUnion.init(inst, def);
24050
24057
  $ZodXor.init(inst, def);
24051
- inst._zod.processJSONSchema = (ctx, json3, params) => unionProcessor(inst, ctx, json3, params);
24058
+ inst._zod.processJSONSchema = (ctx, json4, params) => unionProcessor(inst, ctx, json4, params);
24052
24059
  inst.options = def.options;
24053
24060
  });
24054
24061
  function xor(options, params) {
@@ -24074,7 +24081,7 @@ function discriminatedUnion(discriminator, options, params) {
24074
24081
  var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
24075
24082
  $ZodIntersection.init(inst, def);
24076
24083
  ZodType.init(inst, def);
24077
- inst._zod.processJSONSchema = (ctx, json3, params) => intersectionProcessor(inst, ctx, json3, params);
24084
+ inst._zod.processJSONSchema = (ctx, json4, params) => intersectionProcessor(inst, ctx, json4, params);
24078
24085
  });
24079
24086
  function intersection(left, right) {
24080
24087
  return new ZodIntersection({
@@ -24087,7 +24094,7 @@ var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
24087
24094
  _ensureDefaultMemoizer();
24088
24095
  $ZodTuple.init(inst, def);
24089
24096
  ZodType.init(inst, def);
24090
- inst._zod.processJSONSchema = (ctx, json3, params) => tupleProcessor(inst, ctx, json3, params);
24097
+ inst._zod.processJSONSchema = (ctx, json4, params) => tupleProcessor(inst, ctx, json4, params);
24091
24098
  }, {
24092
24099
  rest(rest) {
24093
24100
  return this.clone({
@@ -24120,7 +24127,7 @@ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
24120
24127
  _ensureDefaultMemoizer();
24121
24128
  $ZodRecord.init(inst, def);
24122
24129
  ZodType.init(inst, def);
24123
- inst._zod.processJSONSchema = (ctx, json3, params) => recordProcessor(inst, ctx, json3, params);
24130
+ inst._zod.processJSONSchema = (ctx, json4, params) => recordProcessor(inst, ctx, json4, params);
24124
24131
  inst.keyType = def.keyType;
24125
24132
  inst.valueType = def.valueType;
24126
24133
  });
@@ -24162,7 +24169,7 @@ var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
24162
24169
  _ensureDefaultMemoizer();
24163
24170
  $ZodMap.init(inst, def);
24164
24171
  ZodType.init(inst, def);
24165
- inst._zod.processJSONSchema = (ctx, json3, params) => mapProcessor(inst, ctx, json3, params);
24172
+ inst._zod.processJSONSchema = (ctx, json4, params) => mapProcessor(inst, ctx, json4, params);
24166
24173
  inst.keyType = def.keyType;
24167
24174
  inst.valueType = def.valueType;
24168
24175
  inst.min = (...args) => inst.check(_minSize(...args));
@@ -24182,7 +24189,7 @@ var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
24182
24189
  _ensureDefaultMemoizer();
24183
24190
  $ZodSet.init(inst, def);
24184
24191
  ZodType.init(inst, def);
24185
- inst._zod.processJSONSchema = (ctx, json3, params) => setProcessor(inst, ctx, json3, params);
24192
+ inst._zod.processJSONSchema = (ctx, json4, params) => setProcessor(inst, ctx, json4, params);
24186
24193
  inst.min = (...args) => inst.check(_minSize(...args));
24187
24194
  inst.nonempty = (params) => inst.check(_minSize(1, params));
24188
24195
  inst.max = (...args) => inst.check(_maxSize(...args));
@@ -24198,7 +24205,7 @@ function set(valueType, params) {
24198
24205
  var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
24199
24206
  $ZodEnum.init(inst, def);
24200
24207
  ZodType.init(inst, def);
24201
- inst._zod.processJSONSchema = (ctx, json3, params) => enumProcessor(inst, ctx, json3, params);
24208
+ inst._zod.processJSONSchema = (ctx, json4, params) => enumProcessor(inst, ctx, json4, params);
24202
24209
  inst.enum = def.entries;
24203
24210
  inst.options = [...inst._zod.values];
24204
24211
  const keys = new Set(Object.keys(def.entries));
@@ -24251,7 +24258,7 @@ function nativeEnum(entries, params) {
24251
24258
  var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
24252
24259
  $ZodLiteral.init(inst, def);
24253
24260
  ZodType.init(inst, def);
24254
- inst._zod.processJSONSchema = (ctx, json3, params) => literalProcessor(inst, ctx, json3, params);
24261
+ inst._zod.processJSONSchema = (ctx, json4, params) => literalProcessor(inst, ctx, json4, params);
24255
24262
  inst.values = new Set(def.values);
24256
24263
  Object.defineProperty(inst, "value", {
24257
24264
  get() {
@@ -24272,7 +24279,7 @@ function literal(value, params) {
24272
24279
  var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
24273
24280
  $ZodFile.init(inst, def);
24274
24281
  ZodType.init(inst, def);
24275
- inst._zod.processJSONSchema = (ctx, json3, params) => fileProcessor(inst, ctx, json3, params);
24282
+ inst._zod.processJSONSchema = (ctx, json4, params) => fileProcessor(inst, ctx, json4, params);
24276
24283
  inst.min = (size, params) => inst.check(_minSize(size, params));
24277
24284
  inst.max = (size, params) => inst.check(_maxSize(size, params));
24278
24285
  inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
@@ -24284,7 +24291,7 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
24284
24291
  _ensureDefaultMemoizer();
24285
24292
  $ZodTransform.init(inst, def);
24286
24293
  ZodType.init(inst, def);
24287
- inst._zod.processJSONSchema = (ctx, json3, params) => transformProcessor(inst, ctx, json3, params);
24294
+ inst._zod.processJSONSchema = (ctx, json4, params) => transformProcessor(inst, ctx, json4, params);
24288
24295
  inst._zod.parse = (payload, _ctx) => {
24289
24296
  if (_ctx.direction === "backward") {
24290
24297
  throw new $ZodEncodeError(inst.constructor.name);
@@ -24323,7 +24330,7 @@ function transform(fn) {
24323
24330
  var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
24324
24331
  $ZodOptional.init(inst, def);
24325
24332
  ZodType.init(inst, def);
24326
- inst._zod.processJSONSchema = (ctx, json3, params) => optionalProcessor(inst, ctx, json3, params);
24333
+ inst._zod.processJSONSchema = (ctx, json4, params) => optionalProcessor(inst, ctx, json4, params);
24327
24334
  inst.unwrap = () => inst._zod.def.innerType;
24328
24335
  });
24329
24336
  function optional(innerType) {
@@ -24335,7 +24342,7 @@ function optional(innerType) {
24335
24342
  var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
24336
24343
  $ZodExactOptional.init(inst, def);
24337
24344
  ZodType.init(inst, def);
24338
- inst._zod.processJSONSchema = (ctx, json3, params) => optionalProcessor(inst, ctx, json3, params);
24345
+ inst._zod.processJSONSchema = (ctx, json4, params) => optionalProcessor(inst, ctx, json4, params);
24339
24346
  inst.unwrap = () => inst._zod.def.innerType;
24340
24347
  });
24341
24348
  function exactOptional(innerType) {
@@ -24347,7 +24354,7 @@ function exactOptional(innerType) {
24347
24354
  var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
24348
24355
  $ZodNullable.init(inst, def);
24349
24356
  ZodType.init(inst, def);
24350
- inst._zod.processJSONSchema = (ctx, json3, params) => nullableProcessor(inst, ctx, json3, params);
24357
+ inst._zod.processJSONSchema = (ctx, json4, params) => nullableProcessor(inst, ctx, json4, params);
24351
24358
  inst.unwrap = () => inst._zod.def.innerType;
24352
24359
  });
24353
24360
  function nullable(innerType) {
@@ -24362,7 +24369,7 @@ function nullish2(innerType) {
24362
24369
  var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
24363
24370
  $ZodDefault.init(inst, def);
24364
24371
  ZodType.init(inst, def);
24365
- inst._zod.processJSONSchema = (ctx, json3, params) => defaultProcessor(inst, ctx, json3, params);
24372
+ inst._zod.processJSONSchema = (ctx, json4, params) => defaultProcessor(inst, ctx, json4, params);
24366
24373
  inst.unwrap = () => inst._zod.def.innerType;
24367
24374
  inst.removeDefault = inst.unwrap;
24368
24375
  });
@@ -24378,7 +24385,7 @@ function _default2(innerType, defaultValue) {
24378
24385
  var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
24379
24386
  $ZodPrefault.init(inst, def);
24380
24387
  ZodType.init(inst, def);
24381
- inst._zod.processJSONSchema = (ctx, json3, params) => prefaultProcessor(inst, ctx, json3, params);
24388
+ inst._zod.processJSONSchema = (ctx, json4, params) => prefaultProcessor(inst, ctx, json4, params);
24382
24389
  inst.unwrap = () => inst._zod.def.innerType;
24383
24390
  });
24384
24391
  function prefault(innerType, defaultValue) {
@@ -24393,7 +24400,7 @@ function prefault(innerType, defaultValue) {
24393
24400
  var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
24394
24401
  $ZodNonOptional.init(inst, def);
24395
24402
  ZodType.init(inst, def);
24396
- inst._zod.processJSONSchema = (ctx, json3, params) => nonoptionalProcessor(inst, ctx, json3, params);
24403
+ inst._zod.processJSONSchema = (ctx, json4, params) => nonoptionalProcessor(inst, ctx, json4, params);
24397
24404
  inst.unwrap = () => inst._zod.def.innerType;
24398
24405
  });
24399
24406
  function nonoptional(innerType, params) {
@@ -24406,7 +24413,7 @@ function nonoptional(innerType, params) {
24406
24413
  var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
24407
24414
  $ZodSuccess.init(inst, def);
24408
24415
  ZodType.init(inst, def);
24409
- inst._zod.processJSONSchema = (ctx, json3, params) => successProcessor(inst, ctx, json3, params);
24416
+ inst._zod.processJSONSchema = (ctx, json4, params) => successProcessor(inst, ctx, json4, params);
24410
24417
  inst.unwrap = () => inst._zod.def.innerType;
24411
24418
  });
24412
24419
  function success(innerType) {
@@ -24418,7 +24425,7 @@ function success(innerType) {
24418
24425
  var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
24419
24426
  $ZodCatch.init(inst, def);
24420
24427
  ZodType.init(inst, def);
24421
- inst._zod.processJSONSchema = (ctx, json3, params) => catchProcessor(inst, ctx, json3, params);
24428
+ inst._zod.processJSONSchema = (ctx, json4, params) => catchProcessor(inst, ctx, json4, params);
24422
24429
  inst.unwrap = () => inst._zod.def.innerType;
24423
24430
  inst.removeCatch = inst.unwrap;
24424
24431
  });
@@ -24432,7 +24439,7 @@ function _catch2(innerType, catchValue) {
24432
24439
  var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
24433
24440
  $ZodNaN.init(inst, def);
24434
24441
  ZodType.init(inst, def);
24435
- inst._zod.processJSONSchema = (ctx, json3, params) => nanProcessor(inst, ctx, json3, params);
24442
+ inst._zod.processJSONSchema = (ctx, json4, params) => nanProcessor(inst, ctx, json4, params);
24436
24443
  });
24437
24444
  function nan(params) {
24438
24445
  return _nan(ZodNaN, params);
@@ -24440,7 +24447,7 @@ function nan(params) {
24440
24447
  var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
24441
24448
  $ZodPipe.init(inst, def);
24442
24449
  ZodType.init(inst, def);
24443
- inst._zod.processJSONSchema = (ctx, json3, params) => pipeProcessor(inst, ctx, json3, params);
24450
+ inst._zod.processJSONSchema = (ctx, json4, params) => pipeProcessor(inst, ctx, json4, params);
24444
24451
  inst.in = def.in;
24445
24452
  inst.out = def.out;
24446
24453
  });
@@ -24482,7 +24489,7 @@ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) =>
24482
24489
  var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
24483
24490
  $ZodReadonly.init(inst, def);
24484
24491
  ZodType.init(inst, def);
24485
- inst._zod.processJSONSchema = (ctx, json3, params) => readonlyProcessor(inst, ctx, json3, params);
24492
+ inst._zod.processJSONSchema = (ctx, json4, params) => readonlyProcessor(inst, ctx, json4, params);
24486
24493
  inst.unwrap = () => inst._zod.def.innerType;
24487
24494
  });
24488
24495
  function readonly(innerType) {
@@ -24494,7 +24501,7 @@ function readonly(innerType) {
24494
24501
  var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
24495
24502
  $ZodTemplateLiteral.init(inst, def);
24496
24503
  ZodType.init(inst, def);
24497
- inst._zod.processJSONSchema = (ctx, json3, params) => templateLiteralProcessor(inst, ctx, json3, params);
24504
+ inst._zod.processJSONSchema = (ctx, json4, params) => templateLiteralProcessor(inst, ctx, json4, params);
24498
24505
  });
24499
24506
  function templateLiteral(parts, params) {
24500
24507
  return new ZodTemplateLiteral({
@@ -24506,7 +24513,7 @@ function templateLiteral(parts, params) {
24506
24513
  var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
24507
24514
  $ZodLazy.init(inst, def);
24508
24515
  ZodType.init(inst, def);
24509
- inst._zod.processJSONSchema = (ctx, json3, params) => lazyProcessor(inst, ctx, json3, params);
24516
+ inst._zod.processJSONSchema = (ctx, json4, params) => lazyProcessor(inst, ctx, json4, params);
24510
24517
  inst.unwrap = () => inst._zod.def.getter();
24511
24518
  });
24512
24519
  function lazy(getter) {
@@ -24518,7 +24525,7 @@ function lazy(getter) {
24518
24525
  var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
24519
24526
  $ZodPromise.init(inst, def);
24520
24527
  ZodType.init(inst, def);
24521
- inst._zod.processJSONSchema = (ctx, json3, params) => promiseProcessor(inst, ctx, json3, params);
24528
+ inst._zod.processJSONSchema = (ctx, json4, params) => promiseProcessor(inst, ctx, json4, params);
24522
24529
  inst.unwrap = () => inst._zod.def.innerType;
24523
24530
  });
24524
24531
  function promise(innerType) {
@@ -24530,7 +24537,7 @@ function promise(innerType) {
24530
24537
  var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
24531
24538
  $ZodFunction.init(inst, def);
24532
24539
  ZodType.init(inst, def);
24533
- inst._zod.processJSONSchema = (ctx, json3, params) => functionProcessor(inst, ctx, json3, params);
24540
+ inst._zod.processJSONSchema = (ctx, json4, params) => functionProcessor(inst, ctx, json4, params);
24534
24541
  });
24535
24542
  function _function(params) {
24536
24543
  return new ZodFunction({
@@ -24542,7 +24549,7 @@ function _function(params) {
24542
24549
  var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
24543
24550
  $ZodCustom.init(inst, def);
24544
24551
  ZodType.init(inst, def);
24545
- inst._zod.processJSONSchema = (ctx, json3, params) => customProcessor(inst, ctx, json3, params);
24552
+ inst._zod.processJSONSchema = (ctx, json4, params) => customProcessor(inst, ctx, json4, params);
24546
24553
  });
24547
24554
  function check(fn) {
24548
24555
  const ch = new $ZodCheck({
@@ -25774,153 +25781,6 @@ var GitHub = class {
25774
25781
  }
25775
25782
  };
25776
25783
 
25777
- // ../server/src/actions.ts
25778
- async function setFileViewed(gh, prId, path, viewed) {
25779
- const mutation = viewed ? "markFileAsViewed" : "unmarkFileAsViewed";
25780
- await gh.graphql(
25781
- `mutation($id: ID!, $path: String!) { ${mutation}(input: { pullRequestId: $id, path: $path }) { clientMutationId } }`,
25782
- { id: prId, path }
25783
- );
25784
- }
25785
- async function replyToThread(gh, threadId, body, pendingReviewId) {
25786
- const data = await gh.graphql(
25787
- `mutation($thread: ID!, $body: String!, $review: ID) {
25788
- addPullRequestReviewThreadReply(input: { pullRequestReviewThreadId: $thread, body: $body, pullRequestReviewId: $review }) {
25789
- comment { id }
25790
- }
25791
- }`,
25792
- { thread: threadId, body, review: pendingReviewId }
25793
- );
25794
- return data.addPullRequestReviewThreadReply.comment.id;
25795
- }
25796
- async function setThreadResolved(gh, threadId, resolved) {
25797
- const mutation = resolved ? "resolveReviewThread" : "unresolveReviewThread";
25798
- await gh.graphql(`mutation($id: ID!) { ${mutation}(input: { threadId: $id }) { thread { id } } }`, {
25799
- id: threadId
25800
- });
25801
- }
25802
- function threadInput(t2) {
25803
- if (t2.subjectType === "FILE") return { path: t2.path, body: t2.body, subjectType: "FILE" };
25804
- return {
25805
- path: t2.path,
25806
- body: t2.body,
25807
- subjectType: "LINE",
25808
- line: t2.line,
25809
- side: t2.side,
25810
- ...t2.startLine !== null && t2.startLine !== t2.line ? { startLine: t2.startLine, startSide: t2.startSide ?? t2.side } : {}
25811
- };
25812
- }
25813
- async function addThread(gh, prId, pendingReviewId, thread, mode) {
25814
- if (mode === "single" && pendingReviewId) {
25815
- throw new GitHubError(
25816
- "Une review est en attente : ajoutez le commentaire \xE0 la review ou soumettez-la d\u2019abord.",
25817
- 409
25818
- );
25819
- }
25820
- let reviewId = pendingReviewId;
25821
- if (!reviewId) {
25822
- const created = await gh.graphql(
25823
- `mutation($id: ID!) { addPullRequestReview(input: { pullRequestId: $id }) { pullRequestReview { id } } }`,
25824
- { id: prId }
25825
- );
25826
- reviewId = created.addPullRequestReview.pullRequestReview.id;
25827
- }
25828
- try {
25829
- await gh.graphql(
25830
- `mutation($input: AddPullRequestReviewThreadInput!) { addPullRequestReviewThread(input: $input) { thread { id } } }`,
25831
- { input: { pullRequestReviewId: reviewId, ...threadInput(thread) } }
25832
- );
25833
- } catch (error62) {
25834
- if (!pendingReviewId) await discardReview(gh, reviewId).catch(() => void 0);
25835
- throw error62;
25836
- }
25837
- if (mode === "single") await submitReview(gh, prId, reviewId, "COMMENT", "");
25838
- }
25839
- async function submitReview(gh, prId, pendingReviewId, event, body) {
25840
- if (pendingReviewId) {
25841
- await gh.graphql(
25842
- `mutation($id: ID!, $event: PullRequestReviewEvent!, $body: String) {
25843
- submitPullRequestReview(input: { pullRequestReviewId: $id, event: $event, body: $body }) { pullRequestReview { id } }
25844
- }`,
25845
- { id: pendingReviewId, event, body: body || null }
25846
- );
25847
- return;
25848
- }
25849
- await gh.graphql(
25850
- `mutation($input: AddPullRequestReviewInput!) { addPullRequestReview(input: $input) { pullRequestReview { id } } }`,
25851
- { input: { pullRequestId: prId, event, ...body ? { body } : {} } }
25852
- );
25853
- }
25854
- async function discardReview(gh, reviewId) {
25855
- await gh.graphql(
25856
- `mutation($id: ID!) { deletePullRequestReview(input: { pullRequestReviewId: $id }) { pullRequestReview { id } } }`,
25857
- { id: reviewId }
25858
- );
25859
- }
25860
- async function addIssueComment(gh, subjectId, body) {
25861
- await gh.graphql(
25862
- `mutation($id: ID!, $body: String!) { addComment(input: { subjectId: $id, body: $body }) { clientMutationId } }`,
25863
- {
25864
- id: subjectId,
25865
- body
25866
- }
25867
- );
25868
- }
25869
- async function deleteReviewComment(gh, commentId) {
25870
- await gh.graphql(
25871
- `mutation($id: ID!) { deletePullRequestReviewComment(input: { id: $id }) { clientMutationId } }`,
25872
- { id: commentId }
25873
- );
25874
- }
25875
- async function updateReviewComment(gh, commentId, body) {
25876
- await gh.graphql(
25877
- `mutation($id: ID!, $body: String!) {
25878
- updatePullRequestReviewComment(input: { pullRequestReviewCommentId: $id, body: $body }) { clientMutationId }
25879
- }`,
25880
- { id: commentId, body }
25881
- );
25882
- }
25883
- async function applySuggestion(gh, ref, input2) {
25884
- const branch = await gh.rest(
25885
- `/repos/${ref.owner}/${ref.repo}/branches/${encodeURIComponent(input2.branch)}`
25886
- );
25887
- if (branch.commit.sha !== input2.expectedHeadOid) {
25888
- throw new GitHubError(
25889
- "La branche a boug\xE9 depuis le chargement de la PR : rechargez avant d\u2019appliquer.",
25890
- 409
25891
- );
25892
- }
25893
- const encodedPath = input2.path.split("/").map(encodeURIComponent).join("/");
25894
- const file2 = await gh.rest(
25895
- `/repos/${ref.owner}/${ref.repo}/contents/${encodedPath}?ref=${input2.expectedHeadOid}`
25896
- );
25897
- const text = Buffer.from(file2.content, "base64").toString("utf8");
25898
- const eol = text.includes("\r\n") ? "\r\n" : "\n";
25899
- const lines = text.split(eol);
25900
- if (input2.endLine > lines.length || input2.startLine < 1 || input2.startLine > input2.endLine) {
25901
- throw new GitHubError("Lignes de la suggestion hors du fichier.", 422);
25902
- }
25903
- const replacement = input2.replacement.replace(/\r?\n$/, "").split(/\r?\n/);
25904
- lines.splice(
25905
- input2.startLine - 1,
25906
- input2.endLine - input2.startLine + 1,
25907
- ...input2.replacement === "" ? [] : replacement
25908
- );
25909
- const res = await gh.rest(
25910
- `/repos/${ref.owner}/${ref.repo}/contents/${encodedPath}`,
25911
- {
25912
- method: "PUT",
25913
- body: {
25914
- message: input2.message,
25915
- content: Buffer.from(lines.join(eol), "utf8").toString("base64"),
25916
- sha: file2.sha,
25917
- branch: input2.branch
25918
- }
25919
- }
25920
- );
25921
- return res.commit.sha;
25922
- }
25923
-
25924
25784
  // ../server/src/github/queries.ts
25925
25785
  var PR_SUMMARY = (
25926
25786
  /* GraphQL */
@@ -26069,6 +25929,34 @@ var INBOX_FINGERPRINT_QUERY = (
26069
25929
  }
26070
25930
  `
26071
25931
  );
25932
+ var REVIEW_COMMENT_FIELDS = (
25933
+ /* GraphQL */
25934
+ `
25935
+ fragment ReviewCommentFields on PullRequestReviewComment {
25936
+ id
25937
+ databaseId
25938
+ url
25939
+ body
25940
+ bodyHTML
25941
+ createdAt
25942
+ state
25943
+ diffHunk
25944
+ author {
25945
+ login
25946
+ avatarUrl
25947
+ }
25948
+ originalCommit {
25949
+ oid
25950
+ }
25951
+ pullRequestReview {
25952
+ id
25953
+ state
25954
+ }
25955
+ viewerCanUpdate
25956
+ viewerCanDelete
25957
+ }
25958
+ `
25959
+ );
26072
25960
  var THREAD_FIELDS = (
26073
25961
  /* GraphQL */
26074
25962
  `
@@ -26092,30 +25980,11 @@ var THREAD_FIELDS = (
26092
25980
  viewerCanReply
26093
25981
  comments(first: 100) {
26094
25982
  nodes {
26095
- id
26096
- databaseId
26097
- url
26098
- body
26099
- bodyHTML
26100
- createdAt
26101
- state
26102
- diffHunk
26103
- author {
26104
- login
26105
- avatarUrl
26106
- }
26107
- originalCommit {
26108
- oid
26109
- }
26110
- pullRequestReview {
26111
- id
26112
- state
26113
- }
26114
- viewerCanUpdate
26115
- viewerCanDelete
25983
+ ...ReviewCommentFields
26116
25984
  }
26117
25985
  }
26118
25986
  }
25987
+ ${REVIEW_COMMENT_FIELDS}
26119
25988
  `
26120
25989
  );
26121
25990
  var PR_QUERY = (
@@ -26380,6 +26249,28 @@ var PR_FINGERPRINT_QUERY = (
26380
26249
  `
26381
26250
  );
26382
26251
 
26252
+ // ../server/src/github/blobs.ts
26253
+ var BATCH = 50;
26254
+ async function fetchTexts(gh, ref, expressions) {
26255
+ const texts = /* @__PURE__ */ new Map();
26256
+ for (let i = 0; i < expressions.length; i += BATCH) {
26257
+ const batch = expressions.slice(i, i + BATCH);
26258
+ const vars = { owner: ref.owner, repo: ref.repo };
26259
+ batch.forEach((e, k) => vars[`e${k}`] = e);
26260
+ const query = `query(${["$owner: String!", "$repo: String!", ...batch.map((_, k) => `$e${k}: String!`)].join(", ")}) {
26261
+ repository(owner: $owner, name: $repo) {
26262
+ ${batch.map((_, k) => `f${k}: object(expression: $e${k}) { ... on Blob { text isBinary isTruncated } }`).join("\n")}
26263
+ }
26264
+ }`;
26265
+ const data = await gh.graphql(query, vars);
26266
+ batch.forEach((e, k) => {
26267
+ const blob = data.repository[`f${k}`];
26268
+ texts.set(e, blob && !blob.isBinary && !blob.isTruncated ? blob.text : null);
26269
+ });
26270
+ }
26271
+ return texts;
26272
+ }
26273
+
26383
26274
  // ../server/src/inbox.ts
26384
26275
  var SCOPE_CHUNK = 20;
26385
26276
  function scopeChunks(config2) {
@@ -26695,8 +26586,8 @@ async function loadPr(gh, store, ref) {
26695
26586
  seenHunks: store.seenHunks(key)
26696
26587
  };
26697
26588
  }
26698
- function toThread(t2, me, lastReadId) {
26699
- const comments = t2.comments.nodes.map((c) => ({
26589
+ function toComment(c) {
26590
+ return {
26700
26591
  id: c.id,
26701
26592
  databaseId: c.databaseId,
26702
26593
  url: c.url,
@@ -26708,7 +26599,10 @@ function toThread(t2, me, lastReadId) {
26708
26599
  originalCommitOid: c.originalCommit?.oid ?? null,
26709
26600
  canUpdate: c.viewerCanUpdate,
26710
26601
  canDelete: c.viewerCanDelete
26711
- }));
26602
+ };
26603
+ }
26604
+ function toThread(t2, me, lastReadId) {
26605
+ const comments = t2.comments.nodes.map(toComment);
26712
26606
  const readIdx = lastReadId ? comments.findIndex((c) => c.id === lastReadId) : -1;
26713
26607
  const unread = comments.slice(readIdx + 1).filter((c) => c.author?.login !== me).length;
26714
26608
  return {
@@ -26748,6 +26642,7 @@ function restFilesToDiff(files) {
26748
26642
  if (f.status === "added") header.push("new file mode 100644");
26749
26643
  if (f.status === "removed") header.push("deleted file mode 100644");
26750
26644
  if (f.status === "renamed") header.push(`rename from ${oldPath}`, `rename to ${f.filename}`);
26645
+ if (f.sha && f.status !== "removed") header.push(`index 0000000..${f.sha}`);
26751
26646
  if (f.patch !== void 0) {
26752
26647
  header.push(
26753
26648
  f.status === "added" ? "--- /dev/null" : `--- a/${oldPath}`,
@@ -26774,9 +26669,9 @@ async function loadDiff(gh, store, ref, base, head, isFullPr) {
26774
26669
  const res = await gh.request(`/repos/${ref.owner}/${ref.repo}/compare/${base}...${head}`, {
26775
26670
  accept: "application/vnd.github.diff"
26776
26671
  });
26777
- const text = await res.text();
26778
- store.putDiff(cacheKey2, text);
26779
- return { base, head, files: parseUnifiedDiff(text), missingFiles: 0 };
26672
+ const text2 = await res.text();
26673
+ store.putDiff(cacheKey2, text2);
26674
+ return { base, head, files: parseUnifiedDiff(text2), missingFiles: 0 };
26780
26675
  } catch (error62) {
26781
26676
  if (!(error62 instanceof GitHubError) || error62.status === 404) throw error62;
26782
26677
  }
@@ -26797,53 +26692,391 @@ async function loadDiff(gh, store, ref, base, head, isFullPr) {
26797
26692
  const files = compare.files ?? [];
26798
26693
  return { base, head, files: restFilesToDiff(files), missingFiles: files.length >= 300 ? 1 : 0 };
26799
26694
  }
26800
-
26801
- // ../server/src/links/extract.ts
26802
- import ts from "typescript";
26803
-
26804
- // ../server/src/links/paths.ts
26805
- function normalizePath(path) {
26806
- const segments = [];
26807
- for (const segment of path.split("/")) {
26808
- if (segment === "" || segment === ".") continue;
26809
- if (segment !== "..") segments.push(segment);
26810
- else if (segments.pop() === void 0) return null;
26695
+ async function loadBlobs(gh, store, ref, oids) {
26696
+ const key = (oid) => `blob:${ref.owner}/${ref.repo}:${oid}`.toLowerCase();
26697
+ const out = {};
26698
+ const missing = [];
26699
+ for (const oid of oids) {
26700
+ const cached2 = store.getDiff(key(oid));
26701
+ if (cached2 === void 0) missing.push(oid);
26702
+ else out[oid] = JSON.parse(cached2);
26811
26703
  }
26812
- return segments.length > 0 ? segments.join("/") : null;
26813
- }
26814
- function joinPath(dir, relative2) {
26815
- return normalizePath(dir === "" ? relative2 : `${dir}/${relative2}`);
26816
- }
26817
- function dirname(path) {
26818
- const slash = path.lastIndexOf("/");
26819
- return slash === -1 ? "" : path.slice(0, slash);
26704
+ if (missing.length > 0) {
26705
+ const texts = await fetchTexts(gh, ref, missing);
26706
+ for (const oid of missing) {
26707
+ const text2 = texts.get(oid) ?? null;
26708
+ store.putDiff(key(oid), JSON.stringify(text2));
26709
+ out[oid] = text2;
26710
+ }
26711
+ }
26712
+ return out;
26820
26713
  }
26821
- function basename(path) {
26822
- return path.slice(path.lastIndexOf("/") + 1);
26714
+
26715
+ // ../server/src/actions.ts
26716
+ async function setFileViewed(gh, prId, path, viewed) {
26717
+ const mutation = viewed ? "markFileAsViewed" : "unmarkFileAsViewed";
26718
+ await gh.graphql(
26719
+ `mutation($id: ID!, $path: String!) { ${mutation}(input: { pullRequestId: $id, path: $path }) { clientMutationId } }`,
26720
+ { id: prId, path }
26721
+ );
26823
26722
  }
26824
- function extname(path) {
26825
- const name = basename(path);
26826
- const dot = name.lastIndexOf(".");
26827
- return dot > 0 ? name.slice(dot) : "";
26723
+ async function replyToThread(gh, threadId, body, pendingReviewId) {
26724
+ const data = await gh.graphql(
26725
+ `mutation($thread: ID!, $body: String!, $review: ID) {
26726
+ addPullRequestReviewThreadReply(input: { pullRequestReviewThreadId: $thread, body: $body, pullRequestReviewId: $review }) {
26727
+ comment { ...ReviewCommentFields }
26728
+ }
26729
+ }
26730
+ ${REVIEW_COMMENT_FIELDS}`,
26731
+ { thread: threadId, body, review: pendingReviewId }
26732
+ );
26733
+ return toComment(data.addPullRequestReviewThreadReply.comment);
26828
26734
  }
26829
- function fileStem(path) {
26830
- const name = basename(path);
26831
- if (name.endsWith(".d.ts")) return name.slice(0, -".d.ts".length);
26832
- const extension = extname(name);
26833
- return extension === "" ? name : name.slice(0, -extension.length);
26735
+ async function setThreadResolved(gh, threadId, resolved) {
26736
+ const mutation = resolved ? "resolveReviewThread" : "unresolveReviewThread";
26737
+ await gh.graphql(`mutation($id: ID!) { ${mutation}(input: { threadId: $id }) { thread { id } } }`, {
26738
+ id: threadId
26739
+ });
26834
26740
  }
26835
- function sharedPrefixLength(a, b) {
26836
- const left = a === "" ? [] : a.split("/");
26837
- const right = b === "" ? [] : b.split("/");
26838
- let count = 0;
26839
- while (count < left.length && count < right.length && left[count] === right[count]) count++;
26840
- return count;
26741
+ function threadInput(t2) {
26742
+ if (t2.subjectType === "FILE") return { path: t2.path, body: t2.body, subjectType: "FILE" };
26743
+ return {
26744
+ path: t2.path,
26745
+ body: t2.body,
26746
+ subjectType: "LINE",
26747
+ line: t2.line,
26748
+ side: t2.side,
26749
+ ...t2.startLine !== null && t2.startLine !== t2.line ? { startLine: t2.startLine, startSide: t2.startSide ?? t2.side } : {}
26750
+ };
26841
26751
  }
26842
-
26843
- // ../server/src/links/extract.ts
26844
- var SCRIPT_KIND_BY_EXTENSION = {
26845
- ".ts": ts.ScriptKind.TS,
26846
- ".mts": ts.ScriptKind.TS,
26752
+ async function addThread(gh, prId, pendingReviewId, thread, mode) {
26753
+ if (mode === "single" && pendingReviewId) {
26754
+ throw new GitHubError(
26755
+ "Une review est en attente : ajoutez le commentaire \xE0 la review ou soumettez-la d\u2019abord.",
26756
+ 409
26757
+ );
26758
+ }
26759
+ let reviewId = pendingReviewId;
26760
+ if (!reviewId) {
26761
+ const created2 = await gh.graphql(
26762
+ `mutation($id: ID!) { addPullRequestReview(input: { pullRequestId: $id }) { pullRequestReview { id } } }`,
26763
+ { id: prId }
26764
+ );
26765
+ reviewId = created2.addPullRequestReview.pullRequestReview.id;
26766
+ }
26767
+ let node2;
26768
+ try {
26769
+ const data = await gh.graphql(
26770
+ `mutation($input: AddPullRequestReviewThreadInput!) {
26771
+ addPullRequestReviewThread(input: $input) { thread { ...ThreadFields } }
26772
+ }
26773
+ ${THREAD_FIELDS}`,
26774
+ { input: { pullRequestReviewId: reviewId, ...threadInput(thread) } }
26775
+ );
26776
+ node2 = data.addPullRequestReviewThread.thread;
26777
+ } catch (error62) {
26778
+ if (!pendingReviewId) await discardReview(gh, reviewId).catch(() => void 0);
26779
+ throw error62;
26780
+ }
26781
+ const created = toThread(node2, "", node2.comments.nodes.at(-1)?.id);
26782
+ if (mode === "review") return { thread: created, pendingReviewId: reviewId };
26783
+ await submitReview(gh, prId, reviewId, "COMMENT", "");
26784
+ return {
26785
+ thread: { ...created, pending: false, comments: created.comments.map((c) => ({ ...c, pending: false })) },
26786
+ pendingReviewId: null
26787
+ };
26788
+ }
26789
+ async function submitReview(gh, prId, pendingReviewId, event, body) {
26790
+ if (pendingReviewId) {
26791
+ await gh.graphql(
26792
+ `mutation($id: ID!, $event: PullRequestReviewEvent!, $body: String) {
26793
+ submitPullRequestReview(input: { pullRequestReviewId: $id, event: $event, body: $body }) { pullRequestReview { id } }
26794
+ }`,
26795
+ { id: pendingReviewId, event, body: body || null }
26796
+ );
26797
+ return;
26798
+ }
26799
+ await gh.graphql(
26800
+ `mutation($input: AddPullRequestReviewInput!) { addPullRequestReview(input: $input) { pullRequestReview { id } } }`,
26801
+ { input: { pullRequestId: prId, event, ...body ? { body } : {} } }
26802
+ );
26803
+ }
26804
+ async function discardReview(gh, reviewId) {
26805
+ await gh.graphql(
26806
+ `mutation($id: ID!) { deletePullRequestReview(input: { pullRequestReviewId: $id }) { pullRequestReview { id } } }`,
26807
+ { id: reviewId }
26808
+ );
26809
+ }
26810
+ async function addIssueComment(gh, subjectId, body) {
26811
+ const data = await gh.graphql(
26812
+ `mutation($id: ID!, $body: String!) {
26813
+ addComment(input: { subjectId: $id, body: $body }) {
26814
+ commentEdge { node { id url body bodyHTML createdAt author { login avatarUrl } } }
26815
+ }
26816
+ }`,
26817
+ { id: subjectId, body }
26818
+ );
26819
+ return { kind: "comment", ...data.addComment.commentEdge.node, unread: false };
26820
+ }
26821
+ async function deleteReviewComment(gh, commentId) {
26822
+ await gh.graphql(
26823
+ `mutation($id: ID!) { deletePullRequestReviewComment(input: { id: $id }) { clientMutationId } }`,
26824
+ { id: commentId }
26825
+ );
26826
+ }
26827
+ async function updateReviewComment(gh, commentId, body) {
26828
+ await gh.graphql(
26829
+ `mutation($id: ID!, $body: String!) {
26830
+ updatePullRequestReviewComment(input: { pullRequestReviewCommentId: $id, body: $body }) { clientMutationId }
26831
+ }`,
26832
+ { id: commentId, body }
26833
+ );
26834
+ }
26835
+ async function applySuggestion(gh, ref, input2) {
26836
+ const branch = await gh.rest(
26837
+ `/repos/${ref.owner}/${ref.repo}/branches/${encodeURIComponent(input2.branch)}`
26838
+ );
26839
+ if (branch.commit.sha !== input2.expectedHeadOid) {
26840
+ throw new GitHubError(
26841
+ "La branche a boug\xE9 depuis le chargement de la PR : rechargez avant d\u2019appliquer.",
26842
+ 409
26843
+ );
26844
+ }
26845
+ const encodedPath = input2.path.split("/").map(encodeURIComponent).join("/");
26846
+ const file2 = await gh.rest(
26847
+ `/repos/${ref.owner}/${ref.repo}/contents/${encodedPath}?ref=${input2.expectedHeadOid}`
26848
+ );
26849
+ const text2 = Buffer.from(file2.content, "base64").toString("utf8");
26850
+ const eol = text2.includes("\r\n") ? "\r\n" : "\n";
26851
+ const lines = text2.split(eol);
26852
+ if (input2.endLine > lines.length || input2.startLine < 1 || input2.startLine > input2.endLine) {
26853
+ throw new GitHubError("Lignes de la suggestion hors du fichier.", 422);
26854
+ }
26855
+ const replacement = input2.replacement.replace(/\r?\n$/, "").split(/\r?\n/);
26856
+ lines.splice(
26857
+ input2.startLine - 1,
26858
+ input2.endLine - input2.startLine + 1,
26859
+ ...input2.replacement === "" ? [] : replacement
26860
+ );
26861
+ const res = await gh.rest(
26862
+ `/repos/${ref.owner}/${ref.repo}/contents/${encodedPath}`,
26863
+ {
26864
+ method: "PUT",
26865
+ body: {
26866
+ message: input2.message,
26867
+ content: Buffer.from(lines.join(eol), "utf8").toString("base64"),
26868
+ sha: file2.sha,
26869
+ branch: input2.branch
26870
+ }
26871
+ }
26872
+ );
26873
+ return res.commit.sha;
26874
+ }
26875
+
26876
+ // ../../packages/language/src/paths.ts
26877
+ function normalizePath(path) {
26878
+ const segments = [];
26879
+ for (const segment of path.split("/")) {
26880
+ if (segment === "" || segment === ".") continue;
26881
+ if (segment !== "..") segments.push(segment);
26882
+ else if (segments.pop() === void 0) return null;
26883
+ }
26884
+ return segments.length > 0 ? segments.join("/") : null;
26885
+ }
26886
+ function joinPath(dir, relative2) {
26887
+ return normalizePath(dir === "" ? relative2 : `${dir}/${relative2}`);
26888
+ }
26889
+ function dirname(path) {
26890
+ const slash = path.lastIndexOf("/");
26891
+ return slash === -1 ? "" : path.slice(0, slash);
26892
+ }
26893
+ function basename(path) {
26894
+ return path.slice(path.lastIndexOf("/") + 1);
26895
+ }
26896
+ function extname(path) {
26897
+ const name = basename(path);
26898
+ const dot = name.lastIndexOf(".");
26899
+ return dot > 0 ? name.slice(dot) : "";
26900
+ }
26901
+ function fileStem(path) {
26902
+ const name = basename(path);
26903
+ if (name.endsWith(".d.ts")) return name.slice(0, -".d.ts".length);
26904
+ const extension = extname(name);
26905
+ return extension === "" ? name : name.slice(0, -extension.length);
26906
+ }
26907
+ function sharedPrefixLength(a, b) {
26908
+ const left = a === "" ? [] : a.split("/");
26909
+ const right = b === "" ? [] : b.split("/");
26910
+ let count = 0;
26911
+ while (count < left.length && count < right.length && left[count] === right[count]) count++;
26912
+ return count;
26913
+ }
26914
+
26915
+ // ../../packages/language/src/registry.ts
26916
+ var LanguageRegistry = class {
26917
+ #byId = /* @__PURE__ */ new Map();
26918
+ #byFilename = /* @__PURE__ */ new Map();
26919
+ /** Longest extension first. */
26920
+ #byExtension = [];
26921
+ constructor(languages2) {
26922
+ const extensions = /* @__PURE__ */ new Map();
26923
+ for (const language of languages2) {
26924
+ const { id, extensions: exts, filenames = [] } = language.info;
26925
+ if (this.#byId.has(id)) throw new Error(`Langage d\xE9clar\xE9 deux fois : ${id}`);
26926
+ this.#byId.set(id, language);
26927
+ for (const name of filenames) claim2(this.#byFilename, name.toLowerCase(), language);
26928
+ for (const ext of exts) claim2(extensions, ext.toLowerCase(), language);
26929
+ }
26930
+ this.#byExtension = [...extensions].sort(([a], [b]) => b.length - a.length);
26931
+ }
26932
+ /** Every language, in declaration order. */
26933
+ all() {
26934
+ return [...this.#byId.values()];
26935
+ }
26936
+ byId(id) {
26937
+ return this.#byId.get(id);
26938
+ }
26939
+ /** Language of a repository path, or null when no registered language handles it. */
26940
+ detect(path) {
26941
+ const name = basename(path).toLowerCase();
26942
+ const exact = this.#byFilename.get(name);
26943
+ if (exact !== void 0) return exact;
26944
+ for (const [extension, language] of this.#byExtension) {
26945
+ if (name.length > extension.length && name.endsWith(extension)) return language;
26946
+ }
26947
+ return null;
26948
+ }
26949
+ };
26950
+ function claim2(map2, key, language) {
26951
+ const owner = map2.get(key);
26952
+ if (owner !== void 0 && owner !== language) {
26953
+ throw new Error(`\xAB ${key} \xBB revendiqu\xE9 par ${owner.info.id} et ${language.info.id}`);
26954
+ }
26955
+ map2.set(key, language);
26956
+ }
26957
+
26958
+ // ../../packages/lang-css/src/info.ts
26959
+ var cssInfo = { id: "css", label: "CSS", extensions: [".css"] };
26960
+ var scssInfo = { id: "scss", label: "SCSS", extensions: [".scss"] };
26961
+ var sassInfo = { id: "sass", label: "Sass", extensions: [".sass"] };
26962
+ var lessInfo = { id: "less", label: "Less", extensions: [".less"] };
26963
+
26964
+ // ../../packages/lang-css/src/analysis.ts
26965
+ function extractImports(text2) {
26966
+ const refs = [];
26967
+ const source = text2.replace(/\/\*[\s\S]*?\*\//g, "");
26968
+ for (const match2 of source.matchAll(/@(import|use|forward)\s+([^;\n]+)/g)) {
26969
+ const urls = [...(match2[2] ?? "").matchAll(/url\(\s*["']?([^"')\s]+)["']?\s*\)|["']([^"'\n]+)["']/g)];
26970
+ for (const url2 of match2[1] === "import" ? urls : urls.slice(0, 1)) {
26971
+ const specifier = url2[1] ?? url2[2];
26972
+ if (specifier !== void 0) refs.push({ specifier, names: [] });
26973
+ }
26974
+ }
26975
+ return refs;
26976
+ }
26977
+ var STYLE_EXTENSIONS = [".scss", ".sass", ".css", ".less"];
26978
+ function candidates(base) {
26979
+ const dir = dirname(base);
26980
+ const partial2 = `${dir === "" ? "" : `${dir}/`}_${basename(base)}`;
26981
+ if (STYLE_EXTENSIONS.includes(extname(base))) return [base, partial2];
26982
+ return [
26983
+ base,
26984
+ ...STYLE_EXTENSIONS.flatMap((ext) => [base + ext, partial2 + ext]),
26985
+ ...STYLE_EXTENSIONS.flatMap((ext) => [`${base}/_index${ext}`, `${base}/index${ext}`])
26986
+ ];
26987
+ }
26988
+ function resolveImport(ref, from, index) {
26989
+ const specifier = ref.specifier.replace(/^~/, "");
26990
+ if (/^(?:[a-z]+:|\/\/)/i.test(specifier)) return [];
26991
+ const paths = candidates(specifier);
26992
+ const relative2 = index.firstRelative(dirname(from), paths);
26993
+ if (relative2 !== null) return [{ path: relative2, names: ref.names }];
26994
+ if (specifier.startsWith(".")) return [];
26995
+ return index.closestWithSuffix(from, paths).map((path) => ({ path, names: ref.names }));
26996
+ }
26997
+ var stylesheet = (info) => ({ info, extractImports, resolveImport });
26998
+ var css = stylesheet(cssInfo);
26999
+ var scss = stylesheet(scssInfo);
27000
+ var sass = stylesheet(sassInfo);
27001
+ var less = stylesheet(lessInfo);
27002
+
27003
+ // ../../packages/lang-html/src/info.ts
27004
+ var htmlInfo = { id: "html", label: "HTML", extensions: [".html", ".htm"] };
27005
+
27006
+ // ../../packages/lang-html/src/analysis.ts
27007
+ function extractImports2(text2) {
27008
+ const source = text2.replace(/<!--[\s\S]*?-->/g, "");
27009
+ const refs = [];
27010
+ for (const tag of source.matchAll(/<(script|link)\b[^>]*>/gi)) {
27011
+ const attribute = tag[1].toLowerCase() === "script" ? "src" : "href";
27012
+ const value = new RegExp(`\\s${attribute}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i").exec(tag[0]);
27013
+ const url2 = value?.[1] ?? value?.[2] ?? value?.[3];
27014
+ if (url2) refs.push({ specifier: url2, names: [] });
27015
+ }
27016
+ return refs;
27017
+ }
27018
+ function resolveImport2(ref, from, index) {
27019
+ const url2 = ref.specifier.replace(/[?#].*$/, "");
27020
+ if (url2 === "" || /^(?:[a-z]+:|\/\/)/i.test(url2)) return [];
27021
+ const rooted = url2.startsWith("/");
27022
+ const relative2 = index.firstRelative(dirname(from), [rooted ? url2.slice(1) : url2]);
27023
+ if (relative2 !== null) return [{ path: relative2, names: ref.names }];
27024
+ if (!rooted) return [];
27025
+ return index.closestWithSuffix(from, [url2.slice(1)]).map((path) => ({ path, names: ref.names }));
27026
+ }
27027
+ var html = { info: htmlInfo, extractImports: extractImports2, resolveImport: resolveImport2 };
27028
+
27029
+ // ../../packages/lang-json/src/info.ts
27030
+ var jsonInfo = {
27031
+ id: "json",
27032
+ label: "JSON",
27033
+ extensions: [".json", ".jsonc"],
27034
+ // JSON configuration files without the extension.
27035
+ filenames: [".babelrc", ".eslintrc", ".prettierrc", ".swcrc"]
27036
+ };
27037
+
27038
+ // ../../packages/lang-json/src/analysis.ts
27039
+ var json3 = { info: jsonInfo };
27040
+
27041
+ // ../../packages/lang-markdown/src/info.ts
27042
+ var markdownInfo = {
27043
+ id: "markdown",
27044
+ label: "MD",
27045
+ extensions: [".md", ".markdown"]
27046
+ };
27047
+
27048
+ // ../../packages/lang-markdown/src/analysis.ts
27049
+ var markdown = { info: markdownInfo };
27050
+
27051
+ // ../../packages/lang-text/src/info.ts
27052
+ var textInfo = {
27053
+ id: "text",
27054
+ label: "TXT",
27055
+ extensions: [".txt"]
27056
+ };
27057
+
27058
+ // ../../packages/lang-text/src/analysis.ts
27059
+ var text = { info: textInfo };
27060
+
27061
+ // ../../packages/lang-typescript/src/analysis.ts
27062
+ import ts from "typescript";
27063
+
27064
+ // ../../packages/lang-typescript/src/info.ts
27065
+ var typescriptInfo = {
27066
+ id: "typescript",
27067
+ label: "TS",
27068
+ extensions: [".ts", ".tsx", ".mts", ".cts"]
27069
+ };
27070
+ var javascriptInfo = {
27071
+ id: "javascript",
27072
+ label: "JS",
27073
+ extensions: [".js", ".jsx", ".mjs", ".cjs"]
27074
+ };
27075
+
27076
+ // ../../packages/lang-typescript/src/analysis.ts
27077
+ var SCRIPT_KIND_BY_EXTENSION = {
27078
+ ".ts": ts.ScriptKind.TS,
27079
+ ".mts": ts.ScriptKind.TS,
26847
27080
  ".cts": ts.ScriptKind.TS,
26848
27081
  ".tsx": ts.ScriptKind.TSX,
26849
27082
  ".js": ts.ScriptKind.JS,
@@ -26851,44 +27084,9 @@ var SCRIPT_KIND_BY_EXTENSION = {
26851
27084
  ".cjs": ts.ScriptKind.JS,
26852
27085
  ".jsx": ts.ScriptKind.JSX
26853
27086
  };
26854
- var SCRIPT_KIND_BY_LANG = {
26855
- ts: ts.ScriptKind.TS,
26856
- typescript: ts.ScriptKind.TS,
26857
- tsx: ts.ScriptKind.TSX,
26858
- jsx: ts.ScriptKind.JSX
26859
- };
26860
- var EXTRACTORS = {
26861
- typescript: extractScriptFile,
26862
- javascript: extractScriptFile,
26863
- vue: extractComponentScripts,
26864
- svelte: extractComponentScripts,
26865
- python: extractPython,
26866
- css: extractStyle,
26867
- go: extractGo,
26868
- java: extractJvm,
26869
- kotlin: extractJvm,
26870
- c: extractInclude,
26871
- cpp: extractInclude,
26872
- rust: extractRust,
26873
- ruby: extractRuby,
26874
- markdown: () => []
26875
- };
26876
- function extractImports(text, path, language) {
26877
- return language === null ? [] : EXTRACTORS[language](text, path);
26878
- }
26879
- function extractScriptFile(text, path) {
26880
- return parseScript(text, path, SCRIPT_KIND_BY_EXTENSION[extname(path).toLowerCase()] ?? ts.ScriptKind.TS);
26881
- }
26882
- function extractComponentScripts(text, path) {
26883
- const refs = [];
26884
- for (const match2 of text.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi)) {
26885
- const lang = /\blang\s*=\s*["']?(tsx?|jsx|typescript)\b/i.exec(match2[1] ?? "")?.[1]?.toLowerCase() ?? "";
26886
- refs.push(...parseScript(match2[2] ?? "", path, SCRIPT_KIND_BY_LANG[lang] ?? ts.ScriptKind.JS));
26887
- }
26888
- return refs;
26889
- }
26890
- function parseScript(text, path, kind) {
26891
- const source = ts.createSourceFile(path, text, ts.ScriptTarget.Latest, true, kind);
27087
+ function extractImports3(text2, path) {
27088
+ const kind = SCRIPT_KIND_BY_EXTENSION[extname(path).toLowerCase()] ?? ts.ScriptKind.TS;
27089
+ const source = ts.createSourceFile(path, text2, ts.ScriptTarget.Latest, true, kind);
26892
27090
  const refs = [];
26893
27091
  const visit2 = (node2) => {
26894
27092
  const ref = scriptImport(node2);
@@ -26959,162 +27157,228 @@ function boundNames(call) {
26959
27157
  return ts.isIdentifier(key) ? [key.text] : [];
26960
27158
  });
26961
27159
  }
26962
- function extractPython(text) {
26963
- const source = text.replace(/\\\r?\n/g, " ");
26964
- const refs = [];
26965
- for (const match2 of source.matchAll(
26966
- /^[ \t]*from[ \t]+(\.+[\w.]*|[\w.]+)[ \t]+import[ \t]+(\([^)]{0,10000}\)|[^\n#;]*)/gm
26967
- )) {
26968
- const names = splitNames(match2[2]?.replace(/[()]/g, "") ?? "").filter(
26969
- (name) => /^(?:\w+|\*)$/.test(name)
26970
- );
26971
- if (match2[1] !== void 0 && names.length > 0) refs.push({ specifier: match2[1], names });
27160
+ var SCRIPT_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts", ".d.ts", ".js", ".jsx", ".mjs", ".cjs"];
27161
+ var TS_COUNTERPARTS = {
27162
+ ".js": [".ts", ".tsx"],
27163
+ ".jsx": [".tsx"],
27164
+ ".mjs": [".mts"],
27165
+ ".cjs": [".cts"]
27166
+ };
27167
+ var ALIAS_PREFIX = /^(?:@\/|~\/|#\/?)/;
27168
+ function scriptCandidates(base) {
27169
+ const extension = extname(base);
27170
+ const counterparts = (TS_COUNTERPARTS[extension] ?? []).map((ts2) => base.slice(0, -extension.length) + ts2);
27171
+ return [
27172
+ base,
27173
+ ...counterparts,
27174
+ ...SCRIPT_EXTENSIONS.map((ext) => base + ext),
27175
+ ...SCRIPT_EXTENSIONS.map((ext) => `${base}/index${ext}`)
27176
+ ];
27177
+ }
27178
+ function resolveImport3(ref, from, index) {
27179
+ const { specifier, names } = ref;
27180
+ if (specifier.startsWith("./") || specifier.startsWith("../") || specifier === "." || specifier === "..") {
27181
+ const path = index.firstRelative(dirname(from), scriptCandidates(specifier));
27182
+ return path === null ? [] : [{ path, names }];
26972
27183
  }
26973
- for (const match2 of source.matchAll(/^[ \t]*import[ \t]+([^\n#;]+)/gm)) {
26974
- for (const module of splitNames(match2[1] ?? "")) {
26975
- if (/^\w+(?:\.\w+)*$/.test(module)) refs.push({ specifier: module, names: [] });
26976
- }
27184
+ const workspace = index.packageFor(specifier);
27185
+ if (workspace !== null) {
27186
+ const path = resolveWorkspaceImport(workspace.pkg, workspace.subpath, index);
27187
+ return path === null ? [] : [{ path, names }];
26977
27188
  }
26978
- return refs;
27189
+ if (!ALIAS_PREFIX.test(specifier) && !specifier.startsWith("/")) return [];
27190
+ const remainder = specifier.replace(ALIAS_PREFIX, "").replace(/^\/+/, "");
27191
+ if (remainder === "") return [];
27192
+ return index.closestWithSuffix(from, scriptCandidates(remainder)).map((path) => ({ path, names }));
26979
27193
  }
26980
- function splitNames(list) {
26981
- return list.replace(/#[^\n]*/g, "").split(",").map(
26982
- (part) => part.trim().split(/\s+as\s+/)[0]?.trim() ?? ""
26983
- ).filter((name) => name !== "");
27194
+ function resolveWorkspaceImport(pkg, subpath, index) {
27195
+ if (subpath === "") return index.entryOf(pkg);
27196
+ return index.firstRelative(pkg.root, scriptCandidates(subpath)) ?? index.firstRelative(pkg.root, scriptCandidates(`src/${subpath}`));
26984
27197
  }
26985
- function extractStyle(text) {
26986
- const refs = [];
26987
- const source = text.replace(/\/\*[\s\S]*?\*\//g, "");
26988
- for (const match2 of source.matchAll(/@(import|use|forward)\s+([^;\n]+)/g)) {
26989
- const urls = [...(match2[2] ?? "").matchAll(/url\(\s*["']?([^"')\s]+)["']?\s*\)|["']([^"'\n]+)["']/g)];
26990
- for (const url2 of match2[1] === "import" ? urls : urls.slice(0, 1)) {
26991
- const specifier = url2[1] ?? url2[2];
26992
- if (specifier !== void 0) refs.push({ specifier, names: [] });
27198
+ function importedPackageRoot(ref, index) {
27199
+ return ref.specifier.startsWith(".") ? null : index.packageFor(ref.specifier)?.pkg.root ?? null;
27200
+ }
27201
+ var typescript = {
27202
+ info: typescriptInfo,
27203
+ extractImports: extractImports3,
27204
+ resolveImport: resolveImport3,
27205
+ importedPackageRoot
27206
+ };
27207
+ var javascript = {
27208
+ info: javascriptInfo,
27209
+ extractImports: extractImports3,
27210
+ resolveImport: resolveImport3,
27211
+ importedPackageRoot
27212
+ };
27213
+ var DeclaredName = external_exports.string().optional().catch(void 0);
27214
+ var DependencyMap = external_exports.record(external_exports.string(), external_exports.unknown()).optional().catch(void 0);
27215
+ var PackageJson = external_exports.object({
27216
+ name: DeclaredName,
27217
+ dependencies: DependencyMap,
27218
+ devDependencies: DependencyMap,
27219
+ peerDependencies: DependencyMap,
27220
+ optionalDependencies: DependencyMap
27221
+ });
27222
+ var NPM_LOCAL_SPEC = /^(?:file|link|portal):(.+)$/;
27223
+ function readPackageJson(text2) {
27224
+ const data = PackageJson.parse(JSON.parse(text2));
27225
+ const deps = [];
27226
+ const paths = [];
27227
+ for (const entries of [
27228
+ data.dependencies,
27229
+ data.devDependencies,
27230
+ data.peerDependencies,
27231
+ data.optionalDependencies
27232
+ ]) {
27233
+ for (const [dep, spec] of Object.entries(entries ?? {})) {
27234
+ deps.push(dep);
27235
+ const local = typeof spec === "string" ? NPM_LOCAL_SPEC.exec(spec)?.[1] : void 0;
27236
+ if (local !== void 0) paths.push(local);
26993
27237
  }
26994
27238
  }
26995
- return refs;
27239
+ const name = data.name?.trim();
27240
+ return { name: name === void 0 || name === "" ? null : name, deps, paths };
26996
27241
  }
26997
- function extractGo(text) {
26998
- const refs = [];
26999
- const addSpec = (alias, path) => {
27000
- if (path === void 0) return;
27001
- const name = alias !== void 0 && alias !== "_" && alias !== "." ? alias : path.slice(path.lastIndexOf("/") + 1);
27002
- refs.push({ specifier: path, names: [name] });
27242
+ var SRC_EXTENSIONS = [".ts", ".tsx", ".mts", ".js", ".jsx"];
27243
+ function exportTargets(value) {
27244
+ if (typeof value === "string") return [value];
27245
+ if (!value || typeof value !== "object") return [];
27246
+ const entries = Object.entries(value);
27247
+ const root = entries.find(([k]) => k === ".");
27248
+ const ordered = root ? [root] : entries.filter(([k]) => !k.startsWith("./"));
27249
+ return ordered.flatMap(([, v]) => exportTargets(v));
27250
+ }
27251
+ function entryCandidates(root, manifestText) {
27252
+ if (!manifestText) return [];
27253
+ const join5 = (rel) => {
27254
+ const clean = rel.replace(/^\.\//, "");
27255
+ return root ? `${root}/${clean}` : clean;
27003
27256
  };
27004
- for (const match2 of text.matchAll(/^[ \t]*import[ \t]+(?:([\w.]+)[ \t]+)?"([^"\n]+)"/gm))
27005
- addSpec(match2[1], match2[2]);
27006
- for (const group of text.matchAll(/^[ \t]*import[ \t]*\(([^)]{0,10000})\)/gm)) {
27007
- for (const match2 of (group[1] ?? "").matchAll(/^[ \t]*(?:([\w.]+)[ \t]+)?"([^"\n]+)"/gm))
27008
- addSpec(match2[1], match2[2]);
27257
+ const out = [];
27258
+ let manifest = null;
27259
+ try {
27260
+ manifest = JSON.parse(manifestText);
27261
+ } catch {
27009
27262
  }
27010
- return refs;
27011
- }
27012
- function extractJvm(text) {
27013
- return [...text.matchAll(/^[ \t]*import[ \t]+(?:static[ \t]+)?(\w+(?:\.\w+)*(?:\.\*)?)/gm)].flatMap(
27014
- (match2) => {
27015
- const specifier = match2[1];
27016
- return specifier === void 0 ? [] : [{ specifier, names: [specifier.slice(specifier.lastIndexOf(".") + 1)] }];
27263
+ if (manifest && typeof manifest === "object") {
27264
+ const fields = ["exports", "module", "main", "types", "typings"];
27265
+ for (const field of fields) {
27266
+ if (!(field in manifest)) continue;
27267
+ const value = Reflect.get(manifest, field);
27268
+ for (const target of exportTargets(value)) {
27269
+ out.push(join5(target));
27270
+ const source = target.replace(/^\.?\/?(dist|build|lib|out)\//, "src/").replace(/(\.d)?\.(m|c)?[jt]sx?$/, "");
27271
+ if (source !== target) for (const ext of SRC_EXTENSIONS) out.push(join5(source + ext));
27272
+ }
27017
27273
  }
27018
- );
27019
- }
27020
- function extractInclude(text) {
27021
- return [...text.matchAll(/^[ \t]*#[ \t]*include[ \t]*"([^"\n]+)"/gm)].flatMap(
27022
- (match2) => match2[1] === void 0 ? [] : [{ specifier: match2[1], names: [] }]
27023
- );
27274
+ }
27275
+ for (const base of ["src/index", "index", "src/main"]) {
27276
+ for (const ext of SRC_EXTENSIONS) out.push(join5(base + ext));
27277
+ }
27278
+ return [...new Set(out)];
27024
27279
  }
27025
- function extractRust(text) {
27026
- const source = text.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "");
27027
- const refs = [];
27028
- const visibility = String.raw`(?:pub(?:\([^)\n]*\))?[ \t]+)?`;
27029
- const modPattern = new RegExp(
27030
- String.raw`^[ \t]*(?:#\[[^\]\n]*\][ \t]*)*${visibility}mod[ \t]+(?:r#)?(\w+)[ \t]*;`,
27031
- "gm"
27032
- );
27033
- for (const match2 of source.matchAll(modPattern)) {
27034
- if (match2[1] !== void 0) refs.push({ specifier: `self::${match2[1]}`, names: [match2[1]] });
27280
+ var npm = {
27281
+ id: "npm",
27282
+ manifests: ["package.json"],
27283
+ readManifest: readPackageJson,
27284
+ entryCandidates
27285
+ };
27286
+
27287
+ // ../server/src/languages.ts
27288
+ var languages = new LanguageRegistry([
27289
+ typescript,
27290
+ javascript,
27291
+ html,
27292
+ css,
27293
+ scss,
27294
+ sass,
27295
+ less,
27296
+ markdown,
27297
+ json3,
27298
+ text
27299
+ ]);
27300
+ var ecosystems = [npm];
27301
+
27302
+ // ../../packages/language/src/analysis.ts
27303
+ var FileIndex = class {
27304
+ #paths = /* @__PURE__ */ new Set();
27305
+ #byBasename = /* @__PURE__ */ new Map();
27306
+ #byDir = /* @__PURE__ */ new Map();
27307
+ /** Longest name first, so that `@acme/ui/forms` prefers a package named `@acme/ui/forms` over `@acme/ui`. */
27308
+ #packages = [];
27309
+ constructor(paths, packages = []) {
27310
+ for (const path of paths) {
27311
+ if (this.#paths.has(path)) continue;
27312
+ this.#paths.add(path);
27313
+ pushTo(this.#byBasename, basename(path), path);
27314
+ pushTo(this.#byDir, dirname(path), path);
27315
+ }
27316
+ for (const ref of packages) {
27317
+ const root = ref.root === "" ? "" : normalizePath(ref.root);
27318
+ if (ref.name === "" || root === null) continue;
27319
+ const entries = ref.entries.flatMap((entry) => normalizePath(entry) ?? []);
27320
+ this.#packages.push({ name: ref.name, root, entries });
27321
+ }
27322
+ this.#packages.sort((a, b) => b.name.length - a.name.length);
27035
27323
  }
27036
- for (const match2 of source.matchAll(/^[ \t]*(?:#\[[^\]\n]*\][ \t]*)*extern[ \t]+crate[ \t]+(\w+)/gm)) {
27037
- if (match2[1] !== void 0 && match2[1] !== "self") refs.push({ specifier: match2[1], names: [match2[1]] });
27324
+ /** Package named by a bare specifier (`name` or `name/sub/path`), with the remaining subpath. */
27325
+ packageFor(specifier) {
27326
+ for (const pkg of this.#packages) {
27327
+ if (specifier === pkg.name) return { pkg, subpath: "" };
27328
+ if (specifier.startsWith(`${pkg.name}/`)) return { pkg, subpath: specifier.slice(pkg.name.length + 1) };
27329
+ }
27330
+ return null;
27038
27331
  }
27039
- for (const match2 of source.matchAll(
27040
- new RegExp(String.raw`^[ \t]*${visibility}use[ \t]+([^;]{1,10000});`, "gm")
27041
- )) {
27042
- const tree = (match2[1] ?? "").replace(/\s+as\s+\w+/g, "").replace(/\s+/g, "");
27043
- for (const path of expandUseTree(tree)) {
27044
- const segments = path.replace(/^::/, "").split("::");
27045
- const last = segments.at(-1);
27046
- if (last === "*") segments.pop();
27047
- refs.push({ specifier: segments.join("::"), names: last === void 0 ? [] : [last] });
27332
+ /** First entry candidate of a package that is a changed file. */
27333
+ entryOf(pkg) {
27334
+ return pkg.entries.find((entry) => this.#paths.has(entry)) ?? null;
27335
+ }
27336
+ /** Root of the package containing `path`: the root that is its longest segment prefix; null when none. */
27337
+ ownPackageRoot(path) {
27338
+ let best = null;
27339
+ for (const { root } of this.#packages) {
27340
+ const contains = root === "" || path === root || path.startsWith(`${root}/`);
27341
+ if (contains && (best === null || root.length > best.length)) best = root;
27048
27342
  }
27343
+ return best;
27049
27344
  }
27050
- return refs;
27051
- }
27052
- function expandUseTree(tree) {
27053
- const open2 = tree.indexOf("{");
27054
- const close = tree.lastIndexOf("}");
27055
- if (open2 === -1 || close < open2) return [tree];
27056
- const head = tree.slice(0, open2);
27057
- return splitTopLevel(tree.slice(open2 + 1, close)).flatMap(
27058
- (part) => part === "self" ? [head.replace(/::$/, "")] : expandUseTree(head + part)
27059
- );
27060
- }
27061
- function splitTopLevel(list) {
27062
- const parts = [];
27063
- let depth = 0;
27064
- let start = 0;
27065
- for (let i = 0; i < list.length; i++) {
27066
- const char = list[i];
27067
- if (char === "{") depth++;
27068
- else if (char === "}") depth--;
27069
- else if (char === "," && depth === 0) {
27070
- parts.push(list.slice(start, i));
27071
- start = i + 1;
27345
+ has(path) {
27346
+ return path !== null && this.#paths.has(path);
27347
+ }
27348
+ /** Paths equal to `suffix` or ending with `/suffix`. */
27349
+ withSuffix(suffix) {
27350
+ const candidates2 = this.#byBasename.get(basename(suffix)) ?? [];
27351
+ return candidates2.filter((path) => path === suffix || path.endsWith(`/${suffix}`));
27352
+ }
27353
+ /** First candidate path present in the index, relative to `dir`. */
27354
+ firstRelative(dir, candidates2) {
27355
+ for (const candidate of candidates2) {
27356
+ const path = joinPath(dir, candidate);
27357
+ if (this.has(path)) return path;
27072
27358
  }
27359
+ return null;
27073
27360
  }
27074
- parts.push(list.slice(start));
27075
- return parts.filter((part) => part !== "");
27076
- }
27077
- function extractRuby(text) {
27078
- return [...text.matchAll(/^[ \t]*require_relative[ \t(]+["']([^"'\n]+)["']/gm)].flatMap(
27079
- (match2) => match2[1] === void 0 ? [] : [{ specifier: match2[1], names: [] }]
27080
- );
27081
- }
27082
-
27083
- // ../server/src/links/language.ts
27084
- var LANGUAGE_BY_EXTENSION = {
27085
- ".ts": "typescript",
27086
- ".tsx": "typescript",
27087
- ".mts": "typescript",
27088
- ".cts": "typescript",
27089
- ".js": "javascript",
27090
- ".jsx": "javascript",
27091
- ".mjs": "javascript",
27092
- ".cjs": "javascript",
27093
- ".py": "python",
27094
- ".css": "css",
27095
- ".scss": "css",
27096
- ".sass": "css",
27097
- ".less": "css",
27098
- ".go": "go",
27099
- ".java": "java",
27100
- ".kt": "kotlin",
27101
- ".kts": "kotlin",
27102
- ".c": "c",
27103
- ".h": "c",
27104
- ".cpp": "cpp",
27105
- ".cc": "cpp",
27106
- ".cxx": "cpp",
27107
- ".hpp": "cpp",
27108
- ".hh": "cpp",
27109
- ".rs": "rust",
27110
- ".rb": "ruby",
27111
- ".vue": "vue",
27112
- ".svelte": "svelte",
27113
- ".md": "markdown",
27114
- ".mdx": "markdown"
27115
- };
27116
- function detectLanguage(path) {
27117
- return LANGUAGE_BY_EXTENSION[extname(path).toLowerCase()] ?? null;
27361
+ /**
27362
+ * Suffix match of the first candidate that matches anything. Among several matches, keeps those sharing
27363
+ * the most leading directories with the importing file (the closest source root / package wins).
27364
+ */
27365
+ closestWithSuffix(from, candidates2) {
27366
+ for (const candidate of candidates2) {
27367
+ const suffix = normalizePath(candidate);
27368
+ const matches = suffix === null ? [] : this.withSuffix(suffix);
27369
+ if (matches.length === 0) continue;
27370
+ const fromDir = dirname(from);
27371
+ const scores = matches.map((path) => sharedPrefixLength(fromDir, dirname(path)));
27372
+ const best = Math.max(...scores);
27373
+ return matches.filter((_, i) => scores[i] === best);
27374
+ }
27375
+ return [];
27376
+ }
27377
+ };
27378
+ function pushTo(map2, key, value) {
27379
+ const list = map2.get(key);
27380
+ if (list === void 0) map2.set(key, [value]);
27381
+ else list.push(value);
27118
27382
  }
27119
27383
 
27120
27384
  // ../server/src/links/mentions.ts
@@ -27193,375 +27457,91 @@ function findMentions(files, skip) {
27193
27457
  const distinctive = !generic && stem.length >= MIN_STEM_LENGTH && /[A-Za-z]/.test(stem);
27194
27458
  if (owner === void 0 || others.length > 0 || !distinctive) continue;
27195
27459
  const name = basename(owner);
27196
- if (/[A-Z]/.test(stem)) distinctiveTokens.set(stem, owner);
27197
- else if (name !== stem) distinctiveTokens.set(name, owner);
27198
- }
27199
- const mentions = [];
27200
- for (const file2 of files) {
27201
- if (file2.text === null) continue;
27202
- const tokensByTarget = /* @__PURE__ */ new Map();
27203
- const add = (to, token) => {
27204
- if (to === file2.path || skip(file2.path, to)) return;
27205
- const tokens = tokensByTarget.get(to) ?? /* @__PURE__ */ new Set();
27206
- tokens.add(token);
27207
- tokensByTarget.set(to, tokens);
27208
- };
27209
- for (const path of mentionedPaths(file2.path, file2.text, paths)) add(path, path);
27210
- const words = wordSet(file2.text);
27211
- for (const [token, owner] of distinctiveTokens)
27212
- if (!tokensByTarget.has(owner) && words.has(token)) add(owner, token);
27213
- for (const [to, tokens] of tokensByTarget) mentions.push({ from: file2.path, to, tokens: [...tokens] });
27214
- }
27215
- return mentions;
27216
- }
27217
- function mentionedPaths(from, text, paths) {
27218
- const found = /* @__PURE__ */ new Set();
27219
- const seen = /* @__PURE__ */ new Set();
27220
- for (const [raw2] of text.matchAll(/[\w.\-/@$+~[\]]+/g)) {
27221
- const token = raw2.replace(/^\[+/, "").replace(/[.\]]+$/, "");
27222
- if (seen.has(token) || !token.includes(".") && !token.includes("/")) continue;
27223
- seen.add(token);
27224
- const relative2 = token.startsWith(".") ? joinPath(dirname(from), token) : null;
27225
- if (relative2 !== null && paths.has(relative2)) {
27226
- found.add(relative2);
27227
- continue;
27228
- }
27229
- let start = 0;
27230
- while (true) {
27231
- const tail = token.slice(start);
27232
- if (paths.has(tail)) {
27233
- found.add(tail);
27234
- break;
27235
- }
27236
- const slash = token.indexOf("/", start);
27237
- if (slash === -1) break;
27238
- start = slash + 1;
27239
- }
27240
- }
27241
- return found;
27242
- }
27243
- function wordSet(text) {
27244
- const words = /* @__PURE__ */ new Set();
27245
- for (const match2 of text.matchAll(/[\w$]+(?:[.-][\w$]+)*/g)) {
27246
- const word = match2[0];
27247
- const before = text[match2.index - 1];
27248
- const after = text[match2.index + word.length];
27249
- if (before === "/" || before === "\\" || after === "/" || after === "\\") continue;
27250
- words.add(word);
27251
- const parts = word.split(/([.-])/);
27252
- if (parts.length === 1) continue;
27253
- const chunkCount = (parts.length + 1) / 2;
27254
- const maxRun = chunkCount > MAX_COMPOUND_CHUNKS ? 1 : chunkCount;
27255
- for (let first = 0; first < chunkCount; first++) {
27256
- for (let last = first; last < Math.min(chunkCount, first + maxRun); last++) {
27257
- words.add(parts.slice(first * 2, last * 2 + 1).join(""));
27258
- }
27259
- }
27260
- }
27261
- return words;
27262
- }
27263
-
27264
- // ../server/src/links/resolve.ts
27265
- var FileIndex = class {
27266
- #paths = /* @__PURE__ */ new Set();
27267
- #byBasename = /* @__PURE__ */ new Map();
27268
- #byDir = /* @__PURE__ */ new Map();
27269
- /** Longest name first, so that `@acme/ui/forms` prefers a package named `@acme/ui/forms` over `@acme/ui`. */
27270
- #packages = [];
27271
- /** By crate name (`-` → `_`). */
27272
- #crates = /* @__PURE__ */ new Map();
27273
- constructor(paths, packages = []) {
27274
- for (const path of paths) {
27275
- if (this.#paths.has(path)) continue;
27276
- this.#paths.add(path);
27277
- pushTo(this.#byBasename, basename(path), path);
27278
- pushTo(this.#byDir, dirname(path), path);
27279
- }
27280
- for (const ref of packages) {
27281
- const root = ref.root === "" ? "" : normalizePath(ref.root);
27282
- if (ref.name === "" || root === null) continue;
27283
- const entries = ref.entries.flatMap((entry) => normalizePath(entry) ?? []);
27284
- const pkg = { name: ref.name, root, entries };
27285
- this.#packages.push(pkg);
27286
- const crate = ref.name.replaceAll("-", "_");
27287
- if (!this.#crates.has(crate)) this.#crates.set(crate, pkg);
27288
- }
27289
- this.#packages.sort((a, b) => b.name.length - a.name.length);
27290
- }
27291
- /** Package named by a bare specifier (`name` or `name/sub/path`), with the remaining subpath. */
27292
- packageFor(specifier) {
27293
- for (const pkg of this.#packages) {
27294
- if (specifier === pkg.name) return { pkg, subpath: "" };
27295
- if (specifier.startsWith(`${pkg.name}/`)) return { pkg, subpath: specifier.slice(pkg.name.length + 1) };
27296
- }
27297
- return null;
27298
- }
27299
- crate(name) {
27300
- return this.#crates.get(name);
27301
- }
27302
- /** First entry candidate of a package that is a changed file. */
27303
- entryOf(pkg) {
27304
- return pkg.entries.find((entry) => this.#paths.has(entry)) ?? null;
27305
- }
27306
- /** Root of the package containing `path`: the root that is its longest segment prefix; null when none. */
27307
- ownPackageRoot(path) {
27308
- let best = null;
27309
- for (const { root } of this.#packages) {
27310
- const contains = root === "" || path === root || path.startsWith(`${root}/`);
27311
- if (contains && (best === null || root.length > best.length)) best = root;
27312
- }
27313
- return best;
27314
- }
27315
- has(path) {
27316
- return path !== null && this.#paths.has(path);
27317
- }
27318
- /** Paths equal to `suffix` or ending with `/suffix`. */
27319
- withSuffix(suffix) {
27320
- const candidates = this.#byBasename.get(basename(suffix)) ?? [];
27321
- return candidates.filter((path) => path === suffix || path.endsWith(`/${suffix}`));
27322
- }
27323
- /** Paths whose directory equals `dirSuffix` or ends with `/dirSuffix`. */
27324
- inDirWithSuffix(dirSuffix) {
27325
- return [...this.#byDir].flatMap(
27326
- ([dir, paths]) => dir === dirSuffix || dir.endsWith(`/${dirSuffix}`) ? paths : []
27327
- );
27328
- }
27329
- directories() {
27330
- return this.#byDir.entries();
27460
+ if (/[A-Z]/.test(stem)) distinctiveTokens.set(stem, owner);
27461
+ else if (name !== stem) distinctiveTokens.set(name, owner);
27331
27462
  }
27332
- };
27333
- function pushTo(map2, key, value) {
27334
- const list = map2.get(key);
27335
- if (list === void 0) map2.set(key, [value]);
27336
- else list.push(value);
27337
- }
27338
- var RESOLVERS = {
27339
- typescript: resolveScript,
27340
- javascript: resolveScript,
27341
- vue: resolveScript,
27342
- svelte: resolveScript,
27343
- python: resolvePython,
27344
- css: resolveStyle,
27345
- go: resolveGo,
27346
- java: resolveJvm,
27347
- kotlin: resolveJvm,
27348
- c: resolveInclude,
27349
- cpp: resolveInclude,
27350
- rust: resolveRust,
27351
- ruby: resolveRuby,
27352
- markdown: () => []
27353
- };
27354
- function resolveImport(ref, from, language, index) {
27355
- return language === null ? [] : RESOLVERS[language](ref, from, index);
27356
- }
27357
- function importedPackageRoot(ref, language, index) {
27358
- if (language === "rust") {
27359
- const crate = ref.specifier.split("::")[0];
27360
- return (crate === void 0 ? void 0 : index.crate(crate))?.root ?? null;
27361
- }
27362
- const scriptLike = language === "typescript" || language === "javascript" || language === "vue" || language === "svelte";
27363
- return scriptLike && !ref.specifier.startsWith(".") ? index.packageFor(ref.specifier)?.pkg.root ?? null : null;
27364
- }
27365
- function firstRelative(dir, candidates, index) {
27366
- for (const candidate of candidates) {
27367
- const path = joinPath(dir, candidate);
27368
- if (index.has(path)) return path;
27463
+ const mentions = [];
27464
+ for (const file2 of files) {
27465
+ if (file2.text === null) continue;
27466
+ const tokensByTarget = /* @__PURE__ */ new Map();
27467
+ const add = (to, token) => {
27468
+ if (to === file2.path || skip(file2.path, to)) return;
27469
+ const tokens = tokensByTarget.get(to) ?? /* @__PURE__ */ new Set();
27470
+ tokens.add(token);
27471
+ tokensByTarget.set(to, tokens);
27472
+ };
27473
+ for (const path of mentionedPaths(file2.path, file2.text, paths)) add(path, path);
27474
+ const words = wordSet(file2.text);
27475
+ for (const [token, owner] of distinctiveTokens)
27476
+ if (!tokensByTarget.has(owner) && words.has(token)) add(owner, token);
27477
+ for (const [to, tokens] of tokensByTarget) mentions.push({ from: file2.path, to, tokens: [...tokens] });
27369
27478
  }
27370
- return null;
27479
+ return mentions;
27371
27480
  }
27372
- function closestWithSuffix(from, candidates, index) {
27373
- for (const candidate of candidates) {
27374
- const suffix = normalizePath(candidate);
27375
- const matches = suffix === null ? [] : index.withSuffix(suffix);
27376
- if (matches.length === 0) continue;
27377
- const fromDir = dirname(from);
27378
- const scores = matches.map((path) => sharedPrefixLength(fromDir, dirname(path)));
27379
- const best = Math.max(...scores);
27380
- return matches.filter((_, i) => scores[i] === best);
27481
+ function mentionedPaths(from, text2, paths) {
27482
+ const found = /* @__PURE__ */ new Set();
27483
+ const seen = /* @__PURE__ */ new Set();
27484
+ for (const [raw2] of text2.matchAll(/[\w.\-/@$+~[\]]+/g)) {
27485
+ const token = raw2.replace(/^\[+/, "").replace(/[.\]]+$/, "");
27486
+ if (seen.has(token) || !token.includes(".") && !token.includes("/")) continue;
27487
+ seen.add(token);
27488
+ const relative2 = token.startsWith(".") ? joinPath(dirname(from), token) : null;
27489
+ if (relative2 !== null && paths.has(relative2)) {
27490
+ found.add(relative2);
27491
+ continue;
27492
+ }
27493
+ let start = 0;
27494
+ while (true) {
27495
+ const tail = token.slice(start);
27496
+ if (paths.has(tail)) {
27497
+ found.add(tail);
27498
+ break;
27499
+ }
27500
+ const slash = token.indexOf("/", start);
27501
+ if (slash === -1) break;
27502
+ start = slash + 1;
27503
+ }
27381
27504
  }
27382
- return [];
27383
- }
27384
- var SCRIPT_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts", ".d.ts", ".js", ".jsx", ".mjs", ".cjs"];
27385
- var TS_COUNTERPARTS = {
27386
- ".js": [".ts", ".tsx"],
27387
- ".jsx": [".tsx"],
27388
- ".mjs": [".mts"],
27389
- ".cjs": [".cts"]
27390
- };
27391
- var ALIAS_PREFIX = /^(?:@\/|~\/|#\/?)/;
27392
- function scriptCandidates(base) {
27393
- const extension = extname(base);
27394
- const counterparts = (TS_COUNTERPARTS[extension] ?? []).map((ts2) => base.slice(0, -extension.length) + ts2);
27395
- return [
27396
- base,
27397
- ...counterparts,
27398
- ...SCRIPT_EXTENSIONS.map((ext) => base + ext),
27399
- ...SCRIPT_EXTENSIONS.map((ext) => `${base}/index${ext}`)
27400
- ];
27505
+ return found;
27401
27506
  }
27402
- function resolveScript(ref, from, index) {
27403
- const { specifier, names } = ref;
27404
- if (specifier.startsWith("./") || specifier.startsWith("../") || specifier === "." || specifier === "..") {
27405
- const path = firstRelative(dirname(from), scriptCandidates(specifier), index);
27406
- return path === null ? [] : [{ path, names }];
27407
- }
27408
- const workspace = index.packageFor(specifier);
27409
- if (workspace !== null) {
27410
- const path = resolveWorkspaceImport(workspace.pkg, workspace.subpath, index);
27411
- return path === null ? [] : [{ path, names }];
27507
+ function wordSet(text2) {
27508
+ const words = /* @__PURE__ */ new Set();
27509
+ for (const match2 of text2.matchAll(/[\w$]+(?:[.-][\w$]+)*/g)) {
27510
+ const word = match2[0];
27511
+ const before = text2[match2.index - 1];
27512
+ const after = text2[match2.index + word.length];
27513
+ if (before === "/" || before === "\\" || after === "/" || after === "\\") continue;
27514
+ words.add(word);
27515
+ const parts = word.split(/([.-])/);
27516
+ if (parts.length === 1) continue;
27517
+ const chunkCount = (parts.length + 1) / 2;
27518
+ const maxRun = chunkCount > MAX_COMPOUND_CHUNKS ? 1 : chunkCount;
27519
+ for (let first = 0; first < chunkCount; first++) {
27520
+ for (let last = first; last < Math.min(chunkCount, first + maxRun); last++) {
27521
+ words.add(parts.slice(first * 2, last * 2 + 1).join(""));
27522
+ }
27523
+ }
27412
27524
  }
27413
- if (!ALIAS_PREFIX.test(specifier) && !specifier.startsWith("/")) return [];
27414
- const remainder = specifier.replace(ALIAS_PREFIX, "").replace(/^\/+/, "");
27415
- if (remainder === "") return [];
27416
- return closestWithSuffix(from, scriptCandidates(remainder), index).map((path) => ({ path, names }));
27417
- }
27418
- function resolveWorkspaceImport(pkg, subpath, index) {
27419
- if (subpath === "") return index.entryOf(pkg);
27420
- return firstRelative(pkg.root, scriptCandidates(subpath), index) ?? firstRelative(pkg.root, scriptCandidates(`src/${subpath}`), index);
27421
- }
27422
- function resolvePython(ref, from, index) {
27423
- const targets = [];
27424
- const memberNames = [];
27425
- for (const name of ref.names) {
27426
- const submoduleName = ref.specifier.endsWith(".") ? ref.specifier + name : `${ref.specifier}.${name}`;
27427
- const submodule = name === "*" ? [] : findPythonModule(submoduleName, from, index);
27428
- if (submodule.length === 0) memberNames.push(name);
27429
- for (const path of submodule) targets.push({ path, names: [name] });
27430
- }
27431
- if (ref.names.length === 0 || memberNames.length > 0) {
27432
- const names = ref.names.length === 0 ? [ref.specifier] : memberNames;
27433
- for (const path of findPythonModule(ref.specifier, from, index)) targets.push({ path, names });
27434
- }
27435
- return targets;
27436
- }
27437
- function findPythonModule(module, from, index) {
27438
- const dots = /^\.*/.exec(module)?.[0].length ?? 0;
27439
- const modulePath = module.slice(dots).split(".").filter(Boolean).join("/");
27440
- const candidates = modulePath === "" ? ["__init__.py"] : [`${modulePath}.py`, `${modulePath}/__init__.py`];
27441
- if (dots === 0) return closestWithSuffix(from, candidates, index);
27442
- let base = dirname(from);
27443
- for (let level = 1; level < dots && base !== null; level++) base = base === "" ? null : dirname(base);
27444
- const path = base === null ? null : firstRelative(base, candidates, index);
27445
- return path === null ? [] : [path];
27446
- }
27447
- var STYLE_EXTENSIONS = [".scss", ".sass", ".css", ".less"];
27448
- function styleCandidates(base) {
27449
- const dir = dirname(base);
27450
- const partial2 = `${dir === "" ? "" : `${dir}/`}_${basename(base)}`;
27451
- if (STYLE_EXTENSIONS.includes(extname(base))) return [base, partial2];
27452
- return [
27453
- base,
27454
- ...STYLE_EXTENSIONS.flatMap((ext) => [base + ext, partial2 + ext]),
27455
- ...STYLE_EXTENSIONS.flatMap((ext) => [`${base}/_index${ext}`, `${base}/index${ext}`])
27456
- ];
27457
- }
27458
- function resolveStyle(ref, from, index) {
27459
- const specifier = ref.specifier.replace(/^~/, "");
27460
- if (/^(?:[a-z]+:|\/\/)/i.test(specifier)) return [];
27461
- const candidates = styleCandidates(specifier);
27462
- const relative2 = firstRelative(dirname(from), candidates, index);
27463
- if (relative2 !== null) return [{ path: relative2, names: ref.names }];
27464
- if (specifier.startsWith(".")) return [];
27465
- return closestWithSuffix(from, candidates, index).map((path) => ({ path, names: ref.names }));
27466
- }
27467
- function resolveGo(ref, from, index) {
27468
- const importSegments = ref.specifier.split("/");
27469
- const ownDir = dirname(from);
27470
- let best = 0;
27471
- let packages = [];
27472
- for (const [dir, paths] of index.directories()) {
27473
- const sources = paths.filter((path) => path.endsWith(".go") && !path.endsWith("_test.go"));
27474
- if (dir === ownDir || sources.length === 0) continue;
27475
- const score = trailingMatch(dir === "" ? [] : dir.split("/"), importSegments);
27476
- if (score === 0 || score < best) continue;
27477
- if (score > best) packages = [];
27478
- best = score;
27479
- packages.push(sources);
27480
- }
27481
- return packages.flat().map((path) => ({ path, names: ref.names }));
27482
- }
27483
- function trailingMatch(a, b) {
27484
- let count = 0;
27485
- while (count < a.length && count < b.length && a[a.length - 1 - count] === b[b.length - 1 - count]) count++;
27486
- return count;
27487
- }
27488
- var JVM_EXTENSIONS = [".java", ".kt"];
27489
- function resolveJvm(ref, from, index) {
27490
- const segments = ref.specifier.split(".");
27491
- if (segments.at(-1) === "*") {
27492
- return index.inDirWithSuffix(segments.slice(0, -1).join("/")).filter((path) => path !== from && JVM_EXTENSIONS.includes(extname(path))).map((path) => ({ path, names: ref.names }));
27493
- }
27494
- for (let length = segments.length; length >= Math.min(2, segments.length); length--) {
27495
- const base = segments.slice(0, length).join("/");
27496
- const matches = closestWithSuffix(
27497
- from,
27498
- JVM_EXTENSIONS.map((ext) => base + ext),
27499
- index
27500
- );
27501
- if (matches.length > 0) return matches.map((path) => ({ path, names: ref.names }));
27502
- }
27503
- return [];
27504
- }
27505
- function resolveInclude(ref, from, index) {
27506
- const relative2 = firstRelative(dirname(from), [ref.specifier], index);
27507
- const paths = relative2 === null ? closestWithSuffix(from, [ref.specifier], index) : [relative2];
27508
- return paths.map((path) => ({ path, names: ref.names }));
27509
- }
27510
- var RUST_ROOT_STEMS = { mod: true, lib: true, main: true };
27511
- function rustModuleDir(file2) {
27512
- const stem = fileStem(file2);
27513
- const dir = dirname(file2);
27514
- if (Object.hasOwn(RUST_ROOT_STEMS, stem)) return dir;
27515
- return dir === "" ? stem : `${dir}/${stem}`;
27516
- }
27517
- function resolveRust(ref, from, index) {
27518
- const [root, ...rest] = ref.specifier.split("::");
27519
- let base = null;
27520
- if (root === "self" || root === "super") {
27521
- base = rustModuleDir(from);
27522
- if (root === "super") base = base === "" ? null : dirname(base);
27523
- while (rest[0] === "super" && base !== null) {
27524
- rest.shift();
27525
- base = base === "" ? null : dirname(base);
27526
- }
27527
- if (base === null) return [];
27528
- } else if (root !== "crate") {
27529
- const crate = root === void 0 ? void 0 : index.crate(root);
27530
- const entry = crate === void 0 ? null : index.entryOf(crate);
27531
- return entry === null ? [] : [{ path: entry, names: ref.names }];
27532
- }
27533
- for (let length = rest.length; length >= 1; length--) {
27534
- const modulePath = rest.slice(0, length).join("/");
27535
- const candidates = [`${modulePath}.rs`, `${modulePath}/mod.rs`];
27536
- const relative2 = base === null ? null : firstRelative(base, candidates, index);
27537
- const paths = base === null ? closestWithSuffix(from, candidates, index) : relative2 === null ? [] : [relative2];
27538
- if (paths.length > 0) return paths.map((path) => ({ path, names: ref.names }));
27539
- }
27540
- return [];
27541
- }
27542
- function resolveRuby(ref, from, index) {
27543
- const candidate = ref.specifier.endsWith(".rb") ? ref.specifier : `${ref.specifier}.rb`;
27544
- const path = firstRelative(dirname(from), [candidate], index);
27545
- return path === null ? [] : [{ path, names: ref.names }];
27525
+ return words;
27546
27526
  }
27547
27527
 
27548
27528
  // ../server/src/links/index.ts
27549
27529
  var MAX_PARSED_TEXT = 1e6;
27550
27530
  var MAX_DETAIL = 8;
27551
- function buildLinkGraph(files, options = {}) {
27552
- const languages = {};
27531
+ function buildLinkGraph(files, languages2, options = {}) {
27532
+ const languageIds = {};
27553
27533
  const externalImports = {};
27554
27534
  const packageImports = {};
27555
27535
  const indexed = /* @__PURE__ */ new Map();
27556
27536
  for (const file2 of files) {
27557
- const language = detectLanguage(file2.path);
27558
- languages[file2.path] = language;
27537
+ const language = languages2.detect(file2.path);
27538
+ languageIds[file2.path] = language?.info.id ?? null;
27559
27539
  externalImports[file2.path] = 0;
27560
27540
  packageImports[file2.path] = [];
27561
27541
  const key = normalizePath(file2.path);
27562
27542
  if (key === null || indexed.has(key)) continue;
27563
- const text = file2.text !== null && file2.text.length <= MAX_PARSED_TEXT ? file2.text : null;
27564
- indexed.set(key, { path: file2.path, key, language, text });
27543
+ const readable = language !== null && file2.text !== null && file2.text.length <= MAX_PARSED_TEXT;
27544
+ indexed.set(key, { path: file2.path, key, language, text: readable ? file2.text : null });
27565
27545
  }
27566
27546
  const edges = /* @__PURE__ */ new Map();
27567
27547
  const addEdge = (from, toKey, kind, detail) => {
@@ -27583,7 +27563,7 @@ function buildLinkGraph(files, options = {}) {
27583
27563
  for (const target of targets.resolved) addEdge(file2, target.path, "import", target.names);
27584
27564
  }
27585
27565
  const mentions = findMentions(
27586
- [...indexed.values()].map(({ key, text }) => ({ path: key, text })),
27566
+ [...indexed.values()].map(({ key, text: text2 }) => ({ path: key, text: text2 })),
27587
27567
  (from, to) => edges.has(`import\0${from}\0${to}`)
27588
27568
  );
27589
27569
  for (const mention of mentions) {
@@ -27597,7 +27577,7 @@ function buildLinkGraph(files, options = {}) {
27597
27577
  ...edge,
27598
27578
  detail: [...detail].slice(0, MAX_DETAIL)
27599
27579
  })),
27600
- languages,
27580
+ languages: languageIds,
27601
27581
  externalImports,
27602
27582
  packageImports
27603
27583
  };
@@ -27606,14 +27586,16 @@ function importTargets(file2, index) {
27606
27586
  const resolved = [];
27607
27587
  const packageRoots = /* @__PURE__ */ new Set();
27608
27588
  let unresolved = 0;
27609
- if (file2.text === null) return { resolved, unresolved, packageRoots: [] };
27589
+ const { language, text: text2 } = file2;
27590
+ if (language?.extractImports === void 0 || text2 === null)
27591
+ return { resolved, unresolved, packageRoots: [] };
27610
27592
  const ownRoot = index.ownPackageRoot(file2.key);
27611
27593
  try {
27612
- for (const ref of extractImports(file2.text, file2.key, file2.language)) {
27613
- const targets = resolveImport(ref, file2.key, file2.language, index);
27594
+ for (const ref of language.extractImports(text2, file2.key)) {
27595
+ const targets = language.resolveImport?.(ref, file2.key, index) ?? [];
27614
27596
  if (targets.length === 0) unresolved++;
27615
27597
  resolved.push(...targets);
27616
- const root = importedPackageRoot(ref, file2.language, index);
27598
+ const root = language.importedPackageRoot?.(ref, index) ?? null;
27617
27599
  if (root !== null && root !== ownRoot) packageRoots.add(root);
27618
27600
  }
27619
27601
  } catch {
@@ -27622,459 +27604,6 @@ function importTargets(file2, index) {
27622
27604
  return { resolved, unresolved, packageRoots: [...packageRoots].sort() };
27623
27605
  }
27624
27606
 
27625
- // ../server/src/packages/toml.ts
27626
- var TomlSyntaxError = class extends Error {
27627
- };
27628
- var ESCAPES = {
27629
- b: "\b",
27630
- t: " ",
27631
- n: "\n",
27632
- f: "\f",
27633
- r: "\r",
27634
- e: "\x1B",
27635
- '"': '"',
27636
- "\\": "\\"
27637
- };
27638
- var BARE_KEY = /[A-Za-z0-9_-]+/y;
27639
- var BARE_VALUE = /[^,\]}\r\n#]+/y;
27640
- var BASIC_STRING = /"((?:\\.|[^"\\\r\n])*)"/y;
27641
- function parseToml(text) {
27642
- return new TomlReader(text).document();
27643
- }
27644
- var TomlReader = class {
27645
- text;
27646
- pos = 0;
27647
- constructor(text) {
27648
- this.text = text;
27649
- }
27650
- document() {
27651
- const root = /* @__PURE__ */ new Map();
27652
- let current = root;
27653
- while (this.pos < this.text.length) {
27654
- this.skipBlank();
27655
- const ch = this.text[this.pos];
27656
- if (ch === void 0) break;
27657
- if (ch === "\n" || ch === "\r" || ch === "#") {
27658
- this.skipLine();
27659
- continue;
27660
- }
27661
- try {
27662
- if (ch === "[") current = this.header(root);
27663
- else this.keyValue(current);
27664
- this.endOfLine();
27665
- } catch (error62) {
27666
- if (!(error62 instanceof TomlSyntaxError)) throw error62;
27667
- if (ch === "[") current = /* @__PURE__ */ new Map();
27668
- this.skipLine();
27669
- }
27670
- }
27671
- return root;
27672
- }
27673
- /** `[a.b]` or `[[a.b]]`; returns the table that receives the following keys. */
27674
- header(root) {
27675
- const isArray = this.text.startsWith("[[", this.pos);
27676
- this.pos += isArray ? 2 : 1;
27677
- const { parents, last } = this.key();
27678
- this.expect(isArray ? "]]" : "]");
27679
- const table = parents.reduce(child, root);
27680
- if (!isArray) return child(table, last);
27681
- const existing = table.get(last);
27682
- const list = Array.isArray(existing) ? existing : [];
27683
- const created = /* @__PURE__ */ new Map();
27684
- list.push(created);
27685
- table.set(last, list);
27686
- return created;
27687
- }
27688
- keyValue(table) {
27689
- const { parents, last } = this.key();
27690
- this.expect("=");
27691
- this.skipBlank();
27692
- parents.reduce(child, table).set(last, this.value());
27693
- }
27694
- /** A possibly dotted key, split into its parent path and final segment. */
27695
- key() {
27696
- const parents = [];
27697
- let last = this.simpleKey();
27698
- for (; ; ) {
27699
- this.skipBlank();
27700
- if (this.text[this.pos] !== ".") return { parents, last };
27701
- this.pos++;
27702
- parents.push(last);
27703
- last = this.simpleKey();
27704
- }
27705
- }
27706
- simpleKey() {
27707
- this.skipBlank();
27708
- const ch = this.text[this.pos];
27709
- if (ch === '"') return this.basicString();
27710
- if (ch === "'") return this.literalString();
27711
- BARE_KEY.lastIndex = this.pos;
27712
- const match2 = BARE_KEY.exec(this.text);
27713
- if (match2 === null) throw new TomlSyntaxError(`Invalid key at ${this.pos}`);
27714
- this.pos = BARE_KEY.lastIndex;
27715
- return match2[0];
27716
- }
27717
- value() {
27718
- if (this.text.startsWith('"""', this.pos)) return this.multilineString('"""');
27719
- if (this.text.startsWith("'''", this.pos)) return this.multilineString("'''");
27720
- switch (this.text[this.pos]) {
27721
- case '"':
27722
- return this.basicString();
27723
- case "'":
27724
- return this.literalString();
27725
- case "[":
27726
- return this.array();
27727
- case "{":
27728
- return this.inlineTable();
27729
- default: {
27730
- BARE_VALUE.lastIndex = this.pos;
27731
- const match2 = BARE_VALUE.exec(this.text);
27732
- if (match2 === null || match2[0].trim() === "")
27733
- throw new TomlSyntaxError(`Missing value at ${this.pos}`);
27734
- this.pos = BARE_VALUE.lastIndex;
27735
- return null;
27736
- }
27737
- }
27738
- }
27739
- basicString() {
27740
- BASIC_STRING.lastIndex = this.pos;
27741
- const match2 = BASIC_STRING.exec(this.text);
27742
- if (match2 === null) throw new TomlSyntaxError(`Unterminated string at ${this.pos}`);
27743
- this.pos = BASIC_STRING.lastIndex;
27744
- return decodeEscapes(match2[1] ?? "");
27745
- }
27746
- literalString() {
27747
- const start = this.pos + 1;
27748
- const end = this.text.indexOf("'", start);
27749
- const newline = this.text.indexOf("\n", start);
27750
- if (end === -1 || newline !== -1 && newline < end) {
27751
- throw new TomlSyntaxError(`Unterminated string at ${this.pos}`);
27752
- }
27753
- this.pos = end + 1;
27754
- return this.text.slice(start, end);
27755
- }
27756
- /** `"""…"""` (with escapes and line-ending backslashes) or `'''…'''` (verbatim). */
27757
- multilineString(delimiter) {
27758
- let start = this.pos + 3;
27759
- if (this.text.startsWith("\r\n", start)) start += 2;
27760
- else if (this.text[start] === "\n") start++;
27761
- let end = this.text.indexOf(delimiter, start);
27762
- if (end === -1) throw new TomlSyntaxError(`Unterminated string at ${this.pos}`);
27763
- for (let extra = 0; extra < 2 && this.text[end + 3] === delimiter[0]; extra++) end++;
27764
- this.pos = end + 3;
27765
- const raw2 = this.text.slice(start, end);
27766
- return delimiter === "'''" ? raw2 : decodeEscapes(raw2.replace(/\\[ \t]*\r?\n\s*/g, ""));
27767
- }
27768
- array() {
27769
- this.pos++;
27770
- const items = [];
27771
- for (; ; ) {
27772
- this.skipInsignificant();
27773
- if (this.text[this.pos] === "]") {
27774
- this.pos++;
27775
- return items;
27776
- }
27777
- items.push(this.value());
27778
- this.skipInsignificant();
27779
- const ch = this.text[this.pos];
27780
- this.pos++;
27781
- if (ch === "]") return items;
27782
- if (ch !== ",") throw new TomlSyntaxError(`Expected , or ] at ${this.pos - 1}`);
27783
- }
27784
- }
27785
- /** `{ a = 1, b.c = "x" }`; newlines are tolerated inside, as many real manifests use them. */
27786
- inlineTable() {
27787
- this.pos++;
27788
- const table = /* @__PURE__ */ new Map();
27789
- for (; ; ) {
27790
- this.skipInsignificant();
27791
- if (this.text[this.pos] === "}") {
27792
- this.pos++;
27793
- return table;
27794
- }
27795
- this.keyValue(table);
27796
- this.skipInsignificant();
27797
- const ch = this.text[this.pos];
27798
- this.pos++;
27799
- if (ch === "}") return table;
27800
- if (ch !== ",") throw new TomlSyntaxError(`Expected , or } at ${this.pos - 1}`);
27801
- }
27802
- }
27803
- expect(token) {
27804
- this.skipBlank();
27805
- if (!this.text.startsWith(token, this.pos)) throw new TomlSyntaxError(`Expected ${token} at ${this.pos}`);
27806
- this.pos += token.length;
27807
- }
27808
- endOfLine() {
27809
- this.skipBlank();
27810
- const ch = this.text[this.pos];
27811
- if (ch === void 0 || ch === "#") this.skipLine();
27812
- else if (ch === "\n") this.pos++;
27813
- else if (this.text.startsWith("\r\n", this.pos)) this.pos += 2;
27814
- else throw new TomlSyntaxError(`Unexpected ${ch} at ${this.pos}`);
27815
- }
27816
- skipBlank() {
27817
- while (this.text[this.pos] === " " || this.text[this.pos] === " ") this.pos++;
27818
- }
27819
- /** Whitespace, newlines and comments, as allowed between array or inline-table items. */
27820
- skipInsignificant() {
27821
- for (; ; ) {
27822
- const ch = this.text[this.pos];
27823
- if (ch === " " || ch === " " || ch === "\n" || ch === "\r") this.pos++;
27824
- else if (ch === "#") this.skipLine();
27825
- else return;
27826
- }
27827
- }
27828
- skipLine() {
27829
- const newline = this.text.indexOf("\n", this.pos);
27830
- this.pos = newline === -1 ? this.text.length : newline + 1;
27831
- }
27832
- };
27833
- function child(table, key) {
27834
- const existing = table.get(key);
27835
- if (existing instanceof Map) return existing;
27836
- if (Array.isArray(existing)) {
27837
- const last = existing.at(-1);
27838
- if (last instanceof Map) return last;
27839
- }
27840
- const created = /* @__PURE__ */ new Map();
27841
- table.set(key, created);
27842
- return created;
27843
- }
27844
- function decodeEscapes(raw2) {
27845
- return raw2.replace(
27846
- /\\(?:u([0-9A-Fa-f]{4})|U([0-9A-Fa-f]{8})|([\s\S]))/g,
27847
- (match2, short, long, ch) => {
27848
- const hex3 = short ?? long;
27849
- if (hex3 !== void 0) {
27850
- const codePoint = Number.parseInt(hex3, 16);
27851
- return codePoint <= 1114111 ? String.fromCodePoint(codePoint) : "\uFFFD";
27852
- }
27853
- return ch !== void 0 && Object.hasOwn(ESCAPES, ch) ? ESCAPES[ch] ?? match2 : match2;
27854
- }
27855
- );
27856
- }
27857
-
27858
- // ../server/src/packages/manifests.ts
27859
- var MANIFEST_KINDS = {
27860
- "package.json": { ecosystem: "npm", priority: 0, read: readPackageJson },
27861
- "pyproject.toml": { ecosystem: "python", priority: 1, read: readPyproject },
27862
- "setup.py": { ecosystem: "python", priority: 2, read: readSetupPy },
27863
- "Cargo.toml": { ecosystem: "rust", priority: 3, read: readCargoToml },
27864
- "go.mod": { ecosystem: "go", priority: 4, read: readGoMod },
27865
- "pom.xml": { ecosystem: "maven", priority: 5, read: readPom },
27866
- "build.gradle": { ecosystem: "gradle", priority: 6, read: readGradle },
27867
- "build.gradle.kts": { ecosystem: "gradle", priority: 6, read: readGradle },
27868
- "composer.json": { ecosystem: "composer", priority: 7, read: readComposerJson }
27869
- };
27870
- function manifestKind(basename2) {
27871
- return Object.hasOwn(MANIFEST_KINDS, basename2) ? MANIFEST_KINDS[basename2] : void 0;
27872
- }
27873
- function readManifest(kind, text) {
27874
- if (text !== null) {
27875
- try {
27876
- return kind.read(text);
27877
- } catch {
27878
- }
27879
- }
27880
- return { name: null, deps: [], paths: [] };
27881
- }
27882
- function nonEmptyString(value) {
27883
- return typeof value === "string" && value.trim() !== "" ? value.trim() : null;
27884
- }
27885
- var DeclaredName = external_exports.string().optional().catch(void 0);
27886
- var DependencyMap = external_exports.record(external_exports.string(), external_exports.unknown()).optional().catch(void 0);
27887
- var PackageJson = external_exports.object({
27888
- name: DeclaredName,
27889
- dependencies: DependencyMap,
27890
- devDependencies: DependencyMap,
27891
- peerDependencies: DependencyMap,
27892
- optionalDependencies: DependencyMap
27893
- });
27894
- var ComposerJson = external_exports.object({ name: DeclaredName, require: DependencyMap, "require-dev": DependencyMap });
27895
- var NPM_LOCAL_SPEC = /^(?:file|link|portal):(.+)$/;
27896
- function readPackageJson(text) {
27897
- const data = PackageJson.parse(JSON.parse(text));
27898
- const deps = [];
27899
- const paths = [];
27900
- for (const entries of [
27901
- data.dependencies,
27902
- data.devDependencies,
27903
- data.peerDependencies,
27904
- data.optionalDependencies
27905
- ]) {
27906
- for (const [dep, spec] of Object.entries(entries ?? {})) {
27907
- deps.push(dep);
27908
- const local = typeof spec === "string" ? NPM_LOCAL_SPEC.exec(spec)?.[1] : void 0;
27909
- if (local !== void 0) paths.push(local);
27910
- }
27911
- }
27912
- return { name: nonEmptyString(data.name), deps, paths };
27913
- }
27914
- function readComposerJson(text) {
27915
- const data = ComposerJson.parse(JSON.parse(text));
27916
- const deps = [...Object.keys(data.require ?? {}), ...Object.keys(data["require-dev"] ?? {})];
27917
- return { name: nonEmptyString(data.name), deps, paths: [] };
27918
- }
27919
- function tomlAt(table, ...keys) {
27920
- let value = table;
27921
- for (const key of keys) value = value instanceof Map ? value.get(key) : void 0;
27922
- return value;
27923
- }
27924
- function requirementName(requirement) {
27925
- return /^\s*([A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?)/.exec(requirement)?.[1] ?? null;
27926
- }
27927
- function readPyproject(text) {
27928
- const doc = parseToml(text);
27929
- const deps = [];
27930
- const paths = [];
27931
- const requirements = (value) => {
27932
- if (!Array.isArray(value)) return;
27933
- for (const item of value) {
27934
- const name2 = typeof item === "string" ? requirementName(item) : null;
27935
- if (name2 !== null) deps.push(name2);
27936
- }
27937
- };
27938
- const keyedDependencies = (value) => {
27939
- if (!(value instanceof Map)) return;
27940
- for (const [dep, spec] of value) {
27941
- if (dep !== "python") deps.push(dep);
27942
- const path = nonEmptyString(tomlAt(spec instanceof Map ? spec : void 0, "path"));
27943
- if (path !== null) paths.push(path);
27944
- }
27945
- };
27946
- requirements(tomlAt(doc, "project", "dependencies"));
27947
- const optional2 = tomlAt(doc, "project", "optional-dependencies");
27948
- if (optional2 instanceof Map) for (const group of optional2.values()) requirements(group);
27949
- const dependencyGroups = tomlAt(doc, "dependency-groups");
27950
- if (dependencyGroups instanceof Map) for (const group of dependencyGroups.values()) requirements(group);
27951
- const poetry = tomlAt(doc, "tool", "poetry");
27952
- keyedDependencies(tomlAt(doc, "tool", "poetry", "dependencies"));
27953
- keyedDependencies(tomlAt(doc, "tool", "poetry", "dev-dependencies"));
27954
- const poetryGroups = tomlAt(doc, "tool", "poetry", "group");
27955
- if (poetryGroups instanceof Map) {
27956
- for (const group of poetryGroups.values()) {
27957
- keyedDependencies(tomlAt(group instanceof Map ? group : void 0, "dependencies"));
27958
- }
27959
- }
27960
- keyedDependencies(tomlAt(doc, "tool", "uv", "sources"));
27961
- const name = nonEmptyString(tomlAt(doc, "project", "name")) ?? nonEmptyString(tomlAt(poetry instanceof Map ? poetry : void 0, "name"));
27962
- return { name, deps, paths };
27963
- }
27964
- var CARGO_DEPENDENCY_TABLES = ["dependencies", "dev-dependencies", "build-dependencies"];
27965
- function readCargoToml(text) {
27966
- const doc = parseToml(text);
27967
- const deps = [];
27968
- const paths = [];
27969
- const tables = [
27970
- ...CARGO_DEPENDENCY_TABLES.map((key) => doc.get(key)),
27971
- tomlAt(doc, "workspace", "dependencies")
27972
- ];
27973
- const targets = doc.get("target");
27974
- if (targets instanceof Map) {
27975
- for (const target of targets.values()) {
27976
- if (target instanceof Map) tables.push(...CARGO_DEPENDENCY_TABLES.map((key) => target.get(key)));
27977
- }
27978
- }
27979
- for (const table of tables) {
27980
- if (!(table instanceof Map)) continue;
27981
- for (const [key, spec] of table) {
27982
- const detail = spec instanceof Map ? spec : void 0;
27983
- deps.push(nonEmptyString(tomlAt(detail, "package")) ?? key);
27984
- const path = nonEmptyString(tomlAt(detail, "path"));
27985
- if (path !== null) paths.push(path);
27986
- }
27987
- }
27988
- return { name: nonEmptyString(tomlAt(doc, "package", "name")), deps, paths };
27989
- }
27990
- var PYTHON_LIST_TOKEN = /(['"])((?:\\.|(?!\1)[^\\\n])*)\1|#[^\n]*|[\])]/g;
27991
- function readSetupPy(text) {
27992
- const name = /\bname\s*=\s*(['"])([^'"\n]+)\1/.exec(text)?.[2] ?? null;
27993
- const deps = [];
27994
- const opener = /\binstall_requires\s*=\s*[[(]/.exec(text);
27995
- if (opener !== null) {
27996
- PYTHON_LIST_TOKEN.lastIndex = opener.index + opener[0].length;
27997
- for (let token = PYTHON_LIST_TOKEN.exec(text); token !== null; token = PYTHON_LIST_TOKEN.exec(text)) {
27998
- if (token[0] === "]" || token[0] === ")") break;
27999
- const dep = token[1] !== void 0 ? requirementName(token[2] ?? "") : null;
28000
- if (dep !== null) deps.push(dep);
28001
- }
28002
- }
28003
- return { name: nonEmptyString(name), deps, paths: [] };
28004
- }
28005
- function readGoMod(text) {
28006
- let name = null;
28007
- const deps = [];
28008
- const paths = [];
28009
- const directive = (verb, args) => {
28010
- const first = args.split(/\s+/)[0]?.replace(/^"(.*)"$/, "$1") ?? "";
28011
- if (verb === "module" && first !== "") name = first;
28012
- else if (verb === "require" && first !== "") deps.push(first);
28013
- else if (verb === "replace") {
28014
- const target = args.split("=>")[1]?.trim().split(/\s+/)[0] ?? "";
28015
- if (/^\.\.?(?:\/|$)/.test(target)) paths.push(target);
28016
- }
28017
- };
28018
- let block = null;
28019
- for (const raw2 of text.split("\n")) {
28020
- const commentAt = raw2.indexOf("//");
28021
- const line = (commentAt === -1 ? raw2 : raw2.slice(0, commentAt)).trim();
28022
- if (line === "") continue;
28023
- if (block !== null) {
28024
- if (line === ")") block = null;
28025
- else directive(block, line);
28026
- continue;
28027
- }
28028
- const match2 = /^([a-z]+)\s*(.*)$/.exec(line);
28029
- const verb = match2?.[1];
28030
- const args = match2?.[2] ?? "";
28031
- if (verb === void 0) continue;
28032
- if (args === "(") block = verb;
28033
- else directive(verb, args);
28034
- }
28035
- return { name, deps, paths };
28036
- }
28037
- var XML_TAG = /<(\/?)([A-Za-z_][\w.:-]*)[^>]*?(\/?)>/g;
28038
- function readPom(text) {
28039
- const xml = text.replace(/<!--[\s\S]*?-->/g, "").replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, "");
28040
- const stack = [];
28041
- let name = null;
28042
- const deps = [];
28043
- for (const match2 of xml.matchAll(XML_TAG)) {
28044
- const [whole, closing, qualified = "", selfClosing] = match2;
28045
- const tag = qualified.slice(qualified.lastIndexOf(":") + 1);
28046
- if (selfClosing === "/") continue;
28047
- if (closing !== "/") {
28048
- stack.push({ tag, contentStart: match2.index + whole.length });
28049
- continue;
28050
- }
28051
- const openAt = stack.findLastIndex((element) => element.tag === tag);
28052
- const open2 = stack[openAt];
28053
- if (open2 === void 0) continue;
28054
- if (tag === "artifactId") {
28055
- const value = nonEmptyString(xml.slice(open2.contentStart, match2.index));
28056
- const ancestors = stack.slice(0, openAt).map((element) => element.tag);
28057
- if (value !== null && ancestors.length === 1 && ancestors[0] === "project") name ??= value;
28058
- else if (value !== null && ancestors.at(-1) === "dependency" && !ancestors.includes("dependencyManagement")) {
28059
- deps.push(value);
28060
- }
28061
- }
28062
- stack.length = openAt;
28063
- }
28064
- return { name, deps, paths: [] };
28065
- }
28066
- var C_COMMENT_OR_STRING = /("(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*')|\/\/[^\n]*|\/\*[\s\S]*?\*\//g;
28067
- var GRADLE_PROJECT_REF = /\bproject\s*\(\s*(?:path\s*[:=]\s*)?(['"])(:[^'"]*)\1/g;
28068
- function readGradle(text) {
28069
- const code = text.replace(C_COMMENT_OR_STRING, (_match, literal2) => literal2 ?? "");
28070
- const deps = [];
28071
- for (const match2 of code.matchAll(GRADLE_PROJECT_REF)) {
28072
- const path = (match2[2] ?? "").split(":").filter(Boolean).join("/");
28073
- if (path !== "") deps.push(path);
28074
- }
28075
- return { name: null, deps, paths: [] };
28076
- }
28077
-
28078
27607
  // ../server/src/packages/index.ts
28079
27608
  var REPO_ROOT_NAME = "(racine)";
28080
27609
  var EXCLUDED_DIRS = {
@@ -28082,53 +27611,72 @@ var EXCLUDED_DIRS = {
28082
27611
  vendor: true,
28083
27612
  dist: true,
28084
27613
  build: true,
28085
- target: true,
28086
27614
  out: true,
28087
27615
  ".git": true,
28088
- ".venv": true,
28089
- venv: true,
28090
- __pycache__: true,
28091
27616
  coverage: true,
28092
27617
  fixtures: true,
28093
27618
  __fixtures__: true,
28094
27619
  testdata: true,
28095
27620
  __mocks__: true
28096
27621
  };
28097
- function isManifestPath(path) {
27622
+ function manifestKind(basename2, ecosystems2) {
27623
+ let priority = 0;
27624
+ for (const ecosystem of ecosystems2) {
27625
+ for (const manifest of ecosystem.manifests) {
27626
+ if (manifest === basename2) return { ecosystem, priority };
27627
+ priority++;
27628
+ }
27629
+ }
27630
+ return void 0;
27631
+ }
27632
+ function isManifestPath(path, ecosystems2) {
28098
27633
  const segments = path.split("/");
28099
27634
  const basename2 = segments.pop() ?? "";
28100
- return manifestKind(basename2) !== void 0 && !segments.some((segment) => Object.hasOwn(EXCLUDED_DIRS, segment));
27635
+ return manifestKind(basename2, ecosystems2) !== void 0 && !segments.some((segment) => Object.hasOwn(EXCLUDED_DIRS, segment));
27636
+ }
27637
+ function readManifest(ecosystem, path, text2) {
27638
+ if (text2 !== null) {
27639
+ try {
27640
+ return ecosystem.readManifest(text2, path.slice(path.lastIndexOf("/") + 1));
27641
+ } catch {
27642
+ }
27643
+ }
27644
+ return { name: null, deps: [], paths: [] };
28101
27645
  }
28102
- function parseWorkspace(manifests) {
27646
+ function parseWorkspace(manifests, ecosystems2) {
28103
27647
  const chosen = /* @__PURE__ */ new Map();
28104
27648
  for (const file2 of manifests) {
28105
27649
  const slash = file2.path.lastIndexOf("/");
28106
- const kind = isManifestPath(file2.path) ? manifestKind(file2.path.slice(slash + 1)) : void 0;
27650
+ const kind = isManifestPath(file2.path, ecosystems2) ? manifestKind(file2.path.slice(slash + 1), ecosystems2) : void 0;
28107
27651
  if (kind === void 0) continue;
28108
27652
  const root = slash === -1 ? "" : file2.path.slice(0, slash);
28109
27653
  const current = chosen.get(root);
28110
27654
  const wins = current === void 0 || kind.priority < current.kind.priority || kind.priority === current.kind.priority && file2.path < current.file.path;
28111
27655
  if (wins) chosen.set(root, { file: file2, kind });
28112
27656
  }
28113
- const parsed = [...chosen].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([root, { file: file2, kind }]) => ({ root, path: file2.path, kind, info: readManifest(kind, file2.text) }));
27657
+ const parsed = [...chosen].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([root, { file: file2, kind }]) => ({
27658
+ root,
27659
+ path: file2.path,
27660
+ ecosystem: kind.ecosystem,
27661
+ info: readManifest(kind.ecosystem, file2.path, file2.text)
27662
+ }));
28114
27663
  const byName = /* @__PURE__ */ new Map();
28115
- for (const { root, kind, info } of parsed) {
27664
+ const matchKey = (ecosystem, name) => ecosystem.normalizeName?.(name) ?? name;
27665
+ for (const { root, ecosystem, info } of parsed) {
28116
27666
  if (info.name === null) continue;
28117
- let names = byName.get(kind.ecosystem);
27667
+ let names = byName.get(ecosystem);
28118
27668
  if (names === void 0) {
28119
27669
  names = /* @__PURE__ */ new Map();
28120
- byName.set(kind.ecosystem, names);
27670
+ byName.set(ecosystem, names);
28121
27671
  }
28122
- const key = matchKey(kind.ecosystem, info.name);
27672
+ const key = matchKey(ecosystem, info.name);
28123
27673
  if (!names.has(key)) names.set(key, root);
28124
27674
  }
28125
27675
  const roots = new Set(parsed.map(({ root }) => root));
28126
- const gradleRoots = parsed.filter(({ kind }) => kind.ecosystem === "gradle").map(({ root }) => root);
28127
- return parsed.map(({ root, path, kind, info }) => {
28128
- const { ecosystem } = kind;
27676
+ return parsed.map(({ root, path, ecosystem, info }) => {
28129
27677
  const targets = /* @__PURE__ */ new Set();
28130
27678
  for (const dep of info.deps) {
28131
- const target = ecosystem === "gradle" ? resolveGradleProject(dep, root, gradleRoots) : byName.get(ecosystem)?.get(matchKey(ecosystem, dep));
27679
+ const target = byName.get(ecosystem)?.get(matchKey(ecosystem, dep));
28132
27680
  if (target !== void 0) targets.add(target);
28133
27681
  }
28134
27682
  for (const relative2 of info.paths) {
@@ -28136,11 +27684,10 @@ function parseWorkspace(manifests) {
28136
27684
  if (target !== null && roots.has(target)) targets.add(target);
28137
27685
  }
28138
27686
  targets.delete(root);
28139
- const fallback = ecosystem === "gradle" ? root.slice(root.lastIndexOf("/") + 1) : root;
28140
27687
  return {
28141
27688
  root,
28142
- name: info.name ?? (fallback === "" ? REPO_ROOT_NAME : fallback),
28143
- ecosystem,
27689
+ name: info.name ?? (root === "" ? REPO_ROOT_NAME : root),
27690
+ ecosystem: ecosystem.id,
28144
27691
  manifest: path,
28145
27692
  dependsOn: [...targets].sort()
28146
27693
  };
@@ -28154,16 +27701,6 @@ function packageRootOf(path, roots) {
28154
27701
  }
28155
27702
  return best;
28156
27703
  }
28157
- function matchKey(ecosystem, name) {
28158
- switch (ecosystem) {
28159
- case "python":
28160
- return name.toLowerCase().replace(/[-_.]+/g, "-");
28161
- case "rust":
28162
- return name.toLowerCase().replace(/_/g, "-");
28163
- default:
28164
- return name;
28165
- }
28166
- }
28167
27704
  function resolvePath(dir, relative2) {
28168
27705
  const normalized = relative2.replace(/\\/g, "/");
28169
27706
  if (normalized.startsWith("/") || /^[A-Za-z]:/.test(normalized)) return null;
@@ -28175,43 +27712,9 @@ function resolvePath(dir, relative2) {
28175
27712
  }
28176
27713
  return segments.join("/");
28177
27714
  }
28178
- function resolveGradleProject(projectPath, from, gradleRoots) {
28179
- let best;
28180
- let bestDepth = -1;
28181
- for (const root of gradleRoots) {
28182
- if (root !== projectPath && !root.endsWith(`/${projectPath}`)) continue;
28183
- const base = root.slice(0, Math.max(0, root.length - projectPath.length - 1));
28184
- const depth = base === "" || from === base || from.startsWith(`${base}/`) ? base.length : -1;
28185
- if (best === void 0 || depth > bestDepth) {
28186
- best = root;
28187
- bestDepth = depth;
28188
- }
28189
- }
28190
- if (best !== void 0) return best;
28191
- const projectName = projectPath.slice(projectPath.lastIndexOf("/") + 1);
28192
- const byBasename = gradleRoots.filter((root) => root.slice(root.lastIndexOf("/") + 1) === projectName);
28193
- return byBasename.length === 1 ? byBasename[0] : void 0;
28194
- }
28195
27715
 
28196
27716
  // ../server/src/prLinks.ts
28197
- var LINKS_VERSION = 6;
28198
- var BATCH = 50;
28199
- var languageSchema = external_exports.enum([
28200
- "typescript",
28201
- "javascript",
28202
- "python",
28203
- "css",
28204
- "go",
28205
- "java",
28206
- "kotlin",
28207
- "c",
28208
- "cpp",
28209
- "rust",
28210
- "ruby",
28211
- "vue",
28212
- "svelte",
28213
- "markdown"
28214
- ]).nullable();
27717
+ var LINKS_VERSION = 7;
28215
27718
  var cachedSchema = external_exports.object({
28216
27719
  edges: external_exports.array(
28217
27720
  external_exports.object({
@@ -28221,7 +27724,7 @@ var cachedSchema = external_exports.object({
28221
27724
  detail: external_exports.array(external_exports.string())
28222
27725
  })
28223
27726
  ),
28224
- languages: external_exports.record(external_exports.string(), languageSchema),
27727
+ languages: external_exports.record(external_exports.string(), external_exports.string().nullable()),
28225
27728
  externalImports: external_exports.record(external_exports.string(), external_exports.number()),
28226
27729
  packageImports: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
28227
27730
  files: external_exports.array(external_exports.object({ path: external_exports.string(), status: external_exports.enum(["added", "deleted", "modified", "renamed"]) })),
@@ -28230,7 +27733,7 @@ var cachedSchema = external_exports.object({
28230
27733
  external_exports.object({
28231
27734
  root: external_exports.string(),
28232
27735
  name: external_exports.string(),
28233
- ecosystem: external_exports.enum(["npm", "python", "go", "rust", "maven", "gradle", "composer"]),
27736
+ ecosystem: external_exports.string(),
28234
27737
  files: external_exports.array(external_exports.string()),
28235
27738
  dependsOn: external_exports.array(external_exports.string()),
28236
27739
  usedBy: external_exports.array(external_exports.string())
@@ -28240,7 +27743,7 @@ var cachedSchema = external_exports.object({
28240
27743
  external_exports.object({
28241
27744
  root: external_exports.string(),
28242
27745
  name: external_exports.string(),
28243
- ecosystem: external_exports.enum(["npm", "python", "go", "rust", "maven", "gradle", "composer"]),
27746
+ ecosystem: external_exports.string(),
28244
27747
  touched: external_exports.boolean()
28245
27748
  })
28246
27749
  ),
@@ -28256,49 +27759,10 @@ async function manifestPaths(gh, store, ref, head) {
28256
27759
  const tree = await gh.rest(
28257
27760
  `/repos/${ref.owner}/${ref.repo}/git/trees/${head}?recursive=1`
28258
27761
  );
28259
- const paths = tree.tree.filter((t2) => t2.type === "blob" && isManifestPath(t2.path)).map((t2) => t2.path);
27762
+ const paths = tree.tree.filter((t2) => t2.type === "blob" && isManifestPath(t2.path, ecosystems)).map((t2) => t2.path);
28260
27763
  store.putDiff(key, JSON.stringify(paths));
28261
27764
  return paths;
28262
27765
  }
28263
- var SRC_EXTENSIONS = [".ts", ".tsx", ".mts", ".js", ".jsx"];
28264
- function exportTargets(value) {
28265
- if (typeof value === "string") return [value];
28266
- if (!value || typeof value !== "object") return [];
28267
- const entries = Object.entries(value);
28268
- const root = entries.find(([k]) => k === ".");
28269
- const ordered = root ? [root] : entries.filter(([k]) => !k.startsWith("./"));
28270
- return ordered.flatMap(([, v]) => exportTargets(v));
28271
- }
28272
- function entryCandidates(pkg, manifestText) {
28273
- const join5 = (rel) => {
28274
- const clean = rel.replace(/^\.\//, "");
28275
- return pkg.root ? `${pkg.root}/${clean}` : clean;
28276
- };
28277
- const out = [];
28278
- if (pkg.ecosystem === "npm" && manifestText) {
28279
- let manifest = null;
28280
- try {
28281
- manifest = JSON.parse(manifestText);
28282
- } catch {
28283
- }
28284
- if (manifest && typeof manifest === "object") {
28285
- const fields = ["exports", "module", "main", "types", "typings"];
28286
- for (const field of fields) {
28287
- if (!(field in manifest)) continue;
28288
- const value = Reflect.get(manifest, field);
28289
- for (const target of exportTargets(value)) {
28290
- out.push(join5(target));
28291
- const source = target.replace(/^\.?\/?(dist|build|lib|out)\//, "src/").replace(/(\.d)?\.(m|c)?[jt]sx?$/, "");
28292
- if (source !== target) for (const ext of SRC_EXTENSIONS) out.push(join5(source + ext));
28293
- }
28294
- }
28295
- }
28296
- for (const base of ["src/index", "index", "src/main"])
28297
- for (const ext of SRC_EXTENSIONS) out.push(join5(base + ext));
28298
- }
28299
- if (pkg.ecosystem === "rust") out.push(join5("src/lib.rs"), join5("src/main.rs"));
28300
- return [...new Set(out)];
28301
- }
28302
27766
  async function loadWorkspace(gh, store, ref, head) {
28303
27767
  const manifests = await manifestPaths(gh, store, ref, head);
28304
27768
  const dirs = new Set(manifests.map((p) => p.includes("/") ? p.slice(0, p.lastIndexOf("/")) : ""));
@@ -28306,13 +27770,17 @@ async function loadWorkspace(gh, store, ref, head) {
28306
27770
  const texts = await fetchTexts(
28307
27771
  gh,
28308
27772
  ref,
28309
- manifests.map((path) => ({ path, oid: head }))
27773
+ manifests.map((path) => `${head}:${path}`)
27774
+ );
27775
+ const textOf = (path) => texts.get(`${head}:${path}`) ?? null;
27776
+ const packages = parseWorkspace(
27777
+ manifests.map((path) => ({ path, text: textOf(path) })),
27778
+ ecosystems
28310
27779
  );
28311
- const packages = parseWorkspace(manifests.map((path) => ({ path, text: texts.get(path) ?? null })));
28312
27780
  const refs = packages.map((p) => ({
28313
27781
  name: p.name,
28314
27782
  root: p.root,
28315
- entries: entryCandidates(p, texts.get(p.manifest) ?? null)
27783
+ entries: ecosystems.find((e) => e.id === p.ecosystem)?.entryCandidates(p.root, textOf(p.manifest)) ?? []
28316
27784
  }));
28317
27785
  return { packages, refs };
28318
27786
  }
@@ -28363,25 +27831,6 @@ ${to}`;
28363
27831
  packageEdges
28364
27832
  };
28365
27833
  }
28366
- async function fetchTexts(gh, ref, wanted) {
28367
- const texts = /* @__PURE__ */ new Map();
28368
- for (let i = 0; i < wanted.length; i += BATCH) {
28369
- const batch = wanted.slice(i, i + BATCH);
28370
- const vars = { owner: ref.owner, repo: ref.repo };
28371
- batch.forEach((w, k) => vars[`e${k}`] = `${w.oid}:${w.path}`);
28372
- const query = `query(${["$owner: String!", "$repo: String!", ...batch.map((_, k) => `$e${k}: String!`)].join(", ")}) {
28373
- repository(owner: $owner, name: $repo) {
28374
- ${batch.map((_, k) => `f${k}: object(expression: $e${k}) { ... on Blob { text isBinary isTruncated } }`).join("\n")}
28375
- }
28376
- }`;
28377
- const data = await gh.graphql(query, vars);
28378
- batch.forEach((w, k) => {
28379
- const blob = data.repository[`f${k}`];
28380
- texts.set(w.path, blob && !blob.isBinary && !blob.isTruncated ? blob.text : null);
28381
- });
28382
- }
28383
- return texts;
28384
- }
28385
27834
  async function loadLinks(gh, store, ref, base, head, fullPr) {
28386
27835
  const cacheKey2 = `links:v${LINKS_VERSION}:${ref.owner}/${ref.repo}:${base}...${head}`.toLowerCase();
28387
27836
  const cached2 = store.getDiff(cacheKey2);
@@ -28390,25 +27839,18 @@ async function loadLinks(gh, store, ref, base, head, fullPr) {
28390
27839
  if (parsed.success) return parsed.data;
28391
27840
  }
28392
27841
  const diff = await loadDiff(gh, store, ref, base, head, fullPr);
28393
- const readable = diff.files.filter((f) => !f.binary);
28394
- const texts = await fetchTexts(
28395
- gh,
28396
- ref,
28397
- readable.map(
28398
- (f) => f.status === "deleted" ? { path: f.oldPath, oid: base } : { path: f.path, oid: head }
28399
- )
28400
- );
28401
- const sources = diff.files.map((f) => ({
28402
- path: f.path,
28403
- text: f.binary ? null : texts.get(f.status === "deleted" ? f.oldPath : f.path) ?? null
28404
- }));
27842
+ const analysed = diff.files.filter((f) => languages.detect(f.path) !== null);
27843
+ const expression = (f) => f.status === "deleted" ? `${base}:${f.oldPath}` : `${head}:${f.path}`;
27844
+ const texts = await fetchTexts(gh, ref, analysed.filter((f) => !f.binary).map(expression));
27845
+ const textOf = (f) => f.binary ? null : texts.get(expression(f)) ?? null;
27846
+ const sources = diff.files.map((f) => ({ path: f.path, text: textOf(f) }));
28405
27847
  const workspace = await loadWorkspace(gh, store, ref, head);
28406
- const graph = buildLinkGraph(sources, workspace ? { packages: workspace.refs } : void 0);
27848
+ const graph = buildLinkGraph(sources, languages, workspace ? { packages: workspace.refs } : void 0);
28407
27849
  const paths = diff.files.map((f) => f.path);
28408
27850
  const links = {
28409
27851
  ...graph,
28410
27852
  files: diff.files.map((f) => ({ path: f.path, status: f.status })),
28411
- unreadable: sources.filter((s) => s.text === null).map((s) => s.path),
27853
+ unreadable: analysed.filter((f) => textOf(f) === null).map((f) => f.path),
28412
27854
  ...workspace ? orderPackages(workspace.packages, paths, graph.edges) : { packages: [], workspace: [], packageEdges: [] }
28413
27855
  };
28414
27856
  store.putDiff(cacheKey2, JSON.stringify(links));
@@ -28836,6 +28278,7 @@ var prRouter = router({
28836
28278
  get: procedure.input(prRefSchema).query(({ ctx, input: input2 }) => loadPr(ctx.gh, ctx.store, input2)),
28837
28279
  diff: procedure.input(external_exports.object({ ref: prRefSchema, base: shaSchema, head: shaSchema, fullPr: external_exports.boolean() })).query(({ ctx, input: input2 }) => loadDiff(ctx.gh, ctx.store, input2.ref, input2.base, input2.head, input2.fullPr)),
28838
28280
  links: procedure.input(external_exports.object({ ref: prRefSchema, base: shaSchema, head: shaSchema, fullPr: external_exports.boolean() })).query(({ ctx, input: input2 }) => loadLinks(ctx.gh, ctx.store, input2.ref, input2.base, input2.head, input2.fullPr)),
28281
+ blobs: procedure.input(external_exports.object({ ref: prRefSchema, oids: external_exports.array(shaSchema).min(1).max(2) })).query(({ ctx, input: input2 }) => loadBlobs(ctx.gh, ctx.store, input2.ref, input2.oids)),
28839
28282
  onChange: procedure.input(prRefSchema).subscription(async function* ({ ctx, input: input2, signal }) {
28840
28283
  yield* pollChanges(PR_POLL_MS, signal, () => prFingerprint(ctx.gh, input2, signal));
28841
28284
  }),
@@ -28971,8 +28414,11 @@ function createApp(options) {
28971
28414
  );
28972
28415
  if (options.webDist && existsSync2(options.webDist)) {
28973
28416
  const root = relative(process.cwd(), options.webDist);
28974
- app.use("/*", serveStatic({ root }));
28975
- app.get("*", serveStatic({ root, rewriteRequestPath: () => "/index.html" }));
28417
+ const onFound = (path, c) => {
28418
+ if (path.endsWith("index.html")) c.header("Cache-Control", "no-cache");
28419
+ };
28420
+ app.use("/*", serveStatic({ root, onFound }));
28421
+ app.get("*", serveStatic({ root, rewriteRequestPath: () => "/index.html", onFound }));
28976
28422
  }
28977
28423
  return app;
28978
28424
  }
@@ -29036,11 +28482,11 @@ var ConfigStore = class extends EventEmitter {
29036
28482
  }
29037
28483
  }
29038
28484
  #write(next) {
29039
- const text = JSON.stringify(next, null, 2) + "\n";
28485
+ const text2 = JSON.stringify(next, null, 2) + "\n";
29040
28486
  const tmp = this.path + ".tmp";
29041
- writeFileSync(tmp, text);
28487
+ writeFileSync(tmp, text2);
29042
28488
  renameSync(tmp, this.path);
29043
- this.#lastWritten = text;
28489
+ this.#lastWritten = text2;
29044
28490
  this.#config = next;
29045
28491
  this.emit("change", next);
29046
28492
  return next;