@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,551 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ import {
11
+
12
+
13
+ archiveState,
14
+ DEFAULT_ARCHIVE_PAGE_SIZE,
15
+ pageCount,
16
+ viewPagePath,
17
+ } from "./archive.js";
18
+ import { renderComponentSection } from "./blocks.js";
19
+ import { gateNotice } from "./gates.js";
20
+ import { renderBody, renderEntryArticle, renderMarkdown, safeHref, safeSrc } from "./markdown.js";
21
+ import { assetCaption, imageAttributes, imgHtml, } from "./media.js";
22
+ import { entryPath } from "./routing.js";
23
+ import { archiveHead, siteOrigin } from "./seo.js";
24
+ import { pickEntries, renderSurface, surfaceSources } from "./surfaces.js";
25
+ import {
26
+ archiveFeedPath,
27
+ archiveMembers,
28
+ archivePath,
29
+ publicTrail,
30
+ shownTerm,
31
+ taxonomyIndex,
32
+ } from "./taxonomy.js";
33
+
34
+ function esc(s ) {
35
+ return s.replace(
36
+ /[&<>"']/g,
37
+ (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c] ,
38
+ );
39
+ }
40
+
41
+ function localeOf(media ) {
42
+ const defaultLocale = media?.defaultLocale ?? media?.locale ?? "en";
43
+ return { locale: media?.locale ?? defaultLocale, defaultLocale };
44
+ }
45
+
46
+ /** A section image: the asset from the media library when it resolves (RFC-0004 §7.5), else `src`. */
47
+ function sectionImage(image , media ) {
48
+ const asset = image.assetId ? media?.assets?.get(image.assetId) : undefined;
49
+ if (asset) {
50
+ const { locale, defaultLocale } = localeOf(media);
51
+ return imgHtml(
52
+ imageAttributes(asset, image, {
53
+ locale,
54
+ defaultLocale,
55
+ transform: "none",
56
+ sizes: "(min-width: 48rem) 48rem, 100vw",
57
+ preview: true,
58
+ }),
59
+ );
60
+ }
61
+ const src = safeSrc(image.src);
62
+ return src ? `<img src="${esc(src)}" alt="${esc(image.alt)}">` : "";
63
+ }
64
+
65
+ /** The collections a page's sections list: content lists and surfaces' entry sources. */
66
+ export function previewCollections(sections ) {
67
+ return [
68
+ ...new Set(
69
+ sections.flatMap((s) =>
70
+ s.kind === "contentList"
71
+ ? [s.collection]
72
+ : s.kind === "surface"
73
+ ? surfaceSources(s).map((q) => q.collection)
74
+ : [],
75
+ ),
76
+ ),
77
+ ];
78
+ }
79
+
80
+ /**
81
+ * Framework-free HTML for a page's sections — the same structure the Astro components emit
82
+ * (`.ch-*` classes, `data-section-id`), so agents can preview a change without a build and the
83
+ * markup matches what the site will render.
84
+ */
85
+ export function renderSectionHtml(
86
+ section ,
87
+ entries = {},
88
+ media ,
89
+ ) {
90
+ switch (section.kind) {
91
+ case "hero":
92
+ return `<section class="ch-hero" data-section-id="${esc(section.id)}" data-kind="hero"><h1>${esc(section.heading)}</h1>${
93
+ section.subheading ? `<p class="ch-hero__sub">${esc(section.subheading)}</p>` : ""
94
+ }${section.image ? sectionImage(section.image, media) : ""}${
95
+ section.cta && safeHref(section.cta.href)
96
+ ? `<a class="ch-hero__cta" href="${esc(safeHref(section.cta.href) )}">${esc(section.cta.label)}</a>`
97
+ : ""
98
+ }</section>`;
99
+ case "richText":
100
+ return `<section class="ch-richtext" data-section-id="${esc(section.id)}" data-kind="richText">${renderBody({ format: section.format, value: section.body }, media)}</section>`;
101
+ case "image": {
102
+ // Like `Image.astro`: an asset's own caption and credit when the section has no caption.
103
+ const asset = section.image.assetId ? media?.assets?.get(section.image.assetId) : undefined;
104
+ const caption = asset
105
+ ? assetCaption(
106
+ asset,
107
+ localeOf(media).locale,
108
+ localeOf(media).defaultLocale,
109
+ section.caption,
110
+ )
111
+ : section.caption;
112
+ return `<figure class="ch-image" data-section-id="${esc(section.id)}" data-kind="image">${sectionImage(section.image, media)}${
113
+ caption ? `<figcaption>${esc(caption)}</figcaption>` : ""
114
+ }</figure>`;
115
+ }
116
+ case "contentList": {
117
+ const list = [...(entries[section.collection] ?? [])]
118
+ .sort((a, b) =>
119
+ section.sort === "title"
120
+ ? a.title.localeCompare(b.title)
121
+ : section.sort === "oldest"
122
+ ? (a.publishedAt ?? a.createdAt).localeCompare(b.publishedAt ?? b.createdAt)
123
+ : (b.publishedAt ?? b.createdAt).localeCompare(a.publishedAt ?? a.createdAt),
124
+ )
125
+ .slice(0, section.limit);
126
+ const items = list
127
+ .map(
128
+ (e) =>
129
+ `<li><a href="/${esc(e.collection)}/${esc(e.slug)}">${esc(e.title)}</a>${e.summary ? `<p>${esc(e.summary)}</p>` : ""}</li>`,
130
+ )
131
+ .join("");
132
+ return `<section class="ch-contentlist" data-section-id="${esc(section.id)}" data-kind="contentList" data-collection="${esc(section.collection)}">${
133
+ list.length === 0
134
+ ? '<p class="ch-contentlist__empty">Nothing published yet.</p>'
135
+ : `<ul>${items}</ul>`
136
+ }</section>`;
137
+ }
138
+ // RFC-0015: previews show unknown or misfitting blocks as a labelled placeholder.
139
+ case "component":
140
+ return renderComponentSection(section, { ...(media ? { media } : {}), preview: true });
141
+ // RFC-0020: a surface's entry sources come from the collections the caller loaded (the
142
+ // filter is applied on the site; a preview shows the collection's newest).
143
+ case "surface": {
144
+ const sources = Object.fromEntries(
145
+ surfaceSources(section).map((q) => [q.key, pickEntries(entries[q.collection] ?? [], q)]),
146
+ );
147
+ return renderSurface(section, { ...(media ? { media } : {}), sources, preview: true });
148
+ }
149
+ }
150
+ }
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+ /** Words of the preview's gate notice (RFC-0008 §7.3), as the blog starter says them. */
159
+ const GATE_WORDS
160
+
161
+
162
+ = {
163
+ en: {
164
+ embargoed: (when) => `Embargoed until ${when}. Only previews show it until then.`,
165
+ expired: (when) => `Expired on ${when}. Only previews show it now.`,
166
+ },
167
+ tr: {
168
+ embargoed: (when) =>
169
+ `${when} tarihine kadar ambargolu. O zamana kadar yalnızca önizlemede görünür.`,
170
+ expired: (when) => `${when} tarihinde yayından kalktı. Artık yalnızca önizlemede görünür.`,
171
+ },
172
+ };
173
+
174
+ /**
175
+ * The notice a preview shows above a page or entry the public cannot see at `now` (embargoed or
176
+ * expired, RFC-0008 §7.3); empty when its gates are open.
177
+ */
178
+ export function gateNoticeHtml(
179
+ site ,
180
+ node ,
181
+ now ,
182
+ locale = site.defaultLocale,
183
+ ) {
184
+ const notice = gateNotice(node, site, locale, now);
185
+ if (!notice) return "";
186
+ const words =
187
+ GATE_WORDS[locale.split("-")[0] ?? locale] ??
188
+ (GATE_WORDS.en );
189
+ return `<p class="ch-gate-notice" role="status" data-gate="${notice.state}" data-gate-at="${esc(notice.at)}">${esc(words[notice.state](notice.when))}</p>`;
190
+ }
191
+
192
+ /**
193
+ * Full HTML document for a page preview. `now` (default: the caller's clock) decides whether the
194
+ * page's gates are closed, which adds a notice.
195
+ */
196
+ export function renderPagePreview(
197
+ site ,
198
+ page ,
199
+ entries = {},
200
+ media ,
201
+ now = Date.now(),
202
+ ) {
203
+ const ctx = previewMedia(site, media);
204
+ const body =
205
+ gateNoticeHtml(site, page, now) +
206
+ page.sections.map((s) => renderSectionHtml(s, entries, ctx)).join("\n");
207
+ const title = page.seo?.title ?? page.title;
208
+ return { title, path: page.path, html: document(site, title, page.seo?.description, body) };
209
+ }
210
+
211
+ /** Previews resolve `asset:` references and asset-backed images, never through transformations. */
212
+ function previewMedia(site , media ) {
213
+ return { locale: site.defaultLocale, defaultLocale: site.defaultLocale, ...media, preview: true };
214
+ }
215
+
216
+ /**
217
+ * Full HTML document for an article preview (`media.assets`: the assets it refers to), with the
218
+ * gate notice when the entry is embargoed or expired at `now`.
219
+ */
220
+ export function renderEntryPreview(
221
+ site ,
222
+ entry ,
223
+ media ,
224
+ now = Date.now(),
225
+ ) {
226
+ const body =
227
+ gateNoticeHtml(site, entry, now) +
228
+ renderEntryArticle(entry, site.defaultLocale, previewMedia(site, media));
229
+ return {
230
+ title: entry.title,
231
+ path: `/${entry.collection}/${entry.slug}`,
232
+ html: document(site, entry.title, entry.summary, body),
233
+ };
234
+ }
235
+
236
+ /**
237
+ * One piece of a body (a ```surface, a block) as a document of its own, for the body editor's
238
+ * inline preview: the preview's policy and styles, no site header or footer, nothing else.
239
+ */
240
+ export function renderFragmentPreview(
241
+ site ,
242
+ markdown ,
243
+ media ,
244
+ ) {
245
+ const body = `<div class="ch-richtext">${renderMarkdown(markdown, previewMedia(site, media))}</div>`;
246
+ return {
247
+ html: `<!doctype html><html lang="${esc(site.defaultLocale)}"><head><meta charset="utf-8"><meta http-equiv="content-security-policy" content="${PREVIEW_CSP}"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="generator" content="Cloudhal preview"><style>${PREVIEW_CSS}body{background:transparent}main{max-width:none;padding:16px 24px}</style></head><body><main>${body}</main></body></html>`,
248
+ };
249
+ }
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+ /**
263
+ * Why an archive answers the way it does (RFC-0002 §7, `archiveState`): `indexed`; `thin` (fewer
264
+ * published entries than `minEntriesToIndex`) and `noindex` (the term's SEO asks for it) are a 200
265
+ * with `noindex,follow`; `empty`, `proposed`, `internal` and `archiveOff` are a 404; `retired` a 410.
266
+ */
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+ /** Visitor-facing words of the archive page, as the blog starter says them. */
287
+ const ARCHIVE_WORDS
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+ = {
300
+ en: {
301
+ home: "Home",
302
+ breadcrumb: "Breadcrumb",
303
+ feed: "RSS feed",
304
+ posts: (n) => (n === 1 ? "1 post" : `${n} posts`),
305
+ empty: "Nothing published here yet.",
306
+ newer: "← Newer",
307
+ older: "Older →",
308
+ pageOf: (page, pages) => `Page ${page} of ${pages}`,
309
+ },
310
+ tr: {
311
+ home: "Ana sayfa",
312
+ breadcrumb: "Sayfa yolu",
313
+ feed: "RSS beslemesi",
314
+ posts: (n) => `${n} yazı`,
315
+ empty: "Burada henüz yayınlanmış bir şey yok.",
316
+ newer: "← Daha yeni",
317
+ older: "Daha eski →",
318
+ pageOf: (page, pages) => `Sayfa ${page} / ${pages}`,
319
+ },
320
+ };
321
+
322
+ function byNewest(a , b ) {
323
+ return (b.publishedAt ?? b.createdAt).localeCompare(a.publishedAt ?? a.createdAt);
324
+ }
325
+
326
+ /**
327
+ * A term's archive page (`<basePath>/<slug>`, page 1) as the blog starter renders it — breadcrumb,
328
+ * the taxonomy's name, the term's name, post count and feed link, image and markdown intro, the
329
+ * newest entries and pagination — with the `<head>` title and description of `archiveHead`. It
330
+ * renders whatever the archive's state, so a person sees a proposed or empty term's page before it
331
+ * goes public; `state` and `reason` say what the public route answers today (`archiveState`).
332
+ */
333
+ export function renderArchivePreview(
334
+ site ,
335
+ input ,
336
+ ) {
337
+ const locale = site.defaultLocale;
338
+ const term = input.terms.find((t) => t.id === input.termId);
339
+ const taxonomy = term ? input.taxonomies.find((t) => t.id === term.taxonomyId) : undefined;
340
+ if (!term || !taxonomy) throw new Error(`term ${input.termId} or its taxonomy not found`);
341
+ const index = taxonomyIndex(input.taxonomies, input.terms, locale);
342
+ const published = input.entries
343
+ .filter((e) => e.status === "published" && e.locale === locale)
344
+ .sort(byNewest);
345
+ // Membership is counted as the public route counts it: only for a public term.
346
+ const members = archiveMembers(index, published).get(term.id) ?? [];
347
+ const listed = term.status === "active" && term.visibility === "public" ? members : [];
348
+ const state = archiveState(taxonomy, term, listed.length, locale);
349
+ const reason = !taxonomy.archive.enabled
350
+ ? "archiveOff"
351
+ : term.status === "retired"
352
+ ? "retired"
353
+ : term.status === "proposed"
354
+ ? "proposed"
355
+ : term.visibility === "internal"
356
+ ? "internal"
357
+ : listed.length === 0
358
+ ? "empty"
359
+ : state.status === 200 && state.indexable
360
+ ? "indexed"
361
+ : term.labels[locale]?.seo?.noindex
362
+ ? "noindex"
363
+ : "thin";
364
+
365
+ const perPage = input.perPage ?? DEFAULT_ARCHIVE_PAGE_SIZE;
366
+ const root = archivePath(taxonomy, term.slug);
367
+ const shown = shownTerm(index, term) ?? {
368
+ id: term.id,
369
+ slug: term.slug,
370
+ name: term.slug,
371
+ taxonomy,
372
+ term,
373
+ };
374
+ const view = {
375
+ taxonomy,
376
+ term,
377
+ shown,
378
+ trail: publicTrail(index, term),
379
+ locale,
380
+ root,
381
+ path: root,
382
+ ...(taxonomy.feed ? { feedPath: archiveFeedPath(root) } : {}),
383
+ page: 1,
384
+ pages: pageCount(members.length, perPage),
385
+ perPage,
386
+ // A term that is not public yet lists what it will list once it is.
387
+ total: members.length,
388
+ entries: members.slice(0, perPage),
389
+ indexable: state.status === 200 && state.indexable,
390
+ };
391
+ const head = archiveHead(site, view, siteOrigin(site, "https://preview.invalid"));
392
+ const words =
393
+ ARCHIVE_WORDS[locale.split("-")[0] ?? locale] ??
394
+ (ARCHIVE_WORDS.en );
395
+ const label = term.labels[locale];
396
+ const kind =
397
+ taxonomy.labels[locale]?.singular ?? Object.values(taxonomy.labels)[0]?.singular ?? "";
398
+ const imageSrc = term.image ? safeSrc(term.image.src) : undefined;
399
+ const crumbs = [
400
+ { name: words.home, href: "/" },
401
+ ...view.trail.map((t) => ({ name: t.name, href: t.href })),
402
+ { name: shown.name, href: undefined },
403
+ ];
404
+ const breadcrumb = `<nav aria-label="${esc(words.breadcrumb)}" class="ch-breadcrumbs"><ol>${crumbs
405
+ .map((c, i) =>
406
+ i === crumbs.length - 1
407
+ ? `<li><span aria-current="page">${esc(c.name)}</span></li>`
408
+ : c.href
409
+ ? `<li><a href="${esc(c.href)}">${esc(c.name)}</a></li>`
410
+ : `<li><span>${esc(c.name)}</span></li>`,
411
+ )
412
+ .join("")}</ol></nav>`;
413
+ const date = (iso ) =>
414
+ new Date(iso).toLocaleDateString(locale, { year: "numeric", month: "long", day: "numeric" });
415
+ const list =
416
+ view.entries.length === 0
417
+ ? `<p class="ch-contentlist__empty muted">${esc(words.empty)}</p>`
418
+ : `<ul class="ch-entrylist">${view.entries
419
+ .map(
420
+ (e) =>
421
+ `<li><a href="${esc(entryPath(e))}">${esc(e.title)}</a>${e.summary ? `<p>${esc(e.summary)}</p>` : ""}${
422
+ e.publishedAt
423
+ ? `<time datetime="${esc(e.publishedAt)}">${esc(date(e.publishedAt))}</time>`
424
+ : ""
425
+ }</li>`,
426
+ )
427
+ .join("")}</ul>`;
428
+ const pagination =
429
+ view.pages > 1
430
+ ? `<nav class="ch-pagination"><span></span><span>${esc(words.pageOf(1, view.pages))}</span><a href="${esc(viewPagePath(view, 2))}" rel="next">${esc(words.older)}</a></nav>`
431
+ : "";
432
+ const body = `<section class="ch-archive" data-term-id="${esc(term.id)}" data-taxonomy="${esc(taxonomy.key)}">${
433
+ crumbs.length > 1 ? breadcrumb : ""
434
+ }<header class="ch-archive-header">${kind ? `<p class="ch-archive-kind muted">${esc(kind)}</p>` : ""}<h1>${esc(shown.name)}</h1><p class="ch-archive-meta muted"><span>${esc(words.posts(view.total))}</span>${
435
+ view.feedPath ? ` · <a href="${esc(view.feedPath)}">${esc(words.feed)}</a>` : ""
436
+ }</p>${
437
+ term.image && imageSrc
438
+ ? `<img class="ch-archive-image" src="${esc(imageSrc)}" alt="${esc(term.image.alt)}"${term.image.width ? ` width="${term.image.width}"` : ""}${term.image.height ? ` height="${term.image.height}"` : ""}>`
439
+ : ""
440
+ }${label?.description ? `<div class="ch-richtext">${renderMarkdown(label.description)}</div>` : ""}</header>${list}${pagination}</section>`;
441
+ return {
442
+ title: head.title,
443
+ path: root,
444
+ html: document(
445
+ site,
446
+ head.title,
447
+ head.description,
448
+ body,
449
+ view.indexable ? undefined : "noindex,follow",
450
+ ),
451
+ state,
452
+ reason,
453
+ total: listed.length,
454
+ minEntriesToIndex: taxonomy.minEntriesToIndex,
455
+ };
456
+ }
457
+
458
+ /**
459
+ * Neutral reading styles so previews are legible without the site's theme (the theme only exists
460
+ * in the Astro build). Inline because preview responses are CSP-sandboxed (`style-src 'unsafe-inline'`).
461
+ */
462
+ const PREVIEW_CSS =
463
+ ":root{color-scheme:light dark;--fg:#1f2328;--muted:#59636e;--line:#d1d9e0;--bg:#fff}" +
464
+ "@media (prefers-color-scheme:dark){:root{--fg:#e6edf3;--muted:#9198a1;--line:#3d444d;--bg:#0d1117}}" +
465
+ "*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg);font:16px/1.65 system-ui,-apple-system,'Segoe UI',sans-serif}" +
466
+ "header{padding:14px 24px;border-bottom:1px solid var(--line)}header a{color:var(--fg);font-weight:600;text-decoration:none}" +
467
+ ".ch-skip{position:absolute;left:8px;top:-48px;padding:8px 12px;background:var(--bg);color:var(--fg)}.ch-skip:focus{top:8px}" +
468
+ "footer{padding:14px 24px;border-top:1px solid var(--line);color:var(--muted);font-size:14px}" +
469
+ "main{max-width:720px;margin:0 auto;padding:32px 24px 64px}h1,h2,h3{line-height:1.25;margin:1.6em 0 .5em}h1{font-size:2rem;margin-top:.4em}" +
470
+ "p,ul,ol{margin:0 0 1em}a{color:#0969da}img{max-width:100%;height:auto;border-radius:6px}" +
471
+ "pre,code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em}pre{overflow:auto;padding:12px;border:1px solid var(--line);border-radius:6px}" +
472
+ "blockquote{margin:0 0 1em;padding-left:1em;border-left:3px solid var(--line);color:var(--muted)}" +
473
+ "section+section{margin-top:2.5rem}small,time,.muted{color:var(--muted)}" +
474
+ ".ch-article-header{margin-bottom:2rem}.ch-article-header h1{margin-bottom:.3em}.ch-summary{font-size:1.15rem;color:var(--muted)}" +
475
+ ".ch-breadcrumbs ol{display:flex;flex-wrap:wrap;gap:.4em;list-style:none;margin:0 0 1.5rem;padding:0;font-size:.9rem;color:var(--muted)}" +
476
+ ".ch-breadcrumbs li+li::before{content:'›';margin-right:.4em}.ch-archive-kind{margin:0;font-size:.9rem}" +
477
+ ".ch-archive-header h1{margin:.1em 0 .3em}.ch-archive-meta{margin-bottom:1.5rem}.ch-archive-image{margin-bottom:1.5rem}" +
478
+ ".ch-entrylist{list-style:none;padding:0}.ch-entrylist li{padding:1rem 0;border-top:1px solid var(--line)}" +
479
+ ".ch-entrylist li a{font-weight:600}.ch-entrylist p{margin:.3em 0}.ch-pagination{display:flex;justify-content:space-between;padding-top:1rem}" +
480
+ ".ch-gate-notice{margin:0 0 1.5rem;padding:.6rem .9rem;border:1px solid var(--line);border-left:4px solid #bf8700;border-radius:6px}" +
481
+ // Generated UI (RFC-0020): readable layout for the primitives, not the theme's look.
482
+ ".ch-surface{display:block}.ch-stack{display:flex;flex-direction:column;gap:1rem}.ch-row{display:flex;flex-wrap:wrap;align-items:center;gap:1rem}" +
483
+ ".ch-grid,.ch-columns{display:grid;gap:1rem;grid-template-columns:repeat(auto-fit,minmax(160px,1fr))}" +
484
+ "[data-gap=none]{gap:0}[data-gap=s]{gap:.5rem}[data-gap=l]{gap:2rem}[data-gap=xl]{gap:3rem}" +
485
+ ".ch-stack[data-align=center],.ch-row[data-align=center],[data-align=center]{text-align:center;align-items:center}.ch-row[data-justify=center]{justify-content:center}.ch-row[data-justify=between]{justify-content:space-between}" +
486
+ ".ch-band{margin:0 -24px;padding:2.5rem 24px;border-radius:8px}.ch-card{display:flex;flex-direction:column;gap:.5rem;padding:1rem 1.2rem;border:1px solid var(--line);border-radius:8px;color:inherit;text-decoration:none}" +
487
+ // RFC-0023 §4 surfaces, in the preview's two colors: soft ones a tint, loud ones inverted.
488
+ ":is([data-surface=muted],[data-surface=mesh],[data-surface=dots],[data-surface=grid],[data-surface=noise],[data-tone=muted]){background:color-mix(in srgb,var(--fg) 5%,transparent)}" +
489
+ "[data-surface=raised]{box-shadow:0 4px 16px -6px color-mix(in srgb,var(--fg) 25%,transparent)}" +
490
+ ":is([data-surface=brand],[data-surface=inverse],[data-surface=accent],[data-surface=gradient],[data-tone=brand],[data-tone=inverse]){background:var(--fg);color:var(--bg)}" +
491
+ // RFC-0024 §3: scroll stories read as a column in previews; progress bars are left out.
492
+ ".ch-scrolly{display:grid;gap:1rem}.ch-step{padding:.8rem 1rem;border-left:3px solid var(--line)}.ch-progress{display:none}" +
493
+ ".ch-heading{margin:0}.ch-text p:last-child,.ch-markdown p:last-child{margin-bottom:0}.ch-text[data-size=l]{font-size:1.2rem}.ch-text[data-size=s]{font-size:.9rem}.ch-text[data-muted=yes]{color:var(--muted)}" +
494
+ ".ch-button{display:inline-block;width:fit-content;padding:.5rem 1rem;border-radius:6px;border:1px solid var(--line);color:inherit;text-decoration:none;font-weight:500}.ch-button--primary{background:var(--fg);color:var(--bg);border-color:var(--fg)}" +
495
+ ":is([data-surface=brand],[data-surface=inverse],[data-surface=accent],[data-surface=gradient],[data-tone=brand],[data-tone=inverse]) .ch-button--primary{background:var(--bg);color:var(--fg)}" +
496
+ ".ch-badge{display:inline-block;width:fit-content;padding:.1rem .6rem;border-radius:999px;border:1px solid var(--line);font-size:.8rem}" +
497
+ ".ch-stat{display:flex;flex-direction:column}.ch-stat__value{font-size:2rem;font-weight:700;line-height:1.2}.ch-stat__detail{color:var(--muted);font-size:.9rem}" +
498
+ ".ch-quote figcaption{color:var(--muted);font-size:.9rem}.ch-divider{border:0;border-top:1px solid var(--line);width:100%}.ch-spacer{height:2rem}" +
499
+ ".ch-tabs{display:flex;flex-wrap:wrap;gap:.25rem}.ch-tabs__radio{position:absolute;opacity:0}.ch-tabs__tab{padding:.4rem .9rem;border-bottom:2px solid transparent;cursor:pointer;color:var(--muted)}" +
500
+ ".ch-tabs__radio:checked+.ch-tabs__tab{border-color:currentColor;color:var(--fg)}.ch-tabs__panels{width:100%;border-top:1px solid var(--line);padding-top:1rem}.ch-tabs__panel{display:none}" +
501
+ ".ch-tabs__radio:nth-of-type(1):checked~.ch-tabs__panels>.ch-tabs__panel:nth-child(1),.ch-tabs__radio:nth-of-type(2):checked~.ch-tabs__panels>.ch-tabs__panel:nth-child(2)," +
502
+ ".ch-tabs__radio:nth-of-type(3):checked~.ch-tabs__panels>.ch-tabs__panel:nth-child(3),.ch-tabs__radio:nth-of-type(4):checked~.ch-tabs__panels>.ch-tabs__panel:nth-child(4){display:block}" +
503
+ ".ch-accordion{border-top:1px solid var(--line)}.ch-disclosure{border-bottom:1px solid var(--line);padding:.6rem 0}.ch-disclosure summary{cursor:pointer;font-weight:500}" +
504
+ ".ch-node{display:contents}.ch-node[hidden]{display:none}button.ch-button{cursor:pointer;font:inherit}" +
505
+ ".ch-toggle{display:inline-flex;gap:.25rem;padding:.25rem;border:1px solid var(--line);border-radius:8px}.ch-toggle__option input{position:absolute;opacity:0}" +
506
+ ".ch-toggle__option span{display:block;padding:.3rem .8rem;border-radius:6px;cursor:pointer;color:var(--muted)}.ch-toggle__option input:checked+span{background:var(--fg);color:var(--bg)}" +
507
+ ".ch-field{display:grid;align-content:start;gap:.35rem}.ch-field__label{font-weight:500;font-size:.9rem}.ch-select{max-width:20rem;padding:.4rem;border:1px solid var(--line);border-radius:6px;font:inherit}" +
508
+ ".ch-slider{display:flex;align-items:center;gap:.75rem}.ch-slider input{flex:1;max-width:24rem}.ch-slider__value{font-weight:600;min-width:3rem}" +
509
+ // RFC-0022 §4: tables (cards below 480 px).
510
+ ".ch-table{width:100%;border-collapse:collapse;font-size:.9rem}.ch-table caption{text-align:left;font-weight:600;padding-bottom:.5rem}.ch-table th,.ch-table td{border-bottom:1px solid var(--line);padding:.4rem .6rem;text-align:left}.ch-table [data-align=end]{text-align:right}.ch-table[data-striped=yes] tbody tr:nth-child(even){background:color-mix(in srgb,var(--fg) 4%,transparent)}.ch-table tr[data-highlight=yes]{background:color-mix(in srgb,var(--fg) 8%,transparent)}" +
511
+ "@media (max-width:480px){.ch-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}.ch-table caption{display:block;width:100%}.ch-table,.ch-table tbody,.ch-table tr,.ch-table td{display:block;width:100%}.ch-table tr{margin-bottom:.75rem;border:1px solid var(--line);border-radius:8px;padding:.25rem .75rem}.ch-table td{display:flex;justify-content:space-between;gap:1rem;text-align:right}.ch-table td::before{content:attr(data-label);font-weight:500;color:var(--muted);text-align:left}}" +
512
+ // RFC-0022 §3: charts.
513
+ ":root{--ch-chart-1:#18181b;--ch-chart-2:#2563eb;--ch-chart-3:#d97706;--ch-chart-4:#059669;--ch-chart-5:#db2777;--ch-chart-6:#7c3aed}.ch-chart{margin:0;display:grid;gap:.75rem}.ch-chart__title{font-weight:600}.ch-chart__svg{display:block;width:100%;height:auto}.ch-chart__grid{stroke:var(--line)}.ch-chart__tick{fill:var(--muted);font-size:12px}.ch-chart__total{fill:currentColor;font-size:22px;font-weight:600}" +
514
+ ".ch-chart__legend{display:flex;flex-wrap:wrap;gap:.25rem 1rem;margin:0;padding:0;list-style:none;font-size:.9rem}.ch-chart__legend li{display:flex;align-items:center;gap:.4rem}.ch-chart__swatch{display:inline-block;width:.75rem;height:.75rem;border-radius:2px}.ch-chart__caption,.ch-chart__empty,.ch-chart__data summary{color:var(--muted);font-size:.9rem}.ch-chart__data table{width:100%;border-collapse:collapse;font-size:.9rem}.ch-chart__data th,.ch-chart__data td{border-bottom:1px solid var(--line);padding:.25rem .5rem;text-align:left}" +
515
+ // RFC-0022 §2: local inputs.
516
+ ".ch-input-wrap{display:flex;align-items:center;gap:.5rem;max-width:20rem}.ch-input{width:100%;max-width:20rem;padding:.4rem .6rem;border:1px solid var(--line);border-radius:6px;font:inherit}.ch-input[aria-invalid=true]{border-color:#b91c1c}.ch-input__unit,.ch-field__help,.ch-noscript{color:var(--muted);font-size:.9rem}" +
517
+ ".ch-check,.ch-radio__option{display:flex;align-items:center;gap:.5rem;width:fit-content;cursor:pointer}.ch-radio{display:grid;gap:.35rem;border:0;margin:0;padding:0;min-width:0}.ch-radio__options{display:flex;flex-direction:column;gap:.35rem}" +
518
+ ".ch-radio[data-variant=buttons] .ch-radio__options{display:inline-flex;flex-direction:row;flex-wrap:wrap;gap:.25rem;padding:.25rem;border:1px solid var(--line);border-radius:8px;width:fit-content}.ch-radio[data-variant=buttons] input{position:absolute;opacity:0}.ch-radio[data-variant=buttons] .ch-radio__option span{display:block;padding:.3rem .8rem;border-radius:6px;color:var(--muted)}.ch-radio[data-variant=buttons] input:checked+span{background:var(--fg);color:var(--bg)}" +
519
+ // Markdown tables in bodies (no class): ruled rows, the alignment asked for, their own scroll.
520
+ "main table:not([class]){display:block;width:max-content;max-width:100%;overflow-x:auto;border-collapse:collapse;font-size:.95em}main table:not([class]) :is(th,td){padding:.45em .8em;border-bottom:1px solid var(--line);text-align:left;vertical-align:top}main table:not([class]) th{font-weight:600}main table:not([class]) [align=center]{text-align:center}main table:not([class]) [align=right]{text-align:right}" +
521
+ ".ch-fnref a{text-decoration:none;font-size:.75em;padding:0 .1em}.ch-footnotes{margin-top:2.5rem;padding-top:1rem;border-top:1px solid var(--line);color:var(--muted);font-size:.9rem}.ch-fnback{text-decoration:none}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}" +
522
+ ".ch-surface-problem{border:1px solid #d97706;border-radius:8px;padding:.6rem .9rem;font-size:.9rem}.ch-surface-problem ul{margin:.4rem 0 0}" +
523
+ ".ch-block--missing{padding:.6rem .9rem;border:1px dashed var(--line);border-radius:6px;color:var(--muted);font-size:.9rem}" +
524
+ // RFC-0027: carousels without the module (previews run no scripts): a scroll-snap track, the
525
+ // markers as links, the buttons the module would reveal kept hidden.
526
+ ".ch-carousel{position:relative;margin:1.5rem 0}.ch-carousel__track{display:grid;grid-auto-flow:column;grid-auto-columns:80%;gap:1rem;overflow-x:auto;scroll-snap-type:x mandatory;overscroll-behavior-x:contain}" +
527
+ ".ch-carousel:is([data-variant=hero],[data-variant=gallery],[data-variant=testimonials]) .ch-carousel__track{grid-auto-columns:100%}.ch-carousel__slide{scroll-snap-align:start;min-width:0;overflow:hidden;border-radius:8px}" +
528
+ ".ch-carousel[data-aspect='16:9'] .ch-carousel__slide{aspect-ratio:16/9}.ch-carousel[data-aspect='21:9'] .ch-carousel__slide{aspect-ratio:21/9}.ch-carousel[data-aspect='4:3'] .ch-carousel__slide{aspect-ratio:4/3}.ch-carousel[data-aspect='1:1'] .ch-carousel__slide{aspect-ratio:1}.ch-carousel[data-aspect='3:4'] .ch-carousel__slide{aspect-ratio:3/4}" +
529
+ ".ch-carousel[data-aspect] .ch-carousel__slide>*{height:100%;margin:0}.ch-carousel[data-aspect] .ch-carousel__slide img{width:100%;height:100%;object-fit:cover}" +
530
+ ".ch-carousel__controls{display:flex;align-items:center;justify-content:center;gap:.75rem;margin-top:.75rem}[data-ch-pending]{visibility:hidden}.ch-carousel__rotate[data-ch-pending]{display:none}" +
531
+ ".ch-carousel__markers{display:flex;flex-wrap:wrap;gap:.4rem;justify-content:center}.ch-carousel__markers a{display:inline-flex;align-items:center;justify-content:center;min-width:28px;min-height:28px;border-radius:999px;color:var(--muted);text-decoration:none;font-size:.85rem}" +
532
+ ".ch-carousel__markers[data-style=thumbs] a{width:56px;height:56px;overflow:hidden;border-radius:6px}.ch-carousel__markers[data-style=thumbs] img{width:100%;height:100%;object-fit:cover}";
533
+
534
+ /**
535
+ * The same policy `previewResponse` (packages/api) sends as a header, repeated in the document so
536
+ * it also holds where the document is shown without that response (an iframe's `srcdoc`).
537
+ */
538
+ const PREVIEW_CSP =
539
+ "default-src 'none'; img-src https: data:; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'";
540
+
541
+ function document(
542
+ site ,
543
+ title ,
544
+ description ,
545
+ body ,
546
+ robots ,
547
+ ) {
548
+ return `<!doctype html><html lang="${esc(site.defaultLocale)}"><head><meta charset="utf-8"><meta http-equiv="content-security-policy" content="${PREVIEW_CSP}"><title>${esc(title)}</title>${
549
+ description ? `<meta name="description" content="${esc(description)}">` : ""
550
+ }${robots ? `<meta name="robots" content="${esc(robots)}">` : ""}<meta name="viewport" content="width=device-width, initial-scale=1"><meta name="generator" content="Cloudhal preview"><style>${PREVIEW_CSS}</style></head><body><a class="ch-skip" href="#main">${esc(site.defaultLocale.startsWith("tr") ? "İçeriğe geç" : "Skip to content")}</a><header><a href="/">${esc(site.name)}</a></header><main id="main">${body}</main><footer>${esc(site.name)}</footer></body></html>`;
551
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Per-request source selection for a deployed site (Cloudflare Worker or a Node server):
3
+ *
4
+ * - **Published** (default): the site's `publishedSnapshotId` pointer decides what renders, so
5
+ * publish and rollback are pointer flips — no rebuild, no redeploy. Snapshots are immutable,
6
+ * so their sources are cached per isolate; the pointer itself is re-read after `pointerTtlMs`.
7
+ * - **Time gates** (RFC-0008 §7): the published source is the snapshot as seen at the request's
8
+ * instant (`SnapshotSource.at`), so embargoed and expired pages and entries are absent.
9
+ * - **Preview**: a signed token (`?cloudhal-preview=<token>`, then a cookie) shows drafts (`live`)
10
+ * or any snapshot, gated nodes included. Tokens are minted by the admin API (`mintPreviewToken`). `?cloudhal-preview=exit`
11
+ * leaves preview mode.
12
+ */
13
+ import type { Site } from "@cloudhal/core-contracts";
14
+ import { type SiteGraphStore } from "@cloudhal/core-ts";
15
+ import { type GraphSource, SnapshotSource } from "./source.js";
16
+ export declare const PREVIEW_PARAM = "cloudhal-preview";
17
+ export declare const PREVIEW_COOKIE = "cloudhal_preview";
18
+ export type Resolution = {
19
+ kind: "published";
20
+ source: SnapshotSource;
21
+ snapshotId: string;
22
+ /** The request's instant (ms): what the source's gates were checked against. */
23
+ at: number;
24
+ previewError?: string;
25
+ /** Clears a stale or exited preview cookie. */
26
+ setCookie?: string;
27
+ } | {
28
+ kind: "preview";
29
+ source: GraphSource;
30
+ target: "live" | {
31
+ snapshot: string;
32
+ };
33
+ /** Set when the token arrived in the URL: persist it for the rest of the session. */
34
+ setCookie?: string;
35
+ } | {
36
+ kind: "unpublished";
37
+ previewError?: string;
38
+ setCookie?: string;
39
+ };
40
+ export interface SiteResolverOptions {
41
+ store: SiteGraphStore;
42
+ siteId: string;
43
+ /** HMAC secret shared with the admin API; without it preview links are ignored. */
44
+ previewSecret?: string | undefined;
45
+ /** How long the published pointer is trusted before re-reading it. Default 2000 ms. */
46
+ pointerTtlMs?: number | undefined;
47
+ /**
48
+ * Persist a preview token from the URL in an HttpOnly cookie (default true). Disable it behind
49
+ * an edge cache that does not vary on cookies; carry the token in links instead.
50
+ */
51
+ previewCookie?: boolean | undefined;
52
+ /** Snapshot sources kept per isolate (they are immutable). Default 8. */
53
+ snapshotCacheSize?: number | undefined;
54
+ /**
55
+ * RFC-0010 read-through: keeps a background bundle write alive (the Worker's `waitUntil`). With
56
+ * it, the published snapshot gets a bundle the first time it renders without one.
57
+ */
58
+ persistBundle?: ((task: Promise<unknown>) => void) | undefined;
59
+ now?: () => number;
60
+ }
61
+ export declare class SiteResolver {
62
+ #private;
63
+ constructor(options: SiteResolverOptions);
64
+ /** The store sources read from (the media route needs its blobs and ledger). */
65
+ get store(): SiteGraphStore;
66
+ /** Forget the cached pointer (e.g. after a publish handled in the same isolate). */
67
+ invalidate(): void;
68
+ site(): Promise<Site>;
69
+ snapshot(id: string): Promise<SnapshotSource>;
70
+ resolve(request: Request): Promise<Resolution>;
71
+ }