@swiftpatch/react-native 2.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.
Files changed (182) hide show
  1. package/README.md +430 -0
  2. package/android/build.gradle +105 -0
  3. package/android/src/main/AndroidManifest.xml +6 -0
  4. package/android/src/main/java/com/swiftpatch/BundleManager.kt +107 -0
  5. package/android/src/main/java/com/swiftpatch/CrashDetector.kt +79 -0
  6. package/android/src/main/java/com/swiftpatch/CryptoVerifier.kt +69 -0
  7. package/android/src/main/java/com/swiftpatch/DownloadManager.kt +120 -0
  8. package/android/src/main/java/com/swiftpatch/EventQueue.kt +86 -0
  9. package/android/src/main/java/com/swiftpatch/FileUtils.kt +60 -0
  10. package/android/src/main/java/com/swiftpatch/PatchApplier.kt +60 -0
  11. package/android/src/main/java/com/swiftpatch/SignalCrashHandler.kt +84 -0
  12. package/android/src/main/java/com/swiftpatch/SlotManager.kt +299 -0
  13. package/android/src/main/java/com/swiftpatch/SwiftPatchModule.kt +630 -0
  14. package/android/src/main/java/com/swiftpatch/SwiftPatchPackage.kt +21 -0
  15. package/android/src/main/jni/CMakeLists.txt +12 -0
  16. package/android/src/main/jni/bspatch.c +188 -0
  17. package/android/src/main/jni/bspatch.h +57 -0
  18. package/android/src/main/jni/bspatch_jni.c +28 -0
  19. package/ios/Libraries/bspatch/bspatch.c +188 -0
  20. package/ios/Libraries/bspatch/bspatch.h +50 -0
  21. package/ios/Libraries/bspatch/module.modulemap +4 -0
  22. package/ios/SwiftPatch/BundleManager.swift +113 -0
  23. package/ios/SwiftPatch/CrashDetector.swift +71 -0
  24. package/ios/SwiftPatch/CryptoVerifier.swift +70 -0
  25. package/ios/SwiftPatch/DownloadManager.swift +125 -0
  26. package/ios/SwiftPatch/EventQueue.swift +116 -0
  27. package/ios/SwiftPatch/FileUtils.swift +38 -0
  28. package/ios/SwiftPatch/PatchApplier.swift +41 -0
  29. package/ios/SwiftPatch/SignalCrashHandler.swift +129 -0
  30. package/ios/SwiftPatch/SlotManager.swift +360 -0
  31. package/ios/SwiftPatch/SwiftPatchModule.m +56 -0
  32. package/ios/SwiftPatch/SwiftPatchModule.swift +621 -0
  33. package/lib/commonjs/SwiftPatchCore.js +140 -0
  34. package/lib/commonjs/SwiftPatchCore.js.map +1 -0
  35. package/lib/commonjs/SwiftPatchProvider.js +617 -0
  36. package/lib/commonjs/SwiftPatchProvider.js.map +1 -0
  37. package/lib/commonjs/constants.js +50 -0
  38. package/lib/commonjs/constants.js.map +1 -0
  39. package/lib/commonjs/core/Downloader.js +63 -0
  40. package/lib/commonjs/core/Downloader.js.map +1 -0
  41. package/lib/commonjs/core/Installer.js +46 -0
  42. package/lib/commonjs/core/Installer.js.map +1 -0
  43. package/lib/commonjs/core/Rollback.js +36 -0
  44. package/lib/commonjs/core/Rollback.js.map +1 -0
  45. package/lib/commonjs/core/UpdateChecker.js +57 -0
  46. package/lib/commonjs/core/UpdateChecker.js.map +1 -0
  47. package/lib/commonjs/core/Verifier.js +82 -0
  48. package/lib/commonjs/core/Verifier.js.map +1 -0
  49. package/lib/commonjs/core/index.js +41 -0
  50. package/lib/commonjs/core/index.js.map +1 -0
  51. package/lib/commonjs/index.js +154 -0
  52. package/lib/commonjs/index.js.map +1 -0
  53. package/lib/commonjs/modal/SwiftPatchModal.js +667 -0
  54. package/lib/commonjs/modal/SwiftPatchModal.js.map +1 -0
  55. package/lib/commonjs/modal/useSwiftPatchModal.js +26 -0
  56. package/lib/commonjs/modal/useSwiftPatchModal.js.map +1 -0
  57. package/lib/commonjs/native/NativeSwiftPatch.js +85 -0
  58. package/lib/commonjs/native/NativeSwiftPatch.js.map +1 -0
  59. package/lib/commonjs/native/NativeSwiftPatchSpec.js +15 -0
  60. package/lib/commonjs/native/NativeSwiftPatchSpec.js.map +1 -0
  61. package/lib/commonjs/package.json +1 -0
  62. package/lib/commonjs/types.js +126 -0
  63. package/lib/commonjs/types.js.map +1 -0
  64. package/lib/commonjs/useSwiftPatch.js +31 -0
  65. package/lib/commonjs/useSwiftPatch.js.map +1 -0
  66. package/lib/commonjs/utils/api.js +206 -0
  67. package/lib/commonjs/utils/api.js.map +1 -0
  68. package/lib/commonjs/utils/device.js +23 -0
  69. package/lib/commonjs/utils/device.js.map +1 -0
  70. package/lib/commonjs/utils/logger.js +30 -0
  71. package/lib/commonjs/utils/logger.js.map +1 -0
  72. package/lib/commonjs/utils/storage.js +31 -0
  73. package/lib/commonjs/utils/storage.js.map +1 -0
  74. package/lib/commonjs/withSwiftPatch.js +42 -0
  75. package/lib/commonjs/withSwiftPatch.js.map +1 -0
  76. package/lib/module/SwiftPatchCore.js +135 -0
  77. package/lib/module/SwiftPatchCore.js.map +1 -0
  78. package/lib/module/SwiftPatchProvider.js +611 -0
  79. package/lib/module/SwiftPatchProvider.js.map +1 -0
  80. package/lib/module/constants.js +46 -0
  81. package/lib/module/constants.js.map +1 -0
  82. package/lib/module/core/Downloader.js +57 -0
  83. package/lib/module/core/Downloader.js.map +1 -0
  84. package/lib/module/core/Installer.js +41 -0
  85. package/lib/module/core/Installer.js.map +1 -0
  86. package/lib/module/core/Rollback.js +31 -0
  87. package/lib/module/core/Rollback.js.map +1 -0
  88. package/lib/module/core/UpdateChecker.js +51 -0
  89. package/lib/module/core/UpdateChecker.js.map +1 -0
  90. package/lib/module/core/Verifier.js +76 -0
  91. package/lib/module/core/Verifier.js.map +1 -0
  92. package/lib/module/core/index.js +8 -0
  93. package/lib/module/core/index.js.map +1 -0
  94. package/lib/module/index.js +34 -0
  95. package/lib/module/index.js.map +1 -0
  96. package/lib/module/modal/SwiftPatchModal.js +661 -0
  97. package/lib/module/modal/SwiftPatchModal.js.map +1 -0
  98. package/lib/module/modal/useSwiftPatchModal.js +22 -0
  99. package/lib/module/modal/useSwiftPatchModal.js.map +1 -0
  100. package/lib/module/native/NativeSwiftPatch.js +78 -0
  101. package/lib/module/native/NativeSwiftPatch.js.map +1 -0
  102. package/lib/module/native/NativeSwiftPatchSpec.js +12 -0
  103. package/lib/module/native/NativeSwiftPatchSpec.js.map +1 -0
  104. package/lib/module/types.js +139 -0
  105. package/lib/module/types.js.map +1 -0
  106. package/lib/module/useSwiftPatch.js +26 -0
  107. package/lib/module/useSwiftPatch.js.map +1 -0
  108. package/lib/module/utils/api.js +197 -0
  109. package/lib/module/utils/api.js.map +1 -0
  110. package/lib/module/utils/device.js +18 -0
  111. package/lib/module/utils/device.js.map +1 -0
  112. package/lib/module/utils/logger.js +26 -0
  113. package/lib/module/utils/logger.js.map +1 -0
  114. package/lib/module/utils/storage.js +24 -0
  115. package/lib/module/utils/storage.js.map +1 -0
  116. package/lib/module/withSwiftPatch.js +37 -0
  117. package/lib/module/withSwiftPatch.js.map +1 -0
  118. package/lib/typescript/SwiftPatchCore.d.ts +64 -0
  119. package/lib/typescript/SwiftPatchCore.d.ts.map +1 -0
  120. package/lib/typescript/SwiftPatchProvider.d.ts +22 -0
  121. package/lib/typescript/SwiftPatchProvider.d.ts.map +1 -0
  122. package/lib/typescript/constants.d.ts +33 -0
  123. package/lib/typescript/constants.d.ts.map +1 -0
  124. package/lib/typescript/core/Downloader.d.ts +34 -0
  125. package/lib/typescript/core/Downloader.d.ts.map +1 -0
  126. package/lib/typescript/core/Installer.d.ts +25 -0
  127. package/lib/typescript/core/Installer.d.ts.map +1 -0
  128. package/lib/typescript/core/Rollback.d.ts +18 -0
  129. package/lib/typescript/core/Rollback.d.ts.map +1 -0
  130. package/lib/typescript/core/UpdateChecker.d.ts +27 -0
  131. package/lib/typescript/core/UpdateChecker.d.ts.map +1 -0
  132. package/lib/typescript/core/Verifier.d.ts +31 -0
  133. package/lib/typescript/core/Verifier.d.ts.map +1 -0
  134. package/lib/typescript/core/index.d.ts +8 -0
  135. package/lib/typescript/core/index.d.ts.map +1 -0
  136. package/lib/typescript/index.d.ts +13 -0
  137. package/lib/typescript/index.d.ts.map +1 -0
  138. package/lib/typescript/modal/SwiftPatchModal.d.ts +11 -0
  139. package/lib/typescript/modal/SwiftPatchModal.d.ts.map +1 -0
  140. package/lib/typescript/modal/useSwiftPatchModal.d.ts +7 -0
  141. package/lib/typescript/modal/useSwiftPatchModal.d.ts.map +1 -0
  142. package/lib/typescript/native/NativeSwiftPatch.d.ts +61 -0
  143. package/lib/typescript/native/NativeSwiftPatch.d.ts.map +1 -0
  144. package/lib/typescript/native/NativeSwiftPatchSpec.d.ts +67 -0
  145. package/lib/typescript/native/NativeSwiftPatchSpec.d.ts.map +1 -0
  146. package/lib/typescript/types.d.ts +266 -0
  147. package/lib/typescript/types.d.ts.map +1 -0
  148. package/lib/typescript/useSwiftPatch.d.ts +12 -0
  149. package/lib/typescript/useSwiftPatch.d.ts.map +1 -0
  150. package/lib/typescript/utils/api.d.ts +87 -0
  151. package/lib/typescript/utils/api.d.ts.map +1 -0
  152. package/lib/typescript/utils/device.d.ts +9 -0
  153. package/lib/typescript/utils/device.d.ts.map +1 -0
  154. package/lib/typescript/utils/logger.d.ts +8 -0
  155. package/lib/typescript/utils/logger.d.ts.map +1 -0
  156. package/lib/typescript/utils/storage.d.ts +14 -0
  157. package/lib/typescript/utils/storage.d.ts.map +1 -0
  158. package/lib/typescript/withSwiftPatch.d.ts +12 -0
  159. package/lib/typescript/withSwiftPatch.d.ts.map +1 -0
  160. package/package.json +99 -0
  161. package/react-native-swiftpatch.podspec +50 -0
  162. package/src/SwiftPatchCore.ts +148 -0
  163. package/src/SwiftPatchProvider.tsx +514 -0
  164. package/src/constants.ts +49 -0
  165. package/src/core/Downloader.ts +74 -0
  166. package/src/core/Installer.ts +38 -0
  167. package/src/core/Rollback.ts +28 -0
  168. package/src/core/UpdateChecker.ts +70 -0
  169. package/src/core/Verifier.ts +92 -0
  170. package/src/core/index.ts +11 -0
  171. package/src/index.ts +64 -0
  172. package/src/modal/SwiftPatchModal.tsx +657 -0
  173. package/src/modal/useSwiftPatchModal.ts +24 -0
  174. package/src/native/NativeSwiftPatch.ts +205 -0
  175. package/src/native/NativeSwiftPatchSpec.ts +139 -0
  176. package/src/types.ts +336 -0
  177. package/src/useSwiftPatch.ts +29 -0
  178. package/src/utils/api.ts +244 -0
  179. package/src/utils/device.ts +15 -0
  180. package/src/utils/logger.ts +29 -0
  181. package/src/utils/storage.ts +23 -0
  182. package/src/withSwiftPatch.tsx +41 -0
@@ -0,0 +1,74 @@
1
+ import NativeSwiftPatch, {
2
+ onDownloadProgress,
3
+ } from '../native/NativeSwiftPatch';
4
+ import { logger } from '../utils/logger';
5
+ import type { ReleaseInfo, DownloadProgress } from '../types';
6
+
7
+ export interface DownloadOptions {
8
+ url: string;
9
+ expectedHash: string;
10
+ isPatch: boolean;
11
+ signature: string | null;
12
+ }
13
+
14
+ /**
15
+ * Core module responsible for downloading OTA bundles or patches.
16
+ *
17
+ * Delegates to the native module for actual download + disk I/O.
18
+ * Provides progress tracking and cancellation.
19
+ */
20
+ export class Downloader {
21
+ private unsubscribeProgress: (() => void) | null = null;
22
+
23
+ /**
24
+ * Download a bundle or patch from the given options.
25
+ */
26
+ async download(options: DownloadOptions): Promise<void> {
27
+ logger.info(
28
+ `Downloading ${options.isPatch ? 'patch' : 'full bundle'}: ${options.expectedHash}`
29
+ );
30
+
31
+ await NativeSwiftPatch.downloadUpdate(
32
+ options.url,
33
+ options.expectedHash,
34
+ options.isPatch,
35
+ options.signature
36
+ );
37
+
38
+ logger.info('Download complete');
39
+ }
40
+
41
+ /**
42
+ * Convenience: download a release (extracts fields from ReleaseInfo).
43
+ */
44
+ async downloadRelease(release: ReleaseInfo): Promise<void> {
45
+ await this.download({
46
+ url: release.downloadUrl,
47
+ expectedHash: release.bundleHash,
48
+ isPatch: release.isPatch,
49
+ signature: release.signature || null,
50
+ });
51
+ }
52
+
53
+ /**
54
+ * Register a callback for download progress events.
55
+ * Returns an unsubscribe function.
56
+ */
57
+ onProgress(callback: (progress: DownloadProgress) => void): () => void {
58
+ this.unsubscribeProgress = onDownloadProgress(callback);
59
+ return () => {
60
+ if (this.unsubscribeProgress) {
61
+ this.unsubscribeProgress();
62
+ this.unsubscribeProgress = null;
63
+ }
64
+ };
65
+ }
66
+
67
+ /**
68
+ * Cancel an in-progress download.
69
+ */
70
+ async cancel(): Promise<void> {
71
+ logger.info('Cancelling download');
72
+ await NativeSwiftPatch.cancelDownload();
73
+ }
74
+ }
@@ -0,0 +1,38 @@
1
+ import NativeSwiftPatch from '../native/NativeSwiftPatch';
2
+ import { logger } from '../utils/logger';
3
+
4
+ /**
5
+ * Core module responsible for installing verified bundles.
6
+ *
7
+ * Delegates to the native module for atomic file operations
8
+ * and pending install tracking.
9
+ */
10
+ export class Installer {
11
+ /**
12
+ * Install a downloaded and verified bundle by its hash.
13
+ * The native module handles moving the file to the correct location
14
+ * and setting it as the pending bundle.
15
+ */
16
+ async install(bundleHash: string): Promise<void> {
17
+ logger.info(`Installing bundle: ${bundleHash}`);
18
+ await NativeSwiftPatch.installUpdate(bundleHash);
19
+ logger.info('Bundle installed, restart required to activate');
20
+ }
21
+
22
+ /**
23
+ * Confirm the current installation as stable.
24
+ * Call this after the app has been running without crashes
25
+ * for the crash detection window period.
26
+ */
27
+ async confirm(): Promise<void> {
28
+ logger.info('Confirming installation as stable');
29
+ await NativeSwiftPatch.confirmInstall();
30
+ }
31
+
32
+ /**
33
+ * Check if there is a pending installation awaiting restart.
34
+ */
35
+ async hasPending(): Promise<boolean> {
36
+ return NativeSwiftPatch.hasPendingInstall();
37
+ }
38
+ }
@@ -0,0 +1,28 @@
1
+ import NativeSwiftPatch from '../native/NativeSwiftPatch';
2
+ import { logger } from '../utils/logger';
3
+
4
+ /**
5
+ * Core module responsible for rollback operations.
6
+ *
7
+ * Delegates to the native module for reverting to the
8
+ * previous bundle version and clearing pending updates.
9
+ */
10
+ export class Rollback {
11
+ /**
12
+ * Rollback to the previous bundle version.
13
+ * The native module restores the prior known-good bundle.
14
+ */
15
+ async rollback(): Promise<void> {
16
+ logger.info('Rolling back to previous bundle');
17
+ await NativeSwiftPatch.rollback();
18
+ logger.info('Rollback complete');
19
+ }
20
+
21
+ /**
22
+ * Clear any pending update that has not yet been activated.
23
+ */
24
+ async clearPending(): Promise<void> {
25
+ logger.info('Clearing pending update');
26
+ await NativeSwiftPatch.clearPendingUpdate();
27
+ }
28
+ }
@@ -0,0 +1,70 @@
1
+ import { Platform } from 'react-native';
2
+ import NativeSwiftPatch from '../native/NativeSwiftPatch';
3
+ import { checkForUpdateAPI } from '../utils/api';
4
+ import { logger } from '../utils/logger';
5
+ import { SDK_VERSION } from '../constants';
6
+ import type { ReleaseInfo } from '../types';
7
+
8
+ export interface UpdateCheckOptions {
9
+ serverUrl: string;
10
+ deploymentKey: string;
11
+ customHeaders?: Record<string, string>;
12
+ }
13
+
14
+ export interface UpdateCheckResult {
15
+ updateAvailable: boolean;
16
+ release?: ReleaseInfo;
17
+ reason?: string;
18
+ }
19
+
20
+ /**
21
+ * Core module responsible for checking for available OTA updates.
22
+ *
23
+ * Gathers device info from the native module and calls the
24
+ * server's check-update endpoint.
25
+ */
26
+ export class UpdateChecker {
27
+ private options: UpdateCheckOptions;
28
+
29
+ constructor(options: UpdateCheckOptions) {
30
+ this.options = options;
31
+ }
32
+
33
+ /**
34
+ * Check the server for an available update.
35
+ * Gathers appVersion, currentBundleHash, deviceId from native module.
36
+ */
37
+ async check(): Promise<UpdateCheckResult> {
38
+ const appVersion = await NativeSwiftPatch.getAppVersion();
39
+ const currentBundle = await NativeSwiftPatch.getCurrentBundle();
40
+ const deviceId = await NativeSwiftPatch.getDeviceId();
41
+
42
+ logger.debug(
43
+ `Checking for update: appVersion=${appVersion}, platform=${Platform.OS}, sdkVersion=${SDK_VERSION}`
44
+ );
45
+
46
+ const result = await checkForUpdateAPI({
47
+ serverUrl: this.options.serverUrl,
48
+ deploymentKey: this.options.deploymentKey,
49
+ appVersion,
50
+ currentBundleHash: currentBundle?.hash || null,
51
+ platform: Platform.OS as 'ios' | 'android',
52
+ deviceId,
53
+ customHeaders: this.options.customHeaders,
54
+ });
55
+
56
+ if (result.updateAvailable && result.release) {
57
+ logger.info(`Update available: ${result.release.version}`);
58
+ return {
59
+ updateAvailable: true,
60
+ release: result.release,
61
+ };
62
+ }
63
+
64
+ logger.debug('No update available');
65
+ return {
66
+ updateAvailable: false,
67
+ reason: (result as any).reason || 'NO_UPDATE',
68
+ };
69
+ }
70
+ }
@@ -0,0 +1,92 @@
1
+ import NativeSwiftPatch from '../native/NativeSwiftPatch';
2
+ import { logger } from '../utils/logger';
3
+ import type { ReleaseInfo } from '../types';
4
+
5
+ /**
6
+ * Core module responsible for verifying downloaded bundles.
7
+ *
8
+ * 4-step verification pipeline:
9
+ * 1. Apply patch if isPatch (via native bspatch)
10
+ * 2. Compute SHA-256 hash of the resulting bundle (via native)
11
+ * 3. Verify hash matches release.bundleHash
12
+ * 4. Verify RSA signature if provided (via native)
13
+ */
14
+ export class Verifier {
15
+ private publicKey: string | null = null;
16
+
17
+ /**
18
+ * Set the RSA public key for signature verification.
19
+ */
20
+ setPublicKey(key: string | null): void {
21
+ this.publicKey = key;
22
+ }
23
+
24
+ /**
25
+ * Run the full verification pipeline on a downloaded bundle/patch.
26
+ *
27
+ * @param downloadedPath Path to the downloaded file on disk
28
+ * @param release Release metadata from the server
29
+ * @param currentBundlePath Path to the current bundle (needed if isPatch)
30
+ * @returns The path to the final verified bundle
31
+ */
32
+ async verify(
33
+ downloadedPath: string,
34
+ release: ReleaseInfo,
35
+ currentBundlePath?: string
36
+ ): Promise<string> {
37
+ let bundlePath = downloadedPath;
38
+
39
+ // Step 1: Apply patch if this is a diff patch
40
+ if (release.isPatch) {
41
+ if (!currentBundlePath) {
42
+ throw new Error('Current bundle path required to apply patch');
43
+ }
44
+
45
+ logger.info('Applying binary patch...');
46
+ const outputPath = `${downloadedPath}.patched`;
47
+ bundlePath = await NativeSwiftPatch.applyPatch(
48
+ currentBundlePath,
49
+ downloadedPath,
50
+ outputPath
51
+ );
52
+ logger.info('Patch applied successfully');
53
+ }
54
+
55
+ // Step 2: Compute SHA-256 hash
56
+ logger.debug('Computing bundle hash...');
57
+ const computedHash = await NativeSwiftPatch.computeHash(bundlePath);
58
+
59
+ // Step 3: Verify hash matches expected
60
+ if (computedHash !== release.bundleHash) {
61
+ throw new Error(
62
+ `Hash mismatch: expected ${release.bundleHash}, got ${computedHash}`
63
+ );
64
+ }
65
+ logger.info('Hash verified successfully');
66
+
67
+ // Step 4: Verify RSA signature if provided
68
+ if (release.signature && this.publicKey) {
69
+ logger.debug('Verifying RSA signature...');
70
+ const isValid = await NativeSwiftPatch.verifySignature(
71
+ computedHash,
72
+ release.signature,
73
+ this.publicKey
74
+ );
75
+
76
+ if (!isValid) {
77
+ throw new Error('RSA signature verification failed');
78
+ }
79
+ logger.info('Signature verified successfully');
80
+ }
81
+
82
+ return bundlePath;
83
+ }
84
+
85
+ /**
86
+ * Quick hash-only verification.
87
+ */
88
+ async verifyHash(bundlePath: string, expectedHash: string): Promise<boolean> {
89
+ const hash = await NativeSwiftPatch.computeHash(bundlePath);
90
+ return hash === expectedHash;
91
+ }
92
+ }
@@ -0,0 +1,11 @@
1
+ export { UpdateChecker } from './UpdateChecker';
2
+ export type { UpdateCheckOptions, UpdateCheckResult } from './UpdateChecker';
3
+
4
+ export { Downloader } from './Downloader';
5
+ export type { DownloadOptions } from './Downloader';
6
+
7
+ export { Verifier } from './Verifier';
8
+
9
+ export { Installer } from './Installer';
10
+
11
+ export { Rollback } from './Rollback';
package/src/index.ts ADDED
@@ -0,0 +1,64 @@
1
+ // Provider
2
+ export { SwiftPatchProvider } from './SwiftPatchProvider';
3
+
4
+ // Hooks
5
+ export { useSwiftPatch, useSwiftPatchUpdate } from './useSwiftPatch';
6
+ export { useSwiftPatchModal } from './modal/useSwiftPatchModal';
7
+
8
+ // HOC
9
+ export { withSwiftPatch } from './withSwiftPatch';
10
+
11
+ // Imperative API (for non-React usage)
12
+ export { SwiftPatch } from './SwiftPatchCore';
13
+
14
+ // Modal component
15
+ export { SwiftPatchModal } from './modal/SwiftPatchModal';
16
+
17
+ // Types
18
+ export type {
19
+ SwiftPatchConfig,
20
+ SwiftPatchState,
21
+ SwiftPatchActions,
22
+ UseSwiftPatchReturn,
23
+ UseSwiftPatchUpdateReturn,
24
+ UseSwiftPatchModalReturn,
25
+ ReleaseInfo,
26
+ BundleInfo,
27
+ DownloadProgress,
28
+ SwiftPatchError,
29
+ SlotMetadata,
30
+ SwiftPatchEvent,
31
+ } from './types';
32
+
33
+ // Enums
34
+ export {
35
+ UpdateStatus,
36
+ InstallMode,
37
+ SwiftPatchErrorCode,
38
+ SlotState,
39
+ EnvironmentMode,
40
+ SwiftPatchEventType,
41
+ } from './types';
42
+
43
+ // Native module (for advanced usage)
44
+ export { default as NativeSwiftPatch } from './native/NativeSwiftPatch';
45
+
46
+ // Core modules (for advanced/custom usage)
47
+ export {
48
+ UpdateChecker,
49
+ Downloader,
50
+ Verifier,
51
+ Installer,
52
+ Rollback,
53
+ } from './core';
54
+ export type {
55
+ UpdateCheckOptions,
56
+ UpdateCheckResult,
57
+ DownloadOptions,
58
+ } from './core';
59
+
60
+ // Utility: restart the app
61
+ export function restart(): void {
62
+ const NativeModule = require('./native/NativeSwiftPatch').default;
63
+ NativeModule.restart();
64
+ }