@abraca/junis 2.86.0 → 2.87.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.json +1 -1
- package/dist/module.mjs +18 -2
- package/dist/runtime/components/JunDocSurface.vue +3 -0
- package/dist/runtime/components/renderers/JunGlobeRenderer.vue +43 -26
- package/dist/runtime/pages/doc.vue +39 -35
- package/dist/runtime/pages/index.vue +61 -35
- package/dist/runtime/plugins/jun-doc-tree.d.ts +2 -0
- package/dist/runtime/plugins/jun-doc-tree.js +26 -0
- package/dist/runtime/server/api/resolve/[...slug].get.js +2 -2
- package/dist/runtime/server/api/tree.get.d.ts +9 -0
- package/dist/runtime/server/api/tree.get.js +23 -0
- package/dist/runtime/server/janitor/junJanitorActor.d.ts +13 -0
- package/dist/runtime/server/janitor/junJanitorActor.js +36 -5
- package/package.json +1 -1
- /package/dist/runtime/components/{JunSectionPresence.client.d.vue.ts → JunSectionPresence.d.vue.ts} +0 -0
- /package/dist/runtime/components/{JunSectionPresence.client.vue → JunSectionPresence.vue} +0 -0
- /package/dist/runtime/components/{JunSectionPresence.client.vue.d.ts → JunSectionPresence.vue.d.ts} +0 -0
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1008,8 +1008,21 @@ Switch them off with \`jun.pageTypes: { ${missing.map((e) => `${e.key}: false`).
|
|
|
1008
1008
|
ignore: runtime.features.backdrop === "shader" ? [] : ["**/JunShaderBackdrop.client.vue"]
|
|
1009
1009
|
});
|
|
1010
1010
|
addPluginTemplate({
|
|
1011
|
-
|
|
1012
|
-
|
|
1011
|
+
// BOTH sides. This was `jun-page-types.client.mjs` + `mode: 'client'`,
|
|
1012
|
+
// which was consistent with renderers being client-only — and it was the
|
|
1013
|
+
// last thing keeping them that way. `ADocRenderer` resolves a document's
|
|
1014
|
+
// renderer through this registry, so on the server NO page type existed:
|
|
1015
|
+
// every structured page fell back to the default editor and server-
|
|
1016
|
+
// rendered a loading skeleton. A poll, a cinema, a library and the front
|
|
1017
|
+
// page all shipped a breadcrumb and three pulsing grey bars.
|
|
1018
|
+
//
|
|
1019
|
+
// The extension matters as much as the option: Nuxt reads `.client.mjs`
|
|
1020
|
+
// as client-only whatever `mode` says.
|
|
1021
|
+
//
|
|
1022
|
+
// The renderers stay LAZY, which is what the note below is about — an
|
|
1023
|
+
// async component is imported when it is first rendered, so the server
|
|
1024
|
+
// pulls in exactly the one page type it is rendering and never the rest.
|
|
1025
|
+
filename: "jun-page-types.mjs",
|
|
1013
1026
|
getContents: () => {
|
|
1014
1027
|
const imports = enabled.map(
|
|
1015
1028
|
(e) => `const ${e.key}Renderer = defineAsyncComponent(() => import(${JSON.stringify(
|
|
@@ -1075,6 +1088,7 @@ Switch them off with \`jun.pageTypes: { ${missing.map((e) => `${e.key}: false`).
|
|
|
1075
1088
|
mode: "client"
|
|
1076
1089
|
});
|
|
1077
1090
|
addPlugin({ src: resolver.resolve("./runtime/plugins/jun-site-config") });
|
|
1091
|
+
addPlugin({ src: resolver.resolve("./runtime/plugins/jun-doc-tree") });
|
|
1078
1092
|
if (options.layoutName !== false) {
|
|
1079
1093
|
addLayout(
|
|
1080
1094
|
{ src: resolver.resolve("./runtime/layouts/jun.vue") },
|
|
@@ -1105,8 +1119,10 @@ Switch them off with \`jun.pageTypes: { ${missing.map((e) => `${e.key}: false`).
|
|
|
1105
1119
|
const base = runtime.apiBase;
|
|
1106
1120
|
addServerImportsDir(resolver.resolve("./runtime/server/utils"));
|
|
1107
1121
|
addServerHandler({ route: `${base}/nav`, handler: resolver.resolve("./runtime/server/api/nav.get") });
|
|
1122
|
+
addServerHandler({ route: `${base}/tree`, handler: resolver.resolve("./runtime/server/api/tree.get") });
|
|
1108
1123
|
addServerHandler({ route: `${base}/site-config`, handler: resolver.resolve("./runtime/server/api/site-config.get") });
|
|
1109
1124
|
addServerHandler({ route: `${base}/resolve/**`, handler: resolver.resolve("./runtime/server/api/resolve/[...slug].get") });
|
|
1125
|
+
addServerHandler({ route: `${base}/resolve`, handler: resolver.resolve("./runtime/server/api/resolve/[...slug].get") });
|
|
1110
1126
|
if (enabled.some((e) => e.key === "stats")) {
|
|
1111
1127
|
addServerHandler({ route: `${base}/stats`, handler: resolver.resolve("./runtime/server/api/stats.get") });
|
|
1112
1128
|
}
|
|
@@ -28,6 +28,7 @@ const { isFeedType } = useJunLayoutPolicy();
|
|
|
28
28
|
:key="props.renderKey"
|
|
29
29
|
:doc-id="props.docId"
|
|
30
30
|
:entry="props.entry"
|
|
31
|
+
:ssr-html="props.html"
|
|
31
32
|
:editable="props.editable"
|
|
32
33
|
editor-class="w-full h-full"
|
|
33
34
|
renderer-class="w-full h-full"
|
|
@@ -60,6 +61,7 @@ const { isFeedType } = useJunLayoutPolicy();
|
|
|
60
61
|
:key="props.renderKey"
|
|
61
62
|
:doc-id="props.docId"
|
|
62
63
|
:entry="props.entry"
|
|
64
|
+
:ssr-html="props.html"
|
|
63
65
|
:editable="props.editable"
|
|
64
66
|
editor-class="w-full h-full"
|
|
65
67
|
renderer-class="w-full h-full"
|
|
@@ -93,6 +95,7 @@ const { isFeedType } = useJunLayoutPolicy();
|
|
|
93
95
|
:key="props.renderKey"
|
|
94
96
|
:doc-id="props.docId"
|
|
95
97
|
:entry="props.entry"
|
|
98
|
+
:ssr-html="props.html"
|
|
96
99
|
:editable="props.editable"
|
|
97
100
|
editor-class="w-full rounded-md"
|
|
98
101
|
renderer-class="w-full flex-1"
|
|
@@ -59,33 +59,50 @@ function onMapAdd(at) {
|
|
|
59
59
|
class="bg-black"
|
|
60
60
|
:class="isEmbedded ? 'absolute inset-0 [contain:layout_paint]' : 'fixed inset-0'"
|
|
61
61
|
>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
:waypoints="waypoints"
|
|
65
|
-
:selected-id="selectedId"
|
|
66
|
-
:adding="adding"
|
|
67
|
-
:awareness="awareness"
|
|
68
|
-
@ready="mapReady = true"
|
|
69
|
-
@select="onSelect"
|
|
70
|
-
@mapadd="onMapAdd"
|
|
71
|
-
/>
|
|
62
|
+
<!-- The one renderer that is deliberately CLIENT-ONLY, and the exception
|
|
63
|
+
proves the rule the rest of the module now follows.
|
|
72
64
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
Everything else server-renders: the tree is in the payload, so a poll
|
|
66
|
+
ships its tally and a library its shelves. A globe ships a WebGL canvas,
|
|
67
|
+
which cannot exist on a server at all — and the timeline floating over it
|
|
68
|
+
is positioned against that canvas and gated on the map's `ready` event.
|
|
69
|
+
Server-rendering the overlay alone produced exactly what you would
|
|
70
|
+
expect: `ready` false on the server and true after mount, so Vue
|
|
71
|
+
reported "server rendered element contains fewer child nodes than client
|
|
72
|
+
vdom" on every waypoint, plus `class="null"` on each icon. There is no
|
|
73
|
+
SEO or cold-read value being traded away — the page's content is a map.
|
|
80
74
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
The document's PROSE and meta still server-render through the resolve
|
|
76
|
+
payload and `<JunHead>`; only the canvas and its overlay wait. -->
|
|
77
|
+
<ClientOnly>
|
|
78
|
+
<JunGlobeMap
|
|
79
|
+
ref="mapRef"
|
|
80
|
+
:waypoints="waypoints"
|
|
81
|
+
:selected-id="selectedId"
|
|
82
|
+
:adding="adding"
|
|
83
|
+
:awareness="awareness"
|
|
84
|
+
@ready="mapReady = true"
|
|
85
|
+
@select="onSelect"
|
|
86
|
+
@mapadd="onMapAdd"
|
|
87
|
+
/>
|
|
88
|
+
|
|
89
|
+
<JunHorizontalTimeline
|
|
90
|
+
:waypoints="waypoints"
|
|
91
|
+
:selected-id="selectedId"
|
|
92
|
+
:ready="mapReady"
|
|
93
|
+
@select="onSelect"
|
|
94
|
+
@focus-route="onFocusRoute"
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
<JunGlobeEditor
|
|
98
|
+
v-if="editing"
|
|
99
|
+
ref="editorRef"
|
|
100
|
+
v-model:adding="adding"
|
|
101
|
+
:tree="tree"
|
|
102
|
+
:waypoints="waypoints"
|
|
103
|
+
:map="mapRef"
|
|
104
|
+
@select="onSelect"
|
|
105
|
+
/>
|
|
106
|
+
</ClientOnly>
|
|
90
107
|
</div>
|
|
91
108
|
</template>
|
|
@@ -107,42 +107,46 @@ const cachedHtml = computed(() => hidden.value ? "" : resolved.value?.html ?? ""
|
|
|
107
107
|
above it made every page log the very warning the wrapper exists to
|
|
108
108
|
prevent — "does not have a single root node and will cause errors when
|
|
109
109
|
navigating between routes" — while navigation was in fact fine. A
|
|
110
|
-
warning that cries wolf on every page load is worse than no warning.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
/>
|
|
126
|
-
</div>
|
|
127
|
-
</div>
|
|
128
|
-
</template>
|
|
110
|
+
warning that cries wolf on every page load is worse than no warning.
|
|
111
|
+
|
|
112
|
+
**There is no `<ClientOnly>` here any more, and that is the point.**
|
|
113
|
+
It used to wrap everything below, with the cached body in its
|
|
114
|
+
`#fallback` — so the SERVER rendered a page's prose and nothing else,
|
|
115
|
+
and the renderer that draws the actual page (a poll's options, a
|
|
116
|
+
cinema's films, a collection's children) only ever existed in the
|
|
117
|
+
browser. `jun-doc-tree` now seeds the whole tree into the payload and
|
|
118
|
+
`<ADocRenderer>` draws from it, so the real renderer runs here on the
|
|
119
|
+
server. `:html` is still handed down for the renderer's own `#loading`
|
|
120
|
+
slot, which covers the window before a child document's body arrives. -->
|
|
121
|
+
<JunNotFound
|
|
122
|
+
v-if="notFound || hidden"
|
|
123
|
+
:path="route.path"
|
|
124
|
+
/>
|
|
129
125
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
126
|
+
<JunDocSurface
|
|
127
|
+
v-else-if="docId"
|
|
128
|
+
:doc-id="docId"
|
|
129
|
+
:bucket="bucket"
|
|
130
|
+
:flow-max-w="flowMaxW"
|
|
131
|
+
:render-key="renderKey"
|
|
132
|
+
:editable="editing"
|
|
133
|
+
:entry="cachedEntry"
|
|
134
|
+
:html="cachedHtml"
|
|
135
|
+
breadcrumbs
|
|
136
|
+
/>
|
|
134
137
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
138
|
+
<!-- Nothing resolved yet: the cached body is still the best thing to show,
|
|
139
|
+
and it is what a crawler gets on a document the tree has not reached. -->
|
|
140
|
+
<div
|
|
141
|
+
v-else-if="cachedHtml"
|
|
142
|
+
class="min-h-screen pt-24"
|
|
143
|
+
>
|
|
144
|
+
<div :class="['mx-auto w-full', flowMaxW]">
|
|
145
|
+
<div
|
|
146
|
+
class="prose dark:prose-invert max-w-none"
|
|
147
|
+
v-html="cachedHtml"
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
147
151
|
</div>
|
|
148
152
|
</template>
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
import { useRouter } from "vue-router";
|
|
4
|
+
import { useFetch } from "#app";
|
|
4
5
|
import {
|
|
5
6
|
definePageMeta,
|
|
6
7
|
useAbracadabra,
|
|
7
8
|
useChildTree,
|
|
8
9
|
useDocSlugs,
|
|
9
|
-
useJunDocPage
|
|
10
|
+
useJunDocPage,
|
|
11
|
+
useJunOptions
|
|
10
12
|
} from "#imports";
|
|
11
13
|
definePageMeta({ layout: "jun" });
|
|
14
|
+
const { apiBase } = useJunOptions();
|
|
15
|
+
const request = useFetch(() => `${apiBase}/resolve`, {
|
|
16
|
+
ignoreResponseError: true
|
|
17
|
+
});
|
|
18
|
+
const resolved = request.data;
|
|
19
|
+
if (import.meta.server) await request;
|
|
12
20
|
const abra = useAbracadabra();
|
|
13
|
-
const docId = computed(() => abra.spaceDocId.value ?? null);
|
|
14
|
-
const { bucket, flowMaxW, renderKey, cachedEntry, editing } = useJunDocPage(docId);
|
|
21
|
+
const docId = computed(() => abra.spaceDocId.value ?? resolved.value?.docId ?? null);
|
|
22
|
+
const { bucket, flowMaxW, renderKey, cachedEntry, editing } = useJunDocPage(docId, { resolved });
|
|
23
|
+
const cachedHtml = computed(() => resolved.value?.html ?? "");
|
|
15
24
|
const childTree = useChildTree(abra.doc, "jun-index-child-create");
|
|
16
25
|
const { getDocUrl } = useDocSlugs();
|
|
17
26
|
const router = useRouter();
|
|
@@ -38,37 +47,54 @@ function addChild() {
|
|
|
38
47
|
standing warning about the exact failure you are guarding against is
|
|
39
48
|
worse than no warning: it is the one you stop reading.
|
|
40
49
|
|
|
41
|
-
The root doc resolves from the live CRDT connection
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
50
|
+
The root doc resolves from the live CRDT connection on the client, and
|
|
51
|
+
from the doc cache on the server — so unlike the note that used to sit
|
|
52
|
+
here, there IS cached HTML to emit, and the `#fallback` below is what
|
|
53
|
+
a crawler indexes and what a cold visitor reads before the socket is
|
|
54
|
+
up. Without it this page was blank until the CRDT synced, which is why
|
|
55
|
+
a slow or failed sync showed the front page as an empty column while
|
|
56
|
+
every other page still carried its prose.
|
|
57
|
+
|
|
58
|
+
**No `<ClientOnly>`, same as `doc.vue`.** The tree is in the payload
|
|
59
|
+
(`jun-doc-tree`), so the home renderer and its sections run on the
|
|
60
|
+
server. -->
|
|
61
|
+
<JunDocSurface
|
|
62
|
+
v-if="docId"
|
|
63
|
+
:doc-id="docId"
|
|
64
|
+
:bucket="bucket"
|
|
65
|
+
:flow-max-w="flowMaxW"
|
|
66
|
+
:render-key="renderKey"
|
|
67
|
+
:editable="editing"
|
|
68
|
+
:entry="cachedEntry"
|
|
69
|
+
:html="cachedHtml"
|
|
70
|
+
>
|
|
71
|
+
<template #footer>
|
|
72
|
+
<div
|
|
73
|
+
v-if="editing"
|
|
74
|
+
class="px-4 py-4 sm:px-8"
|
|
75
|
+
>
|
|
76
|
+
<UButton
|
|
77
|
+
icon="i-lucide-plus"
|
|
78
|
+
size="sm"
|
|
79
|
+
color="neutral"
|
|
80
|
+
variant="soft"
|
|
81
|
+
label="New page"
|
|
82
|
+
@click="addChild"
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|
|
86
|
+
</JunDocSurface>
|
|
87
|
+
|
|
88
|
+
<div
|
|
89
|
+
v-else-if="cachedHtml"
|
|
90
|
+
class="min-h-screen pt-24"
|
|
91
|
+
>
|
|
92
|
+
<div :class="['mx-auto w-full', flowMaxW]">
|
|
93
|
+
<div
|
|
94
|
+
class="prose dark:prose-invert max-w-none"
|
|
95
|
+
v-html="cachedHtml"
|
|
96
|
+
/>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
73
99
|
</div>
|
|
74
100
|
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useRuntimeConfig } from "#app";
|
|
2
|
+
import { useDocTreeSnapshot } from "#imports";
|
|
3
|
+
const KEY = "jun-doc-tree";
|
|
4
|
+
export default defineNuxtPlugin({
|
|
5
|
+
name: "jun:doc-tree",
|
|
6
|
+
enforce: "pre",
|
|
7
|
+
async setup(nuxtApp) {
|
|
8
|
+
const state = useDocTreeSnapshot();
|
|
9
|
+
if (nuxtApp.payload.data[KEY] !== void 0) {
|
|
10
|
+
state.value = nuxtApp.payload.data[KEY] ?? null;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const pub = useRuntimeConfig().public;
|
|
14
|
+
const apiBase = pub?.jun?.apiBase || "/api/_jun";
|
|
15
|
+
let value = null;
|
|
16
|
+
try {
|
|
17
|
+
const res = await $fetch(`${apiBase}/tree`);
|
|
18
|
+
if (res && typeof res === "object" && !Array.isArray(res) && typeof res.entries === "object" && res.entries !== null) {
|
|
19
|
+
value = res;
|
|
20
|
+
}
|
|
21
|
+
} catch {
|
|
22
|
+
}
|
|
23
|
+
nuxtApp.payload.data[KEY] = value;
|
|
24
|
+
state.value = value;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineEventHandler, getRouterParam } from "h3";
|
|
2
|
-
import { junDocHtml, junDocTree, junSlugMap } from "../../utils/junCache.js";
|
|
2
|
+
import { junDocHtml, junDocTree, junRootDocId, junSlugMap } from "../../utils/junCache.js";
|
|
3
3
|
import { junDocIdForAlias } from "../../utils/junSlugAlias.js";
|
|
4
4
|
import { isJunOwnerOnlyDoc } from "../../utils/junVisibility.js";
|
|
5
5
|
export default defineEventHandler(async (event) => {
|
|
@@ -7,7 +7,7 @@ export default defineEventHandler(async (event) => {
|
|
|
7
7
|
const slug = raw.replace(/^\/+|\/+$/g, "");
|
|
8
8
|
const [tree, idToSlug] = await Promise.all([junDocTree(), junSlugMap()]);
|
|
9
9
|
const cacheReady = Object.keys(tree).length > 0;
|
|
10
|
-
let docId = Object.entries(idToSlug).find(([, s]) => s === slug)?.[0];
|
|
10
|
+
let docId = slug ? Object.entries(idToSlug).find(([, s]) => s === slug)?.[0] : junRootDocId();
|
|
11
11
|
let canonical = null;
|
|
12
12
|
if (!docId) {
|
|
13
13
|
const aliasId = junDocIdForAlias(tree, slug);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface JunTreeSnapshot {
|
|
2
|
+
/** The space document's id — what `topLevelDocs` measures "top level" against. */
|
|
3
|
+
rootId: string;
|
|
4
|
+
/** Whether the cache holds anything at all; `false` means "not synced yet". */
|
|
5
|
+
ready: boolean;
|
|
6
|
+
entries: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<JunTreeSnapshot>>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { junDocTree, junRootDocId } from "../utils/junCache.js";
|
|
3
|
+
import { isJunOwnerOnlyDoc } from "../utils/junVisibility.js";
|
|
4
|
+
const META_OMIT = /* @__PURE__ */ new Set(["routeGeo", "junSite"]);
|
|
5
|
+
export default defineEventHandler(async () => {
|
|
6
|
+
const rootId = junRootDocId();
|
|
7
|
+
const tree = await junDocTree();
|
|
8
|
+
const entries = {};
|
|
9
|
+
for (const [id, entry] of Object.entries(tree)) {
|
|
10
|
+
if (!entry) continue;
|
|
11
|
+
if (isJunOwnerOnlyDoc(entry)) continue;
|
|
12
|
+
let meta = entry.meta;
|
|
13
|
+
if (meta) {
|
|
14
|
+
const kept = {};
|
|
15
|
+
for (const [k, v] of Object.entries(meta)) {
|
|
16
|
+
if (!META_OMIT.has(k)) kept[k] = v;
|
|
17
|
+
}
|
|
18
|
+
meta = kept;
|
|
19
|
+
}
|
|
20
|
+
entries[id] = meta ? { ...entry, meta } : entry;
|
|
21
|
+
}
|
|
22
|
+
return { rootId, ready: Object.keys(tree).length > 0, entries };
|
|
23
|
+
});
|
|
@@ -83,6 +83,19 @@ export declare class JunJanitorActor {
|
|
|
83
83
|
/** The root doc-tree, live. Read-only as far as the janitor is concerned. */
|
|
84
84
|
get tree(): Y.Map<unknown> | null;
|
|
85
85
|
get openDocId(): string | null;
|
|
86
|
+
/**
|
|
87
|
+
* `loginOrRegisterWithKey`, with the service runner's retry policy around it.
|
|
88
|
+
*
|
|
89
|
+
* Registration stays INSIDE the retried call rather than beside it: the
|
|
90
|
+
* "not registered" branch lives in `loginOrRegisterWithKey`, and a first boot
|
|
91
|
+
* that hits a 410 on its post-registration login has to be able to register
|
|
92
|
+
* (a no-op the second time — the server answers an already-registered key
|
|
93
|
+
* without creating anything) and try again.
|
|
94
|
+
*
|
|
95
|
+
* The last failure is rethrown unchanged, so a genuine credential error still
|
|
96
|
+
* surfaces with its own message rather than as "gave up after N attempts".
|
|
97
|
+
*/
|
|
98
|
+
private loginRetrying;
|
|
86
99
|
connect(): Promise<void>;
|
|
87
100
|
/**
|
|
88
101
|
* Where the janitor is. `docId` + `page` are the wire contract every presence
|
|
@@ -41,6 +41,41 @@ export class JunJanitorActor {
|
|
|
41
41
|
return this.open?.docId ?? null;
|
|
42
42
|
}
|
|
43
43
|
// ── Connecting ─────────────────────────────────────────────────────────────
|
|
44
|
+
/**
|
|
45
|
+
* `loginOrRegisterWithKey`, with the service runner's retry policy around it.
|
|
46
|
+
*
|
|
47
|
+
* Registration stays INSIDE the retried call rather than beside it: the
|
|
48
|
+
* "not registered" branch lives in `loginOrRegisterWithKey`, and a first boot
|
|
49
|
+
* that hits a 410 on its post-registration login has to be able to register
|
|
50
|
+
* (a no-op the second time — the server answers an already-registered key
|
|
51
|
+
* without creating anything) and try again.
|
|
52
|
+
*
|
|
53
|
+
* The last failure is rethrown unchanged, so a genuine credential error still
|
|
54
|
+
* surfaces with its own message rather than as "gave up after N attempts".
|
|
55
|
+
*/
|
|
56
|
+
async loginRetrying(client, keypair) {
|
|
57
|
+
const attempts = 5;
|
|
58
|
+
for (let attempt = 1; ; attempt++) {
|
|
59
|
+
try {
|
|
60
|
+
await loginOrRegisterWithKey(client, keypair, {
|
|
61
|
+
displayName: this.options.name,
|
|
62
|
+
deviceName: "jun janitor",
|
|
63
|
+
onRegister: () => this.log(`registering a new account for "${this.options.name}"`)
|
|
64
|
+
});
|
|
65
|
+
return;
|
|
66
|
+
} catch (err) {
|
|
67
|
+
const e = err;
|
|
68
|
+
const status = e?.status ?? e?.response?.status;
|
|
69
|
+
const retryable = isRetryableAuthStatus(status);
|
|
70
|
+
if (!retryable || attempt >= attempts) throw err;
|
|
71
|
+
const delay = authRetryDelayMs(attempt);
|
|
72
|
+
this.log(
|
|
73
|
+
`login attempt ${attempt}/${attempts} failed (${status ?? "no status"}) \u2014 retrying in ${delay}ms` + (status === 410 ? ". A 410 means the backend process answering /auth/verify never issued the challenge; a backend before 3.2.0 keeps that store per-process." : "")
|
|
74
|
+
);
|
|
75
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
44
79
|
async connect() {
|
|
45
80
|
if (this.rootProvider) return;
|
|
46
81
|
const httpUrl = this.options.url.replace(/^wss:\/\//, "https://").replace(/^ws:\/\//, "http://");
|
|
@@ -52,11 +87,7 @@ export class JunJanitorActor {
|
|
|
52
87
|
const client = new AbracadabraClient({ url: httpUrl });
|
|
53
88
|
const keypair = this.options.identity.keyFile ? await loadOrCreateKeyFile(this.options.identity.keyFile) : deterministicKeypair(this.options.identity.seed ?? this.options.name);
|
|
54
89
|
this.publicKey = keypair.publicKeyB64;
|
|
55
|
-
await
|
|
56
|
-
displayName: this.options.name,
|
|
57
|
-
deviceName: "jun janitor",
|
|
58
|
-
onRegister: () => this.log(`registering a new account for "${this.options.name}"`)
|
|
59
|
-
});
|
|
90
|
+
await this.loginRetrying(client, keypair);
|
|
60
91
|
this.client = client;
|
|
61
92
|
this.log(`authenticated as "${this.options.name}" (${keypair.publicKeyB64})`);
|
|
62
93
|
this.log(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abraca/junis",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.87.0",
|
|
4
4
|
"description": "Website-builder Nuxt module for the Abracadabra CRDT platform — page-type renderers, presence chrome, studio editing and SSR, all driven by documents",
|
|
5
5
|
"repository": "abracadabra/jun-is",
|
|
6
6
|
"license": "MIT",
|
/package/dist/runtime/components/{JunSectionPresence.client.d.vue.ts → JunSectionPresence.d.vue.ts}
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/runtime/components/{JunSectionPresence.client.vue.d.ts → JunSectionPresence.vue.d.ts}
RENAMED
|
File without changes
|