@cloudhal/astro-renderer 0.8.0 → 0.10.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.
@@ -72,6 +72,29 @@ const THEME_HOOKS_ID = "virtual:cloudhal/theme-hooks";
72
72
  const RESOLVED_THEME_HOOKS_ID = `\0${THEME_HOOKS_ID}`;
73
73
  const THEME_MODULE = "src/theme.ts";
74
74
 
75
+ /**
76
+ * The type of `virtual:cloudhal/config`: the integration's config, with `dataDir` absent on the
77
+ * `cloudflare` target (`virtualConfig`). Theme code that reads `dataDir` must handle that.
78
+ */
79
+
80
+
81
+
82
+
83
+ /**
84
+ * What pages see as `virtual:cloudhal/config`. On the `cloudflare` target there is no `dataDir`:
85
+ * the Site Worker reads D1 and R2 through its bindings (`runtime-workerd.ts` ignores the field),
86
+ * and the resolved value is the build machine's absolute path, which a release bundle built in CI
87
+ * would otherwise carry to every deployment (RFC-0046 §11b, #239).
88
+ */
89
+ export function virtualConfig(
90
+ resolved ,
91
+ cloudflare ,
92
+ ) {
93
+ if (!cloudflare) return resolved;
94
+ const { dataDir: _buildMachinePath, ...rest } = resolved;
95
+ return rest;
96
+ }
97
+
75
98
  /** The virtual modules: the project config, and in dev the built analytics and comments clients. */
76
99
  function configPlugin(modules ) {
77
100
  const ids = {
@@ -182,7 +205,7 @@ export function cloudhal(config ) {
182
205
  vite: {
183
206
  plugins: [
184
207
  configPlugin({
185
- config: resolved,
208
+ config: virtualConfig(resolved, cloudflare),
186
209
  client: cloudflare ? null : (client ?? null),
187
210
  comments: cloudflare ? null : (comments ?? null),
188
211
  }),
@@ -1,8 +1,10 @@
1
1
  import type { Asset, ContentEntry, Menu, Page, Redirect, Site, Taxonomy, Term } from "@cloudhal/core-contracts";
2
2
  import type { RedirectMatch, SearchResults, SiteGraphStore } from "@cloudhal/core-ts";
3
+ import { type ConversionEntries } from "@cloudhal/core-ts/fields";
3
4
  import { type FieldEntryQuery, type FieldEntryResult } from "./entry-query.js";
4
5
  import { type EntryFieldsOptions, type RenderedFields } from "./fields.js";
5
6
  import { type Navigation, type NavigationOptions } from "./navigation.js";
7
+ import { type ReferencedByQuery } from "./references.js";
6
8
  import type { GraphSource, SourceSearchOptions } from "./source.js";
7
9
  /**
8
10
  * Reads the current nodes on every call. Drafts are included so authors can preview them in dev,
@@ -30,6 +32,21 @@ export declare class LiveSource implements GraphSource {
30
32
  search(query: string, options?: SourceSearchOptions): Promise<SearchResults>;
31
33
  entryById(id: string): Promise<ContentEntry | undefined>;
32
34
  entryFields(entry: ContentEntry, options?: EntryFieldsOptions): Promise<RenderedFields>;
35
+ /** RFC-0045 §4: one store read (`getGroupMembers`), then this view's gates. */
36
+ groupMembers(groupIds: readonly string[]): Promise<Map<string, ContentEntry[]>>;
37
+ /**
38
+ * RFC-0045 §4: the `entry_refs` rows naming the group, expanded by the `shared` rule, each
39
+ * candidate then resolved like the snapshot's index (its original from the same pool), so both
40
+ * sources answer alike on the same graph.
41
+ */
42
+ referencedBy(groupId: string, q?: ReferencedByQuery): Promise<ContentEntry[]>;
43
+ /**
44
+ * RFC-0045 §7: built from the working copy, only while the collection runs a conversion, from
45
+ * the collections it reads. Kept for `CONVERSION_MAPS_TTL_MS` per collection: one page's calls
46
+ * (every `entryFields`, depth-2 members, `referencedBy`) share one build, while `cloudhal dev`,
47
+ * whose one source serves every request, still sees edits.
48
+ */
49
+ conversionEntries(collection: string): Promise<ConversionEntries | undefined>;
33
50
  taxonomies(): Promise<Taxonomy[]>;
34
51
  terms(key: string): Promise<Term[]>;
35
52
  termBySlug(key: string, slug: string): Promise<Term | undefined>;
@@ -9,9 +9,14 @@
9
9
 
10
10
 
11
11
 
12
- import { searchDocuments, searchRows } from "@cloudhal/core-ts";
12
+ import {
13
+ getGroupMembers,
14
+ referrerCandidates,
15
+ searchDocuments,
16
+ searchRows,
17
+ } from "@cloudhal/core-ts";
13
18
  import { isAvailable, nextInstant } from "@cloudhal/core-ts/availability";
14
- import { derivedGates, hasExpiryRules } from "@cloudhal/core-ts/fields";
19
+ import { derivedGates, hasExpiryRules } from "@cloudhal/core-ts/fields";
15
20
  import { matches } from "@cloudhal/core-ts/filter";
16
21
  import {
17
22
  evaluateEntryQuery,
@@ -22,9 +27,15 @@ import {
22
27
  import { gateIndex, splitEntries } from "./entry-views.js";
23
28
  import { entryFields, } from "./fields.js";
24
29
  import { navigationFor } from "./navigation.js";
30
+ import { conversionMaps, conversionMapsOf, conversionNeeds } from "./reference-conversions.js";
31
+
32
+ import { membersIn, referrerRecords, referrersIn } from "./references.js";
25
33
 
26
34
  import { byNewest, byPosition, compile, shown, termFilter, visible } from "./source-helpers.js";
27
35
 
36
+ /** How long a live source reuses the conversion maps it built (one page render, not a session). */
37
+ const CONVERSION_MAPS_TTL_MS = 2_000;
38
+
28
39
  /**
29
40
  * Reads the current nodes on every call. Drafts are included so authors can preview them in dev,
30
41
  * and so are gated nodes (a preview shows embargoed and expired content, RFC-0008 §7.3). Without
@@ -36,6 +47,11 @@ export class LiveSource {
36
47
  #siteId ;
37
48
  #includeDrafts ;
38
49
  #now ;
50
+ /** RFC-0045 §7: conversion maps by collection, with when they were built. */
51
+ #conversions = new Map
52
+
53
+
54
+ ();
39
55
 
40
56
  constructor(
41
57
  store ,
@@ -206,6 +222,74 @@ export class LiveSource {
206
222
  return entryFields(this, entry, options);
207
223
  }
208
224
 
225
+ /** RFC-0045 §4: one store read (`getGroupMembers`), then this view's gates. */
226
+ async groupMembers(groupIds ) {
227
+ const read = await getGroupMembers(this.#store.sql, this.#siteId, groupIds);
228
+ // A translation's original is its group's root, so the rows read are the originals' pool too.
229
+ const members = [...read.values()].flat();
230
+ const split = await this.#split(members, members);
231
+ return membersIn(read, groupIds, { listed: split.listed, reachable: split.reachable });
232
+ }
233
+
234
+ /**
235
+ * RFC-0045 §4: the `entry_refs` rows naming the group, expanded by the `shared` rule, each
236
+ * candidate then resolved like the snapshot's index (its original from the same pool), so both
237
+ * sources answer alike on the same graph.
238
+ */
239
+ async referencedBy(groupId , q = {}) {
240
+ const [site, read] = await Promise.all([
241
+ this.site(),
242
+ referrerCandidates(this.#store.sql, this.#siteId, groupId),
243
+ ]);
244
+ const pool = visible([...read.byId.values()], this.#includeDrafts);
245
+ const ids = new Map(pool.map((e) => [e.id, e]));
246
+ const originalOf = (e ) => {
247
+ const g = e.translation?.group;
248
+ return g && g !== e.id ? ids.get(g) : undefined;
249
+ };
250
+ const shownHere = read.candidates.filter((e) => ids.has(e.id));
251
+ const maps = await conversionMapsOf(
252
+ site,
253
+ shownHere.map((e) => e.collection),
254
+ (c) => this.conversionEntries(c),
255
+ );
256
+ const records =
257
+ referrerRecords(site, shownHere, { originalOf, maps, only: groupId }).get(groupId) ?? [];
258
+ // The candidates' originals were read with them: the pool for derived gates as well.
259
+ const split = await this.#split(pool, pool);
260
+ return referrersIn(records, q, { listed: split.listed, reachable: split.reachable });
261
+ }
262
+
263
+ /**
264
+ * RFC-0045 §7: built from the working copy, only while the collection runs a conversion, from
265
+ * the collections it reads. Kept for `CONVERSION_MAPS_TTL_MS` per collection: one page's calls
266
+ * (every `entryFields`, depth-2 members, `referencedBy`) share one build, while `cloudhal dev`,
267
+ * whose one source serves every request, still sees edits.
268
+ */
269
+ async conversionEntries(collection ) {
270
+ const site = await this.site();
271
+ const needs = conversionNeeds(site, collection);
272
+ if (!needs) return undefined;
273
+ const at = Date.now();
274
+ const hit = this.#conversions.get(collection);
275
+ if (hit && at - hit.at < CONVERSION_MAPS_TTL_MS) return hit.maps;
276
+ const maps = conversionMaps(site, collection, async () => {
277
+ const read = needs.has("*")
278
+ ? await this.#store.listContentEntries(this.#siteId)
279
+ : (
280
+ await Promise.all(
281
+ [...needs].map((c) => this.#store.listContentEntries(this.#siteId, c)),
282
+ )
283
+ ).flat();
284
+ // Every entry, archived ones too: an archived target still lends its title (reference →
285
+ // text), and `conversionEntries` keeps archived ones out of what text matches.
286
+ return read;
287
+ });
288
+ this.#conversions.set(collection, { at, maps });
289
+ maps.catch(() => this.#conversions.delete(collection));
290
+ return maps;
291
+ }
292
+
209
293
  taxonomies() {
210
294
  return this.#store.listTaxonomies(this.#siteId);
211
295
  }
@@ -58,12 +58,22 @@ export interface ImageAttributeOptions {
58
58
  /** RFC-0028 §3. `cover` is the default. */
59
59
  export type ImageFit = "cover" | "contain" | "blur-fill" | "color-fill" | "natural";
60
60
  export declare const IMAGE_FITS: readonly ImageFit[];
61
- /** A page's placeholder allowance (RFC-0028 §4), shared by every image the page draws. */
61
+ /**
62
+ * A page's allowances, shared by everything one request draws: placeholder bytes (RFC-0028 §4),
63
+ * spent by every image, and RFC-0045 §4's resolved reference targets, spent by every
64
+ * `entryFields` call (absent: a full allowance on first use).
65
+ */
62
66
  export interface PlaceholderBudget {
63
67
  left: number;
68
+ /** RFC-0045 §4: reference targets left to resolve; past it they resolve to nothing. */
69
+ references?: number;
70
+ /** Set once the reference allowance ran out and was logged (one warning per request). */
71
+ referencesWarned?: boolean;
64
72
  }
65
73
  /** About 24 KB of LQIPs per page; beyond it images get their colour only. */
66
74
  export declare const PLACEHOLDER_BUDGET: number;
75
+ /** RFC-0045 §4: at most 200 resolved reference targets per request. */
76
+ export declare const REFERENCE_BUDGET = 200;
67
77
  export declare const placeholderBudget: () => PlaceholderBudget;
68
78
  /**
69
79
  * The placeholder painted behind an image while it loads (RFC-0028 §2): the dominant colour, and
package/dist/src/media.js CHANGED
@@ -75,13 +75,26 @@ export const IMAGE_FITS = [
75
75
  "natural",
76
76
  ];
77
77
 
78
- /** A page's placeholder allowance (RFC-0028 §4), shared by every image the page draws. */
78
+ /**
79
+ * A page's allowances, shared by everything one request draws: placeholder bytes (RFC-0028 §4),
80
+ * spent by every image, and RFC-0045 §4's resolved reference targets, spent by every
81
+ * `entryFields` call (absent: a full allowance on first use).
82
+ */
79
83
 
80
84
 
85
+  
86
+
87
+
88
+
81
89
 
82
90
  /** About 24 KB of LQIPs per page; beyond it images get their colour only. */
83
91
  export const PLACEHOLDER_BUDGET = 24 * 1024;
84
- export const placeholderBudget = () => ({ left: PLACEHOLDER_BUDGET });
92
+ /** RFC-0045 §4: at most 200 resolved reference targets per request. */
93
+ export const REFERENCE_BUDGET = 200;
94
+ export const placeholderBudget = () => ({
95
+ left: PLACEHOLDER_BUDGET,
96
+ references: REFERENCE_BUDGET,
97
+ });
85
98
 
86
99
  /**
87
100
  * The placeholder painted behind an image while it loads (RFC-0028 §2): the dominant colour, and
@@ -0,0 +1,35 @@
1
+ /**
2
+ * RFC-0045 §7 in the renderer: the entry maps a running text ↔ reference conversion reads
3
+ * (`ConvertContext.entries`), so `resolveFields` converts an entry phase B has not rewritten yet
4
+ * exactly as the writers and the operation will.
5
+ *
6
+ * - The snapshot source builds them from the snapshot's own entries (every one, drafts and
7
+ * archived ones included: the graph it renders), lazily, once per snapshot, isolate and
8
+ * collection, and only while the collection carries such a marker.
9
+ * - The live source builds them from the working copy (the graph phase B reads), every entry too,
10
+ * before resolving an entry of a collection that carries one.
11
+ *
12
+ * Both pass every entry, as the store does: `conversionEntries` keeps archived ones out of what
13
+ * text matches (`byText`, `usable`), and lets every member lend a title (`titles`).
14
+ *
15
+ * Without such a marker neither reads anything. Worker-safe.
16
+ */
17
+ import type { ContentEntry, Site } from "@cloudhal/core-contracts";
18
+ import { type ConversionEntries } from "@cloudhal/core-ts/fields";
19
+ /** The collections a collection's running conversions read, or `undefined` (nothing to build). */
20
+ export declare function conversionNeeds(site: Site, collection: string): ReadonlySet<string> | undefined;
21
+ /**
22
+ * The maps `source` builds for an entry of `collection`, asked only while the collection runs a
23
+ * conversion (`entryFields` and depth-2 cards call this, so no source reads anything otherwise).
24
+ */
25
+ export declare function conversionsFor(source: {
26
+ conversionEntries?(collection: string): Promise<ConversionEntries | undefined>;
27
+ }, site: Site, collection: string): Promise<ConversionEntries | undefined>;
28
+ /** True when some collection of the site runs a text ↔ reference conversion. */
29
+ export declare function siteConverts(site: Site): boolean;
30
+ /** The maps for `collection` over the entries `load` returns, or `undefined` without a conversion. */
31
+ export declare function conversionMaps(site: Site, collection: string, load: () => Promise<Iterable<ContentEntry>> | Iterable<ContentEntry>): Promise<ConversionEntries | undefined>;
32
+ /** A per-snapshot cache of `conversionMaps` by collection (the snapshot is immutable). */
33
+ export declare function cachedConversionMaps(cache: Map<string, Promise<ConversionEntries | undefined>>, site: Site, collection: string, entries: () => Iterable<ContentEntry>): Promise<ConversionEntries | undefined>;
34
+ /** The maps of every collection in `collections` that runs a conversion, by collection. */
35
+ export declare function conversionMapsOf(site: Site, collections: Iterable<string>, get: (collection: string) => Promise<ConversionEntries | undefined>): Promise<Map<string, ConversionEntries>>;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * RFC-0045 §7 in the renderer: the entry maps a running text ↔ reference conversion reads
3
+ * (`ConvertContext.entries`), so `resolveFields` converts an entry phase B has not rewritten yet
4
+ * exactly as the writers and the operation will.
5
+ *
6
+ * - The snapshot source builds them from the snapshot's own entries (every one, drafts and
7
+ * archived ones included: the graph it renders), lazily, once per snapshot, isolate and
8
+ * collection, and only while the collection carries such a marker.
9
+ * - The live source builds them from the working copy (the graph phase B reads), every entry too,
10
+ * before resolving an entry of a collection that carries one.
11
+ *
12
+ * Both pass every entry, as the store does: `conversionEntries` keeps archived ones out of what
13
+ * text matches (`byText`, `usable`), and lets every member lend a title (`titles`).
14
+ *
15
+ * Without such a marker neither reads anything. Worker-safe.
16
+ */
17
+
18
+ import {
19
+
20
+ conversionCollections,
21
+ conversionEntries,
22
+ fieldDefinitions,
23
+ } from "@cloudhal/core-ts/fields";
24
+
25
+ /** The collections a collection's running conversions read, or `undefined` (nothing to build). */
26
+ export function conversionNeeds(site , collection ) {
27
+ return conversionCollections(fieldDefinitions(site, collection));
28
+ }
29
+
30
+ /**
31
+ * The maps `source` builds for an entry of `collection`, asked only while the collection runs a
32
+ * conversion (`entryFields` and depth-2 cards call this, so no source reads anything otherwise).
33
+ */
34
+ export function conversionsFor(
35
+ source ,
36
+ site ,
37
+ collection ,
38
+ ) {
39
+ return conversionNeeds(site, collection) && source.conversionEntries
40
+ ? source.conversionEntries(collection)
41
+ : Promise.resolve(undefined);
42
+ }
43
+
44
+ /** True when some collection of the site runs a text ↔ reference conversion. */
45
+ export function siteConverts(site ) {
46
+ return Object.keys(site.collections ?? {}).some((c) => conversionNeeds(site, c) !== undefined);
47
+ }
48
+
49
+ /** The maps for `collection` over the entries `load` returns, or `undefined` without a conversion. */
50
+ export async function conversionMaps(
51
+ site ,
52
+ collection ,
53
+ load ,
54
+ ) {
55
+ const needs = conversionNeeds(site, collection);
56
+ if (!needs) return undefined;
57
+ return conversionEntries(await load(), site.defaultLocale, needs);
58
+ }
59
+
60
+ /** A per-snapshot cache of `conversionMaps` by collection (the snapshot is immutable). */
61
+ export function cachedConversionMaps(
62
+ cache ,
63
+ site ,
64
+ collection ,
65
+ entries ,
66
+ ) {
67
+ if (!conversionNeeds(site, collection)) return Promise.resolve(undefined);
68
+ let hit = cache.get(collection);
69
+ if (!hit) {
70
+ hit = conversionMaps(site, collection, entries);
71
+ cache.set(collection, hit);
72
+ }
73
+ return hit;
74
+ }
75
+
76
+ /** The maps of every collection in `collections` that runs a conversion, by collection. */
77
+ export async function conversionMapsOf(
78
+ site ,
79
+ collections ,
80
+ get ,
81
+ ) {
82
+ const out = new Map ();
83
+ for (const c of new Set(collections)) {
84
+ if (!conversionNeeds(site, c)) continue;
85
+ const maps = await get(c);
86
+ if (maps) out.set(c, maps);
87
+ }
88
+ return out;
89
+ }
@@ -0,0 +1,119 @@
1
+ /**
2
+ * RFC-0045 §4 in the renderer: reference cards, and the indexes both sources answer
3
+ * `groupMembers` and `referencedBy` from.
4
+ *
5
+ * - **Cards** (`referenceCards`): breadth-first over the groups a page's values name, one
6
+ * `groupMembers` call per level (the live source: one store read; the snapshot: none). The member
7
+ * shown is `pickMember`'s, among the members the source's *view* shows (gates applied at its
8
+ * instant). Depth 1 (default) yields cards; depth 2 adds each card's own fields, whose references
9
+ * are cards without fields. Groups are fetched once (the visited set), so cycles cost nothing.
10
+ * Every card spends one of the request's 200 targets (`PlaceholderBudget.references`); past it
11
+ * the rest resolve to nothing, with one `console.warn` per request.
12
+ * - **Indexes** (`ReferenceIndex`, snapshot only): members by group and referrers by group over the
13
+ * snapshot's published entries, gate-independent and built once per snapshot and isolate; every
14
+ * lookup then filters through the asking view.
15
+ * - **`referencedBy`** equals the resolved values: a referrer is an entry whose `resolveFields`
16
+ * names the group, with its same-site original while the view shows it and without it otherwise
17
+ * (exactly what its page reads), the running conversions' maps included. The live source finds candidates in
18
+ * `entry_refs` and resolves them the same way (`referrerRecords`), so both answer alike.
19
+ */
20
+ import type { ContentEntry, Site } from "@cloudhal/core-contracts";
21
+ import { type ConversionEntries, type ReferenceUse, type ResolvedFields } from "@cloudhal/core-ts/fields";
22
+ import type { FieldImage, FieldsSource, RenderedFields } from "./fields.js";
23
+ import { type PlaceholderBudget } from "./media.js";
24
+ /** A referenced entry as a theme draws it: a card of the member the page's view shows. */
25
+ export interface ReferencedEntry {
26
+ /** The translation group the value names. */
27
+ groupId: string;
28
+ id: string;
29
+ collection: string;
30
+ locale: string;
31
+ slug: string;
32
+ title: string;
33
+ summary?: string;
34
+ /**
35
+ * The member's graph path (`entryPath`, no locale prefix): link with it, as every other entry
36
+ * link does, so the locale middleware (`localizeLinks`) maps it to the page's locale once.
37
+ */
38
+ path: string;
39
+ /** The member's canonical URL: its locale's path, absolute only on a locale's own domain. */
40
+ url: string;
41
+ /** The member's cover image, when the view shows its asset. */
42
+ image?: FieldImage;
43
+ /** The member is the default locale's, shown under `default-with-notice`: set `lang` on it. */
44
+ fromFallbackLocale: boolean;
45
+ /** Present only at depth 2: the member's own fields, its references as cards without fields. */
46
+ fields?: RenderedFields;
47
+ }
48
+ /** `referencedBy`'s filters. */
49
+ export interface ReferencedByQuery {
50
+ collection?: string;
51
+ /** The referrer's top-level field key (`venue`, `speakers`). */
52
+ field?: string;
53
+ locale?: string;
54
+ /** At most 100 (the default). */
55
+ limit?: number;
56
+ }
57
+ export declare const REFERENCED_BY_LIMIT = 100;
58
+ /** What `referenceCards` needs from `entryFields`: the page, its budget and its media. */
59
+ export interface CardInput {
60
+ readonly source: FieldsSource;
61
+ readonly site: Site;
62
+ /** The page's locale: the member shown is in it, else (with `default-with-notice`) the default. */
63
+ readonly locale: string;
64
+ readonly depth: 1 | 2;
65
+ readonly budget: PlaceholderBudget;
66
+ /** The member's cover through the view's assets, or none. */
67
+ readonly cover: (member: ContentEntry) => Promise<FieldImage | undefined>;
68
+ /** Renders a level-2 member's fields with its own references' cards. */
69
+ readonly render: (resolved: ResolvedFields, cards: ReadonlyMap<string, ReferencedEntry>) => Promise<RenderedFields>;
70
+ }
71
+ /** The reference values under resolved fields, top-level and inside repeater items, in order. */
72
+ export declare function usesOf(resolved: ResolvedFields): ReferenceUse[];
73
+ /**
74
+ * The cards of an entry's resolved values, by value path (`fields/venue`, `fields/speakers/0/
75
+ * person`). Without `groupMembers` (sources from before RFC-0045) nothing resolves.
76
+ */
77
+ export declare function referenceCards(input: CardInput, resolved: ResolvedFields): Promise<Map<string, ReferencedEntry>>;
78
+ /**
79
+ * One referrer of a group: the entry and the field whose resolved value names it. A same-site
80
+ * translation resolves through its original only while the view shows that original (its page
81
+ * reads it through the gated `entryById`), so its records carry which way they hold.
82
+ */
83
+ export interface Referrer {
84
+ readonly entry: ContentEntry;
85
+ /** The top-level field key. */
86
+ readonly field: string;
87
+ /** Holds only while the view shows this original (resolved with it). */
88
+ readonly withOriginal?: string;
89
+ /** Holds only while the view does not show this original (resolved without it). */
90
+ readonly withoutOriginal?: string;
91
+ }
92
+ /** The conversion maps by collection, for collections that run a conversion (§7). */
93
+ export type ConversionMaps = ReadonlyMap<string, ConversionEntries>;
94
+ /**
95
+ * Referrers by group from `entries`' resolved values, with `only` just that group's; the snapshot
96
+ * index and the live source share it. An entry with an original in `originalOf`'s pool is
97
+ * resolved both with it and without it, so `referrersIn` can follow the view's choice.
98
+ */
99
+ export declare function referrerRecords(site: Site, entries: readonly ContentEntry[], input: {
100
+ originalOf: (e: ContentEntry) => ContentEntry | undefined;
101
+ maps?: ConversionMaps | undefined;
102
+ only?: string | undefined;
103
+ }): Map<string, Referrer[]>;
104
+ /** What a view shows: `listed` for "used by" lists, `reachable` for resolution and originals. */
105
+ export interface ReferenceView {
106
+ readonly listed: readonly ContentEntry[];
107
+ readonly reachable: readonly ContentEntry[];
108
+ }
109
+ /** `referencedBy` over records: shown referrers, filtered, newest first, at most 100. */
110
+ export declare function referrersIn(records: readonly Referrer[], q: ReferencedByQuery, view: ReferenceView): ContentEntry[];
111
+ /** The members of `ids` among a view's reachable entries (every id gets a list). */
112
+ export declare function membersIn(all: ReadonlyMap<string, readonly ContentEntry[]>, ids: readonly string[], view: ReferenceView): Map<string, ContentEntry[]>;
113
+ /** A snapshot's gate-independent indexes over its published entries, each built on first use. */
114
+ export declare class ReferenceIndex {
115
+ #private;
116
+ constructor(site: Site, published: readonly ContentEntry[], maps?: ConversionMaps);
117
+ members(): ReadonlyMap<string, readonly ContentEntry[]>;
118
+ referrers(group: string): readonly Referrer[];
119
+ }