react-native-ota-hot-update 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +17 -98
  2. package/android/generated/java/com/otahotupdate/NativeOtaHotUpdateSpec.java +4 -0
  3. package/android/generated/jni/RNOtaHotUpdateSpec-generated.cpp +6 -0
  4. package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/RNOtaHotUpdateSpecJSI-generated.cpp +7 -0
  5. package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/RNOtaHotUpdateSpecJSI.h +9 -0
  6. package/android/src/main/java/com/otahotupdate/OtaHotUpdateModule.kt +7 -0
  7. package/android/src/oldarch/OtaHotUpdateSpec.kt +1 -0
  8. package/ios/OtaHotUpdate.mm +13 -0
  9. package/ios/generated/RNOtaHotUpdateSpec/RNOtaHotUpdateSpec-generated.mm +7 -0
  10. package/ios/generated/RNOtaHotUpdateSpec/RNOtaHotUpdateSpec.h +3 -0
  11. package/ios/generated/RNOtaHotUpdateSpecJSI-generated.cpp +7 -0
  12. package/ios/generated/RNOtaHotUpdateSpecJSI.h +9 -0
  13. package/lib/commonjs/NativeOtaHotUpdate.js.map +1 -1
  14. package/lib/commonjs/gits/helper/fileReader.js +36 -0
  15. package/lib/commonjs/gits/helper/fileReader.js.map +1 -0
  16. package/lib/commonjs/gits/helper/fs.js +152 -0
  17. package/lib/commonjs/gits/helper/fs.js.map +1 -0
  18. package/lib/commonjs/gits/index.js +130 -0
  19. package/lib/commonjs/gits/index.js.map +1 -0
  20. package/lib/commonjs/index.d.js +6 -0
  21. package/lib/commonjs/index.d.js.map +1 -0
  22. package/lib/commonjs/index.js +63 -1
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/type.js +2 -0
  25. package/lib/commonjs/type.js.map +1 -0
  26. package/lib/module/NativeOtaHotUpdate.js.map +1 -1
  27. package/lib/module/gits/helper/fileReader.js +36 -0
  28. package/lib/module/gits/helper/fileReader.js.map +1 -0
  29. package/lib/module/gits/helper/fs.js +139 -0
  30. package/lib/module/gits/helper/fs.js.map +1 -0
  31. package/lib/module/gits/index.js +123 -0
  32. package/lib/module/gits/index.js.map +1 -0
  33. package/lib/module/index.d.js +4 -0
  34. package/lib/module/index.d.js.map +1 -0
  35. package/lib/module/index.js +62 -1
  36. package/lib/module/index.js.map +1 -1
  37. package/lib/module/type.js +2 -0
  38. package/lib/module/type.js.map +1 -0
  39. package/lib/typescript/commonjs/src/NativeOtaHotUpdate.d.ts +1 -0
  40. package/lib/typescript/commonjs/src/NativeOtaHotUpdate.d.ts.map +1 -1
  41. package/lib/typescript/commonjs/src/gits/helper/fs.d.ts +16 -0
  42. package/lib/typescript/commonjs/src/gits/helper/fs.d.ts.map +1 -0
  43. package/lib/typescript/commonjs/src/gits/index.d.ts +25 -0
  44. package/lib/typescript/commonjs/src/gits/index.d.ts.map +1 -0
  45. package/lib/typescript/commonjs/src/index.d.ts +25 -8
  46. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/src/type.d.ts +145 -0
  48. package/lib/typescript/commonjs/src/type.d.ts.map +1 -0
  49. package/lib/typescript/module/src/NativeOtaHotUpdate.d.ts +1 -0
  50. package/lib/typescript/module/src/NativeOtaHotUpdate.d.ts.map +1 -1
  51. package/lib/typescript/module/src/gits/helper/fs.d.ts +16 -0
  52. package/lib/typescript/module/src/gits/helper/fs.d.ts.map +1 -0
  53. package/lib/typescript/module/src/gits/index.d.ts +25 -0
  54. package/lib/typescript/module/src/gits/index.d.ts.map +1 -0
  55. package/lib/typescript/module/src/index.d.ts +25 -8
  56. package/lib/typescript/module/src/index.d.ts.map +1 -1
  57. package/lib/typescript/module/src/type.d.ts +145 -0
  58. package/lib/typescript/module/src/type.d.ts.map +1 -0
  59. package/package.json +8 -2
  60. package/src/NativeOtaHotUpdate.ts +1 -0
  61. package/src/gits/helper/fileReader.js +44 -0
  62. package/src/gits/helper/fs.ts +154 -0
  63. package/src/gits/index.ts +118 -0
  64. package/src/index.d.ts +80 -0
  65. package/src/index.tsx +62 -9
  66. package/src/type.ts +163 -0
package/src/type.ts ADDED
@@ -0,0 +1,163 @@
1
+ export interface UpdateOption {
2
+ /**
3
+ * Optional headers to include with the update request.
4
+ * Typically used for authentication or custom metadata.
5
+ */
6
+ headers?: Record<string, string>;
7
+
8
+ /**
9
+ * Callback to track download progress.
10
+ * @param received - Number of bytes received.
11
+ * @param total - Total number of bytes to be downloaded.
12
+ */
13
+ progress?(received: string, total: string): void;
14
+
15
+ /**
16
+ * Callback triggered when the update succeeds.
17
+ */
18
+ updateSuccess?(): void;
19
+
20
+ /**
21
+ * Callback triggered when the update fails.
22
+ * @param message - Optional error message or object describing the failure.
23
+ */
24
+ updateFail?(message?: string | Error): void;
25
+
26
+ /**
27
+ * Indicates whether the app should restart after installing the update.
28
+ * Default: `false`.
29
+ */
30
+ restartAfterInstall?: boolean;
31
+
32
+ /**
33
+ * Custom extension for the bundle file, if applicable.
34
+ * For example: '.jsbundle'.
35
+ */
36
+ extensionBundle?: string;
37
+ }
38
+
39
+ /**
40
+ * Options for updating a Git repository.
41
+ */
42
+ export interface UpdateGitOption {
43
+ /**
44
+ * The URL of the Git repository to check update.
45
+ */
46
+ url: string;
47
+
48
+ /**
49
+ * Optional callback to monitor the progress of the update.
50
+ * @param received - The number of bytes received so far.
51
+ * @param total - The total number of bytes to be received.
52
+ */
53
+ onProgress?(received: number, total: number): void;
54
+
55
+ /**
56
+ * Optional branch name to update or switch to.
57
+ * If not specified, the default branch will be main.
58
+ */
59
+ branch?: string;
60
+
61
+ /**
62
+ * Optional name of the folder where the repository will be cloned or updated.
63
+ * If not specified, a default folder name will be git_hot_update.
64
+ */
65
+ folderName?: string;
66
+ /**
67
+ * Optional callback when pull success, should handle for case update.
68
+ */
69
+ onPullSuccess?(): void;
70
+ /**
71
+ * Optional callback when pull failed.
72
+ */
73
+ onPullFailed?(msg: string): void;
74
+ /**
75
+ * Optional callback when clone success, handle it in the first time clone.
76
+ */
77
+ onCloneSuccess?(): void;
78
+ /**
79
+ * Optional callback when clone failed.
80
+ */
81
+ onCloneFailed?(msg: string): void;
82
+ /**
83
+ * The bundle path of the Git repository, it should place at root.
84
+ * Eg: the folder name is git_hot_update, bundle file place at git_hot_update/output/main.jsbundle, so bundlePath should be: "output/main.jsbundle".
85
+ */
86
+ bundlePath: string;
87
+ /**
88
+ * Optional restart app after clone / pull success for apply the new bundle.
89
+ */
90
+ restartAfterInstall?: boolean;
91
+ /**
92
+ * Optional when all process success, use for set loading false.
93
+ */
94
+ onFinishProgress?(): void;
95
+ }
96
+
97
+ export interface CloneOption {
98
+ /**
99
+ * The Git repository URL to be cloned.
100
+ * Example: "https://github.com/user/repo.git".
101
+ */
102
+ url: string;
103
+
104
+ /**
105
+ * Optional name of the folder where the repository will be cloned.
106
+ * If not provided, the repository name git_hot_update will be used.
107
+ */
108
+ folderName?: string;
109
+
110
+ /**
111
+ * Callback to track the progress of the cloning process.
112
+ * @param received - Number of bytes received so far.
113
+ * @param total - Total number of bytes to be downloaded.
114
+ */
115
+ onProgress?(received: number, total: number): void;
116
+
117
+ /**
118
+ * The branch to be checked out after cloning.
119
+ * Defaults to the repository's default branch if not specified.
120
+ */
121
+ branch?: string;
122
+
123
+ /**
124
+ * The bundle path of the Git repository, it should place at root.
125
+ * Eg: the folder name is git_hot_update, bundle file place at git_hot_update/output/main.jsbundle, so bundlePath should be: "output/main.jsbundle".
126
+ */
127
+ bundlePath: string;
128
+
129
+ /**
130
+ * Optional username to set up the Git user configuration.
131
+ * Used for operations like committing or signing, not for authentication.
132
+ * Example: "John Doe".
133
+ */
134
+ userName?: string;
135
+
136
+ /**
137
+ * Optional email to set up the Git user configuration.
138
+ * Used for operations like committing or signing, not for authentication.
139
+ * Example: "john.doe@example.com".
140
+ */
141
+ email?: string;
142
+ }
143
+
144
+ export interface PullOption {
145
+ /**
146
+ * Optional name of the folder containing the Git repository to pull from.
147
+ * Defaults to the current directory if not specified.
148
+ */
149
+ folderName?: string;
150
+
151
+ /**
152
+ * Callback to track the progress of the pull operation.
153
+ * @param received - Number of bytes received so far.
154
+ * @param total - Total number of bytes to be downloaded.
155
+ */
156
+ onProgress?(received: number, total: number): void;
157
+
158
+ /**
159
+ * The name of the branch to pull updates from.
160
+ * This branch must exist in the remote repository.
161
+ */
162
+ branch: string;
163
+ }