@hot-updater/react-native 0.12.5 → 0.12.7

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/index.js CHANGED
@@ -22,12 +22,8 @@ function __webpack_require__(moduleId) {
22
22
  return module.exports;
23
23
  }
24
24
  (()=>{
25
- __webpack_require__.n = function(module) {
26
- var getter = module && module.__esModule ? function() {
27
- return module['default'];
28
- } : function() {
29
- return module;
30
- };
25
+ __webpack_require__.n = (module)=>{
26
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
31
27
  __webpack_require__.d(getter, {
32
28
  a: getter
33
29
  });
@@ -35,7 +31,7 @@ function __webpack_require__(moduleId) {
35
31
  };
36
32
  })();
37
33
  (()=>{
38
- __webpack_require__.d = function(exports1, definition) {
34
+ __webpack_require__.d = (exports1, definition)=>{
39
35
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
40
36
  enumerable: true,
41
37
  get: definition[key]
@@ -43,12 +39,10 @@ function __webpack_require__(moduleId) {
43
39
  };
44
40
  })();
45
41
  (()=>{
46
- __webpack_require__.o = function(obj, prop) {
47
- return Object.prototype.hasOwnProperty.call(obj, prop);
48
- };
42
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
49
43
  })();
50
44
  (()=>{
51
- __webpack_require__.r = function(exports1) {
45
+ __webpack_require__.r = (exports1)=>{
52
46
  if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
53
47
  value: 'Module'
54
48
  });
@@ -61,9 +55,9 @@ var __webpack_exports__ = {};
61
55
  (()=>{
62
56
  __webpack_require__.r(__webpack_exports__);
63
57
  __webpack_require__.d(__webpack_exports__, {
64
- hotUpdaterStore: ()=>hotUpdaterStore,
58
+ HotUpdater: ()=>src_HotUpdater,
65
59
  useHotUpdaterStore: ()=>useHotUpdaterStore,
66
- HotUpdater: ()=>src_HotUpdater
60
+ hotUpdaterStore: ()=>hotUpdaterStore
67
61
  });
68
62
  const js_namespaceObject = require("@hot-updater/js");
69
63
  var external_react_native_ = __webpack_require__("react-native");
@@ -161,7 +155,9 @@ var __webpack_exports__ = {};
161
155
  id: updateInfo.id
162
156
  };
163
157
  };
164
- const external_react_namespaceObject = require("react");
158
+ const with_selector_namespaceObject = require("use-sync-external-store/shim/with-selector");
159
+ var with_selector_default = /*#__PURE__*/ __webpack_require__.n(with_selector_namespaceObject);
160
+ const { useSyncExternalStoreWithSelector } = with_selector_default();
165
161
  const createHotUpdaterStore = ()=>{
166
162
  let state = {
167
163
  progress: 0,
@@ -190,7 +186,8 @@ var __webpack_exports__ = {};
190
186
  };
191
187
  };
192
188
  const hotUpdaterStore = createHotUpdaterStore();
193
- const useHotUpdaterStore = ()=>(0, external_react_namespaceObject.useSyncExternalStore)(hotUpdaterStore.subscribe, hotUpdaterStore.getSnapshot, hotUpdaterStore.getSnapshot);
189
+ const useHotUpdaterStore = (selector = (snapshot)=>snapshot)=>useSyncExternalStoreWithSelector(hotUpdaterStore.subscribe, hotUpdaterStore.getSnapshot, hotUpdaterStore.getSnapshot, selector);
190
+ const external_react_namespaceObject = require("react");
194
191
  function useEventCallback(fn) {
195
192
  const callbackRef = (0, external_react_namespaceObject.useRef)(()=>{
196
193
  throw new Error("Cannot call an event handler while rendering.");
@@ -208,7 +205,7 @@ var __webpack_exports__ = {};
208
205
  const { reloadOnForceUpdate = true, ...restConfig } = config;
209
206
  return (WrappedComponent)=>{
210
207
  const HotUpdaterHOC = ()=>{
211
- const { progress } = useHotUpdaterStore();
208
+ const progress = useHotUpdaterStore((state)=>state.progress);
212
209
  const [updateStatus, setUpdateStatus] = (0, external_react_namespaceObject.useState)("CHECK_FOR_UPDATE");
213
210
  const initHotUpdater = useEventCallback(async ()=>{
214
211
  try {
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__ from "react-native";
2
2
  import * as __WEBPACK_EXTERNAL_MODULE__hot_updater_js_db235456__ from "@hot-updater/js";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_use_sync_external_store_shim_with_selector_83d70c15__ from "use-sync-external-store/shim/with-selector";
3
4
  import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
4
5
  var __webpack_modules__ = {
5
6
  "./src/specs/NativeHotUpdater.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
@@ -24,7 +25,7 @@ function __webpack_require__(moduleId) {
24
25
  return module.exports;
25
26
  }
26
27
  (()=>{
27
- __webpack_require__.d = function(exports, definition) {
28
+ __webpack_require__.d = (exports, definition)=>{
28
29
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
29
30
  enumerable: true,
30
31
  get: definition[key]
@@ -32,9 +33,7 @@ function __webpack_require__(moduleId) {
32
33
  };
33
34
  })();
34
35
  (()=>{
35
- __webpack_require__.o = function(obj, prop) {
36
- return Object.prototype.hasOwnProperty.call(obj, prop);
37
- };
36
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
38
37
  })();
39
38
  var external_react_native_ = __webpack_require__("react-native");
40
39
  const ensureUpdateInfo = async (source, { appVersion, bundleId, platform }, requestHeaders)=>{
@@ -131,6 +130,7 @@ const runUpdateProcess = async ({ reloadOnForceUpdate = true, ...checkForUpdateC
131
130
  id: updateInfo.id
132
131
  };
133
132
  };
133
+ const { useSyncExternalStoreWithSelector } = __WEBPACK_EXTERNAL_MODULE_use_sync_external_store_shim_with_selector_83d70c15__["default"];
134
134
  const createHotUpdaterStore = ()=>{
135
135
  let state = {
136
136
  progress: 0,
@@ -159,7 +159,7 @@ const createHotUpdaterStore = ()=>{
159
159
  };
160
160
  };
161
161
  const hotUpdaterStore = createHotUpdaterStore();
162
- const useHotUpdaterStore = ()=>(0, __WEBPACK_EXTERNAL_MODULE_react__.useSyncExternalStore)(hotUpdaterStore.subscribe, hotUpdaterStore.getSnapshot, hotUpdaterStore.getSnapshot);
162
+ const useHotUpdaterStore = (selector = (snapshot)=>snapshot)=>useSyncExternalStoreWithSelector(hotUpdaterStore.subscribe, hotUpdaterStore.getSnapshot, hotUpdaterStore.getSnapshot, selector);
163
163
  function useEventCallback(fn) {
164
164
  const callbackRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(()=>{
165
165
  throw new Error("Cannot call an event handler while rendering.");
@@ -177,7 +177,7 @@ function wrap(config) {
177
177
  const { reloadOnForceUpdate = true, ...restConfig } = config;
178
178
  return (WrappedComponent)=>{
179
179
  const HotUpdaterHOC = ()=>{
180
- const { progress } = useHotUpdaterStore();
180
+ const progress = useHotUpdaterStore((state)=>state.progress);
181
181
  const [updateStatus, setUpdateStatus] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)("CHECK_FOR_UPDATE");
182
182
  const initHotUpdater = useEventCallback(async ()=>{
183
183
  try {
package/dist/store.d.ts CHANGED
@@ -7,4 +7,4 @@ export declare const hotUpdaterStore: {
7
7
  setProgress: (progress: number) => void;
8
8
  subscribe: (listener: () => void) => () => boolean;
9
9
  };
10
- export declare const useHotUpdaterStore: () => HotUpdaterState;
10
+ export declare const useHotUpdaterStore: <T = HotUpdaterState>(selector?: (snapshot: HotUpdaterState) => T) => T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/react-native",
3
- "version": "0.12.5",
3
+ "version": "0.12.7",
4
4
  "description": "React Native OTA solution for self-hosted",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -73,14 +73,16 @@
73
73
  "devDependencies": {
74
74
  "@react-native-community/cli": "15.0.1",
75
75
  "@types/react": "^18.2.44",
76
+ "@types/use-sync-external-store": "^0.0.6",
76
77
  "del-cli": "^6.0.0",
77
78
  "react": "18.3.1",
78
79
  "react-native": "0.76.2",
79
80
  "react-native-builder-bob": "^0.33.1"
80
81
  },
81
82
  "dependencies": {
82
- "@hot-updater/js": "0.12.5",
83
- "@hot-updater/core": "0.12.5"
83
+ "use-sync-external-store": "1.4.0",
84
+ "@hot-updater/js": "0.12.7",
85
+ "@hot-updater/core": "0.12.7"
84
86
  },
85
87
  "scripts": {
86
88
  "build": "rslib build",
package/src/store.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { useSyncExternalStore } from "react";
2
-
1
+ import useSyncExternalStoreExports from "use-sync-external-store/shim/with-selector";
3
2
  export type HotUpdaterState = {
4
3
  progress: number;
5
4
  isBundleUpdated: boolean;
6
5
  };
7
6
 
7
+ const { useSyncExternalStoreWithSelector } = useSyncExternalStoreExports;
8
+
8
9
  const createHotUpdaterStore = () => {
9
10
  let state: HotUpdaterState = {
10
11
  progress: 0,
@@ -41,10 +42,13 @@ const createHotUpdaterStore = () => {
41
42
 
42
43
  export const hotUpdaterStore = createHotUpdaterStore();
43
44
 
44
- export const useHotUpdaterStore = () => {
45
- return useSyncExternalStore(
45
+ export const useHotUpdaterStore = <T = HotUpdaterState>(
46
+ selector: (snapshot: HotUpdaterState) => T = (snapshot) => snapshot as T,
47
+ ) => {
48
+ return useSyncExternalStoreWithSelector(
46
49
  hotUpdaterStore.subscribe,
47
50
  hotUpdaterStore.getSnapshot,
48
51
  hotUpdaterStore.getSnapshot,
52
+ selector,
49
53
  );
50
54
  };
package/src/wrap.tsx CHANGED
@@ -61,7 +61,7 @@ export function wrap<P>(
61
61
  const { reloadOnForceUpdate = true, ...restConfig } = config;
62
62
  return (WrappedComponent) => {
63
63
  const HotUpdaterHOC: React.FC<P> = () => {
64
- const { progress } = useHotUpdaterStore();
64
+ const progress = useHotUpdaterStore((state) => state.progress);
65
65
  const [updateStatus, setUpdateStatus] =
66
66
  useState<UpdateStatus>("CHECK_FOR_UPDATE");
67
67