@rayburst/cli 0.2.4 → 0.2.5

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.
@@ -309,21 +309,37 @@ function getUniqueNodeId(filePath, nodeName, gitHash, usedIds, idCounters) {
309
309
  return id;
310
310
  }
311
311
  function isReactComponent(func) {
312
- const name = func.getName() || func.getParent()?.asKind?.(SyntaxKind.VariableDeclaration)?.getName?.();
313
- const hasComponentName = name && /^[A-Z]/.test(name);
314
- const returnType = func.getReturnType().getText();
315
- const hasJsxReturnType = returnType.includes("JSX.Element") || returnType.includes("React.ReactElement") || returnType.includes("ReactElement") || returnType.includes("React.ReactNode") || returnType.includes("ReactNode");
316
- const body = func.getBody();
317
- if (!body) return false;
318
- const hasJsxElements = body.getDescendantsOfKind(SyntaxKind.JsxElement).length > 0 || body.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement).length > 0 || body.getDescendantsOfKind(SyntaxKind.JsxFragment).length > 0;
319
- const hasHooks = body.getDescendantsOfKind(SyntaxKind.CallExpression).some((call) => {
320
- const expr = call.getExpression().getText();
321
- return expr.startsWith("use") && /^use[A-Z]/.test(expr);
322
- });
323
- if (hasJsxElements) return true;
324
- if (hasJsxReturnType) return true;
325
- if (hasComponentName && hasHooks) return true;
326
- return false;
312
+ try {
313
+ let name = "";
314
+ if (typeof func.getName === "function") {
315
+ name = func.getName() || "";
316
+ }
317
+ if (!name && func.getParent) {
318
+ const parent = func.getParent();
319
+ if (parent && typeof parent.asKind === "function") {
320
+ const varDecl = parent.asKind(SyntaxKind.VariableDeclaration);
321
+ if (varDecl && typeof varDecl.getName === "function") {
322
+ name = varDecl.getName() || "";
323
+ }
324
+ }
325
+ }
326
+ const hasComponentName = name && /^[A-Z]/.test(name);
327
+ const returnType = func.getReturnType()?.getText() || "";
328
+ const hasJsxReturnType = returnType.includes("JSX.Element") || returnType.includes("React.ReactElement") || returnType.includes("ReactElement") || returnType.includes("React.ReactNode") || returnType.includes("ReactNode");
329
+ const body = func.getBody();
330
+ if (!body) return false;
331
+ const hasJsxElements = body.getDescendantsOfKind(SyntaxKind.JsxElement).length > 0 || body.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement).length > 0 || body.getDescendantsOfKind(SyntaxKind.JsxFragment).length > 0;
332
+ const hasHooks = body.getDescendantsOfKind(SyntaxKind.CallExpression).some((call) => {
333
+ const expr = call.getExpression().getText();
334
+ return expr.startsWith("use") && /^use[A-Z]/.test(expr);
335
+ });
336
+ if (hasJsxElements) return true;
337
+ if (hasJsxReturnType) return true;
338
+ if (hasComponentName && hasHooks) return true;
339
+ return false;
340
+ } catch (error) {
341
+ return false;
342
+ }
327
343
  }
328
344
  function analyzeReturnStatements(func) {
329
345
  const body = func.getBody();
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  readLocalMeta,
10
10
  writeLocalAnalysis,
11
11
  writeLocalMeta
12
- } from "./chunk-74JMCHWV.js";
12
+ } from "./chunk-JA66HKP7.js";
13
13
  export {
14
14
  addGitignoreEntry,
15
15
  analyzeProject,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  rayburstPlugin
3
- } from "./chunk-74JMCHWV.js";
3
+ } from "./chunk-JA66HKP7.js";
4
4
  export {
5
5
  rayburstPlugin
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rayburst/cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Rayburst - Automatic code analysis for TypeScript/JavaScript projects via Vite plugin",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",