@abraca/junis 2.85.0 → 2.86.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/dist/module.d.mts +17 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +235 -19
- package/dist/runtime/assets/css/jun.css +1 -1
- package/dist/runtime/components/JunCampfirePresence.client.vue +75 -10
- package/dist/runtime/components/JunCollectionIntro.d.vue.ts +11 -0
- package/dist/runtime/components/JunCollectionIntro.vue +45 -0
- package/dist/runtime/components/JunCollectionIntro.vue.d.ts +11 -0
- package/dist/runtime/components/JunConfigRow.d.vue.ts +43 -0
- package/dist/runtime/components/JunConfigRow.vue +34 -0
- package/dist/runtime/components/JunConfigRow.vue.d.ts +43 -0
- package/dist/runtime/components/JunFooter.vue +1 -1
- package/dist/runtime/components/JunHorizontalTimeline.d.vue.ts +30 -0
- package/dist/runtime/components/JunHorizontalTimeline.vue.d.ts +30 -0
- package/dist/runtime/components/JunLinksRow.d.vue.ts +16 -1
- package/dist/runtime/components/JunLinksRow.vue +17 -7
- package/dist/runtime/components/JunLinksRow.vue.d.ts +16 -1
- package/dist/runtime/components/JunMedia.client.d.vue.ts +1 -1
- package/dist/runtime/components/JunMedia.client.vue.d.ts +1 -1
- package/dist/runtime/components/JunNavigation.vue +21 -4
- package/dist/runtime/components/JunNoteLinks.d.vue.ts +6 -0
- package/dist/runtime/components/JunNoteLinks.vue +57 -0
- package/dist/runtime/components/JunNoteLinks.vue.d.ts +6 -0
- package/dist/runtime/components/JunPageHero.d.vue.ts +8 -2
- package/dist/runtime/components/JunPageHero.vue +15 -3
- package/dist/runtime/components/JunPageHero.vue.d.ts +8 -2
- package/dist/runtime/components/JunReaders.d.vue.ts +11 -0
- package/dist/runtime/components/JunReaders.vue +99 -0
- package/dist/runtime/components/JunReaders.vue.d.ts +11 -0
- package/dist/runtime/components/JunSearch.client.vue +2 -2
- package/dist/runtime/components/JunSectionPresence.client.d.vue.ts +17 -0
- package/dist/runtime/components/JunSectionPresence.client.vue +99 -0
- package/dist/runtime/components/JunSectionPresence.client.vue.d.ts +17 -0
- package/dist/runtime/components/JunThreadComposer.d.vue.ts +37 -0
- package/dist/runtime/components/JunThreadComposer.vue +54 -0
- package/dist/runtime/components/JunThreadComposer.vue.d.ts +37 -0
- package/dist/runtime/components/JunTravellersChip.vue +35 -5
- package/dist/runtime/components/JunVideoEmbed.client.d.vue.ts +1 -1
- package/dist/runtime/components/JunVideoEmbed.client.vue.d.ts +1 -1
- package/dist/runtime/components/JunViewControl.d.vue.ts +29 -0
- package/dist/runtime/components/JunViewControl.vue +340 -0
- package/dist/runtime/components/JunViewControl.vue.d.ts +29 -0
- package/dist/runtime/components/JunViewControls.d.vue.ts +27 -0
- package/dist/runtime/components/JunViewControls.vue +94 -0
- package/dist/runtime/components/JunViewControls.vue.d.ts +27 -0
- package/dist/runtime/components/renderers/JunAppsRenderer.vue +45 -4
- package/dist/runtime/components/renderers/JunCinemaRenderer.vue +42 -4
- package/dist/runtime/components/renderers/JunConfigRenderer.vue +348 -225
- package/dist/runtime/components/renderers/JunCourseRenderer.d.vue.ts +10 -0
- package/dist/runtime/components/renderers/JunCourseRenderer.vue +229 -0
- package/dist/runtime/components/renderers/JunCourseRenderer.vue.d.ts +10 -0
- package/dist/runtime/components/renderers/JunCvRenderer.vue +44 -6
- package/dist/runtime/components/renderers/JunDeckRenderer.d.vue.ts +9 -0
- package/dist/runtime/components/renderers/JunDeckRenderer.vue +370 -0
- package/dist/runtime/components/renderers/JunDeckRenderer.vue.d.ts +9 -0
- package/dist/runtime/components/renderers/JunEntryRenderer.vue +151 -23
- package/dist/runtime/components/renderers/JunFestivalRenderer.vue +41 -4
- package/dist/runtime/components/renderers/JunGardenRenderer.d.vue.ts +10 -0
- package/dist/runtime/components/renderers/JunGardenRenderer.vue +280 -0
- package/dist/runtime/components/renderers/JunGardenRenderer.vue.d.ts +10 -0
- package/dist/runtime/components/renderers/JunGuestbookRenderer.vue +96 -14
- package/dist/runtime/components/renderers/JunHomeRenderer.vue +28 -129
- package/dist/runtime/components/renderers/JunItemRenderer.d.vue.ts +10 -0
- package/dist/runtime/components/renderers/JunItemRenderer.vue +398 -0
- package/dist/runtime/components/renderers/JunItemRenderer.vue.d.ts +10 -0
- package/dist/runtime/components/renderers/JunJournalRenderer.vue +141 -11
- package/dist/runtime/components/renderers/JunLibraryRenderer.vue +295 -12
- package/dist/runtime/components/renderers/JunLinksRenderer.vue +33 -1
- package/dist/runtime/components/renderers/JunLiveRenderer.vue +37 -1
- package/dist/runtime/components/renderers/JunMosaicRenderer.vue +3 -2
- package/dist/runtime/components/renderers/JunMovieRenderer.vue +32 -5
- package/dist/runtime/components/renderers/JunNowRenderer.vue +38 -5
- package/dist/runtime/components/renderers/JunPollRenderer.d.vue.ts +9 -0
- package/dist/runtime/components/renderers/JunPollRenderer.vue +231 -0
- package/dist/runtime/components/renderers/JunPollRenderer.vue.d.ts +9 -0
- package/dist/runtime/components/renderers/JunProjectRenderer.vue +74 -18
- package/dist/runtime/components/renderers/JunServicesRenderer.vue +40 -2
- package/dist/runtime/components/renderers/JunStatsRenderer.vue +37 -50
- package/dist/runtime/components/renderers/JunThreadRenderer.d.vue.ts +9 -0
- package/dist/runtime/components/renderers/JunThreadRenderer.vue +304 -0
- package/dist/runtime/components/renderers/JunThreadRenderer.vue.d.ts +9 -0
- package/dist/runtime/components/renderers/JunTrackRenderer.vue +32 -4
- package/dist/runtime/components/renderers/JunUsesRenderer.vue +51 -5
- package/dist/runtime/components/renderers/JunWallRenderer.vue +60 -5
- package/dist/runtime/composables/useJunDeck.d.ts +66 -0
- package/dist/runtime/composables/useJunDeck.js +61 -0
- package/dist/runtime/composables/useJunDocPage.d.ts +14 -11
- package/dist/runtime/composables/useJunDocPage.js +67 -3
- package/dist/runtime/composables/useJunFollow.d.ts +65 -9
- package/dist/runtime/composables/useJunFollow.js +237 -20
- package/dist/runtime/composables/useJunGarden.d.ts +67 -0
- package/dist/runtime/composables/useJunGarden.js +92 -0
- package/dist/runtime/composables/useJunPresence.d.ts +26 -0
- package/dist/runtime/composables/useJunPresence.js +9 -2
- package/dist/runtime/composables/useJunSections.d.ts +73 -0
- package/dist/runtime/composables/useJunSections.js +117 -0
- package/dist/runtime/composables/useJunSettings.d.ts +1 -1
- package/dist/runtime/composables/useJunSettings.js +5 -1
- package/dist/runtime/composables/useJunSiteConfig.d.ts +37 -0
- package/dist/runtime/composables/useJunTheme.js +40 -2
- package/dist/runtime/composables/useJunViewOptions.d.ts +85 -0
- package/dist/runtime/composables/useJunViewOptions.js +63 -0
- package/dist/runtime/pages/doc.vue +14 -8
- package/dist/runtime/server/api/health.get.d.ts +19 -0
- package/dist/runtime/server/api/health.get.js +40 -0
- package/dist/runtime/server/api/links.get.d.ts +19 -0
- package/dist/runtime/server/api/links.get.js +37 -0
- package/dist/runtime/server/api/resolve/[...slug].get.d.ts +9 -0
- package/dist/runtime/server/api/resolve/[...slug].get.js +5 -0
- package/dist/runtime/server/api/stats.get.js +2 -1
- package/dist/runtime/server/janitor/junJanitorChores.js +8 -0
- package/dist/runtime/server/plugins/jun-bootstrap.js +103 -15
- package/dist/runtime/server/plugins/jun-doc-cache.js +42 -4
- package/dist/runtime/server/plugins/jun-janitor.js +7 -0
- package/dist/runtime/server/plugins/jun-rpc.js +293 -0
- package/dist/runtime/server/plugins/jun-watchdog.d.ts +2 -0
- package/dist/runtime/server/plugins/jun-watchdog.js +54 -0
- package/dist/runtime/server/routes/sitemap.xml.get.js +2 -0
- package/dist/runtime/server/utils/junBoot.d.ts +1 -0
- package/dist/runtime/server/utils/junBoot.js +4 -0
- package/dist/runtime/server/utils/junCache.d.ts +17 -0
- package/dist/runtime/server/utils/junCache.js +5 -0
- package/dist/runtime/server/utils/junSeedGate.d.ts +68 -0
- package/dist/runtime/server/utils/junSeedGate.js +41 -0
- package/dist/runtime/types.d.ts +57 -1
- package/dist/runtime/utils/junCourse.d.ts +106 -0
- package/dist/runtime/utils/junCourse.js +65 -0
- package/dist/runtime/utils/junGarden.d.ts +193 -0
- package/dist/runtime/utils/junGarden.js +233 -0
- package/dist/runtime/utils/junMetaSchemas.js +8 -1
- package/dist/runtime/utils/junModeration.d.ts +67 -0
- package/dist/runtime/utils/junModeration.js +20 -0
- package/dist/runtime/utils/junMotion.d.ts +26 -0
- package/dist/runtime/utils/junMotion.js +31 -0
- package/dist/runtime/utils/junPeople.d.ts +43 -0
- package/dist/runtime/utils/junPeople.js +9 -0
- package/dist/runtime/utils/junPoll.d.ts +79 -0
- package/dist/runtime/utils/junPoll.js +82 -0
- package/dist/runtime/utils/junReadiness.d.ts +131 -0
- package/dist/runtime/utils/junReadiness.js +69 -0
- package/dist/runtime/utils/junSections.d.ts +115 -0
- package/dist/runtime/utils/junSections.js +45 -0
- package/dist/runtime/utils/junSlides.d.ts +66 -0
- package/dist/runtime/utils/junSlides.js +47 -0
- package/dist/runtime/utils/junThread.d.ts +81 -0
- package/dist/runtime/utils/junThread.js +75 -0
- package/dist/runtime/utils/junViewSpecs.d.ts +671 -0
- package/dist/runtime/utils/junViewSpecs.js +534 -0
- package/dist/runtime/utils/junViewValues.d.ts +125 -0
- package/dist/runtime/utils/junViewValues.js +104 -0
- package/dist/types.d.mts +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { defineNitroPlugin, useRuntimeConfig, useStorage } from "nitropack/runtime";
|
|
2
|
+
import { junDocTree, junHeartbeat, junSlugMap } from "../utils/junCache.js";
|
|
3
|
+
import { junBootedAt } from "../utils/junBoot.js";
|
|
4
|
+
import { junReadiness, junShouldWarn } from "../../utils/junReadiness.js";
|
|
5
|
+
const TICK_MS = 2e4;
|
|
6
|
+
const WARN_EVERY_MS = 6e4;
|
|
7
|
+
export default defineNitroPlugin((nitroApp) => {
|
|
8
|
+
const jun = useRuntimeConfig().public.jun ?? {};
|
|
9
|
+
const apiBase = jun.apiBase ?? "/api/_jun";
|
|
10
|
+
const docCacheOn = jun.features?.docCache !== false;
|
|
11
|
+
let lastWarnedAt = null;
|
|
12
|
+
let lastState = null;
|
|
13
|
+
let timer = null;
|
|
14
|
+
async function look() {
|
|
15
|
+
const storage = useStorage();
|
|
16
|
+
const [tree, slugs, bodyKeys, beat] = await Promise.all([
|
|
17
|
+
junDocTree(),
|
|
18
|
+
junSlugMap(),
|
|
19
|
+
storage.getKeys("doc-cache:html"),
|
|
20
|
+
junHeartbeat()
|
|
21
|
+
]);
|
|
22
|
+
const heartbeatAgeMs = beat && beat.at >= junBootedAt() ? Date.now() - beat.at : null;
|
|
23
|
+
const verdict = junReadiness({
|
|
24
|
+
treeSize: Object.keys(tree).length,
|
|
25
|
+
slugCount: Object.keys(slugs).length,
|
|
26
|
+
bodyCount: bodyKeys.length,
|
|
27
|
+
ageMs: Date.now() - junBootedAt(),
|
|
28
|
+
heartbeatAgeMs,
|
|
29
|
+
expectHeartbeat: docCacheOn
|
|
30
|
+
});
|
|
31
|
+
if (verdict.state === "ready" && lastState !== "ready") {
|
|
32
|
+
console.log(`[jun:watchdog] SSR is ready \u2014 ${verdict.reason}`);
|
|
33
|
+
lastWarnedAt = null;
|
|
34
|
+
}
|
|
35
|
+
if (junShouldWarn(verdict.state, lastWarnedAt, Date.now(), WARN_EVERY_MS)) {
|
|
36
|
+
lastWarnedAt = Date.now();
|
|
37
|
+
const log = verdict.state === "dead" ? console.error : console.warn;
|
|
38
|
+
log(
|
|
39
|
+
`[jun:watchdog] THIS DEPLOYMENT CANNOT SERVER-RENDER \u2014 ${verdict.reason}
|
|
40
|
+
[jun:watchdog] ${verdict.hint ?? ""}
|
|
41
|
+
[jun:watchdog] Details: GET ${apiBase}/health (503 while this lasts). The site still works in a browser, which is exactly why this needs saying.`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
lastState = verdict.state;
|
|
45
|
+
}
|
|
46
|
+
const first = setTimeout(() => {
|
|
47
|
+
void look();
|
|
48
|
+
timer = setInterval(() => void look(), TICK_MS);
|
|
49
|
+
}, TICK_MS);
|
|
50
|
+
nitroApp.hooks.hook("close", () => {
|
|
51
|
+
clearTimeout(first);
|
|
52
|
+
if (timer) clearInterval(timer);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -14,6 +14,8 @@ export default defineEventHandler(async (event) => {
|
|
|
14
14
|
if (e.meta?.draft === true) return false;
|
|
15
15
|
if (e.meta?.signerId) return false;
|
|
16
16
|
if ((e.type ?? "").endsWith("-redirect")) return false;
|
|
17
|
+
if (e.meta?.paneDoc || e.meta?.paneWidget) return false;
|
|
18
|
+
if (e.meta?.t != null) return false;
|
|
17
19
|
return true;
|
|
18
20
|
}).map(([, slug]) => `${site}/${slug}`);
|
|
19
21
|
setResponseHeader(event, "content-type", "application/xml; charset=utf-8");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function junBootedAt(): number;
|
|
@@ -33,6 +33,23 @@ export declare function junDocTree(): Promise<Record<string, JunTreeEntry>>;
|
|
|
33
33
|
* disagreeing about what a page is.
|
|
34
34
|
*/
|
|
35
35
|
export declare function junCountedDocIds(tree: Record<string, JunTreeEntry>, rootDocId: string): Set<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Where the doc-cache runner stamps that it is alive.
|
|
38
|
+
*
|
|
39
|
+
* A cache is not a runner: `/app/.data` persists across container restarts, so a
|
|
40
|
+
* complete cache can outlive the process that filled it — and a deployment whose
|
|
41
|
+
* runners never booted then looks perfectly healthy while serving a frozen
|
|
42
|
+
* snapshot. `junReadiness` treats a missing or stale stamp as dead however
|
|
43
|
+
* complete the cache looks. Found by reproducing the jun.is failure, not by
|
|
44
|
+
* reading the code.
|
|
45
|
+
*/
|
|
46
|
+
export declare const JUN_HEARTBEAT_KEY = "doc-cache:jun-heartbeat";
|
|
47
|
+
export interface JunHeartbeat {
|
|
48
|
+
at: number;
|
|
49
|
+
docs: number;
|
|
50
|
+
}
|
|
51
|
+
/** The last sweep's stamp, or `null` when this process has never swept. */
|
|
52
|
+
export declare function junHeartbeat(): Promise<JunHeartbeat | null>;
|
|
36
53
|
/** Document id → canonical slug, as persisted by the doc-tree-cache runner. */
|
|
37
54
|
export declare function junSlugMap(): Promise<Record<string, string>>;
|
|
38
55
|
/** A document's cached HTML body, or `null` if it has not been rendered yet. */
|
|
@@ -20,6 +20,11 @@ export function junCountedDocIds(tree, rootDocId) {
|
|
|
20
20
|
}
|
|
21
21
|
return out;
|
|
22
22
|
}
|
|
23
|
+
export const JUN_HEARTBEAT_KEY = "doc-cache:jun-heartbeat";
|
|
24
|
+
export async function junHeartbeat() {
|
|
25
|
+
const beat = await useStorage().getItem(JUN_HEARTBEAT_KEY);
|
|
26
|
+
return beat && typeof beat.at === "number" ? beat : null;
|
|
27
|
+
}
|
|
23
28
|
export async function junSlugMap() {
|
|
24
29
|
const map = await useStorage().getItem(
|
|
25
30
|
"doc-cache:slug-map"
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One signal, from the seeder to the janitor: **the site is finished being
|
|
3
|
+
* built.**
|
|
4
|
+
*
|
|
5
|
+
* ── The bug this replaces ────────────────────────────────────────────────────
|
|
6
|
+
*
|
|
7
|
+
* The janitor waited a flat `BOOT_DELAY_MS` (20s) before capturing its
|
|
8
|
+
* baseline, with a comment saying exactly why — *"capturing a baseline mid-seed
|
|
9
|
+
* would record a half-built site as the clean state"* — and a guess in place of
|
|
10
|
+
* a signal.
|
|
11
|
+
*
|
|
12
|
+
* The guess loses on a first boot. Measured on the playground: 127 documents,
|
|
13
|
+
* 117 bodies and then four generated PNGs uploaded over HTTP, and the upload
|
|
14
|
+
* pass is the one that finishes last because it is the only part waiting on a
|
|
15
|
+
* network round trip per item. The janitor's baseline landed BETWEEN the tree
|
|
16
|
+
* write and the photo patch, so `coverUploadId` on every wall photograph looked
|
|
17
|
+
* like something a visitor had added — and in `clean` mode it was reverted,
|
|
18
|
+
* once, permanently, before anybody ever saw the Wall.
|
|
19
|
+
*
|
|
20
|
+
* The symptom is not janitor-shaped at all: **the Wall renders its title and no
|
|
21
|
+
* photographs**, on a site whose seeder logged `uploaded 4 wall photo(s)`. The
|
|
22
|
+
* tell is a tree entry that still carries `seedWallPhoto: true` — the seeder
|
|
23
|
+
* deletes that key in the same write that adds the cover — and a
|
|
24
|
+
* `janitor:inspect` that reports the site matching its baseline exactly, because
|
|
25
|
+
* by then it does.
|
|
26
|
+
*
|
|
27
|
+
* ── Why a module-scoped promise ──────────────────────────────────────────────
|
|
28
|
+
*
|
|
29
|
+
* Both plugins live in ONE Nitro process, so the simplest correct channel is a
|
|
30
|
+
* shared module. Either side may touch it first: whoever does creates the
|
|
31
|
+
* promise, the seeder resolves it, the janitor awaits it. Nitro's plugin order
|
|
32
|
+
* therefore does not matter, which is the property a storage key or a hook would
|
|
33
|
+
* not have given without more ceremony.
|
|
34
|
+
*
|
|
35
|
+
* The wait is BOUNDED and the caller passes the bound. A seeder that dies
|
|
36
|
+
* without settling must not leave the janitor asleep forever — it would present
|
|
37
|
+
* as "the janitor never starts", which is the single hardest failure to read in
|
|
38
|
+
* this subsystem.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Called by the seeder as it starts, so a janitor that asks first has something
|
|
42
|
+
* to wait on rather than resolving immediately.
|
|
43
|
+
*/
|
|
44
|
+
export declare function junSeedStarted(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Called by the seeder when the tree, the bodies AND the uploads are all in.
|
|
47
|
+
* Idempotent, and safe to call from a `finally` — a seed that failed halfway is
|
|
48
|
+
* still a seed that is no longer writing, which is what the janitor is waiting
|
|
49
|
+
* to know.
|
|
50
|
+
*/
|
|
51
|
+
export declare function junSeedFinished(): void;
|
|
52
|
+
/** Has the seeder already finished (or never started) in this process? */
|
|
53
|
+
export declare function junSeedSettled(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Is there a seeder in this process at all?
|
|
56
|
+
*
|
|
57
|
+
* The janitor must not wait on a gate nobody will open — a site with
|
|
58
|
+
* `seed.enabled: false` has no seeder, and waiting out the full bound there
|
|
59
|
+
* would delay the baseline for no reason. Safe to call after the janitor's own
|
|
60
|
+
* boot delay: both plugins register their runners in the same tick, so a seeder
|
|
61
|
+
* that exists has claimed the gate long before anybody asks.
|
|
62
|
+
*/
|
|
63
|
+
export declare function junSeedExpected(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Wait for the seed to finish, or for `timeoutMs`, whichever comes first.
|
|
66
|
+
* Resolves immediately when the seed has already settled.
|
|
67
|
+
*/
|
|
68
|
+
export declare function junWaitForSeed(timeoutMs: number): Promise<boolean>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
let settled = false;
|
|
2
|
+
let resolveGate = null;
|
|
3
|
+
let gate = null;
|
|
4
|
+
function ensure() {
|
|
5
|
+
if (!gate) {
|
|
6
|
+
gate = new Promise((resolve) => {
|
|
7
|
+
resolveGate = resolve;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
return gate;
|
|
11
|
+
}
|
|
12
|
+
export function junSeedStarted() {
|
|
13
|
+
if (settled) return;
|
|
14
|
+
ensure();
|
|
15
|
+
}
|
|
16
|
+
export function junSeedFinished() {
|
|
17
|
+
settled = true;
|
|
18
|
+
ensure();
|
|
19
|
+
resolveGate?.();
|
|
20
|
+
resolveGate = null;
|
|
21
|
+
}
|
|
22
|
+
export function junSeedSettled() {
|
|
23
|
+
return settled;
|
|
24
|
+
}
|
|
25
|
+
export function junSeedExpected() {
|
|
26
|
+
return gate !== null;
|
|
27
|
+
}
|
|
28
|
+
export async function junWaitForSeed(timeoutMs) {
|
|
29
|
+
if (settled) return true;
|
|
30
|
+
const promise = ensure();
|
|
31
|
+
let timer;
|
|
32
|
+
const timeout = new Promise((resolve) => {
|
|
33
|
+
timer = setTimeout(() => resolve(false), timeoutMs);
|
|
34
|
+
});
|
|
35
|
+
try {
|
|
36
|
+
const won = await Promise.race([promise.then(() => true), timeout]);
|
|
37
|
+
return won;
|
|
38
|
+
} finally {
|
|
39
|
+
if (timer) clearTimeout(timer);
|
|
40
|
+
}
|
|
41
|
+
}
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* - DETAIL pages are the children of a list page and render one document.
|
|
17
17
|
* - SYSTEM pages are singletons that configure or describe the site itself.
|
|
18
18
|
*/
|
|
19
|
-
export type JunPageTypeKey = 'apps' | 'journal' | 'live' | 'links' | 'cv' | 'wall' | 'uses' | 'library' | 'guestbook' | 'cinema' | 'festival' | 'services' | 'app' | 'entry' | 'now' | 'movie' | 'track' | 'globe' | 'mosaic' | 'config' | 'redirect' | 'stats' | 'home';
|
|
19
|
+
export type JunPageTypeKey = 'apps' | 'journal' | 'live' | 'links' | 'cv' | 'wall' | 'uses' | 'library' | 'guestbook' | 'cinema' | 'festival' | 'services' | 'poll' | 'thread' | 'garden' | 'course' | 'app' | 'entry' | 'now' | 'movie' | 'track' | 'globe' | 'mosaic' | 'deck' | 'config' | 'redirect' | 'stats' | 'home';
|
|
20
20
|
/** Per-page-type overrides. `true` keeps every default; `false` never registers it. */
|
|
21
21
|
export interface JunPageTypeOverride {
|
|
22
22
|
/** Display name in pickers, breadcrumbs and the type switcher. */
|
|
@@ -800,6 +800,21 @@ export interface JunMosaicOptions {
|
|
|
800
800
|
*/
|
|
801
801
|
maxDepth?: number;
|
|
802
802
|
}
|
|
803
|
+
/**
|
|
804
|
+
* The site's house style for its renderers — page-type KEY → option key →
|
|
805
|
+
* value, e.g. `{ library: { variant: 'grid', covers: true } }`.
|
|
806
|
+
*
|
|
807
|
+
* Read by `useJunViewOptions`, which resolves a page's display settings in three
|
|
808
|
+
* steps: the document's own `meta.junView`, then this, then the renderer's own
|
|
809
|
+
* default. A document that stores nothing follows whatever is set here, so
|
|
810
|
+
* changing a value later reaches every page that never disagreed with it.
|
|
811
|
+
*
|
|
812
|
+
* Deliberately loose: each renderer declares its own option keys next to the
|
|
813
|
+
* layout they drive, so a union of every valid key would have to be maintained
|
|
814
|
+
* here as well and would be wrong the moment a renderer gained an option.
|
|
815
|
+
* Unknown keys and out-of-range values are ignored rather than rendered.
|
|
816
|
+
*/
|
|
817
|
+
export type JunRendererDefaults = Record<string, Record<string, string | boolean | number>>;
|
|
803
818
|
/** Which external-service adapters the `services` page type may call. */
|
|
804
819
|
export interface JunServicesOptions {
|
|
805
820
|
/**
|
|
@@ -880,6 +895,11 @@ export interface JunRuntimeOptions {
|
|
|
880
895
|
mosaic: Required<JunMosaicOptions>;
|
|
881
896
|
/** Enabled service adapters + their cache TTL. See `JunServicesOptions`. */
|
|
882
897
|
services: Required<JunServicesOptions>;
|
|
898
|
+
/**
|
|
899
|
+
* Per-page-type display defaults — the site's house style, resolved under
|
|
900
|
+
* each document's own `meta.junView`. See `JunRendererDefaults`.
|
|
901
|
+
*/
|
|
902
|
+
renderers: JunRendererDefaults;
|
|
883
903
|
/** Clicking a node in a renderer: navigate to its page, or open the slideover. */
|
|
884
904
|
nodePanel: 'navigate' | 'slideover';
|
|
885
905
|
/** Which context-menu items exist. Resolved — every key filled. */
|
|
@@ -899,4 +919,40 @@ export interface JunRuntimeOptions {
|
|
|
899
919
|
* client-only and never runs for them.
|
|
900
920
|
*/
|
|
901
921
|
jsonLd: Record<string, JunJsonLdSpec>;
|
|
922
|
+
/**
|
|
923
|
+
* COLLECTION type id → how its unclaimed children present as pages.
|
|
924
|
+
*
|
|
925
|
+
* A Library row, a gear item, a CV station and a links row are all
|
|
926
|
+
* `type: 'doc'` children of a typed parent. They are reachable — every
|
|
927
|
+
* collection renderer links each row to its own page — and until this
|
|
928
|
+
* existed they rendered as a bare editor: no cover, no author, no rating,
|
|
929
|
+
* nothing the shelf above them displays.
|
|
930
|
+
*
|
|
931
|
+
* The presentation is derived from the PARENT rather than from a type on
|
|
932
|
+
* the child, and that is the whole design. Children are `doc` on every site
|
|
933
|
+
* that already exists, so a child-side type would have improved nothing
|
|
934
|
+
* without a migration — and it would have fought the rule that makes page
|
|
935
|
+
* types convertible in the first place: a collection renders every child,
|
|
936
|
+
* including one it did not create.
|
|
937
|
+
*
|
|
938
|
+
* A child with its OWN registered type (an `entry` under a journal, a
|
|
939
|
+
* `movie` under a cinema) is never overridden — it has a renderer already.
|
|
940
|
+
*/
|
|
941
|
+
itemParents: Record<string, JunItemPresentation>;
|
|
942
|
+
/**
|
|
943
|
+
* The registered type id the item renderer is mounted under. Internal: it
|
|
944
|
+
* is not a `JunPageTypeKey`, never appears in the type switcher, and is
|
|
945
|
+
* never written to a document — pages are handed it as a synthetic type at
|
|
946
|
+
* render time.
|
|
947
|
+
*/
|
|
948
|
+
itemType: string;
|
|
949
|
+
}
|
|
950
|
+
/** How one collection's unclaimed children render as their own pages. */
|
|
951
|
+
export interface JunItemPresentation {
|
|
952
|
+
/** Singular noun for the back-link and the type line — "Book", "Tool". */
|
|
953
|
+
label: string;
|
|
954
|
+
/** Lucide icon for the item, when the document has none of its own. */
|
|
955
|
+
icon: string;
|
|
956
|
+
/** Structured data for the item, built from the server cache like every other. */
|
|
957
|
+
jsonLd?: JunJsonLdSpec;
|
|
902
958
|
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The arithmetic behind `jun-course` — a page you get THROUGH.
|
|
3
|
+
*
|
|
4
|
+
* No Vue, no `#imports`, **no imports at all**: the server validates a step and
|
|
5
|
+
* writes progress, the page draws two progress figures from the same data, and a
|
|
6
|
+
* test runs both without a Nuxt app. The server and the page must never disagree
|
|
7
|
+
* about how far somebody is.
|
|
8
|
+
*
|
|
9
|
+
* ── Progress is per PERSON, and the server writes it ─────────────────────────
|
|
10
|
+
*
|
|
11
|
+
* A visitor has no CRDT write access, so ticking a step goes through RPC v1 and
|
|
12
|
+
* lands under the identity the SERVER stamped (`meta.courseProgress[from]`). The
|
|
13
|
+
* same rule as the poll's ballots, for a stronger reason: progress is a claim
|
|
14
|
+
* about a person, so a second tab, a reload and a reconnect are one learner.
|
|
15
|
+
*
|
|
16
|
+
* ── Two numbers, and they answer different questions ─────────────────────────
|
|
17
|
+
*
|
|
18
|
+
* **How far YOU are** is the one a learner came for. **How far the ROOM is** is
|
|
19
|
+
* the one only a live document can offer — "nine people have finished this, you
|
|
20
|
+
* are on step three" is a fact about a shared page, not a progress bar.
|
|
21
|
+
*
|
|
22
|
+
* ── What it must not do ──────────────────────────────────────────────────────
|
|
23
|
+
*
|
|
24
|
+
* **No gating.** `junNextStep` says where to go next; nothing here says a step may
|
|
25
|
+
* not be opened. The steps are pages with their own URLs on a public website, so a
|
|
26
|
+
* lock a reader walks around by typing a path is theatre — and a lock that worked
|
|
27
|
+
* would mean hiding documents from the tree, which breaks search, the feed and the
|
|
28
|
+
* sitemap.
|
|
29
|
+
*/
|
|
30
|
+
/** How many people's progress one course may hold. */
|
|
31
|
+
export declare const JUN_COURSE_MAX_PEOPLE = 5000;
|
|
32
|
+
/** How many steps one person's progress may name. */
|
|
33
|
+
export declare const JUN_COURSE_MAX_STEPS = 200;
|
|
34
|
+
export interface JunCourseStepInput {
|
|
35
|
+
id: string;
|
|
36
|
+
label?: string;
|
|
37
|
+
order?: number;
|
|
38
|
+
trashed?: boolean;
|
|
39
|
+
meta?: Record<string, unknown> | null;
|
|
40
|
+
}
|
|
41
|
+
export interface JunCourseStep {
|
|
42
|
+
id: string;
|
|
43
|
+
label: string;
|
|
44
|
+
/** 1-based, for display — a step called "0" reads as an error. */
|
|
45
|
+
number: number;
|
|
46
|
+
done: boolean;
|
|
47
|
+
/** How many people have finished this one. */
|
|
48
|
+
finishedBy: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The steps, in the owner's order.
|
|
52
|
+
*
|
|
53
|
+
* Trashed children drop out; a child with no label is still a step (an owner mid
|
|
54
|
+
* -typing must not see the list renumber itself), and hidden ones stay, because
|
|
55
|
+
* `meta.hidden` means "not in navigation" and never "not there".
|
|
56
|
+
*/
|
|
57
|
+
export declare function junCourseSteps(children: JunCourseStepInput[]): JunCourseStepInput[];
|
|
58
|
+
/**
|
|
59
|
+
* `meta.courseProgress`, validated.
|
|
60
|
+
*
|
|
61
|
+
* Every layer is checked because this is stored data a newer build may have
|
|
62
|
+
* written: a non-object, a non-array value, a non-string step id and a step that
|
|
63
|
+
* is not in this course are all dropped rather than counted. An uncounted step
|
|
64
|
+
* would inflate somebody's progress past 100%.
|
|
65
|
+
*/
|
|
66
|
+
export declare function junCourseProgress(meta: Record<string, unknown> | null | undefined, stepIds: string[]): Record<string, string[]>;
|
|
67
|
+
export interface JunCourseView {
|
|
68
|
+
steps: JunCourseStep[];
|
|
69
|
+
/** Steps this person has finished. */
|
|
70
|
+
done: number;
|
|
71
|
+
total: number;
|
|
72
|
+
/** 0–100, rounded. 100 only when every step is done. */
|
|
73
|
+
percent: number;
|
|
74
|
+
/** The first unfinished step, or `null` when there are none left. */
|
|
75
|
+
next: JunCourseStep | null;
|
|
76
|
+
/** People who have finished at least one step. */
|
|
77
|
+
people: number;
|
|
78
|
+
/** People who have finished every step. */
|
|
79
|
+
finished: number;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Everything a course page draws, from the steps and the stored progress.
|
|
83
|
+
*
|
|
84
|
+
* One function rather than six, because the figures have to be consistent with
|
|
85
|
+
* each other: a bar at 100% beside a "continue" button pointing at step three is
|
|
86
|
+
* the failure this shape makes impossible.
|
|
87
|
+
*/
|
|
88
|
+
export declare function junCourseView(children: JunCourseStepInput[], meta: Record<string, unknown> | null | undefined, selfId: string | null | undefined): JunCourseView;
|
|
89
|
+
/**
|
|
90
|
+
* One person's next progress list after ticking a step.
|
|
91
|
+
*
|
|
92
|
+
* Returns `null` to REFUSE — an unknown step id, which is the server's check as
|
|
93
|
+
* well as the page's. Ticking is a toggle: a learner who marked a step by mistake
|
|
94
|
+
* must be able to unmark it, and a course that only counts up is a course people
|
|
95
|
+
* stop trusting.
|
|
96
|
+
*/
|
|
97
|
+
export declare function junNextProgress(current: string[] | undefined, stepIds: string[], stepId: string): string[] | null;
|
|
98
|
+
/**
|
|
99
|
+
* Cap the number of PEOPLE a course remembers.
|
|
100
|
+
*
|
|
101
|
+
* Unbounded growth in one document's meta is the hazard the poll's ballots have
|
|
102
|
+
* too: every visitor's progress lives in the course's own entry, which every
|
|
103
|
+
* client syncs. Past the cap, new people are not recorded — their progress still
|
|
104
|
+
* works for the session, and the alternative (dropping somebody else's) is worse.
|
|
105
|
+
*/
|
|
106
|
+
export declare function junCapProgress(progress: Record<string, string[]>, person: string, max?: number): boolean;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export const JUN_COURSE_MAX_PEOPLE = 5e3;
|
|
2
|
+
export const JUN_COURSE_MAX_STEPS = 200;
|
|
3
|
+
export function junCourseSteps(children) {
|
|
4
|
+
return children.filter((child) => !!child?.id && !child.trashed).slice().sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
5
|
+
}
|
|
6
|
+
export function junCourseProgress(meta, stepIds) {
|
|
7
|
+
const raw = meta?.courseProgress;
|
|
8
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
9
|
+
const known = new Set(stepIds);
|
|
10
|
+
const out = {};
|
|
11
|
+
for (const [person, value] of Object.entries(raw)) {
|
|
12
|
+
if (!person || !Array.isArray(value)) continue;
|
|
13
|
+
const seen = /* @__PURE__ */ new Set();
|
|
14
|
+
for (const id of value) {
|
|
15
|
+
if (typeof id !== "string" || !known.has(id) || seen.has(id)) continue;
|
|
16
|
+
seen.add(id);
|
|
17
|
+
if (seen.size >= JUN_COURSE_MAX_STEPS) break;
|
|
18
|
+
}
|
|
19
|
+
if (seen.size) out[person] = [...seen];
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
export function junCourseView(children, meta, selfId) {
|
|
24
|
+
const ordered = junCourseSteps(children);
|
|
25
|
+
const ids = ordered.map((step) => step.id);
|
|
26
|
+
const progress = junCourseProgress(meta, ids);
|
|
27
|
+
const mine = new Set(selfId ? progress[selfId] ?? [] : []);
|
|
28
|
+
const finishedBy = /* @__PURE__ */ new Map();
|
|
29
|
+
let finished = 0;
|
|
30
|
+
for (const list of Object.values(progress)) {
|
|
31
|
+
for (const id of list) finishedBy.set(id, (finishedBy.get(id) ?? 0) + 1);
|
|
32
|
+
if (ids.length > 0 && list.length === ids.length) finished++;
|
|
33
|
+
}
|
|
34
|
+
const steps = ordered.map((step, i) => ({
|
|
35
|
+
id: step.id,
|
|
36
|
+
label: (step.label ?? "").trim() || `Step ${i + 1}`,
|
|
37
|
+
number: i + 1,
|
|
38
|
+
done: mine.has(step.id),
|
|
39
|
+
finishedBy: finishedBy.get(step.id) ?? 0
|
|
40
|
+
}));
|
|
41
|
+
const done = steps.filter((step) => step.done).length;
|
|
42
|
+
const total = steps.length;
|
|
43
|
+
return {
|
|
44
|
+
steps,
|
|
45
|
+
done,
|
|
46
|
+
total,
|
|
47
|
+
// Rounded, but never 99 for a finished course and never 100 for an unfinished
|
|
48
|
+
// one: `Math.round` alone would report 100% at 199 of 200 steps.
|
|
49
|
+
percent: total === 0 ? 0 : done === total ? 100 : Math.min(99, Math.round(done / total * 100)),
|
|
50
|
+
next: steps.find((step) => !step.done) ?? null,
|
|
51
|
+
people: Object.keys(progress).length,
|
|
52
|
+
finished
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function junNextProgress(current, stepIds, stepId) {
|
|
56
|
+
if (!stepIds.includes(stepId)) return null;
|
|
57
|
+
const seen = new Set((current ?? []).filter((id) => stepIds.includes(id)));
|
|
58
|
+
if (seen.has(stepId)) seen.delete(stepId);
|
|
59
|
+
else if (seen.size >= JUN_COURSE_MAX_STEPS) return null;
|
|
60
|
+
else seen.add(stepId);
|
|
61
|
+
return stepIds.filter((id) => seen.has(id));
|
|
62
|
+
}
|
|
63
|
+
export function junCapProgress(progress, person, max = JUN_COURSE_MAX_PEOPLE) {
|
|
64
|
+
return person in progress || Object.keys(progress).length < max;
|
|
65
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The arithmetic behind `jun-garden` — a document tree read as a graph.
|
|
3
|
+
*
|
|
4
|
+
* No Vue, no `#imports`, **no imports at all**: the endpoint builds the edges in
|
|
5
|
+
* Nitro, the renderer draws them in a browser, and a test runs both without a
|
|
6
|
+
* Nuxt app anywhere. Three things live here.
|
|
7
|
+
*
|
|
8
|
+
* ── 1. Two kinds of link, and the second one is the common case ──────────────
|
|
9
|
+
*
|
|
10
|
+
* The platform has a wiki-style reference: `[[doc]]` in the editor becomes a link
|
|
11
|
+
* to `/doc/<id>` (or a `docLink` / `docEmbed` node carrying `data-doc-id`). That
|
|
12
|
+
* is the one a graph view is obviously supposed to follow.
|
|
13
|
+
*
|
|
14
|
+
* It is not the one people write. Somebody linking one note to another usually
|
|
15
|
+
* writes an ordinary link to the other page's PATH, because that is what a link
|
|
16
|
+
* is. A garden that understood only its own syntax would show an empty graph on a
|
|
17
|
+
* site full of cross-references — so a path resolves too, through the slug map
|
|
18
|
+
* the site already keeps for routing.
|
|
19
|
+
*
|
|
20
|
+
* An external link is not an edge, and neither is a path this site does not have:
|
|
21
|
+
* a graph must not invent a node for `/notes/something-i-never-wrote`.
|
|
22
|
+
*
|
|
23
|
+
* ── 2. Maturity is a claim, and an unstated one is not `seedling` ────────────
|
|
24
|
+
*
|
|
25
|
+
* `junMaturityOf` returns **null** for a note whose author never said. Defaulting
|
|
26
|
+
* to `seedling` would print a judgement on every page that predates the setting —
|
|
27
|
+
* the site would appear to claim that a decade of tended writing is rough drafts.
|
|
28
|
+
*
|
|
29
|
+
* ── 3. The layout has to be deterministic ────────────────────────────────────
|
|
30
|
+
*
|
|
31
|
+
* The same graph is drawn during SSR and again after hydration. A force layout
|
|
32
|
+
* seeded from `Math.random()` is therefore a hydration mismatch BY CONSTRUCTION —
|
|
33
|
+
* every node in a different place on the client than the server sent. So: fixed
|
|
34
|
+
* starting positions, a fixed iteration count, no randomness anywhere, and the
|
|
35
|
+
* same input gives the same picture on both sides and in a test.
|
|
36
|
+
*/
|
|
37
|
+
export type JunMaturity = 'seedling' | 'budding' | 'evergreen';
|
|
38
|
+
/**
|
|
39
|
+
* The three states, in growing order — the ONE copy. The leaf page's `select`
|
|
40
|
+
* control, the garden's badges and its filter all read this list, and a fourth
|
|
41
|
+
* state added in two of the three places is how a note becomes unfilterable.
|
|
42
|
+
*/
|
|
43
|
+
export declare const JUN_MATURITIES: readonly [{
|
|
44
|
+
readonly value: "seedling";
|
|
45
|
+
readonly label: "Seedling";
|
|
46
|
+
readonly icon: "i-lucide-sprout";
|
|
47
|
+
readonly hint: "Rough, and says so";
|
|
48
|
+
}, {
|
|
49
|
+
readonly value: "budding";
|
|
50
|
+
readonly label: "Budding";
|
|
51
|
+
readonly icon: "i-lucide-flower-2";
|
|
52
|
+
readonly hint: "Taking shape";
|
|
53
|
+
}, {
|
|
54
|
+
readonly value: "evergreen";
|
|
55
|
+
readonly label: "Evergreen";
|
|
56
|
+
readonly icon: "i-lucide-trees";
|
|
57
|
+
readonly hint: "Tended, and holds up";
|
|
58
|
+
}];
|
|
59
|
+
/**
|
|
60
|
+
* A note's stated maturity, or `null` when its author never stated one.
|
|
61
|
+
*
|
|
62
|
+
* An unknown value — written by a newer build with a fourth state — reads as
|
|
63
|
+
* unstated rather than rendering a badge with no label, the same rule every view
|
|
64
|
+
* option here follows.
|
|
65
|
+
*/
|
|
66
|
+
export declare function junMaturityOf(meta: Record<string, unknown> | undefined | null): JunMaturity | null;
|
|
67
|
+
/**
|
|
68
|
+
* Every link target in a rendered body, in document order, duplicates included.
|
|
69
|
+
*
|
|
70
|
+
* Both shapes: an `<a href>` (which is what a `[[doc]]` reference and an ordinary
|
|
71
|
+
* internal link both become) and a `data-doc-id` attribute (which is what an
|
|
72
|
+
* embed node renders as). Duplicates are kept — how MANY times one note points at
|
|
73
|
+
* another is a real quantity, and de-duplication is the edge builder's job.
|
|
74
|
+
*/
|
|
75
|
+
export declare function junScanLinkTargets(html: string | null | undefined): string[];
|
|
76
|
+
/**
|
|
77
|
+
* Resolve one link target to a document id in THIS site, or `null`.
|
|
78
|
+
*
|
|
79
|
+
* `null` covers four separate cases on purpose, because all four mean "not an
|
|
80
|
+
* edge": an external URL, an in-page anchor, a `/doc/<id>` for a document this
|
|
81
|
+
* site does not have, and a path that resolves to nothing. A graph that guessed
|
|
82
|
+
* on any of them would draw a node for a page that does not exist.
|
|
83
|
+
*/
|
|
84
|
+
export declare function junResolveLinkTarget(target: string, slugToId: Record<string, string>, knownIds: ReadonlySet<string>): string | null;
|
|
85
|
+
export interface JunGardenEdge {
|
|
86
|
+
source: string;
|
|
87
|
+
target: string;
|
|
88
|
+
/** How many links point that way. A note cited three times is not cited once. */
|
|
89
|
+
weight: number;
|
|
90
|
+
}
|
|
91
|
+
export interface JunGardenSource {
|
|
92
|
+
id: string;
|
|
93
|
+
/** The rendered body, as the doc cache holds it. */
|
|
94
|
+
html?: string | null;
|
|
95
|
+
/** Already-scanned targets, for a caller that has them (the live client). */
|
|
96
|
+
targets?: string[];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Every edge in the site, deduplicated and weighted.
|
|
100
|
+
*
|
|
101
|
+
* A self-link is dropped: a note that mentions its own path is not connected to
|
|
102
|
+
* itself, and drawing that would put a loop on the busiest node on every site
|
|
103
|
+
* with a "back to the top" link.
|
|
104
|
+
*/
|
|
105
|
+
export declare function junGardenEdges(sources: JunGardenSource[], slugToId: Record<string, string>, knownIds: ReadonlySet<string>): JunGardenEdge[];
|
|
106
|
+
export interface JunGardenEntryInput {
|
|
107
|
+
id: string;
|
|
108
|
+
label?: string;
|
|
109
|
+
href?: string;
|
|
110
|
+
type?: string;
|
|
111
|
+
updatedAt?: number;
|
|
112
|
+
createdAt?: number;
|
|
113
|
+
meta?: Record<string, unknown> | null;
|
|
114
|
+
}
|
|
115
|
+
export interface JunGardenRef {
|
|
116
|
+
id: string;
|
|
117
|
+
label: string;
|
|
118
|
+
href?: string;
|
|
119
|
+
weight: number;
|
|
120
|
+
}
|
|
121
|
+
export interface JunGardenNote {
|
|
122
|
+
id: string;
|
|
123
|
+
label: string;
|
|
124
|
+
href?: string;
|
|
125
|
+
type?: string;
|
|
126
|
+
maturity: JunMaturity | null;
|
|
127
|
+
updatedAt: number;
|
|
128
|
+
/** What points HERE — the thing a garden owner opens the page for. */
|
|
129
|
+
inbound: JunGardenRef[];
|
|
130
|
+
/** What this note points at. */
|
|
131
|
+
outbound: JunGardenRef[];
|
|
132
|
+
/** Both directions, which is what the graph draws a node's size from. */
|
|
133
|
+
degree: number;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Shape the graph into notes.
|
|
137
|
+
*
|
|
138
|
+
* `scope` is which documents the garden OWNS — its own notes. Inbound links are
|
|
139
|
+
* resolved against every entry in the site, because a note being cited from
|
|
140
|
+
* outside the garden is still a citation, and a garden that only counted its own
|
|
141
|
+
* children would call a widely-linked note an orphan.
|
|
142
|
+
*/
|
|
143
|
+
export declare function junGardenNotes(entries: JunGardenEntryInput[], edges: JunGardenEdge[], scope: ReadonlySet<string>): JunGardenNote[];
|
|
144
|
+
/**
|
|
145
|
+
* The notes nothing points at.
|
|
146
|
+
*
|
|
147
|
+
* Outbound links do not save a note from this list — a page that links out and is
|
|
148
|
+
* never linked to is exactly the page an owner has lost track of, which is the
|
|
149
|
+
* one question a garden exists to answer.
|
|
150
|
+
*/
|
|
151
|
+
export declare function junGardenOrphans(notes: JunGardenNote[]): JunGardenNote[];
|
|
152
|
+
export type JunGardenSort = 'links' | 'recent' | 'alpha';
|
|
153
|
+
/** Order the notes. Ties break on the label, so the list never shuffles. */
|
|
154
|
+
export declare function junGardenSort(notes: JunGardenNote[], key: JunGardenSort): JunGardenNote[];
|
|
155
|
+
/** The one-line summary above the graph. */
|
|
156
|
+
export declare function junGardenCounts(notes: JunGardenNote[]): {
|
|
157
|
+
notes: number;
|
|
158
|
+
links: number;
|
|
159
|
+
orphans: number;
|
|
160
|
+
evergreen: number;
|
|
161
|
+
};
|
|
162
|
+
export interface JunGardenPoint {
|
|
163
|
+
id: string;
|
|
164
|
+
x: number;
|
|
165
|
+
y: number;
|
|
166
|
+
}
|
|
167
|
+
export interface JunGardenLayoutOptions {
|
|
168
|
+
width?: number;
|
|
169
|
+
height?: number;
|
|
170
|
+
/** Ideal edge length, as a multiple of the natural spacing. */
|
|
171
|
+
spread?: number;
|
|
172
|
+
/** Fixed, and part of the contract: the count is what makes this repeatable. */
|
|
173
|
+
iterations?: number;
|
|
174
|
+
padding?: number;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A force-directed layout, hand-rolled and deterministic.
|
|
178
|
+
*
|
|
179
|
+
* Fruchterman-Reingold: every pair of nodes repels, every edge attracts, and a
|
|
180
|
+
* cooling schedule stops the whole thing oscillating. ~60 lines, which is why
|
|
181
|
+
* this is written here rather than taken as a dependency — `d3-force` is a
|
|
182
|
+
* playground dependency and must stay one, the same way this repo writes its own
|
|
183
|
+
* rasteriser and its own TOML reader.
|
|
184
|
+
*
|
|
185
|
+
* **Nothing random.** Starting positions come off a golden-angle spiral (an even
|
|
186
|
+
* spread with no clumps to unstick) and the iteration count is fixed, so the
|
|
187
|
+
* server and the client draw the same picture and a test can assert positions.
|
|
188
|
+
*
|
|
189
|
+
* Coincident nodes are nudged apart by a value derived from their INDEX rather
|
|
190
|
+
* than a random jitter: two nodes at the same point produce a zero-length vector,
|
|
191
|
+
* and dividing by it is how a layout fills with `NaN` and paints nothing.
|
|
192
|
+
*/
|
|
193
|
+
export declare function junGardenLayout(ids: string[], edges: JunGardenEdge[], options?: JunGardenLayoutOptions): JunGardenPoint[];
|