@glw907/cairn-cms 0.62.2 → 0.76.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 (196) hide show
  1. package/CHANGELOG.md +216 -0
  2. package/dist/ambient.d.ts +2 -0
  3. package/dist/auth/types.d.ts +7 -0
  4. package/dist/components/CairnAdmin.svelte.d.ts +2 -7
  5. package/dist/components/ComponentForm.svelte +44 -27
  6. package/dist/components/ComponentInsertDialog.svelte +22 -11
  7. package/dist/components/ComponentInsertDialog.svelte.d.ts +2 -6
  8. package/dist/components/ConceptList.svelte +25 -4
  9. package/dist/components/EditPage.svelte +29 -107
  10. package/dist/components/EditPage.svelte.d.ts +2 -7
  11. package/dist/components/EntryPicker.svelte +117 -0
  12. package/dist/components/EntryPicker.svelte.d.ts +35 -0
  13. package/dist/components/FieldInput.svelte +218 -0
  14. package/dist/components/FieldInput.svelte.d.ts +51 -0
  15. package/dist/components/IconPicker.svelte +2 -2
  16. package/dist/components/IconPicker.svelte.d.ts +2 -0
  17. package/dist/components/LinkPicker.svelte +8 -75
  18. package/dist/components/LinkPicker.svelte.d.ts +4 -5
  19. package/dist/components/MediaHeroField.svelte +8 -5
  20. package/dist/components/MediaHeroField.svelte.d.ts +4 -0
  21. package/dist/components/ObjectGroupField.svelte +54 -0
  22. package/dist/components/ObjectGroupField.svelte.d.ts +47 -0
  23. package/dist/components/ReferenceField.svelte +94 -0
  24. package/dist/components/ReferenceField.svelte.d.ts +27 -0
  25. package/dist/components/RepeatableField.svelte +221 -0
  26. package/dist/components/RepeatableField.svelte.d.ts +53 -0
  27. package/dist/components/cairn-admin.css +179 -2
  28. package/dist/components/preview-doc.js +5 -1
  29. package/dist/components/tidy-validate.js +1 -1
  30. package/dist/content/adapter.js +18 -0
  31. package/dist/content/advisories.d.ts +2 -2
  32. package/dist/content/advisories.js +3 -5
  33. package/dist/content/compose.d.ts +7 -6
  34. package/dist/content/compose.js +26 -20
  35. package/dist/content/concepts.d.ts +21 -15
  36. package/dist/content/concepts.js +55 -32
  37. package/dist/content/field-rules.d.ts +15 -0
  38. package/dist/content/field-rules.js +38 -0
  39. package/dist/content/fields.d.ts +169 -0
  40. package/dist/content/fields.js +41 -0
  41. package/dist/content/fieldset.d.ts +107 -0
  42. package/dist/content/fieldset.js +386 -0
  43. package/dist/content/frontmatter-region.d.ts +38 -0
  44. package/dist/content/frontmatter-region.js +75 -0
  45. package/dist/content/frontmatter.d.ts +35 -2
  46. package/dist/content/frontmatter.js +232 -11
  47. package/dist/content/manifest.d.ts +34 -0
  48. package/dist/content/manifest.js +80 -4
  49. package/dist/content/media-refs.d.ts +2 -2
  50. package/dist/content/media-rewrite.js +1 -69
  51. package/dist/content/reference-index.d.ts +56 -0
  52. package/dist/content/reference-index.js +95 -0
  53. package/dist/content/references.d.ts +40 -0
  54. package/dist/content/references.js +0 -0
  55. package/dist/content/standard-schema.d.ts +30 -0
  56. package/dist/content/standard-schema.js +4 -0
  57. package/dist/content/types.d.ts +127 -178
  58. package/dist/delivery/data.d.ts +2 -2
  59. package/dist/delivery/data.js +1 -1
  60. package/dist/delivery/public-routes.d.ts +10 -5
  61. package/dist/delivery/public-routes.js +25 -2
  62. package/dist/delivery/site-descriptors.d.ts +5 -1
  63. package/dist/delivery/site-descriptors.js +8 -3
  64. package/dist/delivery/site-indexes.d.ts +2 -2
  65. package/dist/delivery/site-resolver.d.ts +25 -0
  66. package/dist/delivery/site-resolver.js +49 -0
  67. package/dist/doctor/checks-local.js +6 -11
  68. package/dist/github/backend.d.ts +83 -0
  69. package/dist/github/backend.js +76 -0
  70. package/dist/github/credentials.d.ts +11 -5
  71. package/dist/github/credentials.js +3 -3
  72. package/dist/github/repo.d.ts +8 -19
  73. package/dist/github/repo.js +69 -80
  74. package/dist/github/types.d.ts +1 -1
  75. package/dist/github/types.js +4 -4
  76. package/dist/index.d.ts +18 -10
  77. package/dist/index.js +9 -5
  78. package/dist/islands/index.d.ts +12 -0
  79. package/dist/islands/index.js +83 -0
  80. package/dist/islands/types.d.ts +7 -0
  81. package/dist/islands/types.js +1 -0
  82. package/dist/log/events.d.ts +1 -1
  83. package/dist/media/index.d.ts +1 -1
  84. package/dist/media/index.js +1 -1
  85. package/dist/media/manifest.d.ts +11 -0
  86. package/dist/media/manifest.js +13 -0
  87. package/dist/media/rewrite-plan.d.ts +2 -3
  88. package/dist/media/rewrite-plan.js +2 -3
  89. package/dist/media/usage.d.ts +2 -2
  90. package/dist/media/usage.js +3 -5
  91. package/dist/nav/site-config.d.ts +0 -6
  92. package/dist/nav/site-config.js +6 -4
  93. package/dist/render/component-grammar.js +11 -11
  94. package/dist/render/component-reference.js +5 -3
  95. package/dist/render/component-validate.d.ts +4 -1
  96. package/dist/render/component-validate.js +10 -35
  97. package/dist/render/highlight.d.ts +9 -0
  98. package/dist/render/highlight.js +206 -0
  99. package/dist/render/pipeline.d.ts +0 -6
  100. package/dist/render/pipeline.js +13 -2
  101. package/dist/render/registry.d.ts +44 -36
  102. package/dist/render/registry.js +47 -6
  103. package/dist/render/rehype-dispatch.d.ts +6 -10
  104. package/dist/render/rehype-dispatch.js +38 -17
  105. package/dist/render/remark-directives.js +4 -5
  106. package/dist/render/sanitize-schema.d.ts +10 -0
  107. package/dist/render/sanitize-schema.js +30 -1
  108. package/dist/sveltekit/cairn-admin.d.ts +5 -5
  109. package/dist/sveltekit/cairn-admin.js +3 -4
  110. package/dist/sveltekit/content-routes.d.ts +10 -8
  111. package/dist/sveltekit/content-routes.js +269 -181
  112. package/dist/sveltekit/guard.js +10 -0
  113. package/dist/sveltekit/health.d.ts +7 -3
  114. package/dist/sveltekit/health.js +9 -3
  115. package/dist/sveltekit/index.d.ts +1 -1
  116. package/dist/sveltekit/nav-routes.d.ts +6 -5
  117. package/dist/sveltekit/nav-routes.js +22 -20
  118. package/dist/sveltekit/types.d.ts +2 -0
  119. package/dist/vite/index.d.ts +3 -3
  120. package/dist/vite/index.js +17 -8
  121. package/package.json +17 -2
  122. package/src/lib/ambient.ts +7 -0
  123. package/src/lib/auth/types.ts +7 -0
  124. package/src/lib/components/CairnAdmin.svelte +2 -6
  125. package/src/lib/components/ComponentForm.svelte +48 -27
  126. package/src/lib/components/ComponentInsertDialog.svelte +26 -14
  127. package/src/lib/components/ConceptList.svelte +41 -4
  128. package/src/lib/components/EditPage.svelte +43 -119
  129. package/src/lib/components/EntryPicker.svelte +154 -0
  130. package/src/lib/components/FieldInput.svelte +262 -0
  131. package/src/lib/components/IconPicker.svelte +4 -2
  132. package/src/lib/components/LinkPicker.svelte +10 -81
  133. package/src/lib/components/MediaHeroField.svelte +12 -5
  134. package/src/lib/components/ObjectGroupField.svelte +97 -0
  135. package/src/lib/components/ReferenceField.svelte +126 -0
  136. package/src/lib/components/RepeatableField.svelte +310 -0
  137. package/src/lib/components/preview-doc.ts +5 -1
  138. package/src/lib/components/tidy-validate.ts +1 -1
  139. package/src/lib/content/adapter.ts +21 -0
  140. package/src/lib/content/advisories.ts +4 -7
  141. package/src/lib/content/compose.ts +30 -23
  142. package/src/lib/content/concepts.ts +68 -40
  143. package/src/lib/content/field-rules.ts +39 -0
  144. package/src/lib/content/fields.ts +178 -0
  145. package/src/lib/content/fieldset.ts +470 -0
  146. package/src/lib/content/frontmatter-region.ts +90 -0
  147. package/src/lib/content/frontmatter.ts +231 -15
  148. package/src/lib/content/manifest.ts +101 -4
  149. package/src/lib/content/media-refs.ts +2 -2
  150. package/src/lib/content/media-rewrite.ts +7 -80
  151. package/src/lib/content/reference-index.ts +159 -0
  152. package/src/lib/content/references.ts +0 -0
  153. package/src/lib/content/standard-schema.ts +25 -0
  154. package/src/lib/content/types.ts +128 -195
  155. package/src/lib/delivery/data.ts +2 -2
  156. package/src/lib/delivery/public-routes.ts +36 -4
  157. package/src/lib/delivery/site-descriptors.ts +8 -3
  158. package/src/lib/delivery/site-indexes.ts +2 -2
  159. package/src/lib/delivery/site-resolver.ts +64 -0
  160. package/src/lib/doctor/checks-local.ts +6 -14
  161. package/src/lib/github/backend.ts +161 -0
  162. package/src/lib/github/credentials.ts +10 -7
  163. package/src/lib/github/repo.ts +79 -83
  164. package/src/lib/github/types.ts +5 -5
  165. package/src/lib/index.ts +40 -18
  166. package/src/lib/islands/index.ts +84 -0
  167. package/src/lib/islands/types.ts +11 -0
  168. package/src/lib/log/events.ts +1 -0
  169. package/src/lib/media/index.ts +1 -0
  170. package/src/lib/media/manifest.ts +14 -0
  171. package/src/lib/media/rewrite-plan.ts +4 -6
  172. package/src/lib/media/usage.ts +4 -7
  173. package/src/lib/nav/site-config.ts +8 -9
  174. package/src/lib/render/component-grammar.ts +10 -10
  175. package/src/lib/render/component-reference.ts +4 -3
  176. package/src/lib/render/component-validate.ts +10 -35
  177. package/src/lib/render/highlight.ts +259 -0
  178. package/src/lib/render/pipeline.ts +13 -8
  179. package/src/lib/render/registry.ts +88 -42
  180. package/src/lib/render/rehype-dispatch.ts +47 -16
  181. package/src/lib/render/remark-directives.ts +4 -5
  182. package/src/lib/render/sanitize-schema.ts +32 -1
  183. package/src/lib/sveltekit/cairn-admin.ts +8 -9
  184. package/src/lib/sveltekit/content-routes.ts +330 -221
  185. package/src/lib/sveltekit/guard.ts +15 -0
  186. package/src/lib/sveltekit/health.ts +13 -6
  187. package/src/lib/sveltekit/index.ts +2 -2
  188. package/src/lib/sveltekit/nav-routes.ts +33 -29
  189. package/src/lib/sveltekit/types.ts +5 -1
  190. package/src/lib/vite/index.ts +20 -11
  191. package/dist/content/schema.d.ts +0 -87
  192. package/dist/content/schema.js +0 -89
  193. package/dist/content/validate.d.ts +0 -17
  194. package/dist/content/validate.js +0 -93
  195. package/src/lib/content/schema.ts +0 -167
  196. package/src/lib/content/validate.ts +0 -90
@@ -1,6 +1,7 @@
1
1
  import { defaultSchema, type Schema } from 'hast-util-sanitize';
2
2
  import type { Root, Element } from 'hast';
3
3
  import { visit } from 'unist-util-visit';
4
+ import { toString } from 'hast-util-to-string';
4
5
  import { dataAttrProp, type ComponentRegistry } from './registry.js';
5
6
 
6
7
  // The fixed directive markers the stamp writes and the dispatch reads. They are inert data
@@ -22,7 +23,7 @@ export function buildSanitizeSchema(
22
23
  registry: ComponentRegistry,
23
24
  extend?: (defaults: Schema) => Schema,
24
25
  ): Schema {
25
- const attrMarkers = registry.defs.flatMap((d) => (d.attributes ?? []).map((a) => dataAttrProp(a.key)));
26
+ const attrMarkers = registry.defs.flatMap((d) => Object.keys(d.attributes ?? {}).map((key) => dataAttrProp(key)));
26
27
  const markers = [...FIXED_MARKERS, ...attrMarkers];
27
28
  const attributes = defaultSchema.attributes ?? {};
28
29
  // defaultSchema's `a` entry carries a className tuple (`['className', 'data-footnote-backref']`)
@@ -68,6 +69,36 @@ export function rehypeAnchorRel(rel: string) {
68
69
  };
69
70
  }
70
71
 
72
+ /**
73
+ * Give every GFM task-list checkbox an accessible name from its item text. remark-gfm emits a real
74
+ * `<input type="checkbox" disabled>` with no label, which axe's `label` rule flags as a critical
75
+ * violation even though the control is read-only; the visible label is the surrounding `<li>` text,
76
+ * not associated programmatically. This sets `aria-label` on each task-list checkbox to its item's
77
+ * text so the name travels with the control, keeping the engine's real disabled input (the bar's
78
+ * non-color cue) while clearing the violation on every site. It must run after the sanitize floor,
79
+ * which does not allow `aria-label`, so the attribute is added once the floor has run.
80
+ */
81
+ export function rehypeTaskListA11y() {
82
+ return (tree: Root) => {
83
+ visit(tree, 'element', (node: Element) => {
84
+ const className = node.properties?.className;
85
+ const isTaskItem =
86
+ node.tagName === 'li' && Array.isArray(className) && className.includes('task-list-item');
87
+ if (!isTaskItem) return;
88
+ const checkbox = node.children.find(
89
+ (child): child is Element =>
90
+ child.type === 'element' &&
91
+ child.tagName === 'input' &&
92
+ child.properties?.type === 'checkbox',
93
+ );
94
+ if (!checkbox) return;
95
+ const label = toString(node).trim();
96
+ // Only when there is text to name it; an empty item leaves the box unnamed rather than blank.
97
+ if (label) (checkbox.properties ??= {})['ariaLabel'] = label;
98
+ });
99
+ };
100
+ }
101
+
71
102
  // URL-bearing hast properties the post-dispatch guard scheme-checks. hast camelCases attribute
72
103
  // names through property-information (srcset -> srcSet, xlink:href -> xLinkHref with a capital L,
73
104
  // formaction -> formAction). data is the <object data> URL attribute; data-* attributes camelCase
@@ -22,7 +22,7 @@ import { createEditorRoutes } from './editors-routes.js';
22
22
  import { createNavRoutes, type NavLoadData } from './nav-routes.js';
23
23
  import type { AuthBranding, SendMagicLink } from '../email.js';
24
24
  import type { AuthEnv, Editor } from '../auth/types.js';
25
- import type { GithubKeyEnv } from '../github/credentials.js';
25
+ import type { BackendEnv } from '../github/credentials.js';
26
26
  import type { CairnRuntime } from '../content/types.js';
27
27
  import type { CookieJar, EventBase } from './types.js';
28
28
 
@@ -31,20 +31,20 @@ import type { CookieJar, EventBase } from './types.js';
31
31
  * (ContentEvent minus params, which the dispatcher synthesizes, plus RequestContext's cookies
32
32
  * and setHeaders). A real SvelteKit RequestEvent satisfies it.
33
33
  */
34
- export interface AdminEvent extends EventBase<GithubKeyEnv & AuthEnv> {
34
+ export interface AdminEvent extends EventBase<BackendEnv & AuthEnv> {
35
35
  cookies: CookieJar;
36
36
  setHeaders(headers: Record<string, string>): void;
37
37
  }
38
38
 
39
39
  /**
40
40
  * Injectable dependencies. Branding defaults from the runtime's siteName and sender, so a
41
- * site overrides it only to change the magic-link email identity; `send` and `mintToken`
42
- * are the same seams the underlying factories take.
41
+ * site overrides it only to change the magic-link email identity; `send` is the same seam the
42
+ * underlying auth factory takes. The content backend rides `event.locals.backend` (the dev double)
43
+ * or the adapter's provider, so it is not a dep here.
43
44
  */
44
45
  export interface CairnAdminDeps {
45
46
  branding?: AuthBranding;
46
47
  send?: SendMagicLink;
47
- mintToken?: ContentRoutesDeps['mintToken'];
48
48
  /**
49
49
  * Build the Anthropic client for the tidy action. Forwarded to the content routes; a site that
50
50
  * enables tidy injects a stub here to avoid a real network call. Defaults to the real SDK client.
@@ -83,13 +83,12 @@ export function createCairnAdmin(runtime: CairnRuntime, deps: CairnAdminDeps = {
83
83
  };
84
84
  const auth = createAuthRoutes({ branding, send: deps.send });
85
85
  const content = createContentRoutes(runtime, {
86
- mintToken: deps.mintToken,
87
86
  anthropic: deps.anthropic,
88
87
  tidyTimeoutMs: deps.tidyTimeoutMs,
89
88
  });
90
89
  const editors = createEditorRoutes();
91
90
  // The nav surface exists only when the site configures a menu; without one its view is a 404.
92
- const nav = runtime.navMenu ? createNavRoutes(runtime, { mintToken: deps.mintToken }) : null;
91
+ const nav = runtime.navMenu ? createNavRoutes(runtime) : null;
93
92
 
94
93
  /**
95
94
  * Build the event a wrapped content load reads. The catch-all route carries only a rest
@@ -111,8 +110,8 @@ export function createCairnAdmin(runtime: CairnRuntime, deps: CairnAdminDeps = {
111
110
 
112
111
  /**
113
112
  * Serve the admin view the pathname names, or a 404 for any shape the parser refuses.
114
- * The authed views run the layout load and the view load concurrently; both mint a GitHub
115
- * token, and the installation-token cache coalesces the mints into one signing.
113
+ * The authed views run the layout load and the view load concurrently; both resolve the same
114
+ * backend, and the installation-token cache coalesces their lazy mints into one signing.
116
115
  */
117
116
  async function load(event: AdminEvent): Promise<AdminData> {
118
117
  const view = parseAdminPath(event.url.pathname, runtime.concepts);