@adapty/core 4.0.0-dev.be3bfb2d97c35a578f09706e179187ebdb312943 → 4.0.0

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/dist/index.mjs CHANGED
@@ -826,6 +826,283 @@ var AdaptyDiscountPhaseCoder = class extends SimpleCoder {
826
826
  }
827
827
  };
828
828
 
829
+ //#endregion
830
+ //#region src/coders/product-reference.ts
831
+ var ProductReferenceCoder = class extends SimpleCoder {
832
+ constructor(..._args) {
833
+ super(..._args);
834
+ this.properties = {
835
+ flowProductId: {
836
+ key: "flow_product_id",
837
+ required: false,
838
+ type: "string"
839
+ },
840
+ vendorId: {
841
+ key: "vendor_product_id",
842
+ required: true,
843
+ type: "string"
844
+ },
845
+ adaptyId: {
846
+ key: "adapty_product_id",
847
+ required: true,
848
+ type: "string"
849
+ },
850
+ accessLevelId: {
851
+ key: "access_level_id",
852
+ required: true,
853
+ type: "string"
854
+ },
855
+ productType: {
856
+ key: "product_type",
857
+ required: true,
858
+ type: "string"
859
+ },
860
+ ios: {
861
+ promotionalOfferId: {
862
+ key: "promotional_offer_id",
863
+ required: false,
864
+ type: "string"
865
+ },
866
+ winBackOfferId: {
867
+ key: "win_back_offer_id",
868
+ required: false,
869
+ type: "string"
870
+ }
871
+ },
872
+ android: {
873
+ basePlanId: {
874
+ key: "base_plan_id",
875
+ required: false,
876
+ type: "string"
877
+ },
878
+ offerId: {
879
+ key: "offer_id",
880
+ required: false,
881
+ type: "string"
882
+ }
883
+ }
884
+ };
885
+ }
886
+ };
887
+
888
+ //#endregion
889
+ //#region src/coders/array.ts
890
+ var ArrayCoder = class {
891
+ constructor(coderFactory) {
892
+ this.coderFactory = coderFactory;
893
+ }
894
+ decode(input) {
895
+ const coder = this.coderFactory();
896
+ return input.map((item) => coder.decode(item));
897
+ }
898
+ encode(value) {
899
+ const coder = this.coderFactory();
900
+ return value.map((item) => coder.encode(item));
901
+ }
902
+ };
903
+
904
+ //#endregion
905
+ //#region src/coders/adapty-placement.ts
906
+ var AdaptyPlacementCoder = class extends SimpleCoder {
907
+ constructor(..._args) {
908
+ super(..._args);
909
+ this.properties = {
910
+ abTestName: {
911
+ key: "ab_test_name",
912
+ required: true,
913
+ type: "string"
914
+ },
915
+ audienceName: {
916
+ key: "audience_name",
917
+ required: true,
918
+ type: "string"
919
+ },
920
+ id: {
921
+ key: "developer_id",
922
+ required: true,
923
+ type: "string"
924
+ },
925
+ revision: {
926
+ key: "revision",
927
+ required: true,
928
+ type: "number"
929
+ },
930
+ audienceVersionId: {
931
+ key: "placement_audience_version_id",
932
+ required: true,
933
+ type: "string"
934
+ },
935
+ isTrackingPurchases: {
936
+ key: "is_tracking_purchases",
937
+ required: false,
938
+ type: "boolean"
939
+ }
940
+ };
941
+ }
942
+ };
943
+
944
+ //#endregion
945
+ //#region src/coders/adapty-flow-paywall.ts
946
+ const PROPERTIES = {
947
+ placement: {
948
+ key: "placement",
949
+ required: true,
950
+ type: "object",
951
+ converter: new AdaptyPlacementCoder()
952
+ },
953
+ id: {
954
+ key: "paywall_id",
955
+ required: true,
956
+ type: "string"
957
+ },
958
+ name: {
959
+ key: "paywall_name",
960
+ required: true,
961
+ type: "string"
962
+ },
963
+ products: {
964
+ key: "products",
965
+ required: true,
966
+ type: "array",
967
+ converter: new ArrayCoder(() => new ProductReferenceCoder())
968
+ },
969
+ variationId: {
970
+ key: "variation_id",
971
+ required: true,
972
+ type: "string"
973
+ },
974
+ webPurchaseUrl: {
975
+ key: "web_purchase_url",
976
+ required: false,
977
+ type: "string"
978
+ }
979
+ };
980
+ var AdaptyFlowPaywallCoder = class extends Coder {
981
+ constructor(..._args) {
982
+ super(..._args);
983
+ this.properties = PROPERTIES;
984
+ }
985
+ decode(data) {
986
+ const codablePart = super.decode(data);
987
+ return {
988
+ ...codablePart,
989
+ productIdentifiers: codablePart.products.map((product) => ({
990
+ vendorProductId: product.vendorId,
991
+ adaptyProductId: product.adaptyId,
992
+ basePlanId: product.android?.basePlanId
993
+ }))
994
+ };
995
+ }
996
+ encode(data) {
997
+ const { productIdentifiers,...codablePart } = data;
998
+ return super.encode(codablePart);
999
+ }
1000
+ };
1001
+
1002
+ //#endregion
1003
+ //#region src/coders/json.ts
1004
+ var JSONCoder = class {
1005
+ decode(input) {
1006
+ if (!input) return {};
1007
+ return JSON.parse(input);
1008
+ }
1009
+ encode(value) {
1010
+ if (Object.keys(value).length === 0) return "";
1011
+ return JSON.stringify(value);
1012
+ }
1013
+ };
1014
+
1015
+ //#endregion
1016
+ //#region src/coders/adapty-remote-config.ts
1017
+ var AdaptyRemoteConfigCoder = class extends Coder {
1018
+ constructor(..._args) {
1019
+ super(..._args);
1020
+ this.properties = {
1021
+ data: {
1022
+ key: "data",
1023
+ required: true,
1024
+ type: "string",
1025
+ converter: new JSONCoder()
1026
+ },
1027
+ lang: {
1028
+ key: "lang",
1029
+ required: true,
1030
+ type: "string"
1031
+ }
1032
+ };
1033
+ }
1034
+ decode(data) {
1035
+ const codablePart = super.decode(data);
1036
+ const dataString = JSON.stringify(codablePart.data);
1037
+ return {
1038
+ ...codablePart,
1039
+ dataString: dataString.length < 4 ? "" : dataString
1040
+ };
1041
+ }
1042
+ encode(data) {
1043
+ const { dataString,...codablePart } = data;
1044
+ return super.encode(codablePart);
1045
+ }
1046
+ };
1047
+
1048
+ //#endregion
1049
+ //#region src/coders/adapty-flow.ts
1050
+ var AdaptyFlowCoder = class extends SimpleCoder {
1051
+ constructor(..._args) {
1052
+ super(..._args);
1053
+ this.properties = {
1054
+ placement: {
1055
+ key: "placement",
1056
+ required: true,
1057
+ type: "object",
1058
+ converter: new AdaptyPlacementCoder()
1059
+ },
1060
+ id: {
1061
+ key: "flow_id",
1062
+ required: true,
1063
+ type: "string"
1064
+ },
1065
+ name: {
1066
+ key: "flow_name",
1067
+ required: true,
1068
+ type: "string"
1069
+ },
1070
+ variationId: {
1071
+ key: "variation_id",
1072
+ required: true,
1073
+ type: "string"
1074
+ },
1075
+ remoteConfigs: {
1076
+ key: "remote_configs",
1077
+ required: false,
1078
+ type: "array",
1079
+ converter: new ArrayCoder(() => new AdaptyRemoteConfigCoder())
1080
+ },
1081
+ flowVersionId: {
1082
+ key: "flow_version_id",
1083
+ required: false,
1084
+ type: "string"
1085
+ },
1086
+ paywalls: {
1087
+ key: "variations",
1088
+ required: true,
1089
+ type: "array",
1090
+ converter: new ArrayCoder(() => new AdaptyFlowPaywallCoder())
1091
+ },
1092
+ responseCreatedAt: {
1093
+ key: "response_created_at",
1094
+ required: true,
1095
+ type: "number"
1096
+ },
1097
+ payloadData: {
1098
+ key: "payload_data",
1099
+ required: false,
1100
+ type: "string"
1101
+ }
1102
+ };
1103
+ }
1104
+ };
1105
+
829
1106
  //#endregion
830
1107
  //#region src/coders/adapty-identify-params.ts
831
1108
  var AdaptyIdentifyParamsCoder = class {
@@ -995,92 +1272,6 @@ var AdaptyOnboardingBuilderCoder = class extends SimpleCoder {
995
1272
  }
996
1273
  };
997
1274
 
998
- //#endregion
999
- //#region src/coders/json.ts
1000
- var JSONCoder = class {
1001
- decode(input) {
1002
- if (!input) return {};
1003
- return JSON.parse(input);
1004
- }
1005
- encode(value) {
1006
- if (Object.keys(value).length === 0) return "";
1007
- return JSON.stringify(value);
1008
- }
1009
- };
1010
-
1011
- //#endregion
1012
- //#region src/coders/adapty-remote-config.ts
1013
- var AdaptyRemoteConfigCoder = class extends Coder {
1014
- constructor(..._args) {
1015
- super(..._args);
1016
- this.properties = {
1017
- data: {
1018
- key: "data",
1019
- required: true,
1020
- type: "string",
1021
- converter: new JSONCoder()
1022
- },
1023
- lang: {
1024
- key: "lang",
1025
- required: true,
1026
- type: "string"
1027
- }
1028
- };
1029
- }
1030
- decode(data) {
1031
- const codablePart = super.decode(data);
1032
- const dataString = JSON.stringify(codablePart.data);
1033
- return {
1034
- ...codablePart,
1035
- dataString: dataString.length < 4 ? "" : dataString
1036
- };
1037
- }
1038
- encode(data) {
1039
- const { dataString,...codablePart } = data;
1040
- return super.encode(codablePart);
1041
- }
1042
- };
1043
-
1044
- //#endregion
1045
- //#region src/coders/adapty-placement.ts
1046
- var AdaptyPlacementCoder = class extends SimpleCoder {
1047
- constructor(..._args) {
1048
- super(..._args);
1049
- this.properties = {
1050
- abTestName: {
1051
- key: "ab_test_name",
1052
- required: true,
1053
- type: "string"
1054
- },
1055
- audienceName: {
1056
- key: "audience_name",
1057
- required: true,
1058
- type: "string"
1059
- },
1060
- id: {
1061
- key: "developer_id",
1062
- required: true,
1063
- type: "string"
1064
- },
1065
- revision: {
1066
- key: "revision",
1067
- required: true,
1068
- type: "number"
1069
- },
1070
- audienceVersionId: {
1071
- key: "placement_audience_version_id",
1072
- required: true,
1073
- type: "string"
1074
- },
1075
- isTrackingPurchases: {
1076
- key: "is_tracking_purchases",
1077
- required: false,
1078
- type: "boolean"
1079
- }
1080
- };
1081
- }
1082
- };
1083
-
1084
1275
  //#endregion
1085
1276
  //#region src/coders/adapty-onboarding.ts
1086
1277
  var AdaptyOnboardingCoder = class extends Coder {
@@ -1150,26 +1341,6 @@ var AdaptyOnboardingCoder = class extends Coder {
1150
1341
  }
1151
1342
  };
1152
1343
 
1153
- //#endregion
1154
- //#region src/coders/adapty-paywall-builder.ts
1155
- var AdaptyPaywallBuilderCoder = class extends SimpleCoder {
1156
- constructor(..._args) {
1157
- super(..._args);
1158
- this.properties = {
1159
- id: {
1160
- key: "paywall_builder_id",
1161
- required: true,
1162
- type: "string"
1163
- },
1164
- lang: {
1165
- key: "lang",
1166
- required: true,
1167
- type: "string"
1168
- }
1169
- };
1170
- }
1171
- };
1172
-
1173
1344
  //#endregion
1174
1345
  //#region src/coders/adapty-subscription-offer-identifier.ts
1175
1346
  var AdaptySubscriptionOfferIdCoder = class extends SimpleCoder {
@@ -1190,22 +1361,6 @@ var AdaptySubscriptionOfferIdCoder = class extends SimpleCoder {
1190
1361
  }
1191
1362
  };
1192
1363
 
1193
- //#endregion
1194
- //#region src/coders/array.ts
1195
- var ArrayCoder = class {
1196
- constructor(coderFactory) {
1197
- this.coderFactory = coderFactory;
1198
- }
1199
- decode(input) {
1200
- const coder = this.coderFactory();
1201
- return input.map((item) => coder.decode(item));
1202
- }
1203
- encode(value) {
1204
- const coder = this.coderFactory();
1205
- return value.map((item) => coder.encode(item));
1206
- }
1207
- };
1208
-
1209
1364
  //#endregion
1210
1365
  //#region src/coders/adapty-subscription-offer.ts
1211
1366
  var AdaptySubscriptionOfferCoder = class extends SimpleCoder {
@@ -1397,145 +1552,6 @@ var AdaptyPaywallProductCoder = class extends SimpleCoder {
1397
1552
  }
1398
1553
  };
1399
1554
 
1400
- //#endregion
1401
- //#region src/coders/product-reference.ts
1402
- var ProductReferenceCoder = class extends SimpleCoder {
1403
- constructor(..._args) {
1404
- super(..._args);
1405
- this.properties = {
1406
- vendorId: {
1407
- key: "vendor_product_id",
1408
- required: true,
1409
- type: "string"
1410
- },
1411
- adaptyId: {
1412
- key: "adapty_product_id",
1413
- required: true,
1414
- type: "string"
1415
- },
1416
- accessLevelId: {
1417
- key: "access_level_id",
1418
- required: true,
1419
- type: "string"
1420
- },
1421
- productType: {
1422
- key: "product_type",
1423
- required: true,
1424
- type: "string"
1425
- },
1426
- ios: {
1427
- promotionalOfferId: {
1428
- key: "promotional_offer_id",
1429
- required: false,
1430
- type: "string"
1431
- },
1432
- winBackOfferId: {
1433
- key: "win_back_offer_id",
1434
- required: false,
1435
- type: "string"
1436
- }
1437
- },
1438
- android: {
1439
- basePlanId: {
1440
- key: "base_plan_id",
1441
- required: false,
1442
- type: "string"
1443
- },
1444
- offerId: {
1445
- key: "offer_id",
1446
- required: false,
1447
- type: "string"
1448
- }
1449
- }
1450
- };
1451
- }
1452
- };
1453
-
1454
- //#endregion
1455
- //#region src/coders/adapty-paywall.ts
1456
- var AdaptyPaywallCoder = class extends Coder {
1457
- constructor(..._args) {
1458
- super(..._args);
1459
- this.properties = {
1460
- placement: {
1461
- key: "placement",
1462
- required: true,
1463
- type: "object",
1464
- converter: new AdaptyPlacementCoder()
1465
- },
1466
- id: {
1467
- key: "paywall_id",
1468
- required: true,
1469
- type: "string"
1470
- },
1471
- name: {
1472
- key: "paywall_name",
1473
- required: true,
1474
- type: "string"
1475
- },
1476
- products: {
1477
- key: "products",
1478
- required: true,
1479
- type: "array",
1480
- converter: new ArrayCoder(() => new ProductReferenceCoder())
1481
- },
1482
- remoteConfig: {
1483
- key: "remote_config",
1484
- required: false,
1485
- type: "object",
1486
- converter: new AdaptyRemoteConfigCoder()
1487
- },
1488
- variationId: {
1489
- key: "variation_id",
1490
- required: true,
1491
- type: "string"
1492
- },
1493
- version: {
1494
- key: "response_created_at",
1495
- required: false,
1496
- type: "number"
1497
- },
1498
- paywallBuilder: {
1499
- key: "paywall_builder",
1500
- required: false,
1501
- type: "object",
1502
- converter: new AdaptyPaywallBuilderCoder()
1503
- },
1504
- webPurchaseUrl: {
1505
- key: "web_purchase_url",
1506
- required: false,
1507
- type: "string"
1508
- },
1509
- payloadData: {
1510
- key: "payload_data",
1511
- required: false,
1512
- type: "string"
1513
- },
1514
- requestLocale: {
1515
- key: "request_locale",
1516
- required: true,
1517
- type: "string"
1518
- }
1519
- };
1520
- }
1521
- decode(data) {
1522
- const codablePart = super.decode(data);
1523
- return {
1524
- ...codablePart,
1525
- hasViewConfiguration: codablePart.paywallBuilder !== void 0,
1526
- productIdentifiers: codablePart.products.map((product) => ({
1527
- vendorProductId: product.vendorId,
1528
- adaptyProductId: product.adaptyId,
1529
- basePlanId: product.android?.basePlanId
1530
- }))
1531
- };
1532
- }
1533
- encode(data) {
1534
- const { hasViewConfiguration, productIdentifiers,...codablePart } = data;
1535
- return super.encode(codablePart);
1536
- }
1537
- };
1538
-
1539
1555
  //#endregion
1540
1556
  //#region src/coders/adapty-profile-parameters.ts
1541
1557
  var AdaptyProfileParametersCoder = class extends SimpleCoder {
@@ -1744,6 +1760,11 @@ var AdaptyProfileCoder = class extends SimpleCoder {
1744
1760
  type: "object",
1745
1761
  converter: new HashmapCoder(new AdaptyAccessLevelCoder())
1746
1762
  },
1763
+ appliedAttributionSources: {
1764
+ key: "applied_attribution_sources",
1765
+ required: false,
1766
+ type: "array"
1767
+ },
1747
1768
  customAttributes: {
1748
1769
  key: "custom_attributes",
1749
1770
  required: false,
@@ -1777,9 +1798,6 @@ var AdaptyProfileCoder = class extends SimpleCoder {
1777
1798
 
1778
1799
  //#endregion
1779
1800
  //#region src/coders/adapty-purchase-params.ts
1780
- function isDeprecatedType(data) {
1781
- return typeof data === "object" && data !== null && "android" in data && typeof data.android === "object" && data.android !== null && "oldSubVendorProductId" in data.android && "prorationMode" in data.android;
1782
- }
1783
1801
  var AdaptyPurchaseParamsCoder = class {
1784
1802
  constructor(platform) {
1785
1803
  this.platform = platform;
@@ -1787,16 +1805,6 @@ var AdaptyPurchaseParamsCoder = class {
1787
1805
  encode(data) {
1788
1806
  if (this.platform.OS !== "android") return {};
1789
1807
  const purchaseParams = {};
1790
- if (isDeprecatedType(data)) {
1791
- if (data.android) {
1792
- purchaseParams["subscription_update_params"] = {
1793
- replacement_mode: data.android.prorationMode,
1794
- old_sub_vendor_product_id: data.android.oldSubVendorProductId
1795
- };
1796
- if (data.android.isOfferPersonalized) purchaseParams["is_offer_personalized"] = data.android.isOfferPersonalized;
1797
- }
1798
- return purchaseParams;
1799
- }
1800
1808
  if (data.android) {
1801
1809
  if (data.android.subscriptionUpdateParams) purchaseParams["subscription_update_params"] = {
1802
1810
  replacement_mode: data.android.subscriptionUpdateParams.prorationMode,
@@ -1929,14 +1937,15 @@ const resolveAssetId = (asset, platformOS) => {
1929
1937
  };
1930
1938
 
1931
1939
  //#endregion
1932
- //#region src/coders/adapty-ui-create-paywall-view-params.ts
1933
- var AdaptyUICreatePaywallViewParamsCoder = class {
1940
+ //#region src/coders/adapty-ui-create-flow-view-params.ts
1941
+ var AdaptyUICreateFlowViewParamsCoder = class {
1934
1942
  constructor(platform) {
1935
1943
  this.platform = platform;
1936
1944
  }
1937
1945
  encode(data) {
1938
1946
  const result = {};
1939
1947
  if (data.prefetchProducts !== void 0) result.preload_products = data.prefetchProducts;
1948
+ if (data.android?.enableSafeArea !== void 0) result.enable_safe_area_paddings = data.android.enableSafeArea;
1940
1949
  if (data.loadTimeoutMs !== void 0) result.load_timeout = data.loadTimeoutMs / 1e3;
1941
1950
  if (data.customTags) result.custom_tags = data.customTags;
1942
1951
  if (data.customTimers) result.custom_timers = this.encodeCustomTimers(data.customTimers);
@@ -2271,11 +2280,11 @@ var CoderFactory = class {
2271
2280
  createOnboardingCoder() {
2272
2281
  return new AdaptyOnboardingCoder(this.deps.platform);
2273
2282
  }
2274
- createPaywallBuilderCoder() {
2275
- return new AdaptyPaywallBuilderCoder(this.deps.platform);
2283
+ createFlowCoder() {
2284
+ return new AdaptyFlowCoder(this.deps.platform);
2276
2285
  }
2277
- createPaywallCoder() {
2278
- return new AdaptyPaywallCoder(this.deps.platform);
2286
+ createFlowPaywallCoder() {
2287
+ return new AdaptyFlowPaywallCoder(this.deps.platform);
2279
2288
  }
2280
2289
  createPaywallProductCoder() {
2281
2290
  return new AdaptyPaywallProductCoder(this.deps.platform);
@@ -2316,8 +2325,8 @@ var CoderFactory = class {
2316
2325
  createUiCreateOnboardingViewParamsCoder() {
2317
2326
  return new AdaptyUICreateOnboardingViewParamsCoder();
2318
2327
  }
2319
- createUiCreatePaywallViewParamsCoder() {
2320
- return new AdaptyUICreatePaywallViewParamsCoder(this.deps.platform);
2328
+ createUiCreateFlowViewParamsCoder() {
2329
+ return new AdaptyUICreateFlowViewParamsCoder(this.deps.platform);
2321
2330
  }
2322
2331
  createUiDialogConfigCoder() {
2323
2332
  return new AdaptyUiDialogConfigCoder(this.deps.platform);
@@ -2407,9 +2416,9 @@ const RefundPreference = Object.freeze({
2407
2416
  const MethodNames = [
2408
2417
  "activate",
2409
2418
  "adapty_ui_activate",
2410
- "adapty_ui_create_paywall_view",
2411
- "adapty_ui_dismiss_paywall_view",
2412
- "adapty_ui_present_paywall_view",
2419
+ "adapty_ui_create_flow_view",
2420
+ "adapty_ui_dismiss_flow_view",
2421
+ "adapty_ui_present_flow_view",
2413
2422
  "adapty_ui_show_dialog",
2414
2423
  "adapty_ui_create_onboarding_view",
2415
2424
  "adapty_ui_dismiss_onboarding_view",
@@ -2417,14 +2426,14 @@ const MethodNames = [
2417
2426
  "create_web_paywall_url",
2418
2427
  "get_current_installation_status",
2419
2428
  "is_activated",
2420
- "get_paywall",
2421
- "get_paywall_for_default_audience",
2429
+ "get_flow",
2430
+ "get_flow_for_default_audience",
2422
2431
  "get_paywall_products",
2423
2432
  "get_onboarding",
2424
2433
  "get_onboarding_for_default_audience",
2425
2434
  "get_profile",
2426
2435
  "identify",
2427
- "log_show_paywall",
2436
+ "log_show_flow",
2428
2437
  "logout",
2429
2438
  "make_purchase",
2430
2439
  "open_web_paywall",
@@ -2437,25 +2446,37 @@ const MethodNames = [
2437
2446
  "update_attribution_data",
2438
2447
  "update_collecting_refund_data_consent",
2439
2448
  "update_profile",
2440
- "update_refund_preference"
2449
+ "update_refund_preference",
2450
+ "flow_view_did_answer_permission",
2451
+ "adapty_ui_open_url",
2452
+ "adapty_ui_request_app_review",
2453
+ "observer_purchase_did_start",
2454
+ "observer_purchase_did_finish",
2455
+ "observer_restore_did_start",
2456
+ "observer_restore_did_finish"
2441
2457
  ];
2442
2458
 
2443
2459
  //#endregion
2444
- //#region src/types/paywall-events.ts
2445
- const PaywallEventId = {
2446
- DidAppear: "paywall_view_did_appear",
2447
- DidDisappear: "paywall_view_did_disappear",
2448
- DidPerformAction: "paywall_view_did_perform_action",
2449
- DidSelectProduct: "paywall_view_did_select_product",
2450
- DidStartPurchase: "paywall_view_did_start_purchase",
2451
- DidFinishPurchase: "paywall_view_did_finish_purchase",
2452
- DidFailPurchase: "paywall_view_did_fail_purchase",
2453
- DidStartRestore: "paywall_view_did_start_restore",
2454
- DidFinishRestore: "paywall_view_did_finish_restore",
2455
- DidFailRestore: "paywall_view_did_fail_restore",
2456
- DidFailRendering: "paywall_view_did_fail_rendering",
2457
- DidFailLoadingProducts: "paywall_view_did_fail_loading_products",
2458
- DidFinishWebPaymentNavigation: "paywall_view_did_finish_web_payment_navigation"
2460
+ //#region src/types/flow-events.ts
2461
+ const FlowEventId = {
2462
+ DidAppear: "flow_view_did_appear",
2463
+ DidDisappear: "flow_view_did_disappear",
2464
+ DidPerformAction: "flow_view_did_perform_action",
2465
+ DidSelectProduct: "flow_view_did_select_product",
2466
+ DidStartPurchase: "flow_view_did_start_purchase",
2467
+ DidFinishPurchase: "flow_view_did_finish_purchase",
2468
+ DidFailPurchase: "flow_view_did_fail_purchase",
2469
+ DidStartRestore: "flow_view_did_start_restore",
2470
+ DidFinishRestore: "flow_view_did_finish_restore",
2471
+ DidFailRestore: "flow_view_did_fail_restore",
2472
+ DidReceiveError: "flow_view_did_receive_error",
2473
+ DidFailLoadingProducts: "flow_view_did_fail_loading_products",
2474
+ DidFinishWebPaymentNavigation: "flow_view_did_finish_web_payment_navigation",
2475
+ DidRequestAppReview: "flow_view_did_request_app_review",
2476
+ DidReceiveAnalyticEvent: "flow_view_did_receive_analytic_event",
2477
+ DidAskPermission: "flow_view_did_ask_permission",
2478
+ ObserverDidInitiatePurchase: "flow_view_observer_did_initiate_purchase",
2479
+ ObserverDidInitiateRestore: "flow_view_observer_did_initiate_restore"
2459
2480
  };
2460
2481
 
2461
2482
  //#endregion
@@ -2471,13 +2492,13 @@ const OnboardingEventId = {
2471
2492
  };
2472
2493
 
2473
2494
  //#endregion
2474
- //#region src/ui-builder/paywall-event-mapping.ts
2495
+ //#region src/ui-builder/flow-event-mapping.ts
2475
2496
  /**
2476
2497
  * Resolves native event to handler name based on event data
2477
2498
  */
2478
2499
  const NATIVE_EVENT_RESOLVER = {
2479
- [PaywallEventId.DidPerformAction]: (event) => {
2480
- if (event.id !== PaywallEventId.DidPerformAction) return null;
2500
+ [FlowEventId.DidPerformAction]: (event) => {
2501
+ if (event.id !== FlowEventId.DidPerformAction) return null;
2481
2502
  const actionMap = {
2482
2503
  close: "onCloseButtonPress",
2483
2504
  system_back: "onAndroidSystemBack",
@@ -2486,59 +2507,74 @@ const NATIVE_EVENT_RESOLVER = {
2486
2507
  };
2487
2508
  return actionMap[event.action.type] || null;
2488
2509
  },
2489
- [PaywallEventId.DidAppear]: () => "onAppeared",
2490
- [PaywallEventId.DidDisappear]: () => "onDisappeared",
2491
- [PaywallEventId.DidSelectProduct]: () => "onProductSelected",
2492
- [PaywallEventId.DidStartPurchase]: () => "onPurchaseStarted",
2493
- [PaywallEventId.DidFinishPurchase]: () => "onPurchaseCompleted",
2494
- [PaywallEventId.DidFailPurchase]: () => "onPurchaseFailed",
2495
- [PaywallEventId.DidStartRestore]: () => "onRestoreStarted",
2496
- [PaywallEventId.DidFinishRestore]: () => "onRestoreCompleted",
2497
- [PaywallEventId.DidFailRestore]: () => "onRestoreFailed",
2498
- [PaywallEventId.DidFailRendering]: () => "onRenderingFailed",
2499
- [PaywallEventId.DidFailLoadingProducts]: () => "onLoadingProductsFailed",
2500
- [PaywallEventId.DidFinishWebPaymentNavigation]: () => "onWebPaymentNavigationFinished"
2510
+ [FlowEventId.DidAppear]: () => "onAppeared",
2511
+ [FlowEventId.DidDisappear]: () => "onDisappeared",
2512
+ [FlowEventId.DidSelectProduct]: () => "onProductSelected",
2513
+ [FlowEventId.DidStartPurchase]: () => "onPurchaseStarted",
2514
+ [FlowEventId.DidFinishPurchase]: () => "onPurchaseCompleted",
2515
+ [FlowEventId.DidFailPurchase]: () => "onPurchaseFailed",
2516
+ [FlowEventId.DidStartRestore]: () => "onRestoreStarted",
2517
+ [FlowEventId.DidFinishRestore]: () => "onRestoreCompleted",
2518
+ [FlowEventId.DidFailRestore]: () => "onRestoreFailed",
2519
+ [FlowEventId.DidReceiveError]: () => "onError",
2520
+ [FlowEventId.DidFailLoadingProducts]: () => "onLoadingProductsFailed",
2521
+ [FlowEventId.DidFinishWebPaymentNavigation]: () => "onWebPaymentNavigationFinished",
2522
+ [FlowEventId.DidRequestAppReview]: () => "onRequestAppReview",
2523
+ [FlowEventId.DidReceiveAnalyticEvent]: () => "onAnalytics",
2524
+ [FlowEventId.DidAskPermission]: () => "onRequestPermission",
2525
+ [FlowEventId.ObserverDidInitiatePurchase]: () => "onObserverPurchaseInitiated",
2526
+ [FlowEventId.ObserverDidInitiateRestore]: () => "onObserverRestoreInitiated"
2501
2527
  };
2502
2528
  /**
2503
2529
  * Maps handler name to native event name
2504
2530
  * Used in addListener/addInternalListener to subscribe to correct native event
2505
2531
  */
2506
2532
  const HANDLER_TO_NATIVE_EVENT = {
2507
- onCloseButtonPress: PaywallEventId.DidPerformAction,
2508
- onAndroidSystemBack: PaywallEventId.DidPerformAction,
2509
- onUrlPress: PaywallEventId.DidPerformAction,
2510
- onCustomAction: PaywallEventId.DidPerformAction,
2511
- onAppeared: PaywallEventId.DidAppear,
2512
- onDisappeared: PaywallEventId.DidDisappear,
2513
- onProductSelected: PaywallEventId.DidSelectProduct,
2514
- onPurchaseStarted: PaywallEventId.DidStartPurchase,
2515
- onPurchaseCompleted: PaywallEventId.DidFinishPurchase,
2516
- onPurchaseFailed: PaywallEventId.DidFailPurchase,
2517
- onRestoreStarted: PaywallEventId.DidStartRestore,
2518
- onRestoreCompleted: PaywallEventId.DidFinishRestore,
2519
- onRestoreFailed: PaywallEventId.DidFailRestore,
2520
- onRenderingFailed: PaywallEventId.DidFailRendering,
2521
- onLoadingProductsFailed: PaywallEventId.DidFailLoadingProducts,
2522
- onWebPaymentNavigationFinished: PaywallEventId.DidFinishWebPaymentNavigation
2533
+ onCloseButtonPress: FlowEventId.DidPerformAction,
2534
+ onAndroidSystemBack: FlowEventId.DidPerformAction,
2535
+ onUrlPress: FlowEventId.DidPerformAction,
2536
+ onCustomAction: FlowEventId.DidPerformAction,
2537
+ onAppeared: FlowEventId.DidAppear,
2538
+ onDisappeared: FlowEventId.DidDisappear,
2539
+ onProductSelected: FlowEventId.DidSelectProduct,
2540
+ onPurchaseStarted: FlowEventId.DidStartPurchase,
2541
+ onPurchaseCompleted: FlowEventId.DidFinishPurchase,
2542
+ onPurchaseFailed: FlowEventId.DidFailPurchase,
2543
+ onRestoreStarted: FlowEventId.DidStartRestore,
2544
+ onRestoreCompleted: FlowEventId.DidFinishRestore,
2545
+ onRestoreFailed: FlowEventId.DidFailRestore,
2546
+ onError: FlowEventId.DidReceiveError,
2547
+ onLoadingProductsFailed: FlowEventId.DidFailLoadingProducts,
2548
+ onWebPaymentNavigationFinished: FlowEventId.DidFinishWebPaymentNavigation,
2549
+ onRequestAppReview: FlowEventId.DidRequestAppReview,
2550
+ onAnalytics: FlowEventId.DidReceiveAnalyticEvent,
2551
+ onRequestPermission: FlowEventId.DidAskPermission,
2552
+ onObserverPurchaseInitiated: FlowEventId.ObserverDidInitiatePurchase,
2553
+ onObserverRestoreInitiated: FlowEventId.ObserverDidInitiateRestore
2523
2554
  };
2524
- function extractPaywallCallbackArgs(handlerName, event) {
2555
+ function extractFlowCallbackArgs(handlerName, event) {
2525
2556
  switch (event.id) {
2526
- case PaywallEventId.DidSelectProduct: return [event.productId];
2527
- case PaywallEventId.DidStartPurchase: return [event.product];
2528
- case PaywallEventId.DidFinishPurchase: return [event.purchaseResult, event.product];
2529
- case PaywallEventId.DidFailPurchase: return [event.error, event.product];
2530
- case PaywallEventId.DidFinishRestore: return [event.profile];
2531
- case PaywallEventId.DidFailRestore:
2532
- case PaywallEventId.DidFailRendering:
2533
- case PaywallEventId.DidFailLoadingProducts: return [event.error];
2534
- case PaywallEventId.DidPerformAction:
2557
+ case FlowEventId.DidSelectProduct: return [event.productId];
2558
+ case FlowEventId.DidStartPurchase: return [event.product];
2559
+ case FlowEventId.DidFinishPurchase: return [event.purchaseResult, event.product];
2560
+ case FlowEventId.DidFailPurchase: return [event.error, event.product];
2561
+ case FlowEventId.DidFinishRestore: return [event.profile];
2562
+ case FlowEventId.DidFailRestore:
2563
+ case FlowEventId.DidReceiveError:
2564
+ case FlowEventId.DidFailLoadingProducts: return [event.error];
2565
+ case FlowEventId.DidPerformAction:
2535
2566
  if (handlerName === "onUrlPress" && event.action.type === "open_url") return [event.action.value, event.action.openIn];
2536
2567
  if (handlerName === "onCustomAction" && event.action.type === "custom") return [event.action.value];
2537
2568
  return [];
2538
- case PaywallEventId.DidFinishWebPaymentNavigation: return [event.product, event.error];
2539
- case PaywallEventId.DidAppear:
2540
- case PaywallEventId.DidDisappear:
2541
- case PaywallEventId.DidStartRestore: return [];
2569
+ case FlowEventId.DidFinishWebPaymentNavigation: return [event.product, event.error];
2570
+ case FlowEventId.DidReceiveAnalyticEvent: return [event.name, event.params];
2571
+ case FlowEventId.DidAskPermission: return [event.permission, event.customArgs];
2572
+ case FlowEventId.ObserverDidInitiatePurchase:
2573
+ case FlowEventId.ObserverDidInitiateRestore: return [];
2574
+ case FlowEventId.DidRequestAppReview:
2575
+ case FlowEventId.DidAppear:
2576
+ case FlowEventId.DidDisappear:
2577
+ case FlowEventId.DidStartRestore: return [];
2542
2578
  }
2543
2579
  }
2544
2580
 
@@ -2642,10 +2678,9 @@ function getCoder(factory, type, ctx) {
2642
2678
  switch (type) {
2643
2679
  case "AdaptyError": return factory.createNativeErrorCoder();
2644
2680
  case "AdaptyProfile": return factory.createProfileCoder();
2645
- case "AdaptyPaywall": return factory.createPaywallCoder();
2681
+ case "AdaptyFlow": return factory.createFlowCoder();
2646
2682
  case "AdaptyPaywallProduct": return factory.createPaywallProductCoder();
2647
2683
  case "AdaptyRemoteConfig": return factory.createRemoteConfigCoder();
2648
- case "AdaptyPaywallBuilder": return factory.createPaywallBuilderCoder();
2649
2684
  case "AdaptyOnboarding": return factory.createOnboardingCoder();
2650
2685
  case "AdaptyPurchaseResult": return factory.createPurchaseResultCoder();
2651
2686
  case "AdaptyInstallationStatus": return factory.createInstallationStatusCoder();
@@ -2661,8 +2696,8 @@ function getCoder(factory, type, ctx) {
2661
2696
  }
2662
2697
 
2663
2698
  //#endregion
2664
- //#region src/coders/parse-paywall.ts
2665
- function parsePaywallEvent(factory, input, ctx) {
2699
+ //#region src/coders/parse-flow.ts
2700
+ function parseFlowEvent(factory, input, ctx) {
2666
2701
  let obj;
2667
2702
  try {
2668
2703
  obj = JSON.parse(input);
@@ -2670,7 +2705,7 @@ function parsePaywallEvent(factory, input, ctx) {
2670
2705
  throw AdaptyError.failedToDecode(`Failed to decode event: ${error?.message}`);
2671
2706
  }
2672
2707
  const eventId = obj["id"];
2673
- if (!eventId?.startsWith("paywall_view_")) return null;
2708
+ if (!eventId?.startsWith("flow_view_")) return null;
2674
2709
  const viewObj = obj["view"];
2675
2710
  const view = {
2676
2711
  id: viewObj["id"],
@@ -2678,59 +2713,59 @@ function parsePaywallEvent(factory, input, ctx) {
2678
2713
  variationId: viewObj["variation_id"]
2679
2714
  };
2680
2715
  switch (eventId) {
2681
- case PaywallEventId.DidAppear: return {
2716
+ case FlowEventId.DidAppear: return {
2682
2717
  id: eventId,
2683
2718
  view
2684
2719
  };
2685
- case PaywallEventId.DidDisappear: return {
2720
+ case FlowEventId.DidDisappear: return {
2686
2721
  id: eventId,
2687
2722
  view
2688
2723
  };
2689
- case PaywallEventId.DidPerformAction: {
2724
+ case FlowEventId.DidPerformAction: {
2690
2725
  const actionObj = obj["action"];
2691
2726
  return {
2692
2727
  id: eventId,
2693
2728
  view,
2694
- action: parsePaywallUserAction(actionObj)
2729
+ action: parseFlowUserAction(actionObj)
2695
2730
  };
2696
2731
  }
2697
- case PaywallEventId.DidSelectProduct: return {
2732
+ case FlowEventId.DidSelectProduct: return {
2698
2733
  id: eventId,
2699
2734
  view,
2700
2735
  productId: obj["product_id"] ?? ""
2701
2736
  };
2702
- case PaywallEventId.DidStartPurchase: return {
2737
+ case FlowEventId.DidStartPurchase: return {
2703
2738
  id: eventId,
2704
2739
  view,
2705
- product: getPaywallCoder(factory, "product", ctx).decode(obj["product"])
2740
+ product: getFlowCoder(factory, "product", ctx).decode(obj["product"])
2706
2741
  };
2707
- case PaywallEventId.DidFinishPurchase: return {
2742
+ case FlowEventId.DidFinishPurchase: return {
2708
2743
  id: eventId,
2709
2744
  view,
2710
- purchaseResult: getPaywallCoder(factory, "purchaseResult", ctx).decode(obj["purchased_result"]),
2711
- product: getPaywallCoder(factory, "product", ctx).decode(obj["product"])
2745
+ purchaseResult: getFlowCoder(factory, "purchaseResult", ctx).decode(obj["purchased_result"]),
2746
+ product: getFlowCoder(factory, "product", ctx).decode(obj["product"])
2712
2747
  };
2713
- case PaywallEventId.DidFailPurchase: {
2714
- const errorCoder = getPaywallCoder(factory, "error", ctx);
2748
+ case FlowEventId.DidFailPurchase: {
2749
+ const errorCoder = getFlowCoder(factory, "error", ctx);
2715
2750
  const decodedError = errorCoder.decode(obj["error"]);
2716
2751
  return {
2717
2752
  id: eventId,
2718
2753
  view,
2719
2754
  error: errorCoder.getError(decodedError),
2720
- product: getPaywallCoder(factory, "product", ctx).decode(obj["product"])
2755
+ product: getFlowCoder(factory, "product", ctx).decode(obj["product"])
2721
2756
  };
2722
2757
  }
2723
- case PaywallEventId.DidStartRestore: return {
2758
+ case FlowEventId.DidStartRestore: return {
2724
2759
  id: eventId,
2725
2760
  view
2726
2761
  };
2727
- case PaywallEventId.DidFinishRestore: return {
2762
+ case FlowEventId.DidFinishRestore: return {
2728
2763
  id: eventId,
2729
2764
  view,
2730
- profile: getPaywallCoder(factory, "profile", ctx).decode(obj["profile"])
2765
+ profile: getFlowCoder(factory, "profile", ctx).decode(obj["profile"])
2731
2766
  };
2732
- case PaywallEventId.DidFailRestore: {
2733
- const errorCoder = getPaywallCoder(factory, "error", ctx);
2767
+ case FlowEventId.DidFailRestore: {
2768
+ const errorCoder = getFlowCoder(factory, "error", ctx);
2734
2769
  const decodedError = errorCoder.decode(obj["error"]);
2735
2770
  return {
2736
2771
  id: eventId,
@@ -2738,8 +2773,8 @@ function parsePaywallEvent(factory, input, ctx) {
2738
2773
  error: errorCoder.getError(decodedError)
2739
2774
  };
2740
2775
  }
2741
- case PaywallEventId.DidFailRendering: {
2742
- const errorCoder = getPaywallCoder(factory, "error", ctx);
2776
+ case FlowEventId.DidReceiveError: {
2777
+ const errorCoder = getFlowCoder(factory, "error", ctx);
2743
2778
  const decodedError = errorCoder.decode(obj["error"]);
2744
2779
  return {
2745
2780
  id: eventId,
@@ -2747,8 +2782,8 @@ function parsePaywallEvent(factory, input, ctx) {
2747
2782
  error: errorCoder.getError(decodedError)
2748
2783
  };
2749
2784
  }
2750
- case PaywallEventId.DidFailLoadingProducts: {
2751
- const errorCoder = getPaywallCoder(factory, "error", ctx);
2785
+ case FlowEventId.DidFailLoadingProducts: {
2786
+ const errorCoder = getFlowCoder(factory, "error", ctx);
2752
2787
  const decodedError = errorCoder.decode(obj["error"]);
2753
2788
  return {
2754
2789
  id: eventId,
@@ -2756,20 +2791,51 @@ function parsePaywallEvent(factory, input, ctx) {
2756
2791
  error: errorCoder.getError(decodedError)
2757
2792
  };
2758
2793
  }
2759
- case PaywallEventId.DidFinishWebPaymentNavigation: return {
2794
+ case FlowEventId.DidFinishWebPaymentNavigation: return {
2760
2795
  id: eventId,
2761
2796
  view,
2762
- product: obj["product"] ? getPaywallCoder(factory, "product", ctx).decode(obj["product"]) : void 0,
2797
+ product: obj["product"] ? getFlowCoder(factory, "product", ctx).decode(obj["product"]) : void 0,
2763
2798
  error: obj["error"] ? (() => {
2764
- const errorCoder = getPaywallCoder(factory, "error", ctx);
2799
+ const errorCoder = getFlowCoder(factory, "error", ctx);
2765
2800
  const decodedError = errorCoder.decode(obj["error"]);
2766
2801
  return errorCoder.getError(decodedError);
2767
2802
  })() : void 0
2768
2803
  };
2804
+ case FlowEventId.DidRequestAppReview: return {
2805
+ id: eventId,
2806
+ view
2807
+ };
2808
+ case FlowEventId.DidReceiveAnalyticEvent: {
2809
+ const params = obj["params"];
2810
+ return {
2811
+ id: eventId,
2812
+ view,
2813
+ name: typeof obj["name"] === "string" ? obj["name"] : "",
2814
+ params: typeof params === "object" && params !== null ? params : {}
2815
+ };
2816
+ }
2817
+ case FlowEventId.DidAskPermission: return {
2818
+ id: eventId,
2819
+ view,
2820
+ eventId: typeof obj["event_id"] === "string" ? obj["event_id"] : "",
2821
+ permission: typeof obj["permission"] === "string" ? obj["permission"] : "",
2822
+ customArgs: typeof obj["custom_args"] === "object" && obj["custom_args"] !== null ? obj["custom_args"] : {}
2823
+ };
2824
+ case FlowEventId.ObserverDidInitiatePurchase: return {
2825
+ id: eventId,
2826
+ view,
2827
+ eventId: typeof obj["event_id"] === "string" ? obj["event_id"] : "",
2828
+ product: getFlowCoder(factory, "product", ctx).decode(obj["product"])
2829
+ };
2830
+ case FlowEventId.ObserverDidInitiateRestore: return {
2831
+ id: eventId,
2832
+ view,
2833
+ eventId: typeof obj["event_id"] === "string" ? obj["event_id"] : ""
2834
+ };
2769
2835
  default: return null;
2770
2836
  }
2771
2837
  }
2772
- function parsePaywallUserAction(actionObj) {
2838
+ function parseFlowUserAction(actionObj) {
2773
2839
  const type = actionObj["type"];
2774
2840
  switch (type) {
2775
2841
  case "open_url": return {
@@ -2785,7 +2851,7 @@ function parsePaywallUserAction(actionObj) {
2785
2851
  case "system_back": return { type };
2786
2852
  }
2787
2853
  }
2788
- function getPaywallCoder(factory, type, _ctx) {
2854
+ function getFlowCoder(factory, type, _ctx) {
2789
2855
  switch (type) {
2790
2856
  case "product": return factory.createPaywallProductCoder();
2791
2857
  case "profile": return factory.createProfileCoder();
@@ -2986,5 +3052,5 @@ function withErrorContext(callback, handlerName, source) {
2986
3052
  }
2987
3053
 
2988
3054
  //#endregion
2989
- export { AdaptyAndroidSubscriptionUpdateReplacementMode, AdaptyError, AdaptyUiDialogActionType, AppTrackingTransparencyStatus, CancellationReason, CoderFactory, DefaultLoggerAdapter, DefaultPlatformAdapter, DefaultSdkMetadataAdapter, ErrorCode, ErrorCodeName, FetchPolicy, Gender, HANDLER_TO_EVENT_CONFIG, HANDLER_TO_NATIVE_EVENT, Log, LogContext, LogLevel, LogScope, MethodNames, NATIVE_EVENT_RESOLVER, NATIVE_EVENT_TO_HANDLERS, ONBOARDING_EVENT_MAPPINGS, OfferType, OnboardingEventId, PaywallEventId, ProductPeriod, RefundPreference, VendorStore, WebPresentation, consoleLogSink, extractOnboardingCallbackArgs, extractPaywallCallbackArgs, filterUndefined, generateId, getErrorCode, getErrorPrompt, mapValues, mergeOptions, parseCommonEvent, parseMethodResult, parseOnboardingEvent, parsePaywallEvent, withErrorContext };
3055
+ export { AdaptyAndroidSubscriptionUpdateReplacementMode, AdaptyError, AdaptyUiDialogActionType, AppTrackingTransparencyStatus, CancellationReason, CoderFactory, DefaultLoggerAdapter, DefaultPlatformAdapter, DefaultSdkMetadataAdapter, ErrorCode, ErrorCodeName, FetchPolicy, FlowEventId, Gender, HANDLER_TO_EVENT_CONFIG, HANDLER_TO_NATIVE_EVENT, Log, LogContext, LogLevel, LogScope, MethodNames, NATIVE_EVENT_RESOLVER, NATIVE_EVENT_TO_HANDLERS, ONBOARDING_EVENT_MAPPINGS, OfferType, OnboardingEventId, ProductPeriod, RefundPreference, VendorStore, WebPresentation, consoleLogSink, extractFlowCallbackArgs, extractOnboardingCallbackArgs, filterUndefined, generateId, getErrorCode, getErrorPrompt, mapValues, mergeOptions, parseCommonEvent, parseFlowEvent, parseMethodResult, parseOnboardingEvent, withErrorContext };
2990
3056
  //# sourceMappingURL=index.mjs.map