create-expo-updates-server 0.2.1 → 0.4.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/README.md +1 -1
- package/dist/template/app/updates/[encodedKey]/page.tsx +55 -33
- package/dist/template/app/updates/devices/page.tsx +13 -7
- package/dist/template/app/updates/embedded/page.tsx +25 -13
- package/dist/template/app/updates/emergency-redirects/page.tsx +70 -38
- package/dist/template/app/updates/page.tsx +33 -20
- package/dist/template/components/admin/admin-shell.tsx +11 -5
- package/dist/template/components/admin/language-switcher.tsx +5 -2
- package/dist/template/components/ui/dialog.tsx +13 -4
- package/dist/template/components/ui/sheet.tsx +6 -2
- package/dist/template/components/ui/sidebar.tsx +62 -17
- package/dist/template/docs/admin-ui.md +18 -24
- package/dist/template/docs/device-targeting.md +4 -5
- 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 +11 -544
- package/dist/template/docs/index.md +1 -1
- package/dist/template/docs/installation-telemetry.md +4 -4
- package/dist/template/docs/operations-guide.md +1 -1
- package/dist/template/docs/ota-client-lifecycle.md +46 -42
- package/dist/template/docs/ota-emergency-recovery.md +34 -57
- package/dist/template/docs/ru/admin-ui.md +29 -0
- package/dist/template/docs/ru/device-targeting.md +59 -0
- package/dist/template/docs/ru/doctor.md +98 -0
- package/dist/template/docs/ru/expo-app-setup.md +497 -0
- package/dist/template/docs/ru/getting-started.md +391 -0
- package/dist/template/docs/ru/index.md +50 -0
- package/dist/template/docs/ru/installation-telemetry.md +125 -0
- package/dist/template/docs/ru/npm-installer.md +71 -0
- package/dist/template/docs/ru/operations-guide.md +317 -0
- package/dist/template/docs/ru/ota-client-lifecycle.md +167 -0
- package/dist/template/docs/ru/ota-emergency-recovery.md +108 -0
- package/dist/template/docs/ru/ota-update-policy.md +67 -0
- package/dist/template/docs/ru/publishing-npm-installer.md +49 -0
- package/dist/template/docs/ru/supabase-setup.md +120 -0
- package/dist/template/docs/uk/admin-ui.md +29 -0
- package/dist/template/docs/uk/device-targeting.md +59 -0
- package/dist/template/docs/uk/doctor.md +98 -0
- package/dist/template/docs/uk/expo-app-setup.md +497 -0
- package/dist/template/docs/uk/getting-started.md +391 -0
- package/dist/template/docs/uk/index.md +50 -0
- package/dist/template/docs/uk/installation-telemetry.md +125 -0
- package/dist/template/docs/uk/npm-installer.md +71 -0
- package/dist/template/docs/uk/operations-guide.md +317 -0
- package/dist/template/docs/uk/ota-client-lifecycle.md +167 -0
- package/dist/template/docs/uk/ota-emergency-recovery.md +108 -0
- package/dist/template/docs/uk/ota-update-policy.md +67 -0
- package/dist/template/docs/uk/publishing-npm-installer.md +49 -0
- package/dist/template/docs/uk/supabase-setup.md +120 -0
- package/dist/template/package-lock.json +589 -0
- package/dist/template/package.json +2 -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/src/client/devices/analytics.tsx +21 -8
- package/dist/template/src/client/devices/device-name.tsx +3 -1
- package/dist/template/src/client/devices/registry.tsx +38 -19
- package/dist/template/src/client/devices/version-adoption-chart.tsx +22 -10
- package/dist/template/src/client/distribution-control.tsx +27 -14
- package/dist/template/src/client/guard-action-combobox.test.ts +1 -1
- package/dist/template/src/client/guard-action-combobox.tsx +16 -10
- package/dist/template/src/client/i18n/en.json +203 -1
- package/dist/template/src/client/i18n/language-switching.test.tsx +224 -0
- package/dist/template/src/client/i18n/messages.test.ts +102 -19
- package/dist/template/src/client/i18n/messages.ts +31 -16
- package/dist/template/src/client/i18n/provider.tsx +6 -3
- package/dist/template/src/client/i18n/ru.json +488 -0
- package/dist/template/src/client/i18n/uk.json +488 -0
- package/dist/template/src/client/i18n/use-formatters.ts +5 -0
- package/dist/template/src/client/update-audience-editor.tsx +18 -11
- package/dist/template/src/client/update-policy-editor.tsx +64 -39
- 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 +302 -127
- 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
|
+
});
|