@hot-updater/react-native 0.12.4 → 0.12.6
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/LICENSE +21 -0
- package/dist/index.js +19 -1595
- package/dist/index.mjs +13 -1586
- package/dist/store.d.ts +1 -1
- package/package.json +7 -4
- package/src/store.ts +8 -4
- package/src/wrap.tsx +1 -1
- package/dist/index.js.LICENSE.txt +0 -19
- package/dist/index.mjs.LICENSE.txt +0 -19
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: () =>
|
|
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.
|
|
3
|
+
"version": "0.12.6",
|
|
4
4
|
"description": "React Native OTA solution for self-hosted",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -67,19 +67,22 @@
|
|
|
67
67
|
"includesGeneratedCode": true
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"react-native": "*"
|
|
70
|
+
"react-native": "*",
|
|
71
|
+
"react": "*"
|
|
71
72
|
},
|
|
72
73
|
"devDependencies": {
|
|
73
74
|
"@react-native-community/cli": "15.0.1",
|
|
74
75
|
"@types/react": "^18.2.44",
|
|
76
|
+
"@types/use-sync-external-store": "^0.0.6",
|
|
75
77
|
"del-cli": "^6.0.0",
|
|
76
78
|
"react": "18.3.1",
|
|
77
79
|
"react-native": "0.76.2",
|
|
78
80
|
"react-native-builder-bob": "^0.33.1"
|
|
79
81
|
},
|
|
80
82
|
"dependencies": {
|
|
81
|
-
"
|
|
82
|
-
"@hot-updater/
|
|
83
|
+
"use-sync-external-store": "1.4.0",
|
|
84
|
+
"@hot-updater/js": "0.12.6",
|
|
85
|
+
"@hot-updater/core": "0.12.6"
|
|
83
86
|
},
|
|
84
87
|
"scripts": {
|
|
85
88
|
"build": "rslib build",
|
package/src/store.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
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
|
|
64
|
+
const progress = useHotUpdaterStore((state) => state.progress);
|
|
65
65
|
const [updateStatus, setUpdateStatus] =
|
|
66
66
|
useState<UpdateStatus>("CHECK_FOR_UPDATE");
|
|
67
67
|
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react.development.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @license React
|
|
13
|
-
* react.production.min.js
|
|
14
|
-
*
|
|
15
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
16
|
-
*
|
|
17
|
-
* This source code is licensed under the MIT license found in the
|
|
18
|
-
* LICENSE file in the root directory of this source tree.
|
|
19
|
-
*/
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react.development.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @license React
|
|
13
|
-
* react.production.min.js
|
|
14
|
-
*
|
|
15
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
16
|
-
*
|
|
17
|
-
* This source code is licensed under the MIT license found in the
|
|
18
|
-
* LICENSE file in the root directory of this source tree.
|
|
19
|
-
*/
|