@abraca/junis 2.80.0 → 2.82.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 +20 -9
- package/dist/module.json +1 -1
- package/dist/module.mjs +47 -18
- package/dist/runtime/assets/css/jun.css +1 -1
- package/dist/runtime/components/JunSettings.client.d.vue.ts +3 -0
- package/dist/runtime/components/JunSettings.client.vue +195 -0
- package/dist/runtime/components/JunSettings.client.vue.d.ts +3 -0
- package/dist/runtime/components/JunStudioBar.client.vue +11 -23
- package/dist/runtime/components/renderers/JunConfigRenderer.d.vue.ts +13 -0
- package/dist/runtime/components/renderers/JunConfigRenderer.vue +54 -21
- package/dist/runtime/components/renderers/JunConfigRenderer.vue.d.ts +13 -0
- package/dist/runtime/components/renderers/JunStatsRenderer.vue +280 -74
- package/dist/runtime/composables/useJunCommands.js +15 -12
- package/dist/runtime/composables/useJunDocPage.d.ts +8 -1
- package/dist/runtime/composables/useJunDocPage.js +6 -4
- package/dist/runtime/composables/useJunRename.js +6 -5
- package/dist/runtime/composables/useJunSettings.d.ts +24 -0
- package/dist/runtime/composables/useJunSettings.js +48 -0
- package/dist/runtime/composables/useJunSiteConfig.d.ts +69 -27
- package/dist/runtime/composables/useJunSiteConfig.js +62 -53
- package/dist/runtime/composables/useJunViewingAccent.d.ts +0 -1
- package/dist/runtime/composables/useJunViewingAccent.js +1 -1
- package/dist/runtime/layouts/jun.vue +18 -2
- package/dist/runtime/pages/index.vue +18 -8
- package/dist/runtime/plugins/jun-site-config.d.ts +17 -0
- package/dist/runtime/plugins/jun-site-config.js +26 -0
- package/dist/runtime/server/api/resolve/[...slug].get.d.ts +15 -1
- package/dist/runtime/server/api/resolve/[...slug].get.js +24 -2
- package/dist/runtime/server/api/stats.get.d.ts +27 -0
- package/dist/runtime/server/api/stats.get.js +35 -8
- package/dist/runtime/server/plugins/jun-bootstrap.js +40 -12
- package/dist/runtime/server/plugins/jun-doc-cache.js +44 -3
- package/dist/runtime/server/tasks/jun-register-tree.d.ts +16 -0
- package/dist/runtime/server/tasks/jun-register-tree.js +22 -0
- package/dist/runtime/server/utils/junActivity.d.ts +15 -0
- package/dist/runtime/server/utils/junActivity.js +71 -0
- package/dist/runtime/server/utils/junActivityMath.d.ts +61 -0
- package/dist/runtime/server/utils/junActivityMath.js +31 -0
- package/dist/runtime/server/utils/junCache.d.ts +30 -12
- package/dist/runtime/server/utils/junCache.js +13 -2
- package/dist/runtime/server/utils/junRegisterTree.d.ts +59 -0
- package/dist/runtime/server/utils/junRegisterTree.js +76 -0
- package/dist/runtime/server/utils/junServiceFetch.js +1 -1
- package/dist/runtime/server/utils/junSlugAlias.d.ts +42 -0
- package/dist/runtime/server/utils/junSlugAlias.js +14 -0
- package/dist/runtime/types.d.ts +1 -1
- package/package.json +2 -1
- package/dist/runtime/components/renderers/JunWindowRenderer.d.vue.ts +0 -10
- package/dist/runtime/components/renderers/JunWindowRenderer.vue +0 -516
- package/dist/runtime/components/renderers/JunWindowRenderer.vue.d.ts +0 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
2
|
import { useRouter } from "vue-router";
|
|
3
|
-
import {
|
|
3
|
+
import { useToast } from "#imports";
|
|
4
4
|
import { useJunOptions } from "./useJunOptions.js";
|
|
5
5
|
import { useJunCreatePage } from "./useJunCreatePage.js";
|
|
6
6
|
import { useJunCurrentDoc } from "./useJunCurrentDoc.js";
|
|
@@ -8,6 +8,7 @@ import { useJunStudio } from "./useJunStudio.js";
|
|
|
8
8
|
import { useJunThemeTransition } from "./useJunThemeTransition.js";
|
|
9
9
|
import { useJunPlayer } from "./useJunPlayer.js";
|
|
10
10
|
import { useJunEffectiveConfig, useJunSiteConfig } from "./useJunSiteConfig.js";
|
|
11
|
+
import { JUN_SETTINGS_SECTIONS, useJunSettings } from "./useJunSettings.js";
|
|
11
12
|
const builders = [];
|
|
12
13
|
export function registerJunCommands(builder) {
|
|
13
14
|
builders.push(builder);
|
|
@@ -31,7 +32,6 @@ const PLACEMENTS = [
|
|
|
31
32
|
];
|
|
32
33
|
export function useJunCommands() {
|
|
33
34
|
const router = useRouter();
|
|
34
|
-
const { getDocUrl } = useDocSlugs();
|
|
35
35
|
const { features, navigation } = useJunOptions();
|
|
36
36
|
const { canEdit, editMode, toggleEdit, openLogin } = useJunStudio();
|
|
37
37
|
const { toggle: toggleTheme, isDark } = useJunThemeTransition();
|
|
@@ -46,7 +46,7 @@ export function useJunCommands() {
|
|
|
46
46
|
}
|
|
47
47
|
const currentSurface = computed(() => effective.value.themeSurface ?? SURFACE_DEFAULT);
|
|
48
48
|
const currentPlacement = computed(() => effective.value.navPlacement ?? navigation.placement);
|
|
49
|
-
const
|
|
49
|
+
const { openSettings } = useJunSettings();
|
|
50
50
|
async function copyLink() {
|
|
51
51
|
const url = new URL(router.currentRoute.value.fullPath, window.location.origin).href;
|
|
52
52
|
try {
|
|
@@ -79,15 +79,18 @@ export function useJunCommands() {
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
if (canEdit.value
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
if (canEdit.value) {
|
|
83
|
+
for (const s of JUN_SETTINGS_SECTIONS) {
|
|
84
|
+
out.push({
|
|
85
|
+
key: `settings:${s.id}`,
|
|
86
|
+
label: `Settings \u2014 ${s.label}`,
|
|
87
|
+
icon: s.icon,
|
|
88
|
+
group: "Go",
|
|
89
|
+
hint: s.hint,
|
|
90
|
+
keywords: ["settings", "config", "configure", "preferences", "options", s.id, s.label],
|
|
91
|
+
run: () => openSettings(s.id)
|
|
92
|
+
});
|
|
93
|
+
}
|
|
91
94
|
}
|
|
92
95
|
out.push({
|
|
93
96
|
key: "theme:toggle",
|
|
@@ -37,10 +37,17 @@ export interface JunResolvedDoc {
|
|
|
37
37
|
docId?: string;
|
|
38
38
|
/** Set when the slug is a FORMER address — the page emits a 301 to it. */
|
|
39
39
|
canonical?: string | null;
|
|
40
|
+
/**
|
|
41
|
+
* The server withheld this document's contents because it is owner-only.
|
|
42
|
+
* Stated rather than inferred: the endpoint blanks `meta`, so the predicate
|
|
43
|
+
* that would otherwise detect it (`meta.siteConfig`, `meta.campfire`) has
|
|
44
|
+
* nothing left to read. `type` alone only catches the config document.
|
|
45
|
+
*/
|
|
46
|
+
ownerOnly?: boolean;
|
|
40
47
|
title?: string | null;
|
|
41
48
|
type?: string;
|
|
42
49
|
meta?: Record<string, unknown>;
|
|
43
|
-
html?: string;
|
|
50
|
+
html?: string | null;
|
|
44
51
|
}
|
|
45
52
|
export type JunLayoutBucket = 'immersive' | 'panel' | 'flowing';
|
|
46
53
|
/** `useFetch` hands back `T | undefined`; a plain ref may hold `null`. Take both. */
|
|
@@ -60,10 +60,12 @@ export function useJunDocPage(docId, options = {}) {
|
|
|
60
60
|
});
|
|
61
61
|
const { data: ssrConfig } = useNuxtData("jun-site-config");
|
|
62
62
|
const siteConfig = computed(() => ssrConfig.value ?? {});
|
|
63
|
-
const ownerOnly = computed(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
const ownerOnly = computed(
|
|
64
|
+
() => resolved?.value?.ownerOnly === true || isJunOwnerOnlyDoc(entry.value ?? {
|
|
65
|
+
type: resolved?.value?.type,
|
|
66
|
+
meta: resolved?.value?.meta
|
|
67
|
+
})
|
|
68
|
+
);
|
|
67
69
|
useHead({
|
|
68
70
|
// `undefined`, NOT the site name, when there is no document title of our
|
|
69
71
|
// own. `JunHead`'s titleTemplate already falls back to the site name for
|
|
@@ -24,12 +24,13 @@ export function useJunRename() {
|
|
|
24
24
|
}
|
|
25
25
|
function docIdForAlias(slug) {
|
|
26
26
|
if (!slug) return null;
|
|
27
|
-
|
|
28
|
-
if (entry.trashed)
|
|
27
|
+
const claimants = tree.entries.value.filter((entry) => {
|
|
28
|
+
if (entry.trashed) return false;
|
|
29
29
|
const aliases = entry.meta?.slugAliases;
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
30
|
+
return Array.isArray(aliases) && aliases.includes(slug);
|
|
31
|
+
});
|
|
32
|
+
if (!claimants.length) return null;
|
|
33
|
+
return [...claimants].sort((a, b) => (a.createdAt ?? 0) - (b.createdAt ?? 0) || (a.id < b.id ? -1 : 1))[0].id;
|
|
33
34
|
}
|
|
34
35
|
return { renameDoc, docIdForAlias };
|
|
35
36
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type JunSettingsSection = 'identity' | 'navigation' | 'mark' | 'theme' | 'announcement' | 'campfire' | 'footer' | 'visitors';
|
|
2
|
+
export interface JunSettingsSectionDef {
|
|
3
|
+
id: JunSettingsSection;
|
|
4
|
+
label: string;
|
|
5
|
+
icon: string;
|
|
6
|
+
/** One line, shown under the label on the mobile list. */
|
|
7
|
+
hint: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Order is the reading order of the old stacked page, deliberately: an owner
|
|
11
|
+
* who knew where a control was should still find it in the same neighbourhood.
|
|
12
|
+
*/
|
|
13
|
+
export declare const JUN_SETTINGS_SECTIONS: JunSettingsSectionDef[];
|
|
14
|
+
export declare function useJunSettings(): {
|
|
15
|
+
open: import("vue").Ref<boolean, boolean>;
|
|
16
|
+
section: import("vue").Ref<JunSettingsSection, JunSettingsSection>;
|
|
17
|
+
drilled: import("vue").Ref<boolean, boolean>;
|
|
18
|
+
activeSection: import("vue").ComputedRef<JunSettingsSectionDef>;
|
|
19
|
+
sections: JunSettingsSectionDef[];
|
|
20
|
+
openSettings: (to?: JunSettingsSection) => void;
|
|
21
|
+
closeSettings: () => void;
|
|
22
|
+
selectSection: (to: JunSettingsSection) => void;
|
|
23
|
+
backToList: () => void;
|
|
24
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
export const JUN_SETTINGS_SECTIONS = [
|
|
3
|
+
{ id: "identity", label: "Identity", icon: "i-lucide-fingerprint", hint: "Name, description, search" },
|
|
4
|
+
{ id: "navigation", label: "Navigation", icon: "i-lucide-navigation", hint: "Placement, shape, behaviour" },
|
|
5
|
+
{ id: "mark", label: "Mark", icon: "i-lucide-hexagon", hint: "The logo and how it reads" },
|
|
6
|
+
{ id: "theme", label: "Theme", icon: "i-lucide-palette", hint: "Colour, type, backdrop, surface" },
|
|
7
|
+
{ id: "announcement", label: "Announcement", icon: "i-lucide-megaphone", hint: "The ribbon across the top" },
|
|
8
|
+
{ id: "campfire", label: "User center", icon: "i-lucide-flame", hint: "Chat, presence, reactions" },
|
|
9
|
+
{ id: "footer", label: "Footer", icon: "i-lucide-panel-bottom", hint: "The line at the bottom" },
|
|
10
|
+
{ id: "visitors", label: "Visitors", icon: "i-lucide-users", hint: "Guestbook, feeds, people" }
|
|
11
|
+
];
|
|
12
|
+
const DEFAULT_SECTION = "identity";
|
|
13
|
+
const open = ref(false);
|
|
14
|
+
const section = ref(DEFAULT_SECTION);
|
|
15
|
+
const drilled = ref(false);
|
|
16
|
+
export function useJunSettings() {
|
|
17
|
+
function openSettings(to) {
|
|
18
|
+
if (to) {
|
|
19
|
+
section.value = to;
|
|
20
|
+
drilled.value = true;
|
|
21
|
+
}
|
|
22
|
+
open.value = true;
|
|
23
|
+
}
|
|
24
|
+
function closeSettings() {
|
|
25
|
+
open.value = false;
|
|
26
|
+
}
|
|
27
|
+
function selectSection(to) {
|
|
28
|
+
section.value = to;
|
|
29
|
+
drilled.value = true;
|
|
30
|
+
}
|
|
31
|
+
function backToList() {
|
|
32
|
+
drilled.value = false;
|
|
33
|
+
}
|
|
34
|
+
const activeSection = computed(
|
|
35
|
+
() => JUN_SETTINGS_SECTIONS.find((s) => s.id === section.value) ?? JUN_SETTINGS_SECTIONS[0]
|
|
36
|
+
);
|
|
37
|
+
return {
|
|
38
|
+
open,
|
|
39
|
+
section,
|
|
40
|
+
drilled,
|
|
41
|
+
activeSection,
|
|
42
|
+
sections: JUN_SETTINGS_SECTIONS,
|
|
43
|
+
openSettings,
|
|
44
|
+
closeSettings,
|
|
45
|
+
selectSection,
|
|
46
|
+
backToList
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -1,30 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* useJunSiteConfig — the site's configuration,
|
|
2
|
+
* useJunSiteConfig — the site's configuration, stored on the SPACE DOCUMENT.
|
|
3
3
|
*
|
|
4
4
|
* > **The `Jun` prefix is load-bearing.** `nuxt-site-config` (pulled in by
|
|
5
5
|
* > `nuxt-og-image`, among others) auto-imports its own `useSiteConfig`, which
|
|
6
6
|
* > shadows an unprefixed composable of that name and crashes SSR with "Cannot
|
|
7
7
|
* > read properties of undefined". Do not rename this to `useSiteConfig`.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* `
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* and the
|
|
9
|
+
* ## Where it lives, and why it moved
|
|
10
|
+
*
|
|
11
|
+
* The website builder is ONE space, so the site's settings belong to the space
|
|
12
|
+
* document — not to a sibling of the pages. They live under a single key,
|
|
13
|
+
* `meta.junSite`, on the tree's SELF-DESCRIPTOR entry (the entry whose id IS
|
|
14
|
+
* `spaceDocId`), which is the same entry that already carries the root page's
|
|
15
|
+
* label and page type.
|
|
16
|
+
*
|
|
17
|
+
* It used to be a hidden `jun-config` document parented to the space root, and
|
|
18
|
+
* essentially every sharp edge in this file came from that separateness:
|
|
19
|
+
*
|
|
20
|
+
* - the client's tree does not necessarily CARRY a hidden top-level document,
|
|
21
|
+
* so `config` resolved to `{}` on every page except the settings page — the
|
|
22
|
+
* whole reason `useJunEffectiveConfig()` had to exist;
|
|
23
|
+
* - a config document created before the space id was known was born
|
|
24
|
+
* unparented, so there was a healer;
|
|
25
|
+
* - two config documents could exist, so both sides needed the same
|
|
26
|
+
* tie-break rule to avoid reading different ones;
|
|
27
|
+
* - it had to be kept out of search, the sitemap and the feeds by a predicate.
|
|
28
|
+
*
|
|
29
|
+
* The space document is always synced, always singular, and always correctly
|
|
30
|
+
* placed. All four problems are gone by construction.
|
|
31
|
+
*
|
|
32
|
+
* **Nesting under one key is deliberate.** The root is also a real page — `/`
|
|
33
|
+
* renders it, and it has a label, an icon, a description, `slugAliases`. Sixty
|
|
34
|
+
* config keys spread flat across that meta would collide with page meta and be
|
|
35
|
+
* indistinguishable from it. `junSite` is in `metaExcludeKeys`, so the editor
|
|
36
|
+
* never materialises the configuration as meta chips on the home page.
|
|
37
|
+
*
|
|
38
|
+
* **Nesting costs nothing in merge granularity**, which is the objection to
|
|
39
|
+
* expect. `useChildTree.updateMeta` is already a read-modify-write of the whole
|
|
40
|
+
* tree ENTRY (`treeMap.set(id, { ...entry, meta: { ...entry.meta, ...patch } })`)
|
|
41
|
+
* — a tree entry is a plain JSON value in a Y.Map, not a nested Y.Map. Two
|
|
42
|
+
* owners changing two different settings concurrently already resolved
|
|
43
|
+
* last-writer-wins before this change, and still do.
|
|
44
|
+
*
|
|
45
|
+
* `ensure()` find-or-creates the self-descriptor entry and REFUSES to act until
|
|
46
|
+
* the space document id is known. `useJunSiteConfigMigration()` moves a legacy
|
|
47
|
+
* `jun-config` document's values across on the owner's next visit.
|
|
28
48
|
*/
|
|
29
49
|
import { type ComputedRef } from 'vue';
|
|
30
50
|
import type { TreeEntry } from '@abraca/nuxt';
|
|
@@ -163,6 +183,17 @@ export interface JunSiteConfig {
|
|
|
163
183
|
notFoundText?: string;
|
|
164
184
|
[k: string]: unknown;
|
|
165
185
|
}
|
|
186
|
+
/** The one meta key on the space document that holds the whole configuration. */
|
|
187
|
+
export declare const JUN_SITE_CONFIG_KEY = "junSite";
|
|
188
|
+
/**
|
|
189
|
+
* Read a space document's tree entry as a config map.
|
|
190
|
+
*
|
|
191
|
+
* Exported because the server reads the SAME shape out of the doc cache and
|
|
192
|
+
* must not invent its own idea of where the values are.
|
|
193
|
+
*/
|
|
194
|
+
export declare function junConfigFromEntry(entry: {
|
|
195
|
+
meta?: Record<string, unknown>;
|
|
196
|
+
} | undefined | null): JunSiteConfig;
|
|
166
197
|
export declare function useJunSiteConfig(): {
|
|
167
198
|
docId: ComputedRef<string | null>;
|
|
168
199
|
candidates: ComputedRef<TreeEntry[]>;
|
|
@@ -216,14 +247,25 @@ export declare function useJunSiteConfig(): {
|
|
|
216
247
|
*/
|
|
217
248
|
export declare function useJunEffectiveConfig(): ComputedRef<JunSiteConfig>;
|
|
218
249
|
/**
|
|
219
|
-
*
|
|
250
|
+
* Move a legacy `jun-config` document's values onto the space document, then
|
|
251
|
+
* retire it. Runs live, on the owner's next visit; visitors keep reading the
|
|
252
|
+
* legacy document through `config`'s merge until it does.
|
|
253
|
+
*
|
|
254
|
+
* This replaces the old healer, whose two jobs — reparenting strays and merging
|
|
255
|
+
* duplicate config documents — are both moot now that there is exactly one
|
|
256
|
+
* possible location for the configuration.
|
|
257
|
+
*
|
|
258
|
+
* Three properties this has to have, and each one is a way it could go wrong:
|
|
220
259
|
*
|
|
221
|
-
* -
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
260
|
+
* - **Idempotent.** It runs on every owner load; a second pass must be a
|
|
261
|
+
* no-op, or a setting cleared after the first migration would be resurrected
|
|
262
|
+
* by the next one. Hence the write happens only while a legacy document is
|
|
263
|
+
* still live, and the document is trashed in the same pass.
|
|
264
|
+
* - **The space document WINS.** Anything already configured there was set
|
|
265
|
+
* after the move and is newer than anything in the legacy document.
|
|
266
|
+
* - **One write per document.** Peers watch this tree; a config half-copied
|
|
267
|
+
* across two ticks is what every one of them renders in between.
|
|
226
268
|
*
|
|
227
269
|
* Mount once, in the layout.
|
|
228
270
|
*/
|
|
229
|
-
export declare function
|
|
271
|
+
export declare function useJunSiteConfigMigration(): void;
|
|
@@ -1,94 +1,103 @@
|
|
|
1
1
|
import { computed, watch } from "vue";
|
|
2
|
-
import { useNuxtData } from "#app";
|
|
3
|
-
import { useAbracadabra, useChildTree, useDocTree } from "#imports";
|
|
2
|
+
import { useNuxtData, useState } from "#app";
|
|
3
|
+
import { useAbracadabra, useChildTree, useDocTree, useJunBrand } from "#imports";
|
|
4
|
+
import { JUN_SITE_CONFIG_STATE } from "../plugins/jun-site-config.js";
|
|
4
5
|
import { useJunStudio } from "./useJunStudio.js";
|
|
6
|
+
export const JUN_SITE_CONFIG_KEY = "junSite";
|
|
7
|
+
export function junConfigFromEntry(entry) {
|
|
8
|
+
const nested = entry?.meta?.[JUN_SITE_CONFIG_KEY];
|
|
9
|
+
return nested && typeof nested === "object" ? nested : {};
|
|
10
|
+
}
|
|
5
11
|
export function useJunSiteConfig() {
|
|
6
12
|
const abra = useAbracadabra();
|
|
13
|
+
const brand = useJunBrand();
|
|
7
14
|
const { entries, getEntry } = useDocTree();
|
|
8
15
|
const tree = useChildTree(abra.doc, "jun-site-config");
|
|
16
|
+
const docId = computed(() => abra.spaceDocId.value ?? null);
|
|
9
17
|
const candidates = computed(
|
|
10
18
|
() => entries.value.filter(
|
|
11
19
|
(e) => e.meta?.siteConfig === true && !e.trashed
|
|
12
20
|
)
|
|
13
21
|
);
|
|
14
|
-
const
|
|
22
|
+
const legacyConfig = computed(() => {
|
|
15
23
|
const all = candidates.value;
|
|
16
|
-
if (all.length === 0) return
|
|
24
|
+
if (all.length === 0) return {};
|
|
17
25
|
const space = abra.spaceDocId.value;
|
|
18
26
|
const parented = space ? all.filter((e) => e.parentId === space) : [];
|
|
19
27
|
const pool = parented.length ? parented : all;
|
|
20
|
-
|
|
28
|
+
const winner = [...pool].sort((a, b) => (a.createdAt ?? 0) - (b.createdAt ?? 0) || (a.id < b.id ? -1 : 1))[0];
|
|
29
|
+
return winner.meta ?? {};
|
|
21
30
|
});
|
|
22
|
-
const config = computed(
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
const config = computed(() => ({
|
|
32
|
+
...legacyConfig.value,
|
|
33
|
+
...junConfigFromEntry(docId.value ? getEntry(docId.value) : void 0)
|
|
34
|
+
}));
|
|
25
35
|
function ensure() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const id = abra.spaceDocId.value;
|
|
37
|
+
if (!id) return null;
|
|
38
|
+
if (!tree.treeMap.get(id)) {
|
|
39
|
+
const now = Date.now();
|
|
40
|
+
tree.treeMap.set(id, {
|
|
41
|
+
// The brand name, NOT an empty string. This entry's label is the
|
|
42
|
+
// one-way MIRROR of the space's REST label — the REST value is the
|
|
43
|
+
// single authority — and seeding it blank would show the root page as
|
|
44
|
+
// "Untitled" until something else refreshed the mirror.
|
|
45
|
+
label: brand.value.name,
|
|
46
|
+
parentId: null,
|
|
47
|
+
order: 0,
|
|
48
|
+
type: "doc",
|
|
49
|
+
createdAt: now,
|
|
50
|
+
updatedAt: now
|
|
51
|
+
});
|
|
52
|
+
}
|
|
41
53
|
return id;
|
|
42
54
|
}
|
|
43
55
|
function set(patch) {
|
|
44
56
|
const id = ensure();
|
|
45
|
-
if (id)
|
|
57
|
+
if (!id) return;
|
|
58
|
+
const current = junConfigFromEntry(tree.treeMap.get(id));
|
|
59
|
+
tree.updateMeta(id, { [JUN_SITE_CONFIG_KEY]: { ...current, ...patch } });
|
|
46
60
|
}
|
|
47
61
|
return { docId, candidates, config, ensure, set };
|
|
48
62
|
}
|
|
49
63
|
export function useJunEffectiveConfig() {
|
|
50
64
|
const { config } = useJunSiteConfig();
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
const ssrState = useState(JUN_SITE_CONFIG_STATE, () => ({}));
|
|
66
|
+
const { data: ssrPayload } = useNuxtData("jun-site-config");
|
|
67
|
+
return computed(() => {
|
|
68
|
+
const seeded = ssrState.value;
|
|
69
|
+
const ssr = seeded && Object.keys(seeded).length ? seeded : ssrPayload.value ?? {};
|
|
70
|
+
return { ...ssr, ...config.value };
|
|
71
|
+
});
|
|
56
72
|
}
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
73
|
+
let migrationArmed = false;
|
|
74
|
+
const NON_CONFIG_KEYS = /* @__PURE__ */ new Set(["siteConfig", "hidden", "icon", "slugAliases", "order"]);
|
|
75
|
+
export function useJunSiteConfigMigration() {
|
|
76
|
+
if (import.meta.server || migrationArmed) return;
|
|
77
|
+
migrationArmed = true;
|
|
61
78
|
const abra = useAbracadabra();
|
|
62
79
|
const { canEdit } = useJunStudio();
|
|
63
80
|
const site = useJunSiteConfig();
|
|
64
|
-
const tree = useChildTree(abra.doc, "jun-site-config-
|
|
81
|
+
const tree = useChildTree(abra.doc, "jun-site-config-migration");
|
|
65
82
|
watch(
|
|
66
83
|
[() => site.candidates.value.length, () => abra.spaceDocId.value, canEdit],
|
|
67
84
|
() => {
|
|
68
85
|
const space = abra.spaceDocId.value;
|
|
69
86
|
if (!space || !canEdit.value) return;
|
|
70
87
|
if (site.candidates.value.length === 0) return;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
label: raw.label || "Site Config",
|
|
78
|
-
type: raw.type || "jun-config"
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
for (const dupe of site.candidates.value) {
|
|
82
|
-
if (dupe.id === canonicalId) continue;
|
|
83
|
-
const extraMeta = dupe.meta ?? {};
|
|
84
|
-
const canonicalMeta = tree.treeMap.get(canonicalId)?.meta ?? {};
|
|
85
|
-
const merged = {};
|
|
86
|
-
for (const [k, v] of Object.entries(extraMeta)) {
|
|
87
|
-
if (!(k in canonicalMeta) && k !== "siteConfig") merged[k] = v;
|
|
88
|
+
if (!site.ensure()) return;
|
|
89
|
+
const legacy = [...site.candidates.value].sort((a, b) => (a.createdAt ?? 0) - (b.createdAt ?? 0) || (a.id < b.id ? -1 : 1));
|
|
90
|
+
const incoming = {};
|
|
91
|
+
for (const doc of legacy) {
|
|
92
|
+
for (const [k, v] of Object.entries(doc.meta ?? {})) {
|
|
93
|
+
if (!NON_CONFIG_KEYS.has(k)) incoming[k] = v;
|
|
88
94
|
}
|
|
89
|
-
if (Object.keys(merged).length) tree.updateMeta(canonicalId, merged);
|
|
90
|
-
tree.deleteEntry(dupe.id);
|
|
91
95
|
}
|
|
96
|
+
const current = junConfigFromEntry(
|
|
97
|
+
tree.treeMap.get(space)
|
|
98
|
+
);
|
|
99
|
+
tree.updateMeta(space, { [JUN_SITE_CONFIG_KEY]: { ...incoming, ...current } });
|
|
100
|
+
for (const doc of legacy) tree.deleteEntry(doc.id);
|
|
92
101
|
},
|
|
93
102
|
{ immediate: true }
|
|
94
103
|
);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare function useJunViewingAccent(): {
|
|
2
|
-
getViewers: (itemId: string | undefined | null) => import("#imports").PresenceUser[];
|
|
3
2
|
accentStyle: (id: string | undefined | null) => Record<string, string> | undefined;
|
|
4
3
|
accentInsetStyle: (id: string | undefined | null) => Record<string, string> | undefined;
|
|
5
4
|
accentTitle: (id: string | undefined | null) => string | undefined;
|
|
@@ -24,5 +24,5 @@ export function useJunViewingAccent() {
|
|
|
24
24
|
const others = viewers.length - 1;
|
|
25
25
|
return `${first} and ${others} ${others === 1 ? "other" : "others"} are reading this`;
|
|
26
26
|
}
|
|
27
|
-
return {
|
|
27
|
+
return { accentStyle, accentInsetStyle, accentTitle };
|
|
28
28
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
useJunOptions,
|
|
10
10
|
useJunPresenceBroadcast,
|
|
11
11
|
useJunRouteGeoHeal,
|
|
12
|
-
|
|
12
|
+
useJunSiteConfigMigration,
|
|
13
13
|
useJunSlugAliasTracker,
|
|
14
14
|
useJunStudio,
|
|
15
15
|
useJunThemeApply
|
|
@@ -35,7 +35,7 @@ const presenceBlobsLit = computed(() => {
|
|
|
35
35
|
const stored = effectiveConfig.value.presenceBlobs;
|
|
36
36
|
return typeof stored === "boolean" ? stored : true;
|
|
37
37
|
});
|
|
38
|
-
|
|
38
|
+
useJunSiteConfigMigration();
|
|
39
39
|
useJunSlugAliasTracker();
|
|
40
40
|
useJunRouteGeoHeal();
|
|
41
41
|
useJunThemeApply();
|
|
@@ -131,6 +131,22 @@ if (import.meta.client && contextMenu.suppressNative) {
|
|
|
131
131
|
|
|
132
132
|
<JunSearch v-if="features.search" />
|
|
133
133
|
|
|
134
|
+
<!-- The settings panel. Mounted once, here, for the same reason the player
|
|
135
|
+
is: the studio bar, the palette and `⌘,` all open it, and state living
|
|
136
|
+
inside it would unmount with whichever of them was on screen. It renders
|
|
137
|
+
nothing at all until an owner opens it.
|
|
138
|
+
|
|
139
|
+
> Adding this line used to break hydration in `JunNavigation`, several
|
|
140
|
+
> components ABOVE it. That was never about where it sits: it calls
|
|
141
|
+
> `useJunStudio()`, and that composable's `mounted` flip rode the
|
|
142
|
+
> `onMounted` of whichever component asked FIRST. One more client
|
|
143
|
+
> component reshuffled the order and moved the flip into the middle of
|
|
144
|
+
> hydration. Fixed in `useJunStudio` — see the note above its `mounted`
|
|
145
|
+
> ref — not by wrapping this. Wrapping it in `<ClientOnly>` made it
|
|
146
|
+
> measurably worse (98 console messages, the nav one item out of step),
|
|
147
|
+
> which is what pointed at shared state rather than node position. -->
|
|
148
|
+
<JunSettings />
|
|
149
|
+
|
|
134
150
|
<!-- Every renderer's media taps route here. Mounted once. -->
|
|
135
151
|
<JunImagePopup v-if="features.lightbox" />
|
|
136
152
|
|
|
@@ -24,15 +24,25 @@ function addChild() {
|
|
|
24
24
|
</script>
|
|
25
25
|
|
|
26
26
|
<template>
|
|
27
|
-
<!-- The root doc resolves from the live CRDT connection, so this branch is
|
|
28
|
-
client-only and the ambient backdrop fills the pre-connect window.
|
|
29
|
-
Unlike `doc.vue` there is no slug to resolve server-side, so there is no
|
|
30
|
-
cached-HTML fallback to emit here — the root's SSR is the layout chrome
|
|
31
|
-
and the navigation. -->
|
|
32
|
-
<!-- Element root — see the note in `doc.vue`. A `<ClientOnly>` root is a
|
|
33
|
-
fragment, and the page transition cannot animate one, which breaks every
|
|
34
|
-
in-app navigation while first load still works. -->
|
|
35
27
|
<div class="jun-doc-root">
|
|
28
|
+
<!-- Element root — see the note in `doc.vue`. A `<ClientOnly>` root is a
|
|
29
|
+
fragment, and the page transition cannot animate one, which breaks
|
|
30
|
+
every in-app navigation while first load still works.
|
|
31
|
+
|
|
32
|
+
**The comments belong INSIDE it.** A template comment is a NODE as far
|
|
33
|
+
as Vue's single-root check is concerned, so two of them sitting in
|
|
34
|
+
front of the div made this page a fragment with an element in it —
|
|
35
|
+
Nuxt warned "does not have a single root node and will cause errors
|
|
36
|
+
when navigating between routes" on every load, about the one file
|
|
37
|
+
whose root node this codebase already knows is load-bearing. A
|
|
38
|
+
standing warning about the exact failure you are guarding against is
|
|
39
|
+
worse than no warning: it is the one you stop reading.
|
|
40
|
+
|
|
41
|
+
The root doc resolves from the live CRDT connection, so this branch is
|
|
42
|
+
client-only and the ambient backdrop fills the pre-connect window.
|
|
43
|
+
Unlike `doc.vue` there is no slug to resolve server-side, so there is
|
|
44
|
+
no cached-HTML fallback to emit here — the root's SSR is the layout
|
|
45
|
+
chrome and the navigation. -->
|
|
36
46
|
<ClientOnly>
|
|
37
47
|
<JunDocSurface
|
|
38
48
|
v-if="docId"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The STATE key readers use, and it is deliberately not the payload key.
|
|
3
|
+
*
|
|
4
|
+
* Seeding `payload.data[KEY]` alone was not enough. `<JunHead>` registers the
|
|
5
|
+
* same key through `useFetch`, and a reader calling `useNuxtData(KEY)` during
|
|
6
|
+
* render can observe that entry mid-lifecycle rather than the seeded value —
|
|
7
|
+
* measured, `data-jun-nav-mode` still came out `icon-stack` on some renders and
|
|
8
|
+
* `text` (the build default, i.e. an empty config) on others, with the payload
|
|
9
|
+
* key present in the HTML both times. A `useState` has no fetch lifecycle to be
|
|
10
|
+
* caught in the middle of: it holds a value from the moment this plugin runs.
|
|
11
|
+
*
|
|
12
|
+
* The payload entry is still written, so `useFetch` finds its cache and never
|
|
13
|
+
* issues a second request.
|
|
14
|
+
*/
|
|
15
|
+
export declare const JUN_SITE_CONFIG_STATE = "jun:site-config";
|
|
16
|
+
declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useRuntimeConfig, useState } from "#app";
|
|
2
|
+
const KEY = "jun-site-config";
|
|
3
|
+
export const JUN_SITE_CONFIG_STATE = "jun:site-config";
|
|
4
|
+
export default defineNuxtPlugin({
|
|
5
|
+
name: "jun:site-config",
|
|
6
|
+
enforce: "pre",
|
|
7
|
+
async setup(nuxtApp) {
|
|
8
|
+
const state = useState(JUN_SITE_CONFIG_STATE, () => ({}));
|
|
9
|
+
if (nuxtApp.payload.data[KEY] !== void 0) {
|
|
10
|
+
state.value = nuxtApp.payload.data[KEY] ?? {};
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const pub = useRuntimeConfig().public;
|
|
14
|
+
const apiBase = pub?.jun?.apiBase || "/api/_jun";
|
|
15
|
+
let value = {};
|
|
16
|
+
try {
|
|
17
|
+
const res = await $fetch(`${apiBase}/site-config`);
|
|
18
|
+
if (res && typeof res === "object" && !Array.isArray(res)) {
|
|
19
|
+
value = res;
|
|
20
|
+
}
|
|
21
|
+
} catch {
|
|
22
|
+
}
|
|
23
|
+
nuxtApp.payload.data[KEY] = value;
|
|
24
|
+
state.value = value;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
@@ -2,17 +2,31 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
|
|
|
2
2
|
found: false;
|
|
3
3
|
cacheReady: boolean;
|
|
4
4
|
docId?: undefined;
|
|
5
|
-
|
|
5
|
+
canonical?: undefined;
|
|
6
|
+
ownerOnly?: undefined;
|
|
6
7
|
type?: undefined;
|
|
8
|
+
title?: undefined;
|
|
7
9
|
meta?: undefined;
|
|
8
10
|
html?: undefined;
|
|
9
11
|
} | {
|
|
10
12
|
found: true;
|
|
11
13
|
cacheReady: boolean;
|
|
12
14
|
docId: string;
|
|
15
|
+
canonical: string | null;
|
|
16
|
+
ownerOnly: true;
|
|
17
|
+
type: string;
|
|
18
|
+
title: null;
|
|
19
|
+
meta: {};
|
|
20
|
+
html: null;
|
|
21
|
+
} | {
|
|
22
|
+
found: true;
|
|
23
|
+
cacheReady: boolean;
|
|
24
|
+
docId: string;
|
|
25
|
+
canonical: string | null;
|
|
13
26
|
title: string | null;
|
|
14
27
|
type: string;
|
|
15
28
|
meta: Record<string, unknown>;
|
|
16
29
|
html: string | null;
|
|
30
|
+
ownerOnly?: undefined;
|
|
17
31
|
}>>;
|
|
18
32
|
export default _default;
|