rampkit-expo-dev 0.0.45 → 0.0.46

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.
@@ -439,6 +439,46 @@ function decodeHtmlEntities(str) {
439
439
  .replace(/>/g, '>')
440
440
  .replace(/&/g, '&');
441
441
  }
442
+ /**
443
+ * Strip surrounding quotes from a string value
444
+ * Handles: "value", 'value', \"value\", \'value\', "value", 'value' (unicode curly quotes)
445
+ * Also handles multiple layers and escaped quotes
446
+ */
447
+ function stripQuotes(str) {
448
+ let value = str.trim();
449
+ // Handle backslash-escaped quotes at start/end: \"value\" -> value
450
+ if (value.startsWith('\\"') && value.endsWith('\\"') && value.length >= 4) {
451
+ value = value.slice(2, -2);
452
+ }
453
+ else if (value.startsWith("\\'") && value.endsWith("\\'") && value.length >= 4) {
454
+ value = value.slice(2, -2);
455
+ }
456
+ // Handle regular double quotes: "value" -> value
457
+ else if (value.startsWith('"') && value.endsWith('"') && value.length >= 2) {
458
+ value = value.slice(1, -1);
459
+ }
460
+ // Handle regular single quotes: 'value' -> value
461
+ else if (value.startsWith("'") && value.endsWith("'") && value.length >= 2) {
462
+ value = value.slice(1, -1);
463
+ }
464
+ // Handle unicode left/right double quotes: "value" -> value
465
+ else if (value.startsWith('\u201C') && value.endsWith('\u201D') && value.length >= 2) {
466
+ value = value.slice(1, -1);
467
+ }
468
+ // Handle unicode left/right single quotes: 'value' -> value
469
+ else if (value.startsWith('\u2018') && value.endsWith('\u2019') && value.length >= 2) {
470
+ value = value.slice(1, -1);
471
+ }
472
+ // Check if there's still another layer of quotes (handles double-quoted values)
473
+ const trimmed = value.trim();
474
+ if ((trimmed.startsWith('"') && trimmed.endsWith('"') && trimmed.length >= 2) ||
475
+ (trimmed.startsWith("'") && trimmed.endsWith("'") && trimmed.length >= 2) ||
476
+ (trimmed.startsWith('\\"') && trimmed.endsWith('\\"') && trimmed.length >= 4) ||
477
+ (trimmed.startsWith("\\'") && trimmed.endsWith("\\'") && trimmed.length >= 4)) {
478
+ return stripQuotes(trimmed);
479
+ }
480
+ return value;
481
+ }
442
482
  /**
443
483
  * Evaluate a comparison condition against variables
444
484
  * Supports: ==, !=, >, <, >=, <=, and truthy checks
@@ -451,13 +491,15 @@ function evaluateCondition(condition, vars) {
451
491
  const [, varName, operator, rawRight] = comparisonMatch;
452
492
  const leftValue = vars.hasOwnProperty(varName) ? vars[varName] : undefined;
453
493
  let rightValue = decodeHtmlEntities(rawRight.trim());
454
- // Parse right side - could be a quoted string or a number or a variable
455
- if ((rightValue.startsWith('"') && rightValue.endsWith('"')) ||
456
- (rightValue.startsWith("'") && rightValue.endsWith("'"))) {
494
+ // Check if right side looks like a quoted string
495
+ const looksLikeQuotedString = (rightValue.startsWith('"') || rightValue.startsWith("'") ||
496
+ rightValue.startsWith('\\"') || rightValue.startsWith("\\'") ||
497
+ rightValue.startsWith('\u201C') || rightValue.startsWith('\u2018'));
498
+ if (looksLikeQuotedString) {
457
499
  // Quoted string literal - strip the quotes
458
- rightValue = rightValue.slice(1, -1);
500
+ rightValue = stripQuotes(rightValue);
459
501
  }
460
- else if (!isNaN(Number(rightValue))) {
502
+ else if (!isNaN(Number(rightValue)) && rightValue !== '') {
461
503
  // Numeric literal
462
504
  rightValue = Number(rightValue);
463
505
  }
@@ -509,18 +551,18 @@ function evaluateCondition(condition, vars) {
509
551
  * Returns the resolved value, handling both quoted strings and variable references
510
552
  */
511
553
  function parseTernaryValue(value, vars) {
512
- value = decodeHtmlEntities(value.trim());
513
- // Check if it's a quoted string (double quotes)
514
- if (value.startsWith('"') && value.endsWith('"') && value.length >= 2) {
515
- return value.slice(1, -1);
516
- }
517
- // Check if it's a quoted string (single quotes)
518
- if (value.startsWith("'") && value.endsWith("'") && value.length >= 2) {
519
- return value.slice(1, -1);
554
+ let decoded = decodeHtmlEntities(value.trim());
555
+ // Check if this looks like a quoted string
556
+ const looksLikeQuotedString = (decoded.startsWith('"') || decoded.startsWith("'") ||
557
+ decoded.startsWith('\\"') || decoded.startsWith("\\'") ||
558
+ decoded.startsWith('\u201C') || decoded.startsWith('\u2018'));
559
+ if (looksLikeQuotedString) {
560
+ // Strip quotes and return the inner value
561
+ return stripQuotes(decoded);
520
562
  }
521
563
  // Otherwise treat as a variable reference
522
- if (vars.hasOwnProperty(value)) {
523
- const varValue = vars[value];
564
+ if (vars.hasOwnProperty(decoded)) {
565
+ const varValue = vars[decoded];
524
566
  if (varValue === undefined || varValue === null)
525
567
  return "";
526
568
  if (typeof varValue === "boolean")
@@ -530,7 +572,7 @@ function parseTernaryValue(value, vars) {
530
572
  return String(varValue);
531
573
  }
532
574
  // Return as-is if not found (could be a literal like a number)
533
- return value;
575
+ return decoded;
534
576
  }
535
577
  /**
536
578
  * Parse a ternary expression and find the colon that separates true/false values
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rampkit-expo-dev",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "description": "The Expo SDK for RampKit. Build, test, and personalize app onboardings with instant updates.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",