@adapty/capacitor 3.17.1 → 4.0.0-beta.2

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