@hot-updater/react-native 0.17.0 → 0.18.1

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 (138) hide show
  1. package/HotUpdater.podspec +7 -11
  2. package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +200 -0
  3. package/android/src/main/java/com/hotupdater/FileManagerService.kt +104 -0
  4. package/android/src/main/java/com/hotupdater/HotUpdater.kt +62 -305
  5. package/android/src/main/java/com/hotupdater/HotUpdaterFactory.kt +49 -0
  6. package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +176 -0
  7. package/android/src/main/java/com/hotupdater/HttpDownloadService.kt +98 -0
  8. package/android/src/main/java/com/hotupdater/VersionedPreferencesService.kt +69 -0
  9. package/android/src/main/java/com/hotupdater/ZipFileUnzipService.kt +52 -0
  10. package/android/src/newarch/HotUpdaterModule.kt +31 -34
  11. package/android/src/oldarch/HotUpdaterModule.kt +32 -34
  12. package/android/src/oldarch/HotUpdaterSpec.kt +2 -9
  13. package/ios/HotUpdater/Internal/BundleFileStorageService.swift +593 -0
  14. package/ios/HotUpdater/Internal/FileManagerService.swift +97 -0
  15. package/ios/HotUpdater/Internal/HotUpdater-Bridging-Header.h +8 -0
  16. package/ios/HotUpdater/Internal/HotUpdater.mm +241 -0
  17. package/ios/HotUpdater/Internal/HotUpdaterFactory.swift +24 -0
  18. package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +143 -0
  19. package/ios/HotUpdater/Internal/NotificationExtension.swift +6 -0
  20. package/ios/HotUpdater/Internal/SSZipArchiveUnzipService.swift +25 -0
  21. package/ios/HotUpdater/Internal/URLSessionDownloadService.swift +101 -0
  22. package/ios/HotUpdater/Internal/VersionedPreferencesService.swift +82 -0
  23. package/ios/HotUpdater/Public/HotUpdater.h +29 -0
  24. package/lib/commonjs/checkForUpdate.js +70 -0
  25. package/lib/commonjs/checkForUpdate.js.map +1 -0
  26. package/lib/commonjs/error.js +14 -0
  27. package/lib/commonjs/error.js.map +1 -0
  28. package/lib/commonjs/fetchUpdateInfo.js +74 -0
  29. package/lib/commonjs/fetchUpdateInfo.js.map +1 -0
  30. package/lib/commonjs/hooks/useEventCallback.js +17 -0
  31. package/lib/commonjs/hooks/useEventCallback.js.map +1 -0
  32. package/lib/commonjs/index.js +234 -0
  33. package/lib/commonjs/index.js.map +1 -0
  34. package/lib/commonjs/native.js +132 -0
  35. package/lib/commonjs/native.js.map +1 -0
  36. package/lib/commonjs/package.json +1 -0
  37. package/lib/commonjs/runUpdateProcess.js +69 -0
  38. package/lib/commonjs/runUpdateProcess.js.map +1 -0
  39. package/lib/commonjs/specs/NativeHotUpdater.js +9 -0
  40. package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -0
  41. package/lib/commonjs/store.js +48 -0
  42. package/lib/commonjs/store.js.map +1 -0
  43. package/lib/commonjs/wrap.js +98 -0
  44. package/lib/commonjs/wrap.js.map +1 -0
  45. package/lib/module/checkForUpdate.js +64 -0
  46. package/lib/module/checkForUpdate.js.map +1 -0
  47. package/lib/module/error.js +9 -0
  48. package/lib/module/error.js.map +1 -0
  49. package/lib/module/fetchUpdateInfo.js +69 -0
  50. package/lib/module/fetchUpdateInfo.js.map +1 -0
  51. package/lib/module/hooks/useEventCallback.js +13 -0
  52. package/lib/module/hooks/useEventCallback.js.map +1 -0
  53. package/lib/module/index.js +211 -0
  54. package/lib/module/index.js.map +1 -0
  55. package/lib/module/native.js +119 -0
  56. package/lib/module/native.js.map +1 -0
  57. package/lib/module/package.json +1 -0
  58. package/lib/module/runUpdateProcess.js +64 -0
  59. package/lib/module/runUpdateProcess.js.map +1 -0
  60. package/lib/module/specs/NativeHotUpdater.js +5 -0
  61. package/lib/module/specs/NativeHotUpdater.js.map +1 -0
  62. package/lib/module/store.js +42 -0
  63. package/lib/module/store.js.map +1 -0
  64. package/lib/module/wrap.js +94 -0
  65. package/lib/module/wrap.js.map +1 -0
  66. package/lib/typescript/commonjs/checkForUpdate.d.ts +22 -0
  67. package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -0
  68. package/{dist → lib/typescript/commonjs}/error.d.ts +1 -0
  69. package/lib/typescript/commonjs/error.d.ts.map +1 -0
  70. package/lib/typescript/commonjs/fetchUpdateInfo.d.ts +4 -0
  71. package/lib/typescript/commonjs/fetchUpdateInfo.d.ts.map +1 -0
  72. package/{dist → lib/typescript/commonjs}/hooks/useEventCallback.d.ts +1 -0
  73. package/lib/typescript/commonjs/hooks/useEventCallback.d.ts.map +1 -0
  74. package/{dist → lib/typescript/commonjs}/index.d.ts +38 -12
  75. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  76. package/lib/typescript/commonjs/native.d.ts +64 -0
  77. package/lib/typescript/commonjs/native.d.ts.map +1 -0
  78. package/lib/typescript/commonjs/package.json +1 -0
  79. package/{dist → lib/typescript/commonjs}/runUpdateProcess.d.ts +1 -0
  80. package/lib/typescript/commonjs/runUpdateProcess.d.ts.map +1 -0
  81. package/{dist → lib/typescript/commonjs}/specs/NativeHotUpdater.d.ts +8 -9
  82. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -0
  83. package/{dist → lib/typescript/commonjs}/store.d.ts +1 -0
  84. package/lib/typescript/commonjs/store.d.ts.map +1 -0
  85. package/{dist → lib/typescript/commonjs}/wrap.d.ts +3 -2
  86. package/lib/typescript/commonjs/wrap.d.ts.map +1 -0
  87. package/lib/typescript/module/checkForUpdate.d.ts +22 -0
  88. package/lib/typescript/module/checkForUpdate.d.ts.map +1 -0
  89. package/lib/typescript/module/error.d.ts +4 -0
  90. package/lib/typescript/module/error.d.ts.map +1 -0
  91. package/lib/typescript/module/fetchUpdateInfo.d.ts +4 -0
  92. package/lib/typescript/module/fetchUpdateInfo.d.ts.map +1 -0
  93. package/lib/typescript/module/hooks/useEventCallback.d.ts +5 -0
  94. package/lib/typescript/module/hooks/useEventCallback.d.ts.map +1 -0
  95. package/lib/typescript/module/index.d.ts +202 -0
  96. package/lib/typescript/module/index.d.ts.map +1 -0
  97. package/lib/typescript/module/native.d.ts +64 -0
  98. package/lib/typescript/module/native.d.ts.map +1 -0
  99. package/lib/typescript/module/package.json +1 -0
  100. package/lib/typescript/module/runUpdateProcess.d.ts +49 -0
  101. package/lib/typescript/module/runUpdateProcess.d.ts.map +1 -0
  102. package/lib/typescript/module/specs/NativeHotUpdater.d.ts +19 -0
  103. package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -0
  104. package/lib/typescript/module/store.d.ts +11 -0
  105. package/lib/typescript/module/store.d.ts.map +1 -0
  106. package/lib/typescript/module/wrap.d.ts +51 -0
  107. package/lib/typescript/module/wrap.d.ts.map +1 -0
  108. package/package.json +59 -30
  109. package/src/checkForUpdate.ts +59 -9
  110. package/src/fetchUpdateInfo.ts +40 -12
  111. package/src/index.ts +37 -11
  112. package/src/native.ts +87 -41
  113. package/src/runUpdateProcess.ts +2 -2
  114. package/src/specs/NativeHotUpdater.ts +8 -10
  115. package/src/wrap.tsx +9 -13
  116. package/android/generated/java/com/hotupdater/NativeHotUpdaterSpec.java +0 -93
  117. package/android/generated/jni/CMakeLists.txt +0 -36
  118. package/android/generated/jni/HotUpdaterSpec-generated.cpp +0 -68
  119. package/android/generated/jni/HotUpdaterSpec.h +0 -31
  120. package/android/generated/jni/react/renderer/components/HotUpdaterSpec/HotUpdaterSpecJSI-generated.cpp +0 -70
  121. package/android/generated/jni/react/renderer/components/HotUpdaterSpec/HotUpdaterSpecJSI.h +0 -121
  122. package/android/src/main/java/com/hotupdater/HotUpdaterPrefs.kt +0 -42
  123. package/dist/checkForUpdate.d.ts +0 -12
  124. package/dist/fetchUpdateInfo.d.ts +0 -3
  125. package/dist/index.js +0 -341
  126. package/dist/index.mjs +0 -301
  127. package/dist/native.d.ts +0 -41
  128. package/ios/HotUpdater/HotUpdater.h +0 -15
  129. package/ios/HotUpdater/HotUpdater.mm +0 -468
  130. package/ios/HotUpdater/HotUpdater.modulemap +0 -6
  131. package/ios/HotUpdater/HotUpdaterPrefs.h +0 -9
  132. package/ios/HotUpdater/HotUpdaterPrefs.mm +0 -45
  133. package/ios/generated/HotUpdaterSpec/HotUpdaterSpec-generated.mm +0 -81
  134. package/ios/generated/HotUpdaterSpec/HotUpdaterSpec.h +0 -112
  135. package/ios/generated/HotUpdaterSpecJSI-generated.cpp +0 -70
  136. package/ios/generated/HotUpdaterSpecJSI.h +0 -121
  137. package/react-native.config.js +0 -12
  138. package/src/global.d.ts +0 -3
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.checkForUpdate = checkForUpdate;
7
+ exports.getUpdateSource = void 0;
8
+ var _reactNative = require("react-native");
9
+ var _error = require("./error.js");
10
+ var _fetchUpdateInfo = require("./fetchUpdateInfo.js");
11
+ var _native = require("./native.js");
12
+ async function checkForUpdate(options) {
13
+ if (__DEV__) {
14
+ return null;
15
+ }
16
+ if (!["ios", "android"].includes(_reactNative.Platform.OS)) {
17
+ options.onError?.(new _error.HotUpdaterError("HotUpdater is only supported on iOS and Android"));
18
+ return null;
19
+ }
20
+ const currentAppVersion = (0, _native.getAppVersion)();
21
+ const platform = _reactNative.Platform.OS;
22
+ const currentBundleId = (0, _native.getBundleId)();
23
+ const minBundleId = (0, _native.getMinBundleId)();
24
+ const channel = (0, _native.getChannel)();
25
+ if (!currentAppVersion) {
26
+ options.onError?.(new _error.HotUpdaterError("Failed to get app version"));
27
+ return null;
28
+ }
29
+ const baseArgs = {
30
+ bundleId: currentBundleId,
31
+ platform,
32
+ minBundleId,
33
+ channel: channel ?? undefined
34
+ };
35
+ return (0, _fetchUpdateInfo.fetchUpdateInfo)(options.source, _native.HotUpdaterConstants.UPDATE_STRATEGY === "appVersion" ? {
36
+ _updateStrategy: _native.HotUpdaterConstants.UPDATE_STRATEGY,
37
+ appVersion: currentAppVersion,
38
+ ...baseArgs
39
+ } : {
40
+ _updateStrategy: _native.HotUpdaterConstants.UPDATE_STRATEGY,
41
+ fingerprintHash: _native.HotUpdaterConstants.FINGERPRINT_HASH,
42
+ ...baseArgs
43
+ }, options.requestHeaders, options.onError, options.requestTimeout).then(updateInfo => {
44
+ if (!updateInfo) {
45
+ return null;
46
+ }
47
+ return {
48
+ ...updateInfo,
49
+ updateBundle: async () => {
50
+ return (0, _native.updateBundle)({
51
+ bundleId: updateInfo.id,
52
+ fileUrl: updateInfo.fileUrl,
53
+ status: updateInfo.status
54
+ });
55
+ }
56
+ };
57
+ });
58
+ }
59
+ const getUpdateSource = baseUrl => args => {
60
+ switch (args._updateStrategy) {
61
+ case "appVersion":
62
+ return `${baseUrl}/app-version/${args.platform}/${args.appVersion}/${args.channel}/${args.minBundleId}/${args.bundleId}`;
63
+ case "fingerprint":
64
+ return `${baseUrl}/fingerprint/${args.platform}/${args.fingerprintHash}/${args.channel}/${args.minBundleId}/${args.bundleId}`;
65
+ default:
66
+ return baseUrl;
67
+ }
68
+ };
69
+ exports.getUpdateSource = getUpdateSource;
70
+ //# sourceMappingURL=checkForUpdate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_error","_fetchUpdateInfo","_native","checkForUpdate","options","__DEV__","includes","Platform","OS","onError","HotUpdaterError","currentAppVersion","getAppVersion","platform","currentBundleId","getBundleId","minBundleId","getMinBundleId","channel","getChannel","baseArgs","bundleId","undefined","fetchUpdateInfo","source","HotUpdaterConstants","UPDATE_STRATEGY","_updateStrategy","appVersion","fingerprintHash","FINGERPRINT_HASH","requestHeaders","requestTimeout","then","updateInfo","updateBundle","id","fileUrl","status","getUpdateSource","baseUrl","args","exports"],"sourceRoot":"../../src","sources":["checkForUpdate.ts"],"mappings":";;;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AA4BO,eAAeI,cAAcA,CAClCC,OAA8B,EACQ;EACtC,IAAIC,OAAO,EAAE;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ACbC,YAAY,EAAE,MAAAA,CAAA,KAAY;QACxB,OAAO,IAAAA,oBAAY,EAAC;UAClBd,QAAQ,EAAEa,UAAU,CAACE,EAAE;UACvBC,OAAO,EAAEH,UAAU,CAACG,OAAO;UAC3BC,MAAM,EAAEJ,UAAU,CAACI;QACrB,CAAC,CAAC;MACJ;IACF,CAAC;EACH,CAAC,CAAC;AACJ;AAEO,MAAMC,eAAe,GAAIC,OAAe,IAAMC,IAAoB,IAAK;EAC5E,QAAQA,IAAI,CAACd,eAAe;IAC1B,KAAK,YAAY;MACf,OAAO,GAAGa,OAAO,gBAAgBC,IAAI,CAAC5B,QAAQ,IAAI4B,IAAI,CAACb,UAAU,IAAIa,IAAI,CAACvB,OAAO,IAAIuB,IAAI,CAACzB,WAAW,IAAIyB,IAAI,CAACpB,QAAQ,EAAE;IAC1H,KAAK,aAAa;MAChB,OAAO,GAAGmB,OAAO,gBAAgBC,IAAI,CAAC5B,QAAQ,IAAI4B,IAAI,CAACZ,eAAe,IAAIY,IAAI,CAACvB,OAAO,IAAIuB,IAAI,CAACzB,WAAW,IAAIyB,IAAI,CAACpB,QAAQ,EAAE;IAC/H;MACE,OAAOmB,OAAO;EAClB;AACF,CAAC;AAACE,OAAA,CAAAH,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.HotUpdaterError = void 0;
7
+ class HotUpdaterError extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = "HotUpdaterError";
11
+ }
12
+ }
13
+ exports.HotUpdaterError = HotUpdaterError;
14
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["HotUpdaterError","Error","constructor","message","name","exports"],"sourceRoot":"../../src","sources":["error.ts"],"mappings":";;;;;;AAAO,MAAMA,eAAe,SAASC,KAAK,CAAC;EACzCC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,iBAAiB;EAC/B;AACF;AAACC,OAAA,CAAAL,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fetchUpdateInfo = void 0;
7
+ const fetchUpdateInfo = async (source, args, requestHeaders, onError, requestTimeout = 5000) => {
8
+ if (typeof source === "function") {
9
+ const url = source(args);
10
+ if (typeof url !== "string") {
11
+ return null;
12
+ }
13
+ source = url;
14
+ }
15
+ const controller = new AbortController();
16
+ const timeoutId = setTimeout(() => {
17
+ controller.abort();
18
+ }, requestTimeout);
19
+ try {
20
+ let headers = {};
21
+ switch (args._updateStrategy) {
22
+ case "fingerprint":
23
+ headers = {
24
+ "Content-Type": "application/json",
25
+ "x-app-platform": args.platform,
26
+ "x-bundle-id": args.bundleId,
27
+ "x-fingerprint-hash": args.fingerprintHash,
28
+ ...(args.minBundleId ? {
29
+ "x-min-bundle-id": args.minBundleId
30
+ } : {}),
31
+ ...(args.channel ? {
32
+ "x-channel": args.channel
33
+ } : {}),
34
+ ...requestHeaders
35
+ };
36
+ break;
37
+ case "appVersion":
38
+ headers = {
39
+ "Content-Type": "application/json",
40
+ "x-app-platform": args.platform,
41
+ "x-bundle-id": args.bundleId,
42
+ "x-app-version": args.appVersion,
43
+ ...(args.minBundleId ? {
44
+ "x-min-bundle-id": args.minBundleId
45
+ } : {}),
46
+ ...(args.channel ? {
47
+ "x-channel": args.channel
48
+ } : {}),
49
+ ...requestHeaders
50
+ };
51
+ break;
52
+ default:
53
+ throw new Error("Invalid update strategy");
54
+ }
55
+ const response = await fetch(source, {
56
+ signal: controller.signal,
57
+ headers
58
+ });
59
+ clearTimeout(timeoutId);
60
+ if (response.status !== 200) {
61
+ throw new Error(response.statusText);
62
+ }
63
+ return response.json();
64
+ } catch (error) {
65
+ if (error.name === "AbortError") {
66
+ onError?.(new Error("Request timed out"));
67
+ return null;
68
+ }
69
+ onError?.(error);
70
+ return null;
71
+ }
72
+ };
73
+ exports.fetchUpdateInfo = fetchUpdateInfo;
74
+ //# sourceMappingURL=fetchUpdateInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fetchUpdateInfo","source","args","requestHeaders","onError","requestTimeout","url","controller","AbortController","timeoutId","setTimeout","abort","headers","_updateStrategy","platform","bundleId","fingerprintHash","minBundleId","channel","appVersion","Error","response","fetch","signal","clearTimeout","status","statusText","json","error","name","exports"],"sourceRoot":"../../src","sources":["fetchUpdateInfo.ts"],"mappings":";;;;;;AAOO,MAAMA,eAAe,GAAG,MAAAA,CAC7BC,MAAoB,EACpBC,IAAoB,EACpBC,cAAuC,EACvCC,OAAgC,EAChCC,cAAc,GAAG,IAAI,KACa;EAClC,IAAI,OAAOJ,MAAM,KAAK,UAAU,EAAE;IAChC,MAAMK,GAAG,GAAGL,MAAM,CAACC,IAAI,CAAC;IACxB,IAAI,OAAOI,GAAG,KAAK,QAAQ,EAAE;MAC3B,OAAO,IAAI;IACb;IACAL,MAAM,GAAGK,GAAG;EACd;EAEA,MAAMC,UAAU,GAAG,IAAIC,eAAe,CAAC,CAAC;EACxC,MAAMC,SAAS,GAAGC,UAAU,CAAC,MAAM;IACjCH,UAAU,CAACI,KAAK,CAAC,CAAC;EACpB,CAAC,EAAEN,cAAc,CAAC;EAElB,IAAI;IACF,IAAIO,OAA+B,GAAG,CAAC,CAAC;IAExC,QAAQV,IAAI,CAACW,eAAe;MAC1B,KAAK,aAAa;QAChBD,OAAO,GAAG;UACR,cAAc,EAAE,kBAAkB;UAClC,gBAAgB,EAAEV,IAAI,CAACY,QAAQ;UAC/B,aAAa,EAAEZ,IAAI,CAACa,QAAQ;UAC5B,oBAAoB,EAAEb,IAAI,CAACc,eAAe;UAC1C,IAAId,IAAI,CAACe,WAAW,GAAG;YAAE,iBAAiB,EAAEf,IAAI,CAACe;UAAY,CAAC,GAAG,CAAC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ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useEventCallback = useEventCallback;
7
+ var _react = require("react");
8
+ function useEventCallback(fn) {
9
+ const callbackRef = (0, _react.useRef)(() => {
10
+ throw new Error("Cannot call an event handler while rendering.");
11
+ });
12
+ (0, _react.useLayoutEffect)(() => {
13
+ callbackRef.current = fn;
14
+ }, [fn]);
15
+ return (0, _react.useCallback)((...args) => callbackRef.current?.(...args), [callbackRef]);
16
+ }
17
+ //# sourceMappingURL=useEventCallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","useEventCallback","fn","callbackRef","useRef","Error","useLayoutEffect","current","useCallback","args"],"sourceRoot":"../../../src","sources":["hooks/useEventCallback.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAYO,SAASC,gBAAgBA,CAC9BC,EAA0B,EACF;EACxB,MAAMC,WAAW,GAAG,IAAAC,aAAM,EAAyB,MAAM;IACvD,MAAM,IAAIC,KAAK,CAAC,+CAA+C,CAAC;EAClE,CAAC,CAAC;EAEF,IAAAC,sBAAe,EAAC,MAAM;IACpBH,WAAW,CAACI,OAAO,GAAGL,EAAE;EAC1B,CAAC,EAAE,CAACA,EAAE,CAAC,CAAC;EAER,OAAO,IAAAM,kBAAW,EAChB,CAAC,GAAGC,IAAU,KAAKN,WAAW,CAACI,OAAO,GAAG,GAAGE,IAAI,CAAC,EACjD,CAACN,WAAW,CACd,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ HotUpdater: true,
8
+ getUpdateSource: true
9
+ };
10
+ exports.HotUpdater = void 0;
11
+ Object.defineProperty(exports, "getUpdateSource", {
12
+ enumerable: true,
13
+ get: function () {
14
+ return _checkForUpdate.getUpdateSource;
15
+ }
16
+ });
17
+ var _checkForUpdate = require("./checkForUpdate.js");
18
+ var _native = require("./native.js");
19
+ var _runUpdateProcess = require("./runUpdateProcess.js");
20
+ var _store = require("./store.js");
21
+ Object.keys(_store).forEach(function (key) {
22
+ if (key === "default" || key === "__esModule") return;
23
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
24
+ if (key in exports && exports[key] === _store[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _store[key];
29
+ }
30
+ });
31
+ });
32
+ var _wrap = require("./wrap.js");
33
+ (0, _native.addListener)("onProgress", ({
34
+ progress
35
+ }) => {
36
+ _store.hotUpdaterStore.setState({
37
+ progress
38
+ });
39
+ });
40
+ const HotUpdater = exports.HotUpdater = {
41
+ /**
42
+ * `HotUpdater.wrap` checks for updates at the entry point, and if there is a bundle to update, it downloads the bundle and applies the update strategy.
43
+ *
44
+ * @param {object} options - Configuration options
45
+ * @param {string} options.source - Update server URL
46
+ * @param {object} [options.requestHeaders] - Request headers
47
+ * @param {React.ComponentType} [options.fallbackComponent] - Component to display during updates
48
+ * @param {boolean} [options.reloadOnForceUpdate=true] - Whether to automatically reload the app on force updates
49
+ * @param {Function} [options.onUpdateProcessCompleted] - Callback after update process completes
50
+ * @param {Function} [options.onProgress] - Callback to track bundle download progress
51
+ * @returns {Function} Higher-order component that wraps the app component
52
+ *
53
+ * @example
54
+ * ```tsx
55
+ * export default HotUpdater.wrap({
56
+ * source: "<your-update-server-url>",
57
+ * requestHeaders: {
58
+ * "Authorization": "Bearer <your-access-token>",
59
+ * },
60
+ * })(App);
61
+ * ```
62
+ */
63
+ wrap: _wrap.wrap,
64
+ /**
65
+ * Reloads the app.
66
+ */
67
+ reload: _native.reload,
68
+ /**
69
+ * Fetches the current app version.
70
+ */
71
+ getAppVersion: _native.getAppVersion,
72
+ /**
73
+ * Fetches the current bundle ID of the app.
74
+ */
75
+ getBundleId: _native.getBundleId,
76
+ /**
77
+ * Retrieves the initial bundle ID based on the build time of the native app.
78
+ */
79
+ getMinBundleId: _native.getMinBundleId,
80
+ /**
81
+ * Fetches the current channel of the app.
82
+ *
83
+ * If no channel is specified, the app is assigned to the 'production' channel.
84
+ *
85
+ * @returns {string} The current release channel of the app
86
+ * @default "production"
87
+ * @example
88
+ * ```ts
89
+ * const channel = HotUpdater.getChannel();
90
+ * console.log(`Current channel: ${channel}`);
91
+ * ```
92
+ */
93
+ getChannel: _native.getChannel,
94
+ /**
95
+ * The initial channel of the native app.
96
+ *
97
+ * @returns {string} The current release channel of the app
98
+ * @default "production"
99
+ * @example
100
+ * ```ts
101
+ * const channel = HotUpdater.getReleaseChannel();
102
+ * console.log(`Current release channel: ${channel}`);
103
+ * ```
104
+ */
105
+ getReleaseChannel: _native.getReleaseChannel,
106
+ /**
107
+ * Adds a listener to HotUpdater events.
108
+ *
109
+ * @param {keyof HotUpdaterEvent} eventName - The name of the event to listen for
110
+ * @param {(event: HotUpdaterEvent[T]) => void} listener - The callback function to handle the event
111
+ * @returns {() => void} A cleanup function that removes the event listener
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * const unsubscribe = HotUpdater.addListener("onProgress", ({ progress }) => {
116
+ * console.log(`Update progress: ${progress * 100}%`);
117
+ * });
118
+ *
119
+ * // Unsubscribe when no longer needed
120
+ * unsubscribe();
121
+ * ```
122
+ */
123
+ addListener: _native.addListener,
124
+ /**
125
+ * Manually checks for updates.
126
+ *
127
+ * @param {Object} config - Update check configuration
128
+ * @param {string} config.source - Update server URL
129
+ * @param {Record<string, string>} [config.requestHeaders] - Request headers
130
+ *
131
+ * @returns {Promise<UpdateInfo | null>} Update information or null if up to date
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * const updateInfo = await HotUpdater.checkForUpdate({
136
+ * source: "<your-update-server-url>",
137
+ * requestHeaders: {
138
+ * Authorization: "Bearer <your-access-token>",
139
+ * },
140
+ * });
141
+ *
142
+ * if (!updateInfo) {
143
+ * console.log("App is up to date");
144
+ * return;
145
+ * }
146
+ *
147
+ * await HotUpdater.updateBundle(updateInfo.id, updateInfo.fileUrl);
148
+ * if (updateInfo.shouldForceUpdate) {
149
+ * HotUpdater.reload();
150
+ * }
151
+ * ```
152
+ */
153
+ checkForUpdate: _checkForUpdate.checkForUpdate,
154
+ /**
155
+ * Manually checks and applies updates for the application.
156
+ *
157
+ * @param {RunUpdateProcessConfig} config - Update process configuration
158
+ * @param {string} config.source - Update server URL
159
+ * @param {Record<string, string>} [config.requestHeaders] - Request headers
160
+ * @param {boolean} [config.reloadOnForceUpdate=false] - Whether to automatically reload on force update
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * // Auto reload on force update
165
+ * const result = await HotUpdater.runUpdateProcess({
166
+ * source: "<your-update-server-url>",
167
+ * requestHeaders: {
168
+ * // Add necessary headers
169
+ * },
170
+ * reloadOnForceUpdate: true
171
+ * });
172
+ *
173
+ * // Manually handle reload on force update
174
+ * const result = await HotUpdater.runUpdateProcess({
175
+ * source: "<your-update-server-url>",
176
+ * reloadOnForceUpdate: false
177
+ * });
178
+ *
179
+ * if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
180
+ * HotUpdater.reload();
181
+ * }
182
+ * ```
183
+ *
184
+ * @returns {Promise<RunUpdateProcessResponse>} The result of the update process
185
+ */
186
+ runUpdateProcess: _runUpdateProcess.runUpdateProcess,
187
+ /**
188
+ * Updates the bundle of the app.
189
+ *
190
+ * @param {UpdateBundleParams} params - Parameters object required for bundle update
191
+ * @param {string} params.bundleId - The bundle ID of the app
192
+ * @param {string|null} params.fileUrl - The URL of the zip file
193
+ *
194
+ * @returns {Promise<boolean>} Whether the update was successful
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * const updateInfo = await HotUpdater.checkForUpdate({
199
+ * source: "<your-update-server-url>",
200
+ * requestHeaders: {
201
+ * Authorization: "Bearer <your-access-token>",
202
+ * },
203
+ * });
204
+ *
205
+ * if (!updateInfo) {
206
+ * return {
207
+ * status: "UP_TO_DATE",
208
+ * };
209
+ * }
210
+ *
211
+ * await HotUpdater.updateBundle({
212
+ * bundleId: updateInfo.id,
213
+ * fileUrl: updateInfo.fileUrl
214
+ * });
215
+ * if (updateInfo.shouldForceUpdate) {
216
+ * HotUpdater.reload();
217
+ * }
218
+ * ```
219
+ */
220
+ updateBundle: _native.updateBundle,
221
+ /**
222
+ * Fetches the fingerprint of the app.
223
+ *
224
+ * @returns {string} The fingerprint of the app
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * const fingerprint = HotUpdater.getFingerprintHash();
229
+ * console.log(`Fingerprint: ${fingerprint}`);
230
+ * ```
231
+ */
232
+ getFingerprintHash: _native.getFingerprintHash
233
+ };
234
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_checkForUpdate","require","_native","_runUpdateProcess","_store","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_wrap","addListener","progress","hotUpdaterStore","setState","HotUpdater","wrap","reload","getAppVersion","getBundleId","getMinBundleId","getChannel","getReleaseChannel","checkForUpdate","runUpdateProcess","updateBundle","getFingerprintHash"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAWA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAMAI,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AALA,IAAAS,KAAA,GAAAhB,OAAA;AAOA,IAAAiB,mBAAW,EAAC,YAAY,EAAE,CAAC;EAAEC;AAAS,CAAC,KAAK;EAC1CC,sBAAe,CAACC,QAAQ,CAAC;IACvBF;EACF,CAAC,CAAC;AACJ,CAAC,CAAC;AAEK,MAAMG,UAAU,GAAAT,OAAA,CAAAS,UAAA,GAAG;EACxB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,IAAI,EAAJA,UAAI;EACJ;AACF;AACA;EACEC,MAAM,EAANA,cAAM;EACN;AACF;AACA;EACEC,aAAa,EAAbA,qBAAa;EACb;AACF;AACA;EACEC,WAAW,EAAXA,mBAAW;EACX;AACF;AACA;EACEC,cAAc,EAAdA,sBAAc;EACd;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,UAAU,EAAVA,kBAAU;EACV;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,iBAAiB,EAAjBA,yBAAiB;EACjB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEX,WAAW,EAAXA,mBAAW;EACX;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEY,cAAc,EAAdA,8BAAc;EACd;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,gBAAgB,EAAhBA,kCAAgB;EAChB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,YAAY,EAAZA,oBAAY;EACZ;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,kBAAkB,EAAlBA;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.reload = exports.getReleaseChannel = exports.getMinBundleId = exports.getFingerprintHash = exports.getChannel = exports.getBundleId = exports.getAppVersion = exports.addListener = exports.HotUpdaterConstants = void 0;
7
+ exports.updateBundle = updateBundle;
8
+ var _reactNative = require("react-native");
9
+ var _NativeHotUpdater = _interopRequireDefault(require("./specs/NativeHotUpdater.js"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
12
+ const HotUpdaterConstants = exports.HotUpdaterConstants = {
13
+ OVER_THE_AIR_CHANNEL: __HOT_UPDATER_CHANNEL,
14
+ HOT_UPDATER_BUNDLE_ID: __HOT_UPDATER_BUNDLE_ID || NIL_UUID,
15
+ FINGERPRINT_HASH: _reactNative.Platform.select({
16
+ ios: __HOT_UPDATER_FINGERPRINT_HASH_IOS,
17
+ android: __HOT_UPDATER_FINGERPRINT_HASH_ANDROID,
18
+ default: null
19
+ }),
20
+ UPDATE_STRATEGY: __HOT_UPDATER_UPDATE_STRATEGY
21
+ };
22
+ const addListener = (eventName, listener) => {
23
+ const eventEmitter = new _reactNative.NativeEventEmitter(_NativeHotUpdater.default);
24
+ const subscription = eventEmitter.addListener(eventName, listener);
25
+ return () => {
26
+ subscription.remove();
27
+ };
28
+ };
29
+
30
+ /**
31
+ * Downloads files and applies them to the app.
32
+ *
33
+ * @param {UpdateParams} params - Parameters object required for bundle update
34
+ * @returns {Promise<boolean>} Resolves with true if download was successful, otherwise rejects with an error.
35
+ */
36
+
37
+ /**
38
+ * @deprecated Use updateBundle(params: UpdateBundleParamsWithStatus) instead
39
+ */
40
+ exports.addListener = addListener;
41
+ async function updateBundle(paramsOrBundleId, fileUrl) {
42
+ const updateBundleId = typeof paramsOrBundleId === "string" ? paramsOrBundleId : paramsOrBundleId.bundleId;
43
+ const status = typeof paramsOrBundleId === "string" ? "UPDATE" : paramsOrBundleId.status;
44
+ const currentBundleId = getBundleId();
45
+
46
+ // updateBundleId <= currentBundleId
47
+ if (status === "UPDATE" && updateBundleId.localeCompare(currentBundleId) <= 0) {
48
+ throw new Error("Update bundle id is the same as the current bundle id. Preventing infinite update loop.");
49
+ }
50
+ if (typeof paramsOrBundleId === "string") {
51
+ return _NativeHotUpdater.default.updateBundle({
52
+ bundleId: updateBundleId,
53
+ fileUrl: fileUrl || null
54
+ });
55
+ }
56
+ return _NativeHotUpdater.default.updateBundle({
57
+ bundleId: updateBundleId,
58
+ fileUrl: paramsOrBundleId.fileUrl
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Fetches the current app version.
64
+ */
65
+ const getAppVersion = () => {
66
+ const constants = _NativeHotUpdater.default.getConstants();
67
+ return constants?.APP_VERSION ?? null;
68
+ };
69
+
70
+ /**
71
+ * Reloads the app.
72
+ */
73
+ exports.getAppVersion = getAppVersion;
74
+ const reload = () => {
75
+ requestAnimationFrame(() => {
76
+ _NativeHotUpdater.default.reload();
77
+ });
78
+ };
79
+
80
+ /**
81
+ * Fetches the minimum bundle id, which represents the initial bundle of the app
82
+ * since it is created at build time.
83
+ *
84
+ * @returns {string} Resolves with the minimum bundle id or null if not available.
85
+ */
86
+ exports.reload = reload;
87
+ const getMinBundleId = () => {
88
+ const constants = _NativeHotUpdater.default.getConstants();
89
+ return constants.MIN_BUNDLE_ID;
90
+ };
91
+
92
+ /**
93
+ * Fetches the current bundle version id.
94
+ *
95
+ * @async
96
+ * @returns {Promise<string>} Resolves with the current version id or null if not available.
97
+ */
98
+ exports.getMinBundleId = getMinBundleId;
99
+ const getBundleId = () => {
100
+ return HotUpdaterConstants.HOT_UPDATER_BUNDLE_ID === NIL_UUID ? getMinBundleId() : HotUpdaterConstants.HOT_UPDATER_BUNDLE_ID;
101
+ };
102
+
103
+ /**
104
+ * Fetches the channel for the app.
105
+ *
106
+ * @returns {string} Resolves with the channel or null if not available.
107
+ */
108
+ exports.getBundleId = getBundleId;
109
+ const getChannel = () => {
110
+ if (HotUpdaterConstants.OVER_THE_AIR_CHANNEL) {
111
+ return HotUpdaterConstants.OVER_THE_AIR_CHANNEL;
112
+ }
113
+ const constants = _NativeHotUpdater.default.getConstants();
114
+ return constants.CHANNEL;
115
+ };
116
+ exports.getChannel = getChannel;
117
+ const getReleaseChannel = () => {
118
+ const constants = _NativeHotUpdater.default.getConstants();
119
+ return constants.CHANNEL;
120
+ };
121
+
122
+ /**
123
+ * Fetches the fingerprint for the app.
124
+ *
125
+ * @returns {string | null} Resolves with the fingerprint hash
126
+ */
127
+ exports.getReleaseChannel = getReleaseChannel;
128
+ const getFingerprintHash = () => {
129
+ return HotUpdaterConstants.FINGERPRINT_HASH;
130
+ };
131
+ exports.getFingerprintHash = getFingerprintHash;
132
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_NativeHotUpdater","_interopRequireDefault","e","__esModule","default","NIL_UUID","HotUpdaterConstants","exports","OVER_THE_AIR_CHANNEL","__HOT_UPDATER_CHANNEL","HOT_UPDATER_BUNDLE_ID","__HOT_UPDATER_BUNDLE_ID","FINGERPRINT_HASH","Platform","select","ios","__HOT_UPDATER_FINGERPRINT_HASH_IOS","android","__HOT_UPDATER_FINGERPRINT_HASH_ANDROID","UPDATE_STRATEGY","__HOT_UPDATER_UPDATE_STRATEGY","addListener","eventName","listener","eventEmitter","NativeEventEmitter","HotUpdaterNative","subscription","remove","updateBundle","paramsOrBundleId","fileUrl","updateBundleId","bundleId","status","currentBundleId","getBundleId","localeCompare","Error","getAppVersion","constants","getConstants","APP_VERSION","reload","requestAnimationFrame","getMinBundleId","MIN_BUNDLE_ID","getChannel","CHANNEL","getReleaseChannel","getFingerprintHash"],"sourceRoot":"../../src","sources":["native.ts"],"mappings":";;;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEkC,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAElC,MAAMG,QAAQ,GAAG,sCAAsC;AAQhD,MAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG;EACjCE,oBAAoB,EAAEC,qBAAqB;EAC3CC,qBAAqB,EAAEC,uBAAuB,IAAIN,QAAQ;EAC1DO,gBAAgB,EAAEC,qBAAQ,CAACC,MAAM,CAAC;IAChCC,GAAG,EAAEC,kCAAkC;IACvCC,OAAO,EAAEC,sCAAsC;IAC/Cd,OAAO,EAAE;EACX,CAAC,CAAC;EACFe,eAAe,EAAEC;AACnB,CAAC;AAQM,MAAMC,WAAW,GAAGA,CACzBC,SAAY,EACZC,QAA6C,KAC1C;EACH,MAAMC,YAAY,GAAG,IAAIC,+BAAkB,CAACC,yBAAgB,CAAC;EAC7D,MAAMC,YAAY,GAAGH,YAAY,CAACH,WAAW,CAACC,SAAS,EAAEC,QAAQ,CAAC;EAElE,OAAO,MAAM;IACXI,YAAY,CAACC,MAAM,CAAC,CAAC;EACvB,CAAC;AACH,CAAC;;AAMD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAFArB,OAAA,CAAAc,WAAA,GAAAA,WAAA;AAOO,eAAeQ,YAAYA,CAChCC,gBAAuC,EACvCC,OAAuB,EACL;EAClB,MAAMC,cAAc,GAClB,OAAOF,gBAAgB,KAAK,QAAQ,GAChCA,gBAAgB,GAChBA,gBAAgB,CAACG,QAA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AAA;AAMO,MAAMT,WAAW,GAAGA,CAAA,KAAc;EACvC,OAAO9B,mBAAmB,CAACI,qBAAqB,KAAKL,QAAQ,GACzDwC,cAAc,CAAC,CAAC,GAChBvC,mBAAmB,CAACI,qBAAqB;AAC/C,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAH,OAAA,CAAA6B,WAAA,GAAAA,WAAA;AAKO,MAAMW,UAAU,GAAGA,CAAA,KAAc;EACtC,IAAIzC,mBAAmB,CAACE,oBAAoB,EAAE;IAC5C,OAAOF,mBAAmB,CAACE,oBAAoB;EACjD;EACA,MAAMgC,SAAS,GAAGd,yBAAgB,CAACe,YAAY,CAAC,CAAC;EACjD,OAAOD,SAAS,CAACQ,OAAO;AAC1B,CAAC;AAACzC,OAAA,CAAAwC,UAAA,GAAAA,UAAA;AAEK,MAAME,iBAAiB,GAAGA,CAAA,KAAc;EAC7C,MAAMT,SAAS,GAAGd,yBAAgB,CAACe,YAAY,CAAC,CAAC;EACjD,OAAOD,SAAS,CAACQ,OAAO;AAC1B,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAzC,OAAA,CAAA0C,iBAAA,GAAAA,iBAAA;AAKO,MAAMC,kBAAkB,GAAGA,CAAA,KAAqB;EACrD,OAAO5C,mBAAmB,CAACM,gBAAgB;AAC7C,CAAC;AAACL,OAAA,CAAA2C,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.runUpdateProcess = void 0;
7
+ var _checkForUpdate = require("./checkForUpdate.js");
8
+ var _native = require("./native.js");
9
+ /**
10
+ * Manually checks and applies updates for the application.
11
+ *
12
+ * @param {RunUpdateProcessConfig} config - Update process configuration
13
+ * @param {string} config.source - Update server URL
14
+ * @param {Record<string, string>} [config.requestHeaders] - Request headers
15
+ * @param {boolean} [config.reloadOnForceUpdate=true] - Whether to automatically reload on force update
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * // Auto reload on force update
20
+ * const result = await HotUpdater.runUpdateProcess({
21
+ * source: "<your-update-server-url>",
22
+ * requestHeaders: {
23
+ * // Add necessary headers
24
+ * },
25
+ * reloadOnForceUpdate: true
26
+ * });
27
+ *
28
+ * // Manually handle reload on force update
29
+ * const result = await HotUpdater.runUpdateProcess({
30
+ * source: "<your-update-server-url>",
31
+ * reloadOnForceUpdate: false
32
+ * });
33
+ *
34
+ * if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
35
+ * HotUpdater.reload();
36
+ * }
37
+ * ```
38
+ *
39
+ * @returns {Promise<RunUpdateProcessResponse>} The result of the update process
40
+ */
41
+ const runUpdateProcess = async ({
42
+ reloadOnForceUpdate = true,
43
+ ...checkForUpdateOptions
44
+ }) => {
45
+ const updateInfo = await (0, _checkForUpdate.checkForUpdate)(checkForUpdateOptions);
46
+ if (!updateInfo) {
47
+ return {
48
+ status: "UP_TO_DATE",
49
+ shouldForceUpdate: false,
50
+ message: null,
51
+ id: (0, _native.getBundleId)()
52
+ };
53
+ }
54
+ const isUpdated = await updateInfo.updateBundle();
55
+ if (isUpdated && updateInfo.shouldForceUpdate && reloadOnForceUpdate) {
56
+ (0, _native.reload)();
57
+ }
58
+ if (!isUpdated) {
59
+ throw new Error("New update was found but failed to download the bundle.");
60
+ }
61
+ return {
62
+ status: updateInfo.status,
63
+ shouldForceUpdate: updateInfo.shouldForceUpdate,
64
+ id: updateInfo.id,
65
+ message: updateInfo.message
66
+ };
67
+ };
68
+ exports.runUpdateProcess = runUpdateProcess;
69
+ //# sourceMappingURL=runUpdateProcess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_checkForUpdate","require","_native","runUpdateProcess","reloadOnForceUpdate","checkForUpdateOptions","updateInfo","checkForUpdate","status","shouldForceUpdate","message","id","getBundleId","isUpdated","updateBundle","reload","Error","exports"],"sourceRoot":"../../src","sources":["runUpdateProcess.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,gBAAgB,GAAG,MAAAA,CAAO;EACrCC,mBAAmB,GAAG,IAAI;EAC1B,GAAGC;AACoB,CAAC,KAAwC;EAChE,MAAMC,UAAU,GAAG,MAAM,IAAAC,8BAAc,EAACF,qBAAqB,CAAC;EAC9D,IAAI,CAACC,UAAU,EAAE;IACf,OAAO;MACLE,MAAM,EAAE,YAAY;MACpBC,iBAAiB,EAAE,KAAK;MACxBC,OAAO,EAAE,IAAI;MACbC,EAAE,EAAE,IAAAC,mBAAW,EAAC;IAClB,CAAC;EACH;EAEA,MAAMC,SAAS,GAAG,MAAMP,UAAU,CAACQ,YAAY,CAAC,CAAC;EACjD,IAAID,SAAS,IAAIP,UAAU,CAACG,iBAAiB,IAAIL,mBAAmB,EAAE;IACpE,IAAAW,cAAM,EAAC,CAAC;EACV;EAEA,IAAI,CAACF,SAAS,EAAE;IACd,MAAM,IAAIG,KAAK,CAAC,yDAAyD,CAAC;EAC5E;EACA,OAAO;IACLR,MAAM,EAAEF,UAAU,CAACE,MAAM;IACzBC,iBAAiB,EAAEH,UAAU,CAACG,iBAAiB;IAC/CE,EAAE,EAAEL,UAAU,CAACK,EAAE;IACjBD,OAAO,EAAEJ,UAAU,CAACI;EACtB,CAAC;AACH,CAAC;AAACO,OAAA,CAAAd,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing("HotUpdater");
9
+ //# sourceMappingURL=NativeHotUpdater.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../../src","sources":["specs/NativeHotUpdater.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAsBpCC,gCAAmB,CAACC,YAAY,CAAO,YAAY,CAAC","ignoreList":[]}