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.
Files changed (103) hide show
  1. package/dist/template/README.md +1 -1
  2. package/dist/template/app/updates/[encodedKey]/page.tsx +55 -33
  3. package/dist/template/app/updates/devices/page.tsx +13 -7
  4. package/dist/template/app/updates/embedded/page.tsx +25 -13
  5. package/dist/template/app/updates/emergency-redirects/page.tsx +70 -38
  6. package/dist/template/app/updates/page.tsx +33 -20
  7. package/dist/template/components/admin/admin-shell.tsx +11 -5
  8. package/dist/template/components/admin/language-switcher.tsx +5 -2
  9. package/dist/template/components/ui/dialog.tsx +13 -4
  10. package/dist/template/components/ui/sheet.tsx +6 -2
  11. package/dist/template/components/ui/sidebar.tsx +62 -17
  12. package/dist/template/docs/admin-ui.md +18 -24
  13. package/dist/template/docs/device-targeting.md +4 -5
  14. package/dist/template/docs/expo-app-setup.md +8 -12
  15. package/dist/template/docs/getting-started.md +5 -5
  16. package/dist/template/docs/getting-started.ru.md +11 -544
  17. package/dist/template/docs/index.md +1 -1
  18. package/dist/template/docs/installation-telemetry.md +4 -4
  19. package/dist/template/docs/operations-guide.md +1 -1
  20. package/dist/template/docs/ota-client-lifecycle.md +46 -42
  21. package/dist/template/docs/ota-emergency-recovery.md +34 -57
  22. package/dist/template/docs/ru/admin-ui.md +29 -0
  23. package/dist/template/docs/ru/device-targeting.md +59 -0
  24. package/dist/template/docs/ru/doctor.md +98 -0
  25. package/dist/template/docs/ru/expo-app-setup.md +497 -0
  26. package/dist/template/docs/ru/getting-started.md +391 -0
  27. package/dist/template/docs/ru/index.md +50 -0
  28. package/dist/template/docs/ru/installation-telemetry.md +125 -0
  29. package/dist/template/docs/ru/npm-installer.md +71 -0
  30. package/dist/template/docs/ru/operations-guide.md +317 -0
  31. package/dist/template/docs/ru/ota-client-lifecycle.md +167 -0
  32. package/dist/template/docs/ru/ota-emergency-recovery.md +108 -0
  33. package/dist/template/docs/ru/ota-update-policy.md +67 -0
  34. package/dist/template/docs/ru/publishing-npm-installer.md +49 -0
  35. package/dist/template/docs/ru/supabase-setup.md +120 -0
  36. package/dist/template/docs/uk/admin-ui.md +29 -0
  37. package/dist/template/docs/uk/device-targeting.md +59 -0
  38. package/dist/template/docs/uk/doctor.md +98 -0
  39. package/dist/template/docs/uk/expo-app-setup.md +497 -0
  40. package/dist/template/docs/uk/getting-started.md +391 -0
  41. package/dist/template/docs/uk/index.md +50 -0
  42. package/dist/template/docs/uk/installation-telemetry.md +125 -0
  43. package/dist/template/docs/uk/npm-installer.md +71 -0
  44. package/dist/template/docs/uk/operations-guide.md +317 -0
  45. package/dist/template/docs/uk/ota-client-lifecycle.md +167 -0
  46. package/dist/template/docs/uk/ota-emergency-recovery.md +108 -0
  47. package/dist/template/docs/uk/ota-update-policy.md +67 -0
  48. package/dist/template/docs/uk/publishing-npm-installer.md +49 -0
  49. package/dist/template/docs/uk/supabase-setup.md +120 -0
  50. package/dist/template/package-lock.json +589 -0
  51. package/dist/template/package.json +2 -0
  52. package/dist/template/scripts/lib/device-identity.test.ts +2 -2
  53. package/dist/template/scripts/lib/doctor.mjs +3 -3
  54. package/dist/template/scripts/lib/doctor.test.mjs +1 -1
  55. package/dist/template/scripts/lib/ota-client-configurator.mjs +116 -34
  56. package/dist/template/scripts/lib/ota-client-configurator.test.ts +210 -61
  57. package/dist/template/scripts/lib/ota-client.test.ts +1 -1
  58. package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +435 -118
  59. package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +243 -86
  60. package/dist/template/scripts/lib/ota-update-controller.test.ts +10 -9
  61. package/dist/template/scripts/lib/ota-updates-ui.test.tsx +154 -0
  62. package/dist/template/scripts/tests/fixtures/react-native-ui.tsx +34 -0
  63. package/dist/template/scripts/tests/ota-client-types.mjs +69 -0
  64. package/dist/template/src/client/devices/analytics.tsx +21 -8
  65. package/dist/template/src/client/devices/device-name.tsx +3 -1
  66. package/dist/template/src/client/devices/registry.tsx +38 -19
  67. package/dist/template/src/client/devices/version-adoption-chart.tsx +22 -10
  68. package/dist/template/src/client/distribution-control.tsx +27 -14
  69. package/dist/template/src/client/guard-action-combobox.test.ts +1 -1
  70. package/dist/template/src/client/guard-action-combobox.tsx +16 -10
  71. package/dist/template/src/client/i18n/en.json +203 -1
  72. package/dist/template/src/client/i18n/language-switching.test.tsx +224 -0
  73. package/dist/template/src/client/i18n/messages.test.ts +102 -19
  74. package/dist/template/src/client/i18n/messages.ts +31 -16
  75. package/dist/template/src/client/i18n/provider.tsx +6 -3
  76. package/dist/template/src/client/i18n/ru.json +488 -0
  77. package/dist/template/src/client/i18n/uk.json +488 -0
  78. package/dist/template/src/client/i18n/use-formatters.ts +5 -0
  79. package/dist/template/src/client/update-audience-editor.tsx +18 -11
  80. package/dist/template/src/client/update-policy-editor.tsx +64 -39
  81. package/dist/template/templates/expo-app/ota-client/README.md +16 -2
  82. package/dist/template/templates/expo-app/ota-client/controller.ts +107 -0
  83. package/dist/template/templates/expo-app/ota-client/device-identity.ts +48 -0
  84. package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +18 -9
  85. package/dist/template/templates/expo-app/ota-client/index.ts +16 -0
  86. package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +97 -0
  87. package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +293 -0
  88. package/dist/template/templates/expo-app/ota-client/runtime.ts +153 -0
  89. package/dist/template/templates/expo-app/ota-client/types.ts +85 -0
  90. package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +25 -0
  91. package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +196 -0
  92. package/dist/template/tsconfig.json +3 -1
  93. package/dist/template/vitest.config.mts +3 -0
  94. package/dist/template-manifest.json +302 -127
  95. package/package.json +1 -1
  96. package/dist/template/templates/expo-app/ota-client/controller.js +0 -60
  97. package/dist/template/templates/expo-app/ota-client/device-identity.js +0 -26
  98. package/dist/template/templates/expo-app/ota-client/index.d.ts +0 -47
  99. package/dist/template/templates/expo-app/ota-client/index.js +0 -3
  100. package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.js +0 -48
  101. package/dist/template/templates/expo-app/ota-client/model/update-controller.js +0 -182
  102. package/dist/template/templates/expo-app/ota-client/runtime.js +0 -112
  103. package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.js +0 -56
@@ -0,0 +1,69 @@
1
+ import { cp, mkdtemp, writeFile, symlink, rm } from "node:fs/promises";
2
+ import { createRequire } from "node:module";
3
+ import { spawnSync } from "node:child_process";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ // Check the generated source against the target application's actual Expo/RN types.
9
+ const app = process.argv[2];
10
+ if (!app)
11
+ throw new Error(
12
+ "Usage: node scripts/tests/ota-client-types.mjs /path/to/expo-app",
13
+ );
14
+ const require = createRequire(path.resolve(app, "package.json"));
15
+ const temp = await mkdtemp(path.join(os.tmpdir(), "ota-client-types-"));
16
+ try {
17
+ const template = fileURLToPath(
18
+ new URL("../../templates/expo-app/ota-client", import.meta.url),
19
+ );
20
+ await cp(template, path.join(temp, "ota-client"), { recursive: true });
21
+ await symlink(
22
+ path.resolve(app, "node_modules"),
23
+ path.join(temp, "node_modules"),
24
+ "dir",
25
+ );
26
+ await writeFile(
27
+ path.join(temp, "ota-client/config.json"),
28
+ JSON.stringify({
29
+ channel: "test",
30
+ identityNamespace: "test",
31
+ heartbeatUrl: "https://example.org/api/device-heartbeat",
32
+ }),
33
+ );
34
+ await writeFile(
35
+ path.join(temp, "tsconfig.json"),
36
+ JSON.stringify({
37
+ compilerOptions: {
38
+ strict: true,
39
+ noEmit: true,
40
+ target: "ES2022",
41
+ module: "ESNext",
42
+ moduleResolution: "bundler",
43
+ jsx: "react-jsx",
44
+ esModuleInterop: true,
45
+ skipLibCheck: true,
46
+ resolveJsonModule: true,
47
+ types: ["react", "react-native"],
48
+ },
49
+ include: ["ota-client/**/*"],
50
+ }),
51
+ );
52
+ const result = spawnSync(
53
+ process.execPath,
54
+ [
55
+ require.resolve("typescript/bin/tsc"),
56
+ "--project",
57
+ path.join(temp, "tsconfig.json"),
58
+ ],
59
+ { stdio: "inherit" },
60
+ );
61
+ if (result.error) throw result.error;
62
+ if (result.status !== 0)
63
+ throw new Error("Generated OTA client typecheck failed.");
64
+ console.log(
65
+ "Generated OTA client passed strict TypeScript with the application dependencies.",
66
+ );
67
+ } finally {
68
+ await rm(temp, { recursive: true, force: true });
69
+ }
@@ -15,7 +15,12 @@ import {
15
15
  CardHeader,
16
16
  CardTitle,
17
17
  } from "@/components/ui/card";
18
- import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
18
+ import {
19
+ Tabs,
20
+ TabsContent,
21
+ TabsList,
22
+ TabsTrigger,
23
+ } from "@/components/ui/tabs";
19
24
  import {
20
25
  Table,
21
26
  TableBody,
@@ -32,7 +37,7 @@ export function useKindNames() {
32
37
  const { t } = useI18n();
33
38
  return {
34
39
  ota: "OTA",
35
- embedded: "Embedded",
40
+ embedded: t("Embedded"),
36
41
  unknown: t("Не определён"),
37
42
  };
38
43
  }
@@ -43,7 +48,7 @@ export function Analytics({ report }: { report: DevicesReport }) {
43
48
  const kinds = [
44
49
  { label: "OTA", value: s.otaInstallations, color: "var(--chart-1)" },
45
50
  {
46
- label: "Embedded",
51
+ label: t("Embedded"),
47
52
  value: s.embeddedInstallations,
48
53
  color: "var(--chart-2)",
49
54
  },
@@ -211,7 +216,9 @@ export function Analytics({ report }: { report: DevicesReport }) {
211
216
  {report.activity.map((day) => (
212
217
  <TableRow key={day.date}>
213
218
  <TableCell>{date(day.date)}</TableCell>
214
- <TableCell>{day.activeInstallations ?? "—"}</TableCell>
219
+ <TableCell>
220
+ {day.activeInstallations ?? "—"}
221
+ </TableCell>
215
222
  <TableCell>{day.newInstallations ?? "—"}</TableCell>
216
223
  <TableCell>
217
224
  {day.coverage === "complete"
@@ -238,7 +245,9 @@ export function Analytics({ report }: { report: DevicesReport }) {
238
245
  <div
239
246
  className="flex h-3 overflow-hidden rounded-full bg-muted"
240
247
  role="img"
241
- aria-label={kinds.map((k) => `${k.label}: ${k.value}`).join(", ")}
248
+ aria-label={kinds
249
+ .map((k) => `${k.label}: ${k.value}`)
250
+ .join(", ")}
242
251
  >
243
252
  {kinds.map((k) => (
244
253
  <div
@@ -291,8 +300,12 @@ export function Analytics({ report }: { report: DevicesReport }) {
291
300
  <CardContent>
292
301
  <Tabs defaultValue="adoption">
293
302
  <TabsList className="mb-4">
294
- <TabsTrigger value="adoption">{t("Текущие версии")}</TabsTrigger>
295
- <TabsTrigger value="retention">{t("Возвращаемость")}</TabsTrigger>
303
+ <TabsTrigger value="adoption">
304
+ {t("Текущие версии")}
305
+ </TabsTrigger>
306
+ <TabsTrigger value="retention">
307
+ {t("Возвращаемость")}
308
+ </TabsTrigger>
296
309
  </TabsList>
297
310
  <TabsContent value="adoption">
298
311
  <p className="mb-3 text-xs text-muted-foreground">
@@ -306,7 +319,7 @@ export function Analytics({ report }: { report: DevicesReport }) {
306
319
  <TableHead>{t("Неделя · UTC")}</TableHead>
307
320
  <TableHead>{t("Установки")}</TableHead>
308
321
  <TableHead>OTA</TableHead>
309
- <TableHead>Embedded</TableHead>
322
+ <TableHead>{t("Embedded")}</TableHead>
310
323
  <TableHead>{t("Не определён")}</TableHead>
311
324
  </TableRow>
312
325
  </TableHeader>
@@ -47,7 +47,9 @@ export function DeviceName({
47
47
  });
48
48
  if (!r.ok)
49
49
  throw new Error((await r.json()).error || "Не удалось сохранить");
50
- setStatus(t("Имя сохранено — устройство можно выбрать в аудитории OTA."));
50
+ setStatus(
51
+ "Имя сохранено — устройство можно выбрать в аудитории OTA.",
52
+ );
51
53
  } catch (e) {
52
54
  setStatus((e as Error).message);
53
55
  } finally {
@@ -4,7 +4,13 @@ import { useI18n } from "@/src/client/i18n/provider";
4
4
 
5
5
  import { DeviceName } from "./device-name";
6
6
  import { useRef, useState } from "react";
7
- import { Copy, Check, ChevronLeft, ChevronRight, Search } from "lucide-react";
7
+ import {
8
+ Copy,
9
+ Check,
10
+ ChevronLeft,
11
+ ChevronRight,
12
+ Search,
13
+ } from "lucide-react";
8
14
  import { Button } from "@/components/ui/button";
9
15
  import { Badge } from "@/components/ui/badge";
10
16
  import {
@@ -14,7 +20,12 @@ import {
14
20
  CardDescription,
15
21
  CardContent,
16
22
  } from "@/components/ui/card";
17
- import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
23
+ import {
24
+ Tabs,
25
+ TabsList,
26
+ TabsTrigger,
27
+ TabsContent,
28
+ } from "@/components/ui/tabs";
18
29
  import {
19
30
  Table,
20
31
  TableHeader,
@@ -85,7 +96,7 @@ export function Registry({
85
96
  const { t } = useI18n();
86
97
  const opener = useRef<HTMLButtonElement | null>(null);
87
98
  const kindNames = useKindNames();
88
- const { number, fullDate } = useFormatters();
99
+ const { number, fullDate, calendarDate } = useFormatters();
89
100
  const [selected, setSelected] = useState<DeviceInstallation | null>(null);
90
101
  return (
91
102
  <>
@@ -142,7 +153,7 @@ export function Registry({
142
153
  </Button>
143
154
  <p className="mt-1 text-xs text-muted-foreground">
144
155
  {t("С ")}
145
- {fullDate(d.first_seen_at).split(",")[0]}
156
+ {calendarDate(d.first_seen_at)}
146
157
  </p>
147
158
  </TableCell>
148
159
  <TableCell>
@@ -171,14 +182,16 @@ export function Registry({
171
182
  {d.runtime_version}
172
183
  </p>
173
184
  <p className="mt-1 text-xs text-muted-foreground">
174
- Native {d.native_version || "—"} (
185
+ {t("Native")} {d.native_version || "—"} (
175
186
  {d.native_build || "—"})
176
187
  </p>
177
188
  </TableCell>
178
189
  <TableCell>
179
190
  <Badge
180
191
  variant={
181
- d.launch_kind === "ota" ? "default" : "secondary"
192
+ d.launch_kind === "ota"
193
+ ? "default"
194
+ : "secondary"
182
195
  }
183
196
  >
184
197
  {kindNames[d.launch_kind]}
@@ -188,7 +201,7 @@ export function Registry({
188
201
  variant="destructive"
189
202
  className="mt-1 block w-fit"
190
203
  >
191
- Emergency
204
+ {t("Emergency")}
192
205
  </Badge>
193
206
  )}
194
207
  </TableCell>
@@ -243,9 +256,12 @@ export function Registry({
243
256
  size="sm"
244
257
  variant="outline"
245
258
  disabled={
246
- loading || report.offset + report.pageSize >= report.total
259
+ loading ||
260
+ report.offset + report.pageSize >= report.total
261
+ }
262
+ onClick={() =>
263
+ paginate(report.offset + report.pageSize)
247
264
  }
248
- onClick={() => paginate(report.offset + report.pageSize)}
249
265
  >
250
266
  {t("Далее")}
251
267
  <ChevronRight />
@@ -259,12 +275,14 @@ export function Registry({
259
275
  <TableRow>
260
276
  <TableHead>{t("Версия / ID")}</TableHead>
261
277
  <TableHead>{t("Платформа / канал")}</TableHead>
262
- <TableHead>Runtime / native</TableHead>
278
+ <TableHead>{t("Runtime / native")}</TableHead>
263
279
  <TableHead>{t("Запуск")}</TableHead>
264
280
  <TableHead className="text-right">
265
281
  {t("Установки")}
266
282
  </TableHead>
267
- <TableHead className="text-right">{t("Доля")}</TableHead>
283
+ <TableHead className="text-right">
284
+ {t("Доля")}
285
+ </TableHead>
268
286
  </TableRow>
269
287
  </TableHeader>
270
288
  <TableBody>
@@ -295,7 +313,8 @@ export function Registry({
295
313
  <TableCell>
296
314
  {v.runtime_version}
297
315
  <p className="text-xs text-muted-foreground">
298
- {v.native_version || "—"} ({v.native_build || "—"})
316
+ {v.native_version || "—"} ({v.native_build || "—"}
317
+ )
299
318
  </p>
300
319
  </TableCell>
301
320
  <TableCell>
@@ -353,21 +372,21 @@ export function Registry({
353
372
  {selected && (
354
373
  <dl className="space-y-5 px-6 pb-8">
355
374
  {[
356
- ["Installation ID", selected.installation_id],
357
- ["Device ID", selected.device_id || "—"],
375
+ [t("Installation ID"), selected.installation_id],
376
+ [t("Device ID"), selected.device_id || "—"],
358
377
  [t("Платформа"), selected.platform],
359
378
  [t("Канал"), selected.channel],
360
- ["Runtime", selected.runtime_version],
379
+ [t("Runtime"), selected.runtime_version],
361
380
  [
362
- "Native version / build",
381
+ t("Native version / build"),
363
382
  `${selected.native_version || "—"} (${selected.native_build || "—"})`,
364
383
  ],
365
384
  [t("Тип запуска"), kindNames[selected.launch_kind]],
366
385
  [t("Название обновления"), selected.update_label || "—"],
367
- ["OTA artifact ID", selected.resolved_update_id || "—"],
368
- ["Launch update ID", selected.reported_update_id || "—"],
386
+ [t("OTA artifact ID"), selected.resolved_update_id || "—"],
387
+ [t("Launch update ID"), selected.reported_update_id || "—"],
369
388
  [
370
- "Emergency launch",
389
+ t("Emergency launch"),
371
390
  selected.emergency_launch ? t("Да") : t("Нет"),
372
391
  ],
373
392
  [t("Первый heartbeat"), fullDate(selected.first_seen_at)],
@@ -25,7 +25,7 @@ function useKindLabels() {
25
25
  const { t } = useI18n();
26
26
  return {
27
27
  ota: "OTA",
28
- embedded: "Embedded",
28
+ embedded: t("Embedded"),
29
29
  unknown: t("Не определён"),
30
30
  };
31
31
  }
@@ -52,8 +52,12 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
52
52
  <header className="mb-4 flex flex-wrap items-center justify-between gap-3">
53
53
  <div className="flex min-w-0 flex-wrap items-center gap-2">
54
54
  <GitBranch className="size-4 shrink-0 text-muted-foreground" />
55
- <span className="text-xs text-muted-foreground">{t("Канал")}</span>
56
- <h4 className="break-all text-sm font-semibold">{scope.channel}</h4>
55
+ <span className="text-xs text-muted-foreground">
56
+ {t("Канал")}
57
+ </span>
58
+ <h4 className="break-all text-sm font-semibold">
59
+ {scope.channel}
60
+ </h4>
57
61
  <Badge variant="outline">
58
62
  {scope.platform === "ios" ? "iOS" : "Android"}
59
63
  </Badge>
@@ -93,11 +97,13 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
93
97
  title={version.updateId || undefined}
94
98
  >
95
99
  {kindLabels[version.kind]}
96
- {version.updateId ? ` ${version.updateId.slice(0, 8)}` : ""}
100
+ {version.updateId
101
+ ? ` ${version.updateId.slice(0, 8)}`
102
+ : ""}
97
103
  </Badge>
98
104
  </div>
99
105
  <p className="mt-1 break-words text-xs leading-5 text-muted-foreground">
100
- Native: {version.nativeBuilds.join(", ")}
106
+ {t("Native:")} {version.nativeBuilds.join(", ")}
101
107
  </p>
102
108
  {version.updateId && (
103
109
  <details className="mt-1 text-xs text-muted-foreground">
@@ -151,7 +157,8 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
151
157
  <p className="text-xs text-muted-foreground">
152
158
  {t("Показано ")}
153
159
  {visible.length} {t(" из ")}
154
- {scope.versions.length} {t(" версий. Доли учитывают весь блок.")}
160
+ {scope.versions.length}{" "}
161
+ {t(" версий. Доли учитывают весь блок.")}
155
162
  </p>
156
163
  <Button
157
164
  variant="outline"
@@ -169,7 +176,11 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
169
176
  </section>
170
177
  );
171
178
  }
172
- export function VersionAdoptionChart({ report }: { report: DevicesReport }) {
179
+ export function VersionAdoptionChart({
180
+ report,
181
+ }: {
182
+ report: DevicesReport;
183
+ }) {
173
184
  const kindLabels = useKindLabels();
174
185
  const { number } = useFormatters();
175
186
  const { t } = useI18n();
@@ -210,7 +221,8 @@ export function VersionAdoptionChart({ report }: { report: DevicesReport }) {
210
221
  <i
211
222
  className="size-2 rounded-full"
212
223
  style={{
213
- background: kindColors[kind as keyof typeof kindColors],
224
+ background:
225
+ kindColors[kind as keyof typeof kindColors],
214
226
  }}
215
227
  />
216
228
  {label}
@@ -221,13 +233,13 @@ export function VersionAdoptionChart({ report }: { report: DevicesReport }) {
221
233
  {runtimes.map((runtime) => (
222
234
  <section
223
235
  key={runtime.runtime}
224
- aria-label={`Runtime ${runtime.runtime}`}
236
+ aria-label={t("Runtime {0}", [runtime.runtime])}
225
237
  >
226
238
  <header className="mb-3 flex flex-wrap items-center justify-between gap-3">
227
239
  <h3 className="flex min-w-0 items-center gap-2 text-sm">
228
240
  <Layers className="size-4 shrink-0 text-muted-foreground" />
229
241
  <span className="shrink-0 text-muted-foreground">
230
- Runtime
242
+ {t("Runtime")}
231
243
  </span>
232
244
  <span className="break-all font-semibold">
233
245
  {runtime.runtime}
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import type { TranslationMessage } from "@/src/client/i18n/messages";
2
3
  import { useI18n } from "@/src/client/i18n/provider";
3
4
 
4
5
  import { Textarea } from "@/components/ui/textarea";
@@ -6,7 +7,12 @@ import { Textarea } from "@/components/ui/textarea";
6
7
  import { Button } from "@/components/ui/button";
7
8
  import { Badge } from "@/components/ui/badge";
8
9
  import { Card } from "@/components/ui/card";
9
- import { ShieldCheck, ShieldAlert, ChevronDown, RefreshCw } from "lucide-react";
10
+ import {
11
+ ShieldCheck,
12
+ ShieldAlert,
13
+ ChevronDown,
14
+ RefreshCw,
15
+ } from "lucide-react";
10
16
 
11
17
  import {
12
18
  AdminApiError,
@@ -17,8 +23,9 @@ import type { DistributionControlResponse } from "./admin-types";
17
23
  import { useCallback, useEffect, useState } from "react";
18
24
 
19
25
  export function useDistributionControlState() {
20
- const { t } = useI18n();
21
- const [state, setState] = useState<DistributionControlResponse | null>(null);
26
+ const [state, setState] = useState<DistributionControlResponse | null>(
27
+ null,
28
+ );
22
29
  const [loading, setLoading] = useState(true);
23
30
  const [error, setError] = useState("");
24
31
 
@@ -46,11 +53,14 @@ export function useDistributionControlState() {
46
53
  return () => window.clearTimeout(timeoutId);
47
54
  }, [refresh]);
48
55
 
49
- return { state, setState, loading, error: t(error), setError, refresh };
56
+ return { state, setState, loading, error, setError, refresh };
50
57
  }
51
58
 
52
- function formatChangedBy(state: DistributionControlResponse): string {
53
- const role = state.changedBy.role ? ` (${state.changedBy.role})` : "";
59
+ function formatChangedBy(
60
+ state: DistributionControlResponse,
61
+ t: ReturnType<typeof useI18n>["t"],
62
+ ): string {
63
+ const role = state.changedBy.role ? ` (${t(state.changedBy.role)})` : "";
54
64
  return `${state.changedBy.label}${role}`;
55
65
  }
56
66
 
@@ -89,11 +99,13 @@ export function DistributionControlBanner({
89
99
 
90
100
  return (
91
101
  <section className="rounded-lg border border-destructive/25 bg-destructive/5 p-4 text-destructive">
92
- <p className="font-semibold">{t("Распространение OTA остановлено")}</p>
102
+ <p className="font-semibold">
103
+ {t("Распространение OTA остановлено")}
104
+ </p>
93
105
  <p className="mt-1 text-sm">{state.reason}</p>
94
106
  <p className="mt-2 text-xs">
95
107
  {new Date(state.changedAt).toLocaleString(formatLocale)} ·{" "}
96
- {formatChangedBy(state)}
108
+ {formatChangedBy(state, t)}
97
109
  </p>
98
110
  </section>
99
111
  );
@@ -105,7 +117,7 @@ export default function DistributionControl() {
105
117
  useDistributionControlState();
106
118
  const [reason, setReason] = useState("");
107
119
  const [saving, setSaving] = useState(false);
108
- const [message, setMessage] = useState("");
120
+ const [message, setMessage] = useState<TranslationMessage>("");
109
121
  const [expanded, setExpanded] = useState(false);
110
122
 
111
123
  const changeState = async (blocked: boolean) => {
@@ -143,8 +155,8 @@ export default function DistributionControl() {
143
155
  setReason("");
144
156
  setMessage(
145
157
  blocked
146
- ? t("OTA-распространение остановлено.")
147
- : t("OTA-распространение возобновлено."),
158
+ ? "OTA-распространение остановлено."
159
+ : "OTA-распространение возобновлено.",
148
160
  );
149
161
  } catch (saveError: unknown) {
150
162
  if (saveError instanceof AdminApiError && saveError.status === 409) {
@@ -222,7 +234,7 @@ export default function DistributionControl() {
222
234
  />
223
235
  </Button>
224
236
  ) : state ? (
225
- <Badge variant="outline">Read only · updates:write</Badge>
237
+ <Badge variant="outline">{t("Read only · updates:write")}</Badge>
226
238
  ) : null}
227
239
  </div>
228
240
  {expanded && state?.canWrite && (
@@ -233,7 +245,8 @@ export default function DistributionControl() {
233
245
  <p className="text-xs text-muted-foreground">
234
246
  {t("Изменено: ")}
235
247
  {new Date(state.changedAt).toLocaleString(formatLocale)} ·{" "}
236
- {formatChangedBy(state)} · version {state.version}
248
+ {formatChangedBy(state, t)}{" "}
249
+ {t(" · version {0}", [state.version])}
237
250
  </p>
238
251
  {!state.blocked && (
239
252
  <label className="block space-y-2 text-sm font-medium">
@@ -277,7 +290,7 @@ export default function DistributionControl() {
277
290
  role="status"
278
291
  className="border-t px-4 py-3 text-sm text-emerald-700 dark:text-emerald-400"
279
292
  >
280
- {message}
293
+ {t(message)}
281
294
  </p>
282
295
  )}
283
296
  </Card>
@@ -10,7 +10,7 @@ describe("Guard action combobox semantics", () => {
10
10
  it("uses a named dialog popup instead of interactive listbox options", () => {
11
11
  expect(source).toContain('aria-haspopup="dialog"');
12
12
  expect(source).toContain('role="dialog"');
13
- expect(source).toContain('aria-label="Guard action catalog"');
13
+ expect(source).toContain('aria-label={t("Guard action catalog")}');
14
14
  expect(source).not.toMatch(/role="(?:listbox|option)"/);
15
15
  });
16
16
 
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { useI18n } from "@/src/client/i18n/provider";
2
3
 
3
4
  import { Input } from "@/components/ui/input";
4
5
 
@@ -32,6 +33,7 @@ export default function GuardActionCombobox({
32
33
  onDelete,
33
34
  onRetry,
34
35
  }: Props) {
36
+ const { t } = useI18n();
35
37
  const generatedId = useId();
36
38
  const popupId = `${generatedId}-popup`;
37
39
  const errorId = `${generatedId}-error`;
@@ -144,7 +146,7 @@ export default function GuardActionCombobox({
144
146
  readOnly={selectionDisabled}
145
147
  aria-disabled={selectionDisabled}
146
148
  role="combobox"
147
- aria-label="Rule action"
149
+ aria-label={t("Rule action")}
148
150
  aria-autocomplete="list"
149
151
  aria-haspopup="dialog"
150
152
  aria-expanded={open}
@@ -159,13 +161,13 @@ export default function GuardActionCombobox({
159
161
  }}
160
162
  onKeyDown={handleKeyDown}
161
163
  className="w-full"
162
- placeholder="Action (required)"
164
+ placeholder={t("Action (required)")}
163
165
  />
164
166
  {open ? (
165
167
  <div
166
168
  id={popupId}
167
169
  role="dialog"
168
- aria-label="Guard action catalog"
170
+ aria-label={t("Guard action catalog")}
169
171
  className="absolute z-20 mt-1 max-h-60 w-full overflow-auto rounded-lg border bg-popover p-1 text-popover-foreground shadow-md"
170
172
  >
171
173
  {filteredOptions.map((option, index) => (
@@ -179,7 +181,9 @@ export default function GuardActionCombobox({
179
181
  type="button"
180
182
  tabIndex={-1}
181
183
  disabled={selectionDisabled}
182
- aria-current={option.actionKey === value ? "true" : undefined}
184
+ aria-current={
185
+ option.actionKey === value ? "true" : undefined
186
+ }
183
187
  onMouseDown={(event) => event.preventDefault()}
184
188
  onClick={() => chooseOption(option)}
185
189
  className="min-w-0 flex-1 truncate px-3 py-2 text-left text-sm disabled:cursor-default"
@@ -190,8 +194,10 @@ export default function GuardActionCombobox({
190
194
  {option.persisted && canMutateCatalog ? (
191
195
  <button
192
196
  type="button"
193
- aria-label={`Delete ${option.actionKey} from action catalog`}
194
- title="Delete from catalog"
197
+ aria-label={t("Delete {0} from action catalog", [
198
+ option.actionKey,
199
+ ])}
200
+ title={t("Delete from catalog")}
195
201
  onMouseDown={(event) => event.preventDefault()}
196
202
  onClick={(event) => {
197
203
  event.stopPropagation();
@@ -223,12 +229,12 @@ export default function GuardActionCombobox({
223
229
  activeIndex === filteredOptions.length ? "bg-accent" : ""
224
230
  }`}
225
231
  >
226
- Create “{creatableValue}”
232
+ {t("Create “{0}”", [creatableValue])}
227
233
  </button>
228
234
  ) : null}
229
235
  {filteredOptions.length === 0 && !showCreate ? (
230
236
  <p className="px-3 py-2 text-sm text-muted-foreground">
231
- No matching actions
237
+ {t("No matching actions")}
232
238
  </p>
233
239
  ) : null}
234
240
  </div>
@@ -239,14 +245,14 @@ export default function GuardActionCombobox({
239
245
  role="status"
240
246
  className="mt-1 flex items-center gap-2 text-xs text-amber-700 dark:text-amber-300"
241
247
  >
242
- <span>{inputError || mutationError}</span>
248
+ <span>{t(inputError || mutationError || "")}</span>
243
249
  {mutationError && onRetry ? (
244
250
  <button
245
251
  type="button"
246
252
  onClick={() => void onRetry()}
247
253
  className="underline"
248
254
  >
249
- Retry
255
+ {t("Retry")}
250
256
  </button>
251
257
  ) : null}
252
258
  </div>