@kidecms/core 0.29.3 → 0.31.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 (50) hide show
  1. package/admin/components/BlockEditor.tsx +64 -45
  2. package/admin/components/CheckboxField.tsx +12 -3
  3. package/admin/components/ContentEditor.tsx +1 -1
  4. package/admin/components/DocumentActions.tsx +69 -0
  5. package/admin/components/DocumentsDataTable.tsx +28 -1
  6. package/admin/components/FieldControl.astro +35 -4
  7. package/admin/components/PasskeySettings.tsx +121 -0
  8. package/admin/components/PasskeySignIn.tsx +57 -0
  9. package/admin/components/SharedSectionBlockField.tsx +1 -1
  10. package/admin/components/SidebarUserMenu.tsx +7 -1
  11. package/admin/components/TwoFactorSettings.tsx +206 -0
  12. package/admin/components/UnsavedGuard.tsx +9 -2
  13. package/admin/components/block-fields.tsx +42 -25
  14. package/admin/components/block-values.ts +52 -0
  15. package/admin/layouts/AdminLayout.astro +42 -2
  16. package/admin/views/EditView.astro +75 -39
  17. package/admin/views/ListView.astro +43 -3
  18. package/admin/views/edit/EditScripts.astro +88 -2
  19. package/core/api.ts +49 -5
  20. package/core/auth-config.ts +53 -11
  21. package/core/auth-engine.ts +920 -0
  22. package/core/auth.ts +46 -152
  23. package/core/create-admin.ts +9 -5
  24. package/core/define.ts +75 -35
  25. package/core/generator.ts +80 -10
  26. package/core/index.ts +31 -3
  27. package/core/schema.ts +3 -1
  28. package/core/seed.ts +12 -2
  29. package/internals/integration.ts +34 -3
  30. package/internals/mcp.ts +3 -3
  31. package/internals/shared-deps.ts +126 -0
  32. package/internals/upgrade.ts +3 -0
  33. package/internals/virtual.d.ts +3 -2
  34. package/middleware/auth.ts +58 -18
  35. package/package.json +26 -21
  36. package/routes/admin/account.astro +138 -0
  37. package/routes/admin/login/verify.astro +90 -0
  38. package/routes/admin/login.astro +84 -33
  39. package/routes/api/auth/[...all].ts +153 -0
  40. package/routes/api/auth/_better-auth.ts +26 -0
  41. package/routes/api/auth/account.ts +69 -0
  42. package/routes/api/auth/forgot-password.ts +38 -32
  43. package/routes/api/auth/invite.ts +66 -98
  44. package/routes/api/auth/login/verify.ts +50 -0
  45. package/routes/api/auth/login.ts +68 -118
  46. package/routes/api/auth/logout.ts +13 -28
  47. package/routes/api/auth/reset-password.ts +17 -56
  48. package/routes/api/auth/setup.ts +14 -20
  49. package/routes/api/auth/sso/[provider]/start.ts +33 -25
  50. package/routes/api/forms/submit/[slug].ts +27 -2
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { ChevronsUpDown, LogOut, Monitor, Moon, Sun } from "lucide-react";
3
+ import { ChevronsUpDown, LogOut, Monitor, Moon, Sun, UserRound } from "lucide-react";
4
4
  import { useEffect, useState } from "react";
5
5
 
6
6
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from "./ui/dropdown-menu";
@@ -18,10 +18,12 @@ export default function SidebarUserMenu({
18
18
  userName,
19
19
  userEmail,
20
20
  logoutAction,
21
+ accountHref = "/admin/account",
21
22
  }: {
22
23
  userName: string;
23
24
  userEmail: string;
24
25
  logoutAction: string;
26
+ accountHref?: string;
25
27
  }) {
26
28
  const [theme, setTheme] = useState<Theme>("system");
27
29
 
@@ -81,6 +83,10 @@ export default function SidebarUserMenu({
81
83
 
82
84
  <DropdownMenuSeparator />
83
85
 
86
+ <DropdownMenuItem onClick={() => window.location.assign(accountHref)}>
87
+ <UserRound className="text-muted-foreground size-3.5" />
88
+ Account &amp; security
89
+ </DropdownMenuItem>
84
90
  <DropdownMenuItem
85
91
  onClick={() => {
86
92
  const form = document.createElement("form");
@@ -0,0 +1,206 @@
1
+ "use client";
2
+
3
+ import { useState } from "react";
4
+ import { renderSVG } from "uqr";
5
+
6
+ import { Button } from "./ui/button";
7
+ import { Input } from "./ui/input";
8
+ import { Label } from "./ui/label";
9
+
10
+ const AUTH_BASE = "/api/cms/auth";
11
+
12
+ type Step =
13
+ | { kind: "idle" }
14
+ | { kind: "password"; intent: "enable" | "disable" | "codes" }
15
+ | { kind: "scan"; totpURI: string; backupCodes: string[] }
16
+ | { kind: "codes"; backupCodes: string[] };
17
+
18
+ const post = async (path: string, body: Record<string, unknown>) => {
19
+ const response = await fetch(`${AUTH_BASE}${path}`, {
20
+ method: "POST",
21
+ credentials: "same-origin",
22
+ headers: { "Content-Type": "application/json" },
23
+ body: JSON.stringify(body),
24
+ });
25
+ const data = await response.json().catch(() => ({}));
26
+ if (!response.ok) throw new Error(data?.message ?? data?.error ?? "Request failed");
27
+ return data;
28
+ };
29
+
30
+ const reloadWith = (message: string) => {
31
+ const url = new URL(window.location.href);
32
+ url.search = new URLSearchParams({ _toast: "success", _msg: message }).toString();
33
+ window.location.assign(url.toString());
34
+ };
35
+
36
+ function BackupCodes({ codes }: { codes: string[] }) {
37
+ return (
38
+ <div className="grid gap-2">
39
+ <p className="text-muted-foreground text-sm">
40
+ Save these backup codes somewhere safe. Each one signs you in once if you lose your authenticator.
41
+ </p>
42
+ <pre className="bg-muted rounded-md px-3 py-2 font-mono text-sm leading-6 select-all">{codes.join("\n")}</pre>
43
+ </div>
44
+ );
45
+ }
46
+
47
+ export default function TwoFactorSettings({ enabled, required }: { enabled: boolean; required: boolean }) {
48
+ const [step, setStep] = useState<Step>(
49
+ required && !enabled ? { kind: "password", intent: "enable" } : { kind: "idle" },
50
+ );
51
+ const [password, setPassword] = useState("");
52
+ const [code, setCode] = useState("");
53
+ const [busy, setBusy] = useState(false);
54
+ const [error, setError] = useState<string | null>(null);
55
+
56
+ const run = async (task: () => Promise<void>) => {
57
+ setBusy(true);
58
+ setError(null);
59
+ try {
60
+ await task();
61
+ } catch (cause) {
62
+ setError(cause instanceof Error ? cause.message : "Something went wrong.");
63
+ } finally {
64
+ setBusy(false);
65
+ }
66
+ };
67
+
68
+ const submitPassword = (intent: "enable" | "disable" | "codes") =>
69
+ run(async () => {
70
+ if (intent === "enable") {
71
+ const data = await post("/two-factor/enable", { password });
72
+ setStep({ kind: "scan", totpURI: data.totpURI, backupCodes: data.backupCodes ?? [] });
73
+ } else if (intent === "disable") {
74
+ await post("/two-factor/disable", { password });
75
+ reloadWith("Two-factor authentication turned off.");
76
+ } else {
77
+ const data = await post("/two-factor/generate-backup-codes", { password });
78
+ setStep({ kind: "codes", backupCodes: data.backupCodes ?? [] });
79
+ }
80
+ setPassword("");
81
+ });
82
+
83
+ const confirmCode = () =>
84
+ run(async () => {
85
+ await post("/two-factor/verify-totp", { code: code.replace(/\s+/g, "") });
86
+ reloadWith("Two-factor authentication is on.");
87
+ });
88
+
89
+ if (step.kind === "password") {
90
+ const label = step.intent === "enable" ? "Continue" : step.intent === "disable" ? "Turn off" : "Generate new codes";
91
+ return (
92
+ <form
93
+ className="grid max-w-sm gap-3"
94
+ onSubmit={(event) => {
95
+ event.preventDefault();
96
+ void submitPassword(step.intent);
97
+ }}
98
+ >
99
+ <div className="grid gap-2">
100
+ <Label htmlFor="tf-password">Confirm your password</Label>
101
+ <Input
102
+ id="tf-password"
103
+ type="password"
104
+ autoComplete="current-password"
105
+ value={password}
106
+ onChange={(event) => setPassword(event.target.value)}
107
+ required
108
+ autoFocus
109
+ />
110
+ </div>
111
+ {error && <p className="text-destructive text-sm">{error}</p>}
112
+ <div className="flex gap-2">
113
+ <Button type="submit" disabled={busy}>
114
+ {label}
115
+ </Button>
116
+ {!(required && !enabled) && (
117
+ <Button type="button" variant="ghost" onClick={() => setStep({ kind: "idle" })}>
118
+ Cancel
119
+ </Button>
120
+ )}
121
+ </div>
122
+ </form>
123
+ );
124
+ }
125
+
126
+ if (step.kind === "scan") {
127
+ const secret = new URL(step.totpURI).searchParams.get("secret") ?? "";
128
+ return (
129
+ <div className="grid gap-5">
130
+ <div className="grid gap-3 sm:grid-cols-[auto_1fr] sm:items-start">
131
+ <div
132
+ className="size-44 rounded-md bg-white p-2 [&_svg]:size-full"
133
+ // uqr renders an SVG string from the otpauth URI the server returned.
134
+ dangerouslySetInnerHTML={{ __html: renderSVG(step.totpURI) }}
135
+ />
136
+ <div className="grid gap-2 text-sm">
137
+ <p>Scan the code with an authenticator app (1Password, Google Authenticator, Microsoft Authenticator…).</p>
138
+ <p className="text-muted-foreground">Can't scan? Enter this key:</p>
139
+ <code className="bg-muted rounded-md px-2 py-1 font-mono text-xs break-all select-all">{secret}</code>
140
+ </div>
141
+ </div>
142
+ <BackupCodes codes={step.backupCodes} />
143
+ <form
144
+ className="grid max-w-sm gap-3"
145
+ onSubmit={(event) => {
146
+ event.preventDefault();
147
+ void confirmCode();
148
+ }}
149
+ >
150
+ <div className="grid gap-2">
151
+ <Label htmlFor="tf-code">Enter the 6-digit code to finish</Label>
152
+ <Input
153
+ id="tf-code"
154
+ inputMode="numeric"
155
+ autoComplete="one-time-code"
156
+ value={code}
157
+ onChange={(event) => setCode(event.target.value)}
158
+ required
159
+ />
160
+ </div>
161
+ {error && <p className="text-destructive text-sm">{error}</p>}
162
+ <div>
163
+ <Button type="submit" disabled={busy}>
164
+ Turn on
165
+ </Button>
166
+ </div>
167
+ </form>
168
+ </div>
169
+ );
170
+ }
171
+
172
+ if (step.kind === "codes") {
173
+ return (
174
+ <div className="grid gap-3">
175
+ <BackupCodes codes={step.backupCodes} />
176
+ <p className="text-muted-foreground text-sm">Your previous backup codes no longer work.</p>
177
+ <div>
178
+ <Button type="button" variant="outline" onClick={() => setStep({ kind: "idle" })}>
179
+ Done
180
+ </Button>
181
+ </div>
182
+ </div>
183
+ );
184
+ }
185
+
186
+ return (
187
+ <div className="flex flex-wrap items-center gap-3">
188
+ {enabled ? (
189
+ <>
190
+ <Button type="button" variant="outline" onClick={() => setStep({ kind: "password", intent: "codes" })}>
191
+ New backup codes
192
+ </Button>
193
+ {!required && (
194
+ <Button type="button" variant="ghost" onClick={() => setStep({ kind: "password", intent: "disable" })}>
195
+ Turn off
196
+ </Button>
197
+ )}
198
+ </>
199
+ ) : (
200
+ <Button type="button" onClick={() => setStep({ kind: "password", intent: "enable" })}>
201
+ Set up authenticator app
202
+ </Button>
203
+ )}
204
+ </div>
205
+ );
206
+ }
@@ -43,8 +43,13 @@ export default function UnsavedGuard({
43
43
  const saveBtn = doc.querySelector<HTMLButtonElement>(`button[type="submit"][form="${formId}"][value="save"]`);
44
44
  const publishBtn = doc.querySelector<HTMLButtonElement>(`button[type="submit"][form="${formId}"][value="publish"]`);
45
45
 
46
- const initialData = new FormData(form);
47
- const initialSnapshot = serializeFormData(initialData);
46
+ // After an in-place save (EditScripts swaps this guard in without a reload), the
47
+ // clean baseline is exactly what was submitted — edits typed while the save was in
48
+ // flight stay dirty instead of being silently treated as saved.
49
+ const win = window as Window & { __kideSubmittedForm?: FormData };
50
+ const submitted = win.__kideSubmittedForm;
51
+ delete win.__kideSubmittedForm;
52
+ const initialSnapshot = serializeFormData(submitted ?? new FormData(form));
48
53
 
49
54
  const updateButtons = (dirty: boolean) => {
50
55
  if (isNew) return;
@@ -61,6 +66,8 @@ export default function UnsavedGuard({
61
66
  dirtyRef.current = currentSnapshot !== initialSnapshot;
62
67
  updateButtons(dirtyRef.current);
63
68
  };
69
+ // Edits made while an in-place save was in flight are already unsaved.
70
+ if (submitted) checkDirty();
64
71
 
65
72
  // Mark as clean when form is submitted
66
73
  const handleSubmit = () => {
@@ -27,6 +27,9 @@ import LinkField from "./LinkField";
27
27
  import type { LinkableCollection } from "./InternalLinkPicker";
28
28
  import DocumentCombobox, { useRelationLabels } from "./DocumentCombobox";
29
29
  import YoutubeField from "./YoutubeField";
30
+ // Circular with BlockEditor (which renders SubField); both sides only use the
31
+ // other at render time, so the cycle is safe.
32
+ import BlockEditor from "./BlockEditor";
30
33
 
31
34
  // -----------------------------------------------
32
35
  // Shared types — describe a block sub-field. Used by both the standalone
@@ -49,6 +52,8 @@ export type SubFieldMeta = {
49
52
  condition?: { field: string; value: string | string[] | boolean };
50
53
  /** Typed repeater row schema (json + admin.component "repeater"). */
51
54
  itemFields?: Record<string, SubFieldMeta>;
55
+ /** Block types of a nested `blocks` sub-field. */
56
+ types?: Record<string, Record<string, SubFieldMeta>>;
52
57
  };
53
58
 
54
59
  /** Same semantics as the edit form's conditional-visibility script (EditScripts). */
@@ -76,28 +81,8 @@ export function humanize(value: string) {
76
81
  .replace(/^\w/, (char) => char.toUpperCase());
77
82
  }
78
83
 
79
- /** Build a blank value object for a freshly inserted block of the given type. */
80
- export function blankBlockFields(fieldsMeta: Record<string, SubFieldMeta>): Record<string, unknown> {
81
- const out: Record<string, unknown> = {};
82
- for (const [fieldName, meta] of Object.entries(fieldsMeta)) {
83
- if (meta.defaultValue !== undefined) out[fieldName] = meta.defaultValue;
84
- else if (meta.type === "boolean") out[fieldName] = false;
85
- else if (meta.type === "array") out[fieldName] = [];
86
- else out[fieldName] = "";
87
- }
88
- return out;
89
- }
90
-
91
- /** First text-ish field value, truncated — used for collapsed block previews. */
92
- export function getPreviewText(values: Record<string, unknown>, fieldsMeta: Record<string, SubFieldMeta>): string {
93
- for (const [key, meta] of Object.entries(fieldsMeta)) {
94
- if (meta.type === "text" && values[key]) {
95
- const text = String(values[key]);
96
- return text.length > 60 ? text.slice(0, 60) + "..." : text;
97
- }
98
- }
99
- return "";
100
- }
84
+ // Pure value helpers live in a React-free module so they can be unit-tested.
85
+ export { blankBlockFields, getPreviewText } from "./block-values";
101
86
 
102
87
  // -----------------------------------------------
103
88
  // Sub-field label + control wrapper
@@ -126,6 +111,16 @@ export function SubField({
126
111
 
127
112
  if (meta.condition && !matchesCondition(meta.condition.value, siblings?.[meta.condition.field])) return null;
128
113
 
114
+ // A checkbox carries its own label beside the box; help sits below, under the label text.
115
+ if (meta.type === "boolean") {
116
+ return (
117
+ <div className="grid gap-1.5">
118
+ <SubFieldControl fieldId={fieldId} meta={meta} value={value} onChange={onChange} label={label} />
119
+ {meta.admin?.help && <p className="text-muted-foreground pl-7 text-xs leading-5">{meta.admin.help}</p>}
120
+ </div>
121
+ );
122
+ }
123
+
129
124
  return (
130
125
  <div className="grid gap-2">
131
126
  <Label htmlFor={fieldId}>
@@ -283,12 +278,15 @@ export function SubFieldControl({
283
278
  value,
284
279
  onChange,
285
280
  linkOptions = [],
281
+ label,
286
282
  }: {
287
283
  fieldId: string;
288
284
  meta: SubFieldMeta;
289
285
  value: unknown;
290
286
  onChange: (value: unknown) => void;
291
287
  linkOptions?: LinkableCollection[];
288
+ /** Checkbox text (booleans render their label beside the box). */
289
+ label?: string;
292
290
  }) {
293
291
  const strValue = value == null ? "" : String(value);
294
292
 
@@ -337,14 +335,19 @@ export function SubFieldControl({
337
335
 
338
336
  case "boolean":
339
337
  return (
340
- <label className="group inline-flex cursor-pointer items-center gap-3 text-sm">
338
+ <label className="group inline-flex w-fit cursor-pointer items-center gap-3 text-sm">
341
339
  <Checkbox
342
340
  id={fieldId}
343
341
  className="group-hover:border-primary/60"
344
342
  checked={Boolean(value)}
345
343
  onCheckedChange={(checked) => onChange(Boolean(checked))}
346
344
  />
347
- <span className="text-muted-foreground select-none">{value ? "true" : "false"}</span>
345
+ {label && (
346
+ <span className="text-foreground/80 leading-none font-medium select-none">
347
+ {label}
348
+ {meta.required ? " *" : ""}
349
+ </span>
350
+ )}
348
351
  </label>
349
352
  );
350
353
 
@@ -391,6 +394,20 @@ export function SubFieldControl({
391
394
  case "array":
392
395
  return <ArrayControl fieldId={fieldId} meta={meta} value={value} onChange={onChange} />;
393
396
 
397
+ case "blocks":
398
+ // A nested block list: typed "+ Type" buttons, each item shows only its own fields.
399
+ return (
400
+ <BlockEditor
401
+ name={fieldId}
402
+ value={Array.isArray(value) ? value : []}
403
+ label={meta.label}
404
+ types={meta.types ?? {}}
405
+ linkOptions={linkOptions}
406
+ sharedEnabled={false}
407
+ onChange={onChange}
408
+ />
409
+ );
410
+
394
411
  case "json":
395
412
  if (meta.admin?.component === "repeater") {
396
413
  return (
@@ -533,7 +550,7 @@ function SortableRepeaterItem({
533
550
  </div>
534
551
 
535
552
  {isExpanded && (
536
- <div ref={contentRef} className="space-y-3 border-t px-4 py-3">
553
+ <div ref={contentRef} className="space-y-5 border-t px-4 py-4">
537
554
  {itemFields
538
555
  ? fieldKeys.map((key) => (
539
556
  <SubField
@@ -0,0 +1,52 @@
1
+ // React-free helpers for block values, shared by the block editors (re-exported
2
+ // from block-fields.tsx) and unit-tested directly.
3
+ import type { SubFieldMeta } from "./block-fields";
4
+
5
+ /** Build a blank value object for a freshly inserted block of the given type. */
6
+ export function blankBlockFields(fieldsMeta: Record<string, SubFieldMeta>): Record<string, unknown> {
7
+ const out: Record<string, unknown> = {};
8
+ for (const [fieldName, meta] of Object.entries(fieldsMeta)) {
9
+ if (meta.defaultValue !== undefined) out[fieldName] = meta.defaultValue;
10
+ else if (meta.type === "boolean") out[fieldName] = false;
11
+ else if (meta.type === "array" || meta.type === "blocks") out[fieldName] = [];
12
+ else out[fieldName] = "";
13
+ }
14
+ return out;
15
+ }
16
+
17
+ type PreviewNode = { value?: unknown; children?: PreviewNode[] };
18
+
19
+ const richTextPreview = (value: unknown): string => {
20
+ let doc = value;
21
+ if (typeof doc === "string") {
22
+ try {
23
+ doc = JSON.parse(doc);
24
+ } catch {
25
+ return "";
26
+ }
27
+ }
28
+ const collect = (node: PreviewNode): string =>
29
+ typeof node.value === "string" ? node.value : (node.children ?? []).map(collect).join(" ");
30
+ return doc && typeof doc === "object" ? collect(doc as PreviewNode).replace(/\s+/g, " ").trim() : "";
31
+ };
32
+
33
+ /**
34
+ * Collapsed block/row preview: the first text or rich-text value, else the first
35
+ * image's file name — so a text-less block (an image, a video) still says what it holds.
36
+ */
37
+ export function getPreviewText(values: Record<string, unknown>, fieldsMeta: Record<string, SubFieldMeta>): string {
38
+ const clip = (text: string) => (text.length > 60 ? text.slice(0, 60) + "..." : text);
39
+ for (const [key, meta] of Object.entries(fieldsMeta)) {
40
+ if (meta.type === "text" && values[key]) return clip(String(values[key]));
41
+ if (meta.type === "richText") {
42
+ const text = richTextPreview(values[key]);
43
+ if (text) return clip(text);
44
+ }
45
+ }
46
+ for (const [key, meta] of Object.entries(fieldsMeta)) {
47
+ if (meta.type === "image" && typeof values[key] === "string" && values[key]) {
48
+ return String(values[key]).split("/").pop() ?? "";
49
+ }
50
+ }
51
+ return "";
52
+ }
@@ -246,7 +246,7 @@ for (const c of navCollections) {
246
246
  href: `/admin/${c.slug}`,
247
247
  label: c.labels.plural,
248
248
  singularLabel: c.labels.singular,
249
- Icon: c.admin?.icon ? (navIconMap[c.admin.icon] ?? LayoutGrid) : (pinnedIcons[c.slug] ?? Layers),
249
+ Icon: c.admin?.icon ? (navIconMap[c.admin.icon] ?? Layers) : (pinnedIcons[c.slug] ?? Layers),
250
250
  active: activeCollection === c.slug,
251
251
  // Submissions are created by end users filling out forms, not added manually.
252
252
  newHref: c.slug === "form-submissions" ? undefined : `/admin/${c.slug}/new`,
@@ -282,7 +282,7 @@ for (const item of customNav) {
282
282
  navItems.push({
283
283
  href: item.href,
284
284
  label: item.label,
285
- Icon: navIconMap[item.icon ?? ""] ?? LayoutGrid,
285
+ Icon: navIconMap[item.icon ?? ""] ?? Layers,
286
286
  active: currentPath === item.href || currentPath.startsWith(item.href + "/"),
287
287
  weight: item.weight ?? 50,
288
288
  group: "Custom",
@@ -550,6 +550,46 @@ const navGroups = [...new Set(navItems.map((item) => item.group))]
550
550
 
551
551
  {toastStatus && <Toast status={toastStatus} message={toastMessage} />}
552
552
 
553
+ {/* Shown when an editor island fails to hydrate, so a failed load never looks like empty content. */}
554
+ <div
555
+ id="admin-hydration-error"
556
+ role="alert"
557
+ hidden
558
+ class="border-destructive/40 bg-background text-foreground fixed inset-x-4 bottom-4 z-[100] mx-auto max-w-xl rounded-lg border px-4 py-3 text-sm shadow-lg"
559
+ >
560
+ <p class="font-medium">Some editors failed to load.</p>
561
+ <p class="text-muted-foreground mt-1">
562
+ Fields may look empty, but your content is safe — don't save this page. Reload to try again.
563
+ {
564
+ import.meta.env.DEV && (
565
+ <>
566
+ {" "}
567
+ If it keeps happening, stop the dev server and restart it with <code>pnpm dev:clean</code>, and check its
568
+ log for a <code>[kide-cms]</code> warning about duplicate packages.
569
+ </>
570
+ )
571
+ }
572
+ </p>
573
+ </div>
574
+ <script is:inline>
575
+ (function () {
576
+ // Astro removes `ssr` from an island once it hydrates; a client:load island
577
+ // still carrying it well after the page has loaded failed to import.
578
+ function check() {
579
+ var failed = document.querySelectorAll('astro-island[ssr][client="load"]');
580
+ if (failed.length === 0) return;
581
+ var banner = document.getElementById("admin-hydration-error");
582
+ if (banner) banner.hidden = false;
583
+ console.error("[kide] " + failed.length + " admin editor(s) failed to hydrate.", failed);
584
+ }
585
+ function schedule() {
586
+ setTimeout(check, 5000);
587
+ }
588
+ if (document.readyState === "complete") schedule();
589
+ else window.addEventListener("load", schedule, { once: true });
590
+ })();
591
+ </script>
592
+
553
593
  {/* Persist collapsible sidebar groups locally. Active groups always open. */}
554
594
  <script is:inline>
555
595
  (function () {