create-expo-updates-server 0.2.1 → 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/template/docs/expo-app-setup.md +8 -12
- package/dist/template/docs/getting-started.md +5 -5
- package/dist/template/docs/getting-started.ru.md +5 -5
- package/dist/template/docs/ota-client-lifecycle.md +46 -42
- package/dist/template/package-lock.json +589 -0
- package/dist/template/package.json +1 -0
- package/dist/template/scripts/lib/device-identity.test.ts +2 -2
- package/dist/template/scripts/lib/doctor.mjs +3 -3
- package/dist/template/scripts/lib/doctor.test.mjs +1 -1
- package/dist/template/scripts/lib/ota-client-configurator.mjs +116 -34
- package/dist/template/scripts/lib/ota-client-configurator.test.ts +210 -61
- package/dist/template/scripts/lib/ota-client.test.ts +1 -1
- package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +435 -118
- package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +243 -86
- package/dist/template/scripts/lib/ota-update-controller.test.ts +10 -9
- package/dist/template/scripts/lib/ota-updates-ui.test.tsx +154 -0
- package/dist/template/scripts/tests/fixtures/react-native-ui.tsx +34 -0
- package/dist/template/scripts/tests/ota-client-types.mjs +69 -0
- package/dist/template/templates/expo-app/ota-client/README.md +16 -2
- package/dist/template/templates/expo-app/ota-client/controller.ts +107 -0
- package/dist/template/templates/expo-app/ota-client/device-identity.ts +48 -0
- package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +18 -9
- package/dist/template/templates/expo-app/ota-client/index.ts +16 -0
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +97 -0
- package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +293 -0
- package/dist/template/templates/expo-app/ota-client/runtime.ts +153 -0
- package/dist/template/templates/expo-app/ota-client/types.ts +85 -0
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +25 -0
- package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +196 -0
- package/dist/template/tsconfig.json +3 -1
- package/dist/template/vitest.config.mts +3 -0
- package/dist/template-manifest.json +85 -65
- package/package.json +1 -1
- package/dist/template/templates/expo-app/ota-client/controller.js +0 -60
- package/dist/template/templates/expo-app/ota-client/device-identity.js +0 -26
- package/dist/template/templates/expo-app/ota-client/index.d.ts +0 -47
- package/dist/template/templates/expo-app/ota-client/index.js +0 -3
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.js +0 -48
- package/dist/template/templates/expo-app/ota-client/model/update-controller.js +0 -182
- package/dist/template/templates/expo-app/ota-client/runtime.js +0 -112
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.js +0 -56
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
Modal,
|
|
5
|
+
Pressable,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Text,
|
|
8
|
+
View,
|
|
9
|
+
} from "react-native";
|
|
10
|
+
import type { OtaController, OtaUpdatesProps } from "../types";
|
|
11
|
+
import { manifestDetails } from "../types";
|
|
12
|
+
import { useOtaUpdates } from "../model/hooks/useOtaUpdates";
|
|
13
|
+
|
|
14
|
+
/** Mount once beside navigation. No context or application wrapper is required. */
|
|
15
|
+
export function OtaUpdates({
|
|
16
|
+
autoCheck = true,
|
|
17
|
+
autoUpdate = false,
|
|
18
|
+
autoReload = false,
|
|
19
|
+
guardHandlers,
|
|
20
|
+
renderBlocked,
|
|
21
|
+
renderAvailable,
|
|
22
|
+
}: OtaUpdatesProps) {
|
|
23
|
+
const controller = useOtaUpdates({
|
|
24
|
+
autoCheck,
|
|
25
|
+
autoUpdate,
|
|
26
|
+
autoReload,
|
|
27
|
+
guardHandlers,
|
|
28
|
+
});
|
|
29
|
+
return (
|
|
30
|
+
<OtaUpdateOverlay
|
|
31
|
+
controller={controller}
|
|
32
|
+
renderBlocked={renderBlocked}
|
|
33
|
+
renderAvailable={renderAvailable}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface OverlayProps
|
|
39
|
+
extends Pick<OtaUpdatesProps, "renderBlocked" | "renderAvailable"> {
|
|
40
|
+
controller: OtaController;
|
|
41
|
+
showAvailable?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function OtaUpdateOverlay({
|
|
45
|
+
controller,
|
|
46
|
+
renderBlocked,
|
|
47
|
+
renderAvailable,
|
|
48
|
+
showAvailable = true,
|
|
49
|
+
}: OverlayProps) {
|
|
50
|
+
const [dismissed, setDismissed] = useState<string | null>(null);
|
|
51
|
+
const candidateId =
|
|
52
|
+
manifestDetails(controller.candidate?.manifest)?.id ??
|
|
53
|
+
controller.candidate?.type ??
|
|
54
|
+
"update";
|
|
55
|
+
const noticeId = `${candidateId}:${controller.pending}`;
|
|
56
|
+
const dismiss = () => {
|
|
57
|
+
if (!controller.blocked) setDismissed(noticeId);
|
|
58
|
+
};
|
|
59
|
+
const optional =
|
|
60
|
+
showAvailable &&
|
|
61
|
+
controller.available &&
|
|
62
|
+
controller.policy?.delivery !== "background" &&
|
|
63
|
+
dismissed !== noticeId;
|
|
64
|
+
if (!controller.blocked && !optional) return null;
|
|
65
|
+
|
|
66
|
+
let content = <UpdateNotice controller={controller} dismiss={dismiss} />;
|
|
67
|
+
if (controller.blocked && renderBlocked)
|
|
68
|
+
content = <>{renderBlocked(controller)}</>;
|
|
69
|
+
if (!controller.blocked && renderAvailable)
|
|
70
|
+
content = <>{renderAvailable(controller, dismiss)}</>;
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Modal
|
|
74
|
+
visible
|
|
75
|
+
animationType="none"
|
|
76
|
+
presentationStyle="fullScreen"
|
|
77
|
+
onRequestClose={dismiss}
|
|
78
|
+
>
|
|
79
|
+
{content}
|
|
80
|
+
</Modal>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function UpdateNotice({
|
|
85
|
+
controller,
|
|
86
|
+
dismiss,
|
|
87
|
+
}: {
|
|
88
|
+
controller: OtaController;
|
|
89
|
+
dismiss: () => void;
|
|
90
|
+
}) {
|
|
91
|
+
let title = "Update available";
|
|
92
|
+
let description =
|
|
93
|
+
"A new version is available. Download it now or continue using the application.";
|
|
94
|
+
let label = "Download";
|
|
95
|
+
let action: () => Promise<unknown> = controller.download;
|
|
96
|
+
if (controller.pending) {
|
|
97
|
+
description = "The update is ready. Restart the application to apply it.";
|
|
98
|
+
label = "Restart";
|
|
99
|
+
action = controller.reload;
|
|
100
|
+
}
|
|
101
|
+
if (controller.blocked) {
|
|
102
|
+
title = "Update required";
|
|
103
|
+
description = "An application update is required to continue.";
|
|
104
|
+
label = "Retry";
|
|
105
|
+
action = controller.retry;
|
|
106
|
+
if (controller.blockReason === "ota-force-store-update") {
|
|
107
|
+
description = "Install the latest version from the store to continue.";
|
|
108
|
+
label = "Open store";
|
|
109
|
+
action = controller.openStore;
|
|
110
|
+
} else if (controller.blockReason === "ota-force-update") {
|
|
111
|
+
if (controller.pending) {
|
|
112
|
+
description =
|
|
113
|
+
"The update is ready. Restart the application to continue.";
|
|
114
|
+
label = "Restart";
|
|
115
|
+
action = controller.reload;
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
title = "Update needs attention";
|
|
119
|
+
description = "This update requires an action before you can continue.";
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<View style={styles.root}>
|
|
125
|
+
<Text style={styles.title} accessibilityRole="header">
|
|
126
|
+
{title}
|
|
127
|
+
</Text>
|
|
128
|
+
<Text style={styles.text}>{description}</Text>
|
|
129
|
+
{controller.error && (
|
|
130
|
+
<Text style={styles.error} accessibilityRole="alert">
|
|
131
|
+
{controller.error.message}
|
|
132
|
+
</Text>
|
|
133
|
+
)}
|
|
134
|
+
{controller.isBusy && (
|
|
135
|
+
<ActivityIndicator
|
|
136
|
+
color="#93c5fd"
|
|
137
|
+
accessibilityLabel="Updating application"
|
|
138
|
+
/>
|
|
139
|
+
)}
|
|
140
|
+
<Pressable
|
|
141
|
+
style={styles.button}
|
|
142
|
+
accessibilityRole="button"
|
|
143
|
+
accessibilityState={{ disabled: controller.isBusy }}
|
|
144
|
+
disabled={controller.isBusy}
|
|
145
|
+
onPress={() => {
|
|
146
|
+
void action().catch(() => undefined);
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
<Text style={styles.buttonText}>{label}</Text>
|
|
150
|
+
</Pressable>
|
|
151
|
+
{controller.blockReason === "ota-force-store-update" && (
|
|
152
|
+
<Pressable
|
|
153
|
+
style={styles.button}
|
|
154
|
+
accessibilityRole="button"
|
|
155
|
+
disabled={controller.isBusy}
|
|
156
|
+
onPress={() => {
|
|
157
|
+
void controller.retry().catch(() => undefined);
|
|
158
|
+
}}
|
|
159
|
+
>
|
|
160
|
+
<Text style={styles.buttonText}>Check again</Text>
|
|
161
|
+
</Pressable>
|
|
162
|
+
)}
|
|
163
|
+
{!controller.blocked && (
|
|
164
|
+
<Pressable
|
|
165
|
+
style={styles.button}
|
|
166
|
+
accessibilityRole="button"
|
|
167
|
+
onPress={dismiss}
|
|
168
|
+
>
|
|
169
|
+
<Text style={styles.buttonText}>Later</Text>
|
|
170
|
+
</Pressable>
|
|
171
|
+
)}
|
|
172
|
+
</View>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const styles = StyleSheet.create({
|
|
177
|
+
root: {
|
|
178
|
+
flex: 1,
|
|
179
|
+
justifyContent: "center",
|
|
180
|
+
padding: 28,
|
|
181
|
+
gap: 20,
|
|
182
|
+
backgroundColor: "#0f172a",
|
|
183
|
+
},
|
|
184
|
+
title: { color: "#f8fafc", fontSize: 26, fontWeight: "700" },
|
|
185
|
+
text: { color: "#cbd5e1", fontSize: 16, lineHeight: 24 },
|
|
186
|
+
error: { color: "#fca5a5", fontSize: 14 },
|
|
187
|
+
button: {
|
|
188
|
+
minHeight: 48,
|
|
189
|
+
justifyContent: "center",
|
|
190
|
+
alignItems: "center",
|
|
191
|
+
backgroundColor: "#2563eb",
|
|
192
|
+
borderRadius: 12,
|
|
193
|
+
padding: 12,
|
|
194
|
+
},
|
|
195
|
+
buttonText: { color: "#fff", fontSize: 16, fontWeight: "600" },
|
|
196
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"installerVersion": "0.
|
|
4
|
-
"sourceCommit": "
|
|
5
|
-
"totalSize":
|
|
3
|
+
"installerVersion": "0.3.0",
|
|
4
|
+
"sourceCommit": "8705884a0b13c692c8cf6e290e86c3bd5d41753f",
|
|
5
|
+
"totalSize": 1872262,
|
|
6
6
|
"files": [
|
|
7
7
|
{
|
|
8
8
|
"path": ".dockerignore",
|
|
@@ -437,18 +437,18 @@
|
|
|
437
437
|
},
|
|
438
438
|
{
|
|
439
439
|
"path": "docs/expo-app-setup.md",
|
|
440
|
-
"size":
|
|
441
|
-
"sha256": "
|
|
440
|
+
"size": 23437,
|
|
441
|
+
"sha256": "2328cf0855108b3a1277fc93524e85d6047295cc0d4b63308dde8edd150cc3d0"
|
|
442
442
|
},
|
|
443
443
|
{
|
|
444
444
|
"path": "docs/getting-started.md",
|
|
445
|
-
"size":
|
|
446
|
-
"sha256": "
|
|
445
|
+
"size": 15093,
|
|
446
|
+
"sha256": "4b96762c3899f66b59b37998266b61fef23cbea2b9ea9f9795f3b1913db3bc35"
|
|
447
447
|
},
|
|
448
448
|
{
|
|
449
449
|
"path": "docs/getting-started.ru.md",
|
|
450
|
-
"size":
|
|
451
|
-
"sha256": "
|
|
450
|
+
"size": 24337,
|
|
451
|
+
"sha256": "abcb4e0771664fbe00e53f3a3ccffdb47ac68d75d412062ba2d3f33e86e251e6"
|
|
452
452
|
},
|
|
453
453
|
{
|
|
454
454
|
"path": "docs/index.md",
|
|
@@ -537,8 +537,8 @@
|
|
|
537
537
|
},
|
|
538
538
|
{
|
|
539
539
|
"path": "docs/ota-client-lifecycle.md",
|
|
540
|
-
"size":
|
|
541
|
-
"sha256": "
|
|
540
|
+
"size": 13858,
|
|
541
|
+
"sha256": "e69a76c377a25800f70c0e2d5e4742b7175b09aa45fd304e5037a45dd114af7c"
|
|
542
542
|
},
|
|
543
543
|
{
|
|
544
544
|
"path": "docs/ota-emergency-recovery.md",
|
|
@@ -582,13 +582,13 @@
|
|
|
582
582
|
},
|
|
583
583
|
{
|
|
584
584
|
"path": "package-lock.json",
|
|
585
|
-
"size":
|
|
586
|
-
"sha256": "
|
|
585
|
+
"size": 532996,
|
|
586
|
+
"sha256": "f3e70366354f8d490cc171208a9ed19d72c8cfbd9829700647933750a2331a96"
|
|
587
587
|
},
|
|
588
588
|
{
|
|
589
589
|
"path": "package.json",
|
|
590
|
-
"size":
|
|
591
|
-
"sha256": "
|
|
590
|
+
"size": 1806,
|
|
591
|
+
"sha256": "47be926f3e16f94005d884c83fc132d7b95cbca7f32b4ea49349d68e5a8e781e"
|
|
592
592
|
},
|
|
593
593
|
{
|
|
594
594
|
"path": "postcss.config.mjs",
|
|
@@ -662,8 +662,8 @@
|
|
|
662
662
|
},
|
|
663
663
|
{
|
|
664
664
|
"path": "scripts/lib/device-identity.test.ts",
|
|
665
|
-
"size":
|
|
666
|
-
"sha256": "
|
|
665
|
+
"size": 2115,
|
|
666
|
+
"sha256": "3b582462953f8016d19281e7e6168c5c01742c7b1a8c3f85840e2fe62a356056"
|
|
667
667
|
},
|
|
668
668
|
{
|
|
669
669
|
"path": "scripts/lib/doctor-probes.mjs",
|
|
@@ -672,13 +672,13 @@
|
|
|
672
672
|
},
|
|
673
673
|
{
|
|
674
674
|
"path": "scripts/lib/doctor.mjs",
|
|
675
|
-
"size":
|
|
676
|
-
"sha256": "
|
|
675
|
+
"size": 20985,
|
|
676
|
+
"sha256": "4c09a0dc29211431dfd231567009061a278b990f3a369b7f294ba171f214ac47"
|
|
677
677
|
},
|
|
678
678
|
{
|
|
679
679
|
"path": "scripts/lib/doctor.test.mjs",
|
|
680
680
|
"size": 18599,
|
|
681
|
-
"sha256": "
|
|
681
|
+
"sha256": "3deec6cd70043b2883539f1b31257d92aa72d2d001285344a687c42f0659d625"
|
|
682
682
|
},
|
|
683
683
|
{
|
|
684
684
|
"path": "scripts/lib/embedded-update-registrar.test.ts",
|
|
@@ -712,18 +712,18 @@
|
|
|
712
712
|
},
|
|
713
713
|
{
|
|
714
714
|
"path": "scripts/lib/ota-client-configurator.mjs",
|
|
715
|
-
"size":
|
|
716
|
-
"sha256": "
|
|
715
|
+
"size": 5103,
|
|
716
|
+
"sha256": "c307ab8f593ffb08926ee41e67531686eb97dc56b8ce762dda8d76a9b493738a"
|
|
717
717
|
},
|
|
718
718
|
{
|
|
719
719
|
"path": "scripts/lib/ota-client-configurator.test.ts",
|
|
720
|
-
"size":
|
|
721
|
-
"sha256": "
|
|
720
|
+
"size": 8735,
|
|
721
|
+
"sha256": "8281424e1a95ae823c0d24ac58e673dd789be1d543553adf774ec8739c4f8100"
|
|
722
722
|
},
|
|
723
723
|
{
|
|
724
724
|
"path": "scripts/lib/ota-client.test.ts",
|
|
725
|
-
"size":
|
|
726
|
-
"sha256": "
|
|
725
|
+
"size": 3411,
|
|
726
|
+
"sha256": "8064ba70e397dd5cb90a80ea02c88fb7f0ac91d617a76d8a207164e5a0cd7622"
|
|
727
727
|
},
|
|
728
728
|
{
|
|
729
729
|
"path": "scripts/lib/ota-publish-retry.test.ts",
|
|
@@ -732,18 +732,23 @@
|
|
|
732
732
|
},
|
|
733
733
|
{
|
|
734
734
|
"path": "scripts/lib/ota-root-hook-patcher.mjs",
|
|
735
|
-
"size":
|
|
736
|
-
"sha256": "
|
|
735
|
+
"size": 17390,
|
|
736
|
+
"sha256": "3a3aa88356d37b0eabcc11170df73267b0bb64583c9b897f276f84a5a119099f"
|
|
737
737
|
},
|
|
738
738
|
{
|
|
739
739
|
"path": "scripts/lib/ota-root-hook-patcher.test.ts",
|
|
740
|
-
"size":
|
|
741
|
-
"sha256": "
|
|
740
|
+
"size": 12211,
|
|
741
|
+
"sha256": "b264704f715a9c405ad8cb4d04572c2a3a71243918d87ef350fcc90ac3afe35e"
|
|
742
742
|
},
|
|
743
743
|
{
|
|
744
744
|
"path": "scripts/lib/ota-update-controller.test.ts",
|
|
745
|
-
"size":
|
|
746
|
-
"sha256": "
|
|
745
|
+
"size": 15504,
|
|
746
|
+
"sha256": "a18c6b160c40aec1495e0cd54797188c4d3db2b59be887137a3409fd3289a157"
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
"path": "scripts/lib/ota-updates-ui.test.tsx",
|
|
750
|
+
"size": 5065,
|
|
751
|
+
"sha256": "a0be1670851fc1e963c0cf3f02bbcd69c96cbcb48cfd6c99948e982b7033b1ca"
|
|
747
752
|
},
|
|
748
753
|
{
|
|
749
754
|
"path": "scripts/manage-emergency-redirect.mjs",
|
|
@@ -785,6 +790,11 @@
|
|
|
785
790
|
"size": 3018,
|
|
786
791
|
"sha256": "e04a671e707d917286d66dab84403898adf811eb285c1ede4742888126e07b90"
|
|
787
792
|
},
|
|
793
|
+
{
|
|
794
|
+
"path": "scripts/tests/fixtures/react-native-ui.tsx",
|
|
795
|
+
"size": 984,
|
|
796
|
+
"sha256": "0f5839af24cfd076eb2c9780fe21572a47030a499cc33c38de547a90c8a1ca5d"
|
|
797
|
+
},
|
|
788
798
|
{
|
|
789
799
|
"path": "scripts/tests/manifest-identity-concurrency.mjs",
|
|
790
800
|
"size": 3793,
|
|
@@ -795,6 +805,11 @@
|
|
|
795
805
|
"size": 9669,
|
|
796
806
|
"sha256": "1b6a00ff06c8c93fe50475016de8eb2d05bac474096b2de8b85dbf5c96927e21"
|
|
797
807
|
},
|
|
808
|
+
{
|
|
809
|
+
"path": "scripts/tests/ota-client-types.mjs",
|
|
810
|
+
"size": 2096,
|
|
811
|
+
"sha256": "400a59fcac154e58e4971f8496e55adf75ce50ba03f4680aa71753f0f4a9c179"
|
|
812
|
+
},
|
|
798
813
|
{
|
|
799
814
|
"path": "src/client/admin-api.ts",
|
|
800
815
|
"size": 7026,
|
|
@@ -1156,54 +1171,59 @@
|
|
|
1156
1171
|
"sha256": "6b6cade2dd4f71c3c860e785c99f105e19243f5fd15c462c1de5d0acf98bb808"
|
|
1157
1172
|
},
|
|
1158
1173
|
{
|
|
1159
|
-
"path": "templates/expo-app/ota-client/controller.
|
|
1160
|
-
"size":
|
|
1161
|
-
"sha256": "
|
|
1174
|
+
"path": "templates/expo-app/ota-client/controller.ts",
|
|
1175
|
+
"size": 3057,
|
|
1176
|
+
"sha256": "857b872021aafe85dcefa16c5926084adeba356049534f5b5beeeddd8d69e997"
|
|
1162
1177
|
},
|
|
1163
1178
|
{
|
|
1164
|
-
"path": "templates/expo-app/ota-client/device-identity.
|
|
1165
|
-
"size":
|
|
1166
|
-
"sha256": "
|
|
1179
|
+
"path": "templates/expo-app/ota-client/device-identity.ts",
|
|
1180
|
+
"size": 1265,
|
|
1181
|
+
"sha256": "175e6420b2af63d554b6873f85cdb5367a07deaa5ab2aa9843b35be38846a874"
|
|
1167
1182
|
},
|
|
1168
1183
|
{
|
|
1169
1184
|
"path": "templates/expo-app/ota-client/docs/update-lifecycle.md",
|
|
1170
|
-
"size":
|
|
1171
|
-
"sha256": "
|
|
1185
|
+
"size": 4098,
|
|
1186
|
+
"sha256": "f16381c3884675c0278968a5980c869af909b89ba61dfcaf8cdc3febe97604b4"
|
|
1172
1187
|
},
|
|
1173
1188
|
{
|
|
1174
|
-
"path": "templates/expo-app/ota-client/index.
|
|
1175
|
-
"size":
|
|
1176
|
-
"sha256": "
|
|
1189
|
+
"path": "templates/expo-app/ota-client/index.ts",
|
|
1190
|
+
"size": 374,
|
|
1191
|
+
"sha256": "43229cadbeffcc544704c70e506a89c6bde7b44666f4ff44b64a768eade200b3"
|
|
1177
1192
|
},
|
|
1178
1193
|
{
|
|
1179
|
-
"path": "templates/expo-app/ota-client/
|
|
1180
|
-
"size":
|
|
1181
|
-
"sha256": "
|
|
1194
|
+
"path": "templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts",
|
|
1195
|
+
"size": 2933,
|
|
1196
|
+
"sha256": "01aec47eb8197039beb8895ce3b25e726518bd31c18838656967deb55b025eae"
|
|
1182
1197
|
},
|
|
1183
1198
|
{
|
|
1184
|
-
"path": "templates/expo-app/ota-client/model/
|
|
1185
|
-
"size":
|
|
1186
|
-
"sha256": "
|
|
1199
|
+
"path": "templates/expo-app/ota-client/model/update-controller.ts",
|
|
1200
|
+
"size": 9260,
|
|
1201
|
+
"sha256": "130bcfa37864383143b0f1fb2b0789e94e5f3e2b7f4fe3d22e168a55643b7e03"
|
|
1187
1202
|
},
|
|
1188
1203
|
{
|
|
1189
|
-
"path": "templates/expo-app/ota-client/
|
|
1190
|
-
"size":
|
|
1191
|
-
"sha256": "
|
|
1204
|
+
"path": "templates/expo-app/ota-client/README.md",
|
|
1205
|
+
"size": 4378,
|
|
1206
|
+
"sha256": "94de27962827a474e3348a8619d2f0d5a5a28db986350d87337843c55427754e"
|
|
1192
1207
|
},
|
|
1193
1208
|
{
|
|
1194
|
-
"path": "templates/expo-app/ota-client/
|
|
1195
|
-
"size":
|
|
1196
|
-
"sha256": "
|
|
1209
|
+
"path": "templates/expo-app/ota-client/runtime.ts",
|
|
1210
|
+
"size": 4925,
|
|
1211
|
+
"sha256": "8eb1548b060125ddd93dd05a31ee9197777da30bb7d052ebc3e647c9360e1f4c"
|
|
1212
|
+
},
|
|
1213
|
+
{
|
|
1214
|
+
"path": "templates/expo-app/ota-client/types.ts",
|
|
1215
|
+
"size": 2227,
|
|
1216
|
+
"sha256": "29c4894ed1f7cbd61f59f2f62319748f3555f9e2d883d858e3b64100d8940c64"
|
|
1197
1217
|
},
|
|
1198
1218
|
{
|
|
1199
|
-
"path": "templates/expo-app/ota-client/
|
|
1200
|
-
"size":
|
|
1201
|
-
"sha256": "
|
|
1219
|
+
"path": "templates/expo-app/ota-client/ui/ota-update-gate.tsx",
|
|
1220
|
+
"size": 625,
|
|
1221
|
+
"sha256": "26f34d88605950df11597a01204710c606203baee87a9df9de29be33860d5678"
|
|
1202
1222
|
},
|
|
1203
1223
|
{
|
|
1204
|
-
"path": "templates/expo-app/ota-client/ui/ota-
|
|
1205
|
-
"size":
|
|
1206
|
-
"sha256": "
|
|
1224
|
+
"path": "templates/expo-app/ota-client/ui/ota-updates.tsx",
|
|
1225
|
+
"size": 5437,
|
|
1226
|
+
"sha256": "e2a710f41e9ab2f33fbd8b7948f25c43a601324703b7f714bf34f4fdc9099f2c"
|
|
1207
1227
|
},
|
|
1208
1228
|
{
|
|
1209
1229
|
"path": "templates/expo-app/plugins/with-ota-embedded-registration.js",
|
|
@@ -1262,13 +1282,13 @@
|
|
|
1262
1282
|
},
|
|
1263
1283
|
{
|
|
1264
1284
|
"path": "tsconfig.json",
|
|
1265
|
-
"size":
|
|
1266
|
-
"sha256": "
|
|
1285
|
+
"size": 876,
|
|
1286
|
+
"sha256": "95b66756977ed72dfce964e1ff399ed67f5048490c47fa96b794a952d83a1eda"
|
|
1267
1287
|
},
|
|
1268
1288
|
{
|
|
1269
1289
|
"path": "vitest.config.mts",
|
|
1270
|
-
"size":
|
|
1271
|
-
"sha256": "
|
|
1290
|
+
"size": 541,
|
|
1291
|
+
"sha256": "0b7c17eb5a2efe41e1b845a30f24d247b4eeb48b39160eeba5121943538cda71"
|
|
1272
1292
|
}
|
|
1273
1293
|
]
|
|
1274
1294
|
}
|
package/package.json
CHANGED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// Pure controller: storage and network are injected so ordering is testable.
|
|
2
|
-
// One persisted envelope owns identity, sequence and the bounded outbox.
|
|
3
|
-
export function createInstallationClient({ read, write, uuid, snapshot, send, setIdentity, now = () => new Date().toISOString() }) {
|
|
4
|
-
let state;
|
|
5
|
-
let queue = Promise.resolve();
|
|
6
|
-
let flight;
|
|
7
|
-
const serial = (work) => {
|
|
8
|
-
const result = queue.then(work);
|
|
9
|
-
queue = result.catch(() => undefined);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
async function initialize() {
|
|
13
|
-
if (state) return state;
|
|
14
|
-
const stored = await read();
|
|
15
|
-
if (stored) {
|
|
16
|
-
const parsed = JSON.parse(stored);
|
|
17
|
-
if (!parsed.installationId || !Number.isSafeInteger(parsed.sequence) || parsed.sequence < 0) throw new Error("Invalid OTA client state");
|
|
18
|
-
state = parsed;
|
|
19
|
-
} else {
|
|
20
|
-
const next = { installationId: uuid(), sequence: 0, pending: null };
|
|
21
|
-
await write(JSON.stringify(next));
|
|
22
|
-
state = next;
|
|
23
|
-
}
|
|
24
|
-
return state;
|
|
25
|
-
}
|
|
26
|
-
const ready = () => serial(async () => {
|
|
27
|
-
const current = await initialize();
|
|
28
|
-
await setIdentity(current.installationId);
|
|
29
|
-
return current.installationId;
|
|
30
|
-
});
|
|
31
|
-
async function flush() {
|
|
32
|
-
if (flight) return flight;
|
|
33
|
-
flight = (async () => {
|
|
34
|
-
const pending = await serial(async () => (await initialize()).pending);
|
|
35
|
-
if (!pending) return;
|
|
36
|
-
await send(pending);
|
|
37
|
-
await serial(async () => {
|
|
38
|
-
if (state.pending?.eventId !== pending.eventId) return;
|
|
39
|
-
const next = { ...state, pending: null };
|
|
40
|
-
await write(JSON.stringify(next));
|
|
41
|
-
state = next;
|
|
42
|
-
});
|
|
43
|
-
})();
|
|
44
|
-
try { await flight; } finally { flight = undefined; }
|
|
45
|
-
}
|
|
46
|
-
async function observe() {
|
|
47
|
-
await serial(async () => {
|
|
48
|
-
const current = await initialize();
|
|
49
|
-
await setIdentity(current.installationId);
|
|
50
|
-
if (current.sequence >= Number.MAX_SAFE_INTEGER) throw new Error("OTA sequence exhausted");
|
|
51
|
-
const sequence = current.sequence + 1;
|
|
52
|
-
const pending = { ...snapshot(), installationId: current.installationId, eventId: uuid(), sequence, observedAt: now() };
|
|
53
|
-
const next = { ...current, sequence, pending };
|
|
54
|
-
await write(JSON.stringify(next));
|
|
55
|
-
state = next;
|
|
56
|
-
});
|
|
57
|
-
await flush();
|
|
58
|
-
}
|
|
59
|
-
return { ready, observe, flush };
|
|
60
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Dependencies are injected so reinstall behaviour can be tested without native modules.
|
|
2
|
-
export function createDeviceIdentity({ platform, scope, androidId, readSecure, writeSecure, uuid, digest }) {
|
|
3
|
-
let flight;
|
|
4
|
-
async function resolve() {
|
|
5
|
-
const namespace = await digest(`ota-device-v1:${scope}`);
|
|
6
|
-
let seed;
|
|
7
|
-
if (platform === 'android') {
|
|
8
|
-
seed = androidId();
|
|
9
|
-
if (!seed) throw new Error('Android ID unavailable');
|
|
10
|
-
} else if (platform === 'ios') {
|
|
11
|
-
const key = `ota-device-v1.${namespace}`;
|
|
12
|
-
seed = await readSecure(key);
|
|
13
|
-
if (!seed) {
|
|
14
|
-
seed = uuid();
|
|
15
|
-
await writeSecure(key, seed);
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
return digest(`${namespace}:${platform}:${seed}`);
|
|
21
|
-
}
|
|
22
|
-
return () => {
|
|
23
|
-
if (!flight) flight = resolve().catch((error) => { flight = undefined; throw error; });
|
|
24
|
-
return flight;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type * as Updates from 'expo-updates';
|
|
3
|
-
|
|
4
|
-
export declare function start(): void;
|
|
5
|
-
export declare function getInstallationId(): Promise<string | null>;
|
|
6
|
-
export declare function getDeviceId(): Promise<string | null>;
|
|
7
|
-
/** Low-level compatibility API; new screens should use the shared lifecycle hook. */
|
|
8
|
-
export declare const checkForUpdateAsync: typeof Updates.checkForUpdateAsync;
|
|
9
|
-
export declare const fetchUpdateAsync: typeof Updates.fetchUpdateAsync;
|
|
10
|
-
|
|
11
|
-
export interface OtaPolicy {
|
|
12
|
-
schemaVersion: number;
|
|
13
|
-
delivery: 'manual' | 'background';
|
|
14
|
-
guard?: { action: string; payload?: unknown };
|
|
15
|
-
}
|
|
16
|
-
export interface OtaOptions {
|
|
17
|
-
/** Check at startup/foreground, at most once per minute. Default false. */
|
|
18
|
-
autoCheck?: boolean;
|
|
19
|
-
/** Download eligible manual releases automatically. Default false. */
|
|
20
|
-
autoUpdate?: boolean;
|
|
21
|
-
/** Reload downloaded non-background releases while active. Default false. */
|
|
22
|
-
autoReload?: boolean;
|
|
23
|
-
guardHandlers?: Record<string, (context: { action: string; payload: unknown; manifest: unknown }) =>
|
|
24
|
-
'allow' | 'block' | Promise<'allow' | 'block'>>;
|
|
25
|
-
}
|
|
26
|
-
export interface OtaController {
|
|
27
|
-
enabled: boolean;
|
|
28
|
-
status: 'idle' | 'checking' | 'downloading' | 'reloading' | 'opening-store';
|
|
29
|
-
installationId: string | null;
|
|
30
|
-
deviceId: string | null;
|
|
31
|
-
available: boolean;
|
|
32
|
-
pending: boolean;
|
|
33
|
-
candidate: { type: 'new' | 'rollback'; manifest: unknown } | null;
|
|
34
|
-
policy: OtaPolicy | null;
|
|
35
|
-
blocked: boolean;
|
|
36
|
-
blockReason: string | null;
|
|
37
|
-
error: Error | null;
|
|
38
|
-
isBusy: boolean;
|
|
39
|
-
check(): Promise<Updates.UpdateCheckResult>;
|
|
40
|
-
download(): Promise<Updates.UpdateFetchResult>;
|
|
41
|
-
reload(): Promise<void>;
|
|
42
|
-
retry(): Promise<Updates.UpdateCheckResult>;
|
|
43
|
-
openStore(): Promise<void>;
|
|
44
|
-
}
|
|
45
|
-
export declare function useOtaUpdates(options?: OtaOptions): OtaController;
|
|
46
|
-
export declare function OtaUpdateGate(props: { controller: OtaController; children?: ReactNode;
|
|
47
|
-
renderBlocked?: (controller: OtaController) => ReactNode }): ReactNode;
|