@cloudhal/astro-renderer 0.0.0-stage → 0.1.1

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 (164) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +36 -2
  3. package/dist/src/ambient-client.d.ts +17 -0
  4. package/dist/src/ambient-client.js +55 -0
  5. package/dist/src/analytics-client.d.ts +17 -0
  6. package/dist/src/analytics-client.js +96 -0
  7. package/dist/src/analytics-middleware.d.ts +6 -0
  8. package/dist/src/analytics-middleware.js +43 -0
  9. package/dist/src/analytics-node.d.ts +46 -0
  10. package/dist/src/analytics-node.js +134 -0
  11. package/dist/src/analytics.d.ts +117 -0
  12. package/dist/src/analytics.js +372 -0
  13. package/dist/src/archive.d.ts +106 -0
  14. package/dist/src/archive.js +207 -0
  15. package/dist/src/astro-env.d.ts +21 -0
  16. package/dist/src/block-html.d.ts +14 -0
  17. package/dist/src/block-html.js +103 -0
  18. package/dist/src/blocks.d.ts +24 -0
  19. package/dist/src/blocks.js +66 -0
  20. package/dist/src/cache-tags.d.ts +25 -0
  21. package/dist/src/cache-tags.js +59 -0
  22. package/dist/src/carousel-client.d.ts +28 -0
  23. package/dist/src/carousel-client.js +67 -0
  24. package/dist/src/chart.d.ts +34 -0
  25. package/dist/src/chart.js +182 -0
  26. package/dist/src/chrome-client.d.ts +27 -0
  27. package/dist/src/chrome-client.js +64 -0
  28. package/dist/src/cloudflare-entry.d.ts +87 -0
  29. package/dist/src/cloudflare-entry.js +548 -0
  30. package/dist/src/comments-client.d.ts +11 -0
  31. package/dist/src/comments-client.js +58 -0
  32. package/dist/src/comments-html.d.ts +42 -0
  33. package/dist/src/comments-html.js +303 -0
  34. package/dist/src/comments-middleware.d.ts +6 -0
  35. package/dist/src/comments-middleware.js +38 -0
  36. package/dist/src/comments-node.d.ts +42 -0
  37. package/dist/src/comments-node.js +112 -0
  38. package/dist/src/comments-view.d.ts +68 -0
  39. package/dist/src/comments-view.js +174 -0
  40. package/dist/src/comments.d.ts +66 -0
  41. package/dist/src/comments.js +258 -0
  42. package/dist/src/components/Block.astro +39 -0
  43. package/dist/src/components/Body.astro +43 -0
  44. package/dist/src/components/Comments.astro +19 -0
  45. package/dist/src/components/ContentList.astro +31 -0
  46. package/dist/src/components/EntryArticle.astro +31 -0
  47. package/dist/src/components/Hero.astro +36 -0
  48. package/dist/src/components/Image.astro +36 -0
  49. package/dist/src/components/RichText.astro +19 -0
  50. package/dist/src/components/Sections.astro +66 -0
  51. package/dist/src/components/SeoHead.astro +22 -0
  52. package/dist/src/components/Surface.astro +36 -0
  53. package/dist/src/components/SurfaceNode.astro +82 -0
  54. package/dist/src/components/index.d.ts +12 -0
  55. package/dist/src/components/index.js +12 -0
  56. package/dist/src/csp.d.ts +20 -0
  57. package/dist/src/csp.js +28 -0
  58. package/dist/src/embed-client.d.ts +38 -0
  59. package/dist/src/embed-client.js +98 -0
  60. package/dist/src/embed-middleware.d.ts +9 -0
  61. package/dist/src/embed-middleware.js +49 -0
  62. package/dist/src/feeds.d.ts +72 -0
  63. package/dist/src/feeds.js +246 -0
  64. package/dist/src/gates.d.ts +25 -0
  65. package/dist/src/gates.js +63 -0
  66. package/dist/src/index.d.ts +17 -0
  67. package/dist/src/index.js +17 -0
  68. package/dist/src/integration.d.ts +55 -0
  69. package/dist/src/integration.js +244 -0
  70. package/dist/src/kit.d.ts +48 -0
  71. package/dist/src/kit.js +83 -0
  72. package/dist/src/locale-feeds.d.ts +29 -0
  73. package/dist/src/locale-feeds.js +152 -0
  74. package/dist/src/locale-middleware.d.ts +5 -0
  75. package/dist/src/locale-middleware.js +26 -0
  76. package/dist/src/locales.d.ts +87 -0
  77. package/dist/src/locales.js +336 -0
  78. package/dist/src/markdown.d.ts +83 -0
  79. package/dist/src/markdown.js +533 -0
  80. package/dist/src/media-middleware.d.ts +5 -0
  81. package/dist/src/media-middleware.js +18 -0
  82. package/dist/src/media-route.d.ts +47 -0
  83. package/dist/src/media-route.js +238 -0
  84. package/dist/src/media.d.ts +109 -0
  85. package/dist/src/media.js +298 -0
  86. package/dist/src/motion-client.d.ts +39 -0
  87. package/dist/src/motion-client.js +115 -0
  88. package/dist/src/navigation.d.ts +127 -0
  89. package/dist/src/navigation.js +382 -0
  90. package/dist/src/not-found.d.ts +16 -0
  91. package/dist/src/not-found.js +41 -0
  92. package/dist/src/overlay-client.d.ts +20 -0
  93. package/dist/src/overlay-client.js +49 -0
  94. package/dist/src/prefs-client.d.ts +14 -0
  95. package/dist/src/prefs-client.js +18 -0
  96. package/dist/src/preview.d.ts +70 -0
  97. package/dist/src/preview.js +551 -0
  98. package/dist/src/resolver.d.ts +71 -0
  99. package/dist/src/resolver.js +206 -0
  100. package/dist/src/routing.d.ts +108 -0
  101. package/dist/src/routing.js +285 -0
  102. package/dist/src/runtime-workerd.d.ts +87 -0
  103. package/dist/src/runtime-workerd.js +275 -0
  104. package/dist/src/runtime.d.ts +59 -0
  105. package/dist/src/runtime.js +153 -0
  106. package/dist/src/safe-urls.d.ts +13 -0
  107. package/dist/src/safe-urls.js +35 -0
  108. package/dist/src/sanitize.d.ts +7 -0
  109. package/dist/src/sanitize.js +217 -0
  110. package/dist/src/search-client.d.ts +29 -0
  111. package/dist/src/search-client.js +92 -0
  112. package/dist/src/search-limit.d.ts +36 -0
  113. package/dist/src/search-limit.js +66 -0
  114. package/dist/src/search.d.ts +64 -0
  115. package/dist/src/search.js +155 -0
  116. package/dist/src/seo.d.ts +85 -0
  117. package/dist/src/seo.js +468 -0
  118. package/dist/src/site-dispatch.d.ts +37 -0
  119. package/dist/src/site-dispatch.js +86 -0
  120. package/dist/src/site-hosts.d.ts +35 -0
  121. package/dist/src/site-hosts.js +110 -0
  122. package/dist/src/source.d.ts +227 -0
  123. package/dist/src/source.js +794 -0
  124. package/dist/src/static-gates.d.ts +3 -0
  125. package/dist/src/static-gates.js +28 -0
  126. package/dist/src/static-headers.d.ts +30 -0
  127. package/dist/src/static-headers.js +140 -0
  128. package/dist/src/static-media.d.ts +4 -0
  129. package/dist/src/static-media.js +65 -0
  130. package/dist/src/static-redirects.d.ts +4 -0
  131. package/dist/src/static-redirects.js +40 -0
  132. package/dist/src/surface-client.d.ts +34 -0
  133. package/dist/src/surface-client.js +146 -0
  134. package/dist/src/surfaces/html.d.ts +35 -0
  135. package/dist/src/surfaces/html.js +184 -0
  136. package/dist/src/surfaces/markup.d.ts +57 -0
  137. package/dist/src/surfaces/markup.js +135 -0
  138. package/dist/src/surfaces/motion.d.ts +33 -0
  139. package/dist/src/surfaces/motion.js +132 -0
  140. package/dist/src/surfaces/primitives/carousel.d.ts +2 -0
  141. package/dist/src/surfaces/primitives/carousel.js +95 -0
  142. package/dist/src/surfaces/primitives/content.d.ts +13 -0
  143. package/dist/src/surfaces/primitives/content.js +159 -0
  144. package/dist/src/surfaces/primitives/data.d.ts +5 -0
  145. package/dist/src/surfaces/primitives/data.js +80 -0
  146. package/dist/src/surfaces/primitives/index.d.ts +54 -0
  147. package/dist/src/surfaces/primitives/index.js +106 -0
  148. package/dist/src/surfaces/primitives/inputs.d.ts +8 -0
  149. package/dist/src/surfaces/primitives/inputs.js +68 -0
  150. package/dist/src/surfaces/primitives/layout.d.ts +14 -0
  151. package/dist/src/surfaces/primitives/layout.js +61 -0
  152. package/dist/src/surfaces/primitives/motion.d.ts +9 -0
  153. package/dist/src/surfaces/primitives/motion.js +45 -0
  154. package/dist/src/surfaces/primitives/overlays.d.ts +6 -0
  155. package/dist/src/surfaces/primitives/overlays.js +79 -0
  156. package/dist/src/surfaces/tree.d.ts +107 -0
  157. package/dist/src/surfaces/tree.js +321 -0
  158. package/dist/src/surfaces.d.ts +14 -0
  159. package/dist/src/surfaces.js +33 -0
  160. package/dist/src/taxonomy.d.ts +86 -0
  161. package/dist/src/taxonomy.js +268 -0
  162. package/dist/src/theme-settings.d.ts +24 -0
  163. package/dist/src/theme-settings.js +111 -0
  164. package/package.json +219 -3
@@ -0,0 +1,268 @@
1
+ /**
2
+ * Taxonomy as the public site shows it (RFC-0002 §7): which terms an entry displays, their names in
3
+ * the entry's locale, archive links, breadcrumbs, related posts and archive membership. Pure
4
+ * functions over graph nodes, so heads, feeds, sitemaps and themes agree on one set of rules:
5
+ *
6
+ * - only `active` + `public` terms are shown or linked (proposed and internal terms never are);
7
+ * - names come from the term's label in the locale (`termName`, default-locale fallback);
8
+ * - entries written before the tags → terms migration still show their deprecated `tags`.
9
+ */
10
+
11
+ import { termName } from "@cloudhal/core-ts";
12
+
13
+
14
+ /** Everything needed to show terms: the site's taxonomies and every term, by id. */
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ /** Maximum hierarchy depth the walkers follow (the store enforces 5; this only stops bad data). */
28
+ const MAX_WALK = 16;
29
+
30
+ /**
31
+ * The taxonomy that gives an entry its section (breadcrumb, `articleSection`): `category`, else
32
+ * the first hierarchical one.
33
+ */
34
+ function pickSection(taxonomies ) {
35
+ return taxonomies.find((t) => t.key === "category") ?? taxonomies.find((t) => t.hierarchical);
36
+ }
37
+
38
+ export function taxonomyIndex(
39
+ taxonomies ,
40
+ terms ,
41
+ locale ,
42
+ defaultLocale ,
43
+ ) {
44
+ const section = pickSection(taxonomies);
45
+ const ordered = [...taxonomies].sort(
46
+ (a, b) => Number(b === section) - Number(a === section) || a.key.localeCompare(b.key),
47
+ );
48
+ return {
49
+ locale,
50
+ ...(defaultLocale ? { defaultLocale } : {}),
51
+ taxonomies: ordered,
52
+ byKey: new Map(ordered.map((t) => [t.key, t])),
53
+ byId: new Map(ordered.map((t) => [t.id, t])),
54
+ terms: new Map(terms.map((t) => [t.id, t])),
55
+ };
56
+ }
57
+
58
+ /** Loads the index from a source, in `locale` (default: the site's). */
59
+ export async function loadTaxonomyIndex(
60
+ source ,
61
+ locale ,
62
+ ) {
63
+ const [site, taxonomies, terms] = await Promise.all([
64
+ source.site(),
65
+ source.taxonomies(),
66
+ source.vocabulary(),
67
+ ]);
68
+ return taxonomyIndex(taxonomies, terms, locale ?? site.defaultLocale, site.defaultLocale);
69
+ }
70
+
71
+ export function sectionTaxonomy(index ) {
72
+ return pickSection(index.taxonomies);
73
+ }
74
+
75
+ /** Shown on the public site: active and public (RFC-0002 invariant 11). */
76
+ export function isPublicTerm(term ) {
77
+ return term.status === "active" && term.visibility === "public";
78
+ }
79
+
80
+ /** `/<basePath>/<slug>`. */
81
+ export function archivePath(taxonomy , slug ) {
82
+ return `${taxonomy.archive.basePath}/${slug}`;
83
+ }
84
+
85
+ /** Page `n` of an archive: the root for page 1, `<root>/page/<n>` after it. */
86
+ export function archivePagePath(root , page ) {
87
+ return page <= 1 ? root : `${root}/page/${page}`;
88
+ }
89
+
90
+ /** `<archive>/rss.xml`. */
91
+ export function archiveFeedPath(root ) {
92
+ return `${root}/rss.xml`;
93
+ }
94
+
95
+ /** A term as the site shows it. */
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+ export function shownTerm(index , term ) {
108
+ const taxonomy = index.byId.get(term.taxonomyId);
109
+ if (!taxonomy) return undefined;
110
+ return {
111
+ id: term.id,
112
+ slug: term.slug,
113
+ name: termName(term, index.locale),
114
+ ...(taxonomy.archive.enabled ? { href: archivePath(taxonomy, term.slug) } : {}),
115
+ taxonomy,
116
+ term,
117
+ };
118
+ }
119
+
120
+ /** Ancestors of a term, root first (any status; cycles and dangling parents end the walk). */
121
+ export function termAncestors(index , term ) {
122
+ const out = [];
123
+ const seen = new Set([term.id]);
124
+ let parentId = term.parentId;
125
+ while (parentId && out.length < MAX_WALK && !seen.has(parentId)) {
126
+ const parent = index.terms.get(parentId);
127
+ if (!parent) break;
128
+ seen.add(parent.id);
129
+ out.unshift(parent);
130
+ parentId = parent.parentId;
131
+ }
132
+ return out;
133
+ }
134
+
135
+ /** The public ancestors of a term as breadcrumb items, root first. */
136
+ export function publicTrail(index , term ) {
137
+ return termAncestors(index, term)
138
+ .filter(isPublicTerm)
139
+ .map((t) => shownTerm(index, t))
140
+ .filter((t) => t !== undefined);
141
+ }
142
+
143
+ /** The terms one entry shows. */
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+  
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+ const EMPTY = { groups: [], trail: [], tags: [], authors: [], keywords: [] };
163
+
164
+ export function entryTaxonomy(
165
+ index ,
166
+ entry ,
167
+ ) {
168
+ const legacy = [...entry.tags];
169
+ if (!index) return { ...EMPTY, keywords: legacy };
170
+ const groups = [];
171
+ let section ;
172
+ let tags = [];
173
+ let authors = [];
174
+ const sectionTax = sectionTaxonomy(index);
175
+ for (const taxonomy of index.taxonomies) {
176
+ const assignment = entry.terms?.[taxonomy.key];
177
+ if (!assignment) continue;
178
+ const shown = assignment.ids
179
+ .map((id) => index.terms.get(id))
180
+ .filter((t) => t !== undefined && t.taxonomyId === taxonomy.id && isPublicTerm(t))
181
+ .map((t) => shownTerm(index, t))
182
+ .filter((t) => t !== undefined);
183
+ if (taxonomy === sectionTax && assignment.primary)
184
+ section = shown.find((t) => t.id === assignment.primary);
185
+ if (taxonomy.key === "tag") tags = shown;
186
+ if (taxonomy.key === "author")
187
+ authors = [...shown].sort(
188
+ (a, b) => Number(b.id === assignment.primary) - Number(a.id === assignment.primary),
189
+ );
190
+ if (shown.length > 0) groups.push({ taxonomy, terms: shown });
191
+ }
192
+ const trail = section ? [...publicTrail(index, section.term), section] : [];
193
+ const keywords = entry.terms?.tag ? tags.map((t) => t.name) : legacy;
194
+ return { groups, ...(section ? { section } : {}), trail, tags, authors, keywords };
195
+ }
196
+
197
+ /** Term ids an entry belongs to for archives: its assignments plus, in hierarchical taxonomies, their ancestors. */
198
+ export function archiveTermIds(
199
+ index ,
200
+ entry ,
201
+ ) {
202
+ const ids = new Set ();
203
+ for (const [key, assignment] of Object.entries(entry.terms ?? {})) {
204
+ const taxonomy = index.byKey.get(key);
205
+ if (!taxonomy || !assignment) continue;
206
+ for (const id of assignment.ids) {
207
+ const term = index.terms.get(id);
208
+ if (!term || term.taxonomyId !== taxonomy.id) continue;
209
+ ids.add(id);
210
+ if (taxonomy.hierarchical) for (const a of termAncestors(index, term)) ids.add(a.id);
211
+ }
212
+ }
213
+ return ids;
214
+ }
215
+
216
+ /**
217
+ * Archive membership in one pass: term id → the entries its archive lists (category archives
218
+ * include their sub-categories' entries, RFC-0002 answer 9), in the order given (newest first).
219
+ */
220
+ export function archiveMembers(
221
+ index ,
222
+ entries ,
223
+ ) {
224
+ const out = new Map ();
225
+ for (const entry of entries)
226
+ for (const id of archiveTermIds(index, entry)) {
227
+ const list = out.get(id);
228
+ if (list) list.push(entry);
229
+ else out.set(id, [entry]);
230
+ }
231
+ return out;
232
+ }
233
+
234
+ /**
235
+ * Up to `limit` published entries related to `entry`: sharing its primary category scores 2,
236
+ * every other shared term (or legacy tag) 1. Highest score first, then newest; never the entry
237
+ * itself, never another locale, never zero-score entries.
238
+ */
239
+ export function relatedEntries(
240
+ entry ,
241
+ candidates ,
242
+ index ,
243
+ limit = 3,
244
+ ) {
245
+ const sectionKey = index ? sectionTaxonomy(index)?.key : undefined;
246
+ const primary = sectionKey ? entry.terms?.[sectionKey]?.primary : undefined;
247
+ const mine = new Set(Object.values(entry.terms ?? {}).flatMap((a) => a?.ids ?? []));
248
+ const legacy = new Set(entry.tags);
249
+ const scored = [];
250
+ for (const e of candidates) {
251
+ if (e.id === entry.id || e.status !== "published" || e.locale !== entry.locale) continue;
252
+ let score = 0;
253
+ const theirPrimary = sectionKey ? e.terms?.[sectionKey]?.primary : undefined;
254
+ if (primary && theirPrimary === primary) score += 2;
255
+ for (const id of new Set(Object.values(e.terms ?? {}).flatMap((a) => a?.ids ?? [])))
256
+ if (mine.has(id) && !(id === primary && theirPrimary === primary)) score += 1;
257
+ for (const t of new Set(e.tags)) if (legacy.has(t)) score += 1;
258
+ if (score > 0) scored.push({ e, score });
259
+ }
260
+ return scored
261
+ .sort(
262
+ (a, b) =>
263
+ b.score - a.score ||
264
+ (b.e.publishedAt ?? b.e.createdAt).localeCompare(a.e.publishedAt ?? a.e.createdAt),
265
+ )
266
+ .slice(0, limit)
267
+ .map(({ e }) => e);
268
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A theme's design settings on the page (RFC-0017 §1): `Site.theme.config` read against the
3
+ * theme's schema (`src/settings.ts`). Colors and numbers become CSS custom properties on `:root`
4
+ * (`--ch-brand: #2563eb`), enums and switches become `data-ch-*` attributes on `<html>` for the
5
+ * theme's CSS to select on (`[data-ch-font="serif"]`). Only typed values pass: a `#rrggbb` color,
6
+ * an enum member, a finite number inside its bounds, a boolean. A value that no longer fits (the
7
+ * theme changed) falls back to its default, so nothing in a value ever reaches CSS as free text.
8
+ */
9
+ import type { Site } from "@cloudhal/core-contracts";
10
+ import type { PropsSchema } from "@cloudhal/core-ts/blocks";
11
+ export interface ThemeVariables {
12
+ /** `:root{--ch-…}` for a `<style>` element (empty when nothing applies). */
13
+ style: string;
14
+ /** `data-ch-*` attributes for `<html>`. */
15
+ attributes: Record<string, string>;
16
+ }
17
+ /** The site's design settings as CSS variables and attributes (defaults where unset). */
18
+ export declare function themeVariables(site: Pick<Site, "theme">, schema: PropsSchema | undefined): ThemeVariables;
19
+ /**
20
+ * The color roles for a site: expanded from its seed (RFC-0023) when the theme declares `seed`
21
+ * and the site set one or chose a dark or automatic mode; otherwise its old colors with the blog
22
+ * theme's former greys, so a site that never opts in looks the same.
23
+ */
24
+ export declare function colorRoleCss(config: Readonly<Record<string, unknown>>, schema: PropsSchema): string;
@@ -0,0 +1,111 @@
1
+ /**
2
+ * A theme's design settings on the page (RFC-0017 §1): `Site.theme.config` read against the
3
+ * theme's schema (`src/settings.ts`). Colors and numbers become CSS custom properties on `:root`
4
+ * (`--ch-brand: #2563eb`), enums and switches become `data-ch-*` attributes on `<html>` for the
5
+ * theme's CSS to select on (`[data-ch-font="serif"]`). Only typed values pass: a `#rrggbb` color,
6
+ * an enum member, a finite number inside its bounds, a boolean. A value that no longer fits (the
7
+ * theme changed) falls back to its default, so nothing in a value ever reaches CSS as free text.
8
+ */
9
+
10
+
11
+ import {
12
+ colorRolesCss,
13
+ motionCss,
14
+ shapeCss,
15
+ siteColorTokens,
16
+ TYPE_SCALES,
17
+
18
+ typeScaleCss,
19
+ } from "@cloudhal/core-ts/tokens";
20
+
21
+ const COLOR = /^#[0-9a-fA-F]{6}$/;
22
+ const kebab = (key ) => key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
23
+ const SAFE_KEY = /^[A-Za-z][A-Za-z0-9]{0,40}$/;
24
+
25
+
26
+  
27
+
28
+
29
+
30
+
31
+
32
+ /** The site's design settings as CSS variables and attributes (defaults where unset). */
33
+ export function themeVariables(
34
+ site ,
35
+ schema ,
36
+ ) {
37
+ const vars = [];
38
+ const attributes = {};
39
+ if (!schema) return { style: "", attributes };
40
+ const config = site.theme.config ?? {};
41
+ for (const [key, s] of Object.entries(schema.properties)) {
42
+ if (!SAFE_KEY.test(key)) continue;
43
+ const name = kebab(key);
44
+ const pick = (ok ) => {
45
+ const v = config[key];
46
+ if (ok(v)) return v;
47
+ return ok(s.default) ? s.default : undefined;
48
+ };
49
+ if (s.type === "string" && s.format === "color") {
50
+ const v = pick((x) => typeof x === "string" && COLOR.test(x));
51
+ if (v !== undefined) vars.push(`--ch-${name}:${(v ).toLowerCase()}`);
52
+ } else if (s.type === "string" && s.enum) {
53
+ const allowed = s.enum;
54
+ const v = pick((x) => typeof x === "string" && allowed.includes(x));
55
+ if (typeof v === "string" && /^[a-z0-9-]{1,40}$/.test(v)) attributes[`data-ch-${name}`] = v;
56
+ } else if (s.type === "number" || s.type === "integer") {
57
+ const v = pick(
58
+ (x) =>
59
+ typeof x === "number" &&
60
+ Number.isFinite(x) &&
61
+ (s.minimum === undefined || x >= s.minimum) &&
62
+ (s.maximum === undefined || x <= s.maximum),
63
+ );
64
+ if (typeof v === "number") vars.push(`--ch-${name}:${v}`);
65
+ } else if (s.type === "boolean") {
66
+ const v = pick((x) => typeof x === "boolean");
67
+ if (typeof v === "boolean") attributes[`data-ch-${name}`] = v ? "on" : "off";
68
+ }
69
+ }
70
+ // RFC-0023 §1: the color roles every theme can use (`--ch-color-<role>`).
71
+ const roles = colorRoleCss(config, schema);
72
+ if (roles) vars.push(roles);
73
+ // RFC-0023 §2: the fluid type steps (`--ch-step-<n>`), once the site chose a scale; until then
74
+ // the theme's fixed sizes stay, so a site that never opts in looks the same.
75
+ const scale = config.typeScale;
76
+ if ("typeScale" in schema.properties && TYPE_SCALES.includes(scale ))
77
+ vars.push(typeScaleCss(scale ));
78
+ // RFC-0023 §3: corner radii and spacing, when the theme offers either (the defaults are the
79
+ // theme's former values, so a site that never chose them looks the same).
80
+ if ("radius" in schema.properties || "density" in schema.properties)
81
+ vars.push(
82
+ shapeCss({
83
+ radius: config.radius ?? schema.properties.radius?.default,
84
+ density: config.density ?? schema.properties.density?.default,
85
+ }),
86
+ );
87
+ // RFC-0024 §6: the motion tokens for every level; `data-ch-motion` (the `motion` setting, or a
88
+ // page's own level) picks one.
89
+ const rules = "motion" in schema.properties ? motionCss() : "";
90
+ // RFC-0024 §5: page transitions between pages of the site, once the site chose one.
91
+ const transition = config.pageTransition;
92
+ const transitions =
93
+ "pageTransition" in schema.properties &&
94
+ (transition === "crossfade" || transition === "slide" || transition === "morph")
95
+ ? `@view-transition{navigation:auto}`
96
+ : "";
97
+ const root = vars.length ? `:root{${vars.join(";")}}` : "";
98
+ return { style: root + rules + transitions, attributes };
99
+ }
100
+
101
+ /**
102
+ * The color roles for a site: expanded from its seed (RFC-0023) when the theme declares `seed`
103
+ * and the site set one or chose a dark or automatic mode; otherwise its old colors with the blog
104
+ * theme's former greys, so a site that never opts in looks the same.
105
+ */
106
+ export function colorRoleCss(
107
+ config ,
108
+ schema ,
109
+ ) {
110
+ return colorRolesCss(siteColorTokens(config, schema.properties));
111
+ }
package/package.json CHANGED
@@ -1,6 +1,222 @@
1
1
  {
2
2
  "name": "@cloudhal/astro-renderer",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Render a Cloudhal Site Graph with Astro: data sources (live/snapshot), section components and the cloudhal() integration",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://cloudhal.dev",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/cloudhal-dev/cloudhal.git",
10
+ "directory": "packages/astro-renderer"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/cloudhal-dev/cloudhal/issues"
14
+ },
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/src/index.d.ts",
19
+ "default": "./dist/src/index.js"
20
+ },
21
+ "./source": {
22
+ "types": "./dist/src/source.d.ts",
23
+ "default": "./dist/src/source.js"
24
+ },
25
+ "./routing": {
26
+ "types": "./dist/src/routing.d.ts",
27
+ "default": "./dist/src/routing.js"
28
+ },
29
+ "./search": {
30
+ "types": "./dist/src/search.d.ts",
31
+ "default": "./dist/src/search.js"
32
+ },
33
+ "./seo": {
34
+ "types": "./dist/src/seo.d.ts",
35
+ "default": "./dist/src/seo.js"
36
+ },
37
+ "./feeds": {
38
+ "types": "./dist/src/feeds.d.ts",
39
+ "default": "./dist/src/feeds.js"
40
+ },
41
+ "./taxonomy": {
42
+ "types": "./dist/src/taxonomy.d.ts",
43
+ "default": "./dist/src/taxonomy.js"
44
+ },
45
+ "./archive": {
46
+ "types": "./dist/src/archive.d.ts",
47
+ "default": "./dist/src/archive.js"
48
+ },
49
+ "./cache-tags": {
50
+ "types": "./dist/src/cache-tags.d.ts",
51
+ "default": "./dist/src/cache-tags.js"
52
+ },
53
+ "./gates": {
54
+ "types": "./dist/src/gates.d.ts",
55
+ "default": "./dist/src/gates.js"
56
+ },
57
+ "./navigation": {
58
+ "types": "./dist/src/navigation.d.ts",
59
+ "default": "./dist/src/navigation.js"
60
+ },
61
+ "./integration": {
62
+ "types": "./dist/src/integration.d.ts",
63
+ "default": "./dist/src/integration.js"
64
+ },
65
+ "./components": {
66
+ "types": "./dist/src/components/index.d.ts",
67
+ "default": "./dist/src/components/index.js"
68
+ },
69
+ "./components/*": "./dist/src/components/*",
70
+ "./runtime": {
71
+ "workerd": {
72
+ "types": "./dist/src/runtime-workerd.d.ts",
73
+ "default": "./dist/src/runtime-workerd.js"
74
+ },
75
+ "default": {
76
+ "types": "./dist/src/runtime.d.ts",
77
+ "default": "./dist/src/runtime.js"
78
+ }
79
+ },
80
+ "./preview": {
81
+ "types": "./dist/src/preview.d.ts",
82
+ "default": "./dist/src/preview.js"
83
+ },
84
+ "./resolver": {
85
+ "types": "./dist/src/resolver.d.ts",
86
+ "default": "./dist/src/resolver.js"
87
+ },
88
+ "./markdown": {
89
+ "types": "./dist/src/markdown.d.ts",
90
+ "default": "./dist/src/markdown.js"
91
+ },
92
+ "./cloudflare-entry": {
93
+ "types": "./dist/src/cloudflare-entry.d.ts",
94
+ "default": "./dist/src/cloudflare-entry.js"
95
+ },
96
+ "./media": {
97
+ "types": "./dist/src/media.d.ts",
98
+ "default": "./dist/src/media.js"
99
+ },
100
+ "./media-route": {
101
+ "types": "./dist/src/media-route.d.ts",
102
+ "default": "./dist/src/media-route.js"
103
+ },
104
+ "./media-middleware": {
105
+ "types": "./dist/src/media-middleware.d.ts",
106
+ "default": "./dist/src/media-middleware.js"
107
+ },
108
+ "./analytics": {
109
+ "types": "./dist/src/analytics.d.ts",
110
+ "default": "./dist/src/analytics.js"
111
+ },
112
+ "./analytics-middleware": {
113
+ "types": "./dist/src/analytics-middleware.d.ts",
114
+ "default": "./dist/src/analytics-middleware.js"
115
+ },
116
+ "./comments": {
117
+ "types": "./dist/src/comments-view.d.ts",
118
+ "default": "./dist/src/comments-view.js"
119
+ },
120
+ "./comments-middleware": {
121
+ "types": "./dist/src/comments-middleware.d.ts",
122
+ "default": "./dist/src/comments-middleware.js"
123
+ },
124
+ "./embed-middleware": {
125
+ "types": "./dist/src/embed-middleware.d.ts",
126
+ "default": "./dist/src/embed-middleware.js"
127
+ },
128
+ "./embeds": {
129
+ "types": "./dist/src/embed-client.d.ts",
130
+ "default": "./dist/src/embed-client.js"
131
+ },
132
+ "./theme-settings": {
133
+ "types": "./dist/src/theme-settings.d.ts",
134
+ "default": "./dist/src/theme-settings.js"
135
+ },
136
+ "./kit": {
137
+ "types": "./dist/src/kit.d.ts",
138
+ "default": "./dist/src/kit.js"
139
+ },
140
+ "./surfaces": {
141
+ "types": "./dist/src/surfaces.d.ts",
142
+ "default": "./dist/src/surfaces.js"
143
+ },
144
+ "./chrome": {
145
+ "types": "./dist/src/chrome-client.d.ts",
146
+ "default": "./dist/src/chrome-client.js"
147
+ },
148
+ "./prefs": {
149
+ "types": "./dist/src/prefs-client.d.ts",
150
+ "default": "./dist/src/prefs-client.js"
151
+ },
152
+ "./carousel": {
153
+ "types": "./dist/src/carousel-client.d.ts",
154
+ "default": "./dist/src/carousel-client.js"
155
+ },
156
+ "./search-client": {
157
+ "types": "./dist/src/search-client.d.ts",
158
+ "default": "./dist/src/search-client.js"
159
+ },
160
+ "./locales": {
161
+ "types": "./dist/src/locales.d.ts",
162
+ "default": "./dist/src/locales.js"
163
+ },
164
+ "./locale-middleware": {
165
+ "types": "./dist/src/locale-middleware.d.ts",
166
+ "default": "./dist/src/locale-middleware.js"
167
+ },
168
+ "./locale-feeds": {
169
+ "types": "./dist/src/locale-feeds.d.ts",
170
+ "default": "./dist/src/locale-feeds.js"
171
+ },
172
+ "./not-found": {
173
+ "types": "./dist/src/not-found.d.ts",
174
+ "default": "./dist/src/not-found.js"
175
+ }
176
+ },
177
+ "files": [
178
+ "dist",
179
+ "README.md"
180
+ ],
181
+ "dependencies": {
182
+ "@cloudhal/core-contracts": "0.1.1",
183
+ "@cloudhal/core-ts": "0.1.1",
184
+ "@cloudhal/storage": "0.1.1",
185
+ "marked": "^18.1.0",
186
+ "parse5": "8.0.1",
187
+ "@cloudhal/analytics": "0.1.1",
188
+ "vite": "^8.3.3",
189
+ "@cloudhal/comments": "0.1.1"
190
+ },
191
+ "peerDependencies": {
192
+ "astro": "^7.3.0",
193
+ "@astrojs/cloudflare": "^14.3.0"
194
+ },
195
+ "devDependencies": {
196
+ "@astrojs/cloudflare": "14.3.4",
197
+ "@cloudflare/workers-types": "^5.20261007.1",
198
+ "@types/node": "^26.6.5",
199
+ "astro": "^7.3.6",
200
+ "better-sqlite3": "13.0.3",
201
+ "happy-dom": "^21.0.1",
202
+ "typescript": "7.0.2",
203
+ "vitest": "5.0.3",
204
+ "wrangler": "4.148.0"
205
+ },
206
+ "peerDependenciesMeta": {
207
+ "@astrojs/cloudflare": {
208
+ "optional": true
209
+ }
210
+ },
211
+ "engines": {
212
+ "node": ">=24"
213
+ },
214
+ "publishConfig": {
215
+ "access": "public"
216
+ },
217
+ "scripts": {
218
+ "typecheck": "tsc --noEmit -p tsconfig.json",
219
+ "test": "vitest run",
220
+ "check": "pnpm typecheck && pnpm test"
221
+ }
6
222
  }