@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.
- package/CHANGELOG.md +216 -0
- package/dist/ambient.d.ts +2 -0
- package/dist/auth/types.d.ts +7 -0
- package/dist/components/CairnAdmin.svelte.d.ts +2 -7
- package/dist/components/ComponentForm.svelte +44 -27
- package/dist/components/ComponentInsertDialog.svelte +22 -11
- package/dist/components/ComponentInsertDialog.svelte.d.ts +2 -6
- package/dist/components/ConceptList.svelte +25 -4
- package/dist/components/EditPage.svelte +29 -107
- package/dist/components/EditPage.svelte.d.ts +2 -7
- package/dist/components/EntryPicker.svelte +117 -0
- package/dist/components/EntryPicker.svelte.d.ts +35 -0
- package/dist/components/FieldInput.svelte +218 -0
- package/dist/components/FieldInput.svelte.d.ts +51 -0
- package/dist/components/IconPicker.svelte +2 -2
- package/dist/components/IconPicker.svelte.d.ts +2 -0
- package/dist/components/LinkPicker.svelte +8 -75
- package/dist/components/LinkPicker.svelte.d.ts +4 -5
- package/dist/components/MediaHeroField.svelte +8 -5
- package/dist/components/MediaHeroField.svelte.d.ts +4 -0
- package/dist/components/ObjectGroupField.svelte +54 -0
- package/dist/components/ObjectGroupField.svelte.d.ts +47 -0
- package/dist/components/ReferenceField.svelte +94 -0
- package/dist/components/ReferenceField.svelte.d.ts +27 -0
- package/dist/components/RepeatableField.svelte +221 -0
- package/dist/components/RepeatableField.svelte.d.ts +53 -0
- package/dist/components/cairn-admin.css +179 -2
- package/dist/components/preview-doc.js +5 -1
- package/dist/components/tidy-validate.js +1 -1
- package/dist/content/adapter.js +18 -0
- package/dist/content/advisories.d.ts +2 -2
- package/dist/content/advisories.js +3 -5
- package/dist/content/compose.d.ts +7 -6
- package/dist/content/compose.js +26 -20
- package/dist/content/concepts.d.ts +21 -15
- package/dist/content/concepts.js +55 -32
- package/dist/content/field-rules.d.ts +15 -0
- package/dist/content/field-rules.js +38 -0
- package/dist/content/fields.d.ts +169 -0
- package/dist/content/fields.js +41 -0
- package/dist/content/fieldset.d.ts +107 -0
- package/dist/content/fieldset.js +386 -0
- package/dist/content/frontmatter-region.d.ts +38 -0
- package/dist/content/frontmatter-region.js +75 -0
- package/dist/content/frontmatter.d.ts +35 -2
- package/dist/content/frontmatter.js +232 -11
- package/dist/content/manifest.d.ts +34 -0
- package/dist/content/manifest.js +80 -4
- package/dist/content/media-refs.d.ts +2 -2
- package/dist/content/media-rewrite.js +1 -69
- package/dist/content/reference-index.d.ts +56 -0
- package/dist/content/reference-index.js +95 -0
- package/dist/content/references.d.ts +40 -0
- package/dist/content/references.js +0 -0
- package/dist/content/standard-schema.d.ts +30 -0
- package/dist/content/standard-schema.js +4 -0
- package/dist/content/types.d.ts +127 -178
- package/dist/delivery/data.d.ts +2 -2
- package/dist/delivery/data.js +1 -1
- package/dist/delivery/public-routes.d.ts +10 -5
- package/dist/delivery/public-routes.js +25 -2
- package/dist/delivery/site-descriptors.d.ts +5 -1
- package/dist/delivery/site-descriptors.js +8 -3
- package/dist/delivery/site-indexes.d.ts +2 -2
- package/dist/delivery/site-resolver.d.ts +25 -0
- package/dist/delivery/site-resolver.js +49 -0
- package/dist/doctor/checks-local.js +6 -11
- package/dist/github/backend.d.ts +83 -0
- package/dist/github/backend.js +76 -0
- package/dist/github/credentials.d.ts +11 -5
- package/dist/github/credentials.js +3 -3
- package/dist/github/repo.d.ts +8 -19
- package/dist/github/repo.js +69 -80
- package/dist/github/types.d.ts +1 -1
- package/dist/github/types.js +4 -4
- package/dist/index.d.ts +18 -10
- package/dist/index.js +9 -5
- package/dist/islands/index.d.ts +12 -0
- package/dist/islands/index.js +83 -0
- package/dist/islands/types.d.ts +7 -0
- package/dist/islands/types.js +1 -0
- package/dist/log/events.d.ts +1 -1
- package/dist/media/index.d.ts +1 -1
- package/dist/media/index.js +1 -1
- package/dist/media/manifest.d.ts +11 -0
- package/dist/media/manifest.js +13 -0
- package/dist/media/rewrite-plan.d.ts +2 -3
- package/dist/media/rewrite-plan.js +2 -3
- package/dist/media/usage.d.ts +2 -2
- package/dist/media/usage.js +3 -5
- package/dist/nav/site-config.d.ts +0 -6
- package/dist/nav/site-config.js +6 -4
- package/dist/render/component-grammar.js +11 -11
- package/dist/render/component-reference.js +5 -3
- package/dist/render/component-validate.d.ts +4 -1
- package/dist/render/component-validate.js +10 -35
- package/dist/render/highlight.d.ts +9 -0
- package/dist/render/highlight.js +206 -0
- package/dist/render/pipeline.d.ts +0 -6
- package/dist/render/pipeline.js +13 -2
- package/dist/render/registry.d.ts +44 -36
- package/dist/render/registry.js +47 -6
- package/dist/render/rehype-dispatch.d.ts +6 -10
- package/dist/render/rehype-dispatch.js +38 -17
- package/dist/render/remark-directives.js +4 -5
- package/dist/render/sanitize-schema.d.ts +10 -0
- package/dist/render/sanitize-schema.js +30 -1
- package/dist/sveltekit/cairn-admin.d.ts +5 -5
- package/dist/sveltekit/cairn-admin.js +3 -4
- package/dist/sveltekit/content-routes.d.ts +10 -8
- package/dist/sveltekit/content-routes.js +269 -181
- package/dist/sveltekit/guard.js +10 -0
- package/dist/sveltekit/health.d.ts +7 -3
- package/dist/sveltekit/health.js +9 -3
- package/dist/sveltekit/index.d.ts +1 -1
- package/dist/sveltekit/nav-routes.d.ts +6 -5
- package/dist/sveltekit/nav-routes.js +22 -20
- package/dist/sveltekit/types.d.ts +2 -0
- package/dist/vite/index.d.ts +3 -3
- package/dist/vite/index.js +17 -8
- package/package.json +17 -2
- package/src/lib/ambient.ts +7 -0
- package/src/lib/auth/types.ts +7 -0
- package/src/lib/components/CairnAdmin.svelte +2 -6
- package/src/lib/components/ComponentForm.svelte +48 -27
- package/src/lib/components/ComponentInsertDialog.svelte +26 -14
- package/src/lib/components/ConceptList.svelte +41 -4
- package/src/lib/components/EditPage.svelte +43 -119
- package/src/lib/components/EntryPicker.svelte +154 -0
- package/src/lib/components/FieldInput.svelte +262 -0
- package/src/lib/components/IconPicker.svelte +4 -2
- package/src/lib/components/LinkPicker.svelte +10 -81
- package/src/lib/components/MediaHeroField.svelte +12 -5
- package/src/lib/components/ObjectGroupField.svelte +97 -0
- package/src/lib/components/ReferenceField.svelte +126 -0
- package/src/lib/components/RepeatableField.svelte +310 -0
- package/src/lib/components/preview-doc.ts +5 -1
- package/src/lib/components/tidy-validate.ts +1 -1
- package/src/lib/content/adapter.ts +21 -0
- package/src/lib/content/advisories.ts +4 -7
- package/src/lib/content/compose.ts +30 -23
- package/src/lib/content/concepts.ts +68 -40
- package/src/lib/content/field-rules.ts +39 -0
- package/src/lib/content/fields.ts +178 -0
- package/src/lib/content/fieldset.ts +470 -0
- package/src/lib/content/frontmatter-region.ts +90 -0
- package/src/lib/content/frontmatter.ts +231 -15
- package/src/lib/content/manifest.ts +101 -4
- package/src/lib/content/media-refs.ts +2 -2
- package/src/lib/content/media-rewrite.ts +7 -80
- package/src/lib/content/reference-index.ts +159 -0
- package/src/lib/content/references.ts +0 -0
- package/src/lib/content/standard-schema.ts +25 -0
- package/src/lib/content/types.ts +128 -195
- package/src/lib/delivery/data.ts +2 -2
- package/src/lib/delivery/public-routes.ts +36 -4
- package/src/lib/delivery/site-descriptors.ts +8 -3
- package/src/lib/delivery/site-indexes.ts +2 -2
- package/src/lib/delivery/site-resolver.ts +64 -0
- package/src/lib/doctor/checks-local.ts +6 -14
- package/src/lib/github/backend.ts +161 -0
- package/src/lib/github/credentials.ts +10 -7
- package/src/lib/github/repo.ts +79 -83
- package/src/lib/github/types.ts +5 -5
- package/src/lib/index.ts +40 -18
- package/src/lib/islands/index.ts +84 -0
- package/src/lib/islands/types.ts +11 -0
- package/src/lib/log/events.ts +1 -0
- package/src/lib/media/index.ts +1 -0
- package/src/lib/media/manifest.ts +14 -0
- package/src/lib/media/rewrite-plan.ts +4 -6
- package/src/lib/media/usage.ts +4 -7
- package/src/lib/nav/site-config.ts +8 -9
- package/src/lib/render/component-grammar.ts +10 -10
- package/src/lib/render/component-reference.ts +4 -3
- package/src/lib/render/component-validate.ts +10 -35
- package/src/lib/render/highlight.ts +259 -0
- package/src/lib/render/pipeline.ts +13 -8
- package/src/lib/render/registry.ts +88 -42
- package/src/lib/render/rehype-dispatch.ts +47 -16
- package/src/lib/render/remark-directives.ts +4 -5
- package/src/lib/render/sanitize-schema.ts +32 -1
- package/src/lib/sveltekit/cairn-admin.ts +8 -9
- package/src/lib/sveltekit/content-routes.ts +330 -221
- package/src/lib/sveltekit/guard.ts +15 -0
- package/src/lib/sveltekit/health.ts +13 -6
- package/src/lib/sveltekit/index.ts +2 -2
- package/src/lib/sveltekit/nav-routes.ts +33 -29
- package/src/lib/sveltekit/types.ts +5 -1
- package/src/lib/vite/index.ts +20 -11
- package/dist/content/schema.d.ts +0 -87
- package/dist/content/schema.js +0 -89
- package/dist/content/validate.d.ts +0 -17
- package/dist/content/validate.js +0 -93
- package/src/lib/content/schema.ts +0 -167
- 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 ??
|
|
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 {
|
|
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<
|
|
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`
|
|
42
|
-
*
|
|
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
|
|
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
|
|
115
|
-
*
|
|
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);
|