react-native-3rddigital-appupdate 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sagar Bhavsar
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # react-native-app-update
2
+
3
+ A React Native library for **seamless Over-The-Air (OTA) updates** with:
4
+
5
+ - 🔄 Automatic version checks
6
+ - 📥 Bundle download & installation (iOS & Android)
7
+ - ⚡ Configurable user prompts (dialogs) & loaders
8
+ - 🛠️ CLI tool for building & uploading bundles to your update server
9
+
10
+ ## 🚀 Installation
11
+
12
+ ```sh
13
+ npm install react-native-app-update
14
+ # or
15
+ yarn add react-native-app-update
16
+ ```
17
+
18
+ This package has peer dependencies that also need to be installed:
19
+
20
+ ```sh
21
+ npm install react-native-blob-util react-native-device-info react-native-ota-hot-update
22
+ ```
23
+
24
+ Run pod install for iOS:
25
+
26
+ ```sh
27
+ cd ios && pod install
28
+ ```
29
+
30
+ ## 📦 Usage in Your App
31
+
32
+ - Wrap your app with the OTAProvider to enable the loader and dialog components globally:
33
+
34
+ ```sh
35
+ import React, { useEffect } from 'react';
36
+ import { View, Text } from 'react-native';
37
+ import { OTAProvider, checkOTAUpdate } from 'react-native-app-update';
38
+
39
+ const App = () => {
40
+ useEffect(() => {
41
+ checkOTAUpdate({
42
+ key: 'YOUR_PROJECT_KEY',
43
+ iosPackage: 'com.example.ios',
44
+ androidPackage: 'com.example.android',
45
+ loaderOptions: {
46
+ text: 'Downloading update...',
47
+ },
48
+ dialogOptions: {
49
+ title: 'Update Available',
50
+ message: 'A new version is ready to install.',
51
+ },
52
+ });
53
+ }, []);
54
+
55
+ return (
56
+ <OTAProvider>
57
+ <View>
58
+ <Text>My App Content</Text>
59
+ </View>
60
+ </OTAProvider>
61
+ );
62
+ };
63
+
64
+ export default App;
65
+ ```
66
+
67
+ ## ⚙️ API Reference
68
+
69
+ 🔹 checkOTAUpdate(options: OTAUpdateProps)
70
+
71
+ - Checks the server for available updates and installs if needed.
72
+
73
+ Options:
74
+
75
+ | Key | Type | Required | Description |
76
+ | ---------------- | ------ | -------- | ----------------------------------------------------- |
77
+ | `key` | string | ✅ | Project key to identify the app on your update server |
78
+ | `iosPackage` | string | ✅ | iOS bundle/package identifier |
79
+ | `androidPackage` | string | ✅ | Android bundle/package identifier |
80
+ | `loaderOptions` | object | ❌ | Customize loader UI (see below) |
81
+ | `dialogOptions` | object | ❌ | Customize alert dialog UI (see below) |
82
+
83
+ 🔹 OTAProvider
84
+
85
+ - Renders background components (AppLoader, AppAlertDialog) that handle UI for downloads and update prompts.
86
+ - Must be included once, usually at the root of your app.
87
+
88
+ 🔹 Loader (AppLoader)
89
+
90
+ - Global loader shown when downloading an update.
91
+
92
+ Props (LoaderOptions):
93
+
94
+ | Key | Type | Default | Description |
95
+ | ----------------- | --------- | ----------------- | ------------------------------------- |
96
+ | `text` | string | `undefined` | Text displayed below the spinner |
97
+ | `color` | string | `#2563EB` | Spinner color |
98
+ | `backgroundColor` | string | `rgba(0,0,0,0.3)` | Overlay background color |
99
+ | `textColor` | string | `#fff` | Loader text color |
100
+ | `containerStyle` | ViewStyle | `{}` | Custom style for the loader container |
101
+ | `textStyle` | TextStyle | `{}` | Custom style for the loader text |
102
+
103
+ Usage:
104
+
105
+ ```sh
106
+ AppLoader.show({
107
+ text: "Downloading...",
108
+ color: "#ff0000",
109
+ backgroundColor: "rgba(0,0,0,0.6)",
110
+ textColor: "#fff",
111
+ });
112
+ AppLoader.hide();
113
+ ```
114
+
115
+ 🔹 Dialog (AppAlertDialog)
116
+
117
+ - Global confirmation dialog used to prompt users for updates.
118
+
119
+ Props (DialogOptions):
120
+
121
+ | Key | Type | Default | Description |
122
+ | -------------------- | ---------- | ------------------- | -------------------------------------- |
123
+ | `title` | string | `"Alert"` | Dialog title |
124
+ | `message` | string | `""` | Dialog message |
125
+ | `cancelText` | string | `"Cancel"` | Cancel button text |
126
+ | `confirmText` | string | `"OK"` | Confirm button text |
127
+ | `onCancel` | () => void | `undefined` | Callback when cancel is pressed |
128
+ | `onConfirm` | () => void | `undefined` | Callback when confirm is pressed |
129
+ | `titleStyle` | TextStyle | `{}` | Style override for title text |
130
+ | `messageStyle` | TextStyle | `{}` | Style override for message text |
131
+ | `cancelButtonStyle` | ViewStyle | `{}` | Style override for cancel button |
132
+ | `confirmButtonStyle` | ViewStyle | `{}` | Style override for confirm button |
133
+ | `cancelTextStyle` | TextStyle | `{}` | Style override for cancel button text |
134
+ | `confirmTextStyle` | TextStyle | `{}` | Style override for confirm button text |
135
+ | `overlayColor` | string | `'rgba(0,0,0,0.3)'` | Overlay background color |
136
+
137
+ Usage:
138
+
139
+ ```sh
140
+ AppAlertDialog.showMessage({
141
+ title: "Update Available",
142
+ message: "A new version is ready to install.",
143
+ confirmText: "Update Now",
144
+ cancelText: "Later",
145
+ onConfirm: () => console.log("User confirmed"),
146
+ onCancel: () => console.log("User cancelled"),
147
+ });
148
+ ```
149
+
150
+ ## 🖥️ CLI Tool – appupdate
151
+
152
+ - This package also provides a CLI for building and uploading OTA bundles.
153
+
154
+ Build & Upload
155
+
156
+ ```sh
157
+ npx appupdate android
158
+ npx appupdate ios
159
+ npx appupdate all
160
+ ```
161
+
162
+ You will be prompted for:
163
+
164
+ - API Token
165
+ - Project ID
166
+ - Environment (development / production)
167
+ - Version
168
+ - Build Number
169
+ - Force Update (true/false)
170
+
171
+ What it does
172
+
173
+ - Bundles your React Native JS + assets
174
+ - Zips the output
175
+ - Uploads bundle + metadata to your update server (https://dev.3rddigital.com/appupdate-api/api/)
176
+
177
+ ## 📄 License
178
+
179
+ - This project is licensed under the [MIT License](./LICENSE).
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ import { useState } from 'react';
4
+ import { Modal, Pressable, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ let showDialog;
7
+ let hideDialog;
8
+ export const AppAlertDialog = () => {
9
+ const [visible, setVisible] = useState(false);
10
+ const [options, setOptions] = useState({});
11
+ showDialog = opts => {
12
+ setOptions(opts);
13
+ setVisible(true);
14
+ };
15
+ hideDialog = () => {
16
+ setVisible(false);
17
+ };
18
+ const handleBackPress = () => {
19
+ if (visible) {
20
+ hideDialog();
21
+ options.onCancel?.();
22
+ }
23
+ };
24
+ return /*#__PURE__*/_jsx(Modal, {
25
+ transparent: true,
26
+ visible: visible,
27
+ animationType: "fade",
28
+ onRequestClose: handleBackPress,
29
+ children: /*#__PURE__*/_jsx(Pressable, {
30
+ style: [styles.overlay, {
31
+ backgroundColor: options.overlayColor || 'rgba(0,0,0,0.3)'
32
+ }],
33
+ onPress: () => {
34
+ hideDialog();
35
+ options.onCancel?.();
36
+ },
37
+ children: /*#__PURE__*/_jsxs(Pressable, {
38
+ style: styles.dialogBox,
39
+ onPress: () => {},
40
+ children: [/*#__PURE__*/_jsx(Text, {
41
+ style: [styles.title, options.titleStyle],
42
+ children: options.title || 'Alert'
43
+ }), /*#__PURE__*/_jsx(Text, {
44
+ style: [styles.message, options.messageStyle],
45
+ children: options.message || ''
46
+ }), /*#__PURE__*/_jsxs(View, {
47
+ style: styles.buttonRow,
48
+ children: [/*#__PURE__*/_jsx(TouchableOpacity, {
49
+ onPress: () => {
50
+ hideDialog();
51
+ options.onCancel?.();
52
+ },
53
+ style: [styles.button, styles.cancelButton, options.cancelButtonStyle],
54
+ children: /*#__PURE__*/_jsx(Text, {
55
+ style: [styles.cancelText, options.cancelTextStyle],
56
+ children: options.cancelText || 'Cancel'
57
+ })
58
+ }), /*#__PURE__*/_jsx(TouchableOpacity, {
59
+ onPress: () => {
60
+ hideDialog();
61
+ options.onConfirm?.();
62
+ },
63
+ style: [styles.button, styles.confirmButton, options.confirmButtonStyle],
64
+ children: /*#__PURE__*/_jsx(Text, {
65
+ style: [styles.confirmText, options.confirmTextStyle],
66
+ children: options.confirmText || 'OK'
67
+ })
68
+ })]
69
+ })]
70
+ })
71
+ })
72
+ });
73
+ };
74
+ const styles = StyleSheet.create({
75
+ overlay: {
76
+ flex: 1,
77
+ justifyContent: 'center',
78
+ alignItems: 'center',
79
+ zIndex: 9999
80
+ },
81
+ dialogBox: {
82
+ width: '80%',
83
+ backgroundColor: '#fff',
84
+ borderRadius: 12,
85
+ padding: 20,
86
+ alignItems: 'center'
87
+ },
88
+ title: {
89
+ fontSize: 18,
90
+ fontWeight: '600',
91
+ marginBottom: 10,
92
+ textAlign: 'center'
93
+ },
94
+ message: {
95
+ fontSize: 14,
96
+ color: '#4B5563',
97
+ textAlign: 'center',
98
+ marginBottom: 20
99
+ },
100
+ buttonRow: {
101
+ flexDirection: 'row',
102
+ justifyContent: 'space-between',
103
+ width: '100%'
104
+ },
105
+ button: {
106
+ flex: 1,
107
+ paddingVertical: 10,
108
+ borderRadius: 8,
109
+ alignItems: 'center',
110
+ marginHorizontal: 5
111
+ },
112
+ cancelButton: {
113
+ backgroundColor: '#E5E7EB'
114
+ },
115
+ confirmButton: {
116
+ backgroundColor: '#2563EB'
117
+ },
118
+ cancelText: {
119
+ color: '#374151',
120
+ fontWeight: '500'
121
+ },
122
+ confirmText: {
123
+ color: '#fff',
124
+ fontWeight: '500'
125
+ }
126
+ });
127
+ AppAlertDialog.showMessage = options => showDialog?.(options);
128
+ AppAlertDialog.hide = () => hideDialog?.();
129
+ //# sourceMappingURL=AppAlertDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useState","Modal","Pressable","StyleSheet","Text","TouchableOpacity","View","jsx","_jsx","jsxs","_jsxs","showDialog","hideDialog","AppAlertDialog","visible","setVisible","options","setOptions","opts","handleBackPress","onCancel","transparent","animationType","onRequestClose","children","style","styles","overlay","backgroundColor","overlayColor","onPress","dialogBox","title","titleStyle","message","messageStyle","buttonRow","button","cancelButton","cancelButtonStyle","cancelText","cancelTextStyle","onConfirm","confirmButton","confirmButtonStyle","confirmText","confirmTextStyle","create","flex","justifyContent","alignItems","zIndex","width","borderRadius","padding","fontSize","fontWeight","marginBottom","textAlign","color","flexDirection","paddingVertical","marginHorizontal","showMessage","hide"],"sourceRoot":"../../src","sources":["AppAlertDialog.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,OAAO;AAChC,SACEC,KAAK,EACLC,SAAS,EACTC,UAAU,EACVC,IAAI,EACJC,gBAAgB,EAChBC,IAAI,QAGC,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAkBtB,IAAIC,UAA4C;AAChD,IAAIC,UAAsB;AAE1B,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAClC,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGf,QAAQ,CAAC,KAAK,CAAC;EAC7C,MAAM,CAACgB,OAAO,EAAEC,UAAU,CAAC,GAAGjB,QAAQ,C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ACZxB,eAAe,EAAE,MAAM;IACvByB,YAAY,EAAE,EAAE;IAChBC,OAAO,EAAE,EAAE;IACXJ,UAAU,EAAE;EACd,CAAC;EACDlB,KAAK,EAAE;IACLuB,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,KAAK;IACjBC,YAAY,EAAE,EAAE;IAChBC,SAAS,EAAE;EACb,CAAC;EACDxB,OAAO,EAAE;IACPqB,QAAQ,EAAE,EAAE;IACZI,KAAK,EAAE,SAAS;IAChBD,SAAS,EAAE,QAAQ;IACnBD,YAAY,EAAE;EAChB,CAAC;EACDrB,SAAS,EAAE;IACTwB,aAAa,EAAE,KAAK;IACpBX,cAAc,EAAE,eAAe;IAC/BG,KAAK,EAAE;EACT,CAAC;EACDf,MAAM,EAAE;IACNW,IAAI,EAAE,CAAC;IACPa,eAAe,EAAE,EAAE;IACnBR,YAAY,EAAE,CAAC;IACfH,UAAU,EAAE,QAAQ;IACpBY,gBAAgB,EAAE;EACpB,CAAC;EACDxB,YAAY,EAAE;IACZV,eAAe,EAAE;EACnB,CAAC;EACDe,aAAa,EAAE;IACbf,eAAe,EAAE;EACnB,CAAC;EACDY,UAAU,EAAE;IACVmB,KAAK,EAAE,SAAS;IAChBH,UAAU,EAAE;EACd,CAAC;EACDX,WAAW,EAAE;IACXc,KAAK,EAAE,MAAM;IACbH,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF3C,cAAc,CAACkD,WAAW,GAAI/C,OAAsB,IAAKL,UAAU,GAAGK,OAAO,CAAC;AAC9EH,cAAc,CAACmD,IAAI,GAAG,MAAMpD,UAAU,GAAG,CAAC","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ import { useState } from 'react';
4
+ import { ActivityIndicator, StyleSheet, Text, View } from 'react-native';
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ let showLoader;
7
+ let hideLoader;
8
+ export const AppLoader = () => {
9
+ const [visible, setVisible] = useState(false);
10
+ const [options, setOptions] = useState({});
11
+ showLoader = opts => {
12
+ setOptions(opts || {});
13
+ setVisible(true);
14
+ };
15
+ hideLoader = () => {
16
+ setVisible(false);
17
+ };
18
+ if (!visible) return null;
19
+ return /*#__PURE__*/_jsx(View, {
20
+ style: [styles.overlay, {
21
+ backgroundColor: options.backgroundColor || 'rgba(0,0,0,0.3)'
22
+ }],
23
+ children: /*#__PURE__*/_jsxs(View, {
24
+ style: [styles.loaderBox, options.containerStyle],
25
+ children: [/*#__PURE__*/_jsx(ActivityIndicator, {
26
+ size: "large",
27
+ color: options.color || '#2563EB'
28
+ }), options.text && /*#__PURE__*/_jsx(Text, {
29
+ style: [styles.text, {
30
+ color: options.textColor || '#fff'
31
+ }, options.textStyle],
32
+ children: options.text
33
+ })]
34
+ })
35
+ });
36
+ };
37
+ const styles = StyleSheet.create({
38
+ overlay: {
39
+ ...StyleSheet.absoluteFillObject,
40
+ justifyContent: 'center',
41
+ alignItems: 'center',
42
+ zIndex: 9999
43
+ },
44
+ loaderBox: {
45
+ padding: 20,
46
+ borderRadius: 10,
47
+ backgroundColor: '#1F2937',
48
+ alignItems: 'center'
49
+ },
50
+ text: {
51
+ marginTop: 12,
52
+ fontSize: 14,
53
+ fontWeight: '500'
54
+ }
55
+ });
56
+ AppLoader.show = options => showLoader?.(options);
57
+ AppLoader.hide = () => hideLoader?.();
58
+ //# sourceMappingURL=AppLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useState","ActivityIndicator","StyleSheet","Text","View","jsx","_jsx","jsxs","_jsxs","showLoader","hideLoader","AppLoader","visible","setVisible","options","setOptions","opts","style","styles","overlay","backgroundColor","children","loaderBox","containerStyle","size","color","text","textColor","textStyle","create","absoluteFillObject","justifyContent","alignItems","zIndex","padding","borderRadius","marginTop","fontSize","fontWeight","show","hide"],"sourceRoot":"../../src","sources":["AppLoader.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,OAAO;AAChC,SACEC,iBAAiB,EACjBC,UAAU,EAC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AAEX,CAAC;AAED,MAAMR,MAAM,GAAGhB,UAAU,CAAC2B,MAAM,CAAC;EAC/BV,OAAO,EAAE;IACP,GAAGjB,UAAU,CAAC4B,kBAAkB;IAChCC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE,QAAQ;IACpBC,MAAM,EAAE;EACV,CAAC;EACDX,SAAS,EAAE;IACTY,OAAO,EAAE,EAAE;IACXC,YAAY,EAAE,EAAE;IAChBf,eAAe,EAAE,SAAS;IAC1BY,UAAU,EAAE;EACd,CAAC;EACDN,IAAI,EAAE;IACJU,SAAS,EAAE,EAAE;IACbC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF3B,SAAS,CAAC4B,IAAI,GAAIzB,OAAuB,IAAKL,UAAU,GAAGK,OAAO,CAAC;AACnEH,SAAS,CAAC6B,IAAI,GAAG,MAAM9B,UAAU,GAAG,CAAC","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { AppAlertDialog } from "./AppAlertDialog.js";
5
+ import { AppLoader } from "./AppLoader.js";
6
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
7
+ export const OTAProvider = ({
8
+ children
9
+ }) => /*#__PURE__*/_jsxs(_Fragment, {
10
+ children: [children, /*#__PURE__*/_jsx(AppLoader, {}), /*#__PURE__*/_jsx(AppAlertDialog, {})]
11
+ });
12
+ //# sourceMappingURL=OTAProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","AppAlertDialog","AppLoader","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","OTAProvider","children"],"sourceRoot":"../../src","sources":["OTAProvider.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,QAAQ,qBAAkB;AACjD,SAASC,SAAS,QAAQ,gBAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAExC,OAAO,MAAMC,WAAW,GAAGA,CAAC;EAAEC;AAAyC,CAAC,kBACtEF,KAAA,CAAAF,SAAA;EAAAI,QAAA,GACGA,QAAQ,eACTN,IAAA,CAACF,SAAS,IAAE,CAAC,eACbE,IAAA,CAACH,cAAc,IAAE,CAAC;AAAA,CAClB,CACH","ignoreList":[]}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ import axios from 'axios';
4
+ import { Platform } from 'react-native';
5
+ import ReactNativeBlobUtil from 'react-native-blob-util';
6
+ import DeviceInfo from 'react-native-device-info';
7
+ import hotUpdate from 'react-native-ota-hot-update';
8
+ import { AppAlertDialog } from "./AppAlertDialog.js";
9
+ import { AppLoader } from "./AppLoader.js";
10
+ const API_URL = 'https://dev.3rddigital.com/appupdate-api/api/';
11
+ export const checkOTAUpdate = async ({
12
+ key,
13
+ iosPackage,
14
+ androidPackage,
15
+ loaderOptions,
16
+ dialogOptions
17
+ }) => {
18
+ try {
19
+ const response = await axios.get(`${API_URL}projects/get-bundle?key=${key}&iosPackage=${iosPackage}&androidPackage=${androidPackage}`);
20
+ const currentVersion = await hotUpdate.getCurrentVersion();
21
+ const data = Platform.OS === 'android' ? response?.data?.android : response?.data?.ios;
22
+ const version = data?.version ?? 0;
23
+ const forceUpdate = data?.forceUpdate ?? false;
24
+ const url = data?.url ?? '';
25
+ const bundleId = data?.bundleId ?? '';
26
+ if (version <= currentVersion) return;
27
+ const downloadAndReport = () => {
28
+ AppLoader.show(loaderOptions);
29
+ hotUpdate.downloadBundleUri(ReactNativeBlobUtil, url, version, {
30
+ updateSuccess: () => {
31
+ axios.post(`${API_URL}bundles/${bundleId}/count`, {
32
+ status: 'success'
33
+ }, {
34
+ headers: {
35
+ 'Content-Type': 'application/json'
36
+ }
37
+ }).finally(() => AppLoader.hide());
38
+ },
39
+ updateFail: error => {
40
+ axios.post(`${API_URL}bundles/${bundleId}/count`, {
41
+ status: 'failure',
42
+ error: JSON.stringify(error),
43
+ deviceInfo: {
44
+ model: DeviceInfo.getModel(),
45
+ brand: DeviceInfo.getBrand(),
46
+ systemName: DeviceInfo.getSystemName(),
47
+ systemVersion: DeviceInfo.getSystemVersion()
48
+ }
49
+ }, {
50
+ headers: {
51
+ 'Content-Type': 'application/json'
52
+ }
53
+ }).finally(() => AppLoader.hide());
54
+ },
55
+ restartAfterInstall: true,
56
+ restartDelay: 1000
57
+ });
58
+ };
59
+ if (forceUpdate) {
60
+ downloadAndReport();
61
+ } else {
62
+ AppAlertDialog.showMessage({
63
+ title: 'Update Available!',
64
+ message: 'A newer version is ready to install.',
65
+ confirmText: 'Update',
66
+ cancelText: 'Cancel',
67
+ onConfirm: downloadAndReport,
68
+ onCancel: () => {},
69
+ ...dialogOptions
70
+ });
71
+ }
72
+ } catch (err) {
73
+ console.warn('OTA update check failed:', err);
74
+ }
75
+ };
76
+ //# sourceMappingURL=checkOTAUpdate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["axios","Platform","ReactNativeBlobUtil","DeviceInfo","hotUpdate","AppAlertDialog","AppLoader","API_URL","checkOTAUpdate","key","iosPackage","androidPackage","loaderOptions","dialogOptions","response","get","currentVersion","getCurrentVersion","data","OS","android","ios","version","forceUpdate","url","bundleId","downloadAndReport","show","downloadBundleUri","updateSuccess","post","status","headers","finally","hide","updateFail","error","JSON","stringify","deviceInfo","model","getModel","brand","getBrand","systemName","getSystemName","systemVersion","getSystemVersion","restartAfterInstall","restartDelay","showMessage","title","message","confirmText","cancelText","onConfirm","onCancel","err","console","warn"],"sourceRoot":"../../src","sources":["checkOTAUpdate.ts"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,mBAAmB,MAAM,wBAAwB;AACxD,OAAOC,UAAU,MAAM,0BAA0B;AACjD,OAAOC,SAAS,MAAM,6BAA6B;AACnD,SAASC,cAAc,QAA4B,qBAAkB;AACrE,SAASC,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Provider.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["checkOTAUpdate","OTAProvider"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,cAAc,QAA6B,qBAAkB;AACtE,SAASC,WAAW,QAAQ,kBAAe","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,22 @@
1
+ import { type TextStyle, type ViewStyle } from 'react-native';
2
+ export type DialogOptions = {
3
+ title?: string;
4
+ message?: string;
5
+ cancelText?: string;
6
+ confirmText?: string;
7
+ onCancel?: () => void;
8
+ onConfirm?: () => void;
9
+ titleStyle?: TextStyle;
10
+ messageStyle?: TextStyle;
11
+ cancelButtonStyle?: ViewStyle;
12
+ confirmButtonStyle?: ViewStyle;
13
+ cancelTextStyle?: TextStyle;
14
+ confirmTextStyle?: TextStyle;
15
+ overlayColor?: string;
16
+ };
17
+ export declare const AppAlertDialog: {
18
+ (): import("react/jsx-runtime").JSX.Element;
19
+ showMessage(options: DialogOptions): void;
20
+ hide(): void;
21
+ };
22
+ //# sourceMappingURL=AppAlertDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppAlertDialog.d.ts","sourceRoot":"","sources":["../../../src/AppAlertDialog.tsx"],"names":[],"mappings":"AACA,OAAO,EAOL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAKF,eAAO,MAAM,cAAc;;yBA0IY,aAAa;;CAxDnD,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type TextStyle, type ViewStyle } from 'react-native';
2
+ export type LoaderOptions = {
3
+ text?: string;
4
+ color?: string;
5
+ backgroundColor?: string;
6
+ textColor?: string;
7
+ containerStyle?: ViewStyle;
8
+ textStyle?: TextStyle;
9
+ };
10
+ export declare const AppLoader: {
11
+ (): import("react/jsx-runtime").JSX.Element | null;
12
+ show(options?: LoaderOptions): void;
13
+ hide(): void;
14
+ };
15
+ //# sourceMappingURL=AppLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppLoader.d.ts","sourceRoot":"","sources":["../../../src/AppLoader.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAKF,eAAO,MAAM,SAAS;;mBA4DM,aAAa;;CAtBxC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const OTAProvider: ({ children }: {
3
+ children?: React.ReactNode;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=OTAProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OTAProvider.d.ts","sourceRoot":"","sources":["../../../src/OTAProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,WAAW,GAAI,cAAc;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,4CAMvE,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type DialogOptions } from './AppAlertDialog';
2
+ import { type LoaderOptions } from './AppLoader';
3
+ export type OTAUpdateProps = {
4
+ key: string;
5
+ iosPackage: string;
6
+ androidPackage: string;
7
+ loaderOptions?: LoaderOptions;
8
+ dialogOptions?: Omit<DialogOptions, 'onConfirm' | 'onCancel'>;
9
+ };
10
+ export declare const checkOTAUpdate: ({ key, iosPackage, androidPackage, loaderOptions, dialogOptions, }: OTAUpdateProps) => Promise<void>;
11
+ //# sourceMappingURL=checkOTAUpdate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkOTAUpdate.d.ts","sourceRoot":"","sources":["../../../src/checkOTAUpdate.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5D,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,UAAU,CAAC,CAAC;CAC/D,CAAC;AAEF,eAAO,MAAM,cAAc,GAAU,oEAMlC,cAAc,kBAmEhB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { checkOTAUpdate, type OTAUpdateProps } from './checkOTAUpdate';
2
+ export { OTAProvider } from './OTAProvider';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}