@adapty/capacitor 3.17.0 → 4.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/Package.swift +1 -1
  2. package/README.md +8 -0
  3. package/android/build.gradle +2 -2
  4. package/dist/esm/adapty-instance.d.ts +7 -0
  5. package/dist/esm/adapty-instance.js +8 -0
  6. package/dist/esm/adapty-instance.js.map +1 -0
  7. package/dist/esm/adapty.d.ts +112 -59
  8. package/dist/esm/adapty.js +132 -69
  9. package/dist/esm/adapty.js.map +1 -1
  10. package/dist/esm/coders/parse-flow.d.ts +3 -0
  11. package/dist/esm/coders/parse-flow.js +4 -0
  12. package/dist/esm/coders/parse-flow.js.map +1 -0
  13. package/dist/esm/default-configs.js +2 -2
  14. package/dist/esm/default-configs.js.map +1 -1
  15. package/dist/esm/index.d.ts +4 -4
  16. package/dist/esm/index.js +3 -3
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/types/adapty-plugin.d.ts +31 -17
  19. package/dist/esm/types/adapty-plugin.js.map +1 -1
  20. package/dist/esm/types/configs.d.ts +12 -14
  21. package/dist/esm/types/configs.js.map +1 -1
  22. package/dist/esm/types/flow-events.d.ts +1 -0
  23. package/dist/esm/types/flow-events.js +2 -0
  24. package/dist/esm/types/flow-events.js.map +1 -0
  25. package/dist/esm/types/index.d.ts +2 -2
  26. package/dist/esm/types/index.js +1 -1
  27. package/dist/esm/types/index.js.map +1 -1
  28. package/dist/esm/types/inputs.d.ts +1 -1
  29. package/dist/esm/types/inputs.js.map +1 -1
  30. package/dist/esm/ui-builder/base-view-emitter.d.ts +6 -0
  31. package/dist/esm/ui-builder/base-view-emitter.js +12 -0
  32. package/dist/esm/ui-builder/base-view-emitter.js.map +1 -1
  33. package/dist/esm/ui-builder/create-flow-view.d.ts +14 -0
  34. package/dist/esm/ui-builder/create-flow-view.js +16 -0
  35. package/dist/esm/ui-builder/create-flow-view.js.map +1 -0
  36. package/dist/esm/ui-builder/create-onboarding-view.d.ts +2 -0
  37. package/dist/esm/ui-builder/create-onboarding-view.js +2 -0
  38. package/dist/esm/ui-builder/create-onboarding-view.js.map +1 -1
  39. package/dist/esm/ui-builder/{paywall-view-controller.d.ts → flow-view-controller.d.ts} +37 -37
  40. package/dist/esm/ui-builder/{paywall-view-controller.js → flow-view-controller.js} +54 -51
  41. package/dist/esm/ui-builder/flow-view-controller.js.map +1 -0
  42. package/dist/esm/ui-builder/flow-view-emitter.d.ts +38 -0
  43. package/dist/esm/ui-builder/flow-view-emitter.js +151 -0
  44. package/dist/esm/ui-builder/flow-view-emitter.js.map +1 -0
  45. package/dist/esm/ui-builder/index.d.ts +5 -5
  46. package/dist/esm/ui-builder/index.js +3 -2
  47. package/dist/esm/ui-builder/index.js.map +1 -1
  48. package/dist/esm/ui-builder/onboarding-view-controller.d.ts +7 -5
  49. package/dist/esm/ui-builder/onboarding-view-controller.js +7 -5
  50. package/dist/esm/ui-builder/onboarding-view-controller.js.map +1 -1
  51. package/dist/esm/ui-builder/types.d.ts +11 -358
  52. package/dist/esm/ui-builder/types.js +52 -22
  53. package/dist/esm/ui-builder/types.js.map +1 -1
  54. package/dist/esm/version.d.ts +1 -1
  55. package/dist/esm/version.js +1 -1
  56. package/dist/esm/version.js.map +1 -1
  57. package/dist/plugin.cjs.js +906 -677
  58. package/dist/plugin.cjs.js.map +1 -1
  59. package/dist/plugin.js +906 -677
  60. package/dist/plugin.js.map +1 -1
  61. package/package.json +3 -5
  62. package/AdaptyCapacitor.podspec +0 -20
  63. package/dist/esm/coders/parse-paywall.d.ts +0 -3
  64. package/dist/esm/coders/parse-paywall.js +0 -4
  65. package/dist/esm/coders/parse-paywall.js.map +0 -1
  66. package/dist/esm/types/paywall-events.d.ts +0 -1
  67. package/dist/esm/types/paywall-events.js +0 -2
  68. package/dist/esm/types/paywall-events.js.map +0 -1
  69. package/dist/esm/ui-builder/create-paywall-view.d.ts +0 -25
  70. package/dist/esm/ui-builder/create-paywall-view.js +0 -29
  71. package/dist/esm/ui-builder/create-paywall-view.js.map +0 -1
  72. package/dist/esm/ui-builder/paywall-view-controller.js.map +0 -1
  73. package/dist/esm/ui-builder/paywall-view-emitter.d.ts +0 -16
  74. package/dist/esm/ui-builder/paywall-view-emitter.js +0 -114
  75. package/dist/esm/ui-builder/paywall-view-emitter.js.map +0 -1
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 {
@@ -1288,204 +1443,61 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
1288
1443
  required: true,
1289
1444
  type: "string"
1290
1445
  },
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()
1451
- },
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"
1483
1480
  },
1484
- paywallBuilder: {
1485
- key: "paywall_builder",
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"
1495
+ },
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
@@ -1730,6 +1746,11 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
1730
1746
  type: "object",
1731
1747
  converter: new HashmapCoder(new AdaptyAccessLevelCoder())
1732
1748
  },
1749
+ appliedAttributionSources: {
1750
+ key: "applied_attribution_sources",
1751
+ required: false,
1752
+ type: "array"
1753
+ },
1733
1754
  customAttributes: {
1734
1755
  key: "custom_attributes",
1735
1756
  required: false,
@@ -1763,9 +1784,6 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
1763
1784
 
1764
1785
  //#endregion
1765
1786
  //#region src/coders/adapty-purchase-params.ts
1766
- function isDeprecatedType(data) {
1767
- return typeof data === "object" && data !== null && "android" in data && typeof data.android === "object" && data.android !== null && "oldSubVendorProductId" in data.android && "prorationMode" in data.android;
1768
- }
1769
1787
  var AdaptyPurchaseParamsCoder = class {
1770
1788
  constructor(platform) {
1771
1789
  this.platform = platform;
@@ -1773,16 +1791,6 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
1773
1791
  encode(data) {
1774
1792
  if (this.platform.OS !== "android") return {};
1775
1793
  const purchaseParams = {};
1776
- if (isDeprecatedType(data)) {
1777
- if (data.android) {
1778
- purchaseParams["subscription_update_params"] = {
1779
- replacement_mode: data.android.prorationMode,
1780
- old_sub_vendor_product_id: data.android.oldSubVendorProductId
1781
- };
1782
- if (data.android.isOfferPersonalized) purchaseParams["is_offer_personalized"] = data.android.isOfferPersonalized;
1783
- }
1784
- return purchaseParams;
1785
- }
1786
1794
  if (data.android) {
1787
1795
  if (data.android.subscriptionUpdateParams) purchaseParams["subscription_update_params"] = {
1788
1796
  replacement_mode: data.android.subscriptionUpdateParams.prorationMode,
@@ -1915,14 +1923,15 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
1915
1923
  };
1916
1924
 
1917
1925
  //#endregion
1918
- //#region src/coders/adapty-ui-create-paywall-view-params.ts
1919
- var AdaptyUICreatePaywallViewParamsCoder = class {
1926
+ //#region src/coders/adapty-ui-create-flow-view-params.ts
1927
+ var AdaptyUICreateFlowViewParamsCoder = class {
1920
1928
  constructor(platform) {
1921
1929
  this.platform = platform;
1922
1930
  }
1923
1931
  encode(data) {
1924
1932
  const result = {};
1925
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;
1926
1935
  if (data.loadTimeoutMs !== void 0) result.load_timeout = data.loadTimeoutMs / 1e3;
1927
1936
  if (data.customTags) result.custom_tags = data.customTags;
1928
1937
  if (data.customTimers) result.custom_timers = this.encodeCustomTimers(data.customTimers);
@@ -2257,11 +2266,11 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2257
2266
  createOnboardingCoder() {
2258
2267
  return new AdaptyOnboardingCoder(this.deps.platform);
2259
2268
  }
2260
- createPaywallBuilderCoder() {
2261
- return new AdaptyPaywallBuilderCoder(this.deps.platform);
2269
+ createFlowCoder() {
2270
+ return new AdaptyFlowCoder(this.deps.platform);
2262
2271
  }
2263
- createPaywallCoder() {
2264
- return new AdaptyPaywallCoder(this.deps.platform);
2272
+ createFlowPaywallCoder() {
2273
+ return new AdaptyFlowPaywallCoder(this.deps.platform);
2265
2274
  }
2266
2275
  createPaywallProductCoder() {
2267
2276
  return new AdaptyPaywallProductCoder(this.deps.platform);
@@ -2302,8 +2311,8 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2302
2311
  createUiCreateOnboardingViewParamsCoder() {
2303
2312
  return new AdaptyUICreateOnboardingViewParamsCoder();
2304
2313
  }
2305
- createUiCreatePaywallViewParamsCoder() {
2306
- return new AdaptyUICreatePaywallViewParamsCoder(this.deps.platform);
2314
+ createUiCreateFlowViewParamsCoder() {
2315
+ return new AdaptyUICreateFlowViewParamsCoder(this.deps.platform);
2307
2316
  }
2308
2317
  createUiDialogConfigCoder() {
2309
2318
  return new AdaptyUiDialogConfigCoder(this.deps.platform);
@@ -2383,21 +2392,26 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2383
2392
  });
2384
2393
 
2385
2394
  //#endregion
2386
- //#region src/types/paywall-events.ts
2387
- const PaywallEventId = {
2388
- DidAppear: "paywall_view_did_appear",
2389
- DidDisappear: "paywall_view_did_disappear",
2390
- DidPerformAction: "paywall_view_did_perform_action",
2391
- DidSelectProduct: "paywall_view_did_select_product",
2392
- DidStartPurchase: "paywall_view_did_start_purchase",
2393
- DidFinishPurchase: "paywall_view_did_finish_purchase",
2394
- DidFailPurchase: "paywall_view_did_fail_purchase",
2395
- DidStartRestore: "paywall_view_did_start_restore",
2396
- DidFinishRestore: "paywall_view_did_finish_restore",
2397
- DidFailRestore: "paywall_view_did_fail_restore",
2398
- DidFailRendering: "paywall_view_did_fail_rendering",
2399
- DidFailLoadingProducts: "paywall_view_did_fail_loading_products",
2400
- 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"
2401
2415
  };
2402
2416
 
2403
2417
  //#endregion
@@ -2413,13 +2427,13 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2413
2427
  };
2414
2428
 
2415
2429
  //#endregion
2416
- //#region src/ui-builder/paywall-event-mapping.ts
2430
+ //#region src/ui-builder/flow-event-mapping.ts
2417
2431
  /**
2418
2432
  * Resolves native event to handler name based on event data
2419
2433
  */
2420
- ({
2421
- [PaywallEventId.DidPerformAction]: (event) => {
2422
- 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;
2423
2437
  const actionMap = {
2424
2438
  close: "onCloseButtonPress",
2425
2439
  system_back: "onAndroidSystemBack",
@@ -2428,41 +2442,76 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2428
2442
  };
2429
2443
  return actionMap[event.action.type] || null;
2430
2444
  },
2431
- [PaywallEventId.DidAppear]: () => "onPaywallShown",
2432
- [PaywallEventId.DidDisappear]: () => "onPaywallClosed",
2433
- [PaywallEventId.DidSelectProduct]: () => "onProductSelected",
2434
- [PaywallEventId.DidStartPurchase]: () => "onPurchaseStarted",
2435
- [PaywallEventId.DidFinishPurchase]: () => "onPurchaseCompleted",
2436
- [PaywallEventId.DidFailPurchase]: () => "onPurchaseFailed",
2437
- [PaywallEventId.DidStartRestore]: () => "onRestoreStarted",
2438
- [PaywallEventId.DidFinishRestore]: () => "onRestoreCompleted",
2439
- [PaywallEventId.DidFailRestore]: () => "onRestoreFailed",
2440
- [PaywallEventId.DidFailRendering]: () => "onRenderingFailed",
2441
- [PaywallEventId.DidFailLoadingProducts]: () => "onLoadingProductsFailed",
2442
- [PaywallEventId.DidFinishWebPaymentNavigation]: () => "onWebPaymentNavigationFinished"
2443
- });
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
+ };
2444
2463
  /**
2445
2464
  * Maps handler name to native event name
2446
2465
  * Used in addListener/addInternalListener to subscribe to correct native event
2447
2466
  */
2448
- ({
2449
- onCloseButtonPress: PaywallEventId.DidPerformAction,
2450
- onAndroidSystemBack: PaywallEventId.DidPerformAction,
2451
- onUrlPress: PaywallEventId.DidPerformAction,
2452
- onCustomAction: PaywallEventId.DidPerformAction,
2453
- onPaywallShown: PaywallEventId.DidAppear,
2454
- onPaywallClosed: PaywallEventId.DidDisappear,
2455
- onProductSelected: PaywallEventId.DidSelectProduct,
2456
- onPurchaseStarted: PaywallEventId.DidStartPurchase,
2457
- onPurchaseCompleted: PaywallEventId.DidFinishPurchase,
2458
- onPurchaseFailed: PaywallEventId.DidFailPurchase,
2459
- onRestoreStarted: PaywallEventId.DidStartRestore,
2460
- onRestoreCompleted: PaywallEventId.DidFinishRestore,
2461
- onRestoreFailed: PaywallEventId.DidFailRestore,
2462
- onRenderingFailed: PaywallEventId.DidFailRendering,
2463
- onLoadingProductsFailed: PaywallEventId.DidFailLoadingProducts,
2464
- onWebPaymentNavigationFinished: PaywallEventId.DidFinishWebPaymentNavigation
2465
- });
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
+ }
2466
2515
 
2467
2516
  //#endregion
2468
2517
  //#region src/ui-builder/onboarding-event-mapping.ts
@@ -2491,6 +2540,13 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2491
2540
  return acc;
2492
2541
  }, {});
2493
2542
 
2543
+ //#endregion
2544
+ //#region src/ui-builder/types.ts
2545
+ const AdaptyUiDialogActionType = Object.freeze({
2546
+ primary: "primary",
2547
+ secondary: "secondary"
2548
+ });
2549
+
2494
2550
  //#endregion
2495
2551
  //#region src/coders/parse.ts
2496
2552
  function parseMethodResult$1(factory, input, resultType, ctx) {
@@ -2543,10 +2599,9 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2543
2599
  switch (type) {
2544
2600
  case "AdaptyError": return factory.createNativeErrorCoder();
2545
2601
  case "AdaptyProfile": return factory.createProfileCoder();
2546
- case "AdaptyPaywall": return factory.createPaywallCoder();
2602
+ case "AdaptyFlow": return factory.createFlowCoder();
2547
2603
  case "AdaptyPaywallProduct": return factory.createPaywallProductCoder();
2548
2604
  case "AdaptyRemoteConfig": return factory.createRemoteConfigCoder();
2549
- case "AdaptyPaywallBuilder": return factory.createPaywallBuilderCoder();
2550
2605
  case "AdaptyOnboarding": return factory.createOnboardingCoder();
2551
2606
  case "AdaptyPurchaseResult": return factory.createPurchaseResultCoder();
2552
2607
  case "AdaptyInstallationStatus": return factory.createInstallationStatusCoder();
@@ -2562,8 +2617,8 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2562
2617
  }
2563
2618
 
2564
2619
  //#endregion
2565
- //#region src/coders/parse-paywall.ts
2566
- function parsePaywallEvent$1(factory, input, ctx) {
2620
+ //#region src/coders/parse-flow.ts
2621
+ function parseFlowEvent$1(factory, input, ctx) {
2567
2622
  let obj;
2568
2623
  try {
2569
2624
  obj = JSON.parse(input);
@@ -2571,7 +2626,7 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2571
2626
  throw AdaptyError.failedToDecode(`Failed to decode event: ${error?.message}`);
2572
2627
  }
2573
2628
  const eventId = obj["id"];
2574
- if (!eventId?.startsWith("paywall_view_")) return null;
2629
+ if (!eventId?.startsWith("flow_view_")) return null;
2575
2630
  const viewObj = obj["view"];
2576
2631
  const view = {
2577
2632
  id: viewObj["id"],
@@ -2579,59 +2634,59 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2579
2634
  variationId: viewObj["variation_id"]
2580
2635
  };
2581
2636
  switch (eventId) {
2582
- case PaywallEventId.DidAppear: return {
2637
+ case FlowEventId.DidAppear: return {
2583
2638
  id: eventId,
2584
2639
  view
2585
2640
  };
2586
- case PaywallEventId.DidDisappear: return {
2641
+ case FlowEventId.DidDisappear: return {
2587
2642
  id: eventId,
2588
2643
  view
2589
2644
  };
2590
- case PaywallEventId.DidPerformAction: {
2645
+ case FlowEventId.DidPerformAction: {
2591
2646
  const actionObj = obj["action"];
2592
2647
  return {
2593
2648
  id: eventId,
2594
2649
  view,
2595
- action: parsePaywallUserAction(actionObj)
2650
+ action: parseFlowUserAction(actionObj)
2596
2651
  };
2597
2652
  }
2598
- case PaywallEventId.DidSelectProduct: return {
2653
+ case FlowEventId.DidSelectProduct: return {
2599
2654
  id: eventId,
2600
2655
  view,
2601
2656
  productId: obj["product_id"] ?? ""
2602
2657
  };
2603
- case PaywallEventId.DidStartPurchase: return {
2658
+ case FlowEventId.DidStartPurchase: return {
2604
2659
  id: eventId,
2605
2660
  view,
2606
- product: getPaywallCoder(factory, "product").decode(obj["product"])
2661
+ product: getFlowCoder(factory, "product").decode(obj["product"])
2607
2662
  };
2608
- case PaywallEventId.DidFinishPurchase: return {
2663
+ case FlowEventId.DidFinishPurchase: return {
2609
2664
  id: eventId,
2610
2665
  view,
2611
- purchaseResult: getPaywallCoder(factory, "purchaseResult").decode(obj["purchased_result"]),
2612
- product: getPaywallCoder(factory, "product").decode(obj["product"])
2666
+ purchaseResult: getFlowCoder(factory, "purchaseResult").decode(obj["purchased_result"]),
2667
+ product: getFlowCoder(factory, "product").decode(obj["product"])
2613
2668
  };
2614
- case PaywallEventId.DidFailPurchase: {
2615
- const errorCoder = getPaywallCoder(factory, "error");
2669
+ case FlowEventId.DidFailPurchase: {
2670
+ const errorCoder = getFlowCoder(factory, "error");
2616
2671
  const decodedError = errorCoder.decode(obj["error"]);
2617
2672
  return {
2618
2673
  id: eventId,
2619
2674
  view,
2620
2675
  error: errorCoder.getError(decodedError),
2621
- product: getPaywallCoder(factory, "product").decode(obj["product"])
2676
+ product: getFlowCoder(factory, "product").decode(obj["product"])
2622
2677
  };
2623
2678
  }
2624
- case PaywallEventId.DidStartRestore: return {
2679
+ case FlowEventId.DidStartRestore: return {
2625
2680
  id: eventId,
2626
2681
  view
2627
2682
  };
2628
- case PaywallEventId.DidFinishRestore: return {
2683
+ case FlowEventId.DidFinishRestore: return {
2629
2684
  id: eventId,
2630
2685
  view,
2631
- profile: getPaywallCoder(factory, "profile").decode(obj["profile"])
2686
+ profile: getFlowCoder(factory, "profile").decode(obj["profile"])
2632
2687
  };
2633
- case PaywallEventId.DidFailRestore: {
2634
- const errorCoder = getPaywallCoder(factory, "error");
2688
+ case FlowEventId.DidFailRestore: {
2689
+ const errorCoder = getFlowCoder(factory, "error");
2635
2690
  const decodedError = errorCoder.decode(obj["error"]);
2636
2691
  return {
2637
2692
  id: eventId,
@@ -2639,8 +2694,8 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2639
2694
  error: errorCoder.getError(decodedError)
2640
2695
  };
2641
2696
  }
2642
- case PaywallEventId.DidFailRendering: {
2643
- const errorCoder = getPaywallCoder(factory, "error");
2697
+ case FlowEventId.DidReceiveError: {
2698
+ const errorCoder = getFlowCoder(factory, "error");
2644
2699
  const decodedError = errorCoder.decode(obj["error"]);
2645
2700
  return {
2646
2701
  id: eventId,
@@ -2648,8 +2703,8 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2648
2703
  error: errorCoder.getError(decodedError)
2649
2704
  };
2650
2705
  }
2651
- case PaywallEventId.DidFailLoadingProducts: {
2652
- const errorCoder = getPaywallCoder(factory, "error");
2706
+ case FlowEventId.DidFailLoadingProducts: {
2707
+ const errorCoder = getFlowCoder(factory, "error");
2653
2708
  const decodedError = errorCoder.decode(obj["error"]);
2654
2709
  return {
2655
2710
  id: eventId,
@@ -2657,20 +2712,51 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2657
2712
  error: errorCoder.getError(decodedError)
2658
2713
  };
2659
2714
  }
2660
- case PaywallEventId.DidFinishWebPaymentNavigation: return {
2715
+ case FlowEventId.DidFinishWebPaymentNavigation: return {
2661
2716
  id: eventId,
2662
2717
  view,
2663
- product: obj["product"] ? getPaywallCoder(factory, "product").decode(obj["product"]) : void 0,
2718
+ product: obj["product"] ? getFlowCoder(factory, "product").decode(obj["product"]) : void 0,
2664
2719
  error: obj["error"] ? (() => {
2665
- const errorCoder = getPaywallCoder(factory, "error");
2720
+ const errorCoder = getFlowCoder(factory, "error");
2666
2721
  const decodedError = errorCoder.decode(obj["error"]);
2667
2722
  return errorCoder.getError(decodedError);
2668
2723
  })() : void 0
2669
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
+ };
2670
2756
  default: return null;
2671
2757
  }
2672
2758
  }
2673
- function parsePaywallUserAction(actionObj) {
2759
+ function parseFlowUserAction(actionObj) {
2674
2760
  const type = actionObj["type"];
2675
2761
  switch (type) {
2676
2762
  case "open_url": return {
@@ -2686,7 +2772,7 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2686
2772
  case "system_back": return { type };
2687
2773
  }
2688
2774
  }
2689
- function getPaywallCoder(factory, type, _ctx) {
2775
+ function getFlowCoder(factory, type, _ctx) {
2690
2776
  switch (type) {
2691
2777
  case "product": return factory.createPaywallProductCoder();
2692
2778
  case "profile": return factory.createProfileCoder();
@@ -2878,7 +2964,7 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
2878
2964
  web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.AdaptyCapacitorPluginWeb()),
2879
2965
  });
2880
2966
 
2881
- var VERSION = '3.17.0';
2967
+ var VERSION = '4.0.0-beta.1';
2882
2968
 
2883
2969
  /**
2884
2970
  * Capacitor implementation of IPlatformAdapter
@@ -3104,13 +3190,13 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3104
3190
  }
3105
3191
 
3106
3192
  const defaultAdaptyOptions = {
3107
- get_paywall: {
3193
+ get_flow: {
3108
3194
  params: {
3109
3195
  fetchPolicy: FetchPolicy.ReloadRevalidatingCacheData,
3110
3196
  loadTimeoutMs: 5000,
3111
3197
  },
3112
3198
  },
3113
- get_paywall_for_default_audience: {
3199
+ get_flow_for_default_audience: {
3114
3200
  params: {
3115
3201
  fetchPolicy: FetchPolicy.ReloadRevalidatingCacheData,
3116
3202
  },
@@ -3146,7 +3232,7 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3146
3232
  this.nonWaitingMethods = [
3147
3233
  'activate',
3148
3234
  'is_activated',
3149
- 'get_paywall_for_default_audience',
3235
+ 'get_flow_for_default_audience',
3150
3236
  'get_onboarding_for_default_audience',
3151
3237
  'set_log_level',
3152
3238
  'set_fallback',
@@ -3264,8 +3350,6 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3264
3350
  * so background activities can be performed and cache can be updated.
3265
3351
  *
3266
3352
  * @example
3267
- *
3268
- * @example
3269
3353
  * Usage with your user identifier from your system
3270
3354
  * ```typescript
3271
3355
  * await adapty.activate({
@@ -3398,39 +3482,37 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3398
3482
  return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyInstallationStatus');
3399
3483
  }
3400
3484
  /**
3401
- * Fetches the paywall by the specified placement.
3485
+ * Fetches the flow by the specified placement.
3402
3486
  *
3403
3487
  * @remarks
3404
3488
  * With Adapty, you can remotely configure the products and offers in your app
3405
- * by simply adding them to paywalls – no need for hardcoding them.
3489
+ * by simply adding them to flows – no need for hardcoding them.
3406
3490
  * The only thing you hardcode is the placement ID.
3407
- * This flexibility allows you to easily update paywalls, products, and offers,
3491
+ * This flexibility allows you to easily update flows, products, and offers,
3408
3492
  * or run A/B tests, all without the need for a new app release.
3409
3493
  *
3410
- * @param options - The options for fetching the paywall
3494
+ * @param options - The options for fetching the flow
3411
3495
  * @param options.placementId - The identifier of the desired placement. This is the value you specified when creating a placement in the Adapty Dashboard.
3412
- * @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.
3413
- * @param options.params - Optional. Additional parameters for fetching the paywall, including fetch policy and load timeout.
3414
- * @returns A promise that resolves with the requested {@link AdaptyPaywall}.
3415
- * @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.
3416
3499
  *
3417
3500
  * @example
3418
3501
  * ```typescript
3419
3502
  * import { adapty } from '@adapty/capacitor';
3420
3503
  *
3421
3504
  * try {
3422
- * const paywall = await adapty.getPaywall({
3505
+ * const flow = await adapty.getFlow({
3423
3506
  * placementId: 'YOUR_PLACEMENT_ID',
3424
- * locale: 'en',
3425
3507
  * });
3426
- * console.log('Paywall fetched successfully');
3508
+ * console.log('Flow fetched successfully');
3427
3509
  * } catch (error) {
3428
- * console.error('Failed to fetch paywall:', error);
3510
+ * console.error('Failed to fetch flow:', error);
3429
3511
  * }
3430
3512
  * ```
3431
3513
  */
3432
- async getPaywall(options) {
3433
- const method = 'get_paywall';
3514
+ async getFlow(options) {
3515
+ const method = 'get_flow';
3434
3516
  const optionsWithDefault = mergeOptions(options, this.options[method]);
3435
3517
  const params = optionsWithDefault.params;
3436
3518
  const ctx = new LogContext();
@@ -3440,54 +3522,51 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3440
3522
  method,
3441
3523
  placement_id: optionsWithDefault.placementId,
3442
3524
  load_timeout: params.loadTimeoutMs / 1000,
3443
- locale: optionsWithDefault.locale,
3444
3525
  fetch_policy: params.fetchPolicy === 'return_cache_data_if_not_expired_else_load'
3445
3526
  ? { type: params.fetchPolicy, max_age: params.maxAgeSeconds }
3446
3527
  : { type: params.fetchPolicy },
3447
3528
  };
3448
3529
  const args = filterUndefined(argsWithUndefined);
3449
- return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyPaywall');
3530
+ return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyFlow');
3450
3531
  }
3451
3532
  /**
3452
- * 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.
3453
3534
  *
3454
3535
  * @remarks
3455
3536
  * With Adapty, you can remotely configure the products and offers in your app
3456
- * by simply adding them to paywalls – no need for hardcoding them.
3537
+ * by simply adding them to flows – no need for hardcoding them.
3457
3538
  * The only thing you hardcode is the placement ID.
3458
3539
  *
3459
- * However, it's crucial to understand that the recommended approach is to fetch the paywall
3460
- * through the placement ID by the {@link getPaywall} method.
3461
- * 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:
3462
3543
  * - Potential backward compatibility issues
3463
- * - Loss of targeting (all users see the same paywall)
3544
+ * - Loss of targeting (all users see the same flow)
3464
3545
  *
3465
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.
3466
3547
  *
3467
- * @param options - The options for fetching the paywall
3548
+ * @param options - The options for fetching the flow
3468
3549
  * @param options.placementId - The identifier of the desired placement.
3469
- * @param options.locale - Optional. The identifier of the paywall localization. Default: `'en'`.
3470
- * @param options.params - Optional. Additional parameters for fetching the paywall.
3471
- * @returns A promise that resolves with the requested {@link AdaptyPaywall}.
3472
- * @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.
3473
3553
  *
3474
3554
  * @example
3475
3555
  * ```typescript
3476
3556
  * import { adapty } from '@adapty/capacitor';
3477
3557
  *
3478
3558
  * try {
3479
- * const paywall = await adapty.getPaywallForDefaultAudience({
3559
+ * const flow = await adapty.getFlowForDefaultAudience({
3480
3560
  * placementId: 'YOUR_PLACEMENT_ID',
3481
- * locale: 'en',
3482
3561
  * });
3483
3562
  * } catch (error) {
3484
- * console.error('Failed to fetch paywall:', error);
3563
+ * console.error('Failed to fetch flow:', error);
3485
3564
  * }
3486
3565
  * ```
3487
3566
  */
3488
- async getPaywallForDefaultAudience(options) {
3567
+ async getFlowForDefaultAudience(options) {
3489
3568
  var _a;
3490
- const method = 'get_paywall_for_default_audience';
3569
+ const method = 'get_flow_for_default_audience';
3491
3570
  const optionsWithDefault = mergeOptions(options, this.options[method]);
3492
3571
  const params = optionsWithDefault.params;
3493
3572
  const ctx = new LogContext();
@@ -3496,20 +3575,19 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3496
3575
  const argsWithUndefined = {
3497
3576
  method,
3498
3577
  placement_id: optionsWithDefault.placementId,
3499
- locale: optionsWithDefault.locale,
3500
3578
  fetch_policy: params.fetchPolicy === 'return_cache_data_if_not_expired_else_load'
3501
3579
  ? { type: params.fetchPolicy, max_age: params.maxAgeSeconds }
3502
3580
  : { type: (_a = params.fetchPolicy) !== null && _a !== void 0 ? _a : 'reload_revalidating_cache_data' },
3503
3581
  };
3504
3582
  const args = filterUndefined(argsWithUndefined);
3505
- return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyPaywall');
3583
+ return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyFlow');
3506
3584
  }
3507
3585
  /**
3508
- * Fetches a list of products associated with a provided paywall.
3586
+ * Fetches a list of products associated with a provided flow.
3509
3587
  *
3510
3588
  * @param options - The options object
3511
- * @param options.paywall - A paywall to fetch products for. You can get it using {@link getPaywall} method.
3512
- * @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.
3513
3591
  * @throws Error if an error occurs while fetching products.
3514
3592
  *
3515
3593
  * @example
@@ -3517,8 +3595,8 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3517
3595
  * import { adapty } from '@adapty/capacitor';
3518
3596
  *
3519
3597
  * try {
3520
- * const paywall = await adapty.getPaywall({ placementId: 'YOUR_PLACEMENT_ID' });
3521
- * const products = await adapty.getPaywallProducts({ paywall });
3598
+ * const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
3599
+ * const products = await adapty.getPaywallProducts({ flow });
3522
3600
  * console.log('Products:', products);
3523
3601
  * } catch (error) {
3524
3602
  * console.error('Failed to fetch products:', error);
@@ -3530,10 +3608,10 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3530
3608
  const ctx = new LogContext();
3531
3609
  const log = ctx.call({ methodName: method });
3532
3610
  log.start(() => ({ options }));
3533
- const paywallCoder = coderFactory.createPaywallCoder();
3611
+ const coder = coderFactory.createFlowCoder();
3534
3612
  const argsWithUndefined = {
3535
3613
  method,
3536
- paywall: this.encodeWithLogging(paywallCoder, options.paywall, 'AdaptyPaywall', ctx),
3614
+ flow: this.encodeWithLogging(coder, options.flow, 'AdaptyFlow', ctx),
3537
3615
  };
3538
3616
  const args = filterUndefined(argsWithUndefined);
3539
3617
  return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'Array<AdaptyPaywallProduct>');
@@ -3541,6 +3619,8 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3541
3619
  /**
3542
3620
  * Fetches the onboarding by the specified placement.
3543
3621
  *
3622
+ * @deprecated Since 4.0.0. Migrate onboardings to the Flow Builder API.
3623
+ *
3544
3624
  * @remarks
3545
3625
  * When you create an onboarding with the no-code builder, it's stored as a container with configuration
3546
3626
  * that your app needs to fetch and display. This container manages the entire experience - what content appears,
@@ -3594,6 +3674,8 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3594
3674
  /**
3595
3675
  * Fetches the onboarding of the specified placement for the **All Users** audience.
3596
3676
  *
3677
+ * @deprecated Since 4.0.0. Migrate onboardings to the Flow Builder API.
3678
+ *
3597
3679
  * @remarks
3598
3680
  * It's crucial to understand that the recommended approach is to fetch the onboarding
3599
3681
  * by the {@link getOnboarding} method. The `getOnboardingForDefaultAudience` method
@@ -3727,19 +3809,19 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3727
3809
  await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
3728
3810
  }
3729
3811
  /**
3730
- * Logs a paywall view event.
3812
+ * Logs a flow view event.
3731
3813
  *
3732
3814
  * @remarks
3733
- * Adapty helps you to measure the performance of the paywalls.
3734
- * We automatically collect all the metrics related to purchases except for custom paywall views.
3735
- * 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.
3736
3818
  *
3737
- * Whenever you show a paywall to your user,
3819
+ * Whenever you show a flow to your user,
3738
3820
  * call this function to log the event,
3739
- * and it will be accumulated in the paywall metrics.
3821
+ * and it will be accumulated in the flow metrics.
3740
3822
  *
3741
3823
  * @param options - The options object
3742
- * @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.
3743
3825
  * @returns A promise that resolves when the event is logged.
3744
3826
  * @throws Error if an error occurs while logging the event.
3745
3827
  *
@@ -3747,20 +3829,20 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3747
3829
  * ```typescript
3748
3830
  * import { adapty } from '@adapty/capacitor';
3749
3831
  *
3750
- * const paywall = await adapty.getPaywall({ placementId: 'YOUR_PLACEMENT_ID' });
3751
- * // ...after opening the paywall
3752
- * await adapty.logShowPaywall({ paywall });
3832
+ * const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
3833
+ * // ...after opening the flow
3834
+ * await adapty.logShowFlow({ flow });
3753
3835
  * ```
3754
3836
  */
3755
- async logShowPaywall(options) {
3756
- const method = 'log_show_paywall';
3837
+ async logShowFlow(options) {
3838
+ const method = 'log_show_flow';
3757
3839
  const ctx = new LogContext();
3758
3840
  const log = ctx.call({ methodName: method });
3759
3841
  log.start(() => ({ options }));
3760
- const paywallCoder = coderFactory.createPaywallCoder();
3842
+ const coder = coderFactory.createFlowCoder();
3761
3843
  const argsWithUndefined = {
3762
3844
  method,
3763
- paywall: this.encodeWithLogging(paywallCoder, options.paywall, 'AdaptyPaywall', ctx),
3845
+ flow: this.encodeWithLogging(coder, options.flow, 'AdaptyFlow', ctx),
3764
3846
  };
3765
3847
  const args = filterUndefined(argsWithUndefined);
3766
3848
  await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
@@ -3769,7 +3851,8 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3769
3851
  * Opens a web paywall in the default browser.
3770
3852
  *
3771
3853
  * @param options - The options object
3772
- * @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}).
3773
3856
  * @returns A promise that resolves when the web paywall is opened.
3774
3857
  * @throws Error if an error occurs while opening the web paywall.
3775
3858
  *
@@ -3778,8 +3861,8 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3778
3861
  * import { adapty } from '@adapty/capacitor';
3779
3862
  *
3780
3863
  * try {
3781
- * const paywall = await adapty.getPaywall({ placementId: 'YOUR_PLACEMENT_ID' });
3782
- * await adapty.openWebPaywall({ paywallOrProduct: paywall });
3864
+ * const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
3865
+ * await adapty.openWebPaywall({ paywallOrProduct: flow.paywalls[0] });
3783
3866
  * } catch (error) {
3784
3867
  * console.error('Failed to open web paywall:', error);
3785
3868
  * }
@@ -3790,11 +3873,11 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3790
3873
  const ctx = new LogContext();
3791
3874
  const log = ctx.call({ methodName: method });
3792
3875
  log.start(() => ({ options }));
3793
- const paywallCoder = coderFactory.createPaywallCoder();
3876
+ const flowPaywallCoder = coderFactory.createFlowPaywallCoder();
3794
3877
  const productCoder = coderFactory.createPaywallProductCoder();
3795
3878
  const argsWithUndefined = Object.assign(Object.assign({ method }, (this.isPaywallProduct(options.paywallOrProduct)
3796
3879
  ? { product: this.encodeWithLogging(productCoder, options.paywallOrProduct, 'AdaptyPaywallProduct', ctx) }
3797
- : { 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 } : {}));
3798
3881
  const args = filterUndefined(argsWithUndefined);
3799
3882
  await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
3800
3883
  }
@@ -3806,7 +3889,7 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3806
3889
  * You can use this URL in a custom web view or a browser.
3807
3890
  *
3808
3891
  * @param options - The options object
3809
- * @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.
3810
3893
  * @returns A promise that resolves with the web paywall URL.
3811
3894
  * @throws Error if an error occurs while creating the URL.
3812
3895
  *
@@ -3815,8 +3898,8 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3815
3898
  * import { adapty } from '@adapty/capacitor';
3816
3899
  *
3817
3900
  * try {
3818
- * const paywall = await adapty.getPaywall({ placementId: 'YOUR_PLACEMENT_ID' });
3819
- * 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] });
3820
3903
  * console.log('Web paywall URL:', url);
3821
3904
  * } catch (error) {
3822
3905
  * console.error('Failed to create web paywall URL:', error);
@@ -3828,14 +3911,80 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3828
3911
  const ctx = new LogContext();
3829
3912
  const log = ctx.call({ methodName: method });
3830
3913
  log.start(() => ({ options }));
3831
- const paywallCoder = coderFactory.createPaywallCoder();
3914
+ const flowPaywallCoder = coderFactory.createFlowPaywallCoder();
3832
3915
  const productCoder = coderFactory.createPaywallProductCoder();
3833
3916
  const argsWithUndefined = Object.assign({ method }, (this.isPaywallProduct(options.paywallOrProduct)
3834
3917
  ? { product: this.encodeWithLogging(productCoder, options.paywallOrProduct, 'AdaptyPaywallProduct', ctx) }
3835
- : { paywall: this.encodeWithLogging(paywallCoder, options.paywallOrProduct, 'AdaptyPaywall', ctx) }));
3918
+ : { paywall: this.encodeWithLogging(flowPaywallCoder, options.paywallOrProduct, 'AdaptyFlowPaywall', ctx) }));
3836
3919
  const args = filterUndefined(argsWithUndefined);
3837
3920
  return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'String');
3838
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
+ }
3839
3988
  /**
3840
3989
  * Logs out the current user.
3841
3990
  *
@@ -3962,7 +4111,7 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
3962
4111
  *
3963
4112
  * @param options - The options object
3964
4113
  * @param options.transactionId - The transaction ID of the purchase.
3965
- * @param options.variationId - Optional. The variation ID from the {@link AdaptyPaywall}.
4114
+ * @param options.variationId - Optional. The variation ID from the {@link AdaptyFlow}.
3966
4115
  * @returns A promise that resolves when the transaction is reported.
3967
4116
  * @throws Error if an error occurs while reporting the transaction.
3968
4117
  *
@@ -4397,7 +4546,14 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4397
4546
  }
4398
4547
  }
4399
4548
 
4400
- 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);
4401
4557
 
4402
4558
  /**
4403
4559
  * Base class for view event emitters that manages common event handling logic.
@@ -4410,6 +4566,14 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4410
4566
  this.internalHandlers = new Map();
4411
4567
  this.viewId = viewId;
4412
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
+ }
4413
4577
  async addListener(event, callback, onRequestClose) {
4414
4578
  const nativeEvent = this.getNativeEventForHandler(event);
4415
4579
  if (!nativeEvent) {
@@ -4478,6 +4642,10 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4478
4642
  if (!handlerName) {
4479
4643
  return;
4480
4644
  }
4645
+ if (this.handleSpecialEvent(handlerName, eventData)) {
4646
+ log.success(() => ({ message: 'Special event handled', handlerName }));
4647
+ return;
4648
+ }
4481
4649
  // 1. Client handler (single)
4482
4650
  const handlerData = this.handlers.get(handlerName);
4483
4651
  if (handlerData) {
@@ -4525,14 +4693,25 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4525
4693
  }
4526
4694
 
4527
4695
  /**
4528
- * PaywallViewEmitter manages event handlers for paywall view events.
4696
+ * FlowViewEmitter manages event handlers for flow view events.
4529
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).
4530
4705
  */
4531
- class PaywallViewEmitter extends BaseViewEmitter {
4706
+ class FlowViewEmitter extends BaseViewEmitter {
4707
+ constructor(viewId, adapty) {
4708
+ super(viewId);
4709
+ this.adapty = adapty;
4710
+ }
4532
4711
  parseEventData(rawEventData, ctx) {
4533
- const result = parsePaywallEvent(rawEventData);
4712
+ const result = parseFlowEvent(rawEventData);
4534
4713
  if (!result) {
4535
- throw new Error('Failed to parse paywall event');
4714
+ throw new Error('Failed to parse flow event');
4536
4715
  }
4537
4716
  return result;
4538
4717
  }
@@ -4540,135 +4719,192 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4540
4719
  return HANDLER_TO_NATIVE_EVENT$1[event];
4541
4720
  }
4542
4721
  getHandlerForNativeEvent(nativeEvent, eventData) {
4543
- const resolver = NATIVE_EVENT_RESOLVER$1[nativeEvent];
4544
- if (!resolver) {
4545
- return null;
4546
- }
4547
- 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;
4548
4724
  }
4549
4725
  extractCallbackArgs(handlerName, eventData) {
4550
- return extractCallbackArgs$1(handlerName, eventData);
4726
+ return extractFlowCallbackArgs(handlerName, eventData);
4551
4727
  }
4552
4728
  getEventViewId(eventData) {
4553
4729
  var _a, _b;
4554
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;
4555
4731
  }
4556
4732
  getEmitterName() {
4557
- return 'PaywallViewEmitter';
4733
+ return 'FlowViewEmitter';
4558
4734
  }
4559
- }
4560
- const NATIVE_EVENT_RESOLVER$1 = {
4561
- [PaywallEventId.DidPerformAction]: (event) => {
4562
- var _a;
4563
- if (event.id !== PaywallEventId.DidPerformAction) {
4564
- 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
+ }
4565
4773
  }
4566
- const actionMap = {
4567
- close: 'onCloseButtonPress',
4568
- system_back: 'onAndroidSystemBack',
4569
- open_url: 'onUrlPress',
4570
- 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}`));
4571
4801
  };
4572
- return (_a = actionMap[event.action.type]) !== null && _a !== void 0 ? _a : null;
4573
- },
4574
- [PaywallEventId.DidAppear]: () => 'onAppeared',
4575
- [PaywallEventId.DidDisappear]: () => 'onDisappeared',
4576
- [PaywallEventId.DidSelectProduct]: () => 'onProductSelected',
4577
- [PaywallEventId.DidStartPurchase]: () => 'onPurchaseStarted',
4578
- [PaywallEventId.DidFinishPurchase]: () => 'onPurchaseCompleted',
4579
- [PaywallEventId.DidFailPurchase]: () => 'onPurchaseFailed',
4580
- [PaywallEventId.DidStartRestore]: () => 'onRestoreStarted',
4581
- [PaywallEventId.DidFinishRestore]: () => 'onRestoreCompleted',
4582
- [PaywallEventId.DidFailRestore]: () => 'onRestoreFailed',
4583
- [PaywallEventId.DidFailRendering]: () => 'onRenderingFailed',
4584
- [PaywallEventId.DidFailLoadingProducts]: () => 'onLoadingProductsFailed',
4585
- [PaywallEventId.DidFinishWebPaymentNavigation]: () => 'onWebPaymentNavigationFinished',
4586
- };
4587
- const HANDLER_TO_NATIVE_EVENT$1 = {
4588
- onCloseButtonPress: PaywallEventId.DidPerformAction,
4589
- onAndroidSystemBack: PaywallEventId.DidPerformAction,
4590
- onUrlPress: PaywallEventId.DidPerformAction,
4591
- onCustomAction: PaywallEventId.DidPerformAction,
4592
- onProductSelected: PaywallEventId.DidSelectProduct,
4593
- onPurchaseStarted: PaywallEventId.DidStartPurchase,
4594
- onPurchaseCompleted: PaywallEventId.DidFinishPurchase,
4595
- onPurchaseFailed: PaywallEventId.DidFailPurchase,
4596
- onRestoreStarted: PaywallEventId.DidStartRestore,
4597
- onRestoreCompleted: PaywallEventId.DidFinishRestore,
4598
- onRestoreFailed: PaywallEventId.DidFailRestore,
4599
- onAppeared: PaywallEventId.DidAppear,
4600
- onDisappeared: PaywallEventId.DidDisappear,
4601
- onRenderingFailed: PaywallEventId.DidFailRendering,
4602
- onLoadingProductsFailed: PaywallEventId.DidFailLoadingProducts,
4603
- onWebPaymentNavigationFinished: PaywallEventId.DidFinishWebPaymentNavigation,
4604
- };
4605
- function extractCallbackArgs$1(handlerName, event) {
4606
- switch (event.id) {
4607
- case PaywallEventId.DidSelectProduct:
4608
- return [event.productId];
4609
- case PaywallEventId.DidStartPurchase:
4610
- return [event.product];
4611
- case PaywallEventId.DidFinishPurchase:
4612
- return [event.purchaseResult, event.product];
4613
- case PaywallEventId.DidFailPurchase:
4614
- return [event.error, event.product];
4615
- case PaywallEventId.DidFinishRestore:
4616
- return [event.profile];
4617
- case PaywallEventId.DidFailRestore:
4618
- case PaywallEventId.DidFailRendering:
4619
- case PaywallEventId.DidFailLoadingProducts:
4620
- return [event.error];
4621
- case PaywallEventId.DidPerformAction:
4622
- if (handlerName === 'onUrlPress' && event.action.type === 'open_url') {
4623
- 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 })));
4624
4809
  }
4625
- if (handlerName === 'onCustomAction' && event.action.type === 'custom') {
4626
- 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 })));
4627
4834
  }
4628
- return [];
4629
- case PaywallEventId.DidFinishWebPaymentNavigation:
4630
- return [event.product, event.error];
4631
- case PaywallEventId.DidAppear:
4632
- case PaywallEventId.DidDisappear:
4633
- case PaywallEventId.DidStartRestore:
4634
- return [];
4835
+ }
4836
+ catch (error) {
4837
+ Log.warn('observer_restore_handler_failed', () => `onObserverRestoreInitiated handler threw: ${error}`, () => ({ error }));
4838
+ }
4635
4839
  }
4636
4840
  }
4637
4841
 
4638
4842
  /**
4639
- * 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
4640
4849
  */
4641
- const DEFAULT_EVENT_HANDLERS = {
4850
+ const DEFAULT_FLOW_EVENT_HANDLERS = {
4642
4851
  onCloseButtonPress: () => true,
4643
- 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.
4644
4856
  onUrlPress: (url, openIn) => {
4645
- if (openIn === 'browser_in_app') {
4646
- Log.warn('onUrlPress', () => 'open_in=browser_in_app is not supported by the default onUrlPress handler. Override onUrlPress to support an in-app browser.');
4647
- }
4648
- if (typeof window !== 'undefined') {
4649
- try {
4650
- window.open(new URL(url), '_blank');
4651
- }
4652
- catch (_a) {
4653
- Log.warn('onUrlPress', () => `Invalid URL: ${url}`);
4654
- }
4655
- }
4656
- 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
4657
4861
  },
4658
4862
  onCustomAction: () => false,
4659
4863
  onProductSelected: () => false,
4660
4864
  onPurchaseStarted: () => false,
4661
- onPurchaseCompleted: (purchaseResult) => (purchaseResult === null || purchaseResult === void 0 ? void 0 : purchaseResult.type) !== 'user_cancelled',
4865
+ onPurchaseCompleted: () => false,
4662
4866
  onPurchaseFailed: () => false,
4663
4867
  onRestoreStarted: () => false,
4664
- onRestoreCompleted: () => true,
4868
+ onRestoreCompleted: () => false,
4665
4869
  onRestoreFailed: () => false,
4666
4870
  onAppeared: () => false,
4667
4871
  onDisappeared: () => false,
4668
- onRenderingFailed: () => true,
4872
+ onError: () => true,
4669
4873
  onLoadingProductsFailed: () => false,
4670
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
+ },
4671
4904
  };
4905
+ /**
4906
+ * @internal
4907
+ */
4672
4908
  const DEFAULT_ONBOARDING_EVENT_HANDLERS = {
4673
4909
  onClose: () => true,
4674
4910
  };
@@ -4676,44 +4912,47 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4676
4912
  const DEFAULT_PARAMS = {
4677
4913
  prefetchProducts: true,
4678
4914
  loadTimeoutMs: 5000,
4915
+ android: {
4916
+ enableSafeArea: true,
4917
+ },
4679
4918
  };
4680
4919
  /**
4681
- * Controller for managing paywall views.
4920
+ * Controller for managing flow views.
4682
4921
  *
4683
4922
  * @remarks
4684
- * This class provides methods to present, dismiss, and handle events for paywall views
4685
- * 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
4686
4925
  * rather than directly constructing this class.
4687
4926
  *
4688
4927
  * @public
4689
4928
  */
4690
- class PaywallViewController {
4929
+ class FlowViewController {
4691
4930
  /**
4692
4931
  * Intended way to create a ViewController instance.
4693
4932
  * It prepares a native controller to be presented
4694
4933
  * and creates reference between native controller and JS instance
4695
4934
  * @internal
4696
4935
  */
4697
- static async create(paywall, params, adaptyPlugin) {
4698
- const controller = new PaywallViewController(adaptyPlugin);
4936
+ static async create(flow, params, adaptyPlugin) {
4937
+ const controller = new FlowViewController(adaptyPlugin);
4699
4938
  const ctx = new LogContext();
4700
- const methodKey = 'adapty_ui_create_paywall_view';
4939
+ const methodKey = 'adapty_ui_create_flow_view';
4701
4940
  const log = ctx.call({ methodName: methodKey });
4702
- log.start(() => ({ paywall, params }));
4703
- const paywallCoder = coderFactory.createPaywallCoder();
4704
- const paramsCoder = coderFactory.createUiCreatePaywallViewParamsCoder();
4941
+ log.start(() => ({ flow, params }));
4942
+ const flowCoder = coderFactory.createFlowCoder();
4943
+ const paramsCoder = coderFactory.createUiCreateFlowViewParamsCoder();
4705
4944
  const paramsWithDefaults = Object.assign(Object.assign({}, DEFAULT_PARAMS), params);
4706
- 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));
4707
4946
  const result = (await controller.adaptyPlugin.handleMethodCall(methodKey, JSON.stringify(data), ctx, log));
4708
4947
  controller.id = result.id;
4709
- controller.viewEmitter = new PaywallViewEmitter(controller.id);
4710
- await controller.setEventHandlers(DEFAULT_EVENT_HANDLERS);
4948
+ controller.viewEmitter = new FlowViewEmitter(controller.id, controller.adaptyPlugin);
4949
+ await controller.setEventHandlers(DEFAULT_FLOW_EVENT_HANDLERS);
4711
4950
  return controller;
4712
4951
  }
4713
4952
  /**
4714
4953
  * Since constructors in JS cannot be async, it is not
4715
4954
  * preferred to create ViewControllers in direct way.
4716
- * Consider using @link{ViewController.create} instead
4955
+ * Consider using {@link FlowViewController.create} instead
4717
4956
  *
4718
4957
  * @internal
4719
4958
  */
@@ -4725,31 +4964,31 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4725
4964
  await this.dismiss();
4726
4965
  }
4727
4966
  catch (error) {
4728
- Log.warn('setEventHandlers', () => 'Failed to dismiss paywall', () => ({ error }));
4967
+ Log.warn('setEventHandlers', () => 'Failed to dismiss flow', () => ({ error }));
4729
4968
  }
4730
4969
  };
4731
4970
  this.adaptyPlugin = adaptyPlugin;
4732
4971
  }
4733
4972
  /**
4734
- * Presents the paywall view as a modal screen.
4973
+ * Presents the flow view as a modal screen.
4735
4974
  *
4736
4975
  * @remarks
4737
- * Calling `present` on an already visible paywall view will result in an error.
4738
- * The paywall will be displayed with the configured presentation style on iOS.
4739
- * 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.
4740
4979
  *
4741
4980
  * @param options - Optional presentation options
4742
4981
  * @param options.iosPresentationStyle - iOS presentation style. Available options: `'full_screen'` (default) or `'page_sheet'`. Only affects iOS platform.
4743
- * @returns A promise that resolves when the paywall is presented.
4982
+ * @returns A promise that resolves when the flow is presented.
4744
4983
  * @throws {@link AdaptyError} if the view reference is invalid or the view is already presented.
4745
4984
  *
4746
4985
  * @example
4747
4986
  * Present with default full-screen style
4748
4987
  * ```typescript
4749
- * import { adapty, createPaywallView } from '@adapty/capacitor';
4988
+ * import { adapty, createFlowView } from '@adapty/capacitor';
4750
4989
  *
4751
- * const paywall = await adapty.getPaywall({ placementId: 'YOUR_PLACEMENT_ID' });
4752
- * const view = await createPaywallView(paywall);
4990
+ * const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
4991
+ * const view = await createFlowView(flow);
4753
4992
  * await view.present();
4754
4993
  * ```
4755
4994
  *
@@ -4762,7 +5001,7 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4762
5001
  async present(options = {}) {
4763
5002
  var _a;
4764
5003
  const ctx = new LogContext();
4765
- const methodKey = 'adapty_ui_present_paywall_view';
5004
+ const methodKey = 'adapty_ui_present_flow_view';
4766
5005
  const log = ctx.call({ methodName: methodKey });
4767
5006
  log.start(() => ({ _id: this.id, iosPresentationStyle: options.iosPresentationStyle }));
4768
5007
  if (this.id === null) {
@@ -4779,20 +5018,20 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4779
5018
  await this.adaptyPlugin.handleMethodCall(methodKey, JSON.stringify(data), ctx, log);
4780
5019
  }
4781
5020
  /**
4782
- * Dismisses the paywall view.
5021
+ * Dismisses the flow view.
4783
5022
  *
4784
5023
  * @remarks
4785
- * This method closes the paywall and cleans up associated resources.
5024
+ * This method closes the flow and cleans up associated resources.
4786
5025
  * After dismissing, the view controller instance cannot be reused.
4787
5026
  *
4788
- * @returns A promise that resolves when the paywall is dismissed.
5027
+ * @returns A promise that resolves when the flow is dismissed.
4789
5028
  * @throws {@link AdaptyError} if the view reference is invalid.
4790
5029
  *
4791
5030
  * @example
4792
5031
  * ```typescript
4793
- * import { createPaywallView } from '@adapty/capacitor';
5032
+ * import { createFlowView } from '@adapty/capacitor';
4794
5033
  *
4795
- * const view = await createPaywallView(paywall);
5034
+ * const view = await createFlowView(flow);
4796
5035
  * await view.present();
4797
5036
  * // ... later
4798
5037
  * await view.dismiss();
@@ -4800,7 +5039,7 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4800
5039
  */
4801
5040
  async dismiss() {
4802
5041
  const ctx = new LogContext();
4803
- const methodKey = 'adapty_ui_dismiss_paywall_view';
5042
+ const methodKey = 'adapty_ui_dismiss_flow_view';
4804
5043
  const log = ctx.call({ methodName: methodKey });
4805
5044
  log.start(() => ({ _id: this.id }));
4806
5045
  if (this.id === null) {
@@ -4821,7 +5060,7 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4821
5060
  * Displays a dialog to the user.
4822
5061
  *
4823
5062
  * @remarks
4824
- * Use this method to show custom dialogs within the paywall flow.
5063
+ * Use this method to show custom dialogs within the flow.
4825
5064
  * If you provide two actions in the config, the primary action should cancel the operation
4826
5065
  * and leave things unchanged, while the secondary action should confirm the operation.
4827
5066
  *
@@ -4873,20 +5112,20 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4873
5112
  return await this.adaptyPlugin.handleMethodCall(methodKey, JSON.stringify(data), ctx, log);
4874
5113
  }
4875
5114
  /**
4876
- * Registers event handlers for paywall UI events.
5115
+ * Registers event handlers for flow UI events.
4877
5116
  *
4878
5117
  * @remarks
4879
5118
  * Each event type can have only one handler — new handlers replace existing ones.
4880
- * Default handlers are registered automatically in {@link createPaywallView} and provide standard closing behavior:
4881
- * - `onCloseButtonPress` - closes the paywall
4882
- * - `onAndroidSystemBack` - closes the paywall (Android only)
4883
- * - `onRestoreCompleted` - closes the paywall after successful restore
4884
- * - `onRenderingFailed` - closes the paywall when rendering fails
4885
- * - `onPurchaseCompleted` - closes the paywall after successful purchase
4886
- *
4887
- * If you want to override these listeners, we strongly recommend returning `true`
4888
- * (or `purchaseResult.type !== 'user_cancelled'` in case of `onPurchaseCompleted`)
4889
- * 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).
4890
5129
  *
4891
5130
  * Calling this method multiple times will replace previously registered handlers for provided events.
4892
5131
  *
@@ -4898,9 +5137,9 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4898
5137
  * @example
4899
5138
  * Register custom event handlers
4900
5139
  * ```typescript
4901
- * import { createPaywallView } from '@adapty/capacitor';
5140
+ * import { createFlowView } from '@adapty/capacitor';
4902
5141
  *
4903
- * const view = await createPaywallView(paywall);
5142
+ * const view = await createFlowView(flow);
4904
5143
  *
4905
5144
  * const unsubscribe = await view.setEventHandlers({
4906
5145
  * onPurchaseStarted: (product) => {
@@ -4908,7 +5147,7 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4908
5147
  * },
4909
5148
  * onPurchaseCompleted: (result) => {
4910
5149
  * console.log('Purchase completed:', result.type);
4911
- * // Return true to keep default closing behavior
5150
+ * // Return true to close the view after purchase (default keeps it open)
4912
5151
  * return result.type !== 'user_cancelled';
4913
5152
  * },
4914
5153
  * onPurchaseFailed: (error) => {
@@ -4934,13 +5173,13 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4934
5173
  });
4935
5174
  }
4936
5175
  Log.verbose('setEventHandlers', () => 'Registering event handlers for view', () => ({ id: this.id }));
4937
- 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);
4938
5177
  this.viewEmitter = viewEmitter;
4939
5178
  const wrappedErrorLogEventHandlers = mapValues(eventHandlers, (handler, eventName) => handler && typeof handler === 'function'
4940
- ? withErrorContext(handler, eventName, 'PaywallViewController')
5179
+ ? withErrorContext(handler, eventName, 'FlowViewController')
4941
5180
  : undefined);
4942
5181
  // Merge with defaults to ensure default behavior is preserved after unsubscribe/resubscribe cycles
4943
- const finalEventHandlers = Object.assign(Object.assign({}, DEFAULT_EVENT_HANDLERS), wrappedErrorLogEventHandlers);
5182
+ const finalEventHandlers = Object.assign(Object.assign({}, DEFAULT_FLOW_EVENT_HANDLERS), wrappedErrorLogEventHandlers);
4944
5183
  for (const [eventName, handler] of Object.entries(finalEventHandlers)) {
4945
5184
  if (handler && typeof handler === 'function') {
4946
5185
  try {
@@ -4974,7 +5213,7 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
4974
5213
  *
4975
5214
  * @example
4976
5215
  * ```typescript
4977
- * const view = await createPaywallView(paywall);
5216
+ * const view = await createFlowView(flow);
4978
5217
  * await view.setEventHandlers({ onPurchaseCompleted: handlePurchase });
4979
5218
  *
4980
5219
  * // Later, clear all handlers
@@ -5068,6 +5307,8 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
5068
5307
  /**
5069
5308
  * Controller for managing onboarding views.
5070
5309
  *
5310
+ * @deprecated Since 4.0.0. Migrate onboardings to the Flow Builder API.
5311
+ *
5071
5312
  * @remarks
5072
5313
  * This class provides methods to present, dismiss, and handle events for onboarding views
5073
5314
  * created with the Onboarding Builder. Create instances using the {@link createOnboardingView} function
@@ -5100,7 +5341,7 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
5100
5341
  /**
5101
5342
  * Since constructors in JS cannot be async, it is not
5102
5343
  * preferred to create ViewControllers in direct way.
5103
- * Consider using @link{OnboardingViewController.create} instead
5344
+ * Consider using {@link OnboardingViewController.create} instead
5104
5345
  *
5105
5346
  * @internal
5106
5347
  */
@@ -5229,11 +5470,11 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
5229
5470
  * // Return true to keep default closing behavior
5230
5471
  * return true;
5231
5472
  * },
5232
- * onActionPerformed: (action) => {
5233
- * console.log('Action performed:', action.name);
5473
+ * onCustom: (actionId, meta) => {
5474
+ * console.log('Custom action:', actionId, meta);
5234
5475
  * },
5235
- * onProductSelected: (product) => {
5236
- * console.log('Product selected:', product.vendorProductId);
5476
+ * onStateUpdated: (action, meta) => {
5477
+ * console.log('State updated:', action, meta);
5237
5478
  * }
5238
5479
  * });
5239
5480
  *
@@ -5307,31 +5548,18 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
5307
5548
  }
5308
5549
  }
5309
5550
 
5310
- const adaptyPlugin$1 = new Adapty();
5311
5551
  /**
5312
- * Creates a paywall view controller.
5313
- * 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.
5314
5553
  *
5315
- * @see {@link https://adapty.io/docs/capacitor-present-paywalls | [DOC] Creating a paywall view}
5316
- *
5317
- * @param {AdaptyPaywall} paywall - paywall that you want to present.
5318
- * @param {CreatePaywallViewParamsInput | undefined} [params] - additional params.
5319
- * @returns {Promise<PaywallViewController>} ViewController — A promise that resolves to a ViewController instance.
5320
- *
5321
- * @example
5322
- * ```ts
5323
- * const paywall = await adapty.getPaywall("MY_PAYWALL");
5324
- * const view = await createPaywallView(paywall);
5325
- * view.present();
5326
- * ```
5554
+ * @see {@link https://adapty.io/docs/capacitor-present-paywalls | [DOC] Creating a flow view}
5327
5555
  *
5328
- * @throws {AdaptyError} If paywall is not found,
5329
- * does not have a no-code view configured
5330
- * 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.
5331
5560
  */
5332
- async function createPaywallView(paywall, params = {}) {
5333
- const controller = await PaywallViewController.create(paywall, params, adaptyPlugin$1);
5334
- return controller;
5561
+ async function createFlowView(flow, params = {}) {
5562
+ return FlowViewController.create(flow, params, adapty);
5335
5563
  }
5336
5564
 
5337
5565
  const adaptyPlugin = new Adapty();
@@ -5339,6 +5567,8 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
5339
5567
  * Creates an onboarding view controller.
5340
5568
  * You can use it to further configure a view or present it.
5341
5569
  *
5570
+ * @deprecated Since 4.0.0. Migrate onboardings to the Flow Builder API.
5571
+ *
5342
5572
  * @see {@link https://adapty.io/docs/capacitor-get-onboardings | [DOC] Creating an onboarding view}
5343
5573
  *
5344
5574
  * @param {AdaptyOnboarding} onboarding - onboarding that you want to present.
@@ -5368,8 +5598,6 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
5368
5598
  return controller;
5369
5599
  }
5370
5600
 
5371
- const adapty = new Adapty();
5372
-
5373
5601
  class AdaptyCapacitorPluginWeb extends core.WebPlugin {
5374
5602
  addListener(eventName, listenerFunc) {
5375
5603
  return super.addListener(eventName, listenerFunc);
@@ -5392,26 +5620,27 @@ var capacitorAdaptyCapacitorPlugin = (function (exports, core) {
5392
5620
 
5393
5621
  exports.AdaptyAndroidSubscriptionUpdateReplacementMode = AdaptyAndroidSubscriptionUpdateReplacementMode;
5394
5622
  exports.AdaptyError = AdaptyError;
5623
+ exports.AdaptyUiDialogActionType = AdaptyUiDialogActionType;
5395
5624
  exports.AppTrackingTransparencyStatus = AppTrackingTransparencyStatus;
5396
5625
  exports.CancellationReason = CancellationReason;
5397
5626
  exports.ErrorCode = ErrorCode;
5398
5627
  exports.ErrorCodeName = ErrorCodeName;
5399
5628
  exports.FetchPolicy = FetchPolicy;
5629
+ exports.FlowEventId = FlowEventId;
5630
+ exports.FlowViewController = FlowViewController;
5400
5631
  exports.Gender = Gender;
5401
5632
  exports.LogLevel = LogLevel;
5402
5633
  exports.OfferType = OfferType;
5403
5634
  exports.OnboardingEventId = OnboardingEventId;
5404
5635
  exports.OnboardingViewController = OnboardingViewController;
5405
- exports.PaywallEventId = PaywallEventId;
5406
- exports.PaywallViewController = PaywallViewController;
5407
5636
  exports.ProductPeriod = ProductPeriod;
5408
5637
  exports.RefundPreference = RefundPreference;
5409
5638
  exports.VendorStore = VendorStore;
5410
5639
  exports.WebPresentation = WebPresentation;
5411
5640
  exports.adapty = adapty;
5412
5641
  exports.consoleLogSink = consoleLogSink;
5642
+ exports.createFlowView = createFlowView;
5413
5643
  exports.createOnboardingView = createOnboardingView;
5414
- exports.createPaywallView = createPaywallView;
5415
5644
  exports.getErrorCode = getErrorCode;
5416
5645
  exports.getErrorPrompt = getErrorPrompt;
5417
5646