@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.
- package/README.md +14 -0
- package/dist/src/astro-env.d.ts +2 -1
- package/dist/src/cloudflare-entry.js +15 -4
- package/dist/src/comments-middleware.js +5 -1
- package/dist/src/components/EntryFields.astro +20 -5
- package/dist/src/fields.d.ts +25 -4
- package/dist/src/fields.js +210 -53
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +5 -1
- package/dist/src/integration.d.ts +14 -0
- package/dist/src/integration.js +24 -1
- package/dist/src/live-source.d.ts +17 -0
- package/dist/src/live-source.js +86 -2
- package/dist/src/media.d.ts +11 -1
- package/dist/src/media.js +15 -2
- package/dist/src/reference-conversions.d.ts +35 -0
- package/dist/src/reference-conversions.js +89 -0
- package/dist/src/references.d.ts +119 -0
- package/dist/src/references.js +346 -0
- package/dist/src/runtime-workerd.d.ts +3 -3
- package/dist/src/runtime-workerd.js +3 -3
- package/dist/src/runtime.d.ts +4 -2
- package/dist/src/runtime.js +14 -5
- package/dist/src/site-dispatch.d.ts +10 -0
- package/dist/src/site-dispatch.js +13 -0
- package/dist/src/source.d.ts +29 -1
- package/dist/src/source.js +71 -1
- package/package.json +6 -6
package/dist/src/source.js
CHANGED
|
@@ -13,7 +13,12 @@
|
|
|
13
13
|
|
|
14
14
|
import { matchRedirect, redirectLocale } from "@cloudhal/core-ts";
|
|
15
15
|
import { hasGates, inheritedGate, isAvailable, nextInstant } from "@cloudhal/core-ts/availability";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
derivedGates,
|
|
20
|
+
|
|
21
|
+
} from "@cloudhal/core-ts/fields";
|
|
17
22
|
import { matches } from "@cloudhal/core-ts/filter";
|
|
18
23
|
import { assetRefsOf } from "@cloudhal/core-ts/media";
|
|
19
24
|
import {
|
|
@@ -25,9 +30,12 @@ import {
|
|
|
25
30
|
import { gateIndex, splitEntries } from "./entry-views.js";
|
|
26
31
|
import { entryFields, } from "./fields.js";
|
|
27
32
|
import { navigationFor } from "./navigation.js";
|
|
33
|
+
import { cachedConversionMaps, conversionMapsOf, siteConverts } from "./reference-conversions.js";
|
|
34
|
+
import { membersIn, ReferenceIndex, referrersIn } from "./references.js";
|
|
28
35
|
import { byNewest, byPosition, compile, shown, termFilter, visible } from "./source-helpers.js";
|
|
29
36
|
|
|
30
37
|
export { LiveSource } from "./live-source.js";
|
|
38
|
+
|
|
31
39
|
|
|
32
40
|
/**
|
|
33
41
|
* What a renderer needs from a site, independent of whether it reads live nodes (dev) or a
|
|
@@ -132,6 +140,19 @@ export { LiveSource } from "./live-source.js";
|
|
|
132
140
|
|
|
133
141
|
|
|
134
142
|
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
135
156
|
|
|
136
157
|
|
|
137
158
|
|
|
@@ -153,6 +174,11 @@ export { LiveSource } from "./live-source.js";
|
|
|
153
174
|
|
|
154
175
|
|
|
155
176
|
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
156
182
|
|
|
157
183
|
|
|
158
184
|
|
|
@@ -200,6 +226,10 @@ export { LiveSource } from "./live-source.js";
|
|
|
200
226
|
|
|
201
227
|
|
|
202
228
|
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
203
233
|
|
|
204
234
|
|
|
205
235
|
/** Who may see the nodes of a snapshot: the clock gates are checked against, or nobody (previews). */
|
|
@@ -358,6 +388,7 @@ export class SnapshotSource {
|
|
|
358
388
|
entries: shownEntries,
|
|
359
389
|
published: shownEntries,
|
|
360
390
|
reachable: shownEntries,
|
|
391
|
+
current: siteConverts(site ) ? entries : [],
|
|
361
392
|
derived,
|
|
362
393
|
resolved: new Map(),
|
|
363
394
|
taxonomies,
|
|
@@ -516,6 +547,45 @@ export class SnapshotSource {
|
|
|
516
547
|
return entryFields(this, entry, options);
|
|
517
548
|
}
|
|
518
549
|
|
|
550
|
+
async #references() {
|
|
551
|
+
const loaded = await this.#load();
|
|
552
|
+
if (this.#shared.references) return this.#shared.references;
|
|
553
|
+
const { site } = loaded;
|
|
554
|
+
const maps = await conversionMapsOf(site, Object.keys(site.collections ?? {}), (c) =>
|
|
555
|
+
this.conversionEntries(c),
|
|
556
|
+
);
|
|
557
|
+
this.#shared.references ??= new ReferenceIndex(site, loaded.published, maps);
|
|
558
|
+
return this.#shared.references;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/** RFC-0045 §4: in memory, through this view's gates (`reachable`: unlisted targets resolve). */
|
|
562
|
+
async groupMembers(groupIds ) {
|
|
563
|
+
const [index, view] = [await this.#references(), await this.#current()];
|
|
564
|
+
return membersIn(index.members(), groupIds, {
|
|
565
|
+
listed: view.entries,
|
|
566
|
+
reachable: view.reachable,
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
async referencedBy(groupId , q = {}) {
|
|
571
|
+
const [index, view] = [await this.#references(), await this.#current()];
|
|
572
|
+
return referrersIn(index.referrers(groupId), q, {
|
|
573
|
+
listed: view.entries,
|
|
574
|
+
reachable: view.reachable,
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
async conversionEntries(collection ) {
|
|
579
|
+
const loaded = await this.#load();
|
|
580
|
+
this.#shared.conversions ??= new Map();
|
|
581
|
+
return cachedConversionMaps(
|
|
582
|
+
this.#shared.conversions,
|
|
583
|
+
loaded.site,
|
|
584
|
+
collection,
|
|
585
|
+
() => loaded.current,
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
|
|
519
589
|
async taxonomies() {
|
|
520
590
|
return (await this.#current()).taxonomies;
|
|
521
591
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudhal/astro-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Render a Cloudhal Site Graph with Astro: data sources (live/snapshot), section components and the cloudhal() integration",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://cloudhal.dev",
|
|
@@ -223,14 +223,14 @@
|
|
|
223
223
|
"README.md"
|
|
224
224
|
],
|
|
225
225
|
"dependencies": {
|
|
226
|
-
"@cloudhal/core-contracts": "0.
|
|
227
|
-
"@cloudhal/core-ts": "0.
|
|
228
|
-
"@cloudhal/storage": "0.
|
|
226
|
+
"@cloudhal/core-contracts": "0.10.0",
|
|
227
|
+
"@cloudhal/core-ts": "0.10.0",
|
|
228
|
+
"@cloudhal/storage": "0.10.0",
|
|
229
229
|
"marked": "^18.1.1",
|
|
230
230
|
"parse5": "8.1.0",
|
|
231
|
-
"@cloudhal/analytics": "0.
|
|
231
|
+
"@cloudhal/analytics": "0.10.0",
|
|
232
232
|
"vite": "^8.3.5",
|
|
233
|
-
"@cloudhal/comments": "0.
|
|
233
|
+
"@cloudhal/comments": "0.10.0"
|
|
234
234
|
},
|
|
235
235
|
"peerDependencies": {
|
|
236
236
|
"astro": "^7.4.0",
|