@tryheliumai/paywall-sdk-react-native 0.1.2 → 0.1.4
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/lib/commonjs/native-interface.js +100 -25
- package/lib/commonjs/native-interface.js.map +1 -1
- package/lib/module/native-interface.js +100 -26
- package/lib/module/native-interface.js.map +1 -1
- package/lib/typescript/commonjs/src/native-interface.d.ts +7 -2
- package/lib/typescript/commonjs/src/native-interface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +1 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/native-interface.d.ts +7 -2
- package/lib/typescript/module/src/native-interface.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +1 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/native-interface.tsx +102 -30
- package/src/types.ts +1 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.presentUpsell = exports.initialize = exports.hideUpsell = exports.UpsellView = exports.HeliumProvider = exports.HELIUM_CTA_NAMES = void 0;
|
|
6
|
+
exports.useHelium = exports.presentUpsell = exports.initialize = exports.hideUpsell = exports.UpsellView = exports.HeliumProvider = exports.HELIUM_CTA_NAMES = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -14,8 +14,37 @@ const {
|
|
|
14
14
|
} = _reactNative.NativeModules;
|
|
15
15
|
const heliumEventEmitter = new _reactNative.NativeEventEmitter(HeliumBridge);
|
|
16
16
|
let isProviderMounted = false;
|
|
17
|
+
// Add a promise to track when the provider is mounted
|
|
18
|
+
let providerMountedPromise;
|
|
19
|
+
let resolveProviderMounted;
|
|
20
|
+
|
|
21
|
+
// Initialize the promise
|
|
22
|
+
providerMountedPromise = new Promise(resolve => {
|
|
23
|
+
resolveProviderMounted = resolve;
|
|
24
|
+
// If provider is already mounted, resolve immediately
|
|
25
|
+
if (isProviderMounted) {
|
|
26
|
+
resolve();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Create a context for the download status
|
|
31
|
+
|
|
32
|
+
const HeliumContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
33
|
+
|
|
34
|
+
// Create a ref to store the context setter
|
|
35
|
+
let setDownloadStatusRef = null;
|
|
36
|
+
|
|
37
|
+
// Hook to use the Helium context
|
|
38
|
+
const useHelium = () => {
|
|
39
|
+
const context = (0, _react.useContext)(HeliumContext);
|
|
40
|
+
if (!context) {
|
|
41
|
+
throw new Error('useHelium must be used within a HeliumProvider');
|
|
42
|
+
}
|
|
43
|
+
return context;
|
|
44
|
+
};
|
|
17
45
|
|
|
18
46
|
// Move NativeHeliumUpsellView to a singleton pattern
|
|
47
|
+
exports.useHelium = useHelium;
|
|
19
48
|
let NativeHeliumUpsellView = null;
|
|
20
49
|
const getNativeHeliumUpsellView = () => {
|
|
21
50
|
if (!NativeHeliumUpsellView) {
|
|
@@ -25,19 +54,37 @@ const getNativeHeliumUpsellView = () => {
|
|
|
25
54
|
};
|
|
26
55
|
// Create a ref to store the fallback view reference
|
|
27
56
|
const fallbackRef = /*#__PURE__*/(0, _react.createRef)();
|
|
57
|
+
// Store a reference to the fallback view component
|
|
58
|
+
let FallbackViewComponent = null;
|
|
28
59
|
|
|
29
60
|
// Provider component to be rendered at the app root
|
|
30
61
|
const HeliumProvider = ({
|
|
31
62
|
children,
|
|
32
63
|
fallbackView: FallbackView
|
|
33
64
|
}) => {
|
|
65
|
+
// Add state for download status
|
|
66
|
+
const [downloadStatus, setDownloadStatus] = (0, _react.useState)('notStarted');
|
|
67
|
+
|
|
68
|
+
// Store the setter in the ref so it can be accessed outside of components
|
|
69
|
+
(0, _react.useEffect)(() => {
|
|
70
|
+
setDownloadStatusRef = setDownloadStatus;
|
|
71
|
+
// Store the fallback view component for later use
|
|
72
|
+
FallbackViewComponent = FallbackView;
|
|
73
|
+
}, [setDownloadStatus, FallbackView]);
|
|
34
74
|
(0, _react.useEffect)(() => {
|
|
35
75
|
isProviderMounted = true;
|
|
76
|
+
// Resolve the promise when the provider is mounted
|
|
77
|
+
resolveProviderMounted();
|
|
36
78
|
return () => {
|
|
37
79
|
isProviderMounted = false;
|
|
80
|
+
setDownloadStatusRef = null;
|
|
38
81
|
};
|
|
39
82
|
}, []);
|
|
40
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
83
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(HeliumContext.Provider, {
|
|
84
|
+
value: {
|
|
85
|
+
downloadStatus,
|
|
86
|
+
setDownloadStatus
|
|
87
|
+
},
|
|
41
88
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
42
89
|
ref: fallbackRef,
|
|
43
90
|
collapsable: false,
|
|
@@ -51,37 +98,31 @@ const HeliumProvider = ({
|
|
|
51
98
|
|
|
52
99
|
// Update initialize to accept config
|
|
53
100
|
exports.HeliumProvider = HeliumProvider;
|
|
54
|
-
const initialize = (heliumCallbacks, config = {}) => {
|
|
101
|
+
const initialize = async (heliumCallbacks, config = {}) => {
|
|
102
|
+
// Wait for the provider to be mounted if it's not already
|
|
55
103
|
if (!isProviderMounted) {
|
|
56
|
-
|
|
104
|
+
await providerMountedPromise;
|
|
57
105
|
}
|
|
58
106
|
const viewTag = (0, _reactNative.findNodeHandle)(fallbackRef.current);
|
|
59
107
|
if (!viewTag) {
|
|
60
108
|
throw new Error('Failed to get fallback view reference. Make sure HeliumProvider is mounted with a fallback view.');
|
|
61
109
|
}
|
|
62
110
|
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
transactionId: event.transactionId,
|
|
68
|
-
status: status
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// Set up restore purchases event listener
|
|
73
|
-
heliumEventEmitter.addListener('helium_restore_purchases', async event => {
|
|
74
|
-
const success = await heliumCallbacks.restorePurchases();
|
|
75
|
-
HeliumBridge.handleRestoreResponse({
|
|
76
|
-
transactionId: event.transactionId,
|
|
77
|
-
status: success ? 'restored' : 'failed'
|
|
78
|
-
});
|
|
79
|
-
});
|
|
111
|
+
// Update download status to inProgress
|
|
112
|
+
if (setDownloadStatusRef) {
|
|
113
|
+
setDownloadStatusRef('inProgress');
|
|
114
|
+
}
|
|
80
115
|
|
|
81
|
-
// Set up
|
|
116
|
+
// Set up event listeners
|
|
82
117
|
heliumEventEmitter.addListener('helium_paywall_event', event => {
|
|
83
|
-
|
|
84
|
-
|
|
118
|
+
// Handle download status events
|
|
119
|
+
if (event.type === 'paywallsDownloadSuccess' && setDownloadStatusRef) {
|
|
120
|
+
setDownloadStatusRef('success');
|
|
121
|
+
} else if (event.type === 'paywallsDownloadError' && setDownloadStatusRef) {
|
|
122
|
+
setDownloadStatusRef('failed');
|
|
123
|
+
}
|
|
124
|
+
// Handle fallback view visibility
|
|
125
|
+
else if (event.type === 'paywallOpen' && event.paywallTemplateName === 'Fallback') {
|
|
85
126
|
if (fallbackRef.current) {
|
|
86
127
|
fallbackRef.current.setNativeProps({
|
|
87
128
|
style: {
|
|
@@ -90,7 +131,6 @@ const initialize = (heliumCallbacks, config = {}) => {
|
|
|
90
131
|
});
|
|
91
132
|
}
|
|
92
133
|
} else if (event.type === 'paywallClose' && event.paywallTemplateName === 'Fallback') {
|
|
93
|
-
// Update fallback view visibility if the ref exists
|
|
94
134
|
if (fallbackRef.current) {
|
|
95
135
|
fallbackRef.current.setNativeProps({
|
|
96
136
|
style: {
|
|
@@ -99,9 +139,29 @@ const initialize = (heliumCallbacks, config = {}) => {
|
|
|
99
139
|
});
|
|
100
140
|
}
|
|
101
141
|
}
|
|
142
|
+
|
|
143
|
+
// Forward all events to the callback
|
|
102
144
|
heliumCallbacks.onHeliumPaywallEvent(event);
|
|
103
145
|
});
|
|
104
146
|
|
|
147
|
+
// Set up purchase event listener
|
|
148
|
+
heliumEventEmitter.addListener('helium_make_purchase', async event => {
|
|
149
|
+
const status = await heliumCallbacks.makePurchase(event.productId);
|
|
150
|
+
HeliumBridge.handlePurchaseResponse({
|
|
151
|
+
transactionId: event.transactionId,
|
|
152
|
+
status: status
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Set up restore purchases event listener
|
|
157
|
+
heliumEventEmitter.addListener('helium_restore_purchases', async event => {
|
|
158
|
+
const success = await heliumCallbacks.restorePurchases();
|
|
159
|
+
HeliumBridge.handleRestoreResponse({
|
|
160
|
+
transactionId: event.transactionId,
|
|
161
|
+
status: success ? 'restored' : 'failed'
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
105
165
|
// Initialize the bridge with merged config
|
|
106
166
|
HeliumBridge.initialize({
|
|
107
167
|
apiKey: config.apiKey,
|
|
@@ -131,7 +191,22 @@ const UpsellView = ({
|
|
|
131
191
|
trigger,
|
|
132
192
|
style
|
|
133
193
|
}) => {
|
|
194
|
+
const {
|
|
195
|
+
downloadStatus
|
|
196
|
+
} = useHelium();
|
|
134
197
|
const NativeView = getNativeHeliumUpsellView();
|
|
198
|
+
|
|
199
|
+
// If download status is notStarted or inProgress, we haven't fully initialized yet
|
|
200
|
+
// In this case, we should render the fallback view
|
|
201
|
+
if (downloadStatus === 'notStarted' || downloadStatus === 'inProgress' || downloadStatus === 'failed') {
|
|
202
|
+
// If we have a fallback view component, render it
|
|
203
|
+
if (FallbackViewComponent) {
|
|
204
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(FallbackViewComponent, {});
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Otherwise, render the native view
|
|
135
210
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeView, {
|
|
136
211
|
trigger: trigger,
|
|
137
212
|
style: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_react","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","HeliumBridge","NativeModules","heliumEventEmitter","NativeEventEmitter","isProviderMounted","NativeHeliumUpsellView","getNativeHeliumUpsellView","requireNativeComponent","fallbackRef","createRef","HeliumProvider","children","fallbackView","FallbackView","useEffect","jsxs","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_react","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","HeliumBridge","NativeModules","heliumEventEmitter","NativeEventEmitter","isProviderMounted","providerMountedPromise","resolveProviderMounted","Promise","resolve","HeliumContext","createContext","undefined","setDownloadStatusRef","useHelium","context","useContext","Error","exports","NativeHeliumUpsellView","getNativeHeliumUpsellView","requireNativeComponent","fallbackRef","createRef","FallbackViewComponent","HeliumProvider","children","fallbackView","FallbackView","downloadStatus","setDownloadStatus","useState","useEffect","jsxs","Provider","value","jsx","View","ref","collapsable","style","display","initialize","heliumCallbacks","config","viewTag","findNodeHandle","current","addListener","event","type","paywallTemplateName","setNativeProps","onHeliumPaywallEvent","status","makePurchase","productId","handlePurchaseResponse","transactionId","success","restorePurchases","handleRestoreResponse","apiKey","fallbackPaywall","triggers","customUserId","customAPIEndpoint","customUserTraits","presentUpsell","triggerName","hideUpsell","UpsellView","trigger","NativeView","flex","HELIUM_CTA_NAMES","SCHEDULE_CALL","SUBSCRIBE_BUTTON"],"sourceRoot":"../../src","sources":["native-interface.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAyF,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AAO,IAAI;EACb;;EAEA;EACA,oBACE,IAAA5C,WAAA,CAAAwD,GAAA,EAACqC,UAAU;IACTD,OAAO,EAAEA,OAAQ;IACjBhC,KAAK,EAAE,CAAC;MAAEkC,IAAI,EAAE;IAAE,CAAC,EAAElC,KAAK;EAAE,CAC7B,CAAC;AAEN,CAAC;AAACtB,OAAA,CAAAqD,UAAA,GAAAA,UAAA;AAEK,MAAMI,gBAAgB,GAAAzD,OAAA,CAAAyD,gBAAA,GAAG;EAC9BC,aAAa,EAAE,eAAe;EAC9BC,gBAAgB,EAAE;AACpB,CAAC","ignoreList":[]}
|
|
@@ -1,13 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { findNodeHandle, NativeModules, View, NativeEventEmitter, requireNativeComponent } from 'react-native';
|
|
4
|
-
import React, { createRef, useEffect } from 'react';
|
|
5
|
-
import { jsx as _jsx,
|
|
4
|
+
import React, { createRef, useEffect, useState, createContext, useContext } from 'react';
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
6
|
const {
|
|
7
7
|
HeliumBridge
|
|
8
8
|
} = NativeModules;
|
|
9
9
|
const heliumEventEmitter = new NativeEventEmitter(HeliumBridge);
|
|
10
10
|
let isProviderMounted = false;
|
|
11
|
+
// Add a promise to track when the provider is mounted
|
|
12
|
+
let providerMountedPromise;
|
|
13
|
+
let resolveProviderMounted;
|
|
14
|
+
|
|
15
|
+
// Initialize the promise
|
|
16
|
+
providerMountedPromise = new Promise(resolve => {
|
|
17
|
+
resolveProviderMounted = resolve;
|
|
18
|
+
// If provider is already mounted, resolve immediately
|
|
19
|
+
if (isProviderMounted) {
|
|
20
|
+
resolve();
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Create a context for the download status
|
|
25
|
+
|
|
26
|
+
const HeliumContext = /*#__PURE__*/createContext(undefined);
|
|
27
|
+
|
|
28
|
+
// Create a ref to store the context setter
|
|
29
|
+
let setDownloadStatusRef = null;
|
|
30
|
+
|
|
31
|
+
// Hook to use the Helium context
|
|
32
|
+
export const useHelium = () => {
|
|
33
|
+
const context = useContext(HeliumContext);
|
|
34
|
+
if (!context) {
|
|
35
|
+
throw new Error('useHelium must be used within a HeliumProvider');
|
|
36
|
+
}
|
|
37
|
+
return context;
|
|
38
|
+
};
|
|
11
39
|
|
|
12
40
|
// Move NativeHeliumUpsellView to a singleton pattern
|
|
13
41
|
let NativeHeliumUpsellView = null;
|
|
@@ -19,19 +47,37 @@ const getNativeHeliumUpsellView = () => {
|
|
|
19
47
|
};
|
|
20
48
|
// Create a ref to store the fallback view reference
|
|
21
49
|
const fallbackRef = /*#__PURE__*/createRef();
|
|
50
|
+
// Store a reference to the fallback view component
|
|
51
|
+
let FallbackViewComponent = null;
|
|
22
52
|
|
|
23
53
|
// Provider component to be rendered at the app root
|
|
24
54
|
export const HeliumProvider = ({
|
|
25
55
|
children,
|
|
26
56
|
fallbackView: FallbackView
|
|
27
57
|
}) => {
|
|
58
|
+
// Add state for download status
|
|
59
|
+
const [downloadStatus, setDownloadStatus] = useState('notStarted');
|
|
60
|
+
|
|
61
|
+
// Store the setter in the ref so it can be accessed outside of components
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
setDownloadStatusRef = setDownloadStatus;
|
|
64
|
+
// Store the fallback view component for later use
|
|
65
|
+
FallbackViewComponent = FallbackView;
|
|
66
|
+
}, [setDownloadStatus, FallbackView]);
|
|
28
67
|
useEffect(() => {
|
|
29
68
|
isProviderMounted = true;
|
|
69
|
+
// Resolve the promise when the provider is mounted
|
|
70
|
+
resolveProviderMounted();
|
|
30
71
|
return () => {
|
|
31
72
|
isProviderMounted = false;
|
|
73
|
+
setDownloadStatusRef = null;
|
|
32
74
|
};
|
|
33
75
|
}, []);
|
|
34
|
-
return /*#__PURE__*/_jsxs(
|
|
76
|
+
return /*#__PURE__*/_jsxs(HeliumContext.Provider, {
|
|
77
|
+
value: {
|
|
78
|
+
downloadStatus,
|
|
79
|
+
setDownloadStatus
|
|
80
|
+
},
|
|
35
81
|
children: [/*#__PURE__*/_jsx(View, {
|
|
36
82
|
ref: fallbackRef,
|
|
37
83
|
collapsable: false,
|
|
@@ -44,37 +90,31 @@ export const HeliumProvider = ({
|
|
|
44
90
|
};
|
|
45
91
|
|
|
46
92
|
// Update initialize to accept config
|
|
47
|
-
export const initialize = (heliumCallbacks, config = {}) => {
|
|
93
|
+
export const initialize = async (heliumCallbacks, config = {}) => {
|
|
94
|
+
// Wait for the provider to be mounted if it's not already
|
|
48
95
|
if (!isProviderMounted) {
|
|
49
|
-
|
|
96
|
+
await providerMountedPromise;
|
|
50
97
|
}
|
|
51
98
|
const viewTag = findNodeHandle(fallbackRef.current);
|
|
52
99
|
if (!viewTag) {
|
|
53
100
|
throw new Error('Failed to get fallback view reference. Make sure HeliumProvider is mounted with a fallback view.');
|
|
54
101
|
}
|
|
55
102
|
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
transactionId: event.transactionId,
|
|
61
|
-
status: status
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Set up restore purchases event listener
|
|
66
|
-
heliumEventEmitter.addListener('helium_restore_purchases', async event => {
|
|
67
|
-
const success = await heliumCallbacks.restorePurchases();
|
|
68
|
-
HeliumBridge.handleRestoreResponse({
|
|
69
|
-
transactionId: event.transactionId,
|
|
70
|
-
status: success ? 'restored' : 'failed'
|
|
71
|
-
});
|
|
72
|
-
});
|
|
103
|
+
// Update download status to inProgress
|
|
104
|
+
if (setDownloadStatusRef) {
|
|
105
|
+
setDownloadStatusRef('inProgress');
|
|
106
|
+
}
|
|
73
107
|
|
|
74
|
-
// Set up
|
|
108
|
+
// Set up event listeners
|
|
75
109
|
heliumEventEmitter.addListener('helium_paywall_event', event => {
|
|
76
|
-
|
|
77
|
-
|
|
110
|
+
// Handle download status events
|
|
111
|
+
if (event.type === 'paywallsDownloadSuccess' && setDownloadStatusRef) {
|
|
112
|
+
setDownloadStatusRef('success');
|
|
113
|
+
} else if (event.type === 'paywallsDownloadError' && setDownloadStatusRef) {
|
|
114
|
+
setDownloadStatusRef('failed');
|
|
115
|
+
}
|
|
116
|
+
// Handle fallback view visibility
|
|
117
|
+
else if (event.type === 'paywallOpen' && event.paywallTemplateName === 'Fallback') {
|
|
78
118
|
if (fallbackRef.current) {
|
|
79
119
|
fallbackRef.current.setNativeProps({
|
|
80
120
|
style: {
|
|
@@ -83,7 +123,6 @@ export const initialize = (heliumCallbacks, config = {}) => {
|
|
|
83
123
|
});
|
|
84
124
|
}
|
|
85
125
|
} else if (event.type === 'paywallClose' && event.paywallTemplateName === 'Fallback') {
|
|
86
|
-
// Update fallback view visibility if the ref exists
|
|
87
126
|
if (fallbackRef.current) {
|
|
88
127
|
fallbackRef.current.setNativeProps({
|
|
89
128
|
style: {
|
|
@@ -92,9 +131,29 @@ export const initialize = (heliumCallbacks, config = {}) => {
|
|
|
92
131
|
});
|
|
93
132
|
}
|
|
94
133
|
}
|
|
134
|
+
|
|
135
|
+
// Forward all events to the callback
|
|
95
136
|
heliumCallbacks.onHeliumPaywallEvent(event);
|
|
96
137
|
});
|
|
97
138
|
|
|
139
|
+
// Set up purchase event listener
|
|
140
|
+
heliumEventEmitter.addListener('helium_make_purchase', async event => {
|
|
141
|
+
const status = await heliumCallbacks.makePurchase(event.productId);
|
|
142
|
+
HeliumBridge.handlePurchaseResponse({
|
|
143
|
+
transactionId: event.transactionId,
|
|
144
|
+
status: status
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Set up restore purchases event listener
|
|
149
|
+
heliumEventEmitter.addListener('helium_restore_purchases', async event => {
|
|
150
|
+
const success = await heliumCallbacks.restorePurchases();
|
|
151
|
+
HeliumBridge.handleRestoreResponse({
|
|
152
|
+
transactionId: event.transactionId,
|
|
153
|
+
status: success ? 'restored' : 'failed'
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
98
157
|
// Initialize the bridge with merged config
|
|
99
158
|
HeliumBridge.initialize({
|
|
100
159
|
apiKey: config.apiKey,
|
|
@@ -121,7 +180,22 @@ export const UpsellView = ({
|
|
|
121
180
|
trigger,
|
|
122
181
|
style
|
|
123
182
|
}) => {
|
|
183
|
+
const {
|
|
184
|
+
downloadStatus
|
|
185
|
+
} = useHelium();
|
|
124
186
|
const NativeView = getNativeHeliumUpsellView();
|
|
187
|
+
|
|
188
|
+
// If download status is notStarted or inProgress, we haven't fully initialized yet
|
|
189
|
+
// In this case, we should render the fallback view
|
|
190
|
+
if (downloadStatus === 'notStarted' || downloadStatus === 'inProgress' || downloadStatus === 'failed') {
|
|
191
|
+
// If we have a fallback view component, render it
|
|
192
|
+
if (FallbackViewComponent) {
|
|
193
|
+
return /*#__PURE__*/_jsx(FallbackViewComponent, {});
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Otherwise, render the native view
|
|
125
199
|
return /*#__PURE__*/_jsx(NativeView, {
|
|
126
200
|
trigger: trigger,
|
|
127
201
|
style: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["findNodeHandle","NativeModules","View","NativeEventEmitter","requireNativeComponent","React","createRef","useEffect","
|
|
1
|
+
{"version":3,"names":["findNodeHandle","NativeModules","View","NativeEventEmitter","requireNativeComponent","React","createRef","useEffect","useState","createContext","useContext","jsx","_jsx","jsxs","_jsxs","HeliumBridge","heliumEventEmitter","isProviderMounted","providerMountedPromise","resolveProviderMounted","Promise","resolve","HeliumContext","undefined","setDownloadStatusRef","useHelium","context","Error","NativeHeliumUpsellView","getNativeHeliumUpsellView","fallbackRef","FallbackViewComponent","HeliumProvider","children","fallbackView","FallbackView","downloadStatus","setDownloadStatus","Provider","value","ref","collapsable","style","display","initialize","heliumCallbacks","config","viewTag","current","addListener","event","type","paywallTemplateName","setNativeProps","onHeliumPaywallEvent","status","makePurchase","productId","handlePurchaseResponse","transactionId","success","restorePurchases","handleRestoreResponse","apiKey","fallbackPaywall","triggers","customUserId","customAPIEndpoint","customUserTraits","presentUpsell","triggerName","hideUpsell","UpsellView","trigger","NativeView","flex","HELIUM_CTA_NAMES","SCHEDULE_CALL","SUBSCRIBE_BUTTON"],"sourceRoot":"../../src","sources":["native-interface.tsx"],"mappings":";;AAAA,SAASA,cAAc,EAAEC,aAAa,EAAEC,IAAI,EAAEC,kBAAkB,EAAEC,sBAAsB,QAAQ,cAAc;AAC9G,OAAOC,KAAK,IAAIC,SAAS,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAGzF,MAAM;EAAEC;AAAa,CAAC,GAAGd,aAAa;AACtC,MAAMe,kBAAkB,GAAG,IAAIb,kBAAkB,CAACY,YAAY,CAAC;AAE/D,IAAIE,iBAAiB,GAAG,KAAK;AAC7B;AACA,IAAIC,sBAAqC;AACzC,IAAIC,sBAAkC;;AAEtC;AACAD,sBAAsB,GAAG,IAAIE,OAAO,CAAQC,OAAO,IAAK;EACtDF,sBAAsB,GAAGE,OAAO;EAChC;EACA,IAAIJ,iBAAiB,EAAE;IACrBI,OAAO,CAAC,CAAC;EACX;AACF,CAAC,CAAC;;AAEF;;AAMA,MAAMC,aAAa,gBAAGb,aAAa,CAAgCc,SAAS,CAAC;;AAE7E;AACA,IAAIC,oBAAqE,GAAG,IAAI;;AAEhF;AACA,OAAO,MAAMC,SAAS,GAAGA,CAAA,KAAM;EAC7B,MAAMC,OAAO,GAAGhB,UAAU,CAACY,aAAa,CAAC;EACzC,IAAI,CAACI,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CAAC,gDAAgD,CAAC;EACnE;EACA,OAAOD,OAAO;AAChB,CAAC;;AAED;AACA,IAAIE,sBAA2B,GAAG,IAAI;AACtC,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EACt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GAAGX,SAAS,CAAC,CAAC;EACtC,MAAMiD,UAAU,GAAG7C,yBAAyB,CAAC,CAAC;;EAE9C;EACA;EACA,IAAIO,cAAc,KAAK,YAAY,IAAIA,cAAc,KAAK,YAAY,IAAIA,cAAc,KAAK,QAAQ,EAAE;IACrG;IACA,IAAIL,qBAAqB,EAAE;MACzB,oBAAOnB,IAAA,CAACmB,qBAAqB,IAAE,CAAC;IAClC;IAEA,OAAO,IAAI;EACb;;EAEA;EACA,oBACEnB,IAAA,CAAC8D,UAAU;IACTD,OAAO,EAAEA,OAAQ;IACjB/B,KAAK,EAAE,CAAC;MAAEiC,IAAI,EAAE;IAAE,CAAC,EAAEjC,KAAK;EAAE,CAC7B,CAAC;AAEN,CAAC;AAED,OAAO,MAAMkC,gBAAgB,GAAG;EAC9BC,aAAa,EAAE,eAAe;EAC9BC,gBAAgB,EAAE;AACpB,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { HeliumCallbacks, HeliumConfig, HeliumUpsellViewProps } from './types';
|
|
2
|
+
import type { HeliumCallbacks, HeliumConfig, HeliumUpsellViewProps, HeliumDownloadStatus } from './types';
|
|
3
|
+
interface HeliumContextType {
|
|
4
|
+
downloadStatus: HeliumDownloadStatus;
|
|
5
|
+
setDownloadStatus: (status: HeliumDownloadStatus) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const useHelium: () => HeliumContextType;
|
|
3
8
|
interface HeliumProviderProps {
|
|
4
9
|
children: React.ReactNode;
|
|
5
10
|
fallbackView: React.ComponentType;
|
|
6
11
|
}
|
|
7
12
|
export declare const HeliumProvider: ({ children, fallbackView: FallbackView }: HeliumProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export declare const initialize: (heliumCallbacks: HeliumCallbacks, config?: Partial<HeliumConfig>) => void
|
|
13
|
+
export declare const initialize: (heliumCallbacks: HeliumCallbacks, config?: Partial<HeliumConfig>) => Promise<void>;
|
|
9
14
|
export declare const presentUpsell: (triggerName: string) => void;
|
|
10
15
|
export declare const hideUpsell: () => void;
|
|
11
16
|
export declare const UpsellView: React.FC<HeliumUpsellViewProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-interface.d.ts","sourceRoot":"","sources":["../../../../src/native-interface.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"native-interface.d.ts","sourceRoot":"","sources":["../../../../src/native-interface.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoE,MAAM,OAAO,CAAC;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAoB1G,UAAU,iBAAiB;IACzB,cAAc,EAAE,oBAAoB,CAAC;IACrC,iBAAiB,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC3D;AAQD,eAAO,MAAM,SAAS,yBAMrB,CAAC;AAWF,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC;CACnC;AAQD,eAAO,MAAM,cAAc,6CAA8C,mBAAmB,4CAmC3F,CAAC;AAGF,eAAO,MAAM,UAAU,oBAA2B,eAAe,WAAU,OAAO,CAAC,YAAY,CAAC,kBAoF/F,CAAC;AAGF,eAAO,MAAM,aAAa,gBAAiB,MAAM,SAEhD,CAAC;AAEF,eAAO,MAAM,UAAU,YAEtB,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAsBtD,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;CAG5B,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type HeliumTransactionStatus = 'completed' | 'failed' | 'cancelled' | 'pending' | 'restored';
|
|
2
|
+
export type HeliumDownloadStatus = 'success' | 'failed' | 'inProgress' | 'notStarted';
|
|
2
3
|
export interface HeliumCallbacks {
|
|
3
4
|
makePurchase: (productId: string) => Promise<HeliumTransactionStatus>;
|
|
4
5
|
restorePurchases: () => Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;AACpG,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;AAEtF,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtE,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,oBAAoB,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { HeliumCallbacks, HeliumConfig, HeliumUpsellViewProps } from './types';
|
|
2
|
+
import type { HeliumCallbacks, HeliumConfig, HeliumUpsellViewProps, HeliumDownloadStatus } from './types';
|
|
3
|
+
interface HeliumContextType {
|
|
4
|
+
downloadStatus: HeliumDownloadStatus;
|
|
5
|
+
setDownloadStatus: (status: HeliumDownloadStatus) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const useHelium: () => HeliumContextType;
|
|
3
8
|
interface HeliumProviderProps {
|
|
4
9
|
children: React.ReactNode;
|
|
5
10
|
fallbackView: React.ComponentType;
|
|
6
11
|
}
|
|
7
12
|
export declare const HeliumProvider: ({ children, fallbackView: FallbackView }: HeliumProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export declare const initialize: (heliumCallbacks: HeliumCallbacks, config?: Partial<HeliumConfig>) => void
|
|
13
|
+
export declare const initialize: (heliumCallbacks: HeliumCallbacks, config?: Partial<HeliumConfig>) => Promise<void>;
|
|
9
14
|
export declare const presentUpsell: (triggerName: string) => void;
|
|
10
15
|
export declare const hideUpsell: () => void;
|
|
11
16
|
export declare const UpsellView: React.FC<HeliumUpsellViewProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-interface.d.ts","sourceRoot":"","sources":["../../../../src/native-interface.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"native-interface.d.ts","sourceRoot":"","sources":["../../../../src/native-interface.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoE,MAAM,OAAO,CAAC;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAoB1G,UAAU,iBAAiB;IACzB,cAAc,EAAE,oBAAoB,CAAC;IACrC,iBAAiB,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC3D;AAQD,eAAO,MAAM,SAAS,yBAMrB,CAAC;AAWF,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC;CACnC;AAQD,eAAO,MAAM,cAAc,6CAA8C,mBAAmB,4CAmC3F,CAAC;AAGF,eAAO,MAAM,UAAU,oBAA2B,eAAe,WAAU,OAAO,CAAC,YAAY,CAAC,kBAoF/F,CAAC;AAGF,eAAO,MAAM,aAAa,gBAAiB,MAAM,SAEhD,CAAC;AAEF,eAAO,MAAM,UAAU,YAEtB,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAsBtD,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;CAG5B,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type HeliumTransactionStatus = 'completed' | 'failed' | 'cancelled' | 'pending' | 'restored';
|
|
2
|
+
export type HeliumDownloadStatus = 'success' | 'failed' | 'inProgress' | 'notStarted';
|
|
2
3
|
export interface HeliumCallbacks {
|
|
3
4
|
makePurchase: (productId: string) => Promise<HeliumTransactionStatus>;
|
|
4
5
|
restorePurchases: () => Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;AACpG,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;AAEtF,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtE,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,oBAAoB,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb"}
|
package/package.json
CHANGED
package/src/native-interface.tsx
CHANGED
|
@@ -1,11 +1,43 @@
|
|
|
1
1
|
import { findNodeHandle, NativeModules, View, NativeEventEmitter, requireNativeComponent } from 'react-native';
|
|
2
|
-
import React, { createRef, useEffect } from 'react';
|
|
3
|
-
import type { HeliumCallbacks, HeliumConfig, HeliumUpsellViewProps } from './types';
|
|
2
|
+
import React, { createRef, useEffect, useState, createContext, useContext } from 'react';
|
|
3
|
+
import type { HeliumCallbacks, HeliumConfig, HeliumUpsellViewProps, HeliumDownloadStatus } from './types';
|
|
4
4
|
|
|
5
5
|
const { HeliumBridge } = NativeModules;
|
|
6
6
|
const heliumEventEmitter = new NativeEventEmitter(HeliumBridge);
|
|
7
7
|
|
|
8
8
|
let isProviderMounted = false;
|
|
9
|
+
// Add a promise to track when the provider is mounted
|
|
10
|
+
let providerMountedPromise: Promise<void>;
|
|
11
|
+
let resolveProviderMounted: () => void;
|
|
12
|
+
|
|
13
|
+
// Initialize the promise
|
|
14
|
+
providerMountedPromise = new Promise<void>((resolve) => {
|
|
15
|
+
resolveProviderMounted = resolve;
|
|
16
|
+
// If provider is already mounted, resolve immediately
|
|
17
|
+
if (isProviderMounted) {
|
|
18
|
+
resolve();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Create a context for the download status
|
|
23
|
+
interface HeliumContextType {
|
|
24
|
+
downloadStatus: HeliumDownloadStatus;
|
|
25
|
+
setDownloadStatus: (status: HeliumDownloadStatus) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const HeliumContext = createContext<HeliumContextType | undefined>(undefined);
|
|
29
|
+
|
|
30
|
+
// Create a ref to store the context setter
|
|
31
|
+
let setDownloadStatusRef: ((status: HeliumDownloadStatus) => void) | null = null;
|
|
32
|
+
|
|
33
|
+
// Hook to use the Helium context
|
|
34
|
+
export const useHelium = () => {
|
|
35
|
+
const context = useContext(HeliumContext);
|
|
36
|
+
if (!context) {
|
|
37
|
+
throw new Error('useHelium must be used within a HeliumProvider');
|
|
38
|
+
}
|
|
39
|
+
return context;
|
|
40
|
+
};
|
|
9
41
|
|
|
10
42
|
// Move NativeHeliumUpsellView to a singleton pattern
|
|
11
43
|
let NativeHeliumUpsellView: any = null;
|
|
@@ -23,19 +55,33 @@ interface HeliumProviderProps {
|
|
|
23
55
|
|
|
24
56
|
// Create a ref to store the fallback view reference
|
|
25
57
|
const fallbackRef = createRef<View>();
|
|
58
|
+
// Store a reference to the fallback view component
|
|
59
|
+
let FallbackViewComponent: React.ComponentType | null = null;
|
|
26
60
|
|
|
27
61
|
// Provider component to be rendered at the app root
|
|
28
62
|
export const HeliumProvider = ({ children, fallbackView: FallbackView }: HeliumProviderProps) => {
|
|
63
|
+
// Add state for download status
|
|
64
|
+
const [downloadStatus, setDownloadStatus] = useState<HeliumDownloadStatus>('notStarted');
|
|
65
|
+
|
|
66
|
+
// Store the setter in the ref so it can be accessed outside of components
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
setDownloadStatusRef = setDownloadStatus;
|
|
69
|
+
// Store the fallback view component for later use
|
|
70
|
+
FallbackViewComponent = FallbackView;
|
|
71
|
+
}, [setDownloadStatus, FallbackView]);
|
|
29
72
|
|
|
30
73
|
useEffect(() => {
|
|
31
74
|
isProviderMounted = true;
|
|
75
|
+
// Resolve the promise when the provider is mounted
|
|
76
|
+
resolveProviderMounted();
|
|
32
77
|
return () => {
|
|
33
78
|
isProviderMounted = false;
|
|
79
|
+
setDownloadStatusRef = null;
|
|
34
80
|
};
|
|
35
81
|
}, []);
|
|
36
82
|
|
|
37
83
|
return (
|
|
38
|
-
|
|
84
|
+
<HeliumContext.Provider value={{ downloadStatus, setDownloadStatus }}>
|
|
39
85
|
<View
|
|
40
86
|
ref={fallbackRef}
|
|
41
87
|
collapsable={false}
|
|
@@ -46,14 +92,15 @@ export const HeliumProvider = ({ children, fallbackView: FallbackView }: HeliumP
|
|
|
46
92
|
<FallbackView />
|
|
47
93
|
</View>
|
|
48
94
|
{children}
|
|
49
|
-
|
|
95
|
+
</HeliumContext.Provider>
|
|
50
96
|
);
|
|
51
97
|
};
|
|
52
98
|
|
|
53
99
|
// Update initialize to accept config
|
|
54
|
-
export const initialize = (heliumCallbacks: HeliumCallbacks, config: Partial<HeliumConfig> = {}) => {
|
|
100
|
+
export const initialize = async (heliumCallbacks: HeliumCallbacks, config: Partial<HeliumConfig> = {}) => {
|
|
101
|
+
// Wait for the provider to be mounted if it's not already
|
|
55
102
|
if (!isProviderMounted) {
|
|
56
|
-
|
|
103
|
+
await providerMountedPromise;
|
|
57
104
|
}
|
|
58
105
|
|
|
59
106
|
const viewTag = findNodeHandle(fallbackRef.current);
|
|
@@ -61,6 +108,41 @@ export const initialize = (heliumCallbacks: HeliumCallbacks, config: Partial<Hel
|
|
|
61
108
|
throw new Error('Failed to get fallback view reference. Make sure HeliumProvider is mounted with a fallback view.');
|
|
62
109
|
}
|
|
63
110
|
|
|
111
|
+
// Update download status to inProgress
|
|
112
|
+
if (setDownloadStatusRef) {
|
|
113
|
+
setDownloadStatusRef('inProgress');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Set up event listeners
|
|
117
|
+
heliumEventEmitter.addListener(
|
|
118
|
+
'helium_paywall_event',
|
|
119
|
+
(event: any) => {
|
|
120
|
+
// Handle download status events
|
|
121
|
+
if (event.type === 'paywallsDownloadSuccess' && setDownloadStatusRef) {
|
|
122
|
+
setDownloadStatusRef('success');
|
|
123
|
+
} else if (event.type === 'paywallsDownloadError' && setDownloadStatusRef) {
|
|
124
|
+
setDownloadStatusRef('failed');
|
|
125
|
+
}
|
|
126
|
+
// Handle fallback view visibility
|
|
127
|
+
else if (event.type === 'paywallOpen' && event.paywallTemplateName === 'Fallback') {
|
|
128
|
+
if (fallbackRef.current) {
|
|
129
|
+
fallbackRef.current.setNativeProps({
|
|
130
|
+
style: { display: 'flex' }
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
} else if (event.type === 'paywallClose' && event.paywallTemplateName === 'Fallback') {
|
|
134
|
+
if (fallbackRef.current) {
|
|
135
|
+
fallbackRef.current.setNativeProps({
|
|
136
|
+
style: { display: 'none' }
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Forward all events to the callback
|
|
142
|
+
heliumCallbacks.onHeliumPaywallEvent(event);
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
|
|
64
146
|
// Set up purchase event listener
|
|
65
147
|
heliumEventEmitter.addListener(
|
|
66
148
|
'helium_make_purchase',
|
|
@@ -85,30 +167,6 @@ export const initialize = (heliumCallbacks: HeliumCallbacks, config: Partial<Hel
|
|
|
85
167
|
}
|
|
86
168
|
);
|
|
87
169
|
|
|
88
|
-
// Set up paywall event listener
|
|
89
|
-
heliumEventEmitter.addListener(
|
|
90
|
-
'helium_paywall_event',
|
|
91
|
-
(event: any) => {
|
|
92
|
-
|
|
93
|
-
if (event.type === 'paywallOpen' && event.paywallTemplateName === 'Fallback') {
|
|
94
|
-
// Update fallback view visibility if the ref exists
|
|
95
|
-
if (fallbackRef.current) {
|
|
96
|
-
fallbackRef.current.setNativeProps({
|
|
97
|
-
style: { display: 'flex' }
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
} else if (event.type === 'paywallClose' && event.paywallTemplateName === 'Fallback') {
|
|
101
|
-
// Update fallback view visibility if the ref exists
|
|
102
|
-
if (fallbackRef.current) {
|
|
103
|
-
fallbackRef.current.setNativeProps({
|
|
104
|
-
style: { display: 'none' }
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
heliumCallbacks.onHeliumPaywallEvent(event);
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
|
|
112
170
|
// Initialize the bridge with merged config
|
|
113
171
|
HeliumBridge.initialize(
|
|
114
172
|
{
|
|
@@ -136,7 +194,21 @@ export const hideUpsell = () => {
|
|
|
136
194
|
|
|
137
195
|
// Update the UpsellView component to handle the style prop
|
|
138
196
|
export const UpsellView: React.FC<HeliumUpsellViewProps> = ({ trigger, style }) => {
|
|
197
|
+
const { downloadStatus } = useHelium();
|
|
139
198
|
const NativeView = getNativeHeliumUpsellView();
|
|
199
|
+
|
|
200
|
+
// If download status is notStarted or inProgress, we haven't fully initialized yet
|
|
201
|
+
// In this case, we should render the fallback view
|
|
202
|
+
if (downloadStatus === 'notStarted' || downloadStatus === 'inProgress' || downloadStatus === 'failed') {
|
|
203
|
+
// If we have a fallback view component, render it
|
|
204
|
+
if (FallbackViewComponent) {
|
|
205
|
+
return <FallbackViewComponent />;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Otherwise, render the native view
|
|
140
212
|
return (
|
|
141
213
|
<NativeView
|
|
142
214
|
trigger={trigger}
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type HeliumTransactionStatus = 'completed' | 'failed' | 'cancelled' | 'pending' | 'restored';
|
|
2
|
+
export type HeliumDownloadStatus = 'success' | 'failed' | 'inProgress' | 'notStarted';
|
|
2
3
|
|
|
3
4
|
export interface HeliumCallbacks {
|
|
4
5
|
makePurchase: (productId: string) => Promise<HeliumTransactionStatus>;
|