lightview 2.3.4 → 2.3.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.
package/jprx/parser.js CHANGED
@@ -164,7 +164,6 @@ export const resolvePath = (path, context) => {
164
164
  const unwrappedContext = unwrapSignal(context);
165
165
  if (unwrappedContext && typeof unwrappedContext === 'object') {
166
166
  if (path in unwrappedContext || unwrappedContext[path] !== undefined) {
167
- // Use traverse with one segment to ensure signal unwrapping if context[path] is a signal
168
167
  return traverse(unwrappedContext, [path]);
169
168
  }
170
169
  }
@@ -1512,7 +1511,7 @@ export const parseJPRX = (input) => {
1512
1511
  continue;
1513
1512
  }
1514
1513
 
1515
- // Handle unquoted property names, identifiers, and paths
1514
+ // Handle unquoted property names, identifiers, paths, and FUNCTION CALLS
1516
1515
  if (/[a-zA-Z_$/./]/.test(char)) {
1517
1516
  let word = '';
1518
1517
  while (i < len && /[a-zA-Z0-9_$/.-]/.test(input[i])) {
@@ -1520,13 +1519,46 @@ export const parseJPRX = (input) => {
1520
1519
  i++;
1521
1520
  }
1522
1521
 
1523
- // Skip whitespace to check for :
1522
+ // Skip whitespace to check what follows
1524
1523
  let j = i;
1525
1524
  while (j < len && /\s/.test(input[j])) j++;
1526
1525
 
1527
1526
  if (input[j] === ':') {
1528
1527
  // It's a property name - quote it
1529
1528
  result += `"${word}"`;
1529
+ } else if (input[j] === '(') {
1530
+ // It's a FUNCTION CALL - capture the entire expression with balanced parens
1531
+ let expr = word;
1532
+ i = j; // move to the opening paren
1533
+ let parenDepth = 0;
1534
+ let inQuote = null;
1535
+
1536
+ while (i < len) {
1537
+ const c = input[i];
1538
+
1539
+ // Track quotes to avoid false paren matches inside strings
1540
+ if (inQuote) {
1541
+ if (c === inQuote && input[i - 1] !== '\\') inQuote = null;
1542
+ } else if (c === '"' || c === "'") {
1543
+ inQuote = c;
1544
+ } else {
1545
+ if (c === '(') parenDepth++;
1546
+ else if (c === ')') {
1547
+ parenDepth--;
1548
+ if (parenDepth === 0) {
1549
+ expr += c;
1550
+ i++;
1551
+ break;
1552
+ }
1553
+ }
1554
+ }
1555
+
1556
+ expr += c;
1557
+ i++;
1558
+ }
1559
+
1560
+ // Treat the function call as a JPRX expression by prefixing with =
1561
+ result += JSON.stringify('=' + expr);
1530
1562
  } else {
1531
1563
  // It's a value - check if it's a keyword
1532
1564
  if (word === 'true' || word === 'false' || word === 'null') {