@abraca/junis 2.84.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 +270 -22
- package/dist/runtime/assets/css/jun.css +1 -1
- package/dist/runtime/components/JunBlobBackdrop.client.vue +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/JunHead.vue +37 -5
- 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/JunLogo.vue +10 -45
- 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/JunPatternBackdrop.client.vue +1 -1
- 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/JunShaderBackdrop.client.vue +1 -1
- 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 +362 -239
- 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 +157 -31
- package/dist/runtime/components/renderers/JunFestivalRenderer.vue +42 -5
- 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 +31 -132
- 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 +38 -2
- 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 +40 -7
- 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 +57 -13
- 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/useJunOptions.d.ts +1 -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 +49 -50
- 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/plugins/jun-sw.client.d.ts +2 -0
- package/dist/runtime/plugins/jun-sw.client.js +36 -0
- 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 +9 -1
- 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/jun-icon.png.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-icon.png.get.js +25 -0
- package/dist/runtime/server/routes/jun-icon.svg.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-icon.svg.get.js +9 -0
- package/dist/runtime/server/routes/jun-splash.png.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-splash.png.get.js +37 -0
- package/dist/runtime/server/routes/jun-sw.js.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-sw.js.get.js +126 -0
- package/dist/runtime/server/routes/manifest.webmanifest.get.d.ts +24 -0
- package/dist/runtime/server/routes/manifest.webmanifest.get.js +51 -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/junBrand.d.ts +4 -0
- package/dist/runtime/server/utils/junBrand.js +9 -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/junIcon.d.ts +44 -0
- package/dist/runtime/server/utils/junIcon.js +374 -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 +82 -3
- 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/junIdentity.d.ts +121 -0
- package/dist/runtime/utils/junIdentity.js +115 -0
- package/dist/runtime/utils/junMark.d.ts +254 -0
- package/dist/runtime/utils/junMark.js +169 -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,37 @@
|
|
|
1
|
+
import { defineCachedEventHandler } from "nitropack/runtime";
|
|
2
|
+
import { junDocHtml, junDocTree, junRootDocId, junSlugMap } from "../utils/junCache.js";
|
|
3
|
+
import { isJunOwnerOnlyDoc } from "../utils/junVisibility.js";
|
|
4
|
+
import { junGardenEdges, junMaturityOf } from "../../utils/junGarden.js";
|
|
5
|
+
export default defineCachedEventHandler(async () => {
|
|
6
|
+
const rootDocId = junRootDocId();
|
|
7
|
+
const [tree, idToSlug] = await Promise.all([junDocTree(), junSlugMap()]);
|
|
8
|
+
const nodes = [];
|
|
9
|
+
const slugToId = {};
|
|
10
|
+
const knownIds = /* @__PURE__ */ new Set();
|
|
11
|
+
for (const [id, entry] of Object.entries(tree)) {
|
|
12
|
+
if (!entry || entry.trashed) continue;
|
|
13
|
+
if (id === rootDocId || isJunOwnerOnlyDoc(entry)) continue;
|
|
14
|
+
const slug = idToSlug[id];
|
|
15
|
+
knownIds.add(id);
|
|
16
|
+
if (slug) slugToId[slug.toLowerCase()] = id;
|
|
17
|
+
nodes.push({
|
|
18
|
+
id,
|
|
19
|
+
label: entry.label ?? "",
|
|
20
|
+
href: `/${slug ?? id}`,
|
|
21
|
+
type: entry.type ?? "doc",
|
|
22
|
+
parentId: entry.parentId ?? null,
|
|
23
|
+
updatedAt: typeof entry.updatedAt === "number" ? entry.updatedAt : entry.createdAt ?? 0,
|
|
24
|
+
maturity: junMaturityOf(entry.meta)
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const bodies = await Promise.all(
|
|
28
|
+
nodes.map(async (node) => ({ id: node.id, html: await junDocHtml(node.id) }))
|
|
29
|
+
);
|
|
30
|
+
const scanned = bodies.filter((b) => b.html).length;
|
|
31
|
+
return {
|
|
32
|
+
nodes,
|
|
33
|
+
edges: junGardenEdges(bodies, slugToId, knownIds),
|
|
34
|
+
scanned,
|
|
35
|
+
generatedAt: Date.now()
|
|
36
|
+
};
|
|
37
|
+
}, { maxAge: 60, swr: true, name: "jun-links", getKey: () => "graph" });
|
|
@@ -8,6 +8,9 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
|
|
|
8
8
|
title?: undefined;
|
|
9
9
|
meta?: undefined;
|
|
10
10
|
html?: undefined;
|
|
11
|
+
parentId?: undefined;
|
|
12
|
+
parentType?: undefined;
|
|
13
|
+
parentTitle?: undefined;
|
|
11
14
|
} | {
|
|
12
15
|
found: true;
|
|
13
16
|
cacheReady: boolean;
|
|
@@ -18,6 +21,9 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
|
|
|
18
21
|
title: null;
|
|
19
22
|
meta: {};
|
|
20
23
|
html: null;
|
|
24
|
+
parentId?: undefined;
|
|
25
|
+
parentType?: undefined;
|
|
26
|
+
parentTitle?: undefined;
|
|
21
27
|
} | {
|
|
22
28
|
found: true;
|
|
23
29
|
cacheReady: boolean;
|
|
@@ -26,6 +32,9 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
|
|
|
26
32
|
title: string | null;
|
|
27
33
|
type: string;
|
|
28
34
|
meta: Record<string, unknown>;
|
|
35
|
+
parentId: string | null;
|
|
36
|
+
parentType: string | null;
|
|
37
|
+
parentTitle: string | null;
|
|
29
38
|
html: string | null;
|
|
30
39
|
ownerOnly?: undefined;
|
|
31
40
|
}>>;
|
|
@@ -29,6 +29,8 @@ export default defineEventHandler(async (event) => {
|
|
|
29
29
|
html: null
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
const parentId = entry?.parentId ?? null;
|
|
33
|
+
const parent = parentId ? tree[parentId] : void 0;
|
|
32
34
|
return {
|
|
33
35
|
found: true,
|
|
34
36
|
cacheReady,
|
|
@@ -37,6 +39,9 @@ export default defineEventHandler(async (event) => {
|
|
|
37
39
|
title: entry?.label ?? null,
|
|
38
40
|
type: entry?.type ?? "doc",
|
|
39
41
|
meta: entry?.meta ?? {},
|
|
42
|
+
parentId,
|
|
43
|
+
parentType: parent?.type ?? null,
|
|
44
|
+
parentTitle: parent?.label ?? null,
|
|
40
45
|
html: await junDocHtml(docId)
|
|
41
46
|
};
|
|
42
47
|
});
|
|
@@ -2,6 +2,7 @@ import { defineCachedEventHandler, useRuntimeConfig, useStorage } from "nitropac
|
|
|
2
2
|
import { junCountedDocIds, junDocTree, junRootDocId } from "../utils/junCache.js";
|
|
3
3
|
import { junReadActivity } from "../utils/junActivity.js";
|
|
4
4
|
import { junActivitySeries, junCountWords } from "../utils/junActivityMath.js";
|
|
5
|
+
import { junIsVisibleMessage } from "../../utils/junModeration.js";
|
|
5
6
|
export default defineCachedEventHandler(async () => {
|
|
6
7
|
const jun = useRuntimeConfig().public.jun;
|
|
7
8
|
const types = jun?.typeIds ?? {};
|
|
@@ -26,7 +27,7 @@ export default defineCachedEventHandler(async () => {
|
|
|
26
27
|
if (entry.type) byType[entry.type] = (byType[entry.type] ?? 0) + 1;
|
|
27
28
|
const parent = entry.parentId ? counted[entry.parentId] ?? tree[entry.parentId] : void 0;
|
|
28
29
|
if (types.wall && parent?.type === types.wall && entry.meta?.coverUploadId) photos++;
|
|
29
|
-
if (types.guestbook && parent?.type === types.guestbook &&
|
|
30
|
+
if (types.guestbook && parent?.type === types.guestbook && junIsVisibleMessage(entry.meta)) {
|
|
30
31
|
signatures++;
|
|
31
32
|
}
|
|
32
33
|
if (Array.isArray(entry.meta?.appreciatedBy)) appreciations += entry.meta.appreciatedBy.length;
|
|
@@ -20,6 +20,14 @@ export const JUN_CHORE_POLICY_DEFAULT = {
|
|
|
20
20
|
// hides it, or out of one.
|
|
21
21
|
metaIgnore: [
|
|
22
22
|
"appreciatedBy",
|
|
23
|
+
// Visitor-contributed, exactly like `appreciatedBy` above, and the same
|
|
24
|
+
// reasoning applies: reverting these to a baseline would DELETE real votes and
|
|
25
|
+
// real progress — people who took part, silently un-taken-part. They also
|
|
26
|
+
// predate this list by a round each, which is how a demo's janitor quietly
|
|
27
|
+
// erased its own poll. Anything the RPC runner writes on a visitor's behalf
|
|
28
|
+
// belongs here the moment it is invented.
|
|
29
|
+
"pollVotes",
|
|
30
|
+
"courseProgress",
|
|
23
31
|
"slugAliases",
|
|
24
32
|
"createdAt",
|
|
25
33
|
"updatedAt",
|
|
@@ -2,10 +2,11 @@ import * as Y from "yjs";
|
|
|
2
2
|
import { AbracadabraProvider } from "@abraca/dabra";
|
|
3
3
|
import { markdownToFragmentNodes } from "@abraca/convert";
|
|
4
4
|
import { defineNitroPlugin, useRuntimeConfig } from "nitropack/runtime";
|
|
5
|
+
import { junSeedFinished, junSeedStarted } from "../utils/junSeedGate.js";
|
|
5
6
|
const BOOT_DELAY_MS = 4e3;
|
|
6
7
|
const SYNC_TIMEOUT_MS = 1e4;
|
|
7
8
|
const ECHO_TIMEOUT_MS = 8e3;
|
|
8
|
-
const BODY_CONCURRENCY =
|
|
9
|
+
const BODY_CONCURRENCY = 8;
|
|
9
10
|
const BODY_FLUSH_MS = 400;
|
|
10
11
|
function plain(e) {
|
|
11
12
|
if (!e) return void 0;
|
|
@@ -128,7 +129,8 @@ function defaultTree(typeIds) {
|
|
|
128
129
|
{
|
|
129
130
|
label: "Something in progress",
|
|
130
131
|
type: typeIds.app ?? "doc",
|
|
131
|
-
meta: { status: "building", description: "Tiles reorder by dragging \u2014 their order is stored." }
|
|
132
|
+
meta: { status: "building", description: "Tiles reorder by dragging \u2014 their order is stored." },
|
|
133
|
+
body: "Tiles reorder by dragging, and the order is stored on the documents \u2014 so everyone sees the same arrangement rather than a per-browser one."
|
|
132
134
|
}
|
|
133
135
|
]
|
|
134
136
|
});
|
|
@@ -148,7 +150,8 @@ function defaultTree(typeIds) {
|
|
|
148
150
|
place: "Everywhere",
|
|
149
151
|
description: 'An open end reads as "now" \u2014 leave it blank while something is ongoing.',
|
|
150
152
|
icon: "sprout"
|
|
151
|
-
}
|
|
153
|
+
},
|
|
154
|
+
body: "A station is a document, so it holds as much as you want to write about it. This one has no end date, which is how the timeline draws it as ongoing."
|
|
152
155
|
},
|
|
153
156
|
{
|
|
154
157
|
label: "Something earlier",
|
|
@@ -158,7 +161,8 @@ function defaultTree(typeIds) {
|
|
|
158
161
|
end: "2021",
|
|
159
162
|
place: "Elsewhere",
|
|
160
163
|
description: "A bare year is fine. Stations sort newest first by their start."
|
|
161
|
-
}
|
|
164
|
+
},
|
|
165
|
+
body: "Stations sort by their start date, newest first. A bare year is enough \u2014 and a station with no dates at all sorts last rather than being dropped, which is the rule every collection here follows."
|
|
162
166
|
}
|
|
163
167
|
]
|
|
164
168
|
});
|
|
@@ -177,7 +181,8 @@ function defaultTree(typeIds) {
|
|
|
177
181
|
url: "https://github.com/abracadabra",
|
|
178
182
|
icon: "github",
|
|
179
183
|
description: "The platform this site is built on."
|
|
180
|
-
}
|
|
184
|
+
},
|
|
185
|
+
body: "A links row is a document too, so it can carry a note about why the link is here. Rows with a destination open outward; the page behind them is still indexed and still yours to write."
|
|
181
186
|
},
|
|
182
187
|
{
|
|
183
188
|
// No url on purpose: a row without one links to its own page, which
|
|
@@ -187,7 +192,8 @@ function defaultTree(typeIds) {
|
|
|
187
192
|
meta: {
|
|
188
193
|
icon: "file-text",
|
|
189
194
|
description: "No URL, so this row opens its own page instead."
|
|
190
|
-
}
|
|
195
|
+
},
|
|
196
|
+
body: "No `url`, so this row opens its own page rather than pointing outward. Add one from the editor and it starts leaving the site \u2014 which is how a note grows into a link, or the other way round."
|
|
191
197
|
}
|
|
192
198
|
]
|
|
193
199
|
});
|
|
@@ -202,19 +208,22 @@ function defaultTree(typeIds) {
|
|
|
202
208
|
{
|
|
203
209
|
label: "A laptop",
|
|
204
210
|
type: "doc",
|
|
205
|
-
meta: { category: "Hardware", icon: "laptop", description: "Sections come from the page's own meta.categories." }
|
|
211
|
+
meta: { category: "Hardware", icon: "laptop", description: "Sections come from the page's own meta.categories." },
|
|
212
|
+
body: "Sections on the Uses page come from that page's own `categories` metadata, not from code \u2014 so the headings are yours to name."
|
|
206
213
|
},
|
|
207
214
|
{
|
|
208
215
|
label: "An editor",
|
|
209
216
|
type: "doc",
|
|
210
|
-
meta: { category: "Software", icon: "code", description: "Change an item's category and it moves section." }
|
|
217
|
+
meta: { category: "Software", icon: "code", description: "Change an item's category and it moves section." },
|
|
218
|
+
body: "Change this item's category and it moves section, live, for everyone reading the page. The move is one write; nothing is duplicated and nothing is deleted."
|
|
211
219
|
},
|
|
212
220
|
{
|
|
213
221
|
// No category on purpose: it must surface under "Other" rather than
|
|
214
222
|
// vanish, which is the rule that makes page types convertible.
|
|
215
223
|
label: "Something uncategorised",
|
|
216
224
|
type: "doc",
|
|
217
|
-
meta: { icon: "box", description: 'No category \u2014 shows under "Other".' }
|
|
225
|
+
meta: { icon: "box", description: 'No category \u2014 shows under "Other".' },
|
|
226
|
+
body: "No category at all, so it shows under **Other** rather than vanishing. Every collection here tolerates a child it did not expect \u2014 that is what makes changing a page's type safe."
|
|
218
227
|
}
|
|
219
228
|
]
|
|
220
229
|
});
|
|
@@ -229,14 +238,21 @@ function defaultTree(typeIds) {
|
|
|
229
238
|
{
|
|
230
239
|
label: "Something being read",
|
|
231
240
|
type: "doc",
|
|
232
|
-
meta: { status: "reading", author: "An author", rating: 4 }
|
|
241
|
+
meta: { status: "reading", author: "An author", rating: 4 },
|
|
242
|
+
body: "Books are child documents shelved by one metadata field. Open one and you get a page of its own \u2014 the place for a note about what it changed."
|
|
233
243
|
},
|
|
234
244
|
{
|
|
235
245
|
label: "Something finished",
|
|
236
246
|
type: "doc",
|
|
237
|
-
meta: { status: "read", author: "Another author", rating: 5 }
|
|
247
|
+
meta: { status: "read", author: "Another author", rating: 5 },
|
|
248
|
+
body: "Drag a book between shelves to change its status. That is a single write, and it is live for everyone reading the page."
|
|
238
249
|
},
|
|
239
|
-
{
|
|
250
|
+
{
|
|
251
|
+
label: "Something next",
|
|
252
|
+
type: "doc",
|
|
253
|
+
meta: { status: "want" },
|
|
254
|
+
body: 'Nothing has been read here yet. A book with no status at all shelves under "Up next" \u2014 the state a book starts in \u2014 rather than needing one set before it can appear.'
|
|
255
|
+
}
|
|
240
256
|
]
|
|
241
257
|
});
|
|
242
258
|
}
|
|
@@ -436,12 +452,16 @@ export default defineNitroPlugin((nitroApp) => {
|
|
|
436
452
|
{
|
|
437
453
|
name: "jun:bootstrap",
|
|
438
454
|
start(ctx) {
|
|
455
|
+
junSeedStarted();
|
|
439
456
|
const timer = setTimeout(() => {
|
|
440
457
|
void bootstrap(ctx, seed).catch((err) => {
|
|
441
458
|
console.warn("[jun:bootstrap] failed:", err?.message ?? err);
|
|
442
|
-
});
|
|
459
|
+
}).finally(() => junSeedFinished());
|
|
443
460
|
}, BOOT_DELAY_MS);
|
|
444
|
-
return () =>
|
|
461
|
+
return () => {
|
|
462
|
+
clearTimeout(timer);
|
|
463
|
+
junSeedFinished();
|
|
464
|
+
};
|
|
445
465
|
}
|
|
446
466
|
}
|
|
447
467
|
]
|
|
@@ -488,6 +508,7 @@ async function bootstrap(ctx, seed) {
|
|
|
488
508
|
if (hasContent) {
|
|
489
509
|
console.log("[jun:bootstrap] root already has content \u2014 skipping seed");
|
|
490
510
|
repairIconFormat(ydoc, tree);
|
|
511
|
+
if (backfillRequested()) await backfillBodies(ctx, tree, rootId, nodes);
|
|
491
512
|
return;
|
|
492
513
|
}
|
|
493
514
|
console.log("[jun:bootstrap] empty root \u2014 seeding starter content");
|
|
@@ -677,6 +698,72 @@ function attachJsonNodes(target, nodes) {
|
|
|
677
698
|
}
|
|
678
699
|
}
|
|
679
700
|
}
|
|
701
|
+
const SCHEMA_NODE_NAMES = /* @__PURE__ */ new Set(["documentHeader", "documentMeta"]);
|
|
702
|
+
function fragmentHasProse(fragment) {
|
|
703
|
+
for (const child of fragment.toArray()) {
|
|
704
|
+
const name = child.nodeName;
|
|
705
|
+
if (name && SCHEMA_NODE_NAMES.has(name)) continue;
|
|
706
|
+
if (name === "paragraph") {
|
|
707
|
+
const text = child.toString?.().replace(/<[^>]*>/g, "").trim();
|
|
708
|
+
if (!text) continue;
|
|
709
|
+
}
|
|
710
|
+
return true;
|
|
711
|
+
}
|
|
712
|
+
return false;
|
|
713
|
+
}
|
|
714
|
+
function backfillRequested() {
|
|
715
|
+
const v = process.env.JUN_SEED_BACKFILL;
|
|
716
|
+
return v === "1" || v === "true";
|
|
717
|
+
}
|
|
718
|
+
async function backfillBodies(ctx, tree, rootId, nodes) {
|
|
719
|
+
const childrenByLabel = (parentId) => {
|
|
720
|
+
const out = /* @__PURE__ */ new Map();
|
|
721
|
+
tree.forEach((raw, id) => {
|
|
722
|
+
const e = plain(raw);
|
|
723
|
+
if (!e || e.trashed || e.parentId !== parentId || id === parentId) return;
|
|
724
|
+
const label = e.label;
|
|
725
|
+
if (!label) return;
|
|
726
|
+
out.set(label, out.has(label) ? null : id);
|
|
727
|
+
});
|
|
728
|
+
return out;
|
|
729
|
+
};
|
|
730
|
+
const matched = [];
|
|
731
|
+
const ambiguous = [];
|
|
732
|
+
const missing = [];
|
|
733
|
+
const walk = (seedNodes, parentId) => {
|
|
734
|
+
const live = childrenByLabel(parentId);
|
|
735
|
+
for (const node of seedNodes) {
|
|
736
|
+
const id = live.get(node.label);
|
|
737
|
+
if (id === null) {
|
|
738
|
+
ambiguous.push(node.label);
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
if (!id) {
|
|
742
|
+
missing.push(node.label);
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
const planned = toPlan(node);
|
|
746
|
+
if (typeof planned.meta.body === "string" && planned.meta.body) {
|
|
747
|
+
matched.push({ ...planned, id, children: [] });
|
|
748
|
+
}
|
|
749
|
+
if (node.children?.length) walk(node.children, id);
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
walk(nodes, rootId);
|
|
753
|
+
if (ambiguous.length) {
|
|
754
|
+
console.warn(
|
|
755
|
+
`[jun:bootstrap] backfill skipped ${ambiguous.length} ambiguous label(s): ` + ambiguous.slice(0, 8).join(", ")
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
if (!matched.length) {
|
|
759
|
+
console.log(
|
|
760
|
+
`[jun:bootstrap] backfill: nothing to fill` + (missing.length ? ` (${missing.length} seed page(s) not found in this tree)` : "")
|
|
761
|
+
);
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
console.log(`[jun:bootstrap] backfill: ${matched.length} candidate document(s)`);
|
|
765
|
+
await writeBodies(ctx, matched);
|
|
766
|
+
}
|
|
680
767
|
async function writeBodies(ctx, flat) {
|
|
681
768
|
const withBody = flat.filter((n) => typeof n.meta.body === "string" && n.meta.body);
|
|
682
769
|
if (!withBody.length) return;
|
|
@@ -703,12 +790,13 @@ async function writeBodies(ctx, flat) {
|
|
|
703
790
|
});
|
|
704
791
|
}
|
|
705
792
|
const fragment = ydoc.getXmlFragment("default");
|
|
706
|
-
if (fragment
|
|
793
|
+
if (fragmentHasProse(fragment)) return;
|
|
707
794
|
const { header, meta, body } = markdownToFragmentNodes(
|
|
708
795
|
String(node.meta.body),
|
|
709
796
|
node.label
|
|
710
797
|
);
|
|
711
798
|
ydoc.transact(() => {
|
|
799
|
+
if (fragment.length > 0) fragment.delete(0, fragment.length);
|
|
712
800
|
attachJsonNodes(fragment, [
|
|
713
801
|
...header ? [header] : [],
|
|
714
802
|
...meta ? [meta] : [],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as Y from "yjs";
|
|
2
2
|
import { AbracadabraProvider } from "@abraca/dabra";
|
|
3
3
|
import { Node } from "@tiptap/core";
|
|
4
|
-
import { defineNitroPlugin, useRuntimeConfig } from "nitropack/runtime";
|
|
5
|
-
import { junCountedDocIds } from "../utils/junCache.js";
|
|
4
|
+
import { defineNitroPlugin, useRuntimeConfig, useStorage } from "nitropack/runtime";
|
|
5
|
+
import { JUN_HEARTBEAT_KEY, junCountedDocIds } from "../utils/junCache.js";
|
|
6
6
|
import { junReadActivity, junSweepActivity } from "../utils/junActivity.js";
|
|
7
7
|
import { junDayKey } from "../utils/junActivityMath.js";
|
|
8
8
|
import { junCreateRegistrar, junSetRegisterTreeState } from "../utils/junRegisterTree.js";
|
|
@@ -29,6 +29,27 @@ const CalloutStub = Node.create({
|
|
|
29
29
|
content: "block+",
|
|
30
30
|
renderHTML: () => ["div", { class: "callout" }, 0]
|
|
31
31
|
});
|
|
32
|
+
const DocLinkStub = Node.create({
|
|
33
|
+
name: "docLink",
|
|
34
|
+
group: "inline",
|
|
35
|
+
inline: true,
|
|
36
|
+
atom: true,
|
|
37
|
+
addAttributes: () => ({ docId: { default: null } }),
|
|
38
|
+
renderHTML: ({ HTMLAttributes }) => ["a", {
|
|
39
|
+
"href": `/doc/${HTMLAttributes.docId}`,
|
|
40
|
+
"data-doc-link": ""
|
|
41
|
+
}]
|
|
42
|
+
});
|
|
43
|
+
const DocEmbedStub = Node.create({
|
|
44
|
+
name: "docEmbed",
|
|
45
|
+
group: "block",
|
|
46
|
+
atom: true,
|
|
47
|
+
addAttributes: () => ({ docId: { default: null } }),
|
|
48
|
+
renderHTML: ({ HTMLAttributes }) => ["div", { "data-doc-embed": "" }, [
|
|
49
|
+
"a",
|
|
50
|
+
{ href: `/doc/${HTMLAttributes.docId}` }
|
|
51
|
+
]]
|
|
52
|
+
});
|
|
32
53
|
function createLimiter(concurrency) {
|
|
33
54
|
let active = 0;
|
|
34
55
|
const queue = [];
|
|
@@ -55,7 +76,13 @@ export default defineNitroPlugin((nitroApp) => {
|
|
|
55
76
|
nitroApp.hooks.hook("abracadabra:before-runners", () => {
|
|
56
77
|
registerServerPlugin({
|
|
57
78
|
name: "jun:doc-cache",
|
|
58
|
-
serverExtensions: () => [
|
|
79
|
+
serverExtensions: () => [
|
|
80
|
+
DocumentHeaderStub,
|
|
81
|
+
DocumentMetaStub,
|
|
82
|
+
CalloutStub,
|
|
83
|
+
DocLinkStub,
|
|
84
|
+
DocEmbedStub
|
|
85
|
+
],
|
|
59
86
|
serverRunners: [
|
|
60
87
|
{
|
|
61
88
|
name: "jun:doc-cache",
|
|
@@ -153,12 +180,23 @@ export default defineNitroPlugin((nitroApp) => {
|
|
|
153
180
|
console.warn("[jun:doc-cache] activity sweep failed:", e);
|
|
154
181
|
}
|
|
155
182
|
}
|
|
183
|
+
const beat = async () => {
|
|
184
|
+
try {
|
|
185
|
+
await useStorage().setItem(JUN_HEARTBEAT_KEY, {
|
|
186
|
+
at: Date.now(),
|
|
187
|
+
docs: docs.size
|
|
188
|
+
});
|
|
189
|
+
} catch (e) {
|
|
190
|
+
console.warn("[jun:doc-cache] heartbeat write failed:", e);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
void beat();
|
|
156
194
|
const sweep = setInterval(() => {
|
|
157
195
|
const renders = [...docs].map(
|
|
158
196
|
([docId, ydoc]) => limit(() => renderDoc(docId, ydoc)).catch(() => {
|
|
159
197
|
})
|
|
160
198
|
);
|
|
161
|
-
void Promise.all(renders).then(bookActivity);
|
|
199
|
+
void Promise.all(renders).then(bookActivity).then(beat);
|
|
162
200
|
}, REFRESH_INTERVAL_MS);
|
|
163
201
|
const observer = (event) => {
|
|
164
202
|
event.keysChanged.forEach((docId) => {
|
|
@@ -8,7 +8,9 @@ import {
|
|
|
8
8
|
plain
|
|
9
9
|
} from "../janitor/junJanitorStore.js";
|
|
10
10
|
import { junSiteConfigMeta, junSlugMap } from "../utils/junCache.js";
|
|
11
|
+
import { junSeedExpected, junSeedSettled, junWaitForSeed } from "../utils/junSeedGate.js";
|
|
11
12
|
const BOOT_DELAY_MS = 2e4;
|
|
13
|
+
const SEED_WAIT_MS = 18e4;
|
|
12
14
|
export default defineNitroPlugin((nitroApp) => {
|
|
13
15
|
const runtime = useRuntimeConfig();
|
|
14
16
|
const jun = runtime.public.jun;
|
|
@@ -27,6 +29,11 @@ export default defineNitroPlugin((nitroApp) => {
|
|
|
27
29
|
const boot = setTimeout(() => {
|
|
28
30
|
void (async () => {
|
|
29
31
|
try {
|
|
32
|
+
if (junSeedExpected() && !junSeedSettled()) {
|
|
33
|
+
log('waiting for the seeder to finish before deciding what "clean" means');
|
|
34
|
+
const settled = await junWaitForSeed(SEED_WAIT_MS);
|
|
35
|
+
log(settled ? "seed finished \u2014 reading the site" : `seed still running after ${Math.round(SEED_WAIT_MS / 1e3)}s \u2014 starting anyway`);
|
|
36
|
+
}
|
|
30
37
|
shutdown = await hire(ctx, options, log);
|
|
31
38
|
} catch (error) {
|
|
32
39
|
log(`could not start: ${error?.message ?? error}`);
|
|
@@ -47,8 +54,9 @@ export default defineNitroPlugin((nitroApp) => {
|
|
|
47
54
|
});
|
|
48
55
|
async function hire(ctx, options, log) {
|
|
49
56
|
const runtime = useRuntimeConfig();
|
|
57
|
+
const priv = runtime.abracadabra ?? {};
|
|
50
58
|
const abra = runtime.public.abracadabra ?? {};
|
|
51
|
-
const url =
|
|
59
|
+
const url = priv.serviceServerUrl || abra.url || "http://localhost:3011";
|
|
52
60
|
const actor = new JunJanitorActor({
|
|
53
61
|
name: options.name ?? "janitor",
|
|
54
62
|
color: options.color ?? "#8b8b8b",
|