@hot-updater/react-native 0.17.0 → 0.18.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 (141) hide show
  1. package/HotUpdater.podspec +7 -11
  2. package/android/{generated/java/com/hotupdater → app/build/generated/source/codegen/java/com/facebook/fbreact/specs}/NativeHotUpdaterSpec.java +3 -2
  3. package/android/app/build/generated/source/codegen/jni/HotUpdater-generated.cpp +68 -0
  4. package/android/app/build/generated/source/codegen/jni/HotUpdater.h +31 -0
  5. package/android/{generated → app/build/generated/source/codegen}/jni/HotUpdaterSpec-generated.cpp +2 -2
  6. package/android/{generated/jni/react/renderer/components/HotUpdaterSpec/HotUpdaterSpecJSI-generated.cpp → app/build/generated/source/codegen/jni/react/renderer/components/HotUpdater/HotUpdaterJSI-generated.cpp} +3 -4
  7. package/{ios/generated/HotUpdaterSpecJSI.h → android/app/build/generated/source/codegen/jni/react/renderer/components/HotUpdater/HotUpdaterJSI.h} +53 -6
  8. package/{ios/generated → android/app/build/generated/source/codegen/jni/react/renderer/components/HotUpdaterSpec}/HotUpdaterSpecJSI-generated.cpp +2 -3
  9. package/android/{generated → app/build/generated/source/codegen}/jni/react/renderer/components/HotUpdaterSpec/HotUpdaterSpecJSI.h +59 -8
  10. package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +200 -0
  11. package/android/src/main/java/com/hotupdater/FileManagerService.kt +104 -0
  12. package/android/src/main/java/com/hotupdater/HotUpdater.kt +62 -305
  13. package/android/src/main/java/com/hotupdater/HotUpdaterFactory.kt +49 -0
  14. package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +176 -0
  15. package/android/src/main/java/com/hotupdater/HttpDownloadService.kt +98 -0
  16. package/android/src/main/java/com/hotupdater/VersionedPreferencesService.kt +69 -0
  17. package/android/src/main/java/com/hotupdater/ZipFileUnzipService.kt +52 -0
  18. package/android/src/newarch/HotUpdaterModule.kt +31 -34
  19. package/android/src/oldarch/HotUpdaterModule.kt +32 -34
  20. package/android/src/oldarch/HotUpdaterSpec.kt +2 -9
  21. package/ios/HotUpdater/Internal/BundleFileStorageService.swift +593 -0
  22. package/ios/HotUpdater/Internal/FileManagerService.swift +97 -0
  23. package/ios/HotUpdater/Internal/HotUpdater-Bridging-Header.h +8 -0
  24. package/ios/HotUpdater/Internal/HotUpdater.mm +241 -0
  25. package/ios/HotUpdater/Internal/HotUpdaterFactory.swift +24 -0
  26. package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +143 -0
  27. package/ios/HotUpdater/Internal/NotificationExtension.swift +6 -0
  28. package/ios/HotUpdater/Internal/SSZipArchiveUnzipService.swift +25 -0
  29. package/ios/HotUpdater/Internal/URLSessionDownloadService.swift +101 -0
  30. package/ios/HotUpdater/Internal/VersionedPreferencesService.swift +82 -0
  31. package/ios/HotUpdater/Package.resolved +15 -0
  32. package/ios/HotUpdater/Public/HotUpdater.h +29 -0
  33. package/lib/commonjs/checkForUpdate.js +70 -0
  34. package/lib/commonjs/checkForUpdate.js.map +1 -0
  35. package/lib/commonjs/error.js +14 -0
  36. package/lib/commonjs/error.js.map +1 -0
  37. package/lib/commonjs/fetchUpdateInfo.js +74 -0
  38. package/lib/commonjs/fetchUpdateInfo.js.map +1 -0
  39. package/lib/commonjs/hooks/useEventCallback.js +17 -0
  40. package/lib/commonjs/hooks/useEventCallback.js.map +1 -0
  41. package/lib/commonjs/index.js +234 -0
  42. package/lib/commonjs/index.js.map +1 -0
  43. package/lib/commonjs/native.js +132 -0
  44. package/lib/commonjs/native.js.map +1 -0
  45. package/lib/commonjs/package.json +1 -0
  46. package/lib/commonjs/runUpdateProcess.js +69 -0
  47. package/lib/commonjs/runUpdateProcess.js.map +1 -0
  48. package/lib/commonjs/specs/NativeHotUpdater.js +9 -0
  49. package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -0
  50. package/lib/commonjs/store.js +48 -0
  51. package/lib/commonjs/store.js.map +1 -0
  52. package/lib/commonjs/wrap.js +98 -0
  53. package/lib/commonjs/wrap.js.map +1 -0
  54. package/lib/module/checkForUpdate.js +64 -0
  55. package/lib/module/checkForUpdate.js.map +1 -0
  56. package/lib/module/error.js +9 -0
  57. package/lib/module/error.js.map +1 -0
  58. package/lib/module/fetchUpdateInfo.js +69 -0
  59. package/lib/module/fetchUpdateInfo.js.map +1 -0
  60. package/lib/module/hooks/useEventCallback.js +13 -0
  61. package/lib/module/hooks/useEventCallback.js.map +1 -0
  62. package/lib/module/index.js +211 -0
  63. package/lib/module/index.js.map +1 -0
  64. package/lib/module/native.js +119 -0
  65. package/lib/module/native.js.map +1 -0
  66. package/lib/module/package.json +1 -0
  67. package/lib/module/runUpdateProcess.js +64 -0
  68. package/lib/module/runUpdateProcess.js.map +1 -0
  69. package/lib/module/specs/NativeHotUpdater.js +5 -0
  70. package/lib/module/specs/NativeHotUpdater.js.map +1 -0
  71. package/lib/module/store.js +42 -0
  72. package/lib/module/store.js.map +1 -0
  73. package/lib/module/wrap.js +94 -0
  74. package/lib/module/wrap.js.map +1 -0
  75. package/lib/typescript/commonjs/checkForUpdate.d.ts +22 -0
  76. package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -0
  77. package/{dist → lib/typescript/commonjs}/error.d.ts +1 -0
  78. package/lib/typescript/commonjs/error.d.ts.map +1 -0
  79. package/lib/typescript/commonjs/fetchUpdateInfo.d.ts +4 -0
  80. package/lib/typescript/commonjs/fetchUpdateInfo.d.ts.map +1 -0
  81. package/{dist → lib/typescript/commonjs}/hooks/useEventCallback.d.ts +1 -0
  82. package/lib/typescript/commonjs/hooks/useEventCallback.d.ts.map +1 -0
  83. package/{dist → lib/typescript/commonjs}/index.d.ts +38 -12
  84. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  85. package/lib/typescript/commonjs/native.d.ts +64 -0
  86. package/lib/typescript/commonjs/native.d.ts.map +1 -0
  87. package/lib/typescript/commonjs/package.json +1 -0
  88. package/{dist → lib/typescript/commonjs}/runUpdateProcess.d.ts +1 -0
  89. package/lib/typescript/commonjs/runUpdateProcess.d.ts.map +1 -0
  90. package/{dist → lib/typescript/commonjs}/specs/NativeHotUpdater.d.ts +8 -9
  91. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -0
  92. package/{dist → lib/typescript/commonjs}/store.d.ts +1 -0
  93. package/lib/typescript/commonjs/store.d.ts.map +1 -0
  94. package/{dist → lib/typescript/commonjs}/wrap.d.ts +3 -2
  95. package/lib/typescript/commonjs/wrap.d.ts.map +1 -0
  96. package/lib/typescript/module/checkForUpdate.d.ts +22 -0
  97. package/lib/typescript/module/checkForUpdate.d.ts.map +1 -0
  98. package/lib/typescript/module/error.d.ts +4 -0
  99. package/lib/typescript/module/error.d.ts.map +1 -0
  100. package/lib/typescript/module/fetchUpdateInfo.d.ts +4 -0
  101. package/lib/typescript/module/fetchUpdateInfo.d.ts.map +1 -0
  102. package/lib/typescript/module/hooks/useEventCallback.d.ts +5 -0
  103. package/lib/typescript/module/hooks/useEventCallback.d.ts.map +1 -0
  104. package/lib/typescript/module/index.d.ts +202 -0
  105. package/lib/typescript/module/index.d.ts.map +1 -0
  106. package/lib/typescript/module/native.d.ts +64 -0
  107. package/lib/typescript/module/native.d.ts.map +1 -0
  108. package/lib/typescript/module/package.json +1 -0
  109. package/lib/typescript/module/runUpdateProcess.d.ts +49 -0
  110. package/lib/typescript/module/runUpdateProcess.d.ts.map +1 -0
  111. package/lib/typescript/module/specs/NativeHotUpdater.d.ts +19 -0
  112. package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -0
  113. package/lib/typescript/module/store.d.ts +11 -0
  114. package/lib/typescript/module/store.d.ts.map +1 -0
  115. package/lib/typescript/module/wrap.d.ts +51 -0
  116. package/lib/typescript/module/wrap.d.ts.map +1 -0
  117. package/package.json +59 -30
  118. package/src/checkForUpdate.ts +59 -9
  119. package/src/fetchUpdateInfo.ts +40 -12
  120. package/src/index.ts +37 -11
  121. package/src/native.ts +87 -41
  122. package/src/runUpdateProcess.ts +2 -2
  123. package/src/specs/NativeHotUpdater.ts +8 -10
  124. package/src/wrap.tsx +9 -13
  125. package/android/src/main/java/com/hotupdater/HotUpdaterPrefs.kt +0 -42
  126. package/dist/checkForUpdate.d.ts +0 -12
  127. package/dist/fetchUpdateInfo.d.ts +0 -3
  128. package/dist/index.js +0 -341
  129. package/dist/index.mjs +0 -301
  130. package/dist/native.d.ts +0 -41
  131. package/ios/HotUpdater/HotUpdater.h +0 -15
  132. package/ios/HotUpdater/HotUpdater.mm +0 -468
  133. package/ios/HotUpdater/HotUpdater.modulemap +0 -6
  134. package/ios/HotUpdater/HotUpdaterPrefs.h +0 -9
  135. package/ios/HotUpdater/HotUpdaterPrefs.mm +0 -45
  136. package/ios/generated/HotUpdaterSpec/HotUpdaterSpec-generated.mm +0 -81
  137. package/ios/generated/HotUpdaterSpec/HotUpdaterSpec.h +0 -112
  138. package/react-native.config.js +0 -12
  139. package/src/global.d.ts +0 -3
  140. /package/android/{generated → app/build/generated/source/codegen}/jni/CMakeLists.txt +0 -0
  141. /package/android/{generated → app/build/generated/source/codegen}/jni/HotUpdaterSpec.h +0 -0
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useHotUpdaterStore = exports.hotUpdaterStore = void 0;
7
+ var _withSelector = _interopRequireDefault(require("use-sync-external-store/shim/with-selector"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ const {
10
+ useSyncExternalStoreWithSelector
11
+ } = _withSelector.default;
12
+ const createHotUpdaterStore = () => {
13
+ let state = {
14
+ progress: 0,
15
+ isBundleUpdated: false
16
+ };
17
+ const getSnapshot = () => {
18
+ return state;
19
+ };
20
+ const listeners = new Set();
21
+ const emitChange = () => {
22
+ for (const listener of listeners) {
23
+ listener();
24
+ }
25
+ };
26
+ const setState = newState => {
27
+ state = {
28
+ ...state,
29
+ ...newState
30
+ };
31
+ emitChange();
32
+ };
33
+ const subscribe = listener => {
34
+ listeners.add(listener);
35
+ return () => listeners.delete(listener);
36
+ };
37
+ return {
38
+ getSnapshot,
39
+ setState,
40
+ subscribe
41
+ };
42
+ };
43
+ const hotUpdaterStore = exports.hotUpdaterStore = createHotUpdaterStore();
44
+ const useHotUpdaterStore = (selector = snapshot => snapshot) => {
45
+ return useSyncExternalStoreWithSelector(hotUpdaterStore.subscribe, hotUpdaterStore.getSnapshot, hotUpdaterStore.getSnapshot, selector);
46
+ };
47
+ exports.useHotUpdaterStore = useHotUpdaterStore;
48
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_withSelector","_interopRequireDefault","require","e","__esModule","default","useSyncExternalStoreWithSelector","useSyncExternalStoreExports","createHotUpdaterStore","state","progress","isBundleUpdated","getSnapshot","listeners","Set","emitChange","listener","setState","newState","subscribe","add","delete","hotUpdaterStore","exports","useHotUpdaterStore","selector","snapshot"],"sourceRoot":"../../src","sources":["store.ts"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAqF,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAMrF,MAAM;EAAEG;AAAiC,CAAC,GAAGC,qBAA2B;AAExE,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EAClC,IAAIC,KAAsB,GAAG;IAC3BC,QAAQ,EAAE,CAAC;IACXC,eAAe,EAAE;EACnB,CAAC;EAED,MAAMC,WAAW,GAAGA,CAAA,KAAM;IACxB,OAAOH,KAAK;EACd,CAAC;EAED,MAAMI,SAAS,GAAG,IAAIC,GAAG,CAAa,CAAC;EAEvC,MAAMC,UAAU,GAAGA,CAAA,KAAM;IACvB,KAAK,MAAMC,QAAQ,IAAIH,SAAS,EAAE;MAChCG,QAAQ,CAAC,CAAC;IACZ;EACF,CAAC;EAED,MAAMC,QAAQ,GAAIC,QAAkC,IAAK;IACvDT,KAAK,GAAG;MACN,GAAGA,KAAK;MACR,GAAGS;IACL,CAAC;IACDH,UAAU,CAAC,CAAC;EACd,CAAC;EAED,MAAMI,SAAS,GAAIH,QAAoB,IAAK;IAC1CH,SAAS,CAACO,GAAG,CAACJ,QAAQ,CAAC;IACvB,OAAO,MAAMH,SAAS,CAACQ,MAAM,CAACL,QAAQ,CAAC;EACzC,CAAC;EAED,OAAO;IAAEJ,WAAW;IAAEK,QAAQ;IAAEE;EAAU,CAAC;AAC7C,CAAC;AAEM,MAAMG,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGd,qBAAqB,CAAC,CAAC;AAE/C,MAAMgB,kBAAkB,GAAGA,CAChCC,QAA0C,GAAIC,QAAQ,IAAKA,QAAa,KACrE;EACH,OAAOpB,gCAAgC,CACrCgB,eAAe,CAACH,SAAS,EACzBG,eAAe,CAACV,WAAW,EAC3BU,eAAe,CAACV,WAAW,EAC3Ba,QACF,CAAC;AACH,CAAC;AAACF,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.wrap = wrap;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _checkForUpdate = require("./checkForUpdate.js");
9
+ var _useEventCallback = require("./hooks/useEventCallback.js");
10
+ var _native = require("./native.js");
11
+ var _store = require("./store.js");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
+ function wrap(options) {
15
+ const {
16
+ reloadOnForceUpdate = true,
17
+ ...restOptions
18
+ } = options;
19
+ return WrappedComponent => {
20
+ const HotUpdaterHOC = props => {
21
+ const progress = (0, _store.useHotUpdaterStore)(state => state.progress);
22
+ const [message, setMessage] = (0, _react.useState)(null);
23
+ const [updateStatus, setUpdateStatus] = (0, _react.useState)("CHECK_FOR_UPDATE");
24
+ const initHotUpdater = (0, _useEventCallback.useEventCallback)(async () => {
25
+ try {
26
+ setUpdateStatus("CHECK_FOR_UPDATE");
27
+ const updateInfo = await (0, _checkForUpdate.checkForUpdate)({
28
+ source: restOptions.source,
29
+ requestHeaders: restOptions.requestHeaders,
30
+ onError: restOptions.onError
31
+ });
32
+ setMessage(updateInfo?.message ?? null);
33
+ if (!updateInfo) {
34
+ restOptions.onUpdateProcessCompleted?.({
35
+ status: "UP_TO_DATE",
36
+ shouldForceUpdate: false,
37
+ message: null,
38
+ id: (0, _native.getBundleId)()
39
+ });
40
+ setUpdateStatus("UPDATE_PROCESS_COMPLETED");
41
+ return;
42
+ }
43
+ if (updateInfo.shouldForceUpdate === false) {
44
+ void updateInfo.updateBundle().catch(error => {
45
+ restOptions.onError?.(error);
46
+ });
47
+ restOptions.onUpdateProcessCompleted?.({
48
+ id: updateInfo.id,
49
+ status: updateInfo.status,
50
+ shouldForceUpdate: updateInfo.shouldForceUpdate,
51
+ message: updateInfo.message
52
+ });
53
+ setUpdateStatus("UPDATE_PROCESS_COMPLETED");
54
+ return;
55
+ }
56
+ // Force Update Scenario
57
+ setUpdateStatus("UPDATING");
58
+ const isSuccess = await updateInfo.updateBundle();
59
+ if (!isSuccess) {
60
+ throw new Error("New update was found but failed to download the bundle.");
61
+ }
62
+ if (reloadOnForceUpdate) {
63
+ (0, _native.reload)();
64
+ }
65
+ restOptions.onUpdateProcessCompleted?.({
66
+ id: updateInfo.id,
67
+ status: updateInfo.status,
68
+ shouldForceUpdate: updateInfo.shouldForceUpdate,
69
+ message: updateInfo.message
70
+ });
71
+ setUpdateStatus("UPDATE_PROCESS_COMPLETED");
72
+ } catch (error) {
73
+ restOptions.onError?.(error);
74
+ setUpdateStatus("UPDATE_PROCESS_COMPLETED");
75
+ }
76
+ });
77
+ (0, _react.useEffect)(() => {
78
+ restOptions.onProgress?.(progress);
79
+ }, [progress]);
80
+ (0, _react.useLayoutEffect)(() => {
81
+ initHotUpdater();
82
+ }, []);
83
+ if (restOptions.fallbackComponent && updateStatus !== "UPDATE_PROCESS_COMPLETED") {
84
+ const Fallback = restOptions.fallbackComponent;
85
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Fallback, {
86
+ progress: progress,
87
+ status: updateStatus,
88
+ message: message
89
+ });
90
+ }
91
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, {
92
+ ...props
93
+ });
94
+ };
95
+ return HotUpdaterHOC;
96
+ };
97
+ }
98
+ //# sourceMappingURL=wrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_checkForUpdate","_useEventCallback","_native","_store","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","wrap","options","reloadOnForceUpdate","restOptions","WrappedComponent","HotUpdaterHOC","props","progress","useHotUpdaterStore","state","message","setMessage","useState","updateStatus","setUpdateStatus","initHotUpdater","useEventCallback","updateInfo","checkForUpdate","source","requestHeaders","onError","onUpdateProcessCompleted","status","shouldForceUpdate","id","getBundleId","updateBundle","catch","error","isSuccess","Error","reload","useEffect","onProgress","useLayoutEffect","fallbackComponent","Fallback","jsx"],"sourceRoot":"../../src","sources":["wrap.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,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EAAClC,gBAAgB;QAAA,GAAKE;MAAK,CAAG,CAAC;IACxC,CAAC;IAED,OAAOD,aAAa;EACtB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ import { Platform } from "react-native";
4
+ import { HotUpdaterError } from "./error.js";
5
+ import { fetchUpdateInfo } from "./fetchUpdateInfo.js";
6
+ import { HotUpdaterConstants, getAppVersion, getBundleId, getChannel, getMinBundleId, updateBundle } from "./native.js";
7
+ export async function checkForUpdate(options) {
8
+ if (__DEV__) {
9
+ return null;
10
+ }
11
+ if (!["ios", "android"].includes(Platform.OS)) {
12
+ options.onError?.(new HotUpdaterError("HotUpdater is only supported on iOS and Android"));
13
+ return null;
14
+ }
15
+ const currentAppVersion = getAppVersion();
16
+ const platform = Platform.OS;
17
+ const currentBundleId = getBundleId();
18
+ const minBundleId = getMinBundleId();
19
+ const channel = getChannel();
20
+ if (!currentAppVersion) {
21
+ options.onError?.(new HotUpdaterError("Failed to get app version"));
22
+ return null;
23
+ }
24
+ const baseArgs = {
25
+ bundleId: currentBundleId,
26
+ platform,
27
+ minBundleId,
28
+ channel: channel ?? undefined
29
+ };
30
+ return fetchUpdateInfo(options.source, HotUpdaterConstants.UPDATE_STRATEGY === "appVersion" ? {
31
+ _updateStrategy: HotUpdaterConstants.UPDATE_STRATEGY,
32
+ appVersion: currentAppVersion,
33
+ ...baseArgs
34
+ } : {
35
+ _updateStrategy: HotUpdaterConstants.UPDATE_STRATEGY,
36
+ fingerprintHash: HotUpdaterConstants.FINGERPRINT_HASH,
37
+ ...baseArgs
38
+ }, options.requestHeaders, options.onError, options.requestTimeout).then(updateInfo => {
39
+ if (!updateInfo) {
40
+ return null;
41
+ }
42
+ return {
43
+ ...updateInfo,
44
+ updateBundle: async () => {
45
+ return updateBundle({
46
+ bundleId: updateInfo.id,
47
+ fileUrl: updateInfo.fileUrl,
48
+ status: updateInfo.status
49
+ });
50
+ }
51
+ };
52
+ });
53
+ }
54
+ export const getUpdateSource = baseUrl => args => {
55
+ switch (args._updateStrategy) {
56
+ case "appVersion":
57
+ return `${baseUrl}/app-version/${args.platform}/${args.appVersion}/${args.channel}/${args.minBundleId}/${args.bundleId}`;
58
+ case "fingerprint":
59
+ return `${baseUrl}/fingerprint/${args.platform}/${args.fingerprintHash}/${args.channel}/${args.minBundleId}/${args.bundleId}`;
60
+ default:
61
+ return baseUrl;
62
+ }
63
+ };
64
+ //# sourceMappingURL=checkForUpdate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","HotUpdaterError","fetchUpdateInfo","HotUpdaterConstants","getAppVersion","getBundleId","getChannel","getMinBundleId","updateBundle","checkForUpdate","options","__DEV__","includes","OS","onError","currentAppVersion","platform","currentBundleId","minBundleId","channel","baseArgs","bundleId","undefined","source","UPDATE_STRATEGY","_updateStrategy","appVersion","fingerprintHash","FINGERPRINT_HASH","requestHeaders","requestTimeout","then","updateInfo","id","fileUrl","status","getUpdateSource","baseUrl","args"],"sourceRoot":"../../src","sources":["checkForUpdate.ts"],"mappings":";;AACA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,eAAe,QAAQ,YAAS;AACzC,SAA4BC,eAAe,QAAQ,sBAAmB;AACtE,SACEC,mBAAmB,EACnBC,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,cAAc,EACdC,YAAY,QACP,aAAU;AAqBjB,OAAO,eAAeC,cAAcA,CAClCC,OAA8B,EACQ;EACtC,IAAIC,OAAO,EAAE;IACX,OAAO,IAAI;EACb;EAEA,IAAI,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,CAACC,QAAQ,CAACZ,QAAQ,CAACa,EAAE,CAAC,EAAE;IAC7CH,OAAO,CAACI,OAAO,GACb,IAAIb,eAAe,CAAC,iDAAiD,CACvE,CAAC;IACD,OAAO,IAAI;EACb;EAEA,MAAMc,iBAAiB,GAAGX,aAAa,CAAC,CAAC;EACzC,MAAMY,QAAQ,GAAGhB,QAAQ,CAACa,EAAuB;EAC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ACf,OAAO,GAAGY,OAAO,gBAAgBC,IAAI,CAACtB,QAAQ,IAAIsB,IAAI,CAACZ,UAAU,IAAIY,IAAI,CAACnB,OAAO,IAAImB,IAAI,CAACpB,WAAW,IAAIoB,IAAI,CAACjB,QAAQ,EAAE;IAC1H,KAAK,aAAa;MAChB,OAAO,GAAGgB,OAAO,gBAAgBC,IAAI,CAACtB,QAAQ,IAAIsB,IAAI,CAACX,eAAe,IAAIW,IAAI,CAACnB,OAAO,IAAImB,IAAI,CAACpB,WAAW,IAAIoB,IAAI,CAACjB,QAAQ,EAAE;IAC/H;MACE,OAAOgB,OAAO;EAClB;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ export class HotUpdaterError extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = "HotUpdaterError";
7
+ }
8
+ }
9
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["HotUpdaterError","Error","constructor","message","name"],"sourceRoot":"../../src","sources":["error.ts"],"mappings":";;AAAA,OAAO,MAAMA,eAAe,SAASC,KAAK,CAAC;EACzCC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,iBAAiB;EAC/B;AACF","ignoreList":[]}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ export const fetchUpdateInfo = async (source, args, requestHeaders, onError, requestTimeout = 5000) => {
4
+ if (typeof source === "function") {
5
+ const url = source(args);
6
+ if (typeof url !== "string") {
7
+ return null;
8
+ }
9
+ source = url;
10
+ }
11
+ const controller = new AbortController();
12
+ const timeoutId = setTimeout(() => {
13
+ controller.abort();
14
+ }, requestTimeout);
15
+ try {
16
+ let headers = {};
17
+ switch (args._updateStrategy) {
18
+ case "fingerprint":
19
+ headers = {
20
+ "Content-Type": "application/json",
21
+ "x-app-platform": args.platform,
22
+ "x-bundle-id": args.bundleId,
23
+ "x-fingerprint-hash": args.fingerprintHash,
24
+ ...(args.minBundleId ? {
25
+ "x-min-bundle-id": args.minBundleId
26
+ } : {}),
27
+ ...(args.channel ? {
28
+ "x-channel": args.channel
29
+ } : {}),
30
+ ...requestHeaders
31
+ };
32
+ break;
33
+ case "appVersion":
34
+ headers = {
35
+ "Content-Type": "application/json",
36
+ "x-app-platform": args.platform,
37
+ "x-bundle-id": args.bundleId,
38
+ "x-app-version": args.appVersion,
39
+ ...(args.minBundleId ? {
40
+ "x-min-bundle-id": args.minBundleId
41
+ } : {}),
42
+ ...(args.channel ? {
43
+ "x-channel": args.channel
44
+ } : {}),
45
+ ...requestHeaders
46
+ };
47
+ break;
48
+ default:
49
+ throw new Error("Invalid update strategy");
50
+ }
51
+ const response = await fetch(source, {
52
+ signal: controller.signal,
53
+ headers
54
+ });
55
+ clearTimeout(timeoutId);
56
+ if (response.status !== 200) {
57
+ throw new Error(response.statusText);
58
+ }
59
+ return response.json();
60
+ } catch (error) {
61
+ if (error.name === "AbortError") {
62
+ onError?.(new Error("Request timed out"));
63
+ return null;
64
+ }
65
+ onError?.(error);
66
+ return null;
67
+ }
68
+ };
69
+ //# 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"],"sourceRoot":"../../src","sources":["fetchUpdateInfo.ts"],"mappings":";;AAOA,OAAO,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,Q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A,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAACrB,MAAM,EAAE;MACnCsB,MAAM,EAAEhB,UAAU,CAACgB,MAAM;MACzBX;IACF,CAAC,CAAC;IAEFY,YAAY,CAACf,SAAS,CAAC;IAEvB,IAAIY,QAAQ,CAACI,MAAM,KAAK,GAAG,EAAE;MAC3B,MAAM,IAAIL,KAAK,CAACC,QAAQ,CAACK,UAAU,CAAC;IACtC;IACA,OAAOL,QAAQ,CAACM,IAAI,CAAC,CAAC;EACxB,CAAC,CAAC,OAAOC,KAAU,EAAE;IACnB,IAAIA,KAAK,CAACC,IAAI,KAAK,YAAY,EAAE;MAC/BzB,OAAO,GAAG,IAAIgB,KAAK,CAAC,mBAAmB,CAAC,CAAC;MACzC,OAAO,IAAI;IACb;IACAhB,OAAO,GAAGwB,KAAc,CAAC;IACzB,OAAO,IAAI;EACb;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ import { useCallback, useLayoutEffect, useRef } from "react";
4
+ export function useEventCallback(fn) {
5
+ const callbackRef = useRef(() => {
6
+ throw new Error("Cannot call an event handler while rendering.");
7
+ });
8
+ useLayoutEffect(() => {
9
+ callbackRef.current = fn;
10
+ }, [fn]);
11
+ return useCallback((...args) => callbackRef.current?.(...args), [callbackRef]);
12
+ }
13
+ //# sourceMappingURL=useEventCallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useLayoutEffect","useRef","useEventCallback","fn","callbackRef","Error","current","args"],"sourceRoot":"../../../src","sources":["hooks/useEventCallback.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,eAAe,EAAEC,MAAM,QAAQ,OAAO;AAY5D,OAAO,SAASC,gBAAgBA,CAC9BC,EAA0B,EACF;EACxB,MAAMC,WAAW,GAAGH,MAAM,CAAyB,MAAM;IACvD,MAAM,IAAII,KAAK,CAAC,+CAA+C,CAAC;EAClE,CAAC,CAAC;EAEFL,eAAe,CAAC,MAAM;IACpBI,WAAW,CAACE,OAAO,GAAGH,EAAE;EAC1B,CAAC,EAAE,CAACA,EAAE,CAAC,CAAC;EAER,OAAOJ,WAAW,CAChB,CAAC,GAAGQ,IAAU,KAAKH,WAAW,CAACE,OAAO,GAAG,GAAGC,IAAI,CAAC,EACjD,CAACH,WAAW,CACd,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+
3
+ import { checkForUpdate } from "./checkForUpdate.js";
4
+ import { addListener, getAppVersion, getBundleId, getChannel, getFingerprintHash, getMinBundleId, getReleaseChannel, reload, updateBundle } from "./native.js";
5
+ import { runUpdateProcess } from "./runUpdateProcess.js";
6
+ import { hotUpdaterStore } from "./store.js";
7
+ import { wrap } from "./wrap.js";
8
+ export * from "./store.js";
9
+ addListener("onProgress", ({
10
+ progress
11
+ }) => {
12
+ hotUpdaterStore.setState({
13
+ progress
14
+ });
15
+ });
16
+ export const HotUpdater = {
17
+ /**
18
+ * `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.
19
+ *
20
+ * @param {object} options - Configuration options
21
+ * @param {string} options.source - Update server URL
22
+ * @param {object} [options.requestHeaders] - Request headers
23
+ * @param {React.ComponentType} [options.fallbackComponent] - Component to display during updates
24
+ * @param {boolean} [options.reloadOnForceUpdate=true] - Whether to automatically reload the app on force updates
25
+ * @param {Function} [options.onUpdateProcessCompleted] - Callback after update process completes
26
+ * @param {Function} [options.onProgress] - Callback to track bundle download progress
27
+ * @returns {Function} Higher-order component that wraps the app component
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * export default HotUpdater.wrap({
32
+ * source: "<your-update-server-url>",
33
+ * requestHeaders: {
34
+ * "Authorization": "Bearer <your-access-token>",
35
+ * },
36
+ * })(App);
37
+ * ```
38
+ */
39
+ wrap,
40
+ /**
41
+ * Reloads the app.
42
+ */
43
+ reload,
44
+ /**
45
+ * Fetches the current app version.
46
+ */
47
+ getAppVersion,
48
+ /**
49
+ * Fetches the current bundle ID of the app.
50
+ */
51
+ getBundleId,
52
+ /**
53
+ * Retrieves the initial bundle ID based on the build time of the native app.
54
+ */
55
+ getMinBundleId,
56
+ /**
57
+ * Fetches the current channel of the app.
58
+ *
59
+ * If no channel is specified, the app is assigned to the 'production' channel.
60
+ *
61
+ * @returns {string} The current release channel of the app
62
+ * @default "production"
63
+ * @example
64
+ * ```ts
65
+ * const channel = HotUpdater.getChannel();
66
+ * console.log(`Current channel: ${channel}`);
67
+ * ```
68
+ */
69
+ getChannel,
70
+ /**
71
+ * The initial channel of the native app.
72
+ *
73
+ * @returns {string} The current release channel of the app
74
+ * @default "production"
75
+ * @example
76
+ * ```ts
77
+ * const channel = HotUpdater.getReleaseChannel();
78
+ * console.log(`Current release channel: ${channel}`);
79
+ * ```
80
+ */
81
+ getReleaseChannel,
82
+ /**
83
+ * Adds a listener to HotUpdater events.
84
+ *
85
+ * @param {keyof HotUpdaterEvent} eventName - The name of the event to listen for
86
+ * @param {(event: HotUpdaterEvent[T]) => void} listener - The callback function to handle the event
87
+ * @returns {() => void} A cleanup function that removes the event listener
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const unsubscribe = HotUpdater.addListener("onProgress", ({ progress }) => {
92
+ * console.log(`Update progress: ${progress * 100}%`);
93
+ * });
94
+ *
95
+ * // Unsubscribe when no longer needed
96
+ * unsubscribe();
97
+ * ```
98
+ */
99
+ addListener,
100
+ /**
101
+ * Manually checks for updates.
102
+ *
103
+ * @param {Object} config - Update check configuration
104
+ * @param {string} config.source - Update server URL
105
+ * @param {Record<string, string>} [config.requestHeaders] - Request headers
106
+ *
107
+ * @returns {Promise<UpdateInfo | null>} Update information or null if up to date
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * const updateInfo = await HotUpdater.checkForUpdate({
112
+ * source: "<your-update-server-url>",
113
+ * requestHeaders: {
114
+ * Authorization: "Bearer <your-access-token>",
115
+ * },
116
+ * });
117
+ *
118
+ * if (!updateInfo) {
119
+ * console.log("App is up to date");
120
+ * return;
121
+ * }
122
+ *
123
+ * await HotUpdater.updateBundle(updateInfo.id, updateInfo.fileUrl);
124
+ * if (updateInfo.shouldForceUpdate) {
125
+ * HotUpdater.reload();
126
+ * }
127
+ * ```
128
+ */
129
+ checkForUpdate,
130
+ /**
131
+ * Manually checks and applies updates for the application.
132
+ *
133
+ * @param {RunUpdateProcessConfig} config - Update process configuration
134
+ * @param {string} config.source - Update server URL
135
+ * @param {Record<string, string>} [config.requestHeaders] - Request headers
136
+ * @param {boolean} [config.reloadOnForceUpdate=false] - Whether to automatically reload on force update
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * // Auto reload on force update
141
+ * const result = await HotUpdater.runUpdateProcess({
142
+ * source: "<your-update-server-url>",
143
+ * requestHeaders: {
144
+ * // Add necessary headers
145
+ * },
146
+ * reloadOnForceUpdate: true
147
+ * });
148
+ *
149
+ * // Manually handle reload on force update
150
+ * const result = await HotUpdater.runUpdateProcess({
151
+ * source: "<your-update-server-url>",
152
+ * reloadOnForceUpdate: false
153
+ * });
154
+ *
155
+ * if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
156
+ * HotUpdater.reload();
157
+ * }
158
+ * ```
159
+ *
160
+ * @returns {Promise<RunUpdateProcessResponse>} The result of the update process
161
+ */
162
+ runUpdateProcess,
163
+ /**
164
+ * Updates the bundle of the app.
165
+ *
166
+ * @param {UpdateBundleParams} params - Parameters object required for bundle update
167
+ * @param {string} params.bundleId - The bundle ID of the app
168
+ * @param {string|null} params.fileUrl - The URL of the zip file
169
+ *
170
+ * @returns {Promise<boolean>} Whether the update was successful
171
+ *
172
+ * @example
173
+ * ```ts
174
+ * const updateInfo = await HotUpdater.checkForUpdate({
175
+ * source: "<your-update-server-url>",
176
+ * requestHeaders: {
177
+ * Authorization: "Bearer <your-access-token>",
178
+ * },
179
+ * });
180
+ *
181
+ * if (!updateInfo) {
182
+ * return {
183
+ * status: "UP_TO_DATE",
184
+ * };
185
+ * }
186
+ *
187
+ * await HotUpdater.updateBundle({
188
+ * bundleId: updateInfo.id,
189
+ * fileUrl: updateInfo.fileUrl
190
+ * });
191
+ * if (updateInfo.shouldForceUpdate) {
192
+ * HotUpdater.reload();
193
+ * }
194
+ * ```
195
+ */
196
+ updateBundle,
197
+ /**
198
+ * Fetches the fingerprint of the app.
199
+ *
200
+ * @returns {string} The fingerprint of the app
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * const fingerprint = HotUpdater.getFingerprintHash();
205
+ * console.log(`Fingerprint: ${fingerprint}`);
206
+ * ```
207
+ */
208
+ getFingerprintHash
209
+ };
210
+ export { getUpdateSource } from "./checkForUpdate.js";
211
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["checkForUpdate","addListener","getAppVersion","getBundleId","getChannel","getFingerprintHash","getMinBundleId","getReleaseChannel","reload","updateBundle","runUpdateProcess","hotUpdaterStore","wrap","progress","setState","HotUpdater","getUpdateSource"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,cAAc,QAAQ,qBAAkB;AACjD,SACEC,WAAW,EACXC,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,kBAAkB,EAClBC,cAAc,EACdC,iBAAiB,EACjBC,MAAM,EACNC,YAAY,QACP,aAAU;AACjB,SAASC,gBAAgB,QAAQ,uBAAoB;AACrD,SAASC,eAAe,QAAQ,YAAS;AACzC,SAASC,IAAI,QAAQ,WAAQ;AAK7B,cAAc,YAAS;AAEvBX,WAAW,CAAC,YAAY,EAAE,CAAC;EAAEY;AAAS,CAAC,KAAK;EAC1CF,eAAe,CAACG,QAAQ,CAAC;IACvBD;EACF,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,MAAME,UAAU,GAAG;EACxB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEH,IAAI;EACJ;AACF;AACA;EACEJ,MAAM;EACN;AACF;AACA;EACEN,aAAa;EACb;AACF;AACA;EACEC,WAAW;EACX;AACF;AACA;EACEG,cAAc;EACd;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEF,UAAU;EACV;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEG,iBAAiB;EACjB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEN,WAAW;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;EACED,cAAc;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;EACEU,gBAAgB;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;EACED,YAAY;EACZ;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEJ;AACF,CAAC;AAED,SAASW,eAAe,QAAQ,qBAAkB","ignoreList":[]}