@neat.is/core 0.7.7 → 0.7.8

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.
@@ -1780,6 +1780,7 @@ var ROUTER_METHODS = /* @__PURE__ */ new Set([
1780
1780
  "all"
1781
1781
  ]);
1782
1782
  var NEXT_APP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
1783
+ var NET_HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
1783
1784
  var JS_ROUTE_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".jsx", ".mjs", ".cjs", ".ts", ".tsx"]);
1784
1785
  function goRouterRoutesFromSource(source, parser, framework) {
1785
1786
  const tree = parseSource2(parser, source);
@@ -1833,6 +1834,101 @@ function echoRoutesFromSource(source, parser) {
1833
1834
  function fiberRoutesFromSource(source, parser) {
1834
1835
  return goRouterRoutesFromSource(source, parser, "fiber");
1835
1836
  }
1837
+ function chiRoutesFromSource(source, parser) {
1838
+ const tree = parseSource2(parser, source);
1839
+ const out = [];
1840
+ chiWalk(tree.rootNode, "", out);
1841
+ return out;
1842
+ }
1843
+ function stripChiRegex(path64) {
1844
+ return path64.replace(/\{([^{}:]+):[^{}]*\}/g, "{$1}");
1845
+ }
1846
+ function chiWalk(node, prefix, out) {
1847
+ for (let i = 0; i < node.namedChildCount; i++) {
1848
+ const child = node.namedChild(i);
1849
+ if (child) chiHandle(child, prefix, out);
1850
+ }
1851
+ }
1852
+ function chiHandle(node, prefix, out) {
1853
+ if (node.type === "call_expression") {
1854
+ const fn = node.childForFieldName("function");
1855
+ if (fn?.type === "selector_expression") {
1856
+ const field = fn.childForFieldName("field")?.text;
1857
+ const args = node.childForFieldName("arguments");
1858
+ if (field === "Route") {
1859
+ const leaf = goStringLiteral(args?.namedChild(0));
1860
+ const closure = args?.namedChild(1);
1861
+ if (leaf !== null && closure?.type === "func_literal") {
1862
+ const body = closure.childForFieldName("body");
1863
+ if (body) chiWalk(body, prefix + leaf, out);
1864
+ }
1865
+ return;
1866
+ }
1867
+ if (field === "Group") {
1868
+ const closure = args?.namedChild(0);
1869
+ if (closure?.type === "func_literal") {
1870
+ const body = closure.childForFieldName("body");
1871
+ if (body) chiWalk(body, prefix, out);
1872
+ }
1873
+ return;
1874
+ }
1875
+ if (field === "Mount") {
1876
+ return;
1877
+ }
1878
+ if (field && ROUTER_METHODS.has(field.toLowerCase())) {
1879
+ const leaf = goStringLiteral(args?.namedChild(0));
1880
+ if (leaf !== null) {
1881
+ out.push({
1882
+ method: field.toUpperCase(),
1883
+ pathTemplate: canonicalizeTemplate(stripChiRegex(prefix + leaf)),
1884
+ line: node.startPosition.row + 1,
1885
+ framework: "chi"
1886
+ });
1887
+ }
1888
+ return;
1889
+ }
1890
+ }
1891
+ }
1892
+ chiWalk(node, prefix, out);
1893
+ }
1894
+ function netHttpRoutesFromSource(source, parser) {
1895
+ const tree = parseSource2(parser, source);
1896
+ if (!goImportsNetHttp(tree.rootNode)) return [];
1897
+ const out = [];
1898
+ walk(tree.rootNode, (node) => {
1899
+ if (node.type !== "call_expression") return;
1900
+ const fn = node.childForFieldName("function");
1901
+ if (fn?.type !== "selector_expression") return;
1902
+ const field = fn.childForFieldName("field")?.text;
1903
+ if (field !== "HandleFunc" && field !== "Handle") return;
1904
+ const leaf = goStringLiteral(node.childForFieldName("arguments")?.namedChild(0));
1905
+ if (leaf === null) return;
1906
+ const sp = leaf.indexOf(" ");
1907
+ if (sp < 0) return;
1908
+ const method = leaf.slice(0, sp);
1909
+ const rest = leaf.slice(sp + 1);
1910
+ if (!NET_HTTP_METHODS.has(method)) return;
1911
+ if (!rest.startsWith("/")) return;
1912
+ out.push({
1913
+ method,
1914
+ pathTemplate: canonicalizeTemplate(rest),
1915
+ line: node.startPosition.row + 1,
1916
+ framework: "net/http"
1917
+ });
1918
+ });
1919
+ return out;
1920
+ }
1921
+ function goImportsNetHttp(root) {
1922
+ let found = false;
1923
+ walk(root, (node) => {
1924
+ if (found || node.type !== "import_spec") return;
1925
+ for (let i = 0; i < node.namedChildCount; i++) {
1926
+ const child = node.namedChild(i);
1927
+ if (goStringLiteral(child) === "net/http") found = true;
1928
+ }
1929
+ });
1930
+ return found;
1931
+ }
1836
1932
  var FASTAPI_METHODS = /* @__PURE__ */ new Set(["get", "post", "put", "patch", "delete", "options", "head", "trace"]);
1837
1933
  var NESTJS_METHODS = /* @__PURE__ */ new Map([
1838
1934
  ["Get", "GET"],
@@ -3098,9 +3194,11 @@ async function addRoutes(graph, services) {
3098
3194
  const hasGin = deps["github.com/gin-gonic/gin"] !== void 0;
3099
3195
  const hasEcho = deps["github.com/labstack/echo/v4"] !== void 0 || deps["github.com/labstack/echo"] !== void 0;
3100
3196
  const hasFiber = deps["github.com/gofiber/fiber/v2"] !== void 0 || deps["github.com/gofiber/fiber/v3"] !== void 0;
3197
+ const hasChi = deps["github.com/go-chi/chi/v5"] !== void 0 || deps["github.com/go-chi/chi"] !== void 0;
3198
+ const isGoService = service.node.language === "go";
3101
3199
  const hasRails = deps["rails"] !== void 0;
3102
3200
  const hasLaravel = deps["laravel/framework"] !== void 0;
3103
- if (!hasExpress && !hasFastify && !hasHono && !hasNext && !hasNestjs && !hasFastapi && !hasFlask && !hasDjango && !hasGin && !hasEcho && !hasFiber && !hasRails && !hasLaravel)
3201
+ if (!hasExpress && !hasFastify && !hasHono && !hasNext && !hasNestjs && !hasFastapi && !hasFlask && !hasDjango && !hasGin && !hasEcho && !hasFiber && !hasChi && !isGoService && !hasRails && !hasLaravel)
3104
3202
  continue;
3105
3203
  const files = await loadSourceFiles(service.dir);
3106
3204
  const mountPrefixes = hasExpress ? await expressMountPrefixes(files, service.dir, await loadTsPathConfig(service.dir)) : /* @__PURE__ */ new Map();
@@ -3127,7 +3225,9 @@ async function addRoutes(graph, services) {
3127
3225
  if (hasGin) routes = ginRoutesFromSource(file.content, goParser);
3128
3226
  else if (hasEcho) routes = echoRoutesFromSource(file.content, goParser);
3129
3227
  else if (hasFiber) routes = fiberRoutesFromSource(file.content, goParser);
3228
+ else if (hasChi) routes = chiRoutesFromSource(file.content, goParser);
3130
3229
  else routes = [];
3230
+ routes = routes.concat(netHttpRoutesFromSource(file.content, goParser));
3131
3231
  } else if (isPy) {
3132
3232
  routes = hasFastapi || hasFlask ? pythonRoutesFromSource(file.content, pyParser, hasFastapi ? "fastapi" : "flask") : [];
3133
3233
  if (hasDjango) routes = routes.concat(djangoRoutesFromSource(file.content, pyParser));
@@ -5268,6 +5368,7 @@ function goFramework(deps) {
5268
5368
  if (deps["github.com/gin-gonic/gin"]) return "gin";
5269
5369
  if (deps["github.com/labstack/echo/v4"] || deps["github.com/labstack/echo"]) return "echo";
5270
5370
  if (deps["github.com/gofiber/fiber/v2"] || deps["github.com/gofiber/fiber/v3"]) return "fiber";
5371
+ if (deps["github.com/go-chi/chi/v5"] || deps["github.com/go-chi/chi"]) return "chi";
5271
5372
  return void 0;
5272
5373
  }
5273
5374
  async function discoverGoService(scanPath, dir) {
@@ -17934,4 +18035,4 @@ export {
17934
18035
  deprovisionConnector,
17935
18036
  buildApi
17936
18037
  };
17937
- //# sourceMappingURL=chunk-UI3AFJAF.js.map
18038
+ //# sourceMappingURL=chunk-LN75Z624.js.map