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