@take-out/native-hot-update 0.2.10 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,8 +1,4 @@
1
1
  import { HotUpdater, useHotUpdaterStore } from "@hot-updater/react-native";
2
- import { createHotUpdater } from "./createHotUpdater";
3
- export {
4
- HotUpdater,
5
- createHotUpdater,
6
- useHotUpdaterStore
7
- };
2
+ import { createHotUpdater } from "./createHotUpdater.mjs";
3
+ export { HotUpdater, createHotUpdater, useHotUpdaterStore };
8
4
  //# sourceMappingURL=index.js.map
@@ -1,6 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "mappings": "AACA,SAAS,YAAY,0BAA0B;AAG/C,SAAS,wBAAwB;",
5
- "names": []
6
- }
1
+ {"version":3,"names":["HotUpdater","useHotUpdaterStore","createHotUpdater"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,UAAA,EAAYC,kBAAA,QAA0B;AAG/C,SAASC,gBAAA,QAAwB","ignoreList":[]}
package/package.json CHANGED
@@ -1,15 +1,21 @@
1
1
  {
2
2
  "name": "@take-out/native-hot-update",
3
- "version": "0.2.10",
4
- "type": "module",
5
- "sideEffects": false,
6
- "source": "src/index.ts",
3
+ "version": "0.3.0",
7
4
  "main": "dist/cjs",
8
5
  "module": "dist/esm",
9
- "publishConfig": {
10
- "access": "public"
6
+ "devDependencies": {
7
+ "@tamagui/build": "2.0.0-rc.36",
8
+ "@types/react": "^18.3.18",
9
+ "react": "*",
10
+ "react-native": "*",
11
+ "react-native-mmkv": "^3.1.0",
12
+ "typescript": "^5.7.3"
13
+ },
14
+ "peerDependencies": {
15
+ "expo-application": "*",
16
+ "react": "*",
17
+ "react-native": "*"
11
18
  },
12
- "types": "./types/index.d.ts",
13
19
  "exports": {
14
20
  "./package.json": "./package.json",
15
21
  ".": {
@@ -31,6 +37,14 @@
31
37
  "dist",
32
38
  "src"
33
39
  ],
40
+ "peerDependenciesMeta": {
41
+ "react-native-mmkv": {
42
+ "optional": true
43
+ }
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
34
48
  "scripts": {
35
49
  "build": "tamagui-build --skip-types",
36
50
  "watch": "tamagui-build --skip-types --watch",
@@ -39,25 +53,8 @@
39
53
  "lint": "oxlint src",
40
54
  "check": "tsc --noEmit"
41
55
  },
42
- "dependencies": {
43
- "@hot-updater/react-native": "0.25.6"
44
- },
45
- "peerDependencies": {
46
- "expo-application": "*",
47
- "react": "*",
48
- "react-native": "*"
49
- },
50
- "peerDependenciesMeta": {
51
- "react-native-mmkv": {
52
- "optional": true
53
- }
54
- },
55
- "devDependencies": {
56
- "@tamagui/build": "2.0.0-rc.15",
57
- "@types/react": "^18.3.18",
58
- "react": "*",
59
- "react-native": "*",
60
- "react-native-mmkv": "^3.1.0",
61
- "typescript": "^5.7.3"
62
- }
56
+ "sideEffects": false,
57
+ "source": "src/index.ts",
58
+ "type": "module",
59
+ "types": "./types/index.d.ts"
63
60
  }
@@ -40,7 +40,7 @@ export function createHotUpdater(config: HotUpdaterConfig): HotUpdaterInstance {
40
40
 
41
41
  const handleUpdateDownloaded = (
42
42
  id: string,
43
- options: { isPreRelease?: boolean } = {}
43
+ options: { isPreRelease?: boolean } = {},
44
44
  ) => {
45
45
  const appVersion = Application.nativeApplicationVersion
46
46
  if (appVersion) {
@@ -65,7 +65,7 @@ export function createHotUpdater(config: HotUpdaterConfig): HotUpdaterInstance {
65
65
  enabled?: boolean
66
66
  onUpdateDownloaded?: (info: UpdateInfo) => void
67
67
  onError?: (error: unknown) => void
68
- } = {}
68
+ } = {},
69
69
  ) => {
70
70
  const {
71
71
  enabled = true,
@@ -139,7 +139,7 @@ export function createHotUpdater(config: HotUpdaterConfig): HotUpdaterInstance {
139
139
  ) {
140
140
  Alert.alert(
141
141
  'Update Skipped',
142
- 'Skipped rollback because you are using a newer pre-release bundle.'
142
+ 'Skipped rollback because you are using a newer pre-release bundle.',
143
143
  )
144
144
  setIsUserClearedForAccess(true)
145
145
  return
@@ -176,7 +176,7 @@ export function createHotUpdater(config: HotUpdaterConfig): HotUpdaterInstance {
176
176
  [
177
177
  { text: 'Later', style: 'cancel' },
178
178
  { text: 'Reload Now', onPress: () => HotUpdater.reload() },
179
- ]
179
+ ],
180
180
  )
181
181
  }
182
182
  } catch (error) {
@@ -205,7 +205,7 @@ export function createHotUpdater(config: HotUpdaterConfig): HotUpdaterInstance {
205
205
  * Manually check for updates (for debug/testing).
206
206
  */
207
207
  const checkForUpdate = async (
208
- options: { channel?: string; isPreRelease?: boolean } = {}
208
+ options: { channel?: string; isPreRelease?: boolean } = {},
209
209
  ) => {
210
210
  const { channel, isPreRelease = false } = options
211
211
 
@@ -1,151 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var createHotUpdater_exports = {};
24
- __export(createHotUpdater_exports, {
25
- createHotUpdater: () => createHotUpdater
26
- });
27
- module.exports = __toCommonJS(createHotUpdater_exports);
28
- var import_react_native = require("@hot-updater/react-native"), Application = __toESM(require("expo-application"), 1), import_react = require("react"), import_react_native2 = require("react-native-web");
29
- const INITIAL_OTA_ID = "00000000-0000-0000-0000-000000000000", BUNDLE_ID_KEY_PREFIX = "hotUpdater.bundleId", PRE_RELEASE_BUNDLE_ID_KEY = "hotUpdater.preReleaseBundleId";
30
- function createHotUpdater(config) {
31
- const { storage, updateStrategy = "appVersion" } = config;
32
- let isUpdatePending = !1;
33
- const getAppliedOta = () => {
34
- const id = import_react_native.HotUpdater.getBundleId();
35
- return id === INITIAL_OTA_ID || id === import_react_native.HotUpdater.getMinBundleId() ? null : id;
36
- }, getShortOtaId = () => {
37
- const fullId = getAppliedOta();
38
- return fullId ? fullId.slice(-12) : null;
39
- }, getIsUpdatePending = () => isUpdatePending, getPreReleaseBundleId = () => storage.get(PRE_RELEASE_BUNDLE_ID_KEY), handleUpdateDownloaded = (id, options = {}) => {
40
- const appVersion = Application.nativeApplicationVersion;
41
- appVersion && storage.set(`${BUNDLE_ID_KEY_PREFIX}.${appVersion}`, id), options.isPreRelease ? storage.set(PRE_RELEASE_BUNDLE_ID_KEY, id) : storage.delete(PRE_RELEASE_BUNDLE_ID_KEY), isUpdatePending = !0;
42
- };
43
- return {
44
- useOtaUpdater: (options = {}) => {
45
- const {
46
- enabled = !0,
47
- onUpdateDownloaded: onUpdateDownloadedCallback,
48
- onError
49
- } = options, progress = (0, import_react_native.useHotUpdaterStore)((state) => state.progress), isUpdating = progress > 0.01, [isUserClearedForAccess, setIsUserClearedForAccess] = (0, import_react.useState)(!1), isUserClearedForAccessRef = (0, import_react.useRef)(isUserClearedForAccess);
50
- return isUserClearedForAccessRef.current = isUserClearedForAccess, (0, import_react.useEffect)(() => {
51
- if (!isUpdating) {
52
- const timer = setTimeout(() => {
53
- isUserClearedForAccessRef.current || setIsUserClearedForAccess(!0);
54
- }, 5e3);
55
- return () => clearTimeout(timer);
56
- }
57
- }, [isUpdating]), (0, import_react.useEffect)(() => {
58
- const timer = setTimeout(() => {
59
- isUserClearedForAccessRef.current || setIsUserClearedForAccess(!0);
60
- }, 2e4);
61
- return () => clearTimeout(timer);
62
- }, []), (0, import_react.useEffect)(() => {
63
- let shouldContinue = !0;
64
- return (async () => {
65
- try {
66
- if (!enabled) {
67
- setIsUserClearedForAccess(!0);
68
- return;
69
- }
70
- if (!shouldContinue) return;
71
- const updateInfo = await import_react_native.HotUpdater.checkForUpdate({
72
- updateStrategy
73
- });
74
- if (!updateInfo) {
75
- setIsUserClearedForAccess(!0);
76
- return;
77
- }
78
- if (!shouldContinue) return;
79
- if (updateInfo.status === "ROLLBACK") {
80
- const preReleaseBundleId = getPreReleaseBundleId(), currentBundleId = import_react_native.HotUpdater.getBundleId();
81
- if (preReleaseBundleId && preReleaseBundleId === currentBundleId && currentBundleId > updateInfo.id) {
82
- import_react_native2.Alert.alert(
83
- "Update Skipped",
84
- "Skipped rollback because you are using a newer pre-release bundle."
85
- ), setIsUserClearedForAccess(!0);
86
- return;
87
- }
88
- }
89
- if (updateInfo.shouldForceUpdate || setIsUserClearedForAccess(!0), !shouldContinue) return;
90
- await updateInfo.updateBundle(), handleUpdateDownloaded(updateInfo.id);
91
- const info = {
92
- id: updateInfo.id,
93
- isCriticalUpdate: updateInfo.shouldForceUpdate,
94
- fileUrl: updateInfo.fileUrl,
95
- message: updateInfo.message
96
- };
97
- if (onUpdateDownloadedCallback?.(info), !shouldContinue) return;
98
- if (updateInfo.shouldForceUpdate) {
99
- if (!isUserClearedForAccessRef.current) {
100
- import_react_native.HotUpdater.reload();
101
- return;
102
- }
103
- import_react_native2.Alert.alert(
104
- "Update Downloaded",
105
- "An important update has been downloaded. Reload now to apply it?",
106
- [
107
- { text: "Later", style: "cancel" },
108
- { text: "Reload Now", onPress: () => import_react_native.HotUpdater.reload() }
109
- ]
110
- );
111
- }
112
- } catch (error) {
113
- onError?.(error), setIsUserClearedForAccess(!0);
114
- } finally {
115
- isUserClearedForAccessRef.current || setIsUserClearedForAccess(!0);
116
- }
117
- })(), () => {
118
- shouldContinue = !1;
119
- };
120
- }, [enabled, onUpdateDownloadedCallback, onError]), {
121
- userClearedForAccess: isUserClearedForAccess,
122
- progress,
123
- isUpdatePending: getIsUpdatePending()
124
- };
125
- },
126
- checkForUpdate: async (options = {}) => {
127
- const { channel, isPreRelease = !1 } = options, requestHeaders = {};
128
- channel && (requestHeaders["X-Channel"] = channel);
129
- const updateInfo = await import_react_native.HotUpdater.checkForUpdate({
130
- updateStrategy,
131
- ...Object.keys(requestHeaders).length > 0 && { requestHeaders }
132
- });
133
- return updateInfo ? (await updateInfo.updateBundle(), handleUpdateDownloaded(updateInfo.id, { isPreRelease }), {
134
- id: updateInfo.id,
135
- isCriticalUpdate: updateInfo.shouldForceUpdate,
136
- fileUrl: updateInfo.fileUrl,
137
- message: updateInfo.message
138
- }) : null;
139
- },
140
- getAppliedOta,
141
- getShortOtaId,
142
- getIsUpdatePending,
143
- reload: () => import_react_native.HotUpdater.reload(),
144
- getBundleId: () => import_react_native.HotUpdater.getBundleId(),
145
- getMinBundleId: () => import_react_native.HotUpdater.getMinBundleId(),
146
- getChannel: () => import_react_native.HotUpdater.getChannel(),
147
- clearCrashHistory: () => import_react_native.HotUpdater.clearCrashHistory(),
148
- getCrashHistory: () => import_react_native.HotUpdater.getCrashHistory()
149
- };
150
- }
151
- //# sourceMappingURL=createHotUpdater.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/createHotUpdater.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA+C,sCAC/C,cAA6B,yCAC7B,eAA4C,kBAC5CA,uBAAsB;AAItB,MAAM,iBAAiB,wCACjB,uBAAuB,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ACF;AAAA,YACF;AAAA,UACF,SAAS,OAAO;AACd,sBAAU,KAAK,GACf,0BAA0B,EAAI;AAAA,UAChC,UAAE;AACA,YAAK,0BAA0B,WAC7B,0BAA0B,EAAI;AAAA,UAElC;AAAA,QACF,GAAG,GAEI,MAAM;AACX,2BAAiB;AAAA,QACnB;AAAA,MACF,GAAG,CAAC,SAAS,4BAA4B,OAAO,CAAC,GAE1C;AAAA,QACL,sBAAsB;AAAA,QACtB;AAAA,QACA,iBAAiB,mBAAmB;AAAA,MACtC;AAAA,IACF;AAAA,IAqCE,gBAhCqB,OACrB,UAAwD,CAAC,MACtD;AACH,YAAM,EAAE,SAAS,eAAe,GAAM,IAAI,SAEpC,iBAAyC,CAAC;AAChD,MAAI,YACF,eAAe,WAAW,IAAI;AAGhC,YAAM,aAAa,MAAM,+BAAW,eAAe;AAAA,QACjD;AAAA,QACA,GAAI,OAAO,KAAK,cAAc,EAAE,SAAS,KAAK,EAAE,eAAe;AAAA,MACjE,CAAC;AAED,aAAI,cACF,MAAM,WAAW,aAAa,GAC9B,uBAAuB,WAAW,IAAI,EAAE,aAAa,CAAC,GAE/C;AAAA,QACL,IAAI,WAAW;AAAA,QACf,kBAAkB,WAAW;AAAA,QAC7B,SAAS,WAAW;AAAA,QACpB,SAAS,WAAW;AAAA,MACtB,KAGK;AAAA,IACT;AAAA,IAKE;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,MAAM,+BAAW,OAAO;AAAA,IAChC,aAAa,MAAM,+BAAW,YAAY;AAAA,IAC1C,gBAAgB,MAAM,+BAAW,eAAe;AAAA,IAChD,YAAY,MAAM,+BAAW,WAAW;AAAA,IACxC,mBAAmB,MAAM,+BAAW,kBAAkB;AAAA,IACtD,iBAAiB,MAAM,+BAAW,gBAAgB;AAAA,EACpD;AACF;",
5
- "names": ["import_react_native"]
6
- }
@@ -1,31 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var helpers_exports = {};
16
- __export(helpers_exports, {
17
- getAppliedOta: () => getAppliedOta,
18
- getShortOtaId: () => getShortOtaId
19
- });
20
- module.exports = __toCommonJS(helpers_exports);
21
- var import_react_native = require("@hot-updater/react-native");
22
- const INITIAL_OTA_ID = "00000000-0000-0000-0000-000000000000";
23
- function getAppliedOta() {
24
- const id = import_react_native.HotUpdater.getBundleId();
25
- return id === INITIAL_OTA_ID || id === import_react_native.HotUpdater.getMinBundleId() ? null : id;
26
- }
27
- function getShortOtaId() {
28
- const fullId = getAppliedOta();
29
- return fullId ? fullId.slice(-12) : null;
30
- }
31
- //# sourceMappingURL=helpers.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers.ts"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA2B;AAE3B,MAAM,iBAAiB;AAMhB,SAAS,gBAA+B;AAC7C,QAAM,KAAK,+BAAW,YAAY;AAElC,SADI,OAAO,kBACP,OAAO,+BAAW,eAAe,IAAU,OACxC;AACT;AAMO,SAAS,gBAA+B;AAC7C,QAAM,SAAS,cAAc;AAC7B,SAAO,SAAS,OAAO,MAAM,GAAG,IAAI;AACtC;",
5
- "names": []
6
- }
package/dist/cjs/index.js DELETED
@@ -1,23 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var index_exports = {};
16
- __export(index_exports, {
17
- HotUpdater: () => import_react_native.HotUpdater,
18
- createHotUpdater: () => import_createHotUpdater.createHotUpdater,
19
- useHotUpdaterStore: () => import_react_native.useHotUpdaterStore
20
- });
21
- module.exports = __toCommonJS(index_exports);
22
- var import_react_native = require("@hot-updater/react-native"), import_createHotUpdater = require("./createHotUpdater");
23
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAA+C,sCAG/C,0BAAiC;",
5
- "names": []
6
- }
package/dist/cjs/mmkv.js DELETED
@@ -1,27 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var mmkv_exports = {};
16
- __export(mmkv_exports, {
17
- createMMKVStorage: () => createMMKVStorage
18
- });
19
- module.exports = __toCommonJS(mmkv_exports);
20
- function createMMKVStorage(mmkv) {
21
- return {
22
- get: (key) => mmkv.getString(key),
23
- set: (key, value) => mmkv.set(key, value),
24
- delete: (key) => mmkv.delete(key)
25
- };
26
- }
27
- //# sourceMappingURL=mmkv.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/mmkv.ts"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,kBAAkB,MAA8B;AAC9D,SAAO;AAAA,IACL,KAAK,CAAC,QAAgB,KAAK,UAAU,GAAG;AAAA,IACxC,KAAK,CAAC,KAAa,UAAkB,KAAK,IAAI,KAAK,KAAK;AAAA,IACxD,QAAQ,CAAC,QAAgB,KAAK,OAAO,GAAG;AAAA,EAC1C;AACF;",
5
- "names": []
6
- }
package/dist/cjs/types.js DELETED
@@ -1,14 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- };
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var types_exports = {};
13
- module.exports = __toCommonJS(types_exports);
14
- //# sourceMappingURL=types.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/types.ts"],
4
- "mappings": ";;;;;;;;;;;AAAA;AAAA;",
5
- "names": []
6
- }
@@ -1,130 +0,0 @@
1
- import { HotUpdater, useHotUpdaterStore } from "@hot-updater/react-native";
2
- import * as Application from "expo-application";
3
- import { useEffect, useRef, useState } from "react";
4
- import { Alert } from "react-native-web";
5
- const INITIAL_OTA_ID = "00000000-0000-0000-0000-000000000000", BUNDLE_ID_KEY_PREFIX = "hotUpdater.bundleId", PRE_RELEASE_BUNDLE_ID_KEY = "hotUpdater.preReleaseBundleId";
6
- function createHotUpdater(config) {
7
- const { storage, updateStrategy = "appVersion" } = config;
8
- let isUpdatePending = !1;
9
- const getAppliedOta = () => {
10
- const id = HotUpdater.getBundleId();
11
- return id === INITIAL_OTA_ID || id === HotUpdater.getMinBundleId() ? null : id;
12
- }, getShortOtaId = () => {
13
- const fullId = getAppliedOta();
14
- return fullId ? fullId.slice(-12) : null;
15
- }, getIsUpdatePending = () => isUpdatePending, getPreReleaseBundleId = () => storage.get(PRE_RELEASE_BUNDLE_ID_KEY), handleUpdateDownloaded = (id, options = {}) => {
16
- const appVersion = Application.nativeApplicationVersion;
17
- appVersion && storage.set(`${BUNDLE_ID_KEY_PREFIX}.${appVersion}`, id), options.isPreRelease ? storage.set(PRE_RELEASE_BUNDLE_ID_KEY, id) : storage.delete(PRE_RELEASE_BUNDLE_ID_KEY), isUpdatePending = !0;
18
- };
19
- return {
20
- useOtaUpdater: (options = {}) => {
21
- const {
22
- enabled = !0,
23
- onUpdateDownloaded: onUpdateDownloadedCallback,
24
- onError
25
- } = options, progress = useHotUpdaterStore((state) => state.progress), isUpdating = progress > 0.01, [isUserClearedForAccess, setIsUserClearedForAccess] = useState(!1), isUserClearedForAccessRef = useRef(isUserClearedForAccess);
26
- return isUserClearedForAccessRef.current = isUserClearedForAccess, useEffect(() => {
27
- if (!isUpdating) {
28
- const timer = setTimeout(() => {
29
- isUserClearedForAccessRef.current || setIsUserClearedForAccess(!0);
30
- }, 5e3);
31
- return () => clearTimeout(timer);
32
- }
33
- }, [isUpdating]), useEffect(() => {
34
- const timer = setTimeout(() => {
35
- isUserClearedForAccessRef.current || setIsUserClearedForAccess(!0);
36
- }, 2e4);
37
- return () => clearTimeout(timer);
38
- }, []), useEffect(() => {
39
- let shouldContinue = !0;
40
- return (async () => {
41
- try {
42
- if (!enabled) {
43
- setIsUserClearedForAccess(!0);
44
- return;
45
- }
46
- if (!shouldContinue) return;
47
- const updateInfo = await HotUpdater.checkForUpdate({
48
- updateStrategy
49
- });
50
- if (!updateInfo) {
51
- setIsUserClearedForAccess(!0);
52
- return;
53
- }
54
- if (!shouldContinue) return;
55
- if (updateInfo.status === "ROLLBACK") {
56
- const preReleaseBundleId = getPreReleaseBundleId(), currentBundleId = HotUpdater.getBundleId();
57
- if (preReleaseBundleId && preReleaseBundleId === currentBundleId && currentBundleId > updateInfo.id) {
58
- Alert.alert(
59
- "Update Skipped",
60
- "Skipped rollback because you are using a newer pre-release bundle."
61
- ), setIsUserClearedForAccess(!0);
62
- return;
63
- }
64
- }
65
- if (updateInfo.shouldForceUpdate || setIsUserClearedForAccess(!0), !shouldContinue) return;
66
- await updateInfo.updateBundle(), handleUpdateDownloaded(updateInfo.id);
67
- const info = {
68
- id: updateInfo.id,
69
- isCriticalUpdate: updateInfo.shouldForceUpdate,
70
- fileUrl: updateInfo.fileUrl,
71
- message: updateInfo.message
72
- };
73
- if (onUpdateDownloadedCallback?.(info), !shouldContinue) return;
74
- if (updateInfo.shouldForceUpdate) {
75
- if (!isUserClearedForAccessRef.current) {
76
- HotUpdater.reload();
77
- return;
78
- }
79
- Alert.alert(
80
- "Update Downloaded",
81
- "An important update has been downloaded. Reload now to apply it?",
82
- [
83
- { text: "Later", style: "cancel" },
84
- { text: "Reload Now", onPress: () => HotUpdater.reload() }
85
- ]
86
- );
87
- }
88
- } catch (error) {
89
- onError?.(error), setIsUserClearedForAccess(!0);
90
- } finally {
91
- isUserClearedForAccessRef.current || setIsUserClearedForAccess(!0);
92
- }
93
- })(), () => {
94
- shouldContinue = !1;
95
- };
96
- }, [enabled, onUpdateDownloadedCallback, onError]), {
97
- userClearedForAccess: isUserClearedForAccess,
98
- progress,
99
- isUpdatePending: getIsUpdatePending()
100
- };
101
- },
102
- checkForUpdate: async (options = {}) => {
103
- const { channel, isPreRelease = !1 } = options, requestHeaders = {};
104
- channel && (requestHeaders["X-Channel"] = channel);
105
- const updateInfo = await HotUpdater.checkForUpdate({
106
- updateStrategy,
107
- ...Object.keys(requestHeaders).length > 0 && { requestHeaders }
108
- });
109
- return updateInfo ? (await updateInfo.updateBundle(), handleUpdateDownloaded(updateInfo.id, { isPreRelease }), {
110
- id: updateInfo.id,
111
- isCriticalUpdate: updateInfo.shouldForceUpdate,
112
- fileUrl: updateInfo.fileUrl,
113
- message: updateInfo.message
114
- }) : null;
115
- },
116
- getAppliedOta,
117
- getShortOtaId,
118
- getIsUpdatePending,
119
- reload: () => HotUpdater.reload(),
120
- getBundleId: () => HotUpdater.getBundleId(),
121
- getMinBundleId: () => HotUpdater.getMinBundleId(),
122
- getChannel: () => HotUpdater.getChannel(),
123
- clearCrashHistory: () => HotUpdater.clearCrashHistory(),
124
- getCrashHistory: () => HotUpdater.getCrashHistory()
125
- };
126
- }
127
- export {
128
- createHotUpdater
129
- };
130
- //# sourceMappingURL=createHotUpdater.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/createHotUpdater.ts"],
4
- "mappings": "AAAA,SAAS,YAAY,0BAA0B;AAC/C,YAAY,iBAAiB;AAC7B,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,aAAa;AAItB,MAAM,iBAAiB,wCACjB,uBAAuB,uBACvB,4BAA4B;AAM3B,SAAS,iBAAiB,QAA8C;AAC7E,QAAM,EAAE,SAAS,iBAAiB,aAAa,IAAI;AAEnD,MAAI,kBAAkB;AAEtB,QAAM,gBAAgB,MAAqB;AAC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,GAAG,GAEI,MAAM;AACX,2BAAiB;AAAA,QACnB;AAAA,MACF,GAAG,CAAC,SAAS,4BAA4B,OAAO,CAAC,GAE1C;AAAA,QACL,sBAAsB;AAAA,QACtB;AAAA,QACA,iBAAiB,mBAAmB;AAAA,MACtC;AAAA,IACF;AAAA,IAqCE,gBAhCqB,OACrB,UAAwD,CAAC,MACtD;AACH,YAAM,EAAE,SAAS,eAAe,GAAM,IAAI,SAEpC,iBAAyC,CAAC;AAChD,MAAI,YACF,eAAe,WAAW,IAAI;AAGhC,YAAM,aAAa,MAAM,WAAW,eAAe;AAAA,QACjD;AAAA,QACA,GAAI,OAAO,KAAK,cAAc,EAAE,SAAS,KAAK,EAAE,eAAe;AAAA,MACjE,CAAC;AAED,aAAI,cACF,MAAM,WAAW,aAAa,GAC9B,uBAAuB,WAAW,IAAI,EAAE,aAAa,CAAC,GAE/C;AAAA,QACL,IAAI,WAAW;AAAA,QACf,kBAAkB,WAAW;AAAA,QAC7B,SAAS,WAAW;AAAA,QACpB,SAAS,WAAW;AAAA,MACtB,KAGK;AAAA,IACT;AAAA,IAKE;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,MAAM,WAAW,OAAO;AAAA,IAChC,aAAa,MAAM,WAAW,YAAY;AAAA,IAC1C,gBAAgB,MAAM,WAAW,eAAe;AAAA,IAChD,YAAY,MAAM,WAAW,WAAW;AAAA,IACxC,mBAAmB,MAAM,WAAW,kBAAkB;AAAA,IACtD,iBAAiB,MAAM,WAAW,gBAAgB;AAAA,EACpD;AACF;",
5
- "names": []
6
- }
@@ -1,15 +0,0 @@
1
- import { HotUpdater } from "@hot-updater/react-native";
2
- const INITIAL_OTA_ID = "00000000-0000-0000-0000-000000000000";
3
- function getAppliedOta() {
4
- const id = HotUpdater.getBundleId();
5
- return id === INITIAL_OTA_ID || id === HotUpdater.getMinBundleId() ? null : id;
6
- }
7
- function getShortOtaId() {
8
- const fullId = getAppliedOta();
9
- return fullId ? fullId.slice(-12) : null;
10
- }
11
- export {
12
- getAppliedOta,
13
- getShortOtaId
14
- };
15
- //# sourceMappingURL=helpers.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers.ts"],
4
- "mappings": "AAAA,SAAS,kBAAkB;AAE3B,MAAM,iBAAiB;AAMhB,SAAS,gBAA+B;AAC7C,QAAM,KAAK,WAAW,YAAY;AAElC,SADI,OAAO,kBACP,OAAO,WAAW,eAAe,IAAU,OACxC;AACT;AAMO,SAAS,gBAA+B;AAC7C,QAAM,SAAS,cAAc;AAC7B,SAAO,SAAS,OAAO,MAAM,GAAG,IAAI;AACtC;",
5
- "names": []
6
- }
package/dist/esm/mmkv.js DELETED
@@ -1,11 +0,0 @@
1
- function createMMKVStorage(mmkv) {
2
- return {
3
- get: (key) => mmkv.getString(key),
4
- set: (key, value) => mmkv.set(key, value),
5
- delete: (key) => mmkv.delete(key)
6
- };
7
- }
8
- export {
9
- createMMKVStorage
10
- };
11
- //# sourceMappingURL=mmkv.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/mmkv.ts"],
4
- "mappings": "AAaO,SAAS,kBAAkB,MAA8B;AAC9D,SAAO;AAAA,IACL,KAAK,CAAC,QAAgB,KAAK,UAAU,GAAG;AAAA,IACxC,KAAK,CAAC,KAAa,UAAkB,KAAK,IAAI,KAAK,KAAK;AAAA,IACxD,QAAQ,CAAC,QAAgB,KAAK,OAAO,GAAG;AAAA,EAC1C;AACF;",
5
- "names": []
6
- }
package/dist/esm/types.js DELETED
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "mappings": "",
5
- "names": []
6
- }