@rayburst/cli 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1217,6 +1217,58 @@ function getReturnDescription(returnAnalysis) {
1217
1217
  }
1218
1218
  return "Returns value";
1219
1219
  }
1220
+ function extractProviderItems(func) {
1221
+ const items = [];
1222
+ try {
1223
+ const variables = func.getVariableDeclarations();
1224
+ for (const variable of variables) {
1225
+ const varName = variable.getName();
1226
+ if (varName === "value" || varName.includes("Value") || varName.includes("Context")) {
1227
+ const initializer = variable.getInitializer();
1228
+ if (initializer && Node.isObjectLiteralExpression(initializer)) {
1229
+ const properties = initializer.getProperties();
1230
+ for (const prop of properties) {
1231
+ if (Node.isPropertyAssignment(prop) || Node.isShorthandPropertyAssignment(prop)) {
1232
+ const propName = prop.getName();
1233
+ const propType = prop.getType().getText();
1234
+ let icon = "Other";
1235
+ if (propType.includes("function") || propType.includes("=>")) {
1236
+ icon = "Function";
1237
+ } else if (propType.includes("boolean")) {
1238
+ icon = "State";
1239
+ } else if (propType.includes("User") || propType.includes("Session")) {
1240
+ icon = "User";
1241
+ } else if (propType.includes("object") || propType.includes("{")) {
1242
+ icon = "State";
1243
+ }
1244
+ items.push({
1245
+ name: propName,
1246
+ type: simplifyType(propType),
1247
+ icon,
1248
+ connections: 0
1249
+ // Will be calculated later based on edges
1250
+ });
1251
+ }
1252
+ }
1253
+ }
1254
+ }
1255
+ }
1256
+ } catch (error) {
1257
+ console.error("Failed to extract provider items:", error);
1258
+ }
1259
+ return items;
1260
+ }
1261
+ function simplifyType(type) {
1262
+ if (type.length > 50) {
1263
+ if (type.includes("function") || type.includes("=>")) return "function";
1264
+ if (type.includes("boolean")) return "boolean";
1265
+ if (type.includes("string")) return "string";
1266
+ if (type.includes("number")) return "number";
1267
+ if (type.includes("null")) return "null";
1268
+ return "object";
1269
+ }
1270
+ return type;
1271
+ }
1220
1272
  function extractComponents(sourceFile, relativePath, gitHash, baseX, startY, nodes, nodeMap, usedIds, idCounters) {
1221
1273
  let count = 0;
1222
1274
  let y = startY;
@@ -1229,11 +1281,18 @@ function extractComponents(sourceFile, relativePath, gitHash, baseX, startY, nod
1229
1281
  const propsParam = params[0];
1230
1282
  const propsType = propsParam ? propsParam.getType().getText() : "any";
1231
1283
  const returnAnalysis = analyzeReturnStatements(func);
1284
+ const isProvider = name.endsWith("Provider");
1285
+ const providerItems = isProvider ? extractProviderItems(func) : [];
1232
1286
  const node = {
1233
1287
  id,
1234
- type: "component",
1288
+ type: isProvider ? "provider" : "component",
1235
1289
  position: { x: baseX, y },
1236
- data: {
1290
+ data: isProvider ? {
1291
+ providerName: name,
1292
+ label: name,
1293
+ description: `Provider in ${relativePath}`,
1294
+ providerItems
1295
+ } : {
1237
1296
  componentName: name,
1238
1297
  props: propsType,
1239
1298
  label: name,
@@ -1263,11 +1322,18 @@ function extractComponents(sourceFile, relativePath, gitHash, baseX, startY, nod
1263
1322
  const propsParam = params[0];
1264
1323
  const propsType = propsParam ? propsParam.getType().getText() : "any";
1265
1324
  const returnAnalysis = analyzeReturnStatements(init);
1325
+ const isProvider = name.endsWith("Provider");
1326
+ const providerItems = isProvider ? extractProviderItems(init) : [];
1266
1327
  const node = {
1267
1328
  id,
1268
- type: "component",
1329
+ type: isProvider ? "provider" : "component",
1269
1330
  position: { x: baseX, y },
1270
- data: {
1331
+ data: isProvider ? {
1332
+ providerName: name,
1333
+ label: name,
1334
+ description: `Provider in ${relativePath}`,
1335
+ providerItems
1336
+ } : {
1271
1337
  componentName: name,
1272
1338
  props: propsType,
1273
1339
  label: name,
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  readLocalMeta,
10
10
  writeLocalAnalysis,
11
11
  writeLocalMeta
12
- } from "./chunk-XQX4VJOQ.js";
12
+ } from "./chunk-HXDPGVSZ.js";
13
13
  export {
14
14
  addGitignoreEntry,
15
15
  analyzeProject,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  rayburstPlugin
3
- } from "./chunk-XQX4VJOQ.js";
3
+ } from "./chunk-HXDPGVSZ.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.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Rayburst - Automatic code analysis for TypeScript/JavaScript projects via Vite plugin",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",