react-native-unit-components 1.0.1 → 1.0.3
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/README.md +75 -6
- package/android/src/main/AndroidManifest.xml +12 -1
- package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsPackage.kt +2 -1
- package/android/src/main/java/com/unitreactnativecomponents/sharepdf/UNSharePDF.kt +75 -0
- package/android/src/main/res/layout/un_black_add_to_googlepay_button.xml +2 -2
- package/android/src/main/res/layout/un_view_google_push_provisioning.xml +1 -13
- package/android/src/main/res/layout/un_white_add_to_googlepay_button.xml +1 -1
- package/android/src/main/res/layout/un_white_add_to_googlepay_button_no_shadow.xml +1 -1
- package/android/src/main/res/xml/file_paths.xml +4 -0
- package/ios/UnitReactNativeComponentsViewManager.m +0 -1
- package/ios/UnitReactNativeComponentsViewManager.swift +6 -2
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +103 -0
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -0
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js +47 -0
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +63 -8
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +18 -3
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +56 -13
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +4 -3
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +3 -3
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +114 -46
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +4 -8
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +95 -0
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -0
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js +31 -0
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -0
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +65 -7
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +56 -10
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js +20 -0
- package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -0
- package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +44 -0
- package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -0
- package/lib/commonjs/components/index.js +13 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js +32 -12
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
- package/lib/commonjs/helpers/EventBus.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/cardMessage.js +36 -0
- package/lib/commonjs/messages/nativeMessages/cardMessage.js.map +1 -0
- package/lib/commonjs/messages/nativeMessages/index.js +0 -7
- package/lib/commonjs/messages/nativeMessages/index.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/sdkMessage.js +14 -0
- package/lib/commonjs/messages/nativeMessages/sdkMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/unitMessages.js +1 -0
- package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/commonjs/nativeComponent/{UNNativeAddToWalletButton.js → UnitAddToWalletButton.js} +1 -1
- package/lib/commonjs/nativeComponent/UnitAddToWalletButton.js.map +1 -0
- package/lib/commonjs/scripts/html/bodyHtml.js +1 -1
- package/lib/commonjs/scripts/html/bodyHtml.js.map +1 -1
- package/lib/commonjs/scripts/html/bodyScript.js +22 -5
- package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
- package/lib/commonjs/sharedTypes/bookPayment.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/card.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/index.js +13 -0
- package/lib/commonjs/sharedTypes/index.js.map +1 -1
- package/lib/commonjs/sharedTypes/onLoadResponse.types.js +6 -0
- package/lib/commonjs/sharedTypes/onLoadResponse.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/wallet.types.js +22 -0
- package/lib/commonjs/sharedTypes/wallet.types.js.map +1 -0
- package/lib/commonjs/unitSdkManager/UnitSdk.api.js +5 -3
- package/lib/commonjs/unitSdkManager/UnitSdk.api.js.map +1 -1
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js +18 -0
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.js +35 -10
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.utils.js +41 -0
- package/lib/commonjs/webComponent/WebComponent.utils.js.map +1 -0
- package/lib/commonjs/webComponent/html.js +9 -1
- package/lib/commonjs/webComponent/html.js.map +1 -1
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js +74 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js +26 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +56 -8
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +10 -2
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +50 -12
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +3 -2
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +111 -46
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +5 -9
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +68 -0
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -0
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js +21 -0
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.js +65 -9
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +48 -9
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/module/components/UNCardComponent/networking/common/UNNetworkConstants.js +10 -0
- package/lib/module/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -0
- package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +29 -0
- package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/helpers/BottomSheet/BottomSheet.js +30 -13
- package/lib/module/helpers/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/module/helpers/BottomSheet/BottomSheet.styles.js +2 -2
- package/lib/module/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
- package/lib/module/helpers/EventBus.js.map +1 -1
- package/lib/module/messages/nativeMessages/cardMessage.js +27 -0
- package/lib/module/messages/nativeMessages/cardMessage.js.map +1 -0
- package/lib/module/messages/nativeMessages/index.js +1 -5
- package/lib/module/messages/nativeMessages/index.js.map +1 -1
- package/lib/module/messages/nativeMessages/sdkMessage.js +7 -0
- package/lib/module/messages/nativeMessages/sdkMessage.js.map +1 -0
- package/lib/module/messages/webMessages/unitMessages.js +1 -0
- package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/module/nativeComponent/{UNNativeAddToWalletButton.js → UnitAddToWalletButton.js} +1 -1
- package/lib/module/nativeComponent/UnitAddToWalletButton.js.map +1 -0
- package/lib/module/scripts/html/bodyHtml.js +1 -1
- package/lib/module/scripts/html/bodyHtml.js.map +1 -1
- package/lib/module/scripts/html/bodyScript.js +19 -3
- package/lib/module/scripts/html/bodyScript.js.map +1 -1
- package/lib/module/sharedTypes/bookPayment.types.js.map +1 -1
- package/lib/module/sharedTypes/card.types.js.map +1 -1
- package/lib/module/sharedTypes/index.js +1 -0
- package/lib/module/sharedTypes/index.js.map +1 -1
- package/lib/module/sharedTypes/onLoadResponse.types.js +2 -0
- package/lib/module/sharedTypes/onLoadResponse.types.js.map +1 -0
- package/lib/module/sharedTypes/wallet.types.js +14 -0
- package/lib/module/sharedTypes/wallet.types.js.map +1 -0
- package/lib/module/unitSdkManager/UnitSdk.api.js +4 -3
- package/lib/module/unitSdkManager/UnitSdk.api.js.map +1 -1
- package/lib/module/unitSdkManager/UnitSdkManager.js +13 -0
- package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/module/webComponent/WebComponent.js +32 -10
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/module/webComponent/WebComponent.utils.js +27 -0
- package/lib/module/webComponent/WebComponent.utils.js.map +1 -0
- package/lib/module/webComponent/html.js +9 -2
- package/lib/module/webComponent/html.js.map +1 -1
- package/lib/typescript/components/UNAccountComponent/UNAccountComponent.d.ts +12 -0
- package/lib/typescript/components/UNAccountComponent/UNAccountComponent.utils.d.ts +7 -0
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +2 -0
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.utils.d.ts +4 -0
- package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +2 -1
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.d.ts +1 -1
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.d.ts +9 -2
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.d.ts +2 -1
- package/lib/typescript/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.d.ts +6 -0
- package/lib/typescript/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.d.ts +17 -0
- package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +4 -1
- package/lib/typescript/components/UNCardComponent/UNCardComponent.utils.d.ts +9 -1
- package/lib/typescript/components/UNCardComponent/networking/common/UNNetworkConstants.d.ts +8 -0
- package/lib/typescript/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.d.ts +1 -0
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/helpers/EventBus.d.ts +3 -3
- package/lib/typescript/messages/nativeMessages/cardMessage.d.ts +28 -0
- package/lib/typescript/messages/nativeMessages/index.d.ts +7 -2
- package/lib/typescript/messages/nativeMessages/sdkMessage.d.ts +8 -0
- package/lib/typescript/messages/webMessages/unitMessages.d.ts +16 -6
- package/lib/typescript/scripts/html/bodyScript.d.ts +4 -1
- package/lib/typescript/sharedTypes/bookPayment.types.d.ts +3 -3
- package/lib/typescript/sharedTypes/card.types.d.ts +6 -6
- package/lib/typescript/sharedTypes/index.d.ts +1 -0
- package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +18 -0
- package/lib/typescript/sharedTypes/wallet.types.d.ts +14 -0
- package/lib/typescript/unitSdkManager/UnitSdkManager.d.ts +3 -0
- package/lib/typescript/webComponent/WebComponent.d.ts +4 -1
- package/lib/typescript/webComponent/WebComponent.utils.d.ts +2 -0
- package/package.json +2 -1
- package/src/components/UNAccountComponent/UNAccountComponent.tsx +82 -0
- package/src/components/UNAccountComponent/UNAccountComponent.utils.ts +30 -0
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +57 -8
- package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +14 -2
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +47 -13
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +3 -2
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.ts +1 -1
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +120 -44
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.ts +7 -10
- package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.ts +21 -0
- package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.tsx +74 -0
- package/src/components/UNCardComponent/UNCardComponent.tsx +68 -13
- package/src/components/UNCardComponent/UNCardComponent.utils.ts +47 -9
- package/src/components/UNCardComponent/networking/common/UNNetworkConstants.ts +11 -0
- package/src/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.ts +34 -0
- package/src/components/index.ts +1 -0
- package/src/helpers/BottomSheet/BottomSheet.styles.ts +2 -2
- package/src/helpers/BottomSheet/BottomSheet.tsx +28 -12
- package/src/helpers/EventBus.ts +3 -3
- package/src/messages/nativeMessages/cardMessage.ts +37 -0
- package/src/messages/nativeMessages/index.ts +14 -2
- package/src/messages/nativeMessages/sdkMessage.ts +11 -0
- package/src/messages/webMessages/unitMessages.ts +20 -7
- package/src/scripts/html/bodyHtml.ts +1 -1
- package/src/scripts/html/bodyScript.ts +21 -4
- package/src/sharedTypes/bookPayment.types.ts +3 -3
- package/src/sharedTypes/card.types.ts +6 -6
- package/src/sharedTypes/index.ts +1 -0
- package/src/sharedTypes/onLoadResponse.types.ts +27 -0
- package/src/sharedTypes/wallet.types.ts +17 -0
- package/src/unitSdkManager/UnitSdk.api.ts +3 -2
- package/src/unitSdkManager/UnitSdkManager.ts +12 -0
- package/src/webComponent/WebComponent.tsx +35 -12
- package/src/webComponent/WebComponent.utils.ts +26 -0
- package/src/webComponent/html.ts +9 -2
- package/lib/commonjs/nativeComponent/UNNativeAddToWalletButton.js.map +0 -1
- package/lib/module/nativeComponent/UNNativeAddToWalletButton.js.map +0 -1
- /package/lib/typescript/nativeComponent/{UNNativeAddToWalletButton.d.ts → UnitAddToWalletButton.d.ts} +0 -0
- /package/src/nativeComponent/{UNNativeAddToWalletButton.tsx → UnitAddToWalletButton.tsx} +0 -0
|
@@ -17,6 +17,8 @@ var _UNBottomSheetComponent = require("../../components/UNBottomSheetComponent/U
|
|
|
17
17
|
|
|
18
18
|
var _BottomSheet = require("./BottomSheet.styles");
|
|
19
19
|
|
|
20
|
+
var _useAppStateListener = require("../../hooks/useAppStateListener");
|
|
21
|
+
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
23
|
|
|
22
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -33,6 +35,7 @@ const BottomSheet = props => {
|
|
|
33
35
|
const [contentHeight, setContentHeight] = (0, _react.useState)(undefined);
|
|
34
36
|
const [currentHeight, setCurrentHeight] = (0, _react.useState)(props.sliderMaxHeight);
|
|
35
37
|
const [dy, setDy] = (0, _react.useState)(0);
|
|
38
|
+
const isAppActive = (0, _useAppStateListener.useAppStateListener)();
|
|
36
39
|
|
|
37
40
|
const _parentPanResponder = _reactNative.PanResponder.create({
|
|
38
41
|
onMoveShouldSetPanResponderCapture: (_, gestureState) => {
|
|
@@ -63,6 +66,13 @@ const BottomSheet = props => {
|
|
|
63
66
|
}
|
|
64
67
|
});
|
|
65
68
|
|
|
69
|
+
(0, _react.useEffect)(() => {
|
|
70
|
+
if (!isAppActive && isPanelOpened) {
|
|
71
|
+
setContentHeight(0);
|
|
72
|
+
|
|
73
|
+
_dismiss(false);
|
|
74
|
+
}
|
|
75
|
+
}, [isAppActive]);
|
|
66
76
|
(0, _react.useEffect)(() => {
|
|
67
77
|
if (props.isOpen && !isPanelOpened) {
|
|
68
78
|
fadeIn();
|
|
@@ -84,23 +94,31 @@ const BottomSheet = props => {
|
|
|
84
94
|
}, []);
|
|
85
95
|
|
|
86
96
|
const fadeIn = () => {
|
|
97
|
+
setIsPanelOpened(true);
|
|
98
|
+
|
|
87
99
|
_reactNative.Animated.timing(fadeAnim, {
|
|
88
100
|
toValue: 0.3,
|
|
89
101
|
duration: 500,
|
|
90
102
|
useNativeDriver: false
|
|
91
|
-
}).start(
|
|
92
|
-
setIsPanelOpened(true);
|
|
93
|
-
});
|
|
103
|
+
}).start();
|
|
94
104
|
};
|
|
95
105
|
|
|
96
|
-
const fadeOut = ()
|
|
106
|
+
const fadeOut = function () {
|
|
107
|
+
let withTimeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
108
|
+
|
|
109
|
+
/*
|
|
110
|
+
withTimeout - most of the time we declare 'Close' after the animation is end.
|
|
111
|
+
In a case that the app is not active we do it without timeout. (Otherwise a race condition may occur.)
|
|
112
|
+
*/
|
|
113
|
+
setIsPanelOpened(false);
|
|
114
|
+
!withTimeout && props.onClose();
|
|
115
|
+
|
|
97
116
|
_reactNative.Animated.timing(fadeAnim, {
|
|
98
117
|
toValue: 0,
|
|
99
118
|
duration: 500,
|
|
100
119
|
useNativeDriver: false
|
|
101
120
|
}).start(() => {
|
|
102
|
-
|
|
103
|
-
props.onClose();
|
|
121
|
+
withTimeout && props.onClose();
|
|
104
122
|
});
|
|
105
123
|
};
|
|
106
124
|
|
|
@@ -117,6 +135,7 @@ const BottomSheet = props => {
|
|
|
117
135
|
const {
|
|
118
136
|
animationDuration
|
|
119
137
|
} = props;
|
|
138
|
+
props.onOpen();
|
|
120
139
|
|
|
121
140
|
if (contentHeight && currentHeight > sliderMaxHeight - contentHeight) {
|
|
122
141
|
setToContentHeight(contentHeight);
|
|
@@ -152,7 +171,8 @@ const BottomSheet = props => {
|
|
|
152
171
|
setToContentHeight(newContentHeight);
|
|
153
172
|
};
|
|
154
173
|
|
|
155
|
-
const _dismiss = ()
|
|
174
|
+
const _dismiss = function () {
|
|
175
|
+
let withTimeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
156
176
|
const {
|
|
157
177
|
animationDuration
|
|
158
178
|
} = props;
|
|
@@ -166,7 +186,7 @@ const BottomSheet = props => {
|
|
|
166
186
|
null;
|
|
167
187
|
});
|
|
168
188
|
|
|
169
|
-
fadeOut();
|
|
189
|
+
fadeOut(withTimeout);
|
|
170
190
|
};
|
|
171
191
|
|
|
172
192
|
const {
|
|
@@ -176,7 +196,7 @@ const BottomSheet = props => {
|
|
|
176
196
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
|
|
177
197
|
style: styles.outsideContainer,
|
|
178
198
|
activeOpacity: 1,
|
|
179
|
-
onPress: _dismiss
|
|
199
|
+
onPress: () => _dismiss()
|
|
180
200
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
|
|
181
201
|
style: styles.animation
|
|
182
202
|
})), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, _extends({}, _parentPanResponder.panHandlers, {
|
|
@@ -191,7 +211,7 @@ const BottomSheet = props => {
|
|
|
191
211
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
|
|
192
212
|
activeOpacity: 1,
|
|
193
213
|
style: styles.closeButton,
|
|
194
|
-
onPress: _dismiss
|
|
214
|
+
onPress: () => _dismiss()
|
|
195
215
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
|
|
196
216
|
source: _images.CloseIcon
|
|
197
217
|
})), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
@@ -201,7 +221,7 @@ const BottomSheet = props => {
|
|
|
201
221
|
style: {
|
|
202
222
|
height: props.height
|
|
203
223
|
},
|
|
204
|
-
keyboardVerticalOffset: props.height * (1 - _UNBottomSheetComponent.
|
|
224
|
+
keyboardVerticalOffset: props.height * (1 - _UNBottomSheetComponent.BOTTOM_SHEET_MAX_PERCENTAGE_SIZE)
|
|
205
225
|
}, children)))));
|
|
206
226
|
};
|
|
207
227
|
|
|
@@ -218,7 +238,7 @@ BottomSheet.propTypes = {
|
|
|
218
238
|
BottomSheet.defaultProps = {
|
|
219
239
|
children: /*#__PURE__*/_react.default.createElement(_reactNative.View, null),
|
|
220
240
|
isOpen: true,
|
|
221
|
-
sliderMaxHeight: _reactNative.Dimensions.get('window').height * _UNBottomSheetComponent.
|
|
241
|
+
sliderMaxHeight: _reactNative.Dimensions.get('window').height * _UNBottomSheetComponent.BOTTOM_SHEET_MAX_PERCENTAGE_SIZE,
|
|
222
242
|
animationDuration: 200,
|
|
223
243
|
onOpen: () => null,
|
|
224
244
|
onClose: () => null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BottomSheet","props","panelHeightValue","useRef","Animated","Value","sliderMaxHeight","current","fadeAnim","styles","getStylesObject","isPanelOpened","setIsPanelOpened","useState","isOpen","contentHeight","setContentHeight","undefined","currentHeight","setCurrentHeight","dy","setDy","_parentPanResponder","PanResponder","create","onMoveShouldSetPanResponderCapture","_","gestureState","shouldEnableBottomSheetScroll","Math","abs","onPanResponderMove","handleWebViewScroll","expandToMaxHeightEnabled","setValue","onPanResponderRelease","collapse","setToContentHeight","expand","useEffect","fadeIn","_dismiss","BackHandler","addEventListener","_onBackPress","id","addListener","e","value","removeEventListener","removeListener","timing","toValue","duration","useNativeDriver","start","fadeOut","onClose","animationDuration","easing","Easing","quad","_setSize","newContentHeight","nativeEvent","layout","height","children","outsideContainer","animation","panHandlers","container","transform","translateY","outerContent","closeButton","CloseIcon","BOTTOM_SHEET_MAX_PRECANTAGE_SIZE","propTypes","PropTypes","oneOfType","node","bool","number","func","onOpen","defaultProps","Dimensions","get"],"sources":["BottomSheet.tsx"],"sourcesContent":["import React, { ReactNode, useEffect, useRef, useState } from 'react';\nimport {\n Animated,\n BackHandler,\n Dimensions,\n Easing,\n Image,\n KeyboardAvoidingView,\n LayoutChangeEvent,\n PanResponder,\n TouchableOpacity,\n View,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport { CloseIcon } from '../../assets/images';\nimport { BOTTOM_SHEET_MAX_PRECANTAGE_SIZE } from '../../components/UNBottomSheetComponent/UNBottomSheetComponent.constants';\nimport { getStylesObject } from './BottomSheet.styles';\n\nexport interface BottomSheetProps {\n isOpen: boolean\n children: ReactNode\n sliderMaxHeight: number\n onOpen: () => void\n onClose: () => void\n height: number,\n animationDuration: number,\n expandToMaxHeightEnabled: boolean\n handleWebViewScroll: () => void\n shouldEnableBottomSheetScroll: boolean\n}\n\nconst BottomSheet = (props: BottomSheetProps) => {\n const panelHeightValue = useRef(new Animated.Value(props.sliderMaxHeight)).current;\n const fadeAnim = useRef(new Animated.Value(0)).current;\n const styles = getStylesObject(fadeAnim);\n const [isPanelOpened, setIsPanelOpened] = useState(props.isOpen);\n const [contentHeight, setContentHeight] = useState<number | undefined>(undefined);\n\n const [currentHeight, setCurrentHeight] = useState<number>(props.sliderMaxHeight);\n\n const [dy, setDy] = useState(0);\n\n const _parentPanResponder = PanResponder.create({\n onMoveShouldSetPanResponderCapture: (_, gestureState) => {\n return props.shouldEnableBottomSheetScroll && Math.abs(gestureState.dy) > 10;\n },\n onPanResponderMove(_, gestureState) {\n if (props.shouldEnableBottomSheetScroll && gestureState.dy < 5) {\n props.handleWebViewScroll();\n }\n if (currentHeight + gestureState.dy < 0) return;\n if (!props.expandToMaxHeightEnabled && contentHeight && currentHeight + gestureState.dy < sliderMaxHeight - contentHeight) return;\n panelHeightValue.setValue(currentHeight + gestureState.dy);\n setDy(gestureState.dy);\n },\n onPanResponderRelease: () => {\n if (dy > 0) {\n collapse();\n } else if (!props.expandToMaxHeightEnabled) {\n contentHeight && setToContentHeight(contentHeight);\n } else if (dy < 0) {\n expand();\n } else {\n expand();\n }\n }\n });\n\n useEffect(() => {\n if (props.isOpen && !isPanelOpened) {\n fadeIn();\n } else if (isPanelOpened) {\n setContentHeight(0);\n _dismiss();\n }\n }, [props.isOpen]);\n\n useEffect(() => {\n BackHandler.addEventListener('hardwareBackPress', _onBackPress);\n const id = panelHeightValue.addListener(e => setCurrentHeight(e.value));\n\n return (() => {\n BackHandler.removeEventListener('hardwareBackPress', _onBackPress);\n panelHeightValue.removeListener(id);\n });\n }, []);\n\n const fadeIn = () => {\n Animated.timing(fadeAnim, {\n toValue: 0.3,\n duration: 500,\n useNativeDriver: false\n }).start(() => { setIsPanelOpened(true); });\n };\n\n const fadeOut = () => {\n Animated.timing(fadeAnim, {\n toValue: 0,\n duration: 500,\n useNativeDriver: false\n }).start(() => {\n setIsPanelOpened(false);\n props.onClose();\n });\n };\n\n const setToContentHeight = (contentHeight: number) => {\n Animated.timing(panelHeightValue, {\n duration: props.animationDuration,\n easing: Easing.quad,\n toValue: sliderMaxHeight - contentHeight,\n useNativeDriver: false,\n }).start();\n };\n\n const expand = () => {\n const { animationDuration } = props;\n\n if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {\n setToContentHeight(contentHeight);\n return;\n }\n\n Animated.timing(panelHeightValue, {\n duration: animationDuration,\n easing: Easing.quad,\n toValue: 0,\n useNativeDriver: false,\n }).start();\n };\n\n const collapse = () => {\n if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {\n _dismiss();\n return;\n }\n\n contentHeight && setToContentHeight(contentHeight);\n };\n\n const _onBackPress = () => {\n isPanelOpened && collapse();\n return isPanelOpened;\n };\n\n const _setSize = (e: LayoutChangeEvent) => {\n const newContentHeight = e.nativeEvent.layout.height;\n\n setContentHeight(newContentHeight);\n setToContentHeight(newContentHeight);\n };\n\n const _dismiss = () => {\n const { animationDuration } = props;\n Animated.timing(panelHeightValue, {\n duration: animationDuration,\n easing: Easing.quad,\n toValue: sliderMaxHeight,\n useNativeDriver: false,\n }).start(() => {\n null;\n });\n fadeOut();\n };\n\n const {\n sliderMaxHeight,\n children,\n } = props;\n\n return (\n <>\n <TouchableOpacity\n style={styles.outsideContainer} activeOpacity={1}\n onPress={_dismiss}\n >\n <Animated.View\n style={styles.animation}\n >\n </Animated.View>\n </TouchableOpacity>\n <Animated.View\n {..._parentPanResponder.panHandlers}\n style={{\n ...styles.container,\n height: sliderMaxHeight,\n transform: [\n { translateY: panelHeightValue },\n ],\n }}\n >\n <View\n style={styles.outerContent}\n >\n <TouchableOpacity\n activeOpacity={1}\n style={styles.closeButton}\n onPress={_dismiss}\n >\n <Image source={CloseIcon} />\n </TouchableOpacity>\n\n <View\n onLayout={_setSize}\n >\n <KeyboardAvoidingView\n behavior=\"padding\"\n style={{ height: props.height }}\n keyboardVerticalOffset={props.height * (1 - BOTTOM_SHEET_MAX_PRECANTAGE_SIZE)}\n >\n {children}\n </KeyboardAvoidingView>\n </View>\n </View>\n </Animated.View>\n </>\n );\n};\n\nBottomSheet.propTypes = {\n children: PropTypes.oneOfType([PropTypes.node]),\n isOpen: PropTypes.bool,\n sliderMaxHeight: PropTypes.number,\n animation: PropTypes.func,\n animationDuration: PropTypes.number,\n onOpen: PropTypes.func,\n onClose: PropTypes.func,\n expandToMaxHeightEnabled: PropTypes.bool\n};\n\nBottomSheet.defaultProps = {\n children: <View />,\n isOpen: true,\n sliderMaxHeight: Dimensions.get('window').height * BOTTOM_SHEET_MAX_PRECANTAGE_SIZE,\n animationDuration: 200,\n onOpen: () => null,\n onClose: () => null,\n expandToMaxHeightEnabled: false\n};\n\nexport default BottomSheet;\n"],"mappings":";;;;;;;AAAA;;AACA;;AAYA;;AACA;;AACA;;AACA;;;;;;;;;;AAeA,MAAMA,WAAW,GAAIC,KAAD,IAA6B;EAC/C,MAAMC,gBAAgB,GAAG,IAAAC,aAAA,EAAO,IAAIC,qBAAA,CAASC,KAAb,CAAmBJ,KAAK,CAACK,eAAzB,CAAP,EAAkDC,OAA3E;EACA,MAAMC,QAAQ,GAAG,IAAAL,aAAA,EAAO,IAAIC,qBAAA,CAASC,KAAb,CAAmB,CAAnB,CAAP,EAA8BE,OAA/C;EACA,MAAME,MAAM,GAAG,IAAAC,4BAAA,EAAgBF,QAAhB,CAAf;EACA,MAAM,CAACG,aAAD,EAAgBC,gBAAhB,IAAoC,IAAAC,eAAA,EAASZ,KAAK,CAACa,MAAf,CAA1C;EACA,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoC,IAAAH,eAAA,EAA6BI,SAA7B,CAA1C;EAEA,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoC,IAAAN,eAAA,EAAiBZ,KAAK,CAACK,eAAvB,CAA1C;EAEA,MAAM,CAACc,EAAD,EAAKC,KAAL,IAAc,IAAAR,eAA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eAAe,EAAEyE,kBAAA,CAAUI,MAHL;EAItBd,SAAS,EAAEU,kBAAA,CAAUK,IAJC;EAKtB1B,iBAAiB,EAAEqB,kBAAA,CAAUI,MALP;EAMtBE,MAAM,EAAEN,kBAAA,CAAUK,IANI;EAOtB3B,OAAO,EAAEsB,kBAAA,CAAUK,IAPG;EAQtBnD,wBAAwB,EAAE8C,kBAAA,CAAUG;AARd,CAAxB;AAWAlF,WAAW,CAACsF,YAAZ,GAA2B;EACzBnB,QAAQ,eAAE,6BAAC,iBAAD,OADe;EAEzBrD,MAAM,EAAE,IAFiB;EAGzBR,eAAe,EAAEiF,uBAAA,CAAWC,GAAX,CAAe,QAAf,EAAyBtB,MAAzB,GAAkCW,wDAH1B;EAIzBnB,iBAAiB,EAAE,GAJM;EAKzB2B,MAAM,EAAE,MAAM,IALW;EAMzB5B,OAAO,EAAE,MAAM,IANU;EAOzBxB,wBAAwB,EAAE;AAPD,CAA3B;eAUejC,W"}
|
|
1
|
+
{"version":3,"names":["BottomSheet","props","panelHeightValue","useRef","Animated","Value","sliderMaxHeight","current","fadeAnim","styles","getStylesObject","isPanelOpened","setIsPanelOpened","useState","isOpen","contentHeight","setContentHeight","undefined","currentHeight","setCurrentHeight","dy","setDy","isAppActive","useAppStateListener","_parentPanResponder","PanResponder","create","onMoveShouldSetPanResponderCapture","_","gestureState","shouldEnableBottomSheetScroll","Math","abs","onPanResponderMove","handleWebViewScroll","expandToMaxHeightEnabled","setValue","onPanResponderRelease","collapse","setToContentHeight","expand","useEffect","_dismiss","fadeIn","BackHandler","addEventListener","_onBackPress","id","addListener","e","value","removeEventListener","removeListener","timing","toValue","duration","useNativeDriver","start","fadeOut","withTimeout","onClose","animationDuration","easing","Easing","quad","onOpen","_setSize","newContentHeight","nativeEvent","layout","height","children","outsideContainer","animation","panHandlers","container","transform","translateY","outerContent","closeButton","CloseIcon","BOTTOM_SHEET_MAX_PERCENTAGE_SIZE","propTypes","PropTypes","oneOfType","node","bool","number","func","defaultProps","Dimensions","get"],"sources":["BottomSheet.tsx"],"sourcesContent":["import React, { ReactNode, useEffect, useRef, useState } from 'react';\nimport {\n Animated,\n BackHandler,\n Dimensions,\n Easing,\n Image,\n KeyboardAvoidingView,\n LayoutChangeEvent,\n PanResponder,\n TouchableOpacity,\n View,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport { CloseIcon } from '../../assets/images';\nimport { BOTTOM_SHEET_MAX_PERCENTAGE_SIZE } from '../../components/UNBottomSheetComponent/UNBottomSheetComponent.constants';\nimport { getStylesObject } from './BottomSheet.styles';\nimport { useAppStateListener } from '../../hooks/useAppStateListener';\n\nexport interface BottomSheetProps {\n isOpen: boolean\n children: ReactNode\n sliderMaxHeight: number\n onOpen: () => void\n onClose: () => void\n height: number,\n animationDuration: number,\n expandToMaxHeightEnabled: boolean\n handleWebViewScroll: () => void\n shouldEnableBottomSheetScroll: boolean\n}\n\nconst BottomSheet = (props: BottomSheetProps) => {\n const panelHeightValue = useRef(new Animated.Value(props.sliderMaxHeight)).current;\n const fadeAnim = useRef(new Animated.Value(0)).current;\n const styles = getStylesObject(fadeAnim);\n const [isPanelOpened, setIsPanelOpened] = useState(props.isOpen);\n const [contentHeight, setContentHeight] = useState<number | undefined>(undefined);\n\n const [currentHeight, setCurrentHeight] = useState<number>(props.sliderMaxHeight);\n\n const [dy, setDy] = useState(0);\n\n const isAppActive = useAppStateListener();\n\n const _parentPanResponder = PanResponder.create({\n onMoveShouldSetPanResponderCapture: (_, gestureState) => {\n return props.shouldEnableBottomSheetScroll && Math.abs(gestureState.dy) > 10;\n },\n onPanResponderMove(_, gestureState) {\n if (props.shouldEnableBottomSheetScroll && gestureState.dy < 5) {\n props.handleWebViewScroll();\n }\n if (currentHeight + gestureState.dy < 0) return;\n if (!props.expandToMaxHeightEnabled && contentHeight && currentHeight + gestureState.dy < sliderMaxHeight - contentHeight) return;\n panelHeightValue.setValue(currentHeight + gestureState.dy);\n setDy(gestureState.dy);\n },\n onPanResponderRelease: () => {\n if (dy > 0) {\n collapse();\n } else if (!props.expandToMaxHeightEnabled) {\n contentHeight && setToContentHeight(contentHeight);\n } else if (dy < 0) {\n expand();\n } else {\n expand();\n }\n }\n });\n\n useEffect(() => {\n if (!isAppActive && isPanelOpened) {\n setContentHeight(0);\n _dismiss(false);\n }\n }, [isAppActive]);\n\n useEffect(() => {\n if (props.isOpen && !isPanelOpened) {\n fadeIn();\n } else if (isPanelOpened) {\n setContentHeight(0);\n _dismiss();\n }\n }, [props.isOpen]);\n\n useEffect(() => {\n BackHandler.addEventListener('hardwareBackPress', _onBackPress);\n const id = panelHeightValue.addListener(e => setCurrentHeight(e.value));\n\n return (() => {\n BackHandler.removeEventListener('hardwareBackPress', _onBackPress);\n panelHeightValue.removeListener(id);\n });\n }, []);\n\n const fadeIn = () => {\n setIsPanelOpened(true);\n Animated.timing(fadeAnim, {\n toValue: 0.3,\n duration: 500,\n useNativeDriver: false\n }).start();\n };\n\n const fadeOut = (withTimeout = true) => {\n /*\n withTimeout - most of the time we declare 'Close' after the animation is end.\n In a case that the app is not active we do it without timeout. (Otherwise a race condition may occur.)\n */\n setIsPanelOpened(false);\n !withTimeout && props.onClose();\n Animated.timing(fadeAnim, {\n toValue: 0,\n duration: 500,\n useNativeDriver: false\n }).start(() => {\n withTimeout && props.onClose();\n });\n };\n\n const setToContentHeight = (contentHeight: number) => {\n Animated.timing(panelHeightValue, {\n duration: props.animationDuration,\n easing: Easing.quad,\n toValue: sliderMaxHeight - contentHeight,\n useNativeDriver: false,\n }).start();\n };\n\n const expand = () => {\n const { animationDuration } = props;\n props.onOpen();\n if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {\n setToContentHeight(contentHeight);\n return;\n }\n\n Animated.timing(panelHeightValue, {\n duration: animationDuration,\n easing: Easing.quad,\n toValue: 0,\n useNativeDriver: false,\n }).start();\n };\n\n const collapse = () => {\n if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {\n _dismiss();\n return;\n }\n\n contentHeight && setToContentHeight(contentHeight);\n };\n\n const _onBackPress = () => {\n isPanelOpened && collapse();\n return isPanelOpened;\n };\n\n const _setSize = (e: LayoutChangeEvent) => {\n const newContentHeight = e.nativeEvent.layout.height;\n\n setContentHeight(newContentHeight);\n setToContentHeight(newContentHeight);\n };\n\n const _dismiss = (withTimeout = true) => {\n const { animationDuration } = props;\n Animated.timing(panelHeightValue, {\n duration: animationDuration,\n easing: Easing.quad,\n toValue: sliderMaxHeight,\n useNativeDriver: false,\n }).start(() => {\n null;\n });\n fadeOut(withTimeout);\n };\n\n const {\n sliderMaxHeight,\n children,\n } = props;\n\n return (\n <>\n <TouchableOpacity\n style={styles.outsideContainer} activeOpacity={1}\n onPress={() => _dismiss()}\n >\n <Animated.View\n style={styles.animation}\n >\n </Animated.View>\n </TouchableOpacity>\n <Animated.View\n {..._parentPanResponder.panHandlers}\n style={{\n ...styles.container,\n height: sliderMaxHeight,\n transform: [\n { translateY: panelHeightValue },\n ],\n }}\n >\n <View\n style={styles.outerContent}\n >\n <TouchableOpacity\n activeOpacity={1}\n style={styles.closeButton}\n onPress={() => _dismiss()}\n >\n <Image source={CloseIcon} />\n </TouchableOpacity>\n\n <View\n onLayout={_setSize}\n >\n <KeyboardAvoidingView\n behavior=\"padding\"\n style={{ height: props.height }}\n keyboardVerticalOffset={props.height * (1 - BOTTOM_SHEET_MAX_PERCENTAGE_SIZE)}\n >\n {children}\n </KeyboardAvoidingView>\n </View>\n </View>\n </Animated.View>\n </>\n );\n};\n\nBottomSheet.propTypes = {\n children: PropTypes.oneOfType([PropTypes.node]),\n isOpen: PropTypes.bool,\n sliderMaxHeight: PropTypes.number,\n animation: PropTypes.func,\n animationDuration: PropTypes.number,\n onOpen: PropTypes.func,\n onClose: PropTypes.func,\n expandToMaxHeightEnabled: PropTypes.bool\n};\n\nBottomSheet.defaultProps = {\n children: <View />,\n isOpen: true,\n sliderMaxHeight: Dimensions.get('window').height * BOTTOM_SHEET_MAX_PERCENTAGE_SIZE,\n animationDuration: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,IAFI;EAGtBhF,eAAe,EAAE6E,kBAAA,CAAUI,MAHL;EAItBd,SAAS,EAAEU,kBAAA,CAAUK,IAJC;EAKtB3B,iBAAiB,EAAEsB,kBAAA,CAAUI,MALP;EAMtBtB,MAAM,EAAEkB,kBAAA,CAAUK,IANI;EAOtB5B,OAAO,EAAEuB,kBAAA,CAAUK,IAPG;EAQtBrD,wBAAwB,EAAEgD,kBAAA,CAAUG;AARd,CAAxB;AAWAtF,WAAW,CAACyF,YAAZ,GAA2B;EACzBlB,QAAQ,eAAE,6BAAC,iBAAD,OADe;EAEzBzD,MAAM,EAAE,IAFiB;EAGzBR,eAAe,EAAEoF,uBAAA,CAAWC,GAAX,CAAe,QAAf,EAAyBrB,MAAzB,GAAkCW,wDAH1B;EAIzBpB,iBAAiB,EAAE,GAJM;EAKzBI,MAAM,EAAE,MAAM,IALW;EAMzBL,OAAO,EAAE,MAAM,IANU;EAOzBzB,wBAAwB,EAAE;AAPD,CAA3B;eAUenC,W"}
|
|
@@ -29,7 +29,7 @@ const getStylesObject = fadeAnim => {
|
|
|
29
29
|
container: {
|
|
30
30
|
position: 'relative',
|
|
31
31
|
flex: 1,
|
|
32
|
-
marginTop: _reactNative.Dimensions.get('window').height * (1 - _UNBottomSheetComponent.
|
|
32
|
+
marginTop: _reactNative.Dimensions.get('window').height * (1 - _UNBottomSheetComponent.BOTTOM_SHEET_MAX_PERCENTAGE_SIZE),
|
|
33
33
|
shadowColor: _variables.VARIABLES.COLORS.BLACK,
|
|
34
34
|
shadowOffset: {
|
|
35
35
|
width: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getStylesObject","fadeAnim","StyleSheet","create","outsideContainer","position","top","bottom","right","left","animation","backgroundColor","flex","opacity","container","marginTop","Dimensions","get","height","
|
|
1
|
+
{"version":3,"names":["getStylesObject","fadeAnim","StyleSheet","create","outsideContainer","position","top","bottom","right","left","animation","backgroundColor","flex","opacity","container","marginTop","Dimensions","get","height","BOTTOM_SHEET_MAX_PERCENTAGE_SIZE","shadowColor","VARIABLES","COLORS","BLACK","shadowOffset","width","shadowOpacity","shadowRadius","elevation","borderTopLeftRadius","borderTopRightRadius","WHITE","overflow","lineContainer","alignItems","line","borderRadius","SILVER_FLAKE","outerContent","innerContent","closeButton","display","justifyContent","padding","zIndex"],"sources":["BottomSheet.styles.ts"],"sourcesContent":["import { Dimensions, StyleSheet } from 'react-native';\nimport { BOTTOM_SHEET_MAX_PERCENTAGE_SIZE } from '../../components/UNBottomSheetComponent/UNBottomSheetComponent.constants';\nimport { VARIABLES } from '../../styles/variables';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const getStylesObject = (fadeAnim: any) => {\n return StyleSheet.create({\n outsideContainer: {\n position: 'absolute',\n top: 0,\n bottom: 0,\n right: 0,\n left: 0\n },\n animation: {\n backgroundColor: 'black',\n flex: 1,\n opacity: fadeAnim,\n },\n container: {\n position: 'relative',\n flex: 1,\n marginTop: Dimensions.get('window').height * (1 - BOTTOM_SHEET_MAX_PERCENTAGE_SIZE),\n shadowColor: VARIABLES.COLORS.BLACK,\n shadowOffset: {\n width: 0,\n height: 6,\n },\n shadowOpacity: 0.37,\n shadowRadius: 7.49,\n elevation: 12,\n borderTopLeftRadius: 15,\n borderTopRightRadius: 15,\n backgroundColor: VARIABLES.COLORS.WHITE,\n overflow: 'hidden'\n },\n lineContainer: {\n borderTopLeftRadius: 30,\n borderTopRightRadius: 30,\n alignItems: 'center'\n },\n line: {\n width: 35,\n height: 4,\n borderRadius: 2,\n marginTop: 18,\n backgroundColor: VARIABLES.COLORS.SILVER_FLAKE,\n },\n outerContent: {\n flex: -1,\n },\n innerContent: {\n flex: -1,\n },\n closeButton: {\n position: 'absolute',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: 36,\n height: 36,\n backgroundColor: VARIABLES.COLORS.WHITE,\n borderRadius: 18,\n padding: 7,\n top: 12,\n right: 12,\n zIndex: 100\n }\n });\n};\n"],"mappings":";;;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,CA1CS;IA6CvB2B,YAAY,EAAE;MACZ3B,IAAI,EAAE,CAAC;IADK,CA7CS;IAgDvB4B,WAAW,EAAE;MACXnC,QAAQ,EAAE,UADC;MAEXoC,OAAO,EAAE,MAFE;MAGXP,UAAU,EAAE,QAHD;MAIXQ,cAAc,EAAE,QAJL;MAKXjB,KAAK,EAAE,EALI;MAMXP,MAAM,EAAE,EANG;MAOXP,eAAe,EAAEU,oBAAA,CAAUC,MAAV,CAAiBS,KAPvB;MAQXK,YAAY,EAAE,EARH;MASXO,OAAO,EAAE,CATE;MAUXrC,GAAG,EAAE,EAVM;MAWXE,KAAK,EAAE,EAXI;MAYXoC,MAAM,EAAE;IAZG;EAhDU,CAAlB,CAAP;AA+DD,CAhEM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EventBus","constructor","eventListeners","Instance","_instance","event","data","listeners","valueOf","Array","isArray","map","listener","addListener","push","removeListener","Object","keys","eventName","_remove","length","array","item","i","l","splice"],"sources":["EventBus.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {
|
|
1
|
+
{"version":3,"names":["EventBus","constructor","eventListeners","Instance","_instance","event","data","listeners","valueOf","Array","isArray","map","listener","addListener","push","removeListener","Object","keys","eventName","_remove","length","array","item","i","l","splice"],"sources":["EventBus.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { NativeMessageType } from '../messages/nativeMessages';\nimport type { WebViewMessageType } from '../messages/webMessages';\n\nexport type BusEventKey = NativeMessageType | WebViewMessageType\n\nexport default class EventBus {\n private static _instance: EventBus;\n\n private eventListeners: { [name: string]: Array<(data: any) => void> } = {};\n\n private constructor() {\n this.eventListeners = {};\n }\n\n public static get Instance() {\n return this._instance || (this._instance = new this());\n }\n\n public event(event: BusEventKey, data?: any) {\n const listeners = this.eventListeners[event.valueOf()];\n if (Array.isArray(listeners)) {\n listeners.map(listener => {\n if (typeof listener === 'function') {\n listener(data);\n }\n });\n }\n }\n\n public addListener(event: BusEventKey, listener: (data: any) => void) {\n const listeners = this.eventListeners[event.valueOf()];\n if (Array.isArray(listeners)) {\n listeners.push(listener);\n } else {\n this.eventListeners[event.valueOf()] = [listener];\n }\n }\n\n public removeListener(listener: (data: any) => void) {\n Object.keys(this.eventListeners).map(eventName => {\n const listeners = this.eventListeners[eventName];\n if (listeners) {\n this._remove(listeners, listener);\n if (listeners.length === 0) {\n delete this.eventListeners[eventName];\n }\n }\n });\n }\n\n private _remove(array: Array<(data: any) => void>, item: (data: string) => void) {\n if (!array) return;\n for (let i = 0, l = array.length; i < l; i++) {\n if (item === array[i]) array.splice(i, 1);\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA;AAMe,MAAMA,QAAN,CAAe;EAKpBC,WAAW,GAAG;IAAA,wCAFmD,EAEnD;;IACpB,KAAKC,cAAL,GAAsB,EAAtB;EACD;;EAEyB,WAARC,QAAQ,GAAG;IAC3B,OAAO,KAAKC,SAAL,KAAmB,KAAKA,SAAL,GAAiB,IAAI,IAAJ,EAApC,CAAP;EACD;;EAEMC,KAAK,CAACA,KAAD,EAAqBC,IAArB,EAAiC;IAC3C,MAAMC,SAAS,GAAG,KAAKL,cAAL,CAAoBG,KAAK,CAACG,OAAN,EAApB,CAAlB;;IACA,IAAIC,KAAK,CAACC,OAAN,CAAcH,SAAd,CAAJ,EAA8B;MAC5BA,SAAS,CAACI,GAAV,CAAcC,QAAQ,IAAI;QACxB,IAAI,OAAOA,QAAP,KAAoB,UAAxB,EAAoC;UAClCA,QAAQ,CAACN,IAAD,CAAR;QACD;MACF,CAJD;IAKD;EACF;;EAEMO,WAAW,CAACR,KAAD,EAAqBO,QAArB,EAAoD;IACpE,MAAML,SAAS,GAAG,KAAKL,cAAL,CAAoBG,KAAK,CAACG,OAAN,EAApB,CAAlB;;IACA,IAAIC,KAAK,CAACC,OAAN,CAAcH,SAAd,CAAJ,EAA8B;MAC5BA,SAAS,CAACO,IAAV,CAAeF,QAAf;IACD,CAFD,MAEO;MACL,KAAKV,cAAL,CAAoBG,KAAK,CAACG,OAAN,EAApB,IAAuC,CAACI,QAAD,CAAvC;IACD;EACF;;EAEMG,cAAc,CAACH,QAAD,EAAgC;IACnDI,MAAM,CAACC,IAAP,CAAY,KAAKf,cAAjB,EAAiCS,GAAjC,CAAqCO,SAAS,IAAI;MAChD,MAAMX,SAAS,GAAG,KAAKL,cAAL,CAAoBgB,SAApB,CAAlB;;MACA,IAAIX,SAAJ,EAAe;QACb,KAAKY,OAAL,CAAaZ,SAAb,EAAwBK,QAAxB;;QACA,IAAIL,SAAS,CAACa,MAAV,KAAqB,CAAzB,EAA4B;UAC1B,OAAO,KAAKlB,cAAL,CAAoBgB,SAApB,CAAP;QACD;MACF;IACF,CARD;EASD;;EAEOC,OAAO,CAACE,KAAD,EAAoCC,IAApC,EAAkE;IAC/E,IAAI,CAACD,KAAL,EAAY;;IACZ,KAAK,IAAIE,CAAC,GAAG,CAAR,EAAWC,CAAC,GAAGH,KAAK,CAACD,MAA1B,EAAkCG,CAAC,GAAGC,CAAtC,EAAyCD,CAAC,EAA1C,EAA8C;MAC5C,IAAID,IAAI,KAAKD,KAAK,CAACE,CAAD,CAAlB,EAAuBF,KAAK,CAACI,MAAN,CAAaF,CAAb,EAAgB,CAAhB;IACxB;EACF;;AAlD2B;;;;gBAATvB,Q"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CardNativeMessage = exports.CardAddToWalletStatus = exports.CardAddToWalletErrors = void 0;
|
|
7
|
+
let CardNativeMessage;
|
|
8
|
+
exports.CardNativeMessage = CardNativeMessage;
|
|
9
|
+
|
|
10
|
+
(function (CardNativeMessage) {
|
|
11
|
+
CardNativeMessage["CARD_GET_ADD_TO_WALLET_STATUS"] = "cardGetAddToWalletStatus";
|
|
12
|
+
CardNativeMessage["CARD_UPDATE_ADD_TO_WALLET_STATUS"] = "cardUpdateAddToWalletStatus";
|
|
13
|
+
CardNativeMessage["CARD_START_PUSH_PROVISIONING"] = "cardStartPushProvisioning";
|
|
14
|
+
})(CardNativeMessage || (exports.CardNativeMessage = CardNativeMessage = {}));
|
|
15
|
+
|
|
16
|
+
let CardAddToWalletStatus;
|
|
17
|
+
exports.CardAddToWalletStatus = CardAddToWalletStatus;
|
|
18
|
+
|
|
19
|
+
(function (CardAddToWalletStatus) {
|
|
20
|
+
CardAddToWalletStatus[CardAddToWalletStatus["pending"] = 0] = "pending";
|
|
21
|
+
CardAddToWalletStatus["readyToProvisioning"] = "ReadyToProvision";
|
|
22
|
+
CardAddToWalletStatus["addedToWallet"] = "AlreadyProvisioned";
|
|
23
|
+
CardAddToWalletStatus["iosProvisionedInCurrentDevice"] = "ProvisionedInCurrentDevice";
|
|
24
|
+
CardAddToWalletStatus["iosProvisionedInPairedDevice"] = "ProvisionedInPairedDevice";
|
|
25
|
+
CardAddToWalletStatus["androidNotInstalled"] = "NotInstalled";
|
|
26
|
+
CardAddToWalletStatus["androidWalletSetupNotCompleted"] = "WalletSetupNotCompleted";
|
|
27
|
+
CardAddToWalletStatus["androidWalletAppUpdateAvailable"] = "WalletAppUpdateAvailable";
|
|
28
|
+
})(CardAddToWalletStatus || (exports.CardAddToWalletStatus = CardAddToWalletStatus = {}));
|
|
29
|
+
|
|
30
|
+
let CardAddToWalletErrors;
|
|
31
|
+
exports.CardAddToWalletErrors = CardAddToWalletErrors;
|
|
32
|
+
|
|
33
|
+
(function (CardAddToWalletErrors) {
|
|
34
|
+
CardAddToWalletErrors["closedNativeWalletScreen"] = "VP_ERROR_302";
|
|
35
|
+
})(CardAddToWalletErrors || (exports.CardAddToWalletErrors = CardAddToWalletErrors = {}));
|
|
36
|
+
//# sourceMappingURL=cardMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CardNativeMessage","CardAddToWalletStatus","CardAddToWalletErrors"],"sources":["cardMessage.ts"],"sourcesContent":["export enum CardNativeMessage {\n CARD_GET_ADD_TO_WALLET_STATUS = 'cardGetAddToWalletStatus',\n CARD_UPDATE_ADD_TO_WALLET_STATUS = 'cardUpdateAddToWalletStatus',\n CARD_START_PUSH_PROVISIONING = 'cardStartPushProvisioning'\n}\n\nexport enum CardAddToWalletStatus {\n pending,\n readyToProvisioning = 'ReadyToProvision',\n addedToWallet = 'AlreadyProvisioned',\n iosProvisionedInCurrentDevice = 'ProvisionedInCurrentDevice',\n iosProvisionedInPairedDevice = 'ProvisionedInPairedDevice',\n androidNotInstalled = 'NotInstalled',\n androidWalletSetupNotCompleted = 'WalletSetupNotCompleted',\n androidWalletAppUpdateAvailable = 'WalletAppUpdateAvailable'\n\n}\n\nexport enum CardAddToWalletErrors {\n closedNativeWalletScreen = 'VP_ERROR_302'\n}\nexport interface CardAddToWalletStatusEvent {\n status: CardAddToWalletStatus\n}\n\nexport interface CardGetAddToWalletStatusEvent {\n cardId: string\n}\n\nexport interface CardStartPushProvisioningEvent {\n cardId: string\n}\n\nexport type CardNativeEvent =\n | CardAddToWalletStatusEvent\n | CardGetAddToWalletStatusEvent\n | CardStartPushProvisioningEvent\n"],"mappings":";;;;;;IAAYA,iB;;;WAAAA,iB;EAAAA,iB;EAAAA,iB;EAAAA,iB;GAAAA,iB,iCAAAA,iB;;IAMAC,qB;;;WAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB;EAAAA,qB;EAAAA,qB;EAAAA,qB;EAAAA,qB;EAAAA,qB;EAAAA,qB;GAAAA,qB,qCAAAA,qB;;IAYAC,qB;;;WAAAA,qB;EAAAA,qB;GAAAA,qB,qCAAAA,qB"}
|
|
@@ -3,11 +3,4 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.NativeMessage = void 0;
|
|
7
|
-
let NativeMessage;
|
|
8
|
-
exports.NativeMessage = NativeMessage;
|
|
9
|
-
|
|
10
|
-
(function (NativeMessage) {
|
|
11
|
-
NativeMessage["IS_SCRIPT_FETCHED"] = "isScriptFetched";
|
|
12
|
-
})(NativeMessage || (exports.NativeMessage = NativeMessage = {}));
|
|
13
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import type { CardNativeEvent, CardNativeMessage } from './cardMessage';\nimport type { SDKEvent, SDKMessage } from './sdkMessage';\n\nexport type NativeMessageType =\n | SDKMessage\n | CardNativeMessage\n\nexport type NativeEvent =\n | CardNativeEvent\n | SDKEvent\n\nexport interface NativeMessage {\n type: NativeMessageType,\n details?: NativeEvent\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SDKMessage = void 0;
|
|
7
|
+
let SDKMessage;
|
|
8
|
+
exports.SDKMessage = SDKMessage;
|
|
9
|
+
|
|
10
|
+
(function (SDKMessage) {
|
|
11
|
+
SDKMessage["IS_SCRIPT_FETCHED"] = "isScriptFetched";
|
|
12
|
+
SDKMessage["IS_SDK_INITIALIZED"] = "isSdkInitialized";
|
|
13
|
+
})(SDKMessage || (exports.SDKMessage = SDKMessage = {}));
|
|
14
|
+
//# sourceMappingURL=sdkMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SDKMessage"],"sources":["sdkMessage.ts"],"sourcesContent":["export enum SDKMessage {\n IS_SCRIPT_FETCHED = 'isScriptFetched',\n IS_SDK_INITIALIZED = 'isSdkInitialized',\n}\n\nexport interface SdkScriptFetched {\n unitScript: string\n}\n\nexport type SDKEvent =\n | SdkScriptFetched\n"],"mappings":";;;;;;IAAYA,U;;;WAAAA,U;EAAAA,U;EAAAA,U;GAAAA,U,0BAAAA,U"}
|
|
@@ -13,5 +13,6 @@ exports.UnitMessage = UnitMessage;
|
|
|
13
13
|
UnitMessage["UNIT_REQUEST_CLOSE_FLOW"] = "unitRequestCloseFlow";
|
|
14
14
|
UnitMessage["UNIT_REQUEST_OPEN_LINK"] = "unitRequestOpenLink";
|
|
15
15
|
UnitMessage["UNIT_ON_LOAD"] = "unitOnLoad";
|
|
16
|
+
UnitMessage["UNIT_REQUEST_DOWNLOAD"] = "unitRequestDownload";
|
|
16
17
|
})(UnitMessage || (exports.UnitMessage = UnitMessage = {}));
|
|
17
18
|
//# sourceMappingURL=unitMessages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["UnitMessage"],"sources":["unitMessages.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":["UnitMessage"],"sources":["unitMessages.ts"],"sourcesContent":["import type { ResponseUnitOnLoadEvent } from '../../sharedTypes';\n\nexport enum UnitMessage {\n UNIT_REQUEST_RENDERING = 'unitRequestRendering',\n UNIT_REQUEST_REFRESH = 'unitRequestRefresh',\n UNIT_REQUEST_CLOSE_FLOW = 'unitRequestCloseFlow',\n UNIT_REQUEST_OPEN_LINK = 'unitRequestOpenLink',\n UNIT_ON_LOAD = 'unitOnLoad',\n UNIT_REQUEST_DOWNLOAD = 'unitRequestDownload'\n}\nexport interface RequestRenderingEvent {\n data: RequestRenderingEventData\n}\n\nexport interface RequestRenderingEventData {\n actionType?: string,\n nativePlace: string,\n nativeComponent: string,\n}\n\nexport interface RequestRefreshEvent {\n refEvent: string;\n dependencies: string[];\n resourceId: string;\n}\n\nexport interface RequestOpenLinkEvent {\n href: string;\n target: string\n}\n\nexport interface RequestDownloadEvent {\n url: string\n accessToken: string\n fileType: string\n responseType: string\n fileName: string\n}\n\nexport type UnitEvent =\n | RequestRenderingEvent\n | RequestRefreshEvent\n | RequestOpenLinkEvent\n | ResponseUnitOnLoadEvent\n | RequestDownloadEvent\n"],"mappings":";;;;;;IAEYA,W;;;WAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,2BAAAA,W"}
|
package/lib/commonjs/nativeComponent/{UNNativeAddToWalletButton.js → UnitAddToWalletButton.js}
RENAMED
|
@@ -10,4 +10,4 @@ var _reactNative = require("react-native");
|
|
|
10
10
|
const UnitAddToWalletButtonView = (0, _reactNative.requireNativeComponent)('UnitAddToWalletButtonView');
|
|
11
11
|
var _default = UnitAddToWalletButtonView;
|
|
12
12
|
exports.default = _default;
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=UnitAddToWalletButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["UnitAddToWalletButtonView","requireNativeComponent"],"sources":["UnitAddToWalletButton.tsx"],"sourcesContent":["import {\n requireNativeComponent,\n} from 'react-native';\n\ntype UnitAddToWalletButtonViewProps = {\n style: object;\n onAddToWalletClicked: () => void;\n};\n\nconst UnitAddToWalletButtonView = requireNativeComponent<UnitAddToWalletButtonViewProps>('UnitAddToWalletButtonView');\n\nexport default UnitAddToWalletButtonView;\n"],"mappings":";;;;;;;AAAA;;AASA,MAAMA,yBAAyB,GAAG,IAAAC,mCAAA,EAAuD,2BAAvD,CAAlC;eAEeD,yB"}
|
|
@@ -16,7 +16,7 @@ exports.PresentationMode = PresentationMode;
|
|
|
16
16
|
})(PresentationMode || (exports.PresentationMode = PresentationMode = {}));
|
|
17
17
|
|
|
18
18
|
const getHtmlBody = (unitComponent, unitComponentProps, presentationMode) => {
|
|
19
|
-
const currentComponent = `<${unitComponent} ${unitComponentProps || ''}> </${unitComponent}>`;
|
|
19
|
+
const currentComponent = `<${unitComponent} ${unitComponentProps || ''} }> </${unitComponent}>`;
|
|
20
20
|
|
|
21
21
|
switch (presentationMode) {
|
|
22
22
|
case PresentationMode.CoverInjectedHeight:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["webViewId","PresentationMode","getHtmlBody","unitComponent","unitComponentProps","presentationMode","currentComponent","CoverInjectedHeight","getCoverInjectedHeightBodyScript","Inherit","getInheritParentSizeScript","currentUnitScript"],"sources":["bodyHtml.ts"],"sourcesContent":["export const webViewId = 'webViewContainer';\n\nexport enum PresentationMode {\n /*\n CoverInjectedHeight - give id (<webViewId> param) to enable style injection to the root. Then cover the injected height.\n\n Inherit - inherit the parent size by style of 100 view height\n\n Default - return the unit component script\n */\n\n CoverInjectedHeight = 'coverInjectedHeight',\n Inherit = 'inherit',\n Default = 'deafult'\n}\n\nexport const getHtmlBody = (unitComponent: string, unitComponentProps?: string, presentationMode?: PresentationMode) => {\n const currentComponent = `<${unitComponent} ${unitComponentProps || ''}> </${unitComponent}>`;\n\n switch (presentationMode) {\n case PresentationMode.CoverInjectedHeight:\n return getCoverInjectedHeightBodyScript(currentComponent);\n case PresentationMode.Inherit:\n return getInheritParentSizeScript(currentComponent);\n default:\n return currentComponent;\n }\n};\n\nconst getCoverInjectedHeightBodyScript = (currentUnitScript: string) => {\n return `\n <div id=${webViewId}>\n <div style=\"height: 100%; display: block; padding: 1px;\">\n ${currentUnitScript}\n </div>\n </div>\n `;\n};\n\nconst getInheritParentSizeScript = (currentUnitScript: string) => {\n return `\n <div style=\"height: 100vh\">\n ${currentUnitScript}\n </div>\n `;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAG,kBAAlB;;IAEKC,gB;;;WAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,gCAAAA,gB;;AAcL,MAAMC,WAAW,GAAG,CAACC,aAAD,EAAwBC,kBAAxB,EAAqDC,gBAArD,KAA6F;EACtH,MAAMC,gBAAgB,GAAI,IAAGH,aAAc,IAAGC,kBAAkB,IAAI,EAAG,
|
|
1
|
+
{"version":3,"names":["webViewId","PresentationMode","getHtmlBody","unitComponent","unitComponentProps","presentationMode","currentComponent","CoverInjectedHeight","getCoverInjectedHeightBodyScript","Inherit","getInheritParentSizeScript","currentUnitScript"],"sources":["bodyHtml.ts"],"sourcesContent":["export const webViewId = 'webViewContainer';\n\nexport enum PresentationMode {\n /*\n CoverInjectedHeight - give id (<webViewId> param) to enable style injection to the root. Then cover the injected height.\n\n Inherit - inherit the parent size by style of 100 view height\n\n Default - return the unit component script\n */\n\n CoverInjectedHeight = 'coverInjectedHeight',\n Inherit = 'inherit',\n Default = 'deafult'\n}\n\nexport const getHtmlBody = (unitComponent: string, unitComponentProps?: string, presentationMode?: PresentationMode) => {\n const currentComponent = `<${unitComponent} ${unitComponentProps || ''} }> </${unitComponent}>`;\n\n switch (presentationMode) {\n case PresentationMode.CoverInjectedHeight:\n return getCoverInjectedHeightBodyScript(currentComponent);\n case PresentationMode.Inherit:\n return getInheritParentSizeScript(currentComponent);\n default:\n return currentComponent;\n }\n};\n\nconst getCoverInjectedHeightBodyScript = (currentUnitScript: string) => {\n return `\n <div id=${webViewId}>\n <div style=\"height: 100%; display: block; padding: 1px;\">\n ${currentUnitScript}\n </div>\n </div>\n `;\n};\n\nconst getInheritParentSizeScript = (currentUnitScript: string) => {\n return `\n <div style=\"height: 100vh\">\n ${currentUnitScript}\n </div>\n `;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAG,kBAAlB;;IAEKC,gB;;;WAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,gCAAAA,gB;;AAcL,MAAMC,WAAW,GAAG,CAACC,aAAD,EAAwBC,kBAAxB,EAAqDC,gBAArD,KAA6F;EACtH,MAAMC,gBAAgB,GAAI,IAAGH,aAAc,IAAGC,kBAAkB,IAAI,EAAG,SAAQD,aAAc,GAA7F;;EAEA,QAAQE,gBAAR;IACE,KAAKJ,gBAAgB,CAACM,mBAAtB;MACE,OAAOC,gCAAgC,CAACF,gBAAD,CAAvC;;IACF,KAAKL,gBAAgB,CAACQ,OAAtB;MACE,OAAOC,0BAA0B,CAACJ,gBAAD,CAAjC;;IACF;MACE,OAAOA,gBAAP;EANJ;AAQD,CAXM;;;;AAaP,MAAME,gCAAgC,GAAIG,iBAAD,IAA+B;EACtE,OAAQ;AACV,cAAcX,SAAU;AACxB;AACA,UAAUW,iBAAkB;AAC5B;AACA;AACA,GANE;AAOD,CARD;;AAUA,MAAMD,0BAA0B,GAAIC,iBAAD,IAA+B;EAChE,OAAQ;AACV;AACA,QAAQA,iBAAkB;AAC1B;AACA,GAJE;AAKD,CAND"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.POST_PAGE_HEIGHT = exports.POST_MESSAGE_TO_SDK = exports.LISTENERS = exports.
|
|
6
|
+
exports.POST_PAGE_HEIGHT = exports.POST_MESSAGE_TO_SDK = exports.LISTENERS = exports.DISPATCH_REQUEST_REFRESH = exports.DISPATCH_RENDERING_EVENT = void 0;
|
|
7
7
|
|
|
8
8
|
var _cardMessage = require("../../messages/webMessages/cardMessage");
|
|
9
9
|
|
|
@@ -37,13 +37,18 @@ const LISTENERS = {
|
|
|
37
37
|
`,
|
|
38
38
|
requestRendering: `
|
|
39
39
|
window.addEventListener("${_unitMessages.UnitMessage.UNIT_REQUEST_RENDERING}", (e) => {
|
|
40
|
-
postMessageToSDK({ type: "${_unitMessages.UnitMessage.UNIT_REQUEST_RENDERING}", details: { data:
|
|
40
|
+
postMessageToSDK({ type: "${_unitMessages.UnitMessage.UNIT_REQUEST_RENDERING}", details: { data: e.detail }})
|
|
41
|
+
});
|
|
42
|
+
`,
|
|
43
|
+
requestRefresh: `
|
|
44
|
+
window.addEventListener("${_unitMessages.UnitMessage.UNIT_REQUEST_REFRESH}", (e) => {
|
|
45
|
+
postMessageToSDK({ type: "${_unitMessages.UnitMessage.UNIT_REQUEST_REFRESH}", details: e.detail })
|
|
41
46
|
});
|
|
42
47
|
`,
|
|
43
48
|
onLoad: `
|
|
44
49
|
window.addEventListener("${_unitMessages.UnitMessage.UNIT_ON_LOAD}", (e) => {
|
|
45
50
|
postHeight()
|
|
46
|
-
postMessageToSDK({ type: "${_unitMessages.UnitMessage.UNIT_ON_LOAD}" })
|
|
51
|
+
postMessageToSDK({ type: "${_unitMessages.UnitMessage.UNIT_ON_LOAD}", details: e.detail })
|
|
47
52
|
});
|
|
48
53
|
`,
|
|
49
54
|
requestCloseFlow: `
|
|
@@ -56,6 +61,11 @@ const LISTENERS = {
|
|
|
56
61
|
postMessageToSDK({ type: "${_unitMessages.UnitMessage.UNIT_REQUEST_OPEN_LINK}", details: e.detail })
|
|
57
62
|
});
|
|
58
63
|
`,
|
|
64
|
+
unitRequestDownload: `
|
|
65
|
+
window.addEventListener("${_unitMessages.UnitMessage.UNIT_REQUEST_DOWNLOAD}", (e) => {
|
|
66
|
+
postMessageToSDK({ type: "${_unitMessages.UnitMessage.UNIT_REQUEST_DOWNLOAD}", details: e.detail })
|
|
67
|
+
});
|
|
68
|
+
`,
|
|
59
69
|
cardStatusChange: `
|
|
60
70
|
window.addEventListener("${_cardMessage.CardMessage.CARD_STATUS_CHANGED}", (e) => {
|
|
61
71
|
const response = e.detail
|
|
@@ -68,11 +78,18 @@ const LISTENERS = {
|
|
|
68
78
|
`
|
|
69
79
|
};
|
|
70
80
|
exports.LISTENERS = LISTENERS;
|
|
71
|
-
const
|
|
81
|
+
const DISPATCH_RENDERING_EVENT = `
|
|
72
82
|
const dispatchRenderingEvent = (details) => {
|
|
73
83
|
const event = new CustomEvent("${_unitMessages.UnitMessage.UNIT_REQUEST_RENDERING}",{ detail: JSON.parse(details) })
|
|
74
84
|
window.dispatchEvent(event)
|
|
75
85
|
}
|
|
76
86
|
`;
|
|
77
|
-
exports.
|
|
87
|
+
exports.DISPATCH_RENDERING_EVENT = DISPATCH_RENDERING_EVENT;
|
|
88
|
+
const DISPATCH_REQUEST_REFRESH = `
|
|
89
|
+
const dispatchRefreshEvent = (details) => {
|
|
90
|
+
const event = new CustomEvent("${_unitMessages.UnitMessage.UNIT_REQUEST_REFRESH}",{ detail: JSON.parse(details) })
|
|
91
|
+
window.dispatchEvent(event)
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
exports.DISPATCH_REQUEST_REFRESH = DISPATCH_REQUEST_REFRESH;
|
|
78
95
|
//# sourceMappingURL=bodyScript.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["POST_MESSAGE_TO_SDK","POST_PAGE_HEIGHT","PageMessage","PAGE_HEIGHT","LISTENERS","isPageLoaded","PAGE_LOADED","requestRendering","UnitMessage","UNIT_REQUEST_RENDERING","onLoad","UNIT_ON_LOAD","requestCloseFlow","UNIT_REQUEST_CLOSE_FLOW","requestOpenLink","UNIT_REQUEST_OPEN_LINK","cardStatusChange","CardMessage","CARD_STATUS_CHANGED","
|
|
1
|
+
{"version":3,"names":["POST_MESSAGE_TO_SDK","POST_PAGE_HEIGHT","PageMessage","PAGE_HEIGHT","LISTENERS","isPageLoaded","PAGE_LOADED","requestRendering","UnitMessage","UNIT_REQUEST_RENDERING","requestRefresh","UNIT_REQUEST_REFRESH","onLoad","UNIT_ON_LOAD","requestCloseFlow","UNIT_REQUEST_CLOSE_FLOW","requestOpenLink","UNIT_REQUEST_OPEN_LINK","unitRequestDownload","UNIT_REQUEST_DOWNLOAD","cardStatusChange","CardMessage","CARD_STATUS_CHANGED","DISPATCH_RENDERING_EVENT","DISPATCH_REQUEST_REFRESH"],"sources":["bodyScript.ts"],"sourcesContent":["import { CardMessage } from '../../messages/webMessages/cardMessage';\nimport { PageMessage } from '../../messages/webMessages/pageMessage';\nimport { UnitMessage } from '../../messages/webMessages/unitMessages';\n\nexport const POST_MESSAGE_TO_SDK = `\n const postMessageToSDK = (message) => {\n if ('ReactNativeWebView' in window) {\n const messageString = JSON.stringify(message)\n window['ReactNativeWebView'].postMessage(messageString)\n }\n }\n`;\n\nexport const POST_PAGE_HEIGHT = `\n const postHeight = () => {\n setTimeout(() => {\n const height = window.document.documentElement.getBoundingClientRect().height\n postMessageToSDK({ type: \"${PageMessage.PAGE_HEIGHT}\", details: { height } })\n })\n }\n`;\n\nexport const LISTENERS = {\n isPageLoaded: `\n window.addEventListener('DOMContentLoaded', e => {\n postMessageToSDK({ type: \"${PageMessage.PAGE_LOADED}\" })\n });\n `,\n requestRendering: `\n window.addEventListener(\"${UnitMessage.UNIT_REQUEST_RENDERING}\", (e) => {\n postMessageToSDK({ type: \"${UnitMessage.UNIT_REQUEST_RENDERING}\", details: { data: e.detail }})\n });\n `,\n requestRefresh: `\n window.addEventListener(\"${UnitMessage.UNIT_REQUEST_REFRESH}\", (e) => {\n postMessageToSDK({ type: \"${UnitMessage.UNIT_REQUEST_REFRESH}\", details: e.detail })\n });\n `,\n onLoad: `\n window.addEventListener(\"${UnitMessage.UNIT_ON_LOAD}\", (e) => {\n postHeight()\n postMessageToSDK({ type: \"${UnitMessage.UNIT_ON_LOAD}\", details: e.detail })\n });\n `,\n requestCloseFlow: `\n window.addEventListener(\"${UnitMessage.UNIT_REQUEST_CLOSE_FLOW}\", (e) => {\n postMessageToSDK({ type: \"${UnitMessage.UNIT_REQUEST_CLOSE_FLOW}\" })\n });\n `,\n requestOpenLink: `\n window.addEventListener(\"${UnitMessage.UNIT_REQUEST_OPEN_LINK}\", (e) => {\n postMessageToSDK({ type: \"${UnitMessage.UNIT_REQUEST_OPEN_LINK}\", details: e.detail })\n });\n `,\n unitRequestDownload: `\n window.addEventListener(\"${UnitMessage.UNIT_REQUEST_DOWNLOAD}\", (e) => {\n postMessageToSDK({ type: \"${UnitMessage.UNIT_REQUEST_DOWNLOAD}\", details: e.detail })\n });\n `,\n cardStatusChange: `\n window.addEventListener(\"${CardMessage.CARD_STATUS_CHANGED}\", (e) => {\n const response = e.detail\n response.then((data) => {\n postMessageToSDK({ type: \"${CardMessage.CARD_STATUS_CHANGED}\", details: { card: JSON.stringify(data.data) }})\n }).catch((e) => {\n console.log(e)\n })\n });\n `\n};\n\nexport const DISPATCH_RENDERING_EVENT = `\n const dispatchRenderingEvent = (details) => {\n const event = new CustomEvent(\"${UnitMessage.UNIT_REQUEST_RENDERING}\",{ detail: JSON.parse(details) })\n window.dispatchEvent(event)\n }\n`;\n\nexport const DISPATCH_REQUEST_REFRESH = `\n const dispatchRefreshEvent = (details) => {\n const event = new CustomEvent(\"${UnitMessage.UNIT_REQUEST_REFRESH}\",{ detail: JSON.parse(details) })\n window.dispatchEvent(event)\n }\n`;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEO,MAAMA,mBAAmB,GAAI;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,CAPO;;AASA,MAAMC,gBAAgB,GAAI;AACjC;AACA;AACA;AACA,kCAAkCC,wBAAA,CAAYC,WAAY;AAC1D;AACA;AACA,CAPO;;AASA,MAAMC,SAAS,GAAG;EACvBC,YAAY,EAAG;AACjB;AACA,kCAAkCH,wBAAA,CAAYI,WAAY;AAC1D;AACA,GALyB;EAMvBC,gBAAgB,EAAG;AACrB,+BAA+BC,yBAAA,CAAYC,sBAAuB;AAClE,kCAAkCD,yBAAA,CAAYC,sBAAuB;AACrE;AACA,GAVyB;EAWvBC,cAAc,EAAG;AACnB,+BAA+BF,yBAAA,CAAYG,oBAAqB;AAChE,kCAAkCH,yBAAA,CAAYG,oBAAqB;AACnE;AACA,GAfyB;EAgBvBC,MAAM,EAAG;AACX,+BAA+BJ,yBAAA,CAAYK,YAAa;AACxD;AACA,kCAAkCL,yBAAA,CAAYK,YAAa;AAC3D;AACA,GArByB;EAsBvBC,gBAAgB,EAAG;AACrB,+BAA+BN,yBAAA,CAAYO,uBAAwB;AACnE,kCAAkCP,yBAAA,CAAYO,uBAAwB;AACtE;AACA,GA1ByB;EA2BvBC,eAAe,EAAG;AACpB,+BAA+BR,yBAAA,CAAYS,sBAAuB;AAClE,kCAAkCT,yBAAA,CAAYS,sBAAuB;AACrE;AACA,GA/ByB;EAgCvBC,mBAAmB,EAAG;AACxB,+BAA+BV,yBAAA,CAAYW,qBAAsB;AACjE,kCAAkCX,yBAAA,CAAYW,qBAAsB;AACpE;AACA,GApCyB;EAqCvBC,gBAAgB,EAAG;AACrB,+BAA+BC,wBAAA,CAAYC,mBAAoB;AAC/D;AACA;AACA,oCAAoCD,wBAAA,CAAYC,mBAAoB;AACpE;AACA;AACA;AACA;AACA;AA9CyB,CAAlB;;AAiDA,MAAMC,wBAAwB,GAAI;AACzC;AACA,qCAAqCf,yBAAA,CAAYC,sBAAuB;AACxE;AACA;AACA,CALO;;AAOA,MAAMe,wBAAwB,GAAI;AACzC;AACA,qCAAqChB,yBAAA,CAAYG,oBAAqB;AACtE;AACA;AACA,CALO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["bookPayment.types.ts"],"sourcesContent":["import type { Tags, Relationship } from
|
|
1
|
+
{"version":3,"names":[],"sources":["bookPayment.types.ts"],"sourcesContent":["import type { Tags, Relationship } from './types';\n\ntype BookPaymentStatus = 'Sent' | 'Rejected'\n\nexport type UNBookPaymentData = {\n type: 'bookPayment',\n id: string,\n attributes: {\n createdAt: string | Date,\n status: BookPaymentStatus,\n reason: string,\n direction: 'Debit' | 'Credit',\n description: string,\n transactionSummaryOverride?: string,\n amount: string,\n tags: Tags,\n },\n relationships: {\n account: Relationship,\n customer?: Relationship,\n customers?: Relationship,\n counterpartyAccount: Relationship,\n counterpartyCustomer: Relationship,\n transaction: Relationship,\n recurringPayment: Relationship\n }\n}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["card.types.ts"],"sourcesContent":["import type { Address, FullName, Limits, Relationship, Tags } from
|
|
1
|
+
{"version":3,"names":[],"sources":["card.types.ts"],"sourcesContent":["import type { Address, FullName, Limits, Relationship, Tags } from './types';\n\nexport type UNCardData = IndividualDebitCard | BusinessDebitCard\n\ntype CardStatus = 'Active' | 'Inactive' | 'Stolen' | 'Lost' | 'Frozen' | 'ClosedByCustomer' | 'SuspectedFraud'\n\nexport type IndividualDebitCard = {\n id: string,\n type: 'individualDebitCard' | 'individualVirtualDebitCard',\n attributes: {\n createdAt: string,\n last4Digits: string,\n expirationDate: string,\n status: CardStatus,\n shippingAddress?: Address, /* not exists in virtual card */\n updatedAt?: string,\n design?: string,\n additionalEmbossedText?: string,\n idempotencyKey?: string,\n tags?: Tags,\n limits?: Limits,\n printOnlyBusinessName?: boolean\n },\n relationships: {\n account: Relationship,\n customer: Relationship\n }\n}\n\nexport type BusinessDebitCard = {\n id: string,\n type: 'businessDebitCard' | 'businessVirtualDebitCard',\n attributes: {\n fullName: FullName,\n dateOfBirth: string,\n address: Address,\n shippingAddress?: Address,\n phone: string,\n email: string,\n createdAt: string,\n last4Digits: string,\n expirationDate: string,\n status: CardStatus,\n updatedAt?: string,\n ssn?: string,\n passport?: string,\n nationality?: string,\n design?: string,\n additionalEmbossedText?: string,\n idempotencyKey?: string,\n tags?: Record<string, string>\n limits?: Limits,\n printOnlyBusinessName?: boolean\n },\n relationships: {\n account: Relationship,\n customer: Relationship\n }\n}\n"],"mappings":""}
|
|
@@ -29,4 +29,17 @@ Object.keys(_card).forEach(function (key) {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
|
+
|
|
33
|
+
var _onLoadResponse = require("./onLoadResponse.types");
|
|
34
|
+
|
|
35
|
+
Object.keys(_onLoadResponse).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _onLoadResponse[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _onLoadResponse[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
32
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './bookPayment.types';\nexport * from './card.types';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './bookPayment.types';\nexport * from './card.types';\nexport * from './onLoadResponse.types';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["onLoadResponse.types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport type { UNCardData } from '../sharedTypes';\n\nexport type SuccessResponseUnitOnLoad = {\n /*\n Object since the current response data types from 'Activities' and 'BookPayment' do not have documentation.\n When things are determined, we may update it\n */\n data: UNCardData | Object,\n included: [Object],\n errors: null\n}\n\nexport type ErrorResponseUnitOnLoad = {\n errors: [\n {\n status: string,\n title: string,\n detail?: string,\n details?: string,\n meta?: Record<string, string>\n }\n ]\n}\nexport type ResponseUnitOnLoadEvent =\n | SuccessResponseUnitOnLoad\n | ErrorResponseUnitOnLoad\n"],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UNWalletName = exports.UNWalletCode = void 0;
|
|
7
|
+
let UNWalletCode;
|
|
8
|
+
exports.UNWalletCode = UNWalletCode;
|
|
9
|
+
|
|
10
|
+
(function (UNWalletCode) {
|
|
11
|
+
UNWalletCode["Apple"] = "ApplePayPushProvision";
|
|
12
|
+
UNWalletCode["Google"] = "GooglePayPushProvision";
|
|
13
|
+
})(UNWalletCode || (exports.UNWalletCode = UNWalletCode = {}));
|
|
14
|
+
|
|
15
|
+
let UNWalletName;
|
|
16
|
+
exports.UNWalletName = UNWalletName;
|
|
17
|
+
|
|
18
|
+
(function (UNWalletName) {
|
|
19
|
+
UNWalletName["Apple"] = "APPLE";
|
|
20
|
+
UNWalletName["Google"] = "GOOGLE";
|
|
21
|
+
})(UNWalletName || (exports.UNWalletName = UNWalletName = {}));
|
|
22
|
+
//# sourceMappingURL=wallet.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["UNWalletCode","UNWalletName"],"sources":["wallet.types.ts"],"sourcesContent":["import type { CardAddToWalletStatus } from 'src/messages/nativeMessages/cardMessage';\n\nexport enum UNWalletCode {\n Apple = 'ApplePayPushProvision',\n Google = 'GooglePayPushProvision',\n}\n\nexport enum UNWalletName {\n Apple = 'APPLE',\n Google = 'GOOGLE',\n}\n\nexport interface UNWallet {\n name: string;\n code: string;\n status: CardAddToWalletStatus\n}\n"],"mappings":";;;;;;IAEYA,Y;;;WAAAA,Y;EAAAA,Y;EAAAA,Y;GAAAA,Y,4BAAAA,Y;;IAKAC,Y;;;WAAAA,Y;EAAAA,Y;EAAAA,Y;GAAAA,Y,4BAAAA,Y"}
|
|
@@ -7,7 +7,7 @@ exports.globalUnitScript = exports.fetchUnitScript = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _EventBus = _interopRequireDefault(require("../helpers/EventBus"));
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _sdkMessage = require("../messages/nativeMessages/sdkMessage");
|
|
11
11
|
|
|
12
12
|
var _UnitSdkManager = require("./UnitSdkManager");
|
|
13
13
|
|
|
@@ -34,9 +34,11 @@ const fetchUnitScript = async () => {
|
|
|
34
34
|
const unitScript = await unitScriptRes.text();
|
|
35
35
|
|
|
36
36
|
if (unitScript) {
|
|
37
|
-
|
|
37
|
+
const scriptFetchData = {
|
|
38
38
|
unitScript
|
|
39
|
-
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
_EventBus.default.Instance.event(_sdkMessage.SDKMessage.IS_SCRIPT_FETCHED, scriptFetchData);
|
|
40
42
|
|
|
41
43
|
exports.globalUnitScript = globalUnitScript = unitScript;
|
|
42
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isLoadingScript","globalUnitScript","fetchUnitScript","env","UnitSDK","getEnv","unitScriptRes","fetch","UNIT_SCRIPT_URL","unitScript","text","EventBus","Instance","event","
|
|
1
|
+
{"version":3,"names":["isLoadingScript","globalUnitScript","fetchUnitScript","env","UnitSDK","getEnv","unitScriptRes","fetch","UNIT_SCRIPT_URL","unitScript","text","scriptFetchData","EventBus","Instance","event","SDKMessage","IS_SCRIPT_FETCHED","e","console","log"],"sources":["UnitSdk.api.ts"],"sourcesContent":["import EventBus from '../helpers/EventBus';\nimport { SDKMessage, SdkScriptFetched } from '../messages/nativeMessages/sdkMessage';\nimport { UnitSDK, UNIT_SCRIPT_URL } from './UnitSdkManager';\n\nlet isLoadingScript = false;\n\n/** globalUnitScript is exported ONLY to our project components **/\nexport let globalUnitScript = '';\n\nexport const fetchUnitScript = async () => {\n const env = UnitSDK.getEnv();\n if (isLoadingScript || globalUnitScript || !env) {\n // init function is called and success OR in progress\n return null;\n }\n isLoadingScript = true;\n try {\n const unitScriptRes = await fetch(UNIT_SCRIPT_URL[env]);\n const unitScript = await unitScriptRes.text();\n if (unitScript) {\n const scriptFetchData: SdkScriptFetched = { unitScript };\n EventBus.Instance.event(SDKMessage.IS_SCRIPT_FETCHED, scriptFetchData);\n globalUnitScript = unitScript;\n }\n return null;\n } catch (e) {\n console.log(e);\n return null;\n } finally {\n isLoadingScript = false;\n }\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAEA,IAAIA,eAAe,GAAG,KAAtB;AAEA;;AACO,IAAIC,gBAAgB,GAAG,EAAvB;;;AAEA,MAAMC,eAAe,GAAG,YAAY;EACzC,MAAMC,GAAG,GAAGC,uBAAA,CAAQC,MAAR,EAAZ;;EACA,IAAIL,eAAe,IAAIC,gBAAnB,IAAuC,CAACE,GAA5C,EAAiD;IAC/C;IACA,OAAO,IAAP;EACD;;EACDH,eAAe,GAAG,IAAlB;;EACA,IAAI;IACF,MAAMM,aAAa,GAAG,MAAMC,KAAK,CAACC,+BAAA,CAAgBL,GAAhB,CAAD,CAAjC;IACA,MAAMM,UAAU,GAAG,MAAMH,aAAa,CAACI,IAAd,EAAzB;;IACA,IAAID,UAAJ,EAAgB;MACd,MAAME,eAAiC,GAAG;QAAEF;MAAF,CAA1C;;MACAG,iBAAA,CAASC,QAAT,CAAkBC,KAAlB,CAAwBC,sBAAA,CAAWC,iBAAnC,EAAsDL,eAAtD;;MACA,2BAAAV,gBAAgB,GAAGQ,UAAnB;IACD;;IACD,OAAO,IAAP;EACD,CATD,CASE,OAAOQ,CAAP,EAAU;IACVC,OAAO,CAACC,GAAR,CAAYF,CAAZ;IACA,OAAO,IAAP;EACD,CAZD,SAYU;IACRjB,eAAe,GAAG,KAAlB;EACD;AACF,CAtBM"}
|