pulse-updates 1.1.0 → 1.2.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/README.md +50 -10
- package/SECURITY.md +42 -0
- package/android/src/main/java/app/pulse/updates/PulseController.kt +6 -2
- package/android/src/main/java/app/pulse/updates/PulseUpdatesModule.kt +25 -0
- package/app.plugin.js +47 -0
- package/ios/PulseUpdates/PulseController.swift +7 -2
- package/ios/PulseUpdates/PulseUpdates.m +7 -0
- package/ios/PulseUpdates/PulseUpdates.swift +22 -0
- package/lib/commonjs/NativePulseUpdates.js.map +1 -1
- package/lib/commonjs/PulseUpdates.js +36 -0
- package/lib/commonjs/PulseUpdates.js.map +1 -1
- package/lib/commonjs/config.js +175 -21
- package/lib/commonjs/config.js.map +1 -1
- package/lib/commonjs/decisions.js +128 -0
- package/lib/commonjs/decisions.js.map +1 -0
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/init.js +164 -12
- package/lib/commonjs/init.js.map +1 -1
- package/lib/commonjs/track.js +154 -12
- package/lib/commonjs/track.js.map +1 -1
- package/lib/commonjs/usePulseUpdates.js +21 -16
- package/lib/commonjs/usePulseUpdates.js.map +1 -1
- package/lib/module/NativePulseUpdates.js.map +1 -1
- package/lib/module/PulseUpdates.js +33 -0
- package/lib/module/PulseUpdates.js.map +1 -1
- package/lib/module/config.js +174 -21
- package/lib/module/config.js.map +1 -1
- package/lib/module/decisions.js +122 -0
- package/lib/module/decisions.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/init.js +165 -14
- package/lib/module/init.js.map +1 -1
- package/lib/module/track.js +152 -12
- package/lib/module/track.js.map +1 -1
- package/lib/module/usePulseUpdates.js +21 -16
- package/lib/module/usePulseUpdates.js.map +1 -1
- package/lib/typescript/NativePulseUpdates.d.ts +1 -0
- package/lib/typescript/NativePulseUpdates.d.ts.map +1 -1
- package/lib/typescript/PulseUpdates.d.ts +20 -0
- package/lib/typescript/PulseUpdates.d.ts.map +1 -1
- package/lib/typescript/config.d.ts +22 -0
- package/lib/typescript/config.d.ts.map +1 -1
- package/lib/typescript/decisions.d.ts +55 -0
- package/lib/typescript/decisions.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/init.d.ts +51 -4
- package/lib/typescript/init.d.ts.map +1 -1
- package/lib/typescript/track.d.ts +29 -1
- package/lib/typescript/track.d.ts.map +1 -1
- package/lib/typescript/usePulseUpdates.d.ts.map +1 -1
- package/logo.png +0 -0
- package/package.json +14 -3
- package/scripts/publish.mjs +68 -3
- package/src/NativePulseUpdates.ts +1 -0
- package/src/PulseUpdates.ts +54 -0
- package/src/config.ts +234 -21
- package/src/decisions.ts +179 -0
- package/src/index.ts +1 -0
- package/src/init.ts +240 -11
- package/src/track.ts +191 -13
- package/src/usePulseUpdates.ts +21 -16
package/src/usePulseUpdates.ts
CHANGED
|
@@ -27,6 +27,7 @@ export interface UsePulseUpdatesResult {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export function usePulseUpdates(): UsePulseUpdatesResult {
|
|
30
|
+
const [nativeState, setNativeState] = useState(PulseUpdates.getUpdatesState);
|
|
30
31
|
const [isChecking, setIsChecking] = useState(false);
|
|
31
32
|
const [isDownloading, setIsDownloading] = useState(false);
|
|
32
33
|
const [availableUpdate, setAvailableUpdate] = useState<PulseManifest | null>(null);
|
|
@@ -35,11 +36,15 @@ export function usePulseUpdates(): UsePulseUpdatesResult {
|
|
|
35
36
|
|
|
36
37
|
// Refresh state on mount to get latest values after configure
|
|
37
38
|
useEffect(() => {
|
|
38
|
-
PulseUpdates.
|
|
39
|
+
const unsubscribe = PulseUpdates.onUpdatesStateChange(() => {
|
|
40
|
+
setNativeState(PulseUpdates.getUpdatesState());
|
|
41
|
+
});
|
|
42
|
+
void PulseUpdates.refreshStateAsync();
|
|
43
|
+
return unsubscribe;
|
|
39
44
|
}, []);
|
|
40
45
|
|
|
41
46
|
useEffect(() => {
|
|
42
|
-
if (!
|
|
47
|
+
if (!nativeState.isEnabled) return;
|
|
43
48
|
|
|
44
49
|
const subscription = PulseUpdates.addUpdateListener((event) => {
|
|
45
50
|
switch (event.type) {
|
|
@@ -59,10 +64,10 @@ export function usePulseUpdates(): UsePulseUpdatesResult {
|
|
|
59
64
|
});
|
|
60
65
|
|
|
61
66
|
return () => subscription.remove();
|
|
62
|
-
}, []);
|
|
67
|
+
}, [nativeState.isEnabled]);
|
|
63
68
|
|
|
64
69
|
const checkForUpdate = useCallback(async (): Promise<UpdateCheckResult> => {
|
|
65
|
-
if (!
|
|
70
|
+
if (!nativeState.isEnabled) {
|
|
66
71
|
return { isAvailable: false };
|
|
67
72
|
}
|
|
68
73
|
|
|
@@ -84,10 +89,10 @@ export function usePulseUpdates(): UsePulseUpdatesResult {
|
|
|
84
89
|
} finally {
|
|
85
90
|
setIsChecking(false);
|
|
86
91
|
}
|
|
87
|
-
}, []);
|
|
92
|
+
}, [nativeState.isEnabled]);
|
|
88
93
|
|
|
89
94
|
const downloadUpdate = useCallback(async (): Promise<UpdateFetchResult> => {
|
|
90
|
-
if (!
|
|
95
|
+
if (!nativeState.isEnabled) {
|
|
91
96
|
return { isNew: false };
|
|
92
97
|
}
|
|
93
98
|
|
|
@@ -107,23 +112,23 @@ export function usePulseUpdates(): UsePulseUpdatesResult {
|
|
|
107
112
|
} finally {
|
|
108
113
|
setIsDownloading(false);
|
|
109
114
|
}
|
|
110
|
-
}, []);
|
|
115
|
+
}, [nativeState.isEnabled]);
|
|
111
116
|
|
|
112
117
|
const reload = useCallback(async (): Promise<void> => {
|
|
113
|
-
if (!
|
|
118
|
+
if (!nativeState.isEnabled) return;
|
|
114
119
|
await PulseUpdates.reloadAsync();
|
|
115
|
-
}, []);
|
|
120
|
+
}, [nativeState.isEnabled]);
|
|
116
121
|
|
|
117
122
|
return {
|
|
118
|
-
isEnabled:
|
|
123
|
+
isEnabled: nativeState.isEnabled,
|
|
119
124
|
isChecking,
|
|
120
125
|
isDownloading,
|
|
121
|
-
updateId:
|
|
122
|
-
runtimeVersion:
|
|
123
|
-
channel:
|
|
124
|
-
manifest:
|
|
125
|
-
isEmbeddedLaunch:
|
|
126
|
-
createdAt:
|
|
126
|
+
updateId: nativeState.updateId,
|
|
127
|
+
runtimeVersion: nativeState.runtimeVersion,
|
|
128
|
+
channel: nativeState.channel,
|
|
129
|
+
manifest: nativeState.manifest,
|
|
130
|
+
isEmbeddedLaunch: nativeState.isEmbeddedLaunch,
|
|
131
|
+
createdAt: nativeState.createdAt,
|
|
127
132
|
build: PulseUpdates.getUpdateBuild(),
|
|
128
133
|
availableUpdate,
|
|
129
134
|
downloadedUpdate,
|