@adapty/capacitor 3.17.0 → 4.0.0-beta.1

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.
Files changed (75) hide show
  1. package/Package.swift +1 -1
  2. package/README.md +8 -0
  3. package/android/build.gradle +2 -2
  4. package/dist/esm/adapty-instance.d.ts +7 -0
  5. package/dist/esm/adapty-instance.js +8 -0
  6. package/dist/esm/adapty-instance.js.map +1 -0
  7. package/dist/esm/adapty.d.ts +112 -59
  8. package/dist/esm/adapty.js +132 -69
  9. package/dist/esm/adapty.js.map +1 -1
  10. package/dist/esm/coders/parse-flow.d.ts +3 -0
  11. package/dist/esm/coders/parse-flow.js +4 -0
  12. package/dist/esm/coders/parse-flow.js.map +1 -0
  13. package/dist/esm/default-configs.js +2 -2
  14. package/dist/esm/default-configs.js.map +1 -1
  15. package/dist/esm/index.d.ts +4 -4
  16. package/dist/esm/index.js +3 -3
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/types/adapty-plugin.d.ts +31 -17
  19. package/dist/esm/types/adapty-plugin.js.map +1 -1
  20. package/dist/esm/types/configs.d.ts +12 -14
  21. package/dist/esm/types/configs.js.map +1 -1
  22. package/dist/esm/types/flow-events.d.ts +1 -0
  23. package/dist/esm/types/flow-events.js +2 -0
  24. package/dist/esm/types/flow-events.js.map +1 -0
  25. package/dist/esm/types/index.d.ts +2 -2
  26. package/dist/esm/types/index.js +1 -1
  27. package/dist/esm/types/index.js.map +1 -1
  28. package/dist/esm/types/inputs.d.ts +1 -1
  29. package/dist/esm/types/inputs.js.map +1 -1
  30. package/dist/esm/ui-builder/base-view-emitter.d.ts +6 -0
  31. package/dist/esm/ui-builder/base-view-emitter.js +12 -0
  32. package/dist/esm/ui-builder/base-view-emitter.js.map +1 -1
  33. package/dist/esm/ui-builder/create-flow-view.d.ts +14 -0
  34. package/dist/esm/ui-builder/create-flow-view.js +16 -0
  35. package/dist/esm/ui-builder/create-flow-view.js.map +1 -0
  36. package/dist/esm/ui-builder/create-onboarding-view.d.ts +2 -0
  37. package/dist/esm/ui-builder/create-onboarding-view.js +2 -0
  38. package/dist/esm/ui-builder/create-onboarding-view.js.map +1 -1
  39. package/dist/esm/ui-builder/{paywall-view-controller.d.ts → flow-view-controller.d.ts} +37 -37
  40. package/dist/esm/ui-builder/{paywall-view-controller.js → flow-view-controller.js} +54 -51
  41. package/dist/esm/ui-builder/flow-view-controller.js.map +1 -0
  42. package/dist/esm/ui-builder/flow-view-emitter.d.ts +38 -0
  43. package/dist/esm/ui-builder/flow-view-emitter.js +151 -0
  44. package/dist/esm/ui-builder/flow-view-emitter.js.map +1 -0
  45. package/dist/esm/ui-builder/index.d.ts +5 -5
  46. package/dist/esm/ui-builder/index.js +3 -2
  47. package/dist/esm/ui-builder/index.js.map +1 -1
  48. package/dist/esm/ui-builder/onboarding-view-controller.d.ts +7 -5
  49. package/dist/esm/ui-builder/onboarding-view-controller.js +7 -5
  50. package/dist/esm/ui-builder/onboarding-view-controller.js.map +1 -1
  51. package/dist/esm/ui-builder/types.d.ts +11 -358
  52. package/dist/esm/ui-builder/types.js +52 -22
  53. package/dist/esm/ui-builder/types.js.map +1 -1
  54. package/dist/esm/version.d.ts +1 -1
  55. package/dist/esm/version.js +1 -1
  56. package/dist/esm/version.js.map +1 -1
  57. package/dist/plugin.cjs.js +906 -677
  58. package/dist/plugin.cjs.js.map +1 -1
  59. package/dist/plugin.js +906 -677
  60. package/dist/plugin.js.map +1 -1
  61. package/package.json +3 -5
  62. package/AdaptyCapacitor.podspec +0 -20
  63. package/dist/esm/coders/parse-paywall.d.ts +0 -3
  64. package/dist/esm/coders/parse-paywall.js +0 -4
  65. package/dist/esm/coders/parse-paywall.js.map +0 -1
  66. package/dist/esm/types/paywall-events.d.ts +0 -1
  67. package/dist/esm/types/paywall-events.js +0 -2
  68. package/dist/esm/types/paywall-events.js.map +0 -1
  69. package/dist/esm/ui-builder/create-paywall-view.d.ts +0 -25
  70. package/dist/esm/ui-builder/create-paywall-view.js +0 -29
  71. package/dist/esm/ui-builder/create-paywall-view.js.map +0 -1
  72. package/dist/esm/ui-builder/paywall-view-controller.js.map +0 -1
  73. package/dist/esm/ui-builder/paywall-view-emitter.d.ts +0 -16
  74. package/dist/esm/ui-builder/paywall-view-emitter.js +0 -114
  75. package/dist/esm/ui-builder/paywall-view-emitter.js.map +0 -1
@@ -813,6 +813,283 @@ var AdaptyDiscountPhaseCoder = class extends SimpleCoder {
813
813
  }
814
814
  };
815
815
 
816
+ //#endregion
817
+ //#region src/coders/product-reference.ts
818
+ var ProductReferenceCoder = class extends SimpleCoder {
819
+ constructor(..._args) {
820
+ super(..._args);
821
+ this.properties = {
822
+ flowProductId: {
823
+ key: "flow_product_id",
824
+ required: false,
825
+ type: "string"
826
+ },
827
+ vendorId: {
828
+ key: "vendor_product_id",
829
+ required: true,
830
+ type: "string"
831
+ },
832
+ adaptyId: {
833
+ key: "adapty_product_id",
834
+ required: true,
835
+ type: "string"
836
+ },
837
+ accessLevelId: {
838
+ key: "access_level_id",
839
+ required: true,
840
+ type: "string"
841
+ },
842
+ productType: {
843
+ key: "product_type",
844
+ required: true,
845
+ type: "string"
846
+ },
847
+ ios: {
848
+ promotionalOfferId: {
849
+ key: "promotional_offer_id",
850
+ required: false,
851
+ type: "string"
852
+ },
853
+ winBackOfferId: {
854
+ key: "win_back_offer_id",
855
+ required: false,
856
+ type: "string"
857
+ }
858
+ },
859
+ android: {
860
+ basePlanId: {
861
+ key: "base_plan_id",
862
+ required: false,
863
+ type: "string"
864
+ },
865
+ offerId: {
866
+ key: "offer_id",
867
+ required: false,
868
+ type: "string"
869
+ }
870
+ }
871
+ };
872
+ }
873
+ };
874
+
875
+ //#endregion
876
+ //#region src/coders/array.ts
877
+ var ArrayCoder = class {
878
+ constructor(coderFactory) {
879
+ this.coderFactory = coderFactory;
880
+ }
881
+ decode(input) {
882
+ const coder = this.coderFactory();
883
+ return input.map((item) => coder.decode(item));
884
+ }
885
+ encode(value) {
886
+ const coder = this.coderFactory();
887
+ return value.map((item) => coder.encode(item));
888
+ }
889
+ };
890
+
891
+ //#endregion
892
+ //#region src/coders/adapty-placement.ts
893
+ var AdaptyPlacementCoder = class extends SimpleCoder {
894
+ constructor(..._args) {
895
+ super(..._args);
896
+ this.properties = {
897
+ abTestName: {
898
+ key: "ab_test_name",
899
+ required: true,
900
+ type: "string"
901
+ },
902
+ audienceName: {
903
+ key: "audience_name",
904
+ required: true,
905
+ type: "string"
906
+ },
907
+ id: {
908
+ key: "developer_id",
909
+ required: true,
910
+ type: "string"
911
+ },
912
+ revision: {
913
+ key: "revision",
914
+ required: true,
915
+ type: "number"
916
+ },
917
+ audienceVersionId: {
918
+ key: "placement_audience_version_id",
919
+ required: true,
920
+ type: "string"
921
+ },
922
+ isTrackingPurchases: {
923
+ key: "is_tracking_purchases",
924
+ required: false,
925
+ type: "boolean"
926
+ }
927
+ };
928
+ }
929
+ };
930
+
931
+ //#endregion
932
+ //#region src/coders/adapty-flow-paywall.ts
933
+ const PROPERTIES = {
934
+ placement: {
935
+ key: "placement",
936
+ required: true,
937
+ type: "object",
938
+ converter: new AdaptyPlacementCoder()
939
+ },
940
+ id: {
941
+ key: "paywall_id",
942
+ required: true,
943
+ type: "string"
944
+ },
945
+ name: {
946
+ key: "paywall_name",
947
+ required: true,
948
+ type: "string"
949
+ },
950
+ products: {
951
+ key: "products",
952
+ required: true,
953
+ type: "array",
954
+ converter: new ArrayCoder(() => new ProductReferenceCoder())
955
+ },
956
+ variationId: {
957
+ key: "variation_id",
958
+ required: true,
959
+ type: "string"
960
+ },
961
+ webPurchaseUrl: {
962
+ key: "web_purchase_url",
963
+ required: false,
964
+ type: "string"
965
+ }
966
+ };
967
+ var AdaptyFlowPaywallCoder = class extends Coder {
968
+ constructor(..._args) {
969
+ super(..._args);
970
+ this.properties = PROPERTIES;
971
+ }
972
+ decode(data) {
973
+ const codablePart = super.decode(data);
974
+ return {
975
+ ...codablePart,
976
+ productIdentifiers: codablePart.products.map((product) => ({
977
+ vendorProductId: product.vendorId,
978
+ adaptyProductId: product.adaptyId,
979
+ basePlanId: product.android?.basePlanId
980
+ }))
981
+ };
982
+ }
983
+ encode(data) {
984
+ const { productIdentifiers,...codablePart } = data;
985
+ return super.encode(codablePart);
986
+ }
987
+ };
988
+
989
+ //#endregion
990
+ //#region src/coders/json.ts
991
+ var JSONCoder = class {
992
+ decode(input) {
993
+ if (!input) return {};
994
+ return JSON.parse(input);
995
+ }
996
+ encode(value) {
997
+ if (Object.keys(value).length === 0) return "";
998
+ return JSON.stringify(value);
999
+ }
1000
+ };
1001
+
1002
+ //#endregion
1003
+ //#region src/coders/adapty-remote-config.ts
1004
+ var AdaptyRemoteConfigCoder = class extends Coder {
1005
+ constructor(..._args) {
1006
+ super(..._args);
1007
+ this.properties = {
1008
+ data: {
1009
+ key: "data",
1010
+ required: true,
1011
+ type: "string",
1012
+ converter: new JSONCoder()
1013
+ },
1014
+ lang: {
1015
+ key: "lang",
1016
+ required: true,
1017
+ type: "string"
1018
+ }
1019
+ };
1020
+ }
1021
+ decode(data) {
1022
+ const codablePart = super.decode(data);
1023
+ const dataString = JSON.stringify(codablePart.data);
1024
+ return {
1025
+ ...codablePart,
1026
+ dataString: dataString.length < 4 ? "" : dataString
1027
+ };
1028
+ }
1029
+ encode(data) {
1030
+ const { dataString,...codablePart } = data;
1031
+ return super.encode(codablePart);
1032
+ }
1033
+ };
1034
+
1035
+ //#endregion
1036
+ //#region src/coders/adapty-flow.ts
1037
+ var AdaptyFlowCoder = class extends SimpleCoder {
1038
+ constructor(..._args) {
1039
+ super(..._args);
1040
+ this.properties = {
1041
+ placement: {
1042
+ key: "placement",
1043
+ required: true,
1044
+ type: "object",
1045
+ converter: new AdaptyPlacementCoder()
1046
+ },
1047
+ id: {
1048
+ key: "flow_id",
1049
+ required: true,
1050
+ type: "string"
1051
+ },
1052
+ name: {
1053
+ key: "flow_name",
1054
+ required: true,
1055
+ type: "string"
1056
+ },
1057
+ variationId: {
1058
+ key: "variation_id",
1059
+ required: true,
1060
+ type: "string"
1061
+ },
1062
+ remoteConfigs: {
1063
+ key: "remote_configs",
1064
+ required: false,
1065
+ type: "array",
1066
+ converter: new ArrayCoder(() => new AdaptyRemoteConfigCoder())
1067
+ },
1068
+ flowVersionId: {
1069
+ key: "flow_version_id",
1070
+ required: false,
1071
+ type: "string"
1072
+ },
1073
+ paywalls: {
1074
+ key: "variations",
1075
+ required: true,
1076
+ type: "array",
1077
+ converter: new ArrayCoder(() => new AdaptyFlowPaywallCoder())
1078
+ },
1079
+ responseCreatedAt: {
1080
+ key: "response_created_at",
1081
+ required: true,
1082
+ type: "number"
1083
+ },
1084
+ payloadData: {
1085
+ key: "payload_data",
1086
+ required: false,
1087
+ type: "string"
1088
+ }
1089
+ };
1090
+ }
1091
+ };
1092
+
816
1093
  //#endregion
817
1094
  //#region src/coders/adapty-identify-params.ts
818
1095
  var AdaptyIdentifyParamsCoder = class {
@@ -982,92 +1259,6 @@ var AdaptyOnboardingBuilderCoder = class extends SimpleCoder {
982
1259
  }
983
1260
  };
984
1261
 
985
- //#endregion
986
- //#region src/coders/json.ts
987
- var JSONCoder = class {
988
- decode(input) {
989
- if (!input) return {};
990
- return JSON.parse(input);
991
- }
992
- encode(value) {
993
- if (Object.keys(value).length === 0) return "";
994
- return JSON.stringify(value);
995
- }
996
- };
997
-
998
- //#endregion
999
- //#region src/coders/adapty-remote-config.ts
1000
- var AdaptyRemoteConfigCoder = class extends Coder {
1001
- constructor(..._args) {
1002
- super(..._args);
1003
- this.properties = {
1004
- data: {
1005
- key: "data",
1006
- required: true,
1007
- type: "string",
1008
- converter: new JSONCoder()
1009
- },
1010
- lang: {
1011
- key: "lang",
1012
- required: true,
1013
- type: "string"
1014
- }
1015
- };
1016
- }
1017
- decode(data) {
1018
- const codablePart = super.decode(data);
1019
- const dataString = JSON.stringify(codablePart.data);
1020
- return {
1021
- ...codablePart,
1022
- dataString: dataString.length < 4 ? "" : dataString
1023
- };
1024
- }
1025
- encode(data) {
1026
- const { dataString,...codablePart } = data;
1027
- return super.encode(codablePart);
1028
- }
1029
- };
1030
-
1031
- //#endregion
1032
- //#region src/coders/adapty-placement.ts
1033
- var AdaptyPlacementCoder = class extends SimpleCoder {
1034
- constructor(..._args) {
1035
- super(..._args);
1036
- this.properties = {
1037
- abTestName: {
1038
- key: "ab_test_name",
1039
- required: true,
1040
- type: "string"
1041
- },
1042
- audienceName: {
1043
- key: "audience_name",
1044
- required: true,
1045
- type: "string"
1046
- },
1047
- id: {
1048
- key: "developer_id",
1049
- required: true,
1050
- type: "string"
1051
- },
1052
- revision: {
1053
- key: "revision",
1054
- required: true,
1055
- type: "number"
1056
- },
1057
- audienceVersionId: {
1058
- key: "placement_audience_version_id",
1059
- required: true,
1060
- type: "string"
1061
- },
1062
- isTrackingPurchases: {
1063
- key: "is_tracking_purchases",
1064
- required: false,
1065
- type: "boolean"
1066
- }
1067
- };
1068
- }
1069
- };
1070
-
1071
1262
  //#endregion
1072
1263
  //#region src/coders/adapty-onboarding.ts
1073
1264
  var AdaptyOnboardingCoder = class extends Coder {
@@ -1137,26 +1328,6 @@ var AdaptyOnboardingCoder = class extends Coder {
1137
1328
  }
1138
1329
  };
1139
1330
 
1140
- //#endregion
1141
- //#region src/coders/adapty-paywall-builder.ts
1142
- var AdaptyPaywallBuilderCoder = class extends SimpleCoder {
1143
- constructor(..._args) {
1144
- super(..._args);
1145
- this.properties = {
1146
- id: {
1147
- key: "paywall_builder_id",
1148
- required: true,
1149
- type: "string"
1150
- },
1151
- lang: {
1152
- key: "lang",
1153
- required: true,
1154
- type: "string"
1155
- }
1156
- };
1157
- }
1158
- };
1159
-
1160
1331
  //#endregion
1161
1332
  //#region src/coders/adapty-subscription-offer-identifier.ts
1162
1333
  var AdaptySubscriptionOfferIdCoder = class extends SimpleCoder {
@@ -1177,22 +1348,6 @@ var AdaptySubscriptionOfferIdCoder = class extends SimpleCoder {
1177
1348
  }
1178
1349
  };
1179
1350
 
1180
- //#endregion
1181
- //#region src/coders/array.ts
1182
- var ArrayCoder = class {
1183
- constructor(coderFactory) {
1184
- this.coderFactory = coderFactory;
1185
- }
1186
- decode(input) {
1187
- const coder = this.coderFactory();
1188
- return input.map((item) => coder.decode(item));
1189
- }
1190
- encode(value) {
1191
- const coder = this.coderFactory();
1192
- return value.map((item) => coder.encode(item));
1193
- }
1194
- };
1195
-
1196
1351
  //#endregion
1197
1352
  //#region src/coders/adapty-subscription-offer.ts
1198
1353
  var AdaptySubscriptionOfferCoder = class extends SimpleCoder {
@@ -1289,204 +1444,61 @@ var AdaptyPaywallProductCoder = class extends SimpleCoder {
1289
1444
  required: true,
1290
1445
  type: "string"
1291
1446
  },
1292
- adaptyId: {
1293
- key: "adapty_product_id",
1294
- required: true,
1295
- type: "string"
1296
- },
1297
- paywallProductIndex: {
1298
- key: "paywall_product_index",
1299
- required: true,
1300
- type: "number"
1301
- },
1302
- localizedDescription: {
1303
- key: "localized_description",
1304
- required: true,
1305
- type: "string"
1306
- },
1307
- localizedTitle: {
1308
- key: "localized_title",
1309
- required: true,
1310
- type: "string"
1311
- },
1312
- regionCode: {
1313
- key: "region_code",
1314
- required: false,
1315
- type: "string"
1316
- },
1317
- variationId: {
1318
- key: "paywall_variation_id",
1319
- required: true,
1320
- type: "string"
1321
- },
1322
- paywallABTestName: {
1323
- key: "paywall_ab_test_name",
1324
- required: true,
1325
- type: "string"
1326
- },
1327
- paywallName: {
1328
- key: "paywall_name",
1329
- required: true,
1330
- type: "string"
1331
- },
1332
- accessLevelId: {
1333
- key: "access_level_id",
1334
- required: true,
1335
- type: "string"
1336
- },
1337
- productType: {
1338
- key: "product_type",
1339
- required: true,
1340
- type: "string"
1341
- },
1342
- price: {
1343
- key: "price",
1344
- required: false,
1345
- type: "object",
1346
- converter: new AdaptyPriceCoder()
1347
- },
1348
- webPurchaseUrl: {
1349
- key: "web_purchase_url",
1350
- required: false,
1351
- type: "string"
1352
- },
1353
- payloadData: {
1354
- key: "payload_data",
1355
- required: false,
1356
- type: "string"
1357
- },
1358
- subscription: {
1359
- key: "subscription",
1360
- required: false,
1361
- type: "object",
1362
- converter: new AdaptySubscriptionDetailsCoder()
1363
- },
1364
- ios: { isFamilyShareable: {
1365
- key: "is_family_shareable",
1366
- required: true,
1367
- type: "boolean"
1368
- } }
1369
- };
1370
- }
1371
- getInput(data) {
1372
- return {
1373
- adapty_product_id: data.adapty_product_id,
1374
- access_level_id: data.access_level_id,
1375
- product_type: data.product_type,
1376
- paywall_product_index: data.paywall_product_index,
1377
- paywall_ab_test_name: data.paywall_ab_test_name,
1378
- payload_data: data.payload_data,
1379
- paywall_name: data.paywall_name,
1380
- paywall_variation_id: data.paywall_variation_id,
1381
- subscription_offer_identifier: data.subscription?.offer?.offer_identifier,
1382
- vendor_product_id: data.vendor_product_id
1383
- };
1384
- }
1385
- };
1386
-
1387
- //#endregion
1388
- //#region src/coders/product-reference.ts
1389
- var ProductReferenceCoder = class extends SimpleCoder {
1390
- constructor(..._args) {
1391
- super(..._args);
1392
- this.properties = {
1393
- vendorId: {
1394
- key: "vendor_product_id",
1395
- required: true,
1396
- type: "string"
1397
- },
1398
- adaptyId: {
1399
- key: "adapty_product_id",
1400
- required: true,
1401
- type: "string"
1402
- },
1403
- accessLevelId: {
1404
- key: "access_level_id",
1405
- required: true,
1406
- type: "string"
1407
- },
1408
- productType: {
1409
- key: "product_type",
1410
- required: true,
1411
- type: "string"
1412
- },
1413
- ios: {
1414
- promotionalOfferId: {
1415
- key: "promotional_offer_id",
1416
- required: false,
1417
- type: "string"
1418
- },
1419
- winBackOfferId: {
1420
- key: "win_back_offer_id",
1421
- required: false,
1422
- type: "string"
1423
- }
1424
- },
1425
- android: {
1426
- basePlanId: {
1427
- key: "base_plan_id",
1428
- required: false,
1429
- type: "string"
1430
- },
1431
- offerId: {
1432
- key: "offer_id",
1433
- required: false,
1434
- type: "string"
1435
- }
1436
- }
1437
- };
1438
- }
1439
- };
1440
-
1441
- //#endregion
1442
- //#region src/coders/adapty-paywall.ts
1443
- var AdaptyPaywallCoder = class extends Coder {
1444
- constructor(..._args) {
1445
- super(..._args);
1446
- this.properties = {
1447
- placement: {
1448
- key: "placement",
1449
- required: true,
1450
- type: "object",
1451
- converter: new AdaptyPlacementCoder()
1452
- },
1453
- id: {
1454
- key: "paywall_id",
1447
+ adaptyId: {
1448
+ key: "adapty_product_id",
1455
1449
  required: true,
1456
1450
  type: "string"
1457
1451
  },
1458
- name: {
1459
- key: "paywall_name",
1452
+ paywallProductIndex: {
1453
+ key: "paywall_product_index",
1454
+ required: true,
1455
+ type: "number"
1456
+ },
1457
+ localizedDescription: {
1458
+ key: "localized_description",
1460
1459
  required: true,
1461
1460
  type: "string"
1462
1461
  },
1463
- products: {
1464
- key: "products",
1462
+ localizedTitle: {
1463
+ key: "localized_title",
1465
1464
  required: true,
1466
- type: "array",
1467
- converter: new ArrayCoder(() => new ProductReferenceCoder())
1465
+ type: "string"
1468
1466
  },
1469
- remoteConfig: {
1470
- key: "remote_config",
1467
+ regionCode: {
1468
+ key: "region_code",
1471
1469
  required: false,
1472
- type: "object",
1473
- converter: new AdaptyRemoteConfigCoder()
1470
+ type: "string"
1474
1471
  },
1475
1472
  variationId: {
1476
- key: "variation_id",
1473
+ key: "paywall_variation_id",
1477
1474
  required: true,
1478
1475
  type: "string"
1479
1476
  },
1480
- version: {
1481
- key: "response_created_at",
1482
- required: false,
1483
- type: "number"
1477
+ paywallABTestName: {
1478
+ key: "paywall_ab_test_name",
1479
+ required: true,
1480
+ type: "string"
1484
1481
  },
1485
- paywallBuilder: {
1486
- key: "paywall_builder",
1482
+ paywallName: {
1483
+ key: "paywall_name",
1484
+ required: true,
1485
+ type: "string"
1486
+ },
1487
+ accessLevelId: {
1488
+ key: "access_level_id",
1489
+ required: true,
1490
+ type: "string"
1491
+ },
1492
+ productType: {
1493
+ key: "product_type",
1494
+ required: true,
1495
+ type: "string"
1496
+ },
1497
+ price: {
1498
+ key: "price",
1487
1499
  required: false,
1488
1500
  type: "object",
1489
- converter: new AdaptyPaywallBuilderCoder()
1501
+ converter: new AdaptyPriceCoder()
1490
1502
  },
1491
1503
  webPurchaseUrl: {
1492
1504
  key: "web_purchase_url",
@@ -1498,29 +1510,33 @@ var AdaptyPaywallCoder = class extends Coder {
1498
1510
  required: false,
1499
1511
  type: "string"
1500
1512
  },
1501
- requestLocale: {
1502
- key: "request_locale",
1513
+ subscription: {
1514
+ key: "subscription",
1515
+ required: false,
1516
+ type: "object",
1517
+ converter: new AdaptySubscriptionDetailsCoder()
1518
+ },
1519
+ ios: { isFamilyShareable: {
1520
+ key: "is_family_shareable",
1503
1521
  required: true,
1504
- type: "string"
1505
- }
1522
+ type: "boolean"
1523
+ } }
1506
1524
  };
1507
1525
  }
1508
- decode(data) {
1509
- const codablePart = super.decode(data);
1526
+ getInput(data) {
1510
1527
  return {
1511
- ...codablePart,
1512
- hasViewConfiguration: codablePart.paywallBuilder !== void 0,
1513
- productIdentifiers: codablePart.products.map((product) => ({
1514
- vendorProductId: product.vendorId,
1515
- adaptyProductId: product.adaptyId,
1516
- basePlanId: product.android?.basePlanId
1517
- }))
1528
+ adapty_product_id: data.adapty_product_id,
1529
+ access_level_id: data.access_level_id,
1530
+ product_type: data.product_type,
1531
+ paywall_product_index: data.paywall_product_index,
1532
+ paywall_ab_test_name: data.paywall_ab_test_name,
1533
+ payload_data: data.payload_data,
1534
+ paywall_name: data.paywall_name,
1535
+ paywall_variation_id: data.paywall_variation_id,
1536
+ subscription_offer_identifier: data.subscription?.offer?.offer_identifier,
1537
+ vendor_product_id: data.vendor_product_id
1518
1538
  };
1519
1539
  }
1520
- encode(data) {
1521
- const { hasViewConfiguration, productIdentifiers,...codablePart } = data;
1522
- return super.encode(codablePart);
1523
- }
1524
1540
  };
1525
1541
 
1526
1542
  //#endregion
@@ -1731,6 +1747,11 @@ var AdaptyProfileCoder = class extends SimpleCoder {
1731
1747
  type: "object",
1732
1748
  converter: new HashmapCoder(new AdaptyAccessLevelCoder())
1733
1749
  },
1750
+ appliedAttributionSources: {
1751
+ key: "applied_attribution_sources",
1752
+ required: false,
1753
+ type: "array"
1754
+ },
1734
1755
  customAttributes: {
1735
1756
  key: "custom_attributes",
1736
1757
  required: false,
@@ -1764,9 +1785,6 @@ var AdaptyProfileCoder = class extends SimpleCoder {
1764
1785
 
1765
1786
  //#endregion
1766
1787
  //#region src/coders/adapty-purchase-params.ts
1767
- function isDeprecatedType(data) {
1768
- return typeof data === "object" && data !== null && "android" in data && typeof data.android === "object" && data.android !== null && "oldSubVendorProductId" in data.android && "prorationMode" in data.android;
1769
- }
1770
1788
  var AdaptyPurchaseParamsCoder = class {
1771
1789
  constructor(platform) {
1772
1790
  this.platform = platform;
@@ -1774,16 +1792,6 @@ var AdaptyPurchaseParamsCoder = class {
1774
1792
  encode(data) {
1775
1793
  if (this.platform.OS !== "android") return {};
1776
1794
  const purchaseParams = {};
1777
- if (isDeprecatedType(data)) {
1778
- if (data.android) {
1779
- purchaseParams["subscription_update_params"] = {
1780
- replacement_mode: data.android.prorationMode,
1781
- old_sub_vendor_product_id: data.android.oldSubVendorProductId
1782
- };
1783
- if (data.android.isOfferPersonalized) purchaseParams["is_offer_personalized"] = data.android.isOfferPersonalized;
1784
- }
1785
- return purchaseParams;
1786
- }
1787
1795
  if (data.android) {
1788
1796
  if (data.android.subscriptionUpdateParams) purchaseParams["subscription_update_params"] = {
1789
1797
  replacement_mode: data.android.subscriptionUpdateParams.prorationMode,
@@ -1916,14 +1924,15 @@ const resolveAssetId = (asset, platformOS) => {
1916
1924
  };
1917
1925
 
1918
1926
  //#endregion
1919
- //#region src/coders/adapty-ui-create-paywall-view-params.ts
1920
- var AdaptyUICreatePaywallViewParamsCoder = class {
1927
+ //#region src/coders/adapty-ui-create-flow-view-params.ts
1928
+ var AdaptyUICreateFlowViewParamsCoder = class {
1921
1929
  constructor(platform) {
1922
1930
  this.platform = platform;
1923
1931
  }
1924
1932
  encode(data) {
1925
1933
  const result = {};
1926
1934
  if (data.prefetchProducts !== void 0) result.preload_products = data.prefetchProducts;
1935
+ if (data.android?.enableSafeArea !== void 0) result.enable_safe_area_paddings = data.android.enableSafeArea;
1927
1936
  if (data.loadTimeoutMs !== void 0) result.load_timeout = data.loadTimeoutMs / 1e3;
1928
1937
  if (data.customTags) result.custom_tags = data.customTags;
1929
1938
  if (data.customTimers) result.custom_timers = this.encodeCustomTimers(data.customTimers);
@@ -2258,11 +2267,11 @@ var CoderFactory = class {
2258
2267
  createOnboardingCoder() {
2259
2268
  return new AdaptyOnboardingCoder(this.deps.platform);
2260
2269
  }
2261
- createPaywallBuilderCoder() {
2262
- return new AdaptyPaywallBuilderCoder(this.deps.platform);
2270
+ createFlowCoder() {
2271
+ return new AdaptyFlowCoder(this.deps.platform);
2263
2272
  }
2264
- createPaywallCoder() {
2265
- return new AdaptyPaywallCoder(this.deps.platform);
2273
+ createFlowPaywallCoder() {
2274
+ return new AdaptyFlowPaywallCoder(this.deps.platform);
2266
2275
  }
2267
2276
  createPaywallProductCoder() {
2268
2277
  return new AdaptyPaywallProductCoder(this.deps.platform);
@@ -2303,8 +2312,8 @@ var CoderFactory = class {
2303
2312
  createUiCreateOnboardingViewParamsCoder() {
2304
2313
  return new AdaptyUICreateOnboardingViewParamsCoder();
2305
2314
  }
2306
- createUiCreatePaywallViewParamsCoder() {
2307
- return new AdaptyUICreatePaywallViewParamsCoder(this.deps.platform);
2315
+ createUiCreateFlowViewParamsCoder() {
2316
+ return new AdaptyUICreateFlowViewParamsCoder(this.deps.platform);
2308
2317
  }
2309
2318
  createUiDialogConfigCoder() {
2310
2319
  return new AdaptyUiDialogConfigCoder(this.deps.platform);
@@ -2384,21 +2393,26 @@ const RefundPreference = Object.freeze({
2384
2393
  });
2385
2394
 
2386
2395
  //#endregion
2387
- //#region src/types/paywall-events.ts
2388
- const PaywallEventId = {
2389
- DidAppear: "paywall_view_did_appear",
2390
- DidDisappear: "paywall_view_did_disappear",
2391
- DidPerformAction: "paywall_view_did_perform_action",
2392
- DidSelectProduct: "paywall_view_did_select_product",
2393
- DidStartPurchase: "paywall_view_did_start_purchase",
2394
- DidFinishPurchase: "paywall_view_did_finish_purchase",
2395
- DidFailPurchase: "paywall_view_did_fail_purchase",
2396
- DidStartRestore: "paywall_view_did_start_restore",
2397
- DidFinishRestore: "paywall_view_did_finish_restore",
2398
- DidFailRestore: "paywall_view_did_fail_restore",
2399
- DidFailRendering: "paywall_view_did_fail_rendering",
2400
- DidFailLoadingProducts: "paywall_view_did_fail_loading_products",
2401
- DidFinishWebPaymentNavigation: "paywall_view_did_finish_web_payment_navigation"
2396
+ //#region src/types/flow-events.ts
2397
+ const FlowEventId = {
2398
+ DidAppear: "flow_view_did_appear",
2399
+ DidDisappear: "flow_view_did_disappear",
2400
+ DidPerformAction: "flow_view_did_perform_action",
2401
+ DidSelectProduct: "flow_view_did_select_product",
2402
+ DidStartPurchase: "flow_view_did_start_purchase",
2403
+ DidFinishPurchase: "flow_view_did_finish_purchase",
2404
+ DidFailPurchase: "flow_view_did_fail_purchase",
2405
+ DidStartRestore: "flow_view_did_start_restore",
2406
+ DidFinishRestore: "flow_view_did_finish_restore",
2407
+ DidFailRestore: "flow_view_did_fail_restore",
2408
+ DidReceiveError: "flow_view_did_receive_error",
2409
+ DidFailLoadingProducts: "flow_view_did_fail_loading_products",
2410
+ DidFinishWebPaymentNavigation: "flow_view_did_finish_web_payment_navigation",
2411
+ DidRequestAppReview: "flow_view_did_request_app_review",
2412
+ DidReceiveAnalyticEvent: "flow_view_did_receive_analytic_event",
2413
+ DidAskPermission: "flow_view_did_ask_permission",
2414
+ ObserverDidInitiatePurchase: "flow_view_observer_did_initiate_purchase",
2415
+ ObserverDidInitiateRestore: "flow_view_observer_did_initiate_restore"
2402
2416
  };
2403
2417
 
2404
2418
  //#endregion
@@ -2414,13 +2428,13 @@ const OnboardingEventId = {
2414
2428
  };
2415
2429
 
2416
2430
  //#endregion
2417
- //#region src/ui-builder/paywall-event-mapping.ts
2431
+ //#region src/ui-builder/flow-event-mapping.ts
2418
2432
  /**
2419
2433
  * Resolves native event to handler name based on event data
2420
2434
  */
2421
- ({
2422
- [PaywallEventId.DidPerformAction]: (event) => {
2423
- if (event.id !== PaywallEventId.DidPerformAction) return null;
2435
+ const NATIVE_EVENT_RESOLVER$1 = {
2436
+ [FlowEventId.DidPerformAction]: (event) => {
2437
+ if (event.id !== FlowEventId.DidPerformAction) return null;
2424
2438
  const actionMap = {
2425
2439
  close: "onCloseButtonPress",
2426
2440
  system_back: "onAndroidSystemBack",
@@ -2429,41 +2443,76 @@ const OnboardingEventId = {
2429
2443
  };
2430
2444
  return actionMap[event.action.type] || null;
2431
2445
  },
2432
- [PaywallEventId.DidAppear]: () => "onPaywallShown",
2433
- [PaywallEventId.DidDisappear]: () => "onPaywallClosed",
2434
- [PaywallEventId.DidSelectProduct]: () => "onProductSelected",
2435
- [PaywallEventId.DidStartPurchase]: () => "onPurchaseStarted",
2436
- [PaywallEventId.DidFinishPurchase]: () => "onPurchaseCompleted",
2437
- [PaywallEventId.DidFailPurchase]: () => "onPurchaseFailed",
2438
- [PaywallEventId.DidStartRestore]: () => "onRestoreStarted",
2439
- [PaywallEventId.DidFinishRestore]: () => "onRestoreCompleted",
2440
- [PaywallEventId.DidFailRestore]: () => "onRestoreFailed",
2441
- [PaywallEventId.DidFailRendering]: () => "onRenderingFailed",
2442
- [PaywallEventId.DidFailLoadingProducts]: () => "onLoadingProductsFailed",
2443
- [PaywallEventId.DidFinishWebPaymentNavigation]: () => "onWebPaymentNavigationFinished"
2444
- });
2446
+ [FlowEventId.DidAppear]: () => "onAppeared",
2447
+ [FlowEventId.DidDisappear]: () => "onDisappeared",
2448
+ [FlowEventId.DidSelectProduct]: () => "onProductSelected",
2449
+ [FlowEventId.DidStartPurchase]: () => "onPurchaseStarted",
2450
+ [FlowEventId.DidFinishPurchase]: () => "onPurchaseCompleted",
2451
+ [FlowEventId.DidFailPurchase]: () => "onPurchaseFailed",
2452
+ [FlowEventId.DidStartRestore]: () => "onRestoreStarted",
2453
+ [FlowEventId.DidFinishRestore]: () => "onRestoreCompleted",
2454
+ [FlowEventId.DidFailRestore]: () => "onRestoreFailed",
2455
+ [FlowEventId.DidReceiveError]: () => "onError",
2456
+ [FlowEventId.DidFailLoadingProducts]: () => "onLoadingProductsFailed",
2457
+ [FlowEventId.DidFinishWebPaymentNavigation]: () => "onWebPaymentNavigationFinished",
2458
+ [FlowEventId.DidRequestAppReview]: () => "onRequestAppReview",
2459
+ [FlowEventId.DidReceiveAnalyticEvent]: () => "onAnalytics",
2460
+ [FlowEventId.DidAskPermission]: () => "onRequestPermission",
2461
+ [FlowEventId.ObserverDidInitiatePurchase]: () => "onObserverPurchaseInitiated",
2462
+ [FlowEventId.ObserverDidInitiateRestore]: () => "onObserverRestoreInitiated"
2463
+ };
2445
2464
  /**
2446
2465
  * Maps handler name to native event name
2447
2466
  * Used in addListener/addInternalListener to subscribe to correct native event
2448
2467
  */
2449
- ({
2450
- onCloseButtonPress: PaywallEventId.DidPerformAction,
2451
- onAndroidSystemBack: PaywallEventId.DidPerformAction,
2452
- onUrlPress: PaywallEventId.DidPerformAction,
2453
- onCustomAction: PaywallEventId.DidPerformAction,
2454
- onPaywallShown: PaywallEventId.DidAppear,
2455
- onPaywallClosed: PaywallEventId.DidDisappear,
2456
- onProductSelected: PaywallEventId.DidSelectProduct,
2457
- onPurchaseStarted: PaywallEventId.DidStartPurchase,
2458
- onPurchaseCompleted: PaywallEventId.DidFinishPurchase,
2459
- onPurchaseFailed: PaywallEventId.DidFailPurchase,
2460
- onRestoreStarted: PaywallEventId.DidStartRestore,
2461
- onRestoreCompleted: PaywallEventId.DidFinishRestore,
2462
- onRestoreFailed: PaywallEventId.DidFailRestore,
2463
- onRenderingFailed: PaywallEventId.DidFailRendering,
2464
- onLoadingProductsFailed: PaywallEventId.DidFailLoadingProducts,
2465
- onWebPaymentNavigationFinished: PaywallEventId.DidFinishWebPaymentNavigation
2466
- });
2468
+ const HANDLER_TO_NATIVE_EVENT$1 = {
2469
+ onCloseButtonPress: FlowEventId.DidPerformAction,
2470
+ onAndroidSystemBack: FlowEventId.DidPerformAction,
2471
+ onUrlPress: FlowEventId.DidPerformAction,
2472
+ onCustomAction: FlowEventId.DidPerformAction,
2473
+ onAppeared: FlowEventId.DidAppear,
2474
+ onDisappeared: FlowEventId.DidDisappear,
2475
+ onProductSelected: FlowEventId.DidSelectProduct,
2476
+ onPurchaseStarted: FlowEventId.DidStartPurchase,
2477
+ onPurchaseCompleted: FlowEventId.DidFinishPurchase,
2478
+ onPurchaseFailed: FlowEventId.DidFailPurchase,
2479
+ onRestoreStarted: FlowEventId.DidStartRestore,
2480
+ onRestoreCompleted: FlowEventId.DidFinishRestore,
2481
+ onRestoreFailed: FlowEventId.DidFailRestore,
2482
+ onError: FlowEventId.DidReceiveError,
2483
+ onLoadingProductsFailed: FlowEventId.DidFailLoadingProducts,
2484
+ onWebPaymentNavigationFinished: FlowEventId.DidFinishWebPaymentNavigation,
2485
+ onRequestAppReview: FlowEventId.DidRequestAppReview,
2486
+ onAnalytics: FlowEventId.DidReceiveAnalyticEvent,
2487
+ onRequestPermission: FlowEventId.DidAskPermission,
2488
+ onObserverPurchaseInitiated: FlowEventId.ObserverDidInitiatePurchase,
2489
+ onObserverRestoreInitiated: FlowEventId.ObserverDidInitiateRestore
2490
+ };
2491
+ function extractFlowCallbackArgs(handlerName, event) {
2492
+ switch (event.id) {
2493
+ case FlowEventId.DidSelectProduct: return [event.productId];
2494
+ case FlowEventId.DidStartPurchase: return [event.product];
2495
+ case FlowEventId.DidFinishPurchase: return [event.purchaseResult, event.product];
2496
+ case FlowEventId.DidFailPurchase: return [event.error, event.product];
2497
+ case FlowEventId.DidFinishRestore: return [event.profile];
2498
+ case FlowEventId.DidFailRestore:
2499
+ case FlowEventId.DidReceiveError:
2500
+ case FlowEventId.DidFailLoadingProducts: return [event.error];
2501
+ case FlowEventId.DidPerformAction:
2502
+ if (handlerName === "onUrlPress" && event.action.type === "open_url") return [event.action.value, event.action.openIn];
2503
+ if (handlerName === "onCustomAction" && event.action.type === "custom") return [event.action.value];
2504
+ return [];
2505
+ case FlowEventId.DidFinishWebPaymentNavigation: return [event.product, event.error];
2506
+ case FlowEventId.DidReceiveAnalyticEvent: return [event.name, event.params];
2507
+ case FlowEventId.DidAskPermission: return [event.permission, event.customArgs];
2508
+ case FlowEventId.ObserverDidInitiatePurchase:
2509
+ case FlowEventId.ObserverDidInitiateRestore: return [];
2510
+ case FlowEventId.DidRequestAppReview:
2511
+ case FlowEventId.DidAppear:
2512
+ case FlowEventId.DidDisappear:
2513
+ case FlowEventId.DidStartRestore: return [];
2514
+ }
2515
+ }
2467
2516
 
2468
2517
  //#endregion
2469
2518
  //#region src/ui-builder/onboarding-event-mapping.ts
@@ -2492,6 +2541,13 @@ Object.entries(HANDLER_TO_EVENT_CONFIG).reduce((acc, [handlerName, config]) => {
2492
2541
  return acc;
2493
2542
  }, {});
2494
2543
 
2544
+ //#endregion
2545
+ //#region src/ui-builder/types.ts
2546
+ const AdaptyUiDialogActionType = Object.freeze({
2547
+ primary: "primary",
2548
+ secondary: "secondary"
2549
+ });
2550
+
2495
2551
  //#endregion
2496
2552
  //#region src/coders/parse.ts
2497
2553
  function parseMethodResult$1(factory, input, resultType, ctx) {
@@ -2544,10 +2600,9 @@ function getCoder(factory, type, ctx) {
2544
2600
  switch (type) {
2545
2601
  case "AdaptyError": return factory.createNativeErrorCoder();
2546
2602
  case "AdaptyProfile": return factory.createProfileCoder();
2547
- case "AdaptyPaywall": return factory.createPaywallCoder();
2603
+ case "AdaptyFlow": return factory.createFlowCoder();
2548
2604
  case "AdaptyPaywallProduct": return factory.createPaywallProductCoder();
2549
2605
  case "AdaptyRemoteConfig": return factory.createRemoteConfigCoder();
2550
- case "AdaptyPaywallBuilder": return factory.createPaywallBuilderCoder();
2551
2606
  case "AdaptyOnboarding": return factory.createOnboardingCoder();
2552
2607
  case "AdaptyPurchaseResult": return factory.createPurchaseResultCoder();
2553
2608
  case "AdaptyInstallationStatus": return factory.createInstallationStatusCoder();
@@ -2563,8 +2618,8 @@ function getCoder(factory, type, ctx) {
2563
2618
  }
2564
2619
 
2565
2620
  //#endregion
2566
- //#region src/coders/parse-paywall.ts
2567
- function parsePaywallEvent$1(factory, input, ctx) {
2621
+ //#region src/coders/parse-flow.ts
2622
+ function parseFlowEvent$1(factory, input, ctx) {
2568
2623
  let obj;
2569
2624
  try {
2570
2625
  obj = JSON.parse(input);
@@ -2572,7 +2627,7 @@ function parsePaywallEvent$1(factory, input, ctx) {
2572
2627
  throw AdaptyError.failedToDecode(`Failed to decode event: ${error?.message}`);
2573
2628
  }
2574
2629
  const eventId = obj["id"];
2575
- if (!eventId?.startsWith("paywall_view_")) return null;
2630
+ if (!eventId?.startsWith("flow_view_")) return null;
2576
2631
  const viewObj = obj["view"];
2577
2632
  const view = {
2578
2633
  id: viewObj["id"],
@@ -2580,59 +2635,59 @@ function parsePaywallEvent$1(factory, input, ctx) {
2580
2635
  variationId: viewObj["variation_id"]
2581
2636
  };
2582
2637
  switch (eventId) {
2583
- case PaywallEventId.DidAppear: return {
2638
+ case FlowEventId.DidAppear: return {
2584
2639
  id: eventId,
2585
2640
  view
2586
2641
  };
2587
- case PaywallEventId.DidDisappear: return {
2642
+ case FlowEventId.DidDisappear: return {
2588
2643
  id: eventId,
2589
2644
  view
2590
2645
  };
2591
- case PaywallEventId.DidPerformAction: {
2646
+ case FlowEventId.DidPerformAction: {
2592
2647
  const actionObj = obj["action"];
2593
2648
  return {
2594
2649
  id: eventId,
2595
2650
  view,
2596
- action: parsePaywallUserAction(actionObj)
2651
+ action: parseFlowUserAction(actionObj)
2597
2652
  };
2598
2653
  }
2599
- case PaywallEventId.DidSelectProduct: return {
2654
+ case FlowEventId.DidSelectProduct: return {
2600
2655
  id: eventId,
2601
2656
  view,
2602
2657
  productId: obj["product_id"] ?? ""
2603
2658
  };
2604
- case PaywallEventId.DidStartPurchase: return {
2659
+ case FlowEventId.DidStartPurchase: return {
2605
2660
  id: eventId,
2606
2661
  view,
2607
- product: getPaywallCoder(factory, "product").decode(obj["product"])
2662
+ product: getFlowCoder(factory, "product").decode(obj["product"])
2608
2663
  };
2609
- case PaywallEventId.DidFinishPurchase: return {
2664
+ case FlowEventId.DidFinishPurchase: return {
2610
2665
  id: eventId,
2611
2666
  view,
2612
- purchaseResult: getPaywallCoder(factory, "purchaseResult").decode(obj["purchased_result"]),
2613
- product: getPaywallCoder(factory, "product").decode(obj["product"])
2667
+ purchaseResult: getFlowCoder(factory, "purchaseResult").decode(obj["purchased_result"]),
2668
+ product: getFlowCoder(factory, "product").decode(obj["product"])
2614
2669
  };
2615
- case PaywallEventId.DidFailPurchase: {
2616
- const errorCoder = getPaywallCoder(factory, "error");
2670
+ case FlowEventId.DidFailPurchase: {
2671
+ const errorCoder = getFlowCoder(factory, "error");
2617
2672
  const decodedError = errorCoder.decode(obj["error"]);
2618
2673
  return {
2619
2674
  id: eventId,
2620
2675
  view,
2621
2676
  error: errorCoder.getError(decodedError),
2622
- product: getPaywallCoder(factory, "product").decode(obj["product"])
2677
+ product: getFlowCoder(factory, "product").decode(obj["product"])
2623
2678
  };
2624
2679
  }
2625
- case PaywallEventId.DidStartRestore: return {
2680
+ case FlowEventId.DidStartRestore: return {
2626
2681
  id: eventId,
2627
2682
  view
2628
2683
  };
2629
- case PaywallEventId.DidFinishRestore: return {
2684
+ case FlowEventId.DidFinishRestore: return {
2630
2685
  id: eventId,
2631
2686
  view,
2632
- profile: getPaywallCoder(factory, "profile").decode(obj["profile"])
2687
+ profile: getFlowCoder(factory, "profile").decode(obj["profile"])
2633
2688
  };
2634
- case PaywallEventId.DidFailRestore: {
2635
- const errorCoder = getPaywallCoder(factory, "error");
2689
+ case FlowEventId.DidFailRestore: {
2690
+ const errorCoder = getFlowCoder(factory, "error");
2636
2691
  const decodedError = errorCoder.decode(obj["error"]);
2637
2692
  return {
2638
2693
  id: eventId,
@@ -2640,8 +2695,8 @@ function parsePaywallEvent$1(factory, input, ctx) {
2640
2695
  error: errorCoder.getError(decodedError)
2641
2696
  };
2642
2697
  }
2643
- case PaywallEventId.DidFailRendering: {
2644
- const errorCoder = getPaywallCoder(factory, "error");
2698
+ case FlowEventId.DidReceiveError: {
2699
+ const errorCoder = getFlowCoder(factory, "error");
2645
2700
  const decodedError = errorCoder.decode(obj["error"]);
2646
2701
  return {
2647
2702
  id: eventId,
@@ -2649,8 +2704,8 @@ function parsePaywallEvent$1(factory, input, ctx) {
2649
2704
  error: errorCoder.getError(decodedError)
2650
2705
  };
2651
2706
  }
2652
- case PaywallEventId.DidFailLoadingProducts: {
2653
- const errorCoder = getPaywallCoder(factory, "error");
2707
+ case FlowEventId.DidFailLoadingProducts: {
2708
+ const errorCoder = getFlowCoder(factory, "error");
2654
2709
  const decodedError = errorCoder.decode(obj["error"]);
2655
2710
  return {
2656
2711
  id: eventId,
@@ -2658,20 +2713,51 @@ function parsePaywallEvent$1(factory, input, ctx) {
2658
2713
  error: errorCoder.getError(decodedError)
2659
2714
  };
2660
2715
  }
2661
- case PaywallEventId.DidFinishWebPaymentNavigation: return {
2716
+ case FlowEventId.DidFinishWebPaymentNavigation: return {
2662
2717
  id: eventId,
2663
2718
  view,
2664
- product: obj["product"] ? getPaywallCoder(factory, "product").decode(obj["product"]) : void 0,
2719
+ product: obj["product"] ? getFlowCoder(factory, "product").decode(obj["product"]) : void 0,
2665
2720
  error: obj["error"] ? (() => {
2666
- const errorCoder = getPaywallCoder(factory, "error");
2721
+ const errorCoder = getFlowCoder(factory, "error");
2667
2722
  const decodedError = errorCoder.decode(obj["error"]);
2668
2723
  return errorCoder.getError(decodedError);
2669
2724
  })() : void 0
2670
2725
  };
2726
+ case FlowEventId.DidRequestAppReview: return {
2727
+ id: eventId,
2728
+ view
2729
+ };
2730
+ case FlowEventId.DidReceiveAnalyticEvent: {
2731
+ const params = obj["params"];
2732
+ return {
2733
+ id: eventId,
2734
+ view,
2735
+ name: typeof obj["name"] === "string" ? obj["name"] : "",
2736
+ params: typeof params === "object" && params !== null ? params : {}
2737
+ };
2738
+ }
2739
+ case FlowEventId.DidAskPermission: return {
2740
+ id: eventId,
2741
+ view,
2742
+ eventId: typeof obj["event_id"] === "string" ? obj["event_id"] : "",
2743
+ permission: typeof obj["permission"] === "string" ? obj["permission"] : "",
2744
+ customArgs: typeof obj["custom_args"] === "object" && obj["custom_args"] !== null ? obj["custom_args"] : {}
2745
+ };
2746
+ case FlowEventId.ObserverDidInitiatePurchase: return {
2747
+ id: eventId,
2748
+ view,
2749
+ eventId: typeof obj["event_id"] === "string" ? obj["event_id"] : "",
2750
+ product: getFlowCoder(factory, "product").decode(obj["product"])
2751
+ };
2752
+ case FlowEventId.ObserverDidInitiateRestore: return {
2753
+ id: eventId,
2754
+ view,
2755
+ eventId: typeof obj["event_id"] === "string" ? obj["event_id"] : ""
2756
+ };
2671
2757
  default: return null;
2672
2758
  }
2673
2759
  }
2674
- function parsePaywallUserAction(actionObj) {
2760
+ function parseFlowUserAction(actionObj) {
2675
2761
  const type = actionObj["type"];
2676
2762
  switch (type) {
2677
2763
  case "open_url": return {
@@ -2687,7 +2773,7 @@ function parsePaywallUserAction(actionObj) {
2687
2773
  case "system_back": return { type };
2688
2774
  }
2689
2775
  }
2690
- function getPaywallCoder(factory, type, _ctx) {
2776
+ function getFlowCoder(factory, type, _ctx) {
2691
2777
  switch (type) {
2692
2778
  case "product": return factory.createPaywallProductCoder();
2693
2779
  case "profile": return factory.createProfileCoder();
@@ -2879,7 +2965,7 @@ const AdaptyCapacitorPlugin = core.registerPlugin('AdaptyCapacitorPlugin', {
2879
2965
  web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.AdaptyCapacitorPluginWeb()),
2880
2966
  });
2881
2967
 
2882
- var VERSION = '3.17.0';
2968
+ var VERSION = '4.0.0-beta.1';
2883
2969
 
2884
2970
  /**
2885
2971
  * Capacitor implementation of IPlatformAdapter
@@ -3105,13 +3191,13 @@ class AdaptyEmitter {
3105
3191
  }
3106
3192
 
3107
3193
  const defaultAdaptyOptions = {
3108
- get_paywall: {
3194
+ get_flow: {
3109
3195
  params: {
3110
3196
  fetchPolicy: FetchPolicy.ReloadRevalidatingCacheData,
3111
3197
  loadTimeoutMs: 5000,
3112
3198
  },
3113
3199
  },
3114
- get_paywall_for_default_audience: {
3200
+ get_flow_for_default_audience: {
3115
3201
  params: {
3116
3202
  fetchPolicy: FetchPolicy.ReloadRevalidatingCacheData,
3117
3203
  },
@@ -3147,7 +3233,7 @@ class Adapty {
3147
3233
  this.nonWaitingMethods = [
3148
3234
  'activate',
3149
3235
  'is_activated',
3150
- 'get_paywall_for_default_audience',
3236
+ 'get_flow_for_default_audience',
3151
3237
  'get_onboarding_for_default_audience',
3152
3238
  'set_log_level',
3153
3239
  'set_fallback',
@@ -3265,8 +3351,6 @@ class Adapty {
3265
3351
  * so background activities can be performed and cache can be updated.
3266
3352
  *
3267
3353
  * @example
3268
- *
3269
- * @example
3270
3354
  * Usage with your user identifier from your system
3271
3355
  * ```typescript
3272
3356
  * await adapty.activate({
@@ -3399,39 +3483,37 @@ class Adapty {
3399
3483
  return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyInstallationStatus');
3400
3484
  }
3401
3485
  /**
3402
- * Fetches the paywall by the specified placement.
3486
+ * Fetches the flow by the specified placement.
3403
3487
  *
3404
3488
  * @remarks
3405
3489
  * With Adapty, you can remotely configure the products and offers in your app
3406
- * by simply adding them to paywalls – no need for hardcoding them.
3490
+ * by simply adding them to flows – no need for hardcoding them.
3407
3491
  * The only thing you hardcode is the placement ID.
3408
- * This flexibility allows you to easily update paywalls, products, and offers,
3492
+ * This flexibility allows you to easily update flows, products, and offers,
3409
3493
  * or run A/B tests, all without the need for a new app release.
3410
3494
  *
3411
- * @param options - The options for fetching the paywall
3495
+ * @param options - The options for fetching the flow
3412
3496
  * @param options.placementId - The identifier of the desired placement. This is the value you specified when creating a placement in the Adapty Dashboard.
3413
- * @param options.locale - Optional. The identifier of the paywall localization. Default: `'en'`. See {@link https://docs.adapty.io/docs/localizations-and-locale-codes | Localizations and locale codes} for more information.
3414
- * @param options.params - Optional. Additional parameters for fetching the paywall, including fetch policy and load timeout.
3415
- * @returns A promise that resolves with the requested {@link AdaptyPaywall}.
3416
- * @throws Error if the paywall with the specified ID is not found or if your bundle ID does not match with your Adapty Dashboard setup.
3497
+ * @param options.params - Optional. Additional parameters for fetching the flow, including fetch policy and load timeout.
3498
+ * @returns A promise that resolves with the requested {@link AdaptyFlow}.
3499
+ * @throws Error if the flow with the specified ID is not found or if your bundle ID does not match with your Adapty Dashboard setup.
3417
3500
  *
3418
3501
  * @example
3419
3502
  * ```typescript
3420
3503
  * import { adapty } from '@adapty/capacitor';
3421
3504
  *
3422
3505
  * try {
3423
- * const paywall = await adapty.getPaywall({
3506
+ * const flow = await adapty.getFlow({
3424
3507
  * placementId: 'YOUR_PLACEMENT_ID',
3425
- * locale: 'en',
3426
3508
  * });
3427
- * console.log('Paywall fetched successfully');
3509
+ * console.log('Flow fetched successfully');
3428
3510
  * } catch (error) {
3429
- * console.error('Failed to fetch paywall:', error);
3511
+ * console.error('Failed to fetch flow:', error);
3430
3512
  * }
3431
3513
  * ```
3432
3514
  */
3433
- async getPaywall(options) {
3434
- const method = 'get_paywall';
3515
+ async getFlow(options) {
3516
+ const method = 'get_flow';
3435
3517
  const optionsWithDefault = mergeOptions(options, this.options[method]);
3436
3518
  const params = optionsWithDefault.params;
3437
3519
  const ctx = new LogContext();
@@ -3441,54 +3523,51 @@ class Adapty {
3441
3523
  method,
3442
3524
  placement_id: optionsWithDefault.placementId,
3443
3525
  load_timeout: params.loadTimeoutMs / 1000,
3444
- locale: optionsWithDefault.locale,
3445
3526
  fetch_policy: params.fetchPolicy === 'return_cache_data_if_not_expired_else_load'
3446
3527
  ? { type: params.fetchPolicy, max_age: params.maxAgeSeconds }
3447
3528
  : { type: params.fetchPolicy },
3448
3529
  };
3449
3530
  const args = filterUndefined(argsWithUndefined);
3450
- return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyPaywall');
3531
+ return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyFlow');
3451
3532
  }
3452
3533
  /**
3453
- * Fetches the paywall of the specified placement for the **All Users** audience.
3534
+ * Fetches the flow of the specified placement for the **All Users** audience.
3454
3535
  *
3455
3536
  * @remarks
3456
3537
  * With Adapty, you can remotely configure the products and offers in your app
3457
- * by simply adding them to paywalls – no need for hardcoding them.
3538
+ * by simply adding them to flows – no need for hardcoding them.
3458
3539
  * The only thing you hardcode is the placement ID.
3459
3540
  *
3460
- * However, it's crucial to understand that the recommended approach is to fetch the paywall
3461
- * through the placement ID by the {@link getPaywall} method.
3462
- * The `getPaywallForDefaultAudience` method should be a last resort due to its significant drawbacks:
3541
+ * However, it's crucial to understand that the recommended approach is to fetch the flow
3542
+ * through the placement ID by the {@link getFlow} method.
3543
+ * The `getFlowForDefaultAudience` method should be a last resort due to its significant drawbacks:
3463
3544
  * - Potential backward compatibility issues
3464
- * - Loss of targeting (all users see the same paywall)
3545
+ * - Loss of targeting (all users see the same flow)
3465
3546
  *
3466
3547
  * See {@link https://docs.adapty.io/docs/capacitor-get-pb-paywalls#get-a-paywall-for-a-default-audience-to-fetch-it-faster | documentation} for more details.
3467
3548
  *
3468
- * @param options - The options for fetching the paywall
3549
+ * @param options - The options for fetching the flow
3469
3550
  * @param options.placementId - The identifier of the desired placement.
3470
- * @param options.locale - Optional. The identifier of the paywall localization. Default: `'en'`.
3471
- * @param options.params - Optional. Additional parameters for fetching the paywall.
3472
- * @returns A promise that resolves with the requested {@link AdaptyPaywall}.
3473
- * @throws Error if the paywall with the specified ID is not found.
3551
+ * @param options.params - Optional. Additional parameters for fetching the flow.
3552
+ * @returns A promise that resolves with the requested {@link AdaptyFlow}.
3553
+ * @throws Error if the flow with the specified ID is not found.
3474
3554
  *
3475
3555
  * @example
3476
3556
  * ```typescript
3477
3557
  * import { adapty } from '@adapty/capacitor';
3478
3558
  *
3479
3559
  * try {
3480
- * const paywall = await adapty.getPaywallForDefaultAudience({
3560
+ * const flow = await adapty.getFlowForDefaultAudience({
3481
3561
  * placementId: 'YOUR_PLACEMENT_ID',
3482
- * locale: 'en',
3483
3562
  * });
3484
3563
  * } catch (error) {
3485
- * console.error('Failed to fetch paywall:', error);
3564
+ * console.error('Failed to fetch flow:', error);
3486
3565
  * }
3487
3566
  * ```
3488
3567
  */
3489
- async getPaywallForDefaultAudience(options) {
3568
+ async getFlowForDefaultAudience(options) {
3490
3569
  var _a;
3491
- const method = 'get_paywall_for_default_audience';
3570
+ const method = 'get_flow_for_default_audience';
3492
3571
  const optionsWithDefault = mergeOptions(options, this.options[method]);
3493
3572
  const params = optionsWithDefault.params;
3494
3573
  const ctx = new LogContext();
@@ -3497,20 +3576,19 @@ class Adapty {
3497
3576
  const argsWithUndefined = {
3498
3577
  method,
3499
3578
  placement_id: optionsWithDefault.placementId,
3500
- locale: optionsWithDefault.locale,
3501
3579
  fetch_policy: params.fetchPolicy === 'return_cache_data_if_not_expired_else_load'
3502
3580
  ? { type: params.fetchPolicy, max_age: params.maxAgeSeconds }
3503
3581
  : { type: (_a = params.fetchPolicy) !== null && _a !== void 0 ? _a : 'reload_revalidating_cache_data' },
3504
3582
  };
3505
3583
  const args = filterUndefined(argsWithUndefined);
3506
- return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyPaywall');
3584
+ return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyFlow');
3507
3585
  }
3508
3586
  /**
3509
- * Fetches a list of products associated with a provided paywall.
3587
+ * Fetches a list of products associated with a provided flow.
3510
3588
  *
3511
3589
  * @param options - The options object
3512
- * @param options.paywall - A paywall to fetch products for. You can get it using {@link getPaywall} method.
3513
- * @returns A promise that resolves with a list of {@link AdaptyPaywallProduct} associated with a provided paywall.
3590
+ * @param options.flow - A flow to fetch products for. You can get it using {@link getFlow} method.
3591
+ * @returns A promise that resolves with a list of {@link AdaptyPaywallProduct} associated with a provided flow.
3514
3592
  * @throws Error if an error occurs while fetching products.
3515
3593
  *
3516
3594
  * @example
@@ -3518,8 +3596,8 @@ class Adapty {
3518
3596
  * import { adapty } from '@adapty/capacitor';
3519
3597
  *
3520
3598
  * try {
3521
- * const paywall = await adapty.getPaywall({ placementId: 'YOUR_PLACEMENT_ID' });
3522
- * const products = await adapty.getPaywallProducts({ paywall });
3599
+ * const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
3600
+ * const products = await adapty.getPaywallProducts({ flow });
3523
3601
  * console.log('Products:', products);
3524
3602
  * } catch (error) {
3525
3603
  * console.error('Failed to fetch products:', error);
@@ -3531,10 +3609,10 @@ class Adapty {
3531
3609
  const ctx = new LogContext();
3532
3610
  const log = ctx.call({ methodName: method });
3533
3611
  log.start(() => ({ options }));
3534
- const paywallCoder = coderFactory.createPaywallCoder();
3612
+ const coder = coderFactory.createFlowCoder();
3535
3613
  const argsWithUndefined = {
3536
3614
  method,
3537
- paywall: this.encodeWithLogging(paywallCoder, options.paywall, 'AdaptyPaywall', ctx),
3615
+ flow: this.encodeWithLogging(coder, options.flow, 'AdaptyFlow', ctx),
3538
3616
  };
3539
3617
  const args = filterUndefined(argsWithUndefined);
3540
3618
  return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'Array<AdaptyPaywallProduct>');
@@ -3542,6 +3620,8 @@ class Adapty {
3542
3620
  /**
3543
3621
  * Fetches the onboarding by the specified placement.
3544
3622
  *
3623
+ * @deprecated Since 4.0.0. Migrate onboardings to the Flow Builder API.
3624
+ *
3545
3625
  * @remarks
3546
3626
  * When you create an onboarding with the no-code builder, it's stored as a container with configuration
3547
3627
  * that your app needs to fetch and display. This container manages the entire experience - what content appears,
@@ -3595,6 +3675,8 @@ class Adapty {
3595
3675
  /**
3596
3676
  * Fetches the onboarding of the specified placement for the **All Users** audience.
3597
3677
  *
3678
+ * @deprecated Since 4.0.0. Migrate onboardings to the Flow Builder API.
3679
+ *
3598
3680
  * @remarks
3599
3681
  * It's crucial to understand that the recommended approach is to fetch the onboarding
3600
3682
  * by the {@link getOnboarding} method. The `getOnboardingForDefaultAudience` method
@@ -3728,19 +3810,19 @@ class Adapty {
3728
3810
  await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
3729
3811
  }
3730
3812
  /**
3731
- * Logs a paywall view event.
3813
+ * Logs a flow view event.
3732
3814
  *
3733
3815
  * @remarks
3734
- * Adapty helps you to measure the performance of the paywalls.
3735
- * We automatically collect all the metrics related to purchases except for custom paywall views.
3736
- * This is because only you know when the paywall was shown to a customer.
3816
+ * Adapty helps you to measure the performance of the flows.
3817
+ * We automatically collect all the metrics related to purchases except for custom flow views.
3818
+ * This is because only you know when the flow was shown to a customer.
3737
3819
  *
3738
- * Whenever you show a paywall to your user,
3820
+ * Whenever you show a flow to your user,
3739
3821
  * call this function to log the event,
3740
- * and it will be accumulated in the paywall metrics.
3822
+ * and it will be accumulated in the flow metrics.
3741
3823
  *
3742
3824
  * @param options - The options object
3743
- * @param options.paywall - The paywall object that was shown to the user.
3825
+ * @param options.flow - The flow object that was shown to the user.
3744
3826
  * @returns A promise that resolves when the event is logged.
3745
3827
  * @throws Error if an error occurs while logging the event.
3746
3828
  *
@@ -3748,20 +3830,20 @@ class Adapty {
3748
3830
  * ```typescript
3749
3831
  * import { adapty } from '@adapty/capacitor';
3750
3832
  *
3751
- * const paywall = await adapty.getPaywall({ placementId: 'YOUR_PLACEMENT_ID' });
3752
- * // ...after opening the paywall
3753
- * await adapty.logShowPaywall({ paywall });
3833
+ * const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
3834
+ * // ...after opening the flow
3835
+ * await adapty.logShowFlow({ flow });
3754
3836
  * ```
3755
3837
  */
3756
- async logShowPaywall(options) {
3757
- const method = 'log_show_paywall';
3838
+ async logShowFlow(options) {
3839
+ const method = 'log_show_flow';
3758
3840
  const ctx = new LogContext();
3759
3841
  const log = ctx.call({ methodName: method });
3760
3842
  log.start(() => ({ options }));
3761
- const paywallCoder = coderFactory.createPaywallCoder();
3843
+ const coder = coderFactory.createFlowCoder();
3762
3844
  const argsWithUndefined = {
3763
3845
  method,
3764
- paywall: this.encodeWithLogging(paywallCoder, options.paywall, 'AdaptyPaywall', ctx),
3846
+ flow: this.encodeWithLogging(coder, options.flow, 'AdaptyFlow', ctx),
3765
3847
  };
3766
3848
  const args = filterUndefined(argsWithUndefined);
3767
3849
  await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
@@ -3770,7 +3852,8 @@ class Adapty {
3770
3852
  * Opens a web paywall in the default browser.
3771
3853
  *
3772
3854
  * @param options - The options object
3773
- * @param options.paywallOrProduct - The paywall or product to open as a web paywall.
3855
+ * @param options.paywallOrProduct - The flow paywall or product to open as a web paywall.
3856
+ * @param options.openIn - Optional. Where to open the web paywall ({@link WebPresentation}).
3774
3857
  * @returns A promise that resolves when the web paywall is opened.
3775
3858
  * @throws Error if an error occurs while opening the web paywall.
3776
3859
  *
@@ -3779,8 +3862,8 @@ class Adapty {
3779
3862
  * import { adapty } from '@adapty/capacitor';
3780
3863
  *
3781
3864
  * try {
3782
- * const paywall = await adapty.getPaywall({ placementId: 'YOUR_PLACEMENT_ID' });
3783
- * await adapty.openWebPaywall({ paywallOrProduct: paywall });
3865
+ * const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
3866
+ * await adapty.openWebPaywall({ paywallOrProduct: flow.paywalls[0] });
3784
3867
  * } catch (error) {
3785
3868
  * console.error('Failed to open web paywall:', error);
3786
3869
  * }
@@ -3791,11 +3874,11 @@ class Adapty {
3791
3874
  const ctx = new LogContext();
3792
3875
  const log = ctx.call({ methodName: method });
3793
3876
  log.start(() => ({ options }));
3794
- const paywallCoder = coderFactory.createPaywallCoder();
3877
+ const flowPaywallCoder = coderFactory.createFlowPaywallCoder();
3795
3878
  const productCoder = coderFactory.createPaywallProductCoder();
3796
3879
  const argsWithUndefined = Object.assign(Object.assign({ method }, (this.isPaywallProduct(options.paywallOrProduct)
3797
3880
  ? { product: this.encodeWithLogging(productCoder, options.paywallOrProduct, 'AdaptyPaywallProduct', ctx) }
3798
- : { paywall: this.encodeWithLogging(paywallCoder, options.paywallOrProduct, 'AdaptyPaywall', ctx) })), (options.openIn ? { open_in: options.openIn } : {}));
3881
+ : { paywall: this.encodeWithLogging(flowPaywallCoder, options.paywallOrProduct, 'AdaptyFlowPaywall', ctx) })), (options.openIn ? { open_in: options.openIn } : {}));
3799
3882
  const args = filterUndefined(argsWithUndefined);
3800
3883
  await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
3801
3884
  }
@@ -3807,7 +3890,7 @@ class Adapty {
3807
3890
  * You can use this URL in a custom web view or a browser.
3808
3891
  *
3809
3892
  * @param options - The options object
3810
- * @param options.paywallOrProduct - The paywall or product to create a URL for.
3893
+ * @param options.paywallOrProduct - The flow paywall or product to create a URL for.
3811
3894
  * @returns A promise that resolves with the web paywall URL.
3812
3895
  * @throws Error if an error occurs while creating the URL.
3813
3896
  *
@@ -3816,8 +3899,8 @@ class Adapty {
3816
3899
  * import { adapty } from '@adapty/capacitor';
3817
3900
  *
3818
3901
  * try {
3819
- * const paywall = await adapty.getPaywall({ placementId: 'YOUR_PLACEMENT_ID' });
3820
- * const url = await adapty.createWebPaywallUrl({ paywallOrProduct: paywall });
3902
+ * const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
3903
+ * const url = await adapty.createWebPaywallUrl({ paywallOrProduct: flow.paywalls[0] });
3821
3904
  * console.log('Web paywall URL:', url);
3822
3905
  * } catch (error) {
3823
3906
  * console.error('Failed to create web paywall URL:', error);
@@ -3829,14 +3912,80 @@ class Adapty {
3829
3912
  const ctx = new LogContext();
3830
3913
  const log = ctx.call({ methodName: method });
3831
3914
  log.start(() => ({ options }));
3832
- const paywallCoder = coderFactory.createPaywallCoder();
3915
+ const flowPaywallCoder = coderFactory.createFlowPaywallCoder();
3833
3916
  const productCoder = coderFactory.createPaywallProductCoder();
3834
3917
  const argsWithUndefined = Object.assign({ method }, (this.isPaywallProduct(options.paywallOrProduct)
3835
3918
  ? { product: this.encodeWithLogging(productCoder, options.paywallOrProduct, 'AdaptyPaywallProduct', ctx) }
3836
- : { paywall: this.encodeWithLogging(paywallCoder, options.paywallOrProduct, 'AdaptyPaywall', ctx) }));
3919
+ : { paywall: this.encodeWithLogging(flowPaywallCoder, options.paywallOrProduct, 'AdaptyFlowPaywall', ctx) }));
3837
3920
  const args = filterUndefined(argsWithUndefined);
3838
3921
  return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'String');
3839
3922
  }
3923
+ /**
3924
+ * Opens a URL using the native browser.
3925
+ *
3926
+ * @remarks
3927
+ * Backs the default `onUrlPress` flow handler. Call it directly from a custom
3928
+ * `onUrlPress` handler when you want to run your own logic but keep the native
3929
+ * open-URL behavior. `openIn`: `browser_out_app` → external browser,
3930
+ * `browser_in_app` → in-app browser.
3931
+ *
3932
+ * @param options - The options object
3933
+ * @param options.url - The URL to open.
3934
+ * @param options.openIn - Optional. How to present the URL ({@link WebPresentation}). When omitted, the native SDK decides.
3935
+ * @returns A promise that resolves when the URL is opened.
3936
+ * @throws Error if an error occurs while opening the URL.
3937
+ *
3938
+ * @example
3939
+ * ```typescript
3940
+ * import { adapty } from '@adapty/capacitor';
3941
+ *
3942
+ * try {
3943
+ * await adapty.openWebUrl({ url: 'https://example.com' });
3944
+ * } catch (error) {
3945
+ * console.error('Failed to open URL:', error);
3946
+ * }
3947
+ * ```
3948
+ */
3949
+ async openWebUrl(options) {
3950
+ const method = 'adapty_ui_open_url';
3951
+ const ctx = new LogContext();
3952
+ const log = ctx.call({ methodName: method });
3953
+ log.start(() => ({ options }));
3954
+ const argsWithUndefined = Object.assign({ method, url: options.url }, (options.openIn ? { open_in: options.openIn } : {}));
3955
+ const args = filterUndefined(argsWithUndefined);
3956
+ await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
3957
+ }
3958
+ /**
3959
+ * Requests the native app-review prompt.
3960
+ *
3961
+ * @remarks
3962
+ * Uses `SKStoreReviewController` on iOS and In-App Review on Android. Backs the
3963
+ * default `onRequestAppReview` flow handler. Call it directly from a custom
3964
+ * `onRequestAppReview` handler when you want to run your own logic but keep the
3965
+ * native prompt.
3966
+ *
3967
+ * @returns A promise that resolves when the native call completes.
3968
+ * @throws Error if an error occurs while requesting the app review.
3969
+ *
3970
+ * @example
3971
+ * ```typescript
3972
+ * import { adapty } from '@adapty/capacitor';
3973
+ *
3974
+ * try {
3975
+ * await adapty.requestAppReview();
3976
+ * } catch (error) {
3977
+ * console.error('Failed to request app review:', error);
3978
+ * }
3979
+ * ```
3980
+ */
3981
+ async requestAppReview() {
3982
+ const method = 'adapty_ui_request_app_review';
3983
+ const ctx = new LogContext();
3984
+ const log = ctx.call({ methodName: method });
3985
+ log.start(() => ({}));
3986
+ const args = { method };
3987
+ await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
3988
+ }
3840
3989
  /**
3841
3990
  * Logs out the current user.
3842
3991
  *
@@ -3963,7 +4112,7 @@ class Adapty {
3963
4112
  *
3964
4113
  * @param options - The options object
3965
4114
  * @param options.transactionId - The transaction ID of the purchase.
3966
- * @param options.variationId - Optional. The variation ID from the {@link AdaptyPaywall}.
4115
+ * @param options.variationId - Optional. The variation ID from the {@link AdaptyFlow}.
3967
4116
  * @returns A promise that resolves when the transaction is reported.
3968
4117
  * @throws Error if an error occurs while reporting the transaction.
3969
4118
  *
@@ -4398,7 +4547,14 @@ class Adapty {
4398
4547
  }
4399
4548
  }
4400
4549
 
4401
- const parsePaywallEvent = (input, ctx) => parsePaywallEvent$1(coderFactory, input);
4550
+ /**
4551
+ * The shared Adapty singleton. Extracted into its own module so UI default
4552
+ * handlers can delegate to native handler methods (openWebUrl / requestAppReview)
4553
+ * without importing the package entry point and creating an import cycle.
4554
+ */
4555
+ const adapty = new Adapty();
4556
+
4557
+ const parseFlowEvent = (input, ctx) => parseFlowEvent$1(coderFactory, input);
4402
4558
 
4403
4559
  /**
4404
4560
  * Base class for view event emitters that manages common event handling logic.
@@ -4411,6 +4567,14 @@ class BaseViewEmitter {
4411
4567
  this.internalHandlers = new Map();
4412
4568
  this.viewId = viewId;
4413
4569
  }
4570
+ /**
4571
+ * Hook for subclasses to fully handle an event themselves (e.g. async
4572
+ * request/response round-trips). Return true to skip the standard
4573
+ * "call handler → maybe close view" dispatch for this event.
4574
+ */
4575
+ handleSpecialEvent(_handlerName, _eventData) {
4576
+ return false;
4577
+ }
4414
4578
  async addListener(event, callback, onRequestClose) {
4415
4579
  const nativeEvent = this.getNativeEventForHandler(event);
4416
4580
  if (!nativeEvent) {
@@ -4479,6 +4643,10 @@ class BaseViewEmitter {
4479
4643
  if (!handlerName) {
4480
4644
  return;
4481
4645
  }
4646
+ if (this.handleSpecialEvent(handlerName, eventData)) {
4647
+ log.success(() => ({ message: 'Special event handled', handlerName }));
4648
+ return;
4649
+ }
4482
4650
  // 1. Client handler (single)
4483
4651
  const handlerData = this.handlers.get(handlerName);
4484
4652
  if (handlerData) {
@@ -4526,14 +4694,25 @@ class BaseViewEmitter {
4526
4694
  }
4527
4695
 
4528
4696
  /**
4529
- * PaywallViewEmitter manages event handlers for paywall view events.
4697
+ * FlowViewEmitter manages event handlers for flow view events.
4530
4698
  * Each event type can have only one handler - new handlers replace existing ones.
4699
+ *
4700
+ * In addition to the standard synchronous dispatch inherited from
4701
+ * {@link BaseViewEmitter}, this emitter handles three asynchronous round-trip
4702
+ * events that must reply back to native:
4703
+ * - `onRequestPermission` — awaits the async handler, then replies with the status.
4704
+ * - `onObserverPurchaseInitiated` — injects start/finish callbacks (observer mode).
4705
+ * - `onObserverRestoreInitiated` — injects start/finish callbacks (observer mode).
4531
4706
  */
4532
- class PaywallViewEmitter extends BaseViewEmitter {
4707
+ class FlowViewEmitter extends BaseViewEmitter {
4708
+ constructor(viewId, adapty) {
4709
+ super(viewId);
4710
+ this.adapty = adapty;
4711
+ }
4533
4712
  parseEventData(rawEventData, ctx) {
4534
- const result = parsePaywallEvent(rawEventData);
4713
+ const result = parseFlowEvent(rawEventData);
4535
4714
  if (!result) {
4536
- throw new Error('Failed to parse paywall event');
4715
+ throw new Error('Failed to parse flow event');
4537
4716
  }
4538
4717
  return result;
4539
4718
  }
@@ -4541,135 +4720,192 @@ class PaywallViewEmitter extends BaseViewEmitter {
4541
4720
  return HANDLER_TO_NATIVE_EVENT$1[event];
4542
4721
  }
4543
4722
  getHandlerForNativeEvent(nativeEvent, eventData) {
4544
- const resolver = NATIVE_EVENT_RESOLVER$1[nativeEvent];
4545
- if (!resolver) {
4546
- return null;
4547
- }
4548
- return resolver(eventData);
4723
+ var _a, _b;
4724
+ return (_b = (_a = NATIVE_EVENT_RESOLVER$1[nativeEvent]) === null || _a === void 0 ? void 0 : _a.call(NATIVE_EVENT_RESOLVER$1, eventData)) !== null && _b !== void 0 ? _b : null;
4549
4725
  }
4550
4726
  extractCallbackArgs(handlerName, eventData) {
4551
- return extractCallbackArgs$1(handlerName, eventData);
4727
+ return extractFlowCallbackArgs(handlerName, eventData);
4552
4728
  }
4553
4729
  getEventViewId(eventData) {
4554
4730
  var _a, _b;
4555
4731
  return (_b = (_a = eventData === null || eventData === void 0 ? void 0 : eventData.view) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null;
4556
4732
  }
4557
4733
  getEmitterName() {
4558
- return 'PaywallViewEmitter';
4734
+ return 'FlowViewEmitter';
4559
4735
  }
4560
- }
4561
- const NATIVE_EVENT_RESOLVER$1 = {
4562
- [PaywallEventId.DidPerformAction]: (event) => {
4563
- var _a;
4564
- if (event.id !== PaywallEventId.DidPerformAction) {
4565
- return null;
4736
+ /**
4737
+ * Routes the three asynchronous round-trip events to their dedicated
4738
+ * handlers, bypassing the standard synchronous boolean/close dispatch.
4739
+ */
4740
+ handleSpecialEvent(handlerName, eventData) {
4741
+ if (handlerName === 'onRequestPermission' && eventData.id === FlowEventId.DidAskPermission) {
4742
+ void this.handlePermissionRequest(eventData);
4743
+ return true;
4744
+ }
4745
+ if (handlerName === 'onObserverPurchaseInitiated' && eventData.id === FlowEventId.ObserverDidInitiatePurchase) {
4746
+ this.handleObserverPurchase(eventData);
4747
+ return true;
4748
+ }
4749
+ if (handlerName === 'onObserverRestoreInitiated' && eventData.id === FlowEventId.ObserverDidInitiateRestore) {
4750
+ this.handleObserverRestore(eventData);
4751
+ return true;
4752
+ }
4753
+ return false;
4754
+ }
4755
+ /**
4756
+ * Permission is an async round-trip: await the client handler, then reply to
4757
+ * native with the resulting status (defaults to `denied` on error/no handler).
4758
+ */
4759
+ async handlePermissionRequest(event) {
4760
+ const handlerData = this.handlers.get('onRequestPermission');
4761
+ let status = 'denied';
4762
+ let detail;
4763
+ if (handlerData) {
4764
+ try {
4765
+ const handler = handlerData.handler;
4766
+ const response = await handler(event.permission, event.customArgs);
4767
+ status = response.status;
4768
+ detail = response.detail;
4769
+ }
4770
+ catch (error) {
4771
+ status = 'denied';
4772
+ Log.warn('flow_view_did_answer_permission', () => `onRequestPermission handler threw; replying denied: ${error}`);
4773
+ }
4566
4774
  }
4567
- const actionMap = {
4568
- close: 'onCloseButtonPress',
4569
- system_back: 'onAndroidSystemBack',
4570
- open_url: 'onUrlPress',
4571
- custom: 'onCustomAction',
4775
+ const method = 'flow_view_did_answer_permission';
4776
+ const ctx = new LogContext();
4777
+ const log = ctx.call({ methodName: method });
4778
+ const body = JSON.stringify(filterUndefined({
4779
+ method,
4780
+ event_id: event.eventId,
4781
+ status,
4782
+ detail,
4783
+ }));
4784
+ await this.adapty
4785
+ .handleMethodCall(method, body, ctx, log)
4786
+ .catch((error) => Log.warn(method, () => `Failed to reply to permission request: ${error}`));
4787
+ }
4788
+ // Pass a fully-typed request object into `send` so each literal is checked
4789
+ // against its own `Req[...]` arm (a `satisfies` on a method-union body cannot
4790
+ // narrow, so we type per-call instead).
4791
+ handleObserverPurchase(event) {
4792
+ const handlerData = this.handlers.get('onObserverPurchaseInitiated');
4793
+ if (!handlerData)
4794
+ return;
4795
+ const { handler, onRequestClose } = handlerData;
4796
+ const send = (body) => {
4797
+ const ctx = new LogContext();
4798
+ const log = ctx.call({ methodName: body.method });
4799
+ void this.adapty
4800
+ .handleMethodCall(body.method, JSON.stringify(body), ctx, log)
4801
+ .catch((error) => Log.warn(body.method, () => `Failed observer purchase signal: ${error}`));
4572
4802
  };
4573
- return (_a = actionMap[event.action.type]) !== null && _a !== void 0 ? _a : null;
4574
- },
4575
- [PaywallEventId.DidAppear]: () => 'onAppeared',
4576
- [PaywallEventId.DidDisappear]: () => 'onDisappeared',
4577
- [PaywallEventId.DidSelectProduct]: () => 'onProductSelected',
4578
- [PaywallEventId.DidStartPurchase]: () => 'onPurchaseStarted',
4579
- [PaywallEventId.DidFinishPurchase]: () => 'onPurchaseCompleted',
4580
- [PaywallEventId.DidFailPurchase]: () => 'onPurchaseFailed',
4581
- [PaywallEventId.DidStartRestore]: () => 'onRestoreStarted',
4582
- [PaywallEventId.DidFinishRestore]: () => 'onRestoreCompleted',
4583
- [PaywallEventId.DidFailRestore]: () => 'onRestoreFailed',
4584
- [PaywallEventId.DidFailRendering]: () => 'onRenderingFailed',
4585
- [PaywallEventId.DidFailLoadingProducts]: () => 'onLoadingProductsFailed',
4586
- [PaywallEventId.DidFinishWebPaymentNavigation]: () => 'onWebPaymentNavigationFinished',
4587
- };
4588
- const HANDLER_TO_NATIVE_EVENT$1 = {
4589
- onCloseButtonPress: PaywallEventId.DidPerformAction,
4590
- onAndroidSystemBack: PaywallEventId.DidPerformAction,
4591
- onUrlPress: PaywallEventId.DidPerformAction,
4592
- onCustomAction: PaywallEventId.DidPerformAction,
4593
- onProductSelected: PaywallEventId.DidSelectProduct,
4594
- onPurchaseStarted: PaywallEventId.DidStartPurchase,
4595
- onPurchaseCompleted: PaywallEventId.DidFinishPurchase,
4596
- onPurchaseFailed: PaywallEventId.DidFailPurchase,
4597
- onRestoreStarted: PaywallEventId.DidStartRestore,
4598
- onRestoreCompleted: PaywallEventId.DidFinishRestore,
4599
- onRestoreFailed: PaywallEventId.DidFailRestore,
4600
- onAppeared: PaywallEventId.DidAppear,
4601
- onDisappeared: PaywallEventId.DidDisappear,
4602
- onRenderingFailed: PaywallEventId.DidFailRendering,
4603
- onLoadingProductsFailed: PaywallEventId.DidFailLoadingProducts,
4604
- onWebPaymentNavigationFinished: PaywallEventId.DidFinishWebPaymentNavigation,
4605
- };
4606
- function extractCallbackArgs$1(handlerName, event) {
4607
- switch (event.id) {
4608
- case PaywallEventId.DidSelectProduct:
4609
- return [event.productId];
4610
- case PaywallEventId.DidStartPurchase:
4611
- return [event.product];
4612
- case PaywallEventId.DidFinishPurchase:
4613
- return [event.purchaseResult, event.product];
4614
- case PaywallEventId.DidFailPurchase:
4615
- return [event.error, event.product];
4616
- case PaywallEventId.DidFinishRestore:
4617
- return [event.profile];
4618
- case PaywallEventId.DidFailRestore:
4619
- case PaywallEventId.DidFailRendering:
4620
- case PaywallEventId.DidFailLoadingProducts:
4621
- return [event.error];
4622
- case PaywallEventId.DidPerformAction:
4623
- if (handlerName === 'onUrlPress' && event.action.type === 'open_url') {
4624
- return [event.action.value, event.action.openIn];
4803
+ const purchaseHandler = handler;
4804
+ try {
4805
+ // The observer's documented way to close the view after driving the
4806
+ // purchase: returning `true` requests dismissal (close-on-`true`).
4807
+ const shouldClose = purchaseHandler(event.product, () => send({ method: 'observer_purchase_did_start', event_id: event.eventId }), () => send({ method: 'observer_purchase_did_finish', event_id: event.eventId }));
4808
+ if (shouldClose) {
4809
+ onRequestClose().catch((error) => Log.warn('observer_purchase_did_initiate', () => `Failed to close view after observer purchase: ${error}`, () => ({ error })));
4625
4810
  }
4626
- if (handlerName === 'onCustomAction' && event.action.type === 'custom') {
4627
- return [event.action.value];
4811
+ }
4812
+ catch (error) {
4813
+ Log.warn('observer_purchase_handler_failed', () => `onObserverPurchaseInitiated handler threw: ${error}`, () => ({ error }));
4814
+ }
4815
+ }
4816
+ handleObserverRestore(event) {
4817
+ const handlerData = this.handlers.get('onObserverRestoreInitiated');
4818
+ if (!handlerData)
4819
+ return;
4820
+ const { handler, onRequestClose } = handlerData;
4821
+ const send = (body) => {
4822
+ const ctx = new LogContext();
4823
+ const log = ctx.call({ methodName: body.method });
4824
+ void this.adapty
4825
+ .handleMethodCall(body.method, JSON.stringify(body), ctx, log)
4826
+ .catch((error) => Log.warn(body.method, () => `Failed observer restore signal: ${error}`));
4827
+ };
4828
+ const restoreHandler = handler;
4829
+ try {
4830
+ // The observer's documented way to close the view after driving the
4831
+ // restore: returning `true` requests dismissal (close-on-`true`).
4832
+ const shouldClose = restoreHandler(() => send({ method: 'observer_restore_did_start', event_id: event.eventId }), () => send({ method: 'observer_restore_did_finish', event_id: event.eventId }));
4833
+ if (shouldClose) {
4834
+ onRequestClose().catch((error) => Log.warn('observer_restore_did_initiate', () => `Failed to close view after observer restore: ${error}`, () => ({ error })));
4628
4835
  }
4629
- return [];
4630
- case PaywallEventId.DidFinishWebPaymentNavigation:
4631
- return [event.product, event.error];
4632
- case PaywallEventId.DidAppear:
4633
- case PaywallEventId.DidDisappear:
4634
- case PaywallEventId.DidStartRestore:
4635
- return [];
4836
+ }
4837
+ catch (error) {
4838
+ Log.warn('observer_restore_handler_failed', () => `onObserverRestoreInitiated handler threw: ${error}`, () => ({ error }));
4839
+ }
4636
4840
  }
4637
4841
  }
4638
4842
 
4639
4843
  /**
4640
- * Default event handlers that provide standard closing behavior
4844
+ * Default flow-view event handlers. Mirrors react-native-adapty v4 defaults:
4845
+ * most handlers keep the view open (return false); onCloseButtonPress and
4846
+ * onError close it (return true). onUrlPress / onRequestAppReview delegate to
4847
+ * the native handler methods.
4848
+ *
4849
+ * @internal
4641
4850
  */
4642
- const DEFAULT_EVENT_HANDLERS = {
4851
+ const DEFAULT_FLOW_EVENT_HANDLERS = {
4643
4852
  onCloseButtonPress: () => true,
4644
- onAndroidSystemBack: () => true,
4853
+ onAndroidSystemBack: () => false,
4854
+ // Delegate to the handler method, which opens the URL natively honoring
4855
+ // `open_in` (`browser_out_app` → external browser, `browser_in_app` → in-app
4856
+ // browser). Override this handler to open URLs yourself instead.
4645
4857
  onUrlPress: (url, openIn) => {
4646
- if (openIn === 'browser_in_app') {
4647
- Log.warn('onUrlPress', () => 'open_in=browser_in_app is not supported by the default onUrlPress handler. Override onUrlPress to support an in-app browser.');
4648
- }
4649
- if (typeof window !== 'undefined') {
4650
- try {
4651
- window.open(new URL(url), '_blank');
4652
- }
4653
- catch (_a) {
4654
- Log.warn('onUrlPress', () => `Invalid URL: ${url}`);
4655
- }
4656
- }
4657
- return false;
4858
+ adapty
4859
+ .openWebUrl({ url, openIn })
4860
+ .catch((error) => Log.warn('onUrlPress', () => `Failed to open url via native: ${error}`));
4861
+ return false; // Keep flow view open
4658
4862
  },
4659
4863
  onCustomAction: () => false,
4660
4864
  onProductSelected: () => false,
4661
4865
  onPurchaseStarted: () => false,
4662
- onPurchaseCompleted: (purchaseResult) => (purchaseResult === null || purchaseResult === void 0 ? void 0 : purchaseResult.type) !== 'user_cancelled',
4866
+ onPurchaseCompleted: () => false,
4663
4867
  onPurchaseFailed: () => false,
4664
4868
  onRestoreStarted: () => false,
4665
- onRestoreCompleted: () => true,
4869
+ onRestoreCompleted: () => false,
4666
4870
  onRestoreFailed: () => false,
4667
4871
  onAppeared: () => false,
4668
4872
  onDisappeared: () => false,
4669
- onRenderingFailed: () => true,
4873
+ onError: () => true,
4670
4874
  onLoadingProductsFailed: () => false,
4671
4875
  onWebPaymentNavigationFinished: () => false,
4876
+ // Delegate to the handler method, which shows the platform app-review prompt
4877
+ // natively (`SKStoreReviewController` on iOS, In-App Review on Android).
4878
+ // Override this handler to control the prompt yourself instead.
4879
+ onRequestAppReview: () => {
4880
+ void adapty
4881
+ .requestAppReview()
4882
+ .catch((error) => Log.warn('onRequestAppReview', () => `Failed to request app review via native: ${error}`));
4883
+ return false; // Keep flow view open
4884
+ },
4885
+ onAnalytics: () => false,
4886
+ // There is no real default here: permissions must be declared in the app
4887
+ // bundle by the developer, so we cannot grant them on the user's behalf. Warn
4888
+ // and reply `denied` so native always gets a correlated answer.
4889
+ onRequestPermission: async () => {
4890
+ Log.warn('onRequestPermission', () => 'No onRequestPermission handler provided; replying `denied`. Declare the required ' +
4891
+ 'permissions in your app and provide an onRequestPermission handler to respond.');
4892
+ return { status: 'denied' };
4893
+ },
4894
+ // Observer mode: no real default. If you enable observer mode and present a
4895
+ // flow view, you must drive the purchase/restore yourself, so warn when no
4896
+ // handler is provided.
4897
+ onObserverPurchaseInitiated: () => {
4898
+ Log.warn('onObserverPurchaseInitiated', () => 'No onObserverPurchaseInitiated handler provided. In observer mode you must drive the purchase yourself; provide this handler to do so.');
4899
+ return false;
4900
+ },
4901
+ onObserverRestoreInitiated: () => {
4902
+ Log.warn('onObserverRestoreInitiated', () => 'No onObserverRestoreInitiated handler provided. In observer mode you must drive the restore yourself; provide this handler to do so.');
4903
+ return false;
4904
+ },
4672
4905
  };
4906
+ /**
4907
+ * @internal
4908
+ */
4673
4909
  const DEFAULT_ONBOARDING_EVENT_HANDLERS = {
4674
4910
  onClose: () => true,
4675
4911
  };
@@ -4677,44 +4913,47 @@ const DEFAULT_ONBOARDING_EVENT_HANDLERS = {
4677
4913
  const DEFAULT_PARAMS = {
4678
4914
  prefetchProducts: true,
4679
4915
  loadTimeoutMs: 5000,
4916
+ android: {
4917
+ enableSafeArea: true,
4918
+ },
4680
4919
  };
4681
4920
  /**
4682
- * Controller for managing paywall views.
4921
+ * Controller for managing flow views.
4683
4922
  *
4684
4923
  * @remarks
4685
- * This class provides methods to present, dismiss, and handle events for paywall views
4686
- * created with the Paywall Builder. Create instances using the {@link createPaywallView} function
4924
+ * This class provides methods to present, dismiss, and handle events for flow views
4925
+ * created with the Flow Builder. Create instances using the {@link createFlowView} function
4687
4926
  * rather than directly constructing this class.
4688
4927
  *
4689
4928
  * @public
4690
4929
  */
4691
- class PaywallViewController {
4930
+ class FlowViewController {
4692
4931
  /**
4693
4932
  * Intended way to create a ViewController instance.
4694
4933
  * It prepares a native controller to be presented
4695
4934
  * and creates reference between native controller and JS instance
4696
4935
  * @internal
4697
4936
  */
4698
- static async create(paywall, params, adaptyPlugin) {
4699
- const controller = new PaywallViewController(adaptyPlugin);
4937
+ static async create(flow, params, adaptyPlugin) {
4938
+ const controller = new FlowViewController(adaptyPlugin);
4700
4939
  const ctx = new LogContext();
4701
- const methodKey = 'adapty_ui_create_paywall_view';
4940
+ const methodKey = 'adapty_ui_create_flow_view';
4702
4941
  const log = ctx.call({ methodName: methodKey });
4703
- log.start(() => ({ paywall, params }));
4704
- const paywallCoder = coderFactory.createPaywallCoder();
4705
- const paramsCoder = coderFactory.createUiCreatePaywallViewParamsCoder();
4942
+ log.start(() => ({ flow, params }));
4943
+ const flowCoder = coderFactory.createFlowCoder();
4944
+ const paramsCoder = coderFactory.createUiCreateFlowViewParamsCoder();
4706
4945
  const paramsWithDefaults = Object.assign(Object.assign({}, DEFAULT_PARAMS), params);
4707
- const data = Object.assign({ method: methodKey, paywall: paywallCoder.encode(paywall) }, paramsCoder.encode(paramsWithDefaults));
4946
+ const data = Object.assign({ method: methodKey, flow: flowCoder.encode(flow) }, paramsCoder.encode(paramsWithDefaults));
4708
4947
  const result = (await controller.adaptyPlugin.handleMethodCall(methodKey, JSON.stringify(data), ctx, log));
4709
4948
  controller.id = result.id;
4710
- controller.viewEmitter = new PaywallViewEmitter(controller.id);
4711
- await controller.setEventHandlers(DEFAULT_EVENT_HANDLERS);
4949
+ controller.viewEmitter = new FlowViewEmitter(controller.id, controller.adaptyPlugin);
4950
+ await controller.setEventHandlers(DEFAULT_FLOW_EVENT_HANDLERS);
4712
4951
  return controller;
4713
4952
  }
4714
4953
  /**
4715
4954
  * Since constructors in JS cannot be async, it is not
4716
4955
  * preferred to create ViewControllers in direct way.
4717
- * Consider using @link{ViewController.create} instead
4956
+ * Consider using {@link FlowViewController.create} instead
4718
4957
  *
4719
4958
  * @internal
4720
4959
  */
@@ -4726,31 +4965,31 @@ class PaywallViewController {
4726
4965
  await this.dismiss();
4727
4966
  }
4728
4967
  catch (error) {
4729
- Log.warn('setEventHandlers', () => 'Failed to dismiss paywall', () => ({ error }));
4968
+ Log.warn('setEventHandlers', () => 'Failed to dismiss flow', () => ({ error }));
4730
4969
  }
4731
4970
  };
4732
4971
  this.adaptyPlugin = adaptyPlugin;
4733
4972
  }
4734
4973
  /**
4735
- * Presents the paywall view as a modal screen.
4974
+ * Presents the flow view as a modal screen.
4736
4975
  *
4737
4976
  * @remarks
4738
- * Calling `present` on an already visible paywall view will result in an error.
4739
- * The paywall will be displayed with the configured presentation style on iOS.
4740
- * On Android, the paywall is always presented as a full-screen activity.
4977
+ * Calling `present` on an already visible flow view will result in an error.
4978
+ * The flow will be displayed with the configured presentation style on iOS.
4979
+ * On Android, the flow is always presented as a full-screen activity.
4741
4980
  *
4742
4981
  * @param options - Optional presentation options
4743
4982
  * @param options.iosPresentationStyle - iOS presentation style. Available options: `'full_screen'` (default) or `'page_sheet'`. Only affects iOS platform.
4744
- * @returns A promise that resolves when the paywall is presented.
4983
+ * @returns A promise that resolves when the flow is presented.
4745
4984
  * @throws {@link AdaptyError} if the view reference is invalid or the view is already presented.
4746
4985
  *
4747
4986
  * @example
4748
4987
  * Present with default full-screen style
4749
4988
  * ```typescript
4750
- * import { adapty, createPaywallView } from '@adapty/capacitor';
4989
+ * import { adapty, createFlowView } from '@adapty/capacitor';
4751
4990
  *
4752
- * const paywall = await adapty.getPaywall({ placementId: 'YOUR_PLACEMENT_ID' });
4753
- * const view = await createPaywallView(paywall);
4991
+ * const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
4992
+ * const view = await createFlowView(flow);
4754
4993
  * await view.present();
4755
4994
  * ```
4756
4995
  *
@@ -4763,7 +5002,7 @@ class PaywallViewController {
4763
5002
  async present(options = {}) {
4764
5003
  var _a;
4765
5004
  const ctx = new LogContext();
4766
- const methodKey = 'adapty_ui_present_paywall_view';
5005
+ const methodKey = 'adapty_ui_present_flow_view';
4767
5006
  const log = ctx.call({ methodName: methodKey });
4768
5007
  log.start(() => ({ _id: this.id, iosPresentationStyle: options.iosPresentationStyle }));
4769
5008
  if (this.id === null) {
@@ -4780,20 +5019,20 @@ class PaywallViewController {
4780
5019
  await this.adaptyPlugin.handleMethodCall(methodKey, JSON.stringify(data), ctx, log);
4781
5020
  }
4782
5021
  /**
4783
- * Dismisses the paywall view.
5022
+ * Dismisses the flow view.
4784
5023
  *
4785
5024
  * @remarks
4786
- * This method closes the paywall and cleans up associated resources.
5025
+ * This method closes the flow and cleans up associated resources.
4787
5026
  * After dismissing, the view controller instance cannot be reused.
4788
5027
  *
4789
- * @returns A promise that resolves when the paywall is dismissed.
5028
+ * @returns A promise that resolves when the flow is dismissed.
4790
5029
  * @throws {@link AdaptyError} if the view reference is invalid.
4791
5030
  *
4792
5031
  * @example
4793
5032
  * ```typescript
4794
- * import { createPaywallView } from '@adapty/capacitor';
5033
+ * import { createFlowView } from '@adapty/capacitor';
4795
5034
  *
4796
- * const view = await createPaywallView(paywall);
5035
+ * const view = await createFlowView(flow);
4797
5036
  * await view.present();
4798
5037
  * // ... later
4799
5038
  * await view.dismiss();
@@ -4801,7 +5040,7 @@ class PaywallViewController {
4801
5040
  */
4802
5041
  async dismiss() {
4803
5042
  const ctx = new LogContext();
4804
- const methodKey = 'adapty_ui_dismiss_paywall_view';
5043
+ const methodKey = 'adapty_ui_dismiss_flow_view';
4805
5044
  const log = ctx.call({ methodName: methodKey });
4806
5045
  log.start(() => ({ _id: this.id }));
4807
5046
  if (this.id === null) {
@@ -4822,7 +5061,7 @@ class PaywallViewController {
4822
5061
  * Displays a dialog to the user.
4823
5062
  *
4824
5063
  * @remarks
4825
- * Use this method to show custom dialogs within the paywall flow.
5064
+ * Use this method to show custom dialogs within the flow.
4826
5065
  * If you provide two actions in the config, the primary action should cancel the operation
4827
5066
  * and leave things unchanged, while the secondary action should confirm the operation.
4828
5067
  *
@@ -4874,20 +5113,20 @@ class PaywallViewController {
4874
5113
  return await this.adaptyPlugin.handleMethodCall(methodKey, JSON.stringify(data), ctx, log);
4875
5114
  }
4876
5115
  /**
4877
- * Registers event handlers for paywall UI events.
5116
+ * Registers event handlers for flow UI events.
4878
5117
  *
4879
5118
  * @remarks
4880
5119
  * Each event type can have only one handler — new handlers replace existing ones.
4881
- * Default handlers are registered automatically in {@link createPaywallView} and provide standard closing behavior:
4882
- * - `onCloseButtonPress` - closes the paywall
4883
- * - `onAndroidSystemBack` - closes the paywall (Android only)
4884
- * - `onRestoreCompleted` - closes the paywall after successful restore
4885
- * - `onRenderingFailed` - closes the paywall when rendering fails
4886
- * - `onPurchaseCompleted` - closes the paywall after successful purchase
4887
- *
4888
- * If you want to override these listeners, we strongly recommend returning `true`
4889
- * (or `purchaseResult.type !== 'user_cancelled'` in case of `onPurchaseCompleted`)
4890
- * from your custom listener to retain default closing behavior.
5120
+ * Default handlers are registered automatically in {@link createFlowView} (see `DEFAULT_FLOW_EVENT_HANDLERS`).
5121
+ * Only two defaults close the view; all others keep it open:
5122
+ * - `onCloseButtonPress` - closes the view (returns `true`)
5123
+ * - `onError` - closes the view (returns `true`)
5124
+ * - all other handlers keep the view open by default (return `false`),
5125
+ * including `onAndroidSystemBack`, `onRestoreCompleted`, and `onPurchaseCompleted`
5126
+ *
5127
+ * Returning `true` from a handler closes the view; returning `false` keeps it open.
5128
+ * To retain default behavior in a custom listener, return the same value as the default
5129
+ * implementation (only `onCloseButtonPress` and `onError` close the view by default).
4891
5130
  *
4892
5131
  * Calling this method multiple times will replace previously registered handlers for provided events.
4893
5132
  *
@@ -4899,9 +5138,9 @@ class PaywallViewController {
4899
5138
  * @example
4900
5139
  * Register custom event handlers
4901
5140
  * ```typescript
4902
- * import { createPaywallView } from '@adapty/capacitor';
5141
+ * import { createFlowView } from '@adapty/capacitor';
4903
5142
  *
4904
- * const view = await createPaywallView(paywall);
5143
+ * const view = await createFlowView(flow);
4905
5144
  *
4906
5145
  * const unsubscribe = await view.setEventHandlers({
4907
5146
  * onPurchaseStarted: (product) => {
@@ -4909,7 +5148,7 @@ class PaywallViewController {
4909
5148
  * },
4910
5149
  * onPurchaseCompleted: (result) => {
4911
5150
  * console.log('Purchase completed:', result.type);
4912
- * // Return true to keep default closing behavior
5151
+ * // Return true to close the view after purchase (default keeps it open)
4913
5152
  * return result.type !== 'user_cancelled';
4914
5153
  * },
4915
5154
  * onPurchaseFailed: (error) => {
@@ -4935,13 +5174,13 @@ class PaywallViewController {
4935
5174
  });
4936
5175
  }
4937
5176
  Log.verbose('setEventHandlers', () => 'Registering event handlers for view', () => ({ id: this.id }));
4938
- const viewEmitter = (_a = this.viewEmitter) !== null && _a !== void 0 ? _a : new PaywallViewEmitter(this.id);
5177
+ const viewEmitter = (_a = this.viewEmitter) !== null && _a !== void 0 ? _a : new FlowViewEmitter(this.id, this.adaptyPlugin);
4939
5178
  this.viewEmitter = viewEmitter;
4940
5179
  const wrappedErrorLogEventHandlers = mapValues(eventHandlers, (handler, eventName) => handler && typeof handler === 'function'
4941
- ? withErrorContext(handler, eventName, 'PaywallViewController')
5180
+ ? withErrorContext(handler, eventName, 'FlowViewController')
4942
5181
  : undefined);
4943
5182
  // Merge with defaults to ensure default behavior is preserved after unsubscribe/resubscribe cycles
4944
- const finalEventHandlers = Object.assign(Object.assign({}, DEFAULT_EVENT_HANDLERS), wrappedErrorLogEventHandlers);
5183
+ const finalEventHandlers = Object.assign(Object.assign({}, DEFAULT_FLOW_EVENT_HANDLERS), wrappedErrorLogEventHandlers);
4945
5184
  for (const [eventName, handler] of Object.entries(finalEventHandlers)) {
4946
5185
  if (handler && typeof handler === 'function') {
4947
5186
  try {
@@ -4975,7 +5214,7 @@ class PaywallViewController {
4975
5214
  *
4976
5215
  * @example
4977
5216
  * ```typescript
4978
- * const view = await createPaywallView(paywall);
5217
+ * const view = await createFlowView(flow);
4979
5218
  * await view.setEventHandlers({ onPurchaseCompleted: handlePurchase });
4980
5219
  *
4981
5220
  * // Later, clear all handlers
@@ -5069,6 +5308,8 @@ const DEFAULT_ONBOARDING_PARAMS = {
5069
5308
  /**
5070
5309
  * Controller for managing onboarding views.
5071
5310
  *
5311
+ * @deprecated Since 4.0.0. Migrate onboardings to the Flow Builder API.
5312
+ *
5072
5313
  * @remarks
5073
5314
  * This class provides methods to present, dismiss, and handle events for onboarding views
5074
5315
  * created with the Onboarding Builder. Create instances using the {@link createOnboardingView} function
@@ -5101,7 +5342,7 @@ class OnboardingViewController {
5101
5342
  /**
5102
5343
  * Since constructors in JS cannot be async, it is not
5103
5344
  * preferred to create ViewControllers in direct way.
5104
- * Consider using @link{OnboardingViewController.create} instead
5345
+ * Consider using {@link OnboardingViewController.create} instead
5105
5346
  *
5106
5347
  * @internal
5107
5348
  */
@@ -5230,11 +5471,11 @@ class OnboardingViewController {
5230
5471
  * // Return true to keep default closing behavior
5231
5472
  * return true;
5232
5473
  * },
5233
- * onActionPerformed: (action) => {
5234
- * console.log('Action performed:', action.name);
5474
+ * onCustom: (actionId, meta) => {
5475
+ * console.log('Custom action:', actionId, meta);
5235
5476
  * },
5236
- * onProductSelected: (product) => {
5237
- * console.log('Product selected:', product.vendorProductId);
5477
+ * onStateUpdated: (action, meta) => {
5478
+ * console.log('State updated:', action, meta);
5238
5479
  * }
5239
5480
  * });
5240
5481
  *
@@ -5308,31 +5549,18 @@ class OnboardingViewController {
5308
5549
  }
5309
5550
  }
5310
5551
 
5311
- const adaptyPlugin$1 = new Adapty();
5312
5552
  /**
5313
- * Creates a paywall view controller.
5314
- * You can use it to further configure a view or present it.
5553
+ * Creates a flow view controller. Use it to further configure a view or present it.
5315
5554
  *
5316
- * @see {@link https://adapty.io/docs/capacitor-present-paywalls | [DOC] Creating a paywall view}
5317
- *
5318
- * @param {AdaptyPaywall} paywall - paywall that you want to present.
5319
- * @param {CreatePaywallViewParamsInput | undefined} [params] - additional params.
5320
- * @returns {Promise<PaywallViewController>} ViewController — A promise that resolves to a ViewController instance.
5321
- *
5322
- * @example
5323
- * ```ts
5324
- * const paywall = await adapty.getPaywall("MY_PAYWALL");
5325
- * const view = await createPaywallView(paywall);
5326
- * view.present();
5327
- * ```
5555
+ * @see {@link https://adapty.io/docs/capacitor-present-paywalls | [DOC] Creating a flow view}
5328
5556
  *
5329
- * @throws {AdaptyError} If paywall is not found,
5330
- * does not have a no-code view configured
5331
- * or if there is an error while creating a view.
5557
+ * @param {AdaptyFlow} flow - flow to present (from `adapty.getFlow(...)`).
5558
+ * @param {CreateFlowViewParamsInput} [params] - additional params.
5559
+ * @returns {Promise<FlowViewController>}
5560
+ * @throws {AdaptyError} if the flow has no view configured or view creation fails.
5332
5561
  */
5333
- async function createPaywallView(paywall, params = {}) {
5334
- const controller = await PaywallViewController.create(paywall, params, adaptyPlugin$1);
5335
- return controller;
5562
+ async function createFlowView(flow, params = {}) {
5563
+ return FlowViewController.create(flow, params, adapty);
5336
5564
  }
5337
5565
 
5338
5566
  const adaptyPlugin = new Adapty();
@@ -5340,6 +5568,8 @@ const adaptyPlugin = new Adapty();
5340
5568
  * Creates an onboarding view controller.
5341
5569
  * You can use it to further configure a view or present it.
5342
5570
  *
5571
+ * @deprecated Since 4.0.0. Migrate onboardings to the Flow Builder API.
5572
+ *
5343
5573
  * @see {@link https://adapty.io/docs/capacitor-get-onboardings | [DOC] Creating an onboarding view}
5344
5574
  *
5345
5575
  * @param {AdaptyOnboarding} onboarding - onboarding that you want to present.
@@ -5369,8 +5599,6 @@ async function createOnboardingView(onboarding, params = {}) {
5369
5599
  return controller;
5370
5600
  }
5371
5601
 
5372
- const adapty = new Adapty();
5373
-
5374
5602
  class AdaptyCapacitorPluginWeb extends core.WebPlugin {
5375
5603
  addListener(eventName, listenerFunc) {
5376
5604
  return super.addListener(eventName, listenerFunc);
@@ -5393,26 +5621,27 @@ var web = /*#__PURE__*/Object.freeze({
5393
5621
 
5394
5622
  exports.AdaptyAndroidSubscriptionUpdateReplacementMode = AdaptyAndroidSubscriptionUpdateReplacementMode;
5395
5623
  exports.AdaptyError = AdaptyError;
5624
+ exports.AdaptyUiDialogActionType = AdaptyUiDialogActionType;
5396
5625
  exports.AppTrackingTransparencyStatus = AppTrackingTransparencyStatus;
5397
5626
  exports.CancellationReason = CancellationReason;
5398
5627
  exports.ErrorCode = ErrorCode;
5399
5628
  exports.ErrorCodeName = ErrorCodeName;
5400
5629
  exports.FetchPolicy = FetchPolicy;
5630
+ exports.FlowEventId = FlowEventId;
5631
+ exports.FlowViewController = FlowViewController;
5401
5632
  exports.Gender = Gender;
5402
5633
  exports.LogLevel = LogLevel;
5403
5634
  exports.OfferType = OfferType;
5404
5635
  exports.OnboardingEventId = OnboardingEventId;
5405
5636
  exports.OnboardingViewController = OnboardingViewController;
5406
- exports.PaywallEventId = PaywallEventId;
5407
- exports.PaywallViewController = PaywallViewController;
5408
5637
  exports.ProductPeriod = ProductPeriod;
5409
5638
  exports.RefundPreference = RefundPreference;
5410
5639
  exports.VendorStore = VendorStore;
5411
5640
  exports.WebPresentation = WebPresentation;
5412
5641
  exports.adapty = adapty;
5413
5642
  exports.consoleLogSink = consoleLogSink;
5643
+ exports.createFlowView = createFlowView;
5414
5644
  exports.createOnboardingView = createOnboardingView;
5415
- exports.createPaywallView = createPaywallView;
5416
5645
  exports.getErrorCode = getErrorCode;
5417
5646
  exports.getErrorPrompt = getErrorPrompt;
5418
5647
  //# sourceMappingURL=plugin.cjs.js.map