@developer_tribe/react-builder 1.2.45 → 1.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@developer_tribe/react-builder",
3
- "version": "1.2.45",
3
+ "version": "1.2.46",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "restricted": true,
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "supportedProjectVersion": "1.1.2",
3
- "reactBuilderVersion": "1.2.44"
3
+ "reactBuilderVersion": "1.2.45"
4
4
  }
@@ -12,7 +12,36 @@ export function extractPrice(formattedPrice: string): string {
12
12
  if (!formattedPrice) {
13
13
  return '';
14
14
  }
15
- return formattedPrice.replace(/[^0-9.]/g, '');
15
+ // Remove currency symbols and other non-numeric chars except dot/comma
16
+ const cleaned = formattedPrice.replace(/[^0-9.,]/g, '');
17
+
18
+ // If there's both a dot and a comma, comma is likely decimal (e.g. 1.999,99)
19
+ // If there's multiple dots, dots are likely thousands and comma is decimal (e.g. 1.999,99)
20
+ // If there's only a comma, it's decimal (e.g. 149,99)
21
+
22
+ let numeric: string;
23
+ if (cleaned.includes(',') && cleaned.includes('.')) {
24
+ // Mixed: 1.234,56 -> 1234.56
25
+ numeric = cleaned.replace(/\./g, '').replace(',', '.');
26
+ } else if (cleaned.includes(',')) {
27
+ // Only comma: 149,99 -> 149.99
28
+ numeric = cleaned.replace(',', '.');
29
+ } else {
30
+ // Only dots or none: 1,999.99 (impossible with logic above but for safety) or 9.99
31
+ // If multiple dots, they are thousand separators
32
+ const dots = (cleaned.match(/\./g) || []).length;
33
+ if (dots > 1) {
34
+ numeric = cleaned.replace(/\./g, '');
35
+ } else {
36
+ numeric = cleaned;
37
+ }
38
+ }
39
+
40
+ const parsed = parseFloat(numeric);
41
+ if (isNaN(parsed)) return '';
42
+
43
+ // Round to 2 decimal places to avoid precision issues like 1999.9900000000002
44
+ return String(Math.round(parsed * 100) / 100);
16
45
  }
17
46
 
18
47
  /**
@@ -195,9 +195,8 @@ export function extractAndroidParams(
195
195
 
196
196
  /** Boş params ama mock product price'ları ile birleştirilmiş (fallback) */
197
197
  function getFallbackParams(product: Product): AndroidParams {
198
- const price = String(product.price || product.localizedPrice || '').replace(
199
- /[^0-9.]/g,
200
- '',
198
+ const price = extractPrice(
199
+ String(product.price || product.localizedPrice || ''),
201
200
  );
202
201
  return {
203
202
  ...getEmptyParams(),
@@ -4,6 +4,7 @@ import {
4
4
  } from './periodLocalizationKeys';
5
5
  import { iapLogger } from '../logger';
6
6
  import {
7
+ extractPrice,
7
8
  calculateDiscount,
8
9
  calculatePricePerMonth,
9
10
  calculatePricePerYear,
@@ -56,9 +57,8 @@ export function extractIOSParams(
56
57
  offerId?: string,
57
58
  ): IOSParams {
58
59
  try {
59
- const price = String(product.price || product.localizedPrice || '').replace(
60
- /[^0-9.]/g,
61
- '',
60
+ const price = extractPrice(
61
+ String(product.price || product.localizedPrice || ''),
62
62
  );
63
63
  const currency = product.currency || product.currencyCode || '';
64
64
  const localizedPrice = product.localizedPrice || '';
@@ -120,7 +120,7 @@ export function extractIOSParams(
120
120
  );
121
121
 
122
122
  if (discount) {
123
- promoPrice = String(discount.price || '').replace(/[^0-9.]/g, '');
123
+ promoPrice = extractPrice(String(discount.price || ''));
124
124
  const cycles = discount.numberOfPeriods || 1;
125
125
  const unit = convertIOSPeriodUnit(
126
126
  discount.subscriptionPeriod || 'MONTH',
@@ -485,5 +485,107 @@
485
485
  "subscriptionPeriodUnitIOS": "YEAR",
486
486
  "subscriptionPeriodNumberIOS": 1
487
487
  }
488
+ ],
489
+ "vpn-pro": [
490
+ {
491
+ "productId": "com.vpn111.pro.weekly",
492
+ "title": "Pro Subscription (Weekly)",
493
+ "description": "Pro Subscription (Weekly)",
494
+ "localizedPrice": "₺179,99",
495
+ "price": "179.99",
496
+ "currency": "TRY",
497
+ "type": "subs",
498
+ "subscriptionOffers": [],
499
+ "discounts": [],
500
+ "subscriptionPeriodNumberIOS": 7,
501
+ "subscriptionPeriodUnitIOS": "DAY",
502
+ "isConsumable": false
503
+ },
504
+ {
505
+ "productId": "com.vpn111.pro.monthly",
506
+ "title": "Pro Subscription (Monthly)",
507
+ "description": "Pro Subscription (Monthly)",
508
+ "localizedPrice": "₺399,99",
509
+ "price": "399.99",
510
+ "currency": "TRY",
511
+ "type": "subs",
512
+ "subscriptionOffers": [],
513
+ "discounts": [],
514
+ "subscriptionPeriodNumberIOS": 1,
515
+ "subscriptionPeriodUnitIOS": "MONTH",
516
+ "isConsumable": false
517
+ },
518
+ {
519
+ "productId": "com.vpn111.pro.annual",
520
+ "title": "Pro Subscription (Annual)",
521
+ "description": "Pro Subscription (Annual)",
522
+ "localizedPrice": "₺1.999,99",
523
+ "price": "1999.99",
524
+ "currency": "TRY",
525
+ "type": "subs",
526
+ "subscriptionOffers": [
527
+ {
528
+ "numberOfPeriodsIOS": 1,
529
+ "paymentMode": "pay-up-front",
530
+ "type": "promotional",
531
+ "period": { "value": 1, "unit": "year" },
532
+ "id": "one.year.discount.annual.offer",
533
+ "price": 999.99,
534
+ "periodCount": 1,
535
+ "displayPrice": "₺999,99",
536
+ "localizedPriceIOS": "₺999,99",
537
+ "offerId": "one.year.discount.annual.offer",
538
+ "localizedPrice": "₺999,99"
539
+ },
540
+ {
541
+ "numberOfPeriodsIOS": 1,
542
+ "localizedPriceIOS": "₺149,99",
543
+ "displayPrice": "₺149,99",
544
+ "period": { "value": 1, "unit": "month" },
545
+ "periodCount": 1,
546
+ "id": "one.month.discount.annual.offer",
547
+ "type": "promotional",
548
+ "paymentMode": "pay-up-front",
549
+ "price": 149.99,
550
+ "offerId": "one.month.discount.annual.offer",
551
+ "localizedPrice": "₺149,99"
552
+ }
553
+ ],
554
+ "discounts": [
555
+ {
556
+ "paymentMode": "pay-up-front",
557
+ "priceAmount": 999.99,
558
+ "localizedPrice": "₺999,99",
559
+ "type": "promotional",
560
+ "subscriptionPeriod": "YEAR",
561
+ "numberOfPeriods": 1,
562
+ "price": "999.99",
563
+ "identifier": "one.year.discount.annual.offer"
564
+ },
565
+ {
566
+ "numberOfPeriods": 1,
567
+ "priceAmount": 149.99,
568
+ "localizedPrice": "₺149,99",
569
+ "identifier": "one.month.discount.annual.offer",
570
+ "subscriptionPeriod": "MONTH",
571
+ "type": "promotional",
572
+ "paymentMode": "pay-up-front",
573
+ "price": "149.99"
574
+ },
575
+ {
576
+ "numberOfPeriods": 1,
577
+ "type": "promotional",
578
+ "subscriptionPeriod": "YEAR",
579
+ "priceAmount": 999.99,
580
+ "paymentMode": "pay-up-front",
581
+ "price": "999.99",
582
+ "localizedPrice": "₺999,99",
583
+ "identifier": "one.year.50discount.annual.offer"
584
+ }
585
+ ],
586
+ "subscriptionPeriodNumberIOS": 1,
587
+ "subscriptionPeriodUnitIOS": "YEAR",
588
+ "isConsumable": false
589
+ }
488
590
  ]
489
591
  }