@morphemecms/cms 0.13.0 → 0.14.0-next-20261107093528

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 (166) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/defaults/editor.ts +3 -14
  3. package/icons/lucide/dots-three-vertical.svg +1 -0
  4. package/icons/material-symbols/dots-three-vertical.svg +1 -0
  5. package/icons/phosphor/dots-three-vertical.svg +1 -0
  6. package/lib/appChanges.d.mts +16 -0
  7. package/lib/appChanges.mjs +20 -0
  8. package/lib/appChanges.test.mjs +30 -0
  9. package/lib/apps.d.mts +2 -2
  10. package/lib/apps.mjs +13 -7
  11. package/lib/appsFile.d.mts +20 -0
  12. package/lib/appsFile.mjs +57 -0
  13. package/lib/appsFile.test.mjs +53 -0
  14. package/lib/build-settings.mjs +1 -1
  15. package/lib/changelog.d.mts +7 -0
  16. package/lib/changelog.mjs +16 -5
  17. package/lib/footerClearance.d.mts +1 -0
  18. package/lib/footerClearance.mjs +9 -0
  19. package/lib/footerClearance.test.mjs +24 -0
  20. package/lib/footerLinks.d.mts +12 -0
  21. package/lib/footerLinks.mjs +26 -0
  22. package/lib/footerLinks.test.mjs +32 -0
  23. package/lib/google-result.test.mjs +40 -9
  24. package/lib/menu.mjs +1 -1
  25. package/lib/menu.test.mjs +9 -8
  26. package/lib/releaseNotes.d.mts +136 -0
  27. package/lib/releaseNotes.mjs +249 -0
  28. package/lib/releaseNotes.test.mjs +267 -0
  29. package/lib/serviceFeed.d.mts +2 -0
  30. package/lib/serviceFeed.mjs +13 -0
  31. package/lib/serviceFeed.test.mjs +53 -0
  32. package/lib/serviceStatus.d.mts +72 -0
  33. package/lib/serviceStatus.mjs +143 -0
  34. package/lib/serviceStatus.test.mjs +136 -0
  35. package/lib/strayDividers.d.mts +6 -0
  36. package/lib/strayDividers.mjs +15 -0
  37. package/lib/strayDividers.test.mjs +25 -0
  38. package/package.json +5 -3
  39. package/release-notes/i18n/da-DK/pending/apps-turn-off.json +6 -0
  40. package/release-notes/i18n/da-DK/pending/apps-turn-off.webp +0 -0
  41. package/release-notes/i18n/da-DK/pending/developer-menu.json +5 -0
  42. package/release-notes/i18n/da-DK/pending/dynamic-lists-page.json +5 -0
  43. package/release-notes/i18n/da-DK/pending/editor-footer.json +6 -0
  44. package/release-notes/i18n/da-DK/pending/editor-footer.webp +0 -0
  45. package/release-notes/i18n/da-DK/pending/editor-toolbar-dock.json +5 -0
  46. package/release-notes/i18n/da-DK/pending/google-preview-closer.json +6 -0
  47. package/release-notes/i18n/da-DK/pending/google-preview-closer.webp +0 -0
  48. package/release-notes/i18n/da-DK/pending/morpheme-connection-page.json +5 -0
  49. package/release-notes/i18n/da-DK/pending/quiet-lamps-wander.json +6 -0
  50. package/release-notes/i18n/da-DK/pending/quiet-lamps-wander.webp +0 -0
  51. package/release-notes/i18n/en-US/pending/apps-turn-off.json +6 -0
  52. package/release-notes/i18n/en-US/pending/apps-turn-off.webp +0 -0
  53. package/release-notes/i18n/en-US/pending/developer-menu.json +5 -0
  54. package/release-notes/i18n/en-US/pending/dynamic-lists-page.json +5 -0
  55. package/release-notes/i18n/en-US/pending/editor-footer.json +6 -0
  56. package/release-notes/i18n/en-US/pending/editor-footer.webp +0 -0
  57. package/release-notes/i18n/en-US/pending/editor-toolbar-dock.json +5 -0
  58. package/release-notes/i18n/en-US/pending/google-preview-closer.json +6 -0
  59. package/release-notes/i18n/en-US/pending/google-preview-closer.webp +0 -0
  60. package/release-notes/i18n/en-US/pending/morpheme-connection-page.json +5 -0
  61. package/release-notes/i18n/en-US/pending/quiet-lamps-wander.json +6 -0
  62. package/release-notes/i18n/en-US/pending/quiet-lamps-wander.webp +0 -0
  63. package/scripts/app-screenshots.mjs +4 -4
  64. package/scripts/build-settings-problems.mjs +1 -1
  65. package/scripts/built-site.mjs +1 -1
  66. package/scripts/check-content.mjs +1 -1
  67. package/scripts/check-release-notes.mjs +12 -0
  68. package/scripts/check-worker.mjs +1 -1
  69. package/scripts/editor-screens.mjs +32 -16
  70. package/scripts/release-notes-pending.mjs +46 -0
  71. package/scripts/release-notes.mjs +39 -0
  72. package/site/apps.ts +10 -4
  73. package/site/consent.ts +3 -3
  74. package/site/defineSite.mjs +1 -1
  75. package/site/icons.d.mts +4 -0
  76. package/site/icons.mjs +2 -0
  77. package/site/pageColors.ts +3 -3
  78. package/site/siteCsp.d.mts +1 -1
  79. package/site/siteCsp.mjs +3 -2
  80. package/src/ActionParts.tsx +1 -1
  81. package/src/Advanced.tsx +4 -4
  82. package/src/App.tsx +22 -17
  83. package/src/AppEnabledSwitch.tsx +21 -0
  84. package/src/AppList.tsx +47 -19
  85. package/src/AppSettingsTab.tsx +9 -5
  86. package/src/BlockParts.tsx +7 -7
  87. package/src/BlockSettings.tsx +3 -3
  88. package/src/CmsPage.tsx +11 -10
  89. package/src/Colors.tsx +2 -2
  90. package/src/CommunicationParts.tsx +18 -2
  91. package/src/ContainmentParts.tsx +1 -1
  92. package/src/DataForm.tsx +1 -0
  93. package/src/EditorFooter.tsx +19 -9
  94. package/src/EntryForm.tsx +1 -0
  95. package/src/FooterCopyright.tsx +7 -0
  96. package/src/FooterDivider.tsx +5 -0
  97. package/src/FooterLink.tsx +18 -0
  98. package/src/FooterLinks.tsx +34 -0
  99. package/src/Library.tsx +21 -10
  100. package/src/MainDrawerParts.tsx +1 -1
  101. package/src/MarkdownEditor.tsx +1 -1
  102. package/src/ModalSheetSample.tsx +1 -1
  103. package/src/MorphemeConnection.tsx +30 -0
  104. package/src/MorphemeLogo.tsx +9 -0
  105. package/src/NavigationParts.tsx +1 -1
  106. package/src/NavigationRestParts.tsx +1 -1
  107. package/src/Parts.tsx +9 -9
  108. package/src/PartsShown.tsx +1 -1
  109. package/src/PickerParts.tsx +1 -1
  110. package/src/ReleaseNoteCard.tsx +17 -0
  111. package/src/ReleaseNotes.tsx +52 -0
  112. package/src/Screen.tsx +21 -12
  113. package/src/SearchPreview.tsx +37 -14
  114. package/src/SelectionParts.tsx +1 -1
  115. package/src/ServiceStatus.tsx +59 -0
  116. package/src/SideColumn.tsx +2 -2
  117. package/src/StoreConnectNotice.tsx +1 -1
  118. package/src/StoreConnectedRow.tsx +20 -14
  119. package/src/StoreStatus.tsx +2 -10
  120. package/src/ThemeStoreScreen.tsx +1 -2
  121. package/src/Tokens.tsx +2 -2
  122. package/src/apps.ts +16 -14
  123. package/src/buildSettings.ts +1 -1
  124. package/src/cmsView.d.mts +1 -0
  125. package/src/cmsView.mjs +4 -2
  126. package/src/cmsView.test.mjs +6 -0
  127. package/src/editor.css +13 -2
  128. package/src/examples.ts +2 -2
  129. package/src/fabPresence.tsx +24 -0
  130. package/src/googleResult.d.mts +12 -1
  131. package/src/googleResult.mjs +19 -2
  132. package/src/i18n/da-DK/apps.ts +5 -1
  133. package/src/i18n/da-DK/cms.ts +3 -0
  134. package/src/i18n/da-DK/common.ts +3 -2
  135. package/src/i18n/da-DK/footer.ts +26 -0
  136. package/src/i18n/da-DK/index.ts +2 -0
  137. package/src/i18n/da-DK/parts.ts +5 -0
  138. package/src/i18n/en-US/advanced.ts +1 -1
  139. package/src/i18n/en-US/apps.ts +6 -1
  140. package/src/i18n/en-US/cms.ts +5 -2
  141. package/src/i18n/en-US/common.ts +6 -4
  142. package/src/i18n/en-US/footer.ts +24 -0
  143. package/src/i18n/en-US/index.ts +2 -0
  144. package/src/i18n/en-US/parts.ts +8 -3
  145. package/src/menuChildren.ts +6 -14
  146. package/src/movedRoutes.mjs +12 -8
  147. package/src/movedRoutes.test.mjs +13 -10
  148. package/src/r2Caching.ts +1 -1
  149. package/src/registry.tsx +2 -2
  150. package/src/schema.ts +1 -1
  151. package/src/site.ts +2 -2
  152. package/src/statusReport.ts +24 -0
  153. package/src/store.ts +4 -8
  154. package/src/themeUi.ts +7 -7
  155. package/src/ui.tsx +4 -2
  156. package/src/useFooterClearance.ts +30 -0
  157. package/src/useStrayDividers.ts +24 -0
  158. package/theme/components/AppSlot.astro +4 -4
  159. package/theme/styles/global.css +10 -0
  160. package/theme/styles/ui.css +13 -0
  161. package/theme/ui/Badge.tsx +9 -3
  162. package/worker/cms-update.js +49 -12
  163. package/worker/index.js +10 -4
  164. package/worker/plan-status.js +1 -1
  165. package/worker/r2-status.js +1 -1
  166. package/worker/service-status.js +18 -0
package/src/themeUi.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // The theme's UI parts (packages/editor/theme/ui/, Material 3's names), which the editor draws with too:
2
- // on its own screens (packages/editor/src/ui.tsx, which takes nothing of the theme from anywhere else) and on "Dele" ›
2
+ // on its own screens (packages/editor/src/ui.tsx, which takes nothing of the theme from anywhere else) and on "Parts" ›
3
3
  // "UI-komponenter" (BlockParts.tsx). Only the theme's parts, nothing of the editor, so the editor's parts can be made of them as
4
4
  // it loads.
5
5
  export { default as SiteButton, buttonShapes, buttonSizes } from '@theme/ui/Button';
@@ -34,7 +34,7 @@ export {
34
34
  listClass as siteListClass,
35
35
  listClasses as siteListClasses,
36
36
  } from '@theme/ui/List';
37
- /** The theme's navigation parts (the header's), for "Dele" › "UI-komponenter" (NavigationParts.tsx). */
37
+ /** The theme's navigation parts (the header's), for "Parts" › "UI-komponenter" (NavigationParts.tsx). */
38
38
  export { default as SiteTopAppBar } from '@theme/ui/TopAppBar';
39
39
  export {
40
40
  Menu as SiteMenu,
@@ -62,14 +62,14 @@ export {
62
62
  } from '@theme/ui/NavigationDrawer';
63
63
  export { Tabs as SiteTabs, Tab as SiteTab, tabsClass as siteTabsClass, tabClass as siteTabClass } from '@theme/ui/Tabs';
64
64
  export { Fab as SiteFab, ExtendedFab as SiteExtendedFab, fabKinds, fabSizes, extendedFabSizes } from '@theme/ui/Fab';
65
- /** The theme's action parts (button groups, segmented buttons, split buttons, the FAB menu), for "Dele" › "UI-komponenter"
65
+ /** The theme's action parts (button groups, segmented buttons, split buttons, the FAB menu), for "Parts" › "UI-komponenter"
66
66
  * (ActionParts.tsx). */
67
67
  export { default as SiteButtonGroup, buttonGroupKinds } from '@theme/ui/ButtonGroup';
68
68
  export { default as SiteSegmentedButton } from '@theme/ui/SegmentedButton';
69
69
  export { default as SiteSplitButton, splitButtonKinds } from '@theme/ui/SplitButton';
70
70
  export { default as SiteFabMenu, fabMenuKinds } from '@theme/ui/FabMenu';
71
71
  export { setUpFabMenu } from '@theme/ui/fabMenu.script';
72
- /** The theme's selection parts, dividers and side sheets, for "Dele" › "UI-komponenter" (SelectionParts.tsx). */
72
+ /** The theme's selection parts, dividers and side sheets, for "Parts" › "UI-komponenter" (SelectionParts.tsx). */
73
73
  export { default as SiteSwitch } from '@theme/ui/Switch';
74
74
  export { default as SiteSettingRow } from '@theme/ui/SettingRow';
75
75
  export { default as SiteRadioButton, RadioGroup as SiteRadioGroup } from '@theme/ui/RadioButton';
@@ -78,7 +78,7 @@ export { default as SiteDivider } from '@theme/ui/Divider';
78
78
  export { default as SiteSideSheet } from '@theme/ui/SideSheet';
79
79
  export { sideSheetClass as siteSideSheetDialogClass } from '@theme/ui/SideSheet';
80
80
  export { sideSheet as siteSideSheet, standardSideSheet as siteStandardSideSheet } from '@theme/ui/sideSheetControl';
81
- /** The theme's communication parts, for "Dele" › "UI-komponenter" (CommunicationParts.tsx). */
81
+ /** The theme's communication parts, for "Parts" › "UI-komponenter" (CommunicationParts.tsx). */
82
82
  export { default as SiteBadge } from '@theme/ui/Badge';
83
83
  export { default as SiteLoadingIndicator } from '@theme/ui/LoadingIndicator';
84
84
  export {
@@ -89,7 +89,7 @@ export { default as SiteSnackbar } from '@theme/ui/Snackbar';
89
89
  export { default as SiteTooltip } from '@theme/ui/Tooltip';
90
90
  /** The ripple on the theme's parts when pressed (Material 3's pressed state), on the editor's screens too. */
91
91
  export { default as siteRipples } from '@theme/ui/ripple.script';
92
- /** The rest of the theme's navigation parts, for "Dele" › "UI-komponenter" (NavigationRestParts.tsx). */
92
+ /** The rest of the theme's navigation parts, for "Parts" › "UI-komponenter" (NavigationRestParts.tsx). */
93
93
  export { default as SiteNavigationBar, NavigationBarItem as SiteNavigationBarItem } from '@theme/ui/NavigationBar';
94
94
  export {
95
95
  default as SiteNavigationRail,
@@ -98,7 +98,7 @@ export {
98
98
  } from '@theme/ui/NavigationRail';
99
99
  export { default as SiteSearch, SearchBar as SiteSearchBar } from '@theme/ui/Search';
100
100
  export { default as SiteToolbar } from '@theme/ui/Toolbar';
101
- /** The theme's date and time pickers, for "Dele" › "UI-komponenter" (PickerParts.tsx). */
101
+ /** The theme's date and time pickers, for "Parts" › "UI-komponenter" (PickerParts.tsx). */
102
102
  export { default as SiteDatePicker, datePickerTexts } from '@theme/ui/DatePicker';
103
103
  export { default as SiteDatePickerContainer } from '@theme/ui/DatePickerContainer';
104
104
  export { default as SiteTimePicker, timePickerTexts } from '@theme/ui/TimePicker';
package/src/ui.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  // The editor's parts: every button, field, switch, chip and row a screen is made of, each with one
2
2
  // look, set here. A screen uses these and never writes the classes of a button or a field itself
3
3
  // (CLAUDE.md), so the editor looks the same everywhere and a change here changes it everywhere. They
4
- // are all shown, in every state, on the screen #appearance/parts (Parts.tsx). The screen itself, with its top bar,
4
+ // are all shown, in every state, on the screen #developer/parts (Parts.tsx). The screen itself, with its top bar,
5
5
  // is Screen.tsx.
6
6
  import {
7
7
  useEffect,
@@ -107,6 +107,7 @@ import {
107
107
  siteRipples,
108
108
  } from './themeUi';
109
109
  import { locale, t } from './i18n';
110
+ import { useRegisterFab } from './fabPresence';
110
111
  import { InEditor, type ButtonKind, type IconButtonKind } from './standard/view';
111
112
  import { SvgFile } from './icon';
112
113
  import { countries, countryName, dialCodes, flagOf, regionOf } from './countries';
@@ -3193,7 +3194,7 @@ export function LeadingImage({ src, alt = '' }: { src: string; alt?: string }) {
3193
3194
  return <img src={src} alt={alt} loading="lazy" className="size-10 rounded-(--block-radius-small) bg-tint object-cover" />;
3194
3195
  }
3195
3196
 
3196
- /** What a design token is, for the sample of it before its row ("Dele" › "Værdier", Tokens.tsx). */
3197
+ /** What a design token is, for the sample of it before its row ("Parts" › "Værdier", Tokens.tsx). */
3197
3198
  export type TokenKind = 'shape' | 'elevation' | 'font' | 'color';
3198
3199
 
3199
3200
  /** A sample of one of the theme's design tokens before its name in a row, as a ListItem's `leading`, beside its first
@@ -3911,6 +3912,7 @@ const fabProps = ({ href, onClick, busy, disabled }: FabAction) => ({
3911
3912
  export function FabMenu({ icon: Glyph, label, items }: { icon: Icon; label: string; items: FabAction[] }) {
3912
3913
  const ref = useRef<HTMLDivElement>(null);
3913
3914
  const menu = items.length > 1;
3915
+ useRegisterFab(items.length > 0);
3914
3916
  useEffect(() => {
3915
3917
  const root = ref.current?.querySelector<HTMLElement>('[data-fab-menu]');
3916
3918
  return root ? setUpFabMenu(root) : undefined;
@@ -0,0 +1,30 @@
1
+ // Gives a screen's <main> data-clearance="true" while its content pushes the footer below the window (so the floating action
2
+ // button, if the screen has one, has room under it) and "false" while the footer sits at the bottom of the window. Exposes useFooterClearance. It
3
+ // measures the page with the clearance off, so the answer cannot flip back and forth; the decision is needsClearance in
4
+ // lib/footerClearance.mjs. The attribute is set on the element, with no re-render.
5
+ import { useLayoutEffect, type RefObject } from 'react';
6
+ import { needsClearance } from '../lib/footerClearance.mjs';
7
+
8
+ export default function useFooterClearance(ref: RefObject<HTMLElement | null>, hasFab: boolean) {
9
+ useLayoutEffect(() => {
10
+ const main = ref.current;
11
+ if (!main) return;
12
+ // The page's layout height (offsetHeight), not scrollHeight: that counts a screen's entrance animation, which moves it a few px.
13
+ const measure = () => {
14
+ main.dataset.clearance = 'false';
15
+ const root = document.documentElement;
16
+ main.dataset.clearance = String(needsClearance(document.body.offsetHeight, root.clientHeight, hasFab));
17
+ };
18
+ measure();
19
+ const observer = new ResizeObserver(measure);
20
+ // Watch the parts inside <main> and what lies beside it and its ancestors (the top bar), not <main> itself: their
21
+ // size does not depend on the clearance, so a change in them is a real change of the page.
22
+ for (let el: Element | null = main; el && el !== document.documentElement; el = el.parentElement)
23
+ for (const part of el === main ? el.children : (el.parentElement?.children ?? [])) observer.observe(part);
24
+ window.addEventListener('resize', measure);
25
+ return () => {
26
+ observer.disconnect();
27
+ window.removeEventListener('resize', measure);
28
+ };
29
+ }, [ref, hasFab]);
30
+ }
@@ -0,0 +1,24 @@
1
+ // Hides the dividers (marked data-divider) that stand first or last on a line of a wrapping row, with visibility: hidden so
2
+ // the widths stay and the row does not wrap again. Exposes useStrayDividers. It measures the row's items by their
3
+ // vertical centre (the decision is strayDividers in lib/strayDividers.mjs); a ResizeObserver on the row measures again when it
4
+ // wraps differently. The style is set on the elements, with no re-render.
5
+ import { useLayoutEffect, type RefObject } from 'react';
6
+ import { strayDividers } from '../lib/strayDividers.mjs';
7
+
8
+ export default function useStrayDividers(ref: RefObject<HTMLElement | null>) {
9
+ useLayoutEffect(() => {
10
+ const row = ref.current;
11
+ if (!row) return;
12
+ const measure = () => {
13
+ const items = [...row.children] as HTMLElement[];
14
+ const stray = new Set(strayDividers(items.map((el) => el.offsetTop + el.offsetHeight / 2)));
15
+ items.forEach((el, i) => {
16
+ if (el.dataset.divider !== undefined) el.style.visibility = stray.has(i) ? 'hidden' : '';
17
+ });
18
+ };
19
+ measure();
20
+ const observer = new ResizeObserver(measure);
21
+ observer.observe(row);
22
+ return () => observer.disconnect();
23
+ }, [ref]);
24
+ }
@@ -1,17 +1,17 @@
1
1
  ---
2
- // A place on every page where the apps installed put what they have for it (src/apps/<app>/slots/
2
+ // A place on every page where the active apps (installed, not turned off) put what they have for it (src/apps/<app>/slots/
3
3
  // <name>.astro, packages/editor/site/apps.ts): `head` in <head> (a script, a stylesheet), `body-end` at the end of
4
4
  // <body> (a banner, a dialog). Base.astro has the two places and nothing else about apps. An app that is
5
- // not installed puts nothing there.
5
+ // not installed, or turned off, puts nothing there.
6
6
  import type { AstroComponentFactory } from 'astro/runtime/server/index.js';
7
- import { installed } from '@morphemecms/cms/site/apps';
7
+ import { active } from '@morphemecms/cms/site/apps';
8
8
 
9
9
  type Props = { name: 'head' | 'body-end' };
10
10
  const { name } = Astro.props;
11
11
 
12
12
  const slots = import.meta.glob<{ default: AstroComponentFactory }>('/src/apps/*/slots/*.astro', { eager: true });
13
13
  const here = Object.entries(slots)
14
- .filter(([path]) => path.endsWith(`/slots/${name}.astro`) && installed.includes(path.split('/apps/')[1].split('/')[0]))
14
+ .filter(([path]) => path.endsWith(`/slots/${name}.astro`) && active.includes(path.split('/apps/')[1].split('/')[0]))
15
15
  .sort(([a], [b]) => a.localeCompare(b))
16
16
  .map(([, m]) => m.default);
17
17
  ---
@@ -382,6 +382,12 @@
382
382
  --badge-radius: var(--md-shape-full);
383
383
  --badge-surface: var(--error);
384
384
  --badge-text: var(--on-error);
385
+ /* A badge's status tones (Badge `tone`): each at least 3:1 on the page and surface colours (WCAG 1.4.11). Yellow
386
+ and orange are darker here and brighter in dark mode (below). */
387
+ --badge-ok: #1e8e3e;
388
+ --badge-minor: #b06e00;
389
+ --badge-major: #c25e00;
390
+ --badge-unknown: var(--outline);
385
391
  --snackbar-surface: var(--inverse-surface);
386
392
  --snackbar-text: var(--inverse-on-surface);
387
393
  --snackbar-padding-block: 0.875rem;
@@ -506,10 +512,14 @@
506
512
  @media (prefers-color-scheme: dark) {
507
513
  :root:not([data-theme='light']) {
508
514
  --shadow: var(--elevation-1-rest-shadow);
515
+ --badge-minor: #f9ab00;
516
+ --badge-major: #e8710a;
509
517
  }
510
518
  }
511
519
  :root[data-theme='dark'] {
512
520
  --shadow: var(--elevation-1-rest-shadow);
521
+ --badge-minor: #f9ab00;
522
+ --badge-major: #e8710a;
513
523
  }
514
524
 
515
525
  @theme inline {
@@ -5079,6 +5079,19 @@
5079
5079
  color: var(--badge-text, var(--block-on-accent));
5080
5080
  pointer-events: none;
5081
5081
  }
5082
+ /* A status tone (Badge `tone`): the dot in the tone's colour instead of the error colour. */
5083
+ .badge[data-tone='ok'] {
5084
+ background: var(--badge-ok);
5085
+ }
5086
+ .badge[data-tone='minor'] {
5087
+ background: var(--badge-minor);
5088
+ }
5089
+ .badge[data-tone='major'] {
5090
+ background: var(--badge-major);
5091
+ }
5092
+ .badge[data-tone='unknown'] {
5093
+ background: var(--badge-unknown);
5094
+ }
5082
5095
  .badge-small {
5083
5096
  width: var(--badge-small-size, 0.375rem);
5084
5097
  height: var(--badge-small-size, 0.375rem);
@@ -2,10 +2,14 @@
2
2
  // or a number (`count`, more than `max` shown as "999+"), on what it is about (`children`: an icon or an icon button,
3
3
  // at its top end corner, .badge-anchor) or by itself after a label (a navigation drawer's item). The badge is only seen:
4
4
  // what it says is read by screen readers from `label` (e.g. "3 nye beskeder"), or, on an icon button, from the button's
5
- // own name, which should say it. How it looks is the theme's (--badge-*). An Astro component gives an element the same
6
- // classes with badgeClass.
5
+ // own name, which should say it. How it looks is the theme's (--badge-*). `tone` (ok, minor, major, unknown) colours the
6
+ // badge as a status (green, yellow, orange, grey; written as data-tone, --badge-ok etc.); without it the badge keeps the
7
+ // error colour. An Astro component gives an element the same classes with badgeClass.
7
8
  import type { ReactNode } from 'react';
8
9
 
10
+ /** A badge's status tone: how a status dot is coloured. */
11
+ export type BadgeTone = 'ok' | 'minor' | 'major' | 'unknown';
12
+
9
13
  /** A badge's classes: the small dot, or the large one with a number. */
10
14
  export const badgeClass = (large: boolean) => `badge ${large ? 'badge-large' : 'badge-small'}`;
11
15
 
@@ -13,6 +17,7 @@ export default function Badge({
13
17
  count,
14
18
  max = 999,
15
19
  label,
20
+ tone,
16
21
  className,
17
22
  children,
18
23
  ...rest
@@ -20,12 +25,13 @@ export default function Badge({
20
25
  count?: number;
21
26
  max?: number;
22
27
  label?: string;
28
+ tone?: BadgeTone;
23
29
  className?: string;
24
30
  children?: ReactNode;
25
31
  } & Record<string, unknown>) {
26
32
  const large = count !== undefined;
27
33
  const badge = (
28
- <span className={[badgeClass(large), className].filter(Boolean).join(' ')} aria-hidden="true" {...rest}>
34
+ <span className={[badgeClass(large), className].filter(Boolean).join(' ')} aria-hidden="true" data-tone={tone} {...rest}>
29
35
  {large && (count > max ? `${max}+` : count)}
30
36
  </span>
31
37
  );
@@ -1,13 +1,17 @@
1
1
  // The Worker takes the CMS's new versions by itself: each hour it asks npm for the newest @morphemecms/cms, commits the new exact
2
2
  // version in package.json and package-lock.json, and each minute watches the commit's check run, undoing a version that did not build.
3
- // Exposes RUNNING, checkForUpdate, startUpdate, watchUpdate, cmsStatus and handleCms (/api/cms). Needs GITHUB_PUBLISH_TOKEN and the
4
- // KV binding PUSH. Depends on github.js, session.js, push.js and lib/{lockfile,cms-version,changelog}.mjs; I/O is injected (`deps`).
3
+ // Exposes RUNNING, checkForUpdate, startUpdate, watchUpdate, cmsStatus and handleCms (/api/cms, and GET /api/cms/note-image/<version>/<locale>/<id>,
4
+ // behind the same login check). Needs GITHUB_PUBLISH_TOKEN and the KV binding PUSH. Keeps each new version's changelog text and release
5
+ // notes (en-US, da-DK) as cms:notes:<version> and each card screenshot as cms:note-image:<version>:<locale>:<id>; cmsStatus returns
6
+ // the notes to come and the installed ones, with the screenshot address on each card. Depends on github.js, session.js, push.js and lib/{lockfile,cms-version,changelog,releaseNotes}.mjs;
7
+ // I/O is injected (`deps`).
5
8
  import { config } from '@site/config';
6
9
  import { cms as cmsEn } from '../src/i18n/en-US/cms';
7
10
  import { cms as cmsDa } from '../src/i18n/da-DK/cms';
8
11
  import { addToLock, NeedsNpm } from '../lib/lockfile.mjs';
9
12
  import { compareVersions, managedVersion, nextVersion, PACKAGE, watchStep } from '../lib/cms-version.mjs';
10
13
  import { fileFromTar, gunzip, sectionsBetween } from '../lib/changelog.mjs';
14
+ import { imageKey, installedVersions, notesFromTar, parseImagePath, withImageUrls } from '../lib/releaseNotes.mjs';
11
15
  import pkg from '../package.json';
12
16
  import { GitHubError } from './files.js';
13
17
  import { commitFiles, readFiles } from './github.js';
@@ -92,15 +96,20 @@ export async function startUpdate(env, version, deps = defaultDeps, now = Date.n
92
96
  return update;
93
97
  }
94
98
 
95
- /** The sections of the changelog from `current` to `latest`, each kept as cms:notes:<version>. */
99
+ /** The sections of the changelog from `current` to `latest`, each kept as cms:notes:<version> with its release notes per locale, when the tar has them. */
96
100
  async function keepNotes(env, deps, current, latest) {
97
101
  const manifest = await getJson(deps, `${NPM}/${NPM_NAME}/${latest}`);
98
102
  const res = await deps.fetch(manifest.dist.tarball);
99
103
  if (!res.ok) return;
100
- const changelog = fileFromTar(await gunzip(new Uint8Array(await res.arrayBuffer())), 'package/CHANGELOG.md');
104
+ const tar = await gunzip(new Uint8Array(await res.arrayBuffer()));
105
+ const changelog = fileFromTar(tar, 'package/CHANGELOG.md');
101
106
  if (!changelog) return;
102
- for (const { version, text } of sectionsBetween(changelog, current, latest))
103
- await putJson(env.PUSH, `cms:notes:${version}`, { version, text });
107
+ for (const { version, text } of sectionsBetween(changelog, current, latest)) {
108
+ const kept = notesFromTar(tar, version);
109
+ const notes = kept?.notes;
110
+ for (const { locale, id, bytes } of kept?.images ?? []) await env.PUSH.put(imageKey(version, locale, id), bytes);
111
+ await putJson(env.PUSH, `cms:notes:${version}`, { version, text, ...(notes ? { notes } : {}) });
112
+ }
104
113
  }
105
114
 
106
115
  const versionsUnder = async (kv, prefix) => (await kv.list({ prefix })).keys.map((k) => k.name.slice(prefix.length));
@@ -200,28 +209,56 @@ export async function watchUpdate(env, deps = defaultDeps, now = Date.now()) {
200
209
  return tell(env, deps, 'notifyStuck', update.to, true);
201
210
  }
202
211
 
203
- /** What the page shows: the running version, the token, what npm said, the update, the skipped versions and the notes; no notes when the running version is a pre-release. */
212
+ /**
213
+ * What the page shows: the running version, the token, what npm said, the update, the skipped versions, the notes of the
214
+ * versions still to come (`notes`) and those of the versions installed (`installed`, see installedVersions). Each entry is
215
+ * `{ version, text, notes? }`; `notes` maps a locale to its release notes. Both lists stay empty when the running version is a pre-release.
216
+ */
204
217
  export async function cmsStatus(env, running = RUNNING) {
205
218
  const kv = env.PUSH;
206
- const status = { running, token: !!env.GITHUB_PUBLISH_TOKEN, kv: !!kv, checked: null, update: null, skipped: [], notes: [] };
219
+ const status = {
220
+ running,
221
+ token: !!env.GITHUB_PUBLISH_TOKEN,
222
+ kv: !!kv,
223
+ checked: null,
224
+ update: null,
225
+ skipped: [],
226
+ notes: [],
227
+ installed: [],
228
+ };
207
229
  const plain = /^\d+\.\d+\.\d+$/;
208
230
  if (!kv) return status;
209
231
  status.checked = await kv.get('cms:checked', 'json');
210
232
  status.update = await kv.get('cms:update', 'json');
211
233
  status.skipped = await versionsUnder(kv, 'cms:skip:');
212
234
  if (!plain.test(running)) return status;
213
- const wanted = (await versionsUnder(kv, 'cms:notes:')).filter(
235
+ const kept = await versionsUnder(kv, 'cms:notes:');
236
+ const entries = (rows) =>
237
+ rows.filter(Boolean).map(({ version, text, notes }) => ({ version, text, notes: withImageUrls(version, notes) }));
238
+ const wanted = kept.filter(
214
239
  (v) =>
215
240
  plain.test(v) && compareVersions(v, running) === 1 && (!status.checked?.latest || compareVersions(v, status.checked.latest) <= 0),
216
241
  );
217
242
  wanted.sort((a, b) => compareVersions(b, a));
218
- const notes = await Promise.all(wanted.map((v) => kv.get(`cms:notes:${v}`, 'json')));
219
- status.notes = notes.filter(Boolean).map(({ version, text }) => ({ version, text }));
243
+ status.notes = entries(await Promise.all(wanted.map((v) => kv.get(`cms:notes:${v}`, 'json'))));
244
+ const installed = installedVersions(status.update, running, kept);
245
+ status.installed = entries(await Promise.all(installed.map((v) => kv.get(`cms:notes:${v}`, 'json'))));
220
246
  return status;
221
247
  }
222
248
 
223
- /** `GET /api/cms` (the status) and `POST /api/cms/update { version }`; null for other addresses. */
249
+ /** `GET /api/cms/note-image/<version>/<locale>/<id>`: a kept screenshot, 404 for a bad address or a missing one. */
250
+ async function noteImage(request, env, deps) {
251
+ if (request.method !== 'GET') return json({ error: 'method' }, 405);
252
+ if (!(await deps.mayEdit(request))) return json({ error: 'forbidden' }, 403);
253
+ const parts = parseImagePath(new URL(request.url).pathname);
254
+ const bytes = parts && env.PUSH ? await env.PUSH.get(imageKey(parts.version, parts.locale, parts.id), 'arrayBuffer') : null;
255
+ if (!bytes) return json({ error: 'not-found' }, 404);
256
+ return new Response(bytes, { headers: { 'content-type': 'image/webp', 'cache-control': 'private, max-age=31536000, immutable' } });
257
+ }
258
+
259
+ /** `GET /api/cms` (the status), `POST /api/cms/update { version }` and `GET /api/cms/note-image/...`; null for other addresses. */
224
260
  export async function handleCms(request, env, ctx, deps = defaultDeps) {
261
+ if (new URL(request.url).pathname.startsWith('/api/cms/note-image/')) return noteImage(request, env, deps);
225
262
  const match = /^\/api\/cms(\/update)?\/?$/.exec(new URL(request.url).pathname);
226
263
  if (!match) return null;
227
264
  const posting = !!match[1];
package/worker/index.js CHANGED
@@ -21,17 +21,19 @@
21
21
  // those older than two years deleted.
22
22
  // - whether R2 caching can be turned on in the editor: whether Cloudflare has its bucket (/api/r2, packages/editor/worker/r2-status.js).
23
23
  // - whether the account has Workers Paid, for the switch "Betalt bygning" in the editor (/api/plan, packages/editor/worker/plan-status.js).
24
+ // - the status of GitHub and Cloudflare, for the editor's footer (/api/status, packages/editor/worker/service-status.js).
24
25
  // - the editor on its own address when EDITOR_HOST is set (packages/editor/worker/editor-host.js); noindex there too.
25
26
  // - each hour, the pages and posts that are Planlagt published once their time has come (scheduled, packages/editor/worker/publish.js).
26
27
  // - the editor's notifications on the phone, also when the editor is closed (/api/push, packages/editor/worker/push.js): each minute,
27
28
  // whether the site has been built with a save, and an app's notifications (`notify` in its tools).
28
29
  // - the CMS's own updates (/api/cms, packages/editor/worker/cms-update.js): each hour, whether npm has a newer @morphemecms/cms to commit, and
29
30
  // each minute, whether the update built, else it is undone.
30
- // - the apps' own parts (src/apps/<app>/worker.js, worker/apps.js), while they are installed: their addresses under
31
+ // - the apps' own parts (src/apps/<app>/worker.js, worker/apps.js), while they are installed and not turned off: their addresses under
31
32
  // /api/<app>/ and what they do each hour (scheduled), e.g. Cookiescanner's scan of the site's cookies, and their texts
32
33
  // for their notifications. What the apps
33
34
  // put in the build (dist/_apps/<app>/, packages/editor/lib/apps.mjs) is served to no one; the apps read it.
34
35
  import { apps, appTexts, appWorkers, moved, oldAddresses as map, standard } from '@site/worker';
36
+ import { activeOf, readAppsFile } from '../lib/appsFile.mjs';
35
37
  import { handleOAuth } from './oauth.js';
36
38
  import { editorHost } from './editor-host.js';
37
39
  import { handleNotFound, isVisit, json, recordNotFound } from './not-found.js';
@@ -41,6 +43,7 @@ import { handleGitHub } from './editor-github.js';
41
43
  import { handleConnection } from './store-connection.js';
42
44
  import { handleStore } from './store.js';
43
45
  import { handlePlan } from './plan-status.js';
46
+ import { handleStatus } from './service-status.js';
44
47
  import { handleR2 } from './r2-status.js';
45
48
  import { publishScheduled, SCHEDULED_LIST } from './publish.js';
46
49
  import { commitFiles, readFiles } from './github.js';
@@ -51,8 +54,10 @@ const STAGING = /\.workers\.dev$/i;
51
54
  // The cron in wrangler.jsonc that runs each minute.
52
55
  const EACH_MINUTE = '* * * * *';
53
56
 
54
- // The parts of the Worker of the apps installed (src/data/apps.json), by the app's id.
55
- const installed = Object.fromEntries(Object.entries(appWorkers).filter(([id]) => apps.installed?.includes(id)));
57
+ // The parts of the Worker of the apps installed and not turned off (src/data/apps.json), by the app's id. One turned off
58
+ // answers 404 at its addresses and has no `scheduled` run.
59
+ const active = activeOf(readAppsFile(JSON.stringify(apps)));
60
+ const installed = Object.fromEntries(Object.entries(appWorkers).filter(([id]) => active.includes(id)));
56
61
  // What an app is given, besides the request: whether its sender can save the site (signed in with GitHub), an answer
57
62
  // in JSON, the Worker's own saves to the repository (`github`, packages/editor/worker/github.js: `read` and `commit`, with the request's
58
63
  // `ctx`, so the cache in R2 is written after the answer has gone; given a request as the last argument, with its sender's
@@ -153,11 +158,12 @@ export default {
153
158
  if (url.pathname === '/api/consent') return handleConsent(request, env);
154
159
  if (url.pathname === '/api/r2') return handleR2(request, env);
155
160
  if (url.pathname === '/api/plan') return handlePlan(request, env);
161
+ if (url.pathname === '/api/status') return handleStatus(request, env);
156
162
  if (url.pathname.startsWith('/api/github/')) return handleGitHub(request, env, ctx);
157
163
  if (url.pathname === '/api/store/connection') return handleConnection(request, env, ctx);
158
164
  if (url.pathname.startsWith('/api/store/')) return handleStore(request, env, ctx);
159
165
  if (/^\/api\/push(\/wait)?\/?$/.test(url.pathname)) return handlePush(request, env);
160
- if (/^\/api\/cms(\/update)?\/?$/.test(url.pathname)) return handleCms(request, env, ctx);
166
+ if (/^\/api\/cms(\/update|\/note-image\/.*)?\/?$/.test(url.pathname)) return handleCms(request, env, ctx);
161
167
  const answer = appAnswer(request, url, env, ctx);
162
168
  if (answer) return answer;
163
169
  // The build's lists (what is Planlagt) and the apps' files (what the cookie scan visits) are the Worker's own.
@@ -1,4 +1,4 @@
1
- // Whether the Cloudflare account has Workers Paid, for "Indstillinger" › "Avanceret" › "Bygning" in the editor
1
+ // Whether the Cloudflare account has Workers Paid, for Settings › Developer › Caching and builds › "Builds" in the editor
2
2
  // (packages/editor/src/Advanced.tsx): the switch "Betalt bygning" can only be turned on when Cloudflare says so.
3
3
  // Asked of Cloudflare's API with the Worker's own key, the same token as for R2 (the secret CLOUDFLARE_R2_TOKEN, and
4
4
  // CLOUDFLARE_ACCOUNT_ID); it also needs Account › Billing › Read (docs/editor.md, Opsætning).
@@ -1,4 +1,4 @@
1
- // Whether R2 caching (packages/editor/worker/files.js, the binding FILES) can be turned on, for "Indstillinger" › "Avanceret" in the
1
+ // Whether R2 caching (packages/editor/worker/files.js, the binding FILES) can be turned on, for Settings › Developer › Caching and builds in the
2
2
  // editor (packages/editor/src/Advanced.tsx): the switch writes the bucket into the Worker's settings (wrangler.jsonc),
3
3
  // and a deploy with a bucket Cloudflare does not have fails, so it can only be turned on when Cloudflare says the bucket
4
4
  // is there (R2 turned on for the account, and the bucket made). Asked of Cloudflare's API with the Worker's own key, a
@@ -0,0 +1,18 @@
1
+ // The status of GitHub and Cloudflare, for the editor's footer (packages/editor: the status line).
2
+ // GET /api/status a StatusReport (lib/serviceStatus.mjs): { state, providers[] }.
3
+ // Both Statuspage feeds are fetched inside the request (cached by Cloudflare for 60 seconds, lib/serviceFeed.mjs); a feed that fails counts as unknown.
4
+ // Only the Cloudflare parts the site has bound count (R2 with FILES, D1 with CONSENT, KV with NOT_FOUND or PUSH,
5
+ // `needs` in the provider list); no binding name goes to the client, only the components. Only someone who can save the site (write access to the repository on GitHub) can ask.
6
+ import { json } from './not-found.js';
7
+ import { mayEdit } from './session.js';
8
+ import { PROVIDERS, providersFor, reportFrom } from '../lib/serviceStatus.mjs';
9
+ import { feedOf } from '../lib/serviceFeed.mjs';
10
+
11
+ export async function handleStatus(request, env) {
12
+ if (!(await mayEdit(request))) return json({ error: 'forbidden' }, 403);
13
+ if (request.method !== 'GET') return json({ error: 'method' }, 405);
14
+ const [github, cloudflare] = await Promise.all(PROVIDERS.map((provider) => feedOf(provider.feed)));
15
+ const names = new Set(PROVIDERS.flatMap((p) => p.components.flatMap((c) => c.needs ?? [])));
16
+ const bound = [...names].filter((name) => env[name] != null);
17
+ return json(reportFrom({ github, cloudflare }, providersFor(bound)));
18
+ }