@commonpub/layer 0.24.0 → 0.25.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 (82) hide show
  1. package/README.md +41 -12
  2. package/components/LayoutRow.vue +944 -0
  3. package/components/LayoutSection.vue +1028 -0
  4. package/components/LayoutSlot.vue +104 -162
  5. package/components/PageFrame.vue +116 -0
  6. package/components/admin/layouts/AdminLayoutsAnnouncer.vue +53 -0
  7. package/components/admin/layouts/AdminLayoutsAutoForm.vue +419 -0
  8. package/components/admin/layouts/AdminLayoutsCanvas.vue +332 -0
  9. package/components/admin/layouts/AdminLayoutsConflictModal.vue +266 -0
  10. package/components/admin/layouts/AdminLayoutsHelpOverlay.vue +346 -0
  11. package/components/admin/layouts/AdminLayoutsInspector.vue +157 -0
  12. package/components/admin/layouts/AdminLayoutsInspectorPage.vue +266 -0
  13. package/components/admin/layouts/AdminLayoutsInspectorRow.vue +80 -0
  14. package/components/admin/layouts/AdminLayoutsInspectorSection.vue +175 -0
  15. package/components/admin/layouts/AdminLayoutsPalette.vue +117 -0
  16. package/components/admin/layouts/AdminLayoutsPaletteTile.vue +149 -0
  17. package/components/admin/layouts/AdminLayoutsToolbar.vue +483 -0
  18. package/components/blocks/BlockDividerView.vue +52 -2
  19. package/components/homepage/ContentGridSection.vue +23 -1
  20. package/components/homepage/HeroSection.vue +69 -8
  21. package/components/sections/SectionCta.vue +175 -0
  22. package/composables/autoFormSchema.ts +319 -0
  23. package/composables/useAdminSidebar.ts +116 -0
  24. package/composables/useEditorChrome.ts +56 -0
  25. package/composables/useLayout.ts +34 -41
  26. package/composables/useLayoutAnnouncer.ts +332 -0
  27. package/composables/useLayoutAutoSave.ts +117 -0
  28. package/composables/useLayoutDrag.ts +290 -0
  29. package/composables/useLayoutEditor.ts +593 -0
  30. package/composables/useLayoutHistory.ts +583 -0
  31. package/composables/useLayoutHotkeys.ts +366 -0
  32. package/composables/useLayoutResize.ts +783 -0
  33. package/layouts/admin.vue +137 -24
  34. package/middleware/admin-layouts.ts +29 -0
  35. package/package.json +10 -7
  36. package/pages/[...customPath].vue +154 -0
  37. package/pages/admin/homepage.vue +46 -0
  38. package/pages/admin/index.vue +16 -0
  39. package/pages/admin/layouts/[id].vue +1110 -0
  40. package/pages/admin/layouts/index.vue +356 -0
  41. package/pages/explore.vue +16 -6
  42. package/sections/builtin/content-feed.ts +18 -29
  43. package/sections/builtin/contests.ts +11 -19
  44. package/sections/builtin/cta.ts +46 -0
  45. package/sections/builtin/custom-html.ts +16 -30
  46. package/sections/builtin/divider.ts +15 -17
  47. package/sections/builtin/editorial.ts +11 -21
  48. package/sections/builtin/embed.ts +31 -0
  49. package/sections/builtin/gallery.ts +29 -0
  50. package/sections/builtin/heading.ts +14 -19
  51. package/sections/builtin/hero.ts +16 -51
  52. package/sections/builtin/hubs.ts +11 -26
  53. package/sections/builtin/image.ts +12 -49
  54. package/sections/builtin/learning.ts +5 -13
  55. package/sections/builtin/markdown.ts +29 -0
  56. package/sections/builtin/paragraph.ts +14 -17
  57. package/sections/builtin/stats.ts +17 -18
  58. package/sections/builtin/video.ts +30 -0
  59. package/sections/registry.ts +11 -0
  60. package/server/api/admin/homepage/sections.put.ts +52 -1
  61. package/server/api/admin/layouts/[id]/publish.post.ts +12 -0
  62. package/server/api/admin/layouts/[id]/versions/[versionId]/revert.post.ts +11 -0
  63. package/server/api/admin/layouts/[id].delete.ts +33 -1
  64. package/server/api/admin/layouts/[id].put.ts +78 -0
  65. package/server/api/admin/layouts/index.post.ts +60 -4
  66. package/server/api/admin/layouts/migrate-homepage.post.ts +12 -0
  67. package/server/api/admin/layouts/seed-homepage.post.ts +9 -0
  68. package/server/api/layouts/by-route.get.ts +64 -12
  69. package/server/utils/layoutCache.ts +37 -1
  70. package/server/utils/validateSectionConfigs.ts +123 -0
  71. package/theme/base.css +1 -0
  72. package/components/sections/SectionContentFeed.vue +0 -160
  73. package/components/sections/SectionContests.vue +0 -193
  74. package/components/sections/SectionCustomHtml.vue +0 -70
  75. package/components/sections/SectionDivider.vue +0 -55
  76. package/components/sections/SectionEditorial.vue +0 -138
  77. package/components/sections/SectionHeading.vue +0 -78
  78. package/components/sections/SectionHero.vue +0 -164
  79. package/components/sections/SectionHubs.vue +0 -247
  80. package/components/sections/SectionImage.vue +0 -104
  81. package/components/sections/SectionParagraph.vue +0 -55
  82. package/components/sections/SectionStats.vue +0 -151
package/README.md CHANGED
@@ -27,7 +27,7 @@ export default defineCommonPubConfig({
27
27
  instance: {
28
28
  name: 'My Community',
29
29
  domain: 'example.com',
30
- contentTypes: ['project', 'article', 'blog', 'explainer'],
30
+ contentTypes: ['project', 'blog', 'explainer'],
31
31
  },
32
32
  features: {
33
33
  content: true,
@@ -38,34 +38,63 @@ export default defineCommonPubConfig({
38
38
  admin: true,
39
39
  },
40
40
  auth: {
41
- methods: ['email'],
41
+ emailPassword: true,
42
42
  },
43
43
  });
44
44
  ```
45
45
 
46
- Create `server/utils/config.ts` to load the config on the server side. See `apps/shell/server/utils/config.ts` for a complete example with environment variable overrides.
46
+ > `article` is a deprecated alias that normalises to `blog` on write (session 116); use `blog`, `project`, or `explainer` for new content (CLAUDE.md rule #6).
47
+
48
+ Create `server/utils/config.ts` to load the config on the server side. See `apps/reference/server/utils/config.ts` for a complete example with environment variable overrides.
47
49
 
48
50
  ## What's Included
49
51
 
50
- ### Pages (70+ routes)
52
+ ### Pages (90 routes)
53
+
54
+ Content CRUD (projects/blogs/explainers), hub feeds (community/product/company), learning paths, docs sites, contests, events, messages, notifications, search, user profiles, federation, **admin panel** (users, content, reports, settings, theme editor at `/admin/theme/edit/[id]`, layout editor at `/admin/layouts/[id]`), and more.
55
+
56
+ ### Components (132)
57
+
58
+ Content editor (`CpubEditor`), content cards, author rows, comment sections, engagement bars, federation UI, notification items, message threads, **21 block renderers** under `components/blocks/` (`BlockHeadingView`, `BlockCalloutView`, `BlockEmbedView`, `BlockMarkdownView`, `BlockGalleryView`, etc. — all `*View` suffixed), homepage section renderers (`HeroSection`, etc.), the **layout-editor admin chrome** (`AdminLayoutsToolbar`, `AdminLayoutsCanvas`, `AdminLayoutsPalette`, `AdminLayoutsInspector`, `AdminLayoutsConflictModal`), and the `<LayoutSlot>` renderer that arranges existing components per the layout engine.
59
+
60
+ ### Composables (33)
61
+
62
+ Highlights — see `layers/base/composables/*.ts` for the full set:
51
63
 
52
- Content CRUD, hub feeds, learning paths, docs sites, admin panel, federation management, user profiles, messaging, notifications, search, and more.
64
+ | Composable | Purpose |
65
+ |---|---|
66
+ | `useAuth` | Better Auth session + identity |
67
+ | `useFeatures` | Reactive feature-flag lookup |
68
+ | `useContentSave` / `usePublishValidation` | Save lifecycle for blocks-based content + pre-publish validation |
69
+ | `useEngagement` / `useRealtimeCounts` | Likes, comments, bookmarks + realtime counters |
70
+ | `useFederation` / `useMirrorContent` | AP discovery + mirrored content |
71
+ | `useMessages` / `useNotifications` | Realtime SSE streams |
72
+ | `useTheme` / `useThemeAdmin` | Dark/light + branded theme switch (cookie-persisted, no flash) + admin theme editor |
73
+ | `useAdminSidebar` | Desktop sidebar collapse + mobile drawer (session 161) |
74
+ | `useEditorChrome` | Layout-editor palette + inspector visibility (session 161) |
75
+ | `useLayoutEditor` / `useLayoutAutoSave` | Layout draft state, single-flight save, conflict throttle, pagehide beacon, version-counter dirty (sessions 160-162) |
76
+ | `useLayout` | Public layout resolution via `<LayoutSlot>` |
77
+ | `useMarkdownImport` / `useSanitize` | Markdown ingest + HTML/iframe sanitization |
78
+ | `useFocusTrap` / `useToast` / `useApiError` | Accessibility + UX utilities |
53
79
 
54
- ### Components (100+)
80
+ The TipTap block editor itself lives in `@commonpub/editor` (composable `useBlockEditor` is imported from there, not declared in the layer).
55
81
 
56
- Content editor (`CpubEditor`), content cards, author rows, comment sections, engagement bars, federation UI, notification items, message threads, block renderers, and more.
82
+ ### Server (~300 Nitro API routes)
57
83
 
58
- ### Composables (19)
84
+ API routes for all CommonPub features, auth middleware (`requireAdmin`, `requireFeature`), federation endpoints (Fedify-mounted), per-feature audit logging (`cpub.audit.*`), layout-engine CRUD at `/api/admin/layouts/*` (gated on `features.admin` + `features.layoutEngine`), and Nitro plugins for identity startup + feature-flag override.
59
85
 
60
- `useAuth`, `useFeatures`, `useBlockEditor`, `useContentSave`, `useEngagement`, `useFederation`, `useMessages`, `useNotifications`, `useTheme`, and more.
86
+ ### Layout engine + section registry
61
87
 
62
- ### Server
88
+ The layout engine ships a 12-column zone/row/section model with a section registry at `layers/base/sections/registry.ts`:
63
89
 
64
- API routes for all CommonPub features, auth middleware, federation endpoints, and Nitro plugins.
90
+ - **17 built-in sections** (`hero`, `heading`, `paragraph`, `image`, `content-feed`, `cta`, `learning`, `divider`, etc.). Each is a `SectionDefinition` pointing at an EXISTING `Block*` or `Homepage*` component via `propMap` — the engine ARRANGES, it doesn't render parallel renderers (see `feedback-reuse-existing-components`).
91
+ - **Per-section Zod schemas** in `@commonpub/schema/src/sectionConfigs.ts` (session 161) — enforced server-side at the layout API boundary with `cpub.audit.layout.config-rejected` audit logging.
92
+ - **Database tables** `layouts` / `layout_rows` / `layout_sections` / `layout_versions` (migration 0005). Layouts are instance-local — they NEVER federate via `@commonpub/protocol` per ADR 027.
93
+ - **Editor** at `/admin/layouts` (list) + `/admin/layouts/[id]` (3-column shell: palette / canvas / inspector). Auto-save 1.5s debounce + If-Match optimistic concurrency + 3-option conflict modal + cascade-throttle banner.
65
94
 
66
95
  ### Theme
67
96
 
68
- CSS custom properties with 3 built-in themes (base, dark, generics). Consumer apps override with their own `theme.css`.
97
+ CSS custom properties (`var(--*)` only — CLAUDE.md rule #3). Four user-selectable themes (`base`, `dark`, `agora`, `agora-dark`) plus structural CSS modules (`components.css`, `prose.css`, `editor-panels.css`, `forms.css`, `layouts.css`, `generics.css`). Admins can also create custom DB-stored themes via the theme editor at `/admin/theme` (session 154-156). Consumer apps override with their own `theme.css` and can shadow components for branding.
69
98
 
70
99
  ## Customization
71
100