@meldgrove/ui 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +204 -2
- package/dist/components/alert-dialog.d.ts +18 -0
- package/dist/components/alert-dialog.js +44 -0
- package/dist/components/alert.d.ts +9 -0
- package/dist/components/alert.js +25 -0
- package/dist/components/avatar.d.ts +11 -0
- package/dist/components/avatar.js +24 -0
- package/dist/components/badge.d.ts +9 -0
- package/dist/components/badge.js +25 -0
- package/dist/components/breadcrumb.d.ts +11 -0
- package/dist/components/breadcrumb.js +28 -0
- package/dist/components/button-group.d.ts +11 -0
- package/dist/components/button-group.js +27 -0
- package/dist/components/button.d.ts +10 -0
- package/dist/components/button.js +36 -0
- package/dist/components/calendar.d.ts +8 -0
- package/dist/components/calendar.js +73 -0
- package/dist/components/card.d.ts +9 -0
- package/dist/components/card.js +25 -0
- package/dist/components/chart.d.ts +44 -0
- package/dist/components/chart.js +117 -0
- package/dist/components/checkbox.d.ts +4 -0
- package/dist/components/checkbox.js +10 -0
- package/dist/components/collapsible.d.ts +5 -0
- package/dist/components/collapsible.js +13 -0
- package/dist/components/command.d.ts +18 -0
- package/dist/components/command.js +35 -0
- package/dist/components/confirm-dialog.d.ts +15 -0
- package/dist/components/confirm-dialog.js +26 -0
- package/dist/components/copy-button.d.ts +6 -0
- package/dist/components/copy-button.js +23 -0
- package/dist/components/dialog.d.ts +17 -0
- package/dist/components/dialog.js +39 -0
- package/dist/components/dropdown-menu.d.ts +25 -0
- package/dist/components/dropdown-menu.js +53 -0
- package/dist/components/empty.d.ts +11 -0
- package/dist/components/empty.js +33 -0
- package/dist/components/field.d.ts +24 -0
- package/dist/components/field.js +74 -0
- package/dist/components/hover-card.d.ts +6 -0
- package/dist/components/hover-card.js +16 -0
- package/dist/components/input-group.d.ts +16 -0
- package/dist/components/input-group.js +64 -0
- package/dist/components/input.d.ts +3 -0
- package/dist/components/input.js +7 -0
- package/dist/components/item.d.ts +23 -0
- package/dist/components/item.js +67 -0
- package/dist/components/kbd.d.ts +3 -0
- package/dist/components/kbd.js +11 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/components/label.js +9 -0
- package/dist/components/native-select.d.ts +8 -0
- package/dist/components/native-select.js +14 -0
- package/dist/components/pager.d.ts +7 -0
- package/dist/components/pager.js +11 -0
- package/dist/components/pagination.d.ts +13 -0
- package/dist/components/pagination.js +30 -0
- package/dist/components/popover.d.ts +10 -0
- package/dist/components/popover.js +28 -0
- package/dist/components/progress.d.ts +4 -0
- package/dist/components/progress.js +9 -0
- package/dist/components/radio-group.d.ts +5 -0
- package/dist/components/radio-group.js +13 -0
- package/dist/components/scroll-area.d.ts +5 -0
- package/dist/components/scroll-area.js +12 -0
- package/dist/components/secret-field.d.ts +23 -0
- package/dist/components/secret-field.js +47 -0
- package/dist/components/select.d.ts +15 -0
- package/dist/components/select.js +40 -0
- package/dist/components/separator.d.ts +4 -0
- package/dist/components/separator.js +9 -0
- package/dist/components/sheet.d.ts +14 -0
- package/dist/components/sheet.js +42 -0
- package/dist/components/sidebar.d.ts +70 -0
- package/dist/components/sidebar.js +212 -0
- package/dist/components/skeleton.d.ts +2 -0
- package/dist/components/skeleton.js +6 -0
- package/dist/components/sonner.d.ts +5 -0
- package/dist/components/sonner.js +14 -0
- package/dist/components/spinner.d.ts +2 -0
- package/dist/components/spinner.js +7 -0
- package/dist/components/states.d.ts +14 -0
- package/dist/components/states.js +18 -0
- package/dist/components/switch.d.ts +6 -0
- package/dist/components/switch.js +9 -0
- package/dist/components/table.d.ts +17 -0
- package/dist/components/table.js +34 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +30 -0
- package/dist/components/textarea.d.ts +3 -0
- package/dist/components/textarea.js +7 -0
- package/dist/components/toggle-group.d.ts +9 -0
- package/dist/components/toggle-group.js +23 -0
- package/dist/components/toggle.d.ts +9 -0
- package/dist/components/toggle.js +27 -0
- package/dist/components/tooltip.d.ts +7 -0
- package/dist/components/tooltip.js +19 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.js +13 -0
- package/dist/lib/format.d.ts +8 -0
- package/dist/lib/format.js +38 -0
- package/dist/lib/i18n-core.d.ts +38 -0
- package/dist/lib/i18n-core.js +61 -0
- package/dist/lib/i18n.d.ts +11 -0
- package/dist/lib/i18n.js +19 -0
- package/dist/lib/portal.d.ts +13 -0
- package/dist/lib/portal.js +17 -0
- package/dist/lib/theme.d.ts +5 -0
- package/dist/lib/theme.js +17 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/dist/standalone/meldgrove-updates.js +57 -0
- package/dist/styles.css +11 -0
- package/dist/theme.css +62 -0
- package/dist/tokens.css +94 -0
- package/dist/updates/controller.d.ts +210 -0
- package/dist/updates/controller.js +592 -0
- package/dist/updates/core.d.ts +10 -0
- package/dist/updates/core.js +10 -0
- package/dist/updates/index.d.ts +15 -0
- package/dist/updates/index.js +15 -0
- package/dist/updates/messages.d.ts +92 -0
- package/dist/updates/messages.js +182 -0
- package/dist/updates/notice.d.ts +3 -0
- package/dist/updates/notice.js +6 -0
- package/dist/updates/react.d.ts +56 -0
- package/dist/updates/react.js +72 -0
- package/dist/updates/state.d.ts +214 -0
- package/dist/updates/state.js +396 -0
- package/dist/updates/transport.d.ts +50 -0
- package/dist/updates/transport.js +76 -0
- package/dist/updates/types.d.ts +77 -0
- package/dist/updates/types.js +68 -0
- package/dist/updates/update-button.d.ts +9 -0
- package/dist/updates/update-button.js +161 -0
- package/dist/updates/updates-settings.d.ts +17 -0
- package/dist/updates/updates-settings.js +97 -0
- package/package.json +159 -4
package/dist/styles.css
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The Meldgrove theme for Tailwind CSS 4, with the package's components as a
|
|
3
|
+
* source of class names. In the app's stylesheet, after Tailwind:
|
|
4
|
+
*
|
|
5
|
+
* @import "tailwindcss";
|
|
6
|
+
* @import "@meldgrove/ui/styles.css";
|
|
7
|
+
*/
|
|
8
|
+
@import "./theme.css";
|
|
9
|
+
|
|
10
|
+
@source "./components";
|
|
11
|
+
@source "./updates";
|
package/dist/theme.css
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The Meldgrove theme for Tailwind CSS 4: the tokens (tokens.css), the dark
|
|
3
|
+
* variant (class `dark` on <html>), the theme mapping and the base styles.
|
|
4
|
+
* Apps import styles.css, which adds the package's components as sources.
|
|
5
|
+
*/
|
|
6
|
+
@import "tw-animate-css";
|
|
7
|
+
@import "./tokens.css";
|
|
8
|
+
|
|
9
|
+
@custom-variant dark (&:is(.dark *));
|
|
10
|
+
|
|
11
|
+
@theme inline {
|
|
12
|
+
--radius-sm: calc(var(--radius) * 0.6);
|
|
13
|
+
--radius-md: calc(var(--radius) * 0.8);
|
|
14
|
+
--radius-lg: var(--radius);
|
|
15
|
+
--radius-xl: calc(var(--radius) * 1.4);
|
|
16
|
+
--radius-2xl: calc(var(--radius) * 1.8);
|
|
17
|
+
--radius-3xl: calc(var(--radius) * 2.2);
|
|
18
|
+
--radius-4xl: calc(var(--radius) * 2.6);
|
|
19
|
+
--color-background: var(--background);
|
|
20
|
+
--color-foreground: var(--foreground);
|
|
21
|
+
--color-card: var(--card);
|
|
22
|
+
--color-card-foreground: var(--card-foreground);
|
|
23
|
+
--color-popover: var(--popover);
|
|
24
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
25
|
+
--color-primary: var(--primary);
|
|
26
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
27
|
+
--color-secondary: var(--secondary);
|
|
28
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
29
|
+
--color-muted: var(--muted);
|
|
30
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
31
|
+
--color-accent: var(--accent);
|
|
32
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
33
|
+
--color-destructive: var(--destructive);
|
|
34
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
35
|
+
--color-success: var(--success);
|
|
36
|
+
--color-warning: var(--warning);
|
|
37
|
+
--color-border: var(--border);
|
|
38
|
+
--color-input: var(--input);
|
|
39
|
+
--color-ring: var(--ring);
|
|
40
|
+
--color-chart-1: var(--chart-1);
|
|
41
|
+
--color-chart-2: var(--chart-2);
|
|
42
|
+
--color-chart-3: var(--chart-3);
|
|
43
|
+
--color-chart-4: var(--chart-4);
|
|
44
|
+
--color-chart-5: var(--chart-5);
|
|
45
|
+
--color-sidebar: var(--sidebar);
|
|
46
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
47
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
48
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
49
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
50
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
51
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
52
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@layer base {
|
|
56
|
+
* {
|
|
57
|
+
@apply border-border outline-ring/50;
|
|
58
|
+
}
|
|
59
|
+
body {
|
|
60
|
+
@apply bg-background text-foreground antialiased;
|
|
61
|
+
}
|
|
62
|
+
}
|
package/dist/tokens.css
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Meldgrove design tokens: the colors, radius and sidebar colors every
|
|
3
|
+
* component of @meldgrove/ui uses (shadcn/ui names), light under :root and
|
|
4
|
+
* dark under .dark. Plain CSS: apps without Tailwind can use them too.
|
|
5
|
+
*
|
|
6
|
+
* Brand layer: the accent (--mg-accent, --mg-accent-foreground) colors
|
|
7
|
+
* primary buttons, links, the active sidebar item and the update dot. It is
|
|
8
|
+
* unset by default, so every app shares the fallback below. An app gets its
|
|
9
|
+
* own accent by setting both variables after this file, for light and for
|
|
10
|
+
* dark (they inherit into the standalone elements' shadow roots too):
|
|
11
|
+
*
|
|
12
|
+
* :root { --mg-accent: oklch(0.55 0.15 160); --mg-accent-foreground: oklch(0.985 0 0); }
|
|
13
|
+
* .dark { --mg-accent: oklch(0.75 0.13 160); --mg-accent-foreground: oklch(0.2 0 0); }
|
|
14
|
+
*
|
|
15
|
+
* The Meldgrove brand palette is not chosen yet; the values below are the
|
|
16
|
+
* neutral shadcn palette the apps used so far. A palette change here reaches
|
|
17
|
+
* every app with its next update of the package.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
:root,
|
|
21
|
+
.meldgrove-root {
|
|
22
|
+
--radius: 0.625rem;
|
|
23
|
+
--background: oklch(1 0 0);
|
|
24
|
+
--foreground: oklch(0.145 0 0);
|
|
25
|
+
--card: oklch(1 0 0);
|
|
26
|
+
--card-foreground: oklch(0.145 0 0);
|
|
27
|
+
--popover: oklch(1 0 0);
|
|
28
|
+
--popover-foreground: oklch(0.145 0 0);
|
|
29
|
+
--primary: var(--mg-accent, oklch(0.205 0 0));
|
|
30
|
+
--primary-foreground: var(--mg-accent-foreground, oklch(0.985 0 0));
|
|
31
|
+
--secondary: oklch(0.97 0 0);
|
|
32
|
+
--secondary-foreground: oklch(0.205 0 0);
|
|
33
|
+
--muted: oklch(0.97 0 0);
|
|
34
|
+
--muted-foreground: oklch(0.52 0 0);
|
|
35
|
+
--accent: oklch(0.97 0 0);
|
|
36
|
+
--accent-foreground: oklch(0.205 0 0);
|
|
37
|
+
--destructive: oklch(0.577 0.245 27.325);
|
|
38
|
+
--destructive-foreground: oklch(0.985 0 0);
|
|
39
|
+
--success: oklch(0.6 0.15 150);
|
|
40
|
+
--warning: oklch(0.75 0.15 75);
|
|
41
|
+
--border: oklch(0.922 0 0);
|
|
42
|
+
--input: oklch(0.922 0 0);
|
|
43
|
+
--ring: oklch(0.708 0 0);
|
|
44
|
+
--chart-1: oklch(0.646 0.222 41.116);
|
|
45
|
+
--chart-2: oklch(0.6 0.118 184.704);
|
|
46
|
+
--chart-3: oklch(0.398 0.07 227.392);
|
|
47
|
+
--chart-4: oklch(0.828 0.189 84.429);
|
|
48
|
+
--chart-5: oklch(0.769 0.188 70.08);
|
|
49
|
+
--sidebar: oklch(0.985 0 0);
|
|
50
|
+
--sidebar-foreground: oklch(0.145 0 0);
|
|
51
|
+
--sidebar-primary: var(--mg-accent, oklch(0.205 0 0));
|
|
52
|
+
--sidebar-primary-foreground: var(--mg-accent-foreground, oklch(0.985 0 0));
|
|
53
|
+
--sidebar-accent: oklch(0.97 0 0);
|
|
54
|
+
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
55
|
+
--sidebar-border: oklch(0.922 0 0);
|
|
56
|
+
--sidebar-ring: oklch(0.708 0 0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.dark {
|
|
60
|
+
--background: oklch(0.145 0 0);
|
|
61
|
+
--foreground: oklch(0.985 0 0);
|
|
62
|
+
--card: oklch(0.205 0 0);
|
|
63
|
+
--card-foreground: oklch(0.985 0 0);
|
|
64
|
+
--popover: oklch(0.205 0 0);
|
|
65
|
+
--popover-foreground: oklch(0.985 0 0);
|
|
66
|
+
--primary: var(--mg-accent, oklch(0.922 0 0));
|
|
67
|
+
--primary-foreground: var(--mg-accent-foreground, oklch(0.205 0 0));
|
|
68
|
+
--secondary: oklch(0.269 0 0);
|
|
69
|
+
--secondary-foreground: oklch(0.985 0 0);
|
|
70
|
+
--muted: oklch(0.269 0 0);
|
|
71
|
+
--muted-foreground: oklch(0.708 0 0);
|
|
72
|
+
--accent: oklch(0.269 0 0);
|
|
73
|
+
--accent-foreground: oklch(0.985 0 0);
|
|
74
|
+
--destructive: oklch(0.704 0.191 22.216);
|
|
75
|
+
--destructive-foreground: oklch(0.985 0 0);
|
|
76
|
+
--success: oklch(0.72 0.15 150);
|
|
77
|
+
--warning: oklch(0.8 0.15 75);
|
|
78
|
+
--border: oklch(1 0 0 / 10%);
|
|
79
|
+
--input: oklch(1 0 0 / 15%);
|
|
80
|
+
--ring: oklch(0.556 0 0);
|
|
81
|
+
--chart-1: oklch(0.488 0.243 264.376);
|
|
82
|
+
--chart-2: oklch(0.696 0.17 162.48);
|
|
83
|
+
--chart-3: oklch(0.769 0.188 70.08);
|
|
84
|
+
--chart-4: oklch(0.627 0.265 303.9);
|
|
85
|
+
--chart-5: oklch(0.645 0.246 16.439);
|
|
86
|
+
--sidebar: oklch(0.205 0 0);
|
|
87
|
+
--sidebar-foreground: oklch(0.985 0 0);
|
|
88
|
+
--sidebar-primary: var(--mg-accent, oklch(0.922 0 0));
|
|
89
|
+
--sidebar-primary-foreground: var(--mg-accent-foreground, oklch(0.205 0 0));
|
|
90
|
+
--sidebar-accent: oklch(0.269 0 0);
|
|
91
|
+
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
92
|
+
--sidebar-border: oklch(1 0 0 / 10%);
|
|
93
|
+
--sidebar-ring: oklch(0.556 0 0);
|
|
94
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { type Locale, type Translate } from "../lib/i18n-core.ts";
|
|
2
|
+
import { messages } from "./messages.ts";
|
|
3
|
+
import { type ButtonState, type InstallStorage, type PendingInstall } from "./state.ts";
|
|
4
|
+
import { type UpdatesTransport } from "./transport.ts";
|
|
5
|
+
import { type Update, type UpdateChannel, type UpdaterStatus, type UpdatesResponse } from "./types.ts";
|
|
6
|
+
/** Status requests: every 5 minutes, every 2 seconds while following an installation. */
|
|
7
|
+
export declare const NORMAL_INTERVAL_MS: number;
|
|
8
|
+
export declare const INSTALL_INTERVAL_MS = 2000;
|
|
9
|
+
/** A status older than this is asked again when the window regains focus or the network returns. */
|
|
10
|
+
export declare const STALE_MS = 60000;
|
|
11
|
+
/** How long the install request may take (the app waits up to 10 s for the update service). */
|
|
12
|
+
export declare const INSTALL_TIMEOUT_MS = 15000;
|
|
13
|
+
/** How long a check or a channel switch may take (the app waits up to 35 s). */
|
|
14
|
+
export declare const POST_TIMEOUT_MS = 45000;
|
|
15
|
+
/** The page reloads this long after the new version answered. */
|
|
16
|
+
export declare const RELOAD_DELAY_MS = 1500;
|
|
17
|
+
type LastResult = NonNullable<UpdaterStatus["last"]>;
|
|
18
|
+
/** A message for the person: the app shows it as a toast. */
|
|
19
|
+
export type Notice = {
|
|
20
|
+
kind: "success" | "error";
|
|
21
|
+
title: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
};
|
|
24
|
+
export type UpdatesControllerOptions = {
|
|
25
|
+
transport: UpdatesTransport;
|
|
26
|
+
/** The app's name in texts, e.g. "Meldgrove Handbook". */
|
|
27
|
+
appName: string;
|
|
28
|
+
/** The Compose project of a server installation, for `journalctl -u meldgrove-updater-<project>`. */
|
|
29
|
+
project: string;
|
|
30
|
+
locale?: Locale;
|
|
31
|
+
/** The locale of full dates; default "en-GB" for English (19 Nov 2026, 14:05), "de-DE" for German. Relative times ("5 minutes ago") follow `locale`. */
|
|
32
|
+
dateLocale?: string;
|
|
33
|
+
/** IANA time zone of dates, e.g. "Europe/Berlin"; default: the browser's. */
|
|
34
|
+
timeZone?: string;
|
|
35
|
+
/** Where a tab keeps its followed installation; default: sessionStorage under `meldgrove.updates.<project>`. */
|
|
36
|
+
storage?: InstallStorage;
|
|
37
|
+
/** A status the page already has (rendered on the server); requests still start as usual. */
|
|
38
|
+
initialResponse?: UpdatesResponse;
|
|
39
|
+
/** Shows a message (toast). */
|
|
40
|
+
notify?: (notice: Notice) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Called once when the routes stop answering this page: "signed-out" for
|
|
43
|
+
* 401 or a sign-in page (the session ended), "forbidden" for 403 or 404
|
|
44
|
+
* (signed in, but no longer an app admin).
|
|
45
|
+
*/
|
|
46
|
+
onSignedOut?: (reason: SignedOutReason) => void;
|
|
47
|
+
/** Reloads the page once the new version answers. */
|
|
48
|
+
reload?: () => void;
|
|
49
|
+
/** The clock (epoch ms); for tests. */
|
|
50
|
+
now?: () => number;
|
|
51
|
+
};
|
|
52
|
+
/** Everything the button and the settings show, as of one moment. */
|
|
53
|
+
export type UpdatesSnapshot = {
|
|
54
|
+
/** The latest status; undefined until the first answer. */
|
|
55
|
+
response: UpdatesResponse | undefined;
|
|
56
|
+
status: UpdaterStatus | null;
|
|
57
|
+
/** The installation this tab follows. */
|
|
58
|
+
pending: PendingInstall | null;
|
|
59
|
+
/** The failed result of an installation this tab followed, shown until the next one. */
|
|
60
|
+
recent: LastResult | null;
|
|
61
|
+
/** A check runs (here or in the updater). */
|
|
62
|
+
checking: boolean;
|
|
63
|
+
state: ButtonState;
|
|
64
|
+
/** What the popover shows. */
|
|
65
|
+
shown: Exclude<ButtonState, "checking">;
|
|
66
|
+
/** A click opens the popover (else it checks). */
|
|
67
|
+
panel: boolean;
|
|
68
|
+
open: boolean;
|
|
69
|
+
/** The app or its update service does not answer while following an installation. */
|
|
70
|
+
restarting: boolean;
|
|
71
|
+
/** The followed installation takes longer than expected (Stop waiting). */
|
|
72
|
+
slow: boolean;
|
|
73
|
+
/** This page follows an installation and reloads when it is done. */
|
|
74
|
+
waiting: boolean;
|
|
75
|
+
/** 401, 403, 404 or a sign-in page stopped every automatic status request of the page. */
|
|
76
|
+
stopped: boolean;
|
|
77
|
+
/** A channel switch runs. */
|
|
78
|
+
savingChannel: boolean;
|
|
79
|
+
/** Epoch ms of this snapshot, for times that pass without new data. */
|
|
80
|
+
now: number;
|
|
81
|
+
};
|
|
82
|
+
/** The version the app runs: its own, else what the updater considers installed. */
|
|
83
|
+
export declare function runningVersion(response: UpdatesResponse | undefined): string | null;
|
|
84
|
+
/** Why the routes stopped answering the page; see `onSignedOut`. */
|
|
85
|
+
export type SignedOutReason = "signed-out" | "forbidden";
|
|
86
|
+
/**
|
|
87
|
+
* The update button's behaviour for one page, free of React: asks the app's
|
|
88
|
+
* update routes for the status (on start, every 5 minutes, on focus at most
|
|
89
|
+
* once a minute; every 2 seconds while following an installation), checks and
|
|
90
|
+
* installs on request, follows an installation through the restart, reloads
|
|
91
|
+
* the page when the new version answers, and stops every automatic request
|
|
92
|
+
* once the session ended. Never checks by itself. The React components and
|
|
93
|
+
* the standalone element render its snapshot.
|
|
94
|
+
*/
|
|
95
|
+
export declare class UpdatesController {
|
|
96
|
+
appName: string;
|
|
97
|
+
readonly project: string;
|
|
98
|
+
locale: Locale;
|
|
99
|
+
dateLocale: string;
|
|
100
|
+
timeZone: string | undefined;
|
|
101
|
+
t: Translate<(typeof messages)["en"]>;
|
|
102
|
+
private readonly transport;
|
|
103
|
+
private readonly storage;
|
|
104
|
+
private notifyFn;
|
|
105
|
+
private onSignedOutFn;
|
|
106
|
+
private readonly reloadFn;
|
|
107
|
+
private readonly clock;
|
|
108
|
+
private fixedDateLocale;
|
|
109
|
+
private pageStart;
|
|
110
|
+
private restored;
|
|
111
|
+
private readonly listeners;
|
|
112
|
+
/** The request that asks for the status now, to cancel when an installation starts. */
|
|
113
|
+
private statusAbort;
|
|
114
|
+
private response;
|
|
115
|
+
/** When the latest status request ended, and whether it failed (no status, or not reachable). */
|
|
116
|
+
private lastPoll;
|
|
117
|
+
private pending;
|
|
118
|
+
private ignored;
|
|
119
|
+
private recent;
|
|
120
|
+
private checkRunning;
|
|
121
|
+
private savingChannel;
|
|
122
|
+
private open;
|
|
123
|
+
private stopped;
|
|
124
|
+
private reloading;
|
|
125
|
+
private statusRunning;
|
|
126
|
+
private lastStatusAt;
|
|
127
|
+
private started;
|
|
128
|
+
private pollTimer;
|
|
129
|
+
private deadlineTimer;
|
|
130
|
+
private slowTimer;
|
|
131
|
+
private reloadTimer;
|
|
132
|
+
private tickTimer;
|
|
133
|
+
private snapshot;
|
|
134
|
+
/** The snapshot before `start`: what a server renders, and so what hydration expects. */
|
|
135
|
+
readonly initialSnapshot: UpdatesSnapshot;
|
|
136
|
+
constructor(options: UpdatesControllerOptions);
|
|
137
|
+
subscribe: (listener: () => void) => (() => void);
|
|
138
|
+
getSnapshot: () => UpdatesSnapshot;
|
|
139
|
+
/** For `useSyncExternalStore` on the server and during hydration. */
|
|
140
|
+
getServerSnapshot: () => UpdatesSnapshot;
|
|
141
|
+
private emit;
|
|
142
|
+
private compute;
|
|
143
|
+
/** The language of the texts the controller writes (notices). */
|
|
144
|
+
setLocale(locale: Locale): void;
|
|
145
|
+
/** Options a page may change after the controller exists. */
|
|
146
|
+
configure(options: {
|
|
147
|
+
appName?: string;
|
|
148
|
+
notify?: (notice: Notice) => void;
|
|
149
|
+
onSignedOut?: ((reason: SignedOutReason) => void) | null;
|
|
150
|
+
/** null: the default of the locale. */
|
|
151
|
+
dateLocale?: string | null;
|
|
152
|
+
/** null: the browser's. */
|
|
153
|
+
timeZone?: string | null;
|
|
154
|
+
}): void;
|
|
155
|
+
/** Starts asking for the status; idempotent. Arms the deadline of a restored attempt first. */
|
|
156
|
+
start(): void;
|
|
157
|
+
/** Stops every timer and listener (also a pending reload); `start` resumes. */
|
|
158
|
+
dispose(): void;
|
|
159
|
+
private onFocus;
|
|
160
|
+
private onVisibility;
|
|
161
|
+
/** Shows a message the way the page shows the controller's own (toast). */
|
|
162
|
+
notify(notice: Notice): void;
|
|
163
|
+
/** The next status request: every 2 s while following (also in the background), else every 5 min. */
|
|
164
|
+
private schedule;
|
|
165
|
+
/**
|
|
166
|
+
* An unconfirmed attempt ends at its deadline on a timer of its own, whatever
|
|
167
|
+
* the status requests do (failing, stalled, or paused while offline); not
|
|
168
|
+
* while the page is signed out (kept for a later page load). A followed
|
|
169
|
+
* installation turns slow after 15 minutes on another.
|
|
170
|
+
*/
|
|
171
|
+
private armTimers;
|
|
172
|
+
private setPending;
|
|
173
|
+
/** 401, 403, 404 or a sign-in page: no automatic request on this page any more; a followed installation stays stored. */
|
|
174
|
+
private signOut;
|
|
175
|
+
/** Runs one request with a timeout of its own; a timeout throws an Error with the "did not answer" text. */
|
|
176
|
+
private send;
|
|
177
|
+
/** Asks for the status; each request at most until the deadline of an unconfirmed attempt. */
|
|
178
|
+
fetchStatus(): Promise<void>;
|
|
179
|
+
/** Drops the status request in flight, so that polling follows a new installation at once. */
|
|
180
|
+
private cancelStatus;
|
|
181
|
+
/** A status request failed (network error, timeout, 5xx): while following, an observed outage. */
|
|
182
|
+
private pollFailed;
|
|
183
|
+
/** A new status, from a status request (sent at `sentAt`) or from the answer of a POST. */
|
|
184
|
+
private receive;
|
|
185
|
+
/** Confirms this tab's attempt, adopts a reported installation, and ends it once its result is known. */
|
|
186
|
+
private follow;
|
|
187
|
+
/** A POST to `check` or `channel`: a status into the snapshot, or an Error with the route's reason. */
|
|
188
|
+
private post;
|
|
189
|
+
/** Opens or closes the popover; opening without anything to show checks instead. */
|
|
190
|
+
setOpen: (next: boolean) => void;
|
|
191
|
+
/** Checks for new versions (only ever on request) and says what it found. */
|
|
192
|
+
check: () => Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Installs `update` (the person confirmed it). The attempt is remembered
|
|
195
|
+
* before the request, so that a restart before its answer keeps following it.
|
|
196
|
+
*/
|
|
197
|
+
install: (update: Update) => Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* The answer to the install request, never an exception: accepted (202, also
|
|
200
|
+
* when its body cannot be read), refused (4xx; a 409 with the latest status),
|
|
201
|
+
* or unclear (no update service, a network error, a timeout, an unreadable
|
|
202
|
+
* answer, a sign-in page, or a 5xx): the installation may have started.
|
|
203
|
+
*/
|
|
204
|
+
private requestInstall;
|
|
205
|
+
/** Leaves the followed installation alone, by the identity stored on it, also while no status is there. */
|
|
206
|
+
stopWaiting: () => void;
|
|
207
|
+
/** Switches the channel; true when the update service answered with the new channel. */
|
|
208
|
+
setChannel: (channel: UpdateChannel) => Promise<boolean>;
|
|
209
|
+
}
|
|
210
|
+
export {};
|