@abraca/junis 2.82.0 → 2.84.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -14
- package/dist/module.json +1 -1
- package/dist/module.mjs +21 -2
- package/dist/runtime/assets/css/jun.css +1 -1
- package/dist/runtime/components/JunCampfireChat.vue +7 -5
- package/dist/runtime/components/JunCampfireComposer.d.vue.ts +27 -0
- package/dist/runtime/components/JunCampfireComposer.vue +158 -0
- package/dist/runtime/components/JunCampfireComposer.vue.d.ts +27 -0
- package/dist/runtime/components/JunCampfirePanel.vue +18 -28
- package/dist/runtime/components/JunCampfirePresence.client.vue +109 -9
- package/dist/runtime/components/JunCampfireReactions.d.vue.ts +13 -0
- package/dist/runtime/components/JunCampfireReactions.vue +142 -0
- package/dist/runtime/components/JunCampfireReactions.vue.d.ts +13 -0
- package/dist/runtime/components/JunCampfireRoster.vue +92 -41
- package/dist/runtime/components/JunCampfireYou.vue +9 -9
- package/dist/runtime/components/JunGlobeEditor.client.vue +396 -183
- package/dist/runtime/components/JunGlobeMap.client.vue +1 -0
- package/dist/runtime/components/JunHorizontalTimeline.vue +41 -4
- package/dist/runtime/components/JunImagePopup.client.vue +1 -1
- package/dist/runtime/components/JunMosaicPane.client.d.vue.ts +9 -0
- package/dist/runtime/components/JunMosaicPane.client.vue +63 -3
- package/dist/runtime/components/JunMosaicPane.client.vue.d.ts +9 -0
- package/dist/runtime/components/JunStudioBar.client.vue +2 -1
- package/dist/runtime/components/renderers/JunAppsRenderer.vue +5 -5
- package/dist/runtime/components/renderers/JunCvRenderer.vue +1 -1
- package/dist/runtime/components/renderers/JunEntryRenderer.vue +1 -1
- package/dist/runtime/components/renderers/JunGuestbookRenderer.vue +2 -0
- package/dist/runtime/components/renderers/JunHomeRenderer.vue +2 -2
- package/dist/runtime/components/renderers/JunJournalRenderer.vue +6 -6
- package/dist/runtime/components/renderers/JunLiveRenderer.vue +2 -1
- package/dist/runtime/components/renderers/JunMosaicRenderer.vue +14 -12
- package/dist/runtime/components/renderers/JunMovieRenderer.vue +1 -1
- package/dist/runtime/components/renderers/JunNowRenderer.vue +39 -0
- package/dist/runtime/components/renderers/JunProjectRenderer.vue +2 -2
- package/dist/runtime/components/renderers/JunStatsRenderer.vue +15 -2
- package/dist/runtime/components/renderers/JunTrackRenderer.vue +44 -0
- package/dist/runtime/components/renderers/JunWallRenderer.vue +1 -0
- package/dist/runtime/composables/useJunCampfire.d.ts +2 -0
- package/dist/runtime/composables/useJunCampfire.js +11 -1
- package/dist/runtime/composables/useJunChrome.js +11 -2
- package/dist/runtime/composables/useJunDocMenu.d.ts +16 -1
- package/dist/runtime/composables/useJunDocMenu.js +8 -0
- package/dist/runtime/composables/useJunTheme.js +9 -0
- package/dist/runtime/layouts/jun.vue +10 -0
- package/dist/runtime/plugins/jun-fresh-server.client.d.ts +2 -0
- package/dist/runtime/plugins/jun-fresh-server.client.js +42 -0
- package/dist/runtime/server/janitor/junJanitorChores.d.ts +23 -2
- package/dist/runtime/server/janitor/junJanitorChores.js +74 -8
- package/dist/runtime/server/janitor/junJanitorMachine.js +16 -2
- package/dist/runtime/server/janitor/junJanitorStore.d.ts +35 -1
- package/dist/runtime/server/janitor/junJanitorStore.js +62 -4
- package/dist/runtime/server/plugins/jun-bootstrap.js +88 -3
- package/dist/runtime/server/utils/junVisibility.js +2 -0
- package/dist/runtime/types.d.ts +26 -0
- package/dist/runtime/utils/junVisibility.js +2 -0
- package/package.json +10 -8
|
@@ -196,6 +196,7 @@ function commitCaption(p, e) {
|
|
|
196
196
|
v-for="(p, i) in orderedItems"
|
|
197
197
|
:key="p.id"
|
|
198
198
|
v-motion="junMotion(junStagger(Math.min(i, 8), { delayMs: 50 }))"
|
|
199
|
+
:data-jun-anchor="`doc:${p.id}`"
|
|
199
200
|
class="mb-3 break-inside-avoid sm:mb-4"
|
|
200
201
|
:data-dnd-id="p.id"
|
|
201
202
|
:draggable="editing ? true : void 0"
|
|
@@ -9,7 +9,7 @@ const TABS = ["auto", "here", "fire", "you"];
|
|
|
9
9
|
const SIZES = ["sm", "md", "lg"];
|
|
10
10
|
const HISTORY_MIN = 5;
|
|
11
11
|
const HISTORY_MAX = 300;
|
|
12
|
-
const REACTIONS_MAX =
|
|
12
|
+
const REACTIONS_MAX = 12;
|
|
13
13
|
const TITLE_MAX = 32;
|
|
14
14
|
const ICON_RE = /^i-lucide-[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
15
15
|
export function junCampfireReactions(raw) {
|
|
@@ -56,6 +56,16 @@ export function useJunCampfireSettings() {
|
|
|
56
56
|
roster,
|
|
57
57
|
identity,
|
|
58
58
|
reactions,
|
|
59
|
+
// `&& chat` is the whole rule: a bubble is a chat message, so a site with
|
|
60
|
+
// the fire out must not have sentences drifting past its hearth.
|
|
61
|
+
//
|
|
62
|
+
// `?? true` because a MISSING build default must not read as "off". This
|
|
63
|
+
// key is newer than the option object some consumers ship, and an absent
|
|
64
|
+
// `campfire.bubbles` made `flag()` hand back `undefined` — falsy, so the
|
|
65
|
+
// whole feature was silently disabled for anyone whose `runtimeConfig`
|
|
66
|
+
// predates it. Every other flag here has a real boolean behind it; this
|
|
67
|
+
// is the one that could arrive without one.
|
|
68
|
+
bubbles: chat && flag(c.campfireBubbles, build.bubbles ?? true),
|
|
59
69
|
follow: flag(c.campfireFollow, build.follow),
|
|
60
70
|
showPages: flag(c.campfireShowPages, build.showPages),
|
|
61
71
|
showBots: flag(c.campfireShowBots, build.showBots),
|
|
@@ -13,6 +13,9 @@ const ALIGN = ["x-left", "x-right", "y-top", "y-bottom"];
|
|
|
13
13
|
const SETTLE_MS = 260;
|
|
14
14
|
const GAP = 16;
|
|
15
15
|
const PLAYER_SIDE_ROOM = 220;
|
|
16
|
+
const SHARE_RADIUS_MIN = 4;
|
|
17
|
+
let radiusMax = 0;
|
|
18
|
+
let radiusFor = null;
|
|
16
19
|
const published = {
|
|
17
20
|
edges: { "top": 0, "bottom": 0, "left-top": 0, "left-bottom": 0, "right-top": 0, "right-bottom": 0 },
|
|
18
21
|
align: { "x-left": GAP, "x-right": GAP, "y-top": GAP, "y-bottom": GAP },
|
|
@@ -64,8 +67,14 @@ function measure() {
|
|
|
64
67
|
else out.align["y-top"] = Math.max(GAP, r.top);
|
|
65
68
|
}
|
|
66
69
|
if (!docked) {
|
|
67
|
-
const
|
|
68
|
-
|
|
70
|
+
const px = Number.parseFloat(getComputedStyle(nav).borderTopLeftRadius);
|
|
71
|
+
const round = Number.isFinite(px) ? Math.round(px) : 0;
|
|
72
|
+
if (placement !== radiusFor) {
|
|
73
|
+
radiusFor = placement;
|
|
74
|
+
radiusMax = 0;
|
|
75
|
+
}
|
|
76
|
+
if (round > radiusMax) radiusMax = round;
|
|
77
|
+
out.radius = radiusMax >= SHARE_RADIUS_MIN ? `${radiusMax}px` : null;
|
|
69
78
|
}
|
|
70
79
|
}
|
|
71
80
|
}
|
|
@@ -10,7 +10,21 @@ export interface JunMenuCtx {
|
|
|
10
10
|
/** True while the owner is in edit mode. */
|
|
11
11
|
editing: boolean;
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* A `UContextMenu`/`UDropdownMenu` item. Kept structural — Nuxt UI's own type
|
|
15
|
+
* is not exported in a usable form.
|
|
16
|
+
*
|
|
17
|
+
* > **`checked` alone renders NOTHING. An item that reports a current choice
|
|
18
|
+
* > must also carry `type: 'checkbox'`.** Nuxt UI paints the tick from
|
|
19
|
+
* > `ContextMenu.ItemIndicator`, which only exists inside the
|
|
20
|
+
* > `ContextMenu.CheckboxItem` branch — every other item type drops `checked`
|
|
21
|
+
* > on the floor in silence. Both the "Page type ▸" and "Icon ▸" submenus here
|
|
22
|
+
* > shipped without it, so the one thing a switcher has to say — which option
|
|
23
|
+
* > you are ON — was the one thing it never said. (The indicator lands in the
|
|
24
|
+
* > TRAILING slot, so a checkbox item keeps its leading icon; there is no
|
|
25
|
+
* > trade.) `active` is not a menu-item prop at all, and setting it does
|
|
26
|
+
* > nothing anywhere.
|
|
27
|
+
*/
|
|
14
28
|
export interface JunMenuItem {
|
|
15
29
|
label?: string;
|
|
16
30
|
icon?: string;
|
|
@@ -18,6 +32,7 @@ export interface JunMenuItem {
|
|
|
18
32
|
kbds?: string[];
|
|
19
33
|
disabled?: boolean;
|
|
20
34
|
type?: 'label' | 'separator' | 'checkbox';
|
|
35
|
+
/** Requires `type: 'checkbox'` to render. See the note above. */
|
|
21
36
|
checked?: boolean;
|
|
22
37
|
children?: JunMenuItem[];
|
|
23
38
|
onSelect?: (e?: Event) => void;
|
|
@@ -182,12 +182,18 @@ export function useJunDocMenu() {
|
|
|
182
182
|
...ICON_CHOICES.map((choice) => ({
|
|
183
183
|
label: choice.label,
|
|
184
184
|
icon: choice.icon,
|
|
185
|
+
// `type: 'checkbox'` is what MAKES the tick — see `JunMenuItem`.
|
|
186
|
+
type: "checkbox",
|
|
185
187
|
checked: current === choice.icon,
|
|
186
188
|
onSelect: () => tree.updateMeta(ctx.docId, { icon: choice.icon })
|
|
187
189
|
})),
|
|
188
190
|
{
|
|
189
191
|
label: "Use page-type icon",
|
|
190
192
|
icon: "i-lucide-rotate-ccw",
|
|
193
|
+
// Ticked when nothing is overridden — "inherits the page type" is a
|
|
194
|
+
// state of this list, not an escape from it.
|
|
195
|
+
type: "checkbox",
|
|
196
|
+
checked: !current,
|
|
191
197
|
onSelect: () => tree.updateMeta(ctx.docId, { icon: void 0 })
|
|
192
198
|
}
|
|
193
199
|
]
|
|
@@ -206,12 +212,14 @@ export function useJunDocMenu() {
|
|
|
206
212
|
{
|
|
207
213
|
label: "Document",
|
|
208
214
|
icon: "i-lucide-file-text",
|
|
215
|
+
type: "checkbox",
|
|
209
216
|
checked: currentType === "doc" || !currentType,
|
|
210
217
|
onSelect: () => setType("doc")
|
|
211
218
|
},
|
|
212
219
|
...opts.pageTypes.map((type) => ({
|
|
213
220
|
label: labelForType(type) ?? type,
|
|
214
221
|
icon: opts.typeIcons[type] ?? "i-lucide-file-text",
|
|
222
|
+
type: "checkbox",
|
|
215
223
|
checked: currentType === type,
|
|
216
224
|
onSelect: () => setType(type)
|
|
217
225
|
}))
|
|
@@ -84,6 +84,13 @@ function sunVars(hex, orb) {
|
|
|
84
84
|
`--jun-sun-glow:${hex}`
|
|
85
85
|
];
|
|
86
86
|
}
|
|
87
|
+
function emberVars(hex) {
|
|
88
|
+
if (!hex) return [];
|
|
89
|
+
return [
|
|
90
|
+
`--jun-ember:${hex}`,
|
|
91
|
+
`--jun-ember-glow:${shade(hex, 0.12)}`
|
|
92
|
+
];
|
|
93
|
+
}
|
|
87
94
|
export function junFontClass(cfg) {
|
|
88
95
|
const font = cfg.themeFont;
|
|
89
96
|
const surface = cfg.themeSurface ?? "soft";
|
|
@@ -107,6 +114,8 @@ export function junThemeCss(cfg) {
|
|
|
107
114
|
if (darkHex) dark.push(`--ui-primary:${darkHex}`);
|
|
108
115
|
root.push(...sunVars(lightHex, customLight ? void 0 : preset?.orb?.light));
|
|
109
116
|
dark.push(...sunVars(darkHex, customDark ? void 0 : preset?.orb?.dark));
|
|
117
|
+
root.push(...emberVars(lightHex));
|
|
118
|
+
dark.push(...emberVars(darkHex));
|
|
110
119
|
const neutral = cfg.themeNeutral ?? "stone";
|
|
111
120
|
const ramp = NEUTRAL[neutral] ?? NEUTRAL.stone;
|
|
112
121
|
ramp.forEach((hex, i) => {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed, resolveComponent } from "vue";
|
|
3
3
|
import { useEventListener } from "@vueuse/core";
|
|
4
4
|
import {
|
|
5
|
+
useAAFocus,
|
|
5
6
|
useJunBackdrop,
|
|
6
7
|
useJunCampfireSettings,
|
|
7
8
|
useJunEffectiveConfig,
|
|
@@ -35,6 +36,7 @@ const presenceBlobsLit = computed(() => {
|
|
|
35
36
|
const stored = effectiveConfig.value.presenceBlobs;
|
|
36
37
|
return typeof stored === "boolean" ? stored : true;
|
|
37
38
|
});
|
|
39
|
+
if (features.presence && features.peerSelection) useAAFocus({ selectionOnly: true });
|
|
38
40
|
useJunSiteConfigMigration();
|
|
39
41
|
useJunSlugAliasTracker();
|
|
40
42
|
useJunRouteGeoHeal();
|
|
@@ -123,6 +125,14 @@ if (import.meta.client && contextMenu.suppressNative) {
|
|
|
123
125
|
and read as surveillance rather than company. -->
|
|
124
126
|
<JunPeerCursors v-if="features.presence && features.peerCursors" />
|
|
125
127
|
|
|
128
|
+
<!-- The selection of the traveller you are FOLLOWING, and nobody else's.
|
|
129
|
+
`follow-only` gates the RENDER; the broadcast above is unconditional
|
|
130
|
+
because a leader who follows nobody must still be followable. -->
|
|
131
|
+
<AGlobalFocusLayer
|
|
132
|
+
v-if="features.presence && features.peerSelection"
|
|
133
|
+
follow-only
|
|
134
|
+
/>
|
|
135
|
+
|
|
126
136
|
<!-- The user center. Off by default — "too much for now" on the reference
|
|
127
137
|
site — but the gate is the EFFECTIVE setting, not the build flag, so an
|
|
128
138
|
owner can light the fire from the settings page without a redeploy.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { dropCachesIfServerReplaced } from "@abraca/dabra";
|
|
2
|
+
import { defineNuxtPlugin, useRuntimeConfig } from "#imports";
|
|
3
|
+
export default defineNuxtPlugin({
|
|
4
|
+
name: "jun:fresh-server",
|
|
5
|
+
enforce: "pre",
|
|
6
|
+
async setup() {
|
|
7
|
+
if (import.meta.server) return;
|
|
8
|
+
const config = useRuntimeConfig().public;
|
|
9
|
+
const url = config.abracadabra?.url ?? config.jun?.serverUrl;
|
|
10
|
+
if (!url) return;
|
|
11
|
+
let origin;
|
|
12
|
+
let host;
|
|
13
|
+
try {
|
|
14
|
+
const parsed = new URL(url, window.location.origin);
|
|
15
|
+
origin = parsed.origin;
|
|
16
|
+
host = parsed.host;
|
|
17
|
+
} catch {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const controller = new AbortController();
|
|
22
|
+
const timer = setTimeout(() => controller.abort(), 4e3);
|
|
23
|
+
const info = await fetch(`${origin}/info`, { signal: controller.signal }).finally(() => clearTimeout(timer));
|
|
24
|
+
if (!info.ok) return;
|
|
25
|
+
const serverId = (await info.json())?.server_id;
|
|
26
|
+
if (typeof serverId !== "string" || !serverId) return;
|
|
27
|
+
const outcome = await dropCachesIfServerReplaced(host, serverId);
|
|
28
|
+
if (!outcome) return;
|
|
29
|
+
const moved = `${outcome.previousServerId?.slice(0, 8)} \u2192 ${serverId.slice(0, 8)}`;
|
|
30
|
+
if (outcome.blocked.length) {
|
|
31
|
+
console.warn(
|
|
32
|
+
`[jun] ${origin} has a new database (${moved}), but ${outcome.blocked.length} cache(s) could not be cleared \u2014 something already had them open, so this tab may re-push a tree that no longer exists. Reload it. Blocked: ${outcome.blocked.join(", ")}`
|
|
33
|
+
);
|
|
34
|
+
} else {
|
|
35
|
+
console.info(
|
|
36
|
+
`[jun] ${origin} has a new database (${moved}); cleared ${outcome.cleared.length} local cache(s) so this tab does not re-push a tree that no longer exists.`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
@@ -68,6 +68,13 @@ export type JunChore = (ChoreBase & {
|
|
|
68
68
|
kind: 'entry.rename';
|
|
69
69
|
from: string;
|
|
70
70
|
to: string;
|
|
71
|
+
}) | (ChoreBase & {
|
|
72
|
+
kind: 'entry.type';
|
|
73
|
+
from: string;
|
|
74
|
+
to: string;
|
|
75
|
+
}) | (ChoreBase & {
|
|
76
|
+
kind: 'entry.move';
|
|
77
|
+
parentId: string | null;
|
|
71
78
|
}) | (ChoreBase & {
|
|
72
79
|
kind: 'entry.reorder';
|
|
73
80
|
order: number;
|
|
@@ -100,8 +107,22 @@ export interface JunChorePolicy {
|
|
|
100
107
|
backspaceLimit: number;
|
|
101
108
|
/** Above this, a body edit is not a tidy-up — it collapses to one flat cut. */
|
|
102
109
|
wholesaleLimit: number;
|
|
103
|
-
/**
|
|
104
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Meta keys the janitor must NOT touch. Everything else on a page is content,
|
|
112
|
+
* and content is its business.
|
|
113
|
+
*
|
|
114
|
+
* This is a DENYLIST, and it used to be an allowlist of seven keys
|
|
115
|
+
* (`excerpt`, `icon`, `tags`, `accent`, `description`, `status`, `url`). That
|
|
116
|
+
* was wrong in a way nothing caught: the renderers read **56** distinct meta
|
|
117
|
+
* keys, so a visitor could rewrite `nowPlaying` on a `now` page, `location`
|
|
118
|
+
* on a live entry, an `author`, a `rating`, a `category`, a `place` — any of
|
|
119
|
+
* the forty-nine the list did not name — and the janitor walked straight
|
|
120
|
+
* past it. A custom page type, whose fields are unknowable in advance, was
|
|
121
|
+
* invisible to it ENTIRELY. An allowlist cannot express "put everything
|
|
122
|
+
* back"; only a denylist can, and only a denylist keeps working when a new
|
|
123
|
+
* page type invents a field.
|
|
124
|
+
*/
|
|
125
|
+
metaIgnore: readonly string[];
|
|
105
126
|
/** Never touch these documents, whatever the baseline says. */
|
|
106
127
|
ignoreDocIds: readonly string[];
|
|
107
128
|
/** Never remove a document that has at least this many children. */
|
|
@@ -2,11 +2,35 @@ import { junDiffText, describeSize, editShape } from "./junJanitorDiff.js";
|
|
|
2
2
|
export const JUN_CHORE_POLICY_DEFAULT = {
|
|
3
3
|
backspaceLimit: 90,
|
|
4
4
|
wholesaleLimit: 4e3,
|
|
5
|
-
// Deliberately short
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
5
|
+
// Deliberately short, and every entry has to earn its place — anything left
|
|
6
|
+
// out here IS reverted, which is the point. Four kinds of thing belong:
|
|
7
|
+
//
|
|
8
|
+
// - VISITOR-CONTRIBUTED. `appreciatedBy` is the reaction list the RPC runner
|
|
9
|
+
// appends to. A janitor that reverted it would be un-hearting visitors'
|
|
10
|
+
// reactions, which is not tidying, it is vandalism with a mop.
|
|
11
|
+
// - DERIVED BOOKKEEPING. `slugAliases` is written by `useJunRename` to keep
|
|
12
|
+
// a vacated URL redirecting. Reverting it would break the 301 for a
|
|
13
|
+
// rename the janitor itself is about to undo, and the rename chore already
|
|
14
|
+
// restores the label the alias exists for.
|
|
15
|
+
// - IDENTITY AND TIMESTAMPS. Not content, and `order` has its own chore —
|
|
16
|
+
// comparing it here too would queue two chores for one displacement.
|
|
17
|
+
// - INFRASTRUCTURE FLAGS. The documents carrying these are already excluded
|
|
18
|
+
// wholesale by `isJunOwnerOnlyDoc`; the keys are named again so that a
|
|
19
|
+
// flag appearing on an ordinary page cannot be reverted into a site that
|
|
20
|
+
// hides it, or out of one.
|
|
21
|
+
metaIgnore: [
|
|
22
|
+
"appreciatedBy",
|
|
23
|
+
"slugAliases",
|
|
24
|
+
"createdAt",
|
|
25
|
+
"updatedAt",
|
|
26
|
+
"order",
|
|
27
|
+
"_metaInitialized",
|
|
28
|
+
"janitorBaseline",
|
|
29
|
+
"ownerOnly",
|
|
30
|
+
"siteConfig",
|
|
31
|
+
"campfire",
|
|
32
|
+
"junSite"
|
|
33
|
+
],
|
|
10
34
|
ignoreDocIds: [],
|
|
11
35
|
protectChildCount: 1
|
|
12
36
|
};
|
|
@@ -90,6 +114,7 @@ export function planTreeChores(baseline, live, options = {}) {
|
|
|
90
114
|
const policy = options.policy ?? JUN_CHORE_POLICY_DEFAULT;
|
|
91
115
|
const chores = [];
|
|
92
116
|
const ignored = new Set(policy.ignoreDocIds);
|
|
117
|
+
const ignoredKeys = new Set(policy.metaIgnore);
|
|
93
118
|
for (const [id, base] of Object.entries(baseline.docs)) {
|
|
94
119
|
if (ignored.has(id)) continue;
|
|
95
120
|
const now = live.docs[id];
|
|
@@ -126,7 +151,31 @@ export function planTreeChores(baseline, live, options = {}) {
|
|
|
126
151
|
severity: "minor"
|
|
127
152
|
});
|
|
128
153
|
}
|
|
129
|
-
|
|
154
|
+
if (now.parentId !== base.parentId) {
|
|
155
|
+
chores.push({
|
|
156
|
+
kind: "entry.move",
|
|
157
|
+
id: `move:${id}`,
|
|
158
|
+
docId: id,
|
|
159
|
+
parentId: base.parentId,
|
|
160
|
+
severity: "notable"
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (now.type !== base.type) {
|
|
164
|
+
chores.push({
|
|
165
|
+
kind: "entry.type",
|
|
166
|
+
id: `type:${id}`,
|
|
167
|
+
docId: id,
|
|
168
|
+
from: now.type,
|
|
169
|
+
to: base.type,
|
|
170
|
+
severity: "notable"
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
const keys = /* @__PURE__ */ new Set([
|
|
174
|
+
...Object.keys(base.meta ?? {}),
|
|
175
|
+
...Object.keys(now.meta ?? {})
|
|
176
|
+
]);
|
|
177
|
+
for (const key of keys) {
|
|
178
|
+
if (ignoredKeys.has(key)) continue;
|
|
130
179
|
const want = base.meta?.[key];
|
|
131
180
|
const have = now.meta?.[key];
|
|
132
181
|
if (stableEqual(want, have)) continue;
|
|
@@ -153,14 +202,27 @@ export function planTreeChores(baseline, live, options = {}) {
|
|
|
153
202
|
}
|
|
154
203
|
return chores;
|
|
155
204
|
}
|
|
205
|
+
function canonical(value) {
|
|
206
|
+
if (Array.isArray(value)) return value.map(canonical);
|
|
207
|
+
if (value && typeof value === "object") {
|
|
208
|
+
return Object.fromEntries(
|
|
209
|
+
Object.entries(value).map(([k, v]) => [k, canonical(v)]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
156
214
|
function stableEqual(a, b) {
|
|
157
215
|
if (a === b) return true;
|
|
158
216
|
if (a == null || b == null) return a == null && b == null;
|
|
159
217
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
160
|
-
|
|
218
|
+
if (a.length !== b.length) return false;
|
|
219
|
+
const sortKey = (v) => JSON.stringify(canonical(v));
|
|
220
|
+
const left = a.map(sortKey).sort();
|
|
221
|
+
const right = b.map(sortKey).sort();
|
|
222
|
+
return left.every((v, i) => v === right[i]);
|
|
161
223
|
}
|
|
162
224
|
if (typeof a === "object" && typeof b === "object") {
|
|
163
|
-
return JSON.stringify(a) === JSON.stringify(b);
|
|
225
|
+
return JSON.stringify(canonical(a)) === JSON.stringify(canonical(b));
|
|
164
226
|
}
|
|
165
227
|
return false;
|
|
166
228
|
}
|
|
@@ -177,6 +239,10 @@ export function describeChore(chore) {
|
|
|
177
239
|
};
|
|
178
240
|
case "entry.rename":
|
|
179
241
|
return { what: `the name`, verb: "changed" };
|
|
242
|
+
case "entry.type":
|
|
243
|
+
return { what: "the kind of page", verb: "changed" };
|
|
244
|
+
case "entry.move":
|
|
245
|
+
return { what: "where this lives", verb: "moved" };
|
|
180
246
|
case "entry.reorder":
|
|
181
247
|
return { what: "the order", verb: "shuffled" };
|
|
182
248
|
case "entry.meta":
|
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
import { createJunVoice } from "./junJanitorVoice.js";
|
|
19
19
|
import {
|
|
20
20
|
JUN_PATROL_POLICY_DEFAULT,
|
|
21
|
-
nextPatrolTarget
|
|
21
|
+
nextPatrolTarget,
|
|
22
|
+
scorePatrol
|
|
22
23
|
} from "./junJanitorPatrol.js";
|
|
23
24
|
import { junHear } from "./junJanitorListen.js";
|
|
24
25
|
import { junBlocks, displayToBody, displayToBodyPos, junCursorState, junFragmentText } from "./junJanitorYText.js";
|
|
@@ -244,6 +245,12 @@ export function createJunJanitorMachine(options, deps) {
|
|
|
244
245
|
case "entry.reorder":
|
|
245
246
|
await deps.tree.reorder(chore.docId, chore.order);
|
|
246
247
|
return true;
|
|
248
|
+
case "entry.type":
|
|
249
|
+
await deps.tree.setType(chore.docId, chore.to);
|
|
250
|
+
return true;
|
|
251
|
+
case "entry.move":
|
|
252
|
+
await deps.tree.move(chore.docId, chore.parentId);
|
|
253
|
+
return true;
|
|
247
254
|
case "entry.meta":
|
|
248
255
|
await deps.tree.setMeta(chore.docId, chore.key, chore.value);
|
|
249
256
|
return true;
|
|
@@ -456,8 +463,15 @@ export function createJunJanitorMachine(options, deps) {
|
|
|
456
463
|
pendingChores: 0
|
|
457
464
|
};
|
|
458
465
|
});
|
|
466
|
+
const ranked = scorePatrol(candidates, at, patrolPolicy);
|
|
459
467
|
const target = nextPatrolTarget(candidates, at, patrolPolicy);
|
|
460
|
-
|
|
468
|
+
const top = ranked.slice(0, 3).map((r) => {
|
|
469
|
+
const why = r.skipped ? r.skipped : r.score.toFixed(1);
|
|
470
|
+
return `${labelOf(live, r.candidate.docId)}=${why}`;
|
|
471
|
+
}).join(" ");
|
|
472
|
+
deps.log(
|
|
473
|
+
`patrol: ${candidates.length} candidates \u2192 ${target?.docId.slice(0, 8) ?? "nowhere"}${top ? ` [${top}]` : ""}`
|
|
474
|
+
);
|
|
461
475
|
if (!target) {
|
|
462
476
|
phase = "idle";
|
|
463
477
|
deps.actor.setStatus(null);
|
|
@@ -76,6 +76,24 @@ export declare function createJunTreeWriter(options: JunTreeWriterOptions): {
|
|
|
76
76
|
*/
|
|
77
77
|
rename(docId: string, label: string): Promise<void>;
|
|
78
78
|
reorder(docId: string, order: number): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Put a page back where it belongs.
|
|
81
|
+
*
|
|
82
|
+
* Slugs are derived from the tree, so this MOVES the page's URL — the same
|
|
83
|
+
* consequence a rename has. The vacated path is not recorded as an alias:
|
|
84
|
+
* `meta.slugAliases` is keyed on labels by `useJunRename`, and inventing a
|
|
85
|
+
* second convention for parents would put two writers on one key.
|
|
86
|
+
*/
|
|
87
|
+
move(docId: string, parentId: string | null): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Put a page's TYPE back.
|
|
90
|
+
*
|
|
91
|
+
* The type and the meta go in one `set`, the same rule the media importer
|
|
92
|
+
* follows: two writes leave a window in which the page is one kind of thing
|
|
93
|
+
* carrying another kind's fields, and that is what every peer renders until
|
|
94
|
+
* the second lands.
|
|
95
|
+
*/
|
|
96
|
+
setType(docId: string, type: string): Promise<void>;
|
|
79
97
|
setMeta(docId: string, key: string, value: unknown): Promise<void>;
|
|
80
98
|
/**
|
|
81
99
|
* Trash a page the canonical way: copy the entry into `doc-trash`, then
|
|
@@ -86,7 +104,23 @@ export declare function createJunTreeWriter(options: JunTreeWriterOptions): {
|
|
|
86
104
|
* appear to have failed. See CLAUDE.md, "Trash documents the canonical way".
|
|
87
105
|
*/
|
|
88
106
|
trash(docId: string): Promise<void>;
|
|
89
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Put a trashed page back where it was.
|
|
109
|
+
*
|
|
110
|
+
* A page can be gone in TWO shapes, and this used to handle only one. The
|
|
111
|
+
* canonical trash (`useChildTree.deleteEntry`, and this writer's own
|
|
112
|
+
* `trash`) copies the entry into `doc-trash` and DELETES it from
|
|
113
|
+
* `doc-tree`. But an entry can also be flagged `trashed: true` in place —
|
|
114
|
+
* `planTreeChores` raises a `doc.restore` for exactly that case, and
|
|
115
|
+
* `junReadTree` carries the flag for it.
|
|
116
|
+
*
|
|
117
|
+
* The old guard was `if (tree.get(docId)) return`, so the in-place shape
|
|
118
|
+
* fell straight through it and did nothing — while the confirmation
|
|
119
|
+
* (`!!shared().get(docId)`) found the entry still sitting there and
|
|
120
|
+
* reported the chore DONE. A restore that silently declines is the failure
|
|
121
|
+
* this module warns about everywhere else: a write that reports success
|
|
122
|
+
* and did not happen.
|
|
123
|
+
*/
|
|
90
124
|
restore(docId: string, entry: JunTreeEntry): Promise<void>;
|
|
91
125
|
};
|
|
92
126
|
export type JunTreeWriter = ReturnType<typeof createJunTreeWriter>;
|
|
@@ -120,6 +120,44 @@ export function createJunTreeWriter(options) {
|
|
|
120
120
|
).then(() => {
|
|
121
121
|
});
|
|
122
122
|
},
|
|
123
|
+
/**
|
|
124
|
+
* Put a page back where it belongs.
|
|
125
|
+
*
|
|
126
|
+
* Slugs are derived from the tree, so this MOVES the page's URL — the same
|
|
127
|
+
* consequence a rename has. The vacated path is not recorded as an alias:
|
|
128
|
+
* `meta.slugAliases` is keyed on labels by `useJunRename`, and inventing a
|
|
129
|
+
* second convention for parents would put two writers on one key.
|
|
130
|
+
*/
|
|
131
|
+
move(docId, parentId) {
|
|
132
|
+
return withTree(
|
|
133
|
+
(tree) => {
|
|
134
|
+
const entry = plain(tree.get(docId));
|
|
135
|
+
if (!entry || entry.parentId === parentId) return;
|
|
136
|
+
tree.set(docId, { ...entry, parentId, updatedAt: Date.now() });
|
|
137
|
+
},
|
|
138
|
+
() => plain(shared().get(docId))?.parentId === parentId
|
|
139
|
+
).then(() => {
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
/**
|
|
143
|
+
* Put a page's TYPE back.
|
|
144
|
+
*
|
|
145
|
+
* The type and the meta go in one `set`, the same rule the media importer
|
|
146
|
+
* follows: two writes leave a window in which the page is one kind of thing
|
|
147
|
+
* carrying another kind's fields, and that is what every peer renders until
|
|
148
|
+
* the second lands.
|
|
149
|
+
*/
|
|
150
|
+
setType(docId, type) {
|
|
151
|
+
return withTree(
|
|
152
|
+
(tree) => {
|
|
153
|
+
const entry = plain(tree.get(docId));
|
|
154
|
+
if (!entry || entry.type === type) return;
|
|
155
|
+
tree.set(docId, { ...entry, type, updatedAt: Date.now() });
|
|
156
|
+
},
|
|
157
|
+
() => plain(shared().get(docId))?.type === type
|
|
158
|
+
).then(() => {
|
|
159
|
+
});
|
|
160
|
+
},
|
|
123
161
|
setMeta(docId, key, value) {
|
|
124
162
|
return withTree(
|
|
125
163
|
(tree) => {
|
|
@@ -159,22 +197,42 @@ export function createJunTreeWriter(options) {
|
|
|
159
197
|
).then(() => {
|
|
160
198
|
});
|
|
161
199
|
},
|
|
162
|
-
/**
|
|
200
|
+
/**
|
|
201
|
+
* Put a trashed page back where it was.
|
|
202
|
+
*
|
|
203
|
+
* A page can be gone in TWO shapes, and this used to handle only one. The
|
|
204
|
+
* canonical trash (`useChildTree.deleteEntry`, and this writer's own
|
|
205
|
+
* `trash`) copies the entry into `doc-trash` and DELETES it from
|
|
206
|
+
* `doc-tree`. But an entry can also be flagged `trashed: true` in place —
|
|
207
|
+
* `planTreeChores` raises a `doc.restore` for exactly that case, and
|
|
208
|
+
* `junReadTree` carries the flag for it.
|
|
209
|
+
*
|
|
210
|
+
* The old guard was `if (tree.get(docId)) return`, so the in-place shape
|
|
211
|
+
* fell straight through it and did nothing — while the confirmation
|
|
212
|
+
* (`!!shared().get(docId)`) found the entry still sitting there and
|
|
213
|
+
* reported the chore DONE. A restore that silently declines is the failure
|
|
214
|
+
* this module warns about everywhere else: a write that reports success
|
|
215
|
+
* and did not happen.
|
|
216
|
+
*/
|
|
163
217
|
restore(docId, entry) {
|
|
164
218
|
return withTree(
|
|
165
219
|
(tree) => {
|
|
166
|
-
if (tree.get(docId)) return;
|
|
167
220
|
const trash = tree.doc.getMap("doc-trash");
|
|
221
|
+
const current = plain(tree.get(docId));
|
|
222
|
+
if (current && current.trashed !== true) return;
|
|
168
223
|
const stored = plain(trash.get(docId));
|
|
169
224
|
tree.set(docId, {
|
|
170
|
-
...stored ?? entry,
|
|
225
|
+
...stored ?? current ?? entry,
|
|
171
226
|
...entry,
|
|
172
227
|
trashed: false,
|
|
173
228
|
updatedAt: Date.now()
|
|
174
229
|
});
|
|
175
230
|
trash.delete(docId);
|
|
176
231
|
},
|
|
177
|
-
() =>
|
|
232
|
+
() => {
|
|
233
|
+
const back = plain(shared().get(docId));
|
|
234
|
+
return !!back && back.trashed !== true;
|
|
235
|
+
}
|
|
178
236
|
).then(() => {
|
|
179
237
|
});
|
|
180
238
|
}
|