@abraca/junis 2.92.0 → 2.95.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 +27 -5
- package/dist/runtime/assets/css/jun.css +1 -1
- package/dist/runtime/components/JunDocSurface.vue +1 -1
- package/dist/runtime/components/JunHead.vue +35 -4
- package/dist/runtime/components/JunHorizontalTimeline.vue +1 -1
- package/dist/runtime/components/JunImagePopup.client.vue +7 -2
- package/dist/runtime/components/JunNavMenu.client.vue +3 -3
- package/dist/runtime/components/JunNavPreview.d.vue.ts +2 -1
- package/dist/runtime/components/JunNavPreview.vue +61 -1
- package/dist/runtime/components/JunNavPreview.vue.d.ts +2 -1
- package/dist/runtime/components/JunNavigation.vue +110 -4
- package/dist/runtime/components/JunNotFound.vue +1 -1
- package/dist/runtime/components/JunReaders.vue +1 -1
- package/dist/runtime/components/JunShell.vue +20 -3
- package/dist/runtime/components/JunStudioBar.client.vue +1 -1
- package/dist/runtime/components/renderers/JunConfigRenderer.vue +179 -0
- package/dist/runtime/components/renderers/JunGardenRenderer.vue +45 -8
- package/dist/runtime/components/renderers/JunHomeRenderer.vue +2 -2
- package/dist/runtime/composables/useJunMobile.d.ts +5 -0
- package/dist/runtime/composables/useJunMobile.js +56 -0
- package/dist/runtime/composables/useJunNavItems.js +22 -1
- package/dist/runtime/composables/useJunNavSettings.d.ts +8 -1
- package/dist/runtime/composables/useJunNavSettings.js +21 -1
- package/dist/runtime/composables/useJunOptions.d.ts +2 -2
- package/dist/runtime/composables/useJunSettings.d.ts +1 -1
- package/dist/runtime/composables/useJunSettings.js +4 -0
- package/dist/runtime/composables/useJunSiteConfig.d.ts +63 -2
- package/dist/runtime/composables/useJunTheme.js +3 -7
- package/dist/runtime/error.vue +2 -2
- package/dist/runtime/layouts/jun.vue +3 -1
- package/dist/runtime/pages/doc.vue +1 -1
- package/dist/runtime/pages/index.vue +1 -1
- package/dist/runtime/server/janitor/junJanitorActor.d.ts +40 -0
- package/dist/runtime/server/janitor/junJanitorActor.js +118 -3
- package/dist/runtime/server/janitor/junJanitorMachine.js +25 -2
- package/dist/runtime/server/janitor/junJanitorStore.d.ts +30 -6
- package/dist/runtime/server/janitor/junJanitorStore.js +32 -15
- package/dist/runtime/server/plugins/jun-doc-cache.js +6 -8
- package/dist/runtime/server/plugins/jun-janitor.js +7 -0
- package/dist/runtime/server/routes/manifest.webmanifest.get.js +18 -0
- package/dist/runtime/types.d.ts +56 -2
- package/dist/runtime/utils/junIdentity.d.ts +13 -0
- package/dist/runtime/utils/junIdentity.js +7 -3
- package/dist/runtime/utils/junMark.d.ts +35 -0
- package/dist/runtime/utils/junMark.js +11 -0
- package/dist/runtime/utils/junNavValue.js +8 -1
- package/package.json +2 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { computed, onScopeDispose, watch } from "vue";
|
|
2
|
+
import { useHead } from "#app";
|
|
3
|
+
import { useJunEffectiveConfig } from "./useJunSiteConfig.js";
|
|
4
|
+
import { useJunOptions } from "./useJunOptions.js";
|
|
5
|
+
const STANDALONE_BOOT = `try{var d=document.documentElement,m=window.matchMedia;if(navigator.standalone===true||(m&&(m('(display-mode: standalone)').matches||m('(display-mode: fullscreen)').matches||m('(display-mode: minimal-ui)').matches)))d.setAttribute('data-jun-standalone','')}catch(e){}`;
|
|
6
|
+
function junZoomMode(stored, lockZoom) {
|
|
7
|
+
if (stored === "on" || stored === "app" || stored === "off") return stored;
|
|
8
|
+
return lockZoom ? "off" : "on";
|
|
9
|
+
}
|
|
10
|
+
function junStatusBarMode(stored) {
|
|
11
|
+
return stored === "auto" || stored === "contrast" || stored === "none" ? stored : "auto";
|
|
12
|
+
}
|
|
13
|
+
export function useJunMobile() {
|
|
14
|
+
const { features } = useJunOptions();
|
|
15
|
+
const config = useJunEffectiveConfig();
|
|
16
|
+
const zoom = computed(() => junZoomMode(config.value.mobileZoom, features.lockZoom === true));
|
|
17
|
+
const statusBar = computed(() => junStatusBarMode(config.value.mobileStatusBar));
|
|
18
|
+
const zoomAttr = computed(() => zoom.value === "on" ? void 0 : zoom.value === "off" ? "locked" : "app");
|
|
19
|
+
const pullAttr = computed(() => config.value.mobilePullRefresh === true ? "on" : "off");
|
|
20
|
+
const selectAttr = computed(() => {
|
|
21
|
+
const v = config.value.mobileChromeSelect;
|
|
22
|
+
return v === true ? "on" : v === false ? "off" : void 0;
|
|
23
|
+
});
|
|
24
|
+
useHead({
|
|
25
|
+
htmlAttrs: {
|
|
26
|
+
"data-jun-zoom": zoomAttr,
|
|
27
|
+
"data-jun-statusbar": statusBar,
|
|
28
|
+
"data-jun-pull": pullAttr,
|
|
29
|
+
"data-jun-select": selectAttr
|
|
30
|
+
},
|
|
31
|
+
script: [{
|
|
32
|
+
key: "jun-standalone",
|
|
33
|
+
innerHTML: STANDALONE_BOOT,
|
|
34
|
+
tagPosition: "head"
|
|
35
|
+
}]
|
|
36
|
+
});
|
|
37
|
+
if (import.meta.client) {
|
|
38
|
+
const block = (e) => e.preventDefault();
|
|
39
|
+
const EVENTS = ["gesturestart", "gesturechange", "gestureend"];
|
|
40
|
+
let bound = false;
|
|
41
|
+
const bind = (on) => {
|
|
42
|
+
if (on === bound) return;
|
|
43
|
+
bound = on;
|
|
44
|
+
for (const name of EVENTS) {
|
|
45
|
+
if (on) document.addEventListener(name, block, { passive: false });
|
|
46
|
+
else document.removeEventListener(name, block);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
watch(zoom, (mode) => {
|
|
50
|
+
const standalone = document.documentElement.hasAttribute("data-jun-standalone");
|
|
51
|
+
bind(mode === "off" || mode === "app" && standalone);
|
|
52
|
+
}, { immediate: true });
|
|
53
|
+
onScopeDispose(() => bind(false));
|
|
54
|
+
}
|
|
55
|
+
return { zoom, statusBar };
|
|
56
|
+
}
|
|
@@ -48,7 +48,28 @@ export function useJunNavItems(items, options = {}) {
|
|
|
48
48
|
id: e.id,
|
|
49
49
|
name: e.label || "Untitled",
|
|
50
50
|
href: getDocUrl(e.id),
|
|
51
|
-
|
|
51
|
+
/*
|
|
52
|
+
* RESOLVED, the same way a top-level item's is — and it was neither.
|
|
53
|
+
*
|
|
54
|
+
* Two faults stood on top of each other and the symptom was one thing:
|
|
55
|
+
* the sub-page flyout, the mobile menu and the dock's `⋯` list all
|
|
56
|
+
* rendered without icons.
|
|
57
|
+
*
|
|
58
|
+
* 1. `meta.icon` is stored BARE by project convention (`book-open`),
|
|
59
|
+
* and Iconify needs the collection (`i-lucide-book-open`). A bare
|
|
60
|
+
* name resolves to no collection and paints NOTHING — no error, no
|
|
61
|
+
* placeholder, an empty box. The track normalises in `JunShell`;
|
|
62
|
+
* this list never did.
|
|
63
|
+
* 2. There was no page-TYPE fallback. A top-level item without its own
|
|
64
|
+
* `meta.icon` gets its type's registered icon through `iconFor`;
|
|
65
|
+
* a child got `undefined`, and the template's `v-if="child.icon"`
|
|
66
|
+
* dropped it. Since most pages never have an icon set by hand, that
|
|
67
|
+
* was nearly every child on nearly every site.
|
|
68
|
+
*
|
|
69
|
+
* `docIcon` is the one function that does both, and it is already what
|
|
70
|
+
* `iconFor` calls for the items above.
|
|
71
|
+
*/
|
|
72
|
+
icon: docIcon(e.type, e.meta?.icon),
|
|
52
73
|
type: e.type
|
|
53
74
|
}));
|
|
54
75
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JunNavActiveStyle, JunNavAlign, JunNavBreakpoint, JunNavChildrenMode, JunNavItemMode, JunNavLogoAction, JunNavMenuIcon, JunNavMenuSide, JunNavMobileItemMode, JunNavMobileMode, JunNavMobilePlacement, JunNavOverflow, JunNavPlacement, JunNavRailBreakpoint, JunNavCountMode, JunNavSectionMode, JunNavShape, JunNavSize, JunNavWidth } from '../types.js';
|
|
1
|
+
import type { JunNavActiveStyle, JunNavAlign, JunNavBreakpoint, JunNavChildrenMode, JunNavItemMode, JunNavLogoAction, JunNavMenuIcon, JunNavMenuSide, JunNavMobileBar, JunNavMobileItemMode, JunNavMobileMode, JunNavMobilePlacement, JunNavMobileTitle, JunNavOverflow, JunNavPlacement, JunNavRailBreakpoint, JunNavCountMode, JunNavSectionMode, JunNavShape, JunNavSize, JunNavWidth } from '../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* The pixel width of each breakpoint, for the ONE consumer that cannot use a
|
|
4
4
|
* Tailwind class: `useMediaQuery`. Everything that can express the switch in
|
|
@@ -67,6 +67,13 @@ export declare function useJunNavSettings(): {
|
|
|
67
67
|
*/
|
|
68
68
|
mobileMode: import("vue").ComputedRef<JunNavMobileMode>;
|
|
69
69
|
mobilePlacement: import("vue").ComputedRef<JunNavMobilePlacement>;
|
|
70
|
+
/**
|
|
71
|
+
* What the phone bar IS, as opposed to what the phone MENU is. Separated
|
|
72
|
+
* because they were conflated: five of the seven `mobileMode` values
|
|
73
|
+
* rendered a byte-identical bar, and only the overlay behind it differed.
|
|
74
|
+
*/
|
|
75
|
+
mobileBar: import("vue").ComputedRef<JunNavMobileBar>;
|
|
76
|
+
mobileTitle: import("vue").ComputedRef<JunNavMobileTitle>;
|
|
70
77
|
breakpoint: import("vue").ComputedRef<JunNavBreakpoint>;
|
|
71
78
|
railBreakpoint: import("vue").ComputedRef<JunNavRailBreakpoint>;
|
|
72
79
|
menuIcon: import("vue").ComputedRef<JunNavMenuIcon>;
|
|
@@ -14,6 +14,8 @@ const COUNT_MODES = ["off", "children", "new"];
|
|
|
14
14
|
const SECTION_MODES = ["off", "row", "segmented", "tabs"];
|
|
15
15
|
const MOBILE_MODES = ["track", "sheet", "drawer-left", "drawer-right", "fullscreen", "grid", "dock"];
|
|
16
16
|
const MOBILE_PLACEMENTS = ["inherit", "top", "top-bar", "bottom"];
|
|
17
|
+
const MOBILE_BARS = ["bar", "inset", "edge", "split", "float", "none"];
|
|
18
|
+
const MOBILE_TITLES = ["off", "page", "site"];
|
|
17
19
|
const BREAKPOINTS = ["sm", "md", "lg"];
|
|
18
20
|
const RAIL_BREAKPOINTS = ["lg", "md", "xl"];
|
|
19
21
|
const MENU_ICONS = ["menu", "grid", "dots", "chevron"];
|
|
@@ -35,12 +37,13 @@ export function useJunNavSettings() {
|
|
|
35
37
|
const abra = useAbracadabra();
|
|
36
38
|
const { getEntry } = useDocTree();
|
|
37
39
|
const { docId } = useSlugRoute();
|
|
40
|
+
const preview = computed(() => junNavPreview(route.query["jun-nav"]));
|
|
38
41
|
const docNav = computed(() => {
|
|
39
42
|
const id = docId.value ?? (route.path === "/" ? abra.spaceDocId.value : null);
|
|
40
43
|
if (!id) return {};
|
|
41
44
|
const view = getEntry(id)?.meta?.junView;
|
|
42
45
|
const stored = view && typeof view === "object" ? view : {};
|
|
43
|
-
return { ...stored, ...
|
|
46
|
+
return { ...stored, ...preview.value };
|
|
44
47
|
});
|
|
45
48
|
const config = useJunEffectiveConfig();
|
|
46
49
|
function pick(stored, allowed, fallback, doc) {
|
|
@@ -119,6 +122,23 @@ export function useJunNavSettings() {
|
|
|
119
122
|
*/
|
|
120
123
|
mobileMode,
|
|
121
124
|
mobilePlacement: computed(() => pick(config.value.navMobilePlacement, MOBILE_PLACEMENTS, navigation.mobilePlacement)),
|
|
125
|
+
/**
|
|
126
|
+
* What the phone bar IS, as opposed to what the phone MENU is. Separated
|
|
127
|
+
* because they were conflated: five of the seven `mobileMode` values
|
|
128
|
+
* rendered a byte-identical bar, and only the overlay behind it differed.
|
|
129
|
+
*/
|
|
130
|
+
/*
|
|
131
|
+
* `?jun-nav=bar:float` outranks the stored value, and writes nothing.
|
|
132
|
+
*
|
|
133
|
+
* Read from the preview OBJECT rather than from `docNav`, because these two
|
|
134
|
+
* have no document layer and must not gain one: a page deciding the site
|
|
135
|
+
* has no navigation is not a state any site should be able to reach by
|
|
136
|
+
* accident. The preview exists for the same reason it does for the mobile
|
|
137
|
+
* mode — an owner comparing shapes without saving one, and a suite that is
|
|
138
|
+
* a VISITOR and cannot change a site's settings at all.
|
|
139
|
+
*/
|
|
140
|
+
mobileBar: computed(() => pick(config.value.navMobileBar, MOBILE_BARS, navigation.mobileBar, preview.value.navMobileBar)),
|
|
141
|
+
mobileTitle: computed(() => pick(config.value.navMobileTitle, MOBILE_TITLES, navigation.mobileTitle, preview.value.navMobileTitle)),
|
|
122
142
|
breakpoint: computed(() => pick(config.value.navBreakpoint, BREAKPOINTS, navigation.breakpoint)),
|
|
123
143
|
railBreakpoint: computed(() => pick(config.value.navRailBreakpoint, RAIL_BREAKPOINTS, navigation.railBreakpoint)),
|
|
124
144
|
menuIcon: computed(() => pick(config.value.navMenuIcon, MENU_ICONS, navigation.menuIcon)),
|
|
@@ -9,9 +9,9 @@ export declare function useJunBrand(): import("vue").ComputedRef<{
|
|
|
9
9
|
avatar: string;
|
|
10
10
|
logoMark: import("../types.js").JunLogoMark;
|
|
11
11
|
logoVariant: import("../types.js").JunLogoVariant;
|
|
12
|
-
themeColor
|
|
12
|
+
themeColor?: string;
|
|
13
13
|
lang: string;
|
|
14
|
-
iconBackground
|
|
14
|
+
iconBackground?: string;
|
|
15
15
|
schemaType: import("../types.js").JunBrand["schemaType"];
|
|
16
16
|
}>;
|
|
17
17
|
/** Site-wide feature flags. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type JunSettingsSection = 'identity' | 'navigation' | 'mark' | 'theme' | 'announcement' | 'campfire' | 'footer' | 'visitors' | 'offline' | 'renderers';
|
|
1
|
+
export type JunSettingsSection = 'identity' | 'navigation' | 'mark' | 'theme' | 'announcement' | 'campfire' | 'footer' | 'mobile' | 'visitors' | 'offline' | 'renderers';
|
|
2
2
|
export interface JunSettingsSectionDef {
|
|
3
3
|
id: JunSettingsSection;
|
|
4
4
|
label: string;
|
|
@@ -7,6 +7,10 @@ export const JUN_SETTINGS_SECTIONS = [
|
|
|
7
7
|
{ id: "announcement", label: "Announcement", icon: "i-lucide-megaphone", hint: "The ribbon across the top" },
|
|
8
8
|
{ id: "campfire", label: "User center", icon: "i-lucide-flame", hint: "Chat, presence, reactions" },
|
|
9
9
|
{ id: "footer", label: "Footer", icon: "i-lucide-panel-bottom", hint: "The line at the bottom" },
|
|
10
|
+
// Before Visitors, because it is about the DEVICE a visitor arrives on rather
|
|
11
|
+
// than about what they may contribute. It is also the only section whose
|
|
12
|
+
// effects most owners will never see on the machine they configure them from.
|
|
13
|
+
{ id: "mobile", label: "Mobile", icon: "i-lucide-smartphone", hint: "Phones, and the installed app" },
|
|
10
14
|
{ id: "visitors", label: "Visitors", icon: "i-lucide-users", hint: "Guestbook, feeds, people" },
|
|
11
15
|
// After Visitors, because it is about what a visitor may take away with them.
|
|
12
16
|
{ id: "offline", label: "Offline", icon: "i-lucide-cloud-download", hint: "What a reader may keep on their device" },
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
*/
|
|
49
49
|
import { type ComputedRef } from 'vue';
|
|
50
50
|
import type { TreeEntry } from '@abraca/nuxt';
|
|
51
|
-
import type { JunBackdropKind, JunBackgroundFit, JunCampfirePillMode, JunCampfirePlacement, JunCampfireRosterStyle, JunCampfireSize, JunCampfireTab, JunNavActiveStyle, JunNavAlign, JunNavBreakpoint, JunNavChildrenMode, JunNavItemMode, JunNavLogoAction, JunNavMenuIcon, JunNavMenuSide, JunNavMobileItemMode, JunNavMobileMode, JunNavMobilePlacement, JunNavOverflow, JunNavPlacement, JunNavCountMode, JunNavSectionMode, JunNavRailBreakpoint, JunNavShape, JunNavSize, JunNavWidth } from '../types.js';
|
|
52
|
-
export type { JunBackdropKind, JunBackgroundFit, JunCampfirePillMode, JunCampfirePlacement, JunCampfireRosterStyle, JunCampfireSize, JunCampfireTab, JunNavActiveStyle, JunNavAlign, JunNavBreakpoint, JunNavChildrenMode, JunNavItemMode, JunNavLogoAction, JunNavMenuIcon, JunNavMenuSide, JunNavMobileItemMode, JunNavMobileMode, JunNavMobilePlacement, JunNavOverflow, JunNavPlacement, JunNavRailBreakpoint, JunNavShape, JunNavSize, JunNavWidth, } from '../types.js';
|
|
51
|
+
import type { JunBackdropKind, JunBackgroundFit, JunCampfirePillMode, JunCampfirePlacement, JunCampfireRosterStyle, JunCampfireSize, JunCampfireTab, JunNavActiveStyle, JunNavAlign, JunNavBreakpoint, JunNavChildrenMode, JunNavItemMode, JunNavLogoAction, JunNavMenuIcon, JunNavMenuSide, JunNavMobileBar, JunNavMobileItemMode, JunNavMobileMode, JunNavMobilePlacement, JunNavMobileTitle, JunNavOverflow, JunNavPlacement, JunNavCountMode, JunNavSectionMode, JunNavRailBreakpoint, JunNavShape, JunNavSize, JunNavWidth } from '../types.js';
|
|
52
|
+
export type { JunBackdropKind, JunBackgroundFit, JunCampfirePillMode, JunCampfirePlacement, JunCampfireRosterStyle, JunCampfireSize, JunCampfireTab, JunNavActiveStyle, JunNavAlign, JunNavBreakpoint, JunNavChildrenMode, JunNavItemMode, JunNavLogoAction, JunNavMenuIcon, JunNavMenuSide, JunNavMobileBar, JunNavMobileItemMode, JunNavMobileMode, JunNavMobilePlacement, JunNavMobileTitle, JunNavOverflow, JunNavPlacement, JunNavRailBreakpoint, JunNavShape, JunNavSize, JunNavWidth, } from '../types.js';
|
|
53
53
|
export type JunThemeRadius = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
54
54
|
export type JunThemeAccent = 'mono' | 'sun' | 'blue' | 'emerald' | 'violet' | 'amber' | 'rose' | 'teal';
|
|
55
55
|
export type JunThemeNeutral = 'slate' | 'zinc' | 'stone';
|
|
@@ -68,6 +68,35 @@ export type JunThemeFont = 'default' | 'serif' | 'grotesk' | 'mono' | 'editorial
|
|
|
68
68
|
* control as much as a visual one — see the block at the end of `jun.css`.
|
|
69
69
|
*/
|
|
70
70
|
export type JunThemeSurface = 'glass' | 'soft' | 'solid';
|
|
71
|
+
/**
|
|
72
|
+
* Pinch zoom, in three answers rather than two.
|
|
73
|
+
*
|
|
74
|
+
* `on` is the default and the only one that is unambiguously correct as a
|
|
75
|
+
* default: blocking zoom is WCAG 1.4.4 (Resize Text), and a public website
|
|
76
|
+
* whose reader cannot enlarge it has failed a Level AA criterion.
|
|
77
|
+
*
|
|
78
|
+
* `app` is the interesting one, and it is why this is not a boolean. A page
|
|
79
|
+
* open in a browser is a PAGE — the reader's zoom, find-in-page and font size
|
|
80
|
+
* all apply, and taking any of them away is indefensible. The same site
|
|
81
|
+
* launched from the home screen is something they chose to install, has no
|
|
82
|
+
* browser chrome, and has every fixed layer in this module laid out against a
|
|
83
|
+
* viewport that pinch-zoom silently rescales. So: a page in a tab, an app on
|
|
84
|
+
* the home screen.
|
|
85
|
+
*
|
|
86
|
+
* `off` locks it everywhere, for a kiosk or a signage screen.
|
|
87
|
+
*/
|
|
88
|
+
export type JunMobileZoom = 'on' | 'app' | 'off';
|
|
89
|
+
/**
|
|
90
|
+
* What backs the iOS status bar in a standalone install.
|
|
91
|
+
*
|
|
92
|
+
* `auto` scrims it in LIGHT mode only — `black-translucent` forces the clock
|
|
93
|
+
* and the battery to white, which is right on a dark page and invisible on a
|
|
94
|
+
* pale one. `contrast` is the solid band, for a site whose top edge is busy
|
|
95
|
+
* enough that a scrim is not enough. `none` leaves the page's own colours to
|
|
96
|
+
* run all the way up, which is right for a site that is dark, or one whose
|
|
97
|
+
* pages open on a photograph.
|
|
98
|
+
*/
|
|
99
|
+
export type JunMobileStatusBar = 'auto' | 'contrast' | 'none';
|
|
71
100
|
export interface JunSiteConfig {
|
|
72
101
|
/** SEO */
|
|
73
102
|
seoTitle?: string;
|
|
@@ -109,6 +138,30 @@ export interface JunSiteConfig {
|
|
|
109
138
|
gesturePages?: boolean;
|
|
110
139
|
/** Swipe in from a screen edge to open the navigation menu. Unset means on. */
|
|
111
140
|
gestureEdge?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Mobile — how the site behaves on a phone, and how much of an APP it is
|
|
143
|
+
* when somebody adds it to their home screen.
|
|
144
|
+
*
|
|
145
|
+
* Every key here is applied live by `useJunMobile`, which writes the
|
|
146
|
+
* attributes `jun.css` keys off. `mobileZoom` additionally moves the viewport
|
|
147
|
+
* meta, which is the half only a fresh load can change.
|
|
148
|
+
*/
|
|
149
|
+
mobileZoom?: JunMobileZoom;
|
|
150
|
+
mobileStatusBar?: JunMobileStatusBar;
|
|
151
|
+
/**
|
|
152
|
+
* Pull down at the top of a page to reload it. Unset means OFF — an
|
|
153
|
+
* installed app that reloads when a reader over-scrolls is not an app, and
|
|
154
|
+
* over-scroll on the horizontal axis is off regardless, because on iOS a
|
|
155
|
+
* sideways flick over any wide element is the browser's back gesture.
|
|
156
|
+
*/
|
|
157
|
+
mobilePullRefresh?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Let a long press select the site's own CHROME — the navbar, the studio
|
|
160
|
+
* bar, the floating bars. Unset means off in an installed app (where a
|
|
161
|
+
* toolbar turning blue reads as a defect) and on in a browser tab.
|
|
162
|
+
* Page CONTENT always selects; this never touches prose.
|
|
163
|
+
*/
|
|
164
|
+
mobileChromeSelect?: boolean;
|
|
112
165
|
/** Navigation — every key falls back to the build-time `jun.navigation` default. */
|
|
113
166
|
navItemMode?: JunNavItemMode;
|
|
114
167
|
navActiveStyle?: JunNavActiveStyle;
|
|
@@ -138,6 +191,14 @@ export interface JunSiteConfig {
|
|
|
138
191
|
/** Mobile navigation — the menu that replaces the track below `navBreakpoint`. */
|
|
139
192
|
navMobileMode?: JunNavMobileMode;
|
|
140
193
|
navMobilePlacement?: JunNavMobilePlacement;
|
|
194
|
+
/**
|
|
195
|
+
* The phone BAR, as opposed to the phone MENU. `mobileMode` decides what
|
|
196
|
+
* opens; this decides whether there is a bar to open it from, and what shape
|
|
197
|
+
* it is. See `JunNavMobileBar` for why the two had to be separated.
|
|
198
|
+
*/
|
|
199
|
+
navMobileBar?: JunNavMobileBar;
|
|
200
|
+
/** What the phone bar names — nothing, the page's title, or the site's. */
|
|
201
|
+
navMobileTitle?: JunNavMobileTitle;
|
|
141
202
|
navBreakpoint?: JunNavBreakpoint;
|
|
142
203
|
navMenuIcon?: JunNavMenuIcon;
|
|
143
204
|
navMenuSide?: JunNavMenuSide;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed, watchEffect } from "vue";
|
|
2
2
|
import { useHead, useNuxtData } from "#app";
|
|
3
3
|
import { useJunSiteConfig } from "./useJunSiteConfig.js";
|
|
4
|
-
import { JUN_ACCENTS, junShade, junSunColors } from "../utils/junMark.js";
|
|
4
|
+
import { JUN_ACCENTS, JUN_NEUTRAL_STEPS, JUN_NEUTRALS, junShade, junSunColors } from "../utils/junMark.js";
|
|
5
5
|
import { junSetMotionFloor, junSetMotionLevel } from "../utils/junMotion.js";
|
|
6
6
|
const RADIUS = {
|
|
7
7
|
none: "0px",
|
|
@@ -12,11 +12,7 @@ const RADIUS = {
|
|
|
12
12
|
xl: "1rem"
|
|
13
13
|
};
|
|
14
14
|
const ACCENT = JUN_ACCENTS;
|
|
15
|
-
const NEUTRAL =
|
|
16
|
-
slate: ["#f8fafc", "#f1f5f9", "#e2e8f0", "#cbd5e1", "#94a3b8", "#64748b", "#475569", "#334155", "#1e293b", "#0f172a", "#020617"],
|
|
17
|
-
zinc: ["#fafafa", "#f4f4f5", "#e4e4e7", "#d4d4d8", "#a1a1aa", "#71717a", "#52525b", "#3f3f46", "#27272a", "#18181b", "#09090b"],
|
|
18
|
-
stone: ["#fafaf9", "#f5f5f4", "#e7e5e4", "#d6d3d1", "#a8a29e", "#78716c", "#57534e", "#44403c", "#292524", "#1c1917", "#0c0a09"]
|
|
19
|
-
};
|
|
15
|
+
const NEUTRAL = JUN_NEUTRALS;
|
|
20
16
|
const TYPE_SCALE = {
|
|
21
17
|
small: "94%",
|
|
22
18
|
normal: "",
|
|
@@ -27,7 +23,7 @@ const DENSITY = {
|
|
|
27
23
|
normal: "",
|
|
28
24
|
airy: "1.18"
|
|
29
25
|
};
|
|
30
|
-
const NEUTRAL_STEPS =
|
|
26
|
+
const NEUTRAL_STEPS = JUN_NEUTRAL_STEPS;
|
|
31
27
|
const BLOBS = {
|
|
32
28
|
off: "0",
|
|
33
29
|
quiet: "0.5",
|
package/dist/runtime/error.vue
CHANGED
|
@@ -17,7 +17,7 @@ useSeoMeta({
|
|
|
17
17
|
|
|
18
18
|
<template>
|
|
19
19
|
<UApp>
|
|
20
|
-
<div class="
|
|
20
|
+
<div class="jun-app-floor relative">
|
|
21
21
|
<!-- The plain theme base. The backdrop is a layout concern and the
|
|
22
22
|
layout is exactly what may not have mounted. -->
|
|
23
23
|
<div
|
|
@@ -33,7 +33,7 @@ useSeoMeta({
|
|
|
33
33
|
|
|
34
34
|
<div
|
|
35
35
|
v-else
|
|
36
|
-
class="flex min-h-[
|
|
36
|
+
class="flex min-h-[70dvh] items-center justify-center px-4"
|
|
37
37
|
>
|
|
38
38
|
<div class="w-full max-w-md text-center">
|
|
39
39
|
<p
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
useJunCampfireSettings,
|
|
8
8
|
useJunEffectiveConfig,
|
|
9
9
|
useJunIntro,
|
|
10
|
+
useJunMobile,
|
|
10
11
|
useJunOptions,
|
|
11
12
|
useJunPresenceBroadcast,
|
|
12
13
|
useJunRouteGeoHeal,
|
|
@@ -42,6 +43,7 @@ useJunSiteConfigMigration();
|
|
|
42
43
|
useJunSlugAliasTracker();
|
|
43
44
|
useJunRouteGeoHeal();
|
|
44
45
|
useJunThemeApply();
|
|
46
|
+
useJunMobile();
|
|
45
47
|
if (import.meta.client && contextMenu.suppressNative) {
|
|
46
48
|
useEventListener(
|
|
47
49
|
document,
|
|
@@ -57,7 +59,7 @@ if (import.meta.client && contextMenu.suppressNative) {
|
|
|
57
59
|
</script>
|
|
58
60
|
|
|
59
61
|
<template>
|
|
60
|
-
<div class="
|
|
62
|
+
<div class="jun-app-floor relative">
|
|
61
63
|
<!-- Bypass the navbar. THE FIRST FOCUSABLE THING ON THE PAGE, and that is
|
|
62
64
|
the whole feature: put it inside `<JunShell>` and the navbar renders
|
|
63
65
|
first, so the link is stop twenty-six rather than stop one. (It was,
|
|
@@ -141,7 +141,7 @@ const cachedHtml = computed(() => hidden.value ? "" : resolved.value?.html ?? ""
|
|
|
141
141
|
and it is what a crawler gets on a document the tree has not reached. -->
|
|
142
142
|
<div
|
|
143
143
|
v-else-if="cachedHtml"
|
|
144
|
-
class="
|
|
144
|
+
class="jun-app-floor pt-24"
|
|
145
145
|
>
|
|
146
146
|
<div :class="['mx-auto w-full', flowMaxW]">
|
|
147
147
|
<div
|
|
@@ -69,6 +69,17 @@ export declare class JunJanitorActor {
|
|
|
69
69
|
/** The ONE document currently open. The janitor cannot be in two places. */
|
|
70
70
|
private open;
|
|
71
71
|
private borrowedClient;
|
|
72
|
+
/**
|
|
73
|
+
* The key the janitor signs with, kept so the session can be re-minted.
|
|
74
|
+
* Null when the identity is borrowed — that client belongs to the runner.
|
|
75
|
+
*/
|
|
76
|
+
private keypair;
|
|
77
|
+
/** When the current token stops validating, ms. 0 = unknown. */
|
|
78
|
+
private tokenExpiresAt;
|
|
79
|
+
private sessionTimer;
|
|
80
|
+
/** In-flight renewal, so a burst of callers shares one login. */
|
|
81
|
+
private renewing;
|
|
82
|
+
private lastForcedRenewAt;
|
|
72
83
|
constructor(options: JunActorOptions);
|
|
73
84
|
private log;
|
|
74
85
|
get isConnected(): boolean;
|
|
@@ -82,6 +93,21 @@ export declare class JunJanitorActor {
|
|
|
82
93
|
get httpClient(): unknown;
|
|
83
94
|
/** The root doc-tree, live. Read-only as far as the janitor is concerned. */
|
|
84
95
|
get tree(): Y.Map<unknown> | null;
|
|
96
|
+
/**
|
|
97
|
+
* The janitor's own root document, for the tree writer to mutate.
|
|
98
|
+
*
|
|
99
|
+
* Exposed so a rename or a meta revert can ride the socket that is ALREADY
|
|
100
|
+
* open under the janitor's identity, instead of opening a second one per
|
|
101
|
+
* chore. `createJunTreeWriter` used to build a whole provider, sync the whole
|
|
102
|
+
* root document and tear it down again for every single tree write — one
|
|
103
|
+
* WebSocket and one full root sync to put a five-character label back. On a
|
|
104
|
+
* shift that repeats a failing chore, that is a socket every twenty seconds
|
|
105
|
+
* for the life of the process.
|
|
106
|
+
*
|
|
107
|
+
* `null` while disconnected, which is the writer's cue to fall back to its
|
|
108
|
+
* own short-lived provider.
|
|
109
|
+
*/
|
|
110
|
+
get rootDocument(): Y.Doc | null;
|
|
85
111
|
get openDocId(): string | null;
|
|
86
112
|
/**
|
|
87
113
|
* `loginOrRegisterWithKey`, with the service runner's retry policy around it.
|
|
@@ -97,6 +123,20 @@ export declare class JunJanitorActor {
|
|
|
97
123
|
*/
|
|
98
124
|
private loginRetrying;
|
|
99
125
|
connect(): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Make sure the janitor's token still has time on it, re-minting if not.
|
|
128
|
+
*
|
|
129
|
+
* Called before anything that opens a socket and on its own timer. Cheap
|
|
130
|
+
* when the token is fresh — one subtraction — so callers do not have to
|
|
131
|
+
* reason about when the last renewal was.
|
|
132
|
+
*
|
|
133
|
+
* Returns whether the session is believed good. `false` is not fatal: the
|
|
134
|
+
* caller's own failure (a sync timeout, an echo that never comes) is still
|
|
135
|
+
* the authority, and the next turn tries again.
|
|
136
|
+
*/
|
|
137
|
+
ensureSession(force?: boolean): Promise<boolean>;
|
|
138
|
+
/** Re-arm every socket this actor holds with a freshly minted token. */
|
|
139
|
+
private refreshOpenSockets;
|
|
100
140
|
/**
|
|
101
141
|
* Where the janitor is. `docId` + `page` are the wire contract every presence
|
|
102
142
|
* surface in this module reads (`useJunPresence`, the navbar dots, the
|
|
@@ -3,6 +3,22 @@ import { AbracadabraClient, AbracadabraProvider, deterministicKeypair, loadOrCre
|
|
|
3
3
|
const SYNC_TIMEOUT_MS = 8e3;
|
|
4
4
|
const FLUSH_MS = 400;
|
|
5
5
|
const WRITE_SETTLE_TIMEOUT_MS = 8e3;
|
|
6
|
+
const TOKEN_REFRESH_MARGIN_MS = 20 * 6e4;
|
|
7
|
+
const SESSION_CHECK_MS = 5 * 6e4;
|
|
8
|
+
const FORCED_RENEW_MIN_GAP_MS = 6e4;
|
|
9
|
+
function junTokenExpiry(token) {
|
|
10
|
+
if (!token) return 0;
|
|
11
|
+
const payload = token.split(".")[1];
|
|
12
|
+
if (!payload) return 0;
|
|
13
|
+
try {
|
|
14
|
+
const json = JSON.parse(
|
|
15
|
+
Buffer.from(payload.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf8")
|
|
16
|
+
);
|
|
17
|
+
return typeof json.exp === "number" ? json.exp * 1e3 : 0;
|
|
18
|
+
} catch {
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
6
22
|
export class JunJanitorActor {
|
|
7
23
|
options;
|
|
8
24
|
client = null;
|
|
@@ -12,6 +28,17 @@ export class JunJanitorActor {
|
|
|
12
28
|
/** The ONE document currently open. The janitor cannot be in two places. */
|
|
13
29
|
open = null;
|
|
14
30
|
borrowedClient = false;
|
|
31
|
+
/**
|
|
32
|
+
* The key the janitor signs with, kept so the session can be re-minted.
|
|
33
|
+
* Null when the identity is borrowed — that client belongs to the runner.
|
|
34
|
+
*/
|
|
35
|
+
keypair = null;
|
|
36
|
+
/** When the current token stops validating, ms. 0 = unknown. */
|
|
37
|
+
tokenExpiresAt = 0;
|
|
38
|
+
sessionTimer = null;
|
|
39
|
+
/** In-flight renewal, so a burst of callers shares one login. */
|
|
40
|
+
renewing = null;
|
|
41
|
+
lastForcedRenewAt = 0;
|
|
15
42
|
constructor(options) {
|
|
16
43
|
this.options = options;
|
|
17
44
|
}
|
|
@@ -37,6 +64,23 @@ export class JunJanitorActor {
|
|
|
37
64
|
get tree() {
|
|
38
65
|
return this.rootDoc?.getMap("doc-tree") ?? null;
|
|
39
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* The janitor's own root document, for the tree writer to mutate.
|
|
69
|
+
*
|
|
70
|
+
* Exposed so a rename or a meta revert can ride the socket that is ALREADY
|
|
71
|
+
* open under the janitor's identity, instead of opening a second one per
|
|
72
|
+
* chore. `createJunTreeWriter` used to build a whole provider, sync the whole
|
|
73
|
+
* root document and tear it down again for every single tree write — one
|
|
74
|
+
* WebSocket and one full root sync to put a five-character label back. On a
|
|
75
|
+
* shift that repeats a failing chore, that is a socket every twenty seconds
|
|
76
|
+
* for the life of the process.
|
|
77
|
+
*
|
|
78
|
+
* `null` while disconnected, which is the writer's cue to fall back to its
|
|
79
|
+
* own short-lived provider.
|
|
80
|
+
*/
|
|
81
|
+
get rootDocument() {
|
|
82
|
+
return this.rootProvider ? this.rootDoc : null;
|
|
83
|
+
}
|
|
40
84
|
get openDocId() {
|
|
41
85
|
return this.open?.docId ?? null;
|
|
42
86
|
}
|
|
@@ -89,7 +133,11 @@ export class JunJanitorActor {
|
|
|
89
133
|
this.publicKey = keypair.publicKeyB64;
|
|
90
134
|
await this.loginRetrying(client, keypair);
|
|
91
135
|
this.client = client;
|
|
92
|
-
this.
|
|
136
|
+
this.keypair = keypair;
|
|
137
|
+
this.tokenExpiresAt = junTokenExpiry(client.token);
|
|
138
|
+
this.log(
|
|
139
|
+
`authenticated as "${this.options.name}" (${keypair.publicKeyB64})` + (this.tokenExpiresAt ? ` \u2014 session good for ${Math.round((this.tokenExpiresAt - Date.now()) / 6e4)}m` : "")
|
|
140
|
+
);
|
|
93
141
|
this.log(
|
|
94
142
|
`if writes do not land, grant this key service scope:
|
|
95
143
|
[[users.system_users]] public_key = "${keypair.publicKeyB64}"
|
|
@@ -114,6 +162,67 @@ export class JunJanitorActor {
|
|
|
114
162
|
isAgent: false
|
|
115
163
|
});
|
|
116
164
|
this.log(`connected to ${this.options.rootDocId}`);
|
|
165
|
+
this.sessionTimer = setInterval(() => {
|
|
166
|
+
void this.ensureSession().catch(() => false);
|
|
167
|
+
}, SESSION_CHECK_MS);
|
|
168
|
+
this.sessionTimer.unref?.();
|
|
169
|
+
}
|
|
170
|
+
// ── Staying logged in ──────────────────────────────────────────────────────
|
|
171
|
+
/**
|
|
172
|
+
* Make sure the janitor's token still has time on it, re-minting if not.
|
|
173
|
+
*
|
|
174
|
+
* Called before anything that opens a socket and on its own timer. Cheap
|
|
175
|
+
* when the token is fresh — one subtraction — so callers do not have to
|
|
176
|
+
* reason about when the last renewal was.
|
|
177
|
+
*
|
|
178
|
+
* Returns whether the session is believed good. `false` is not fatal: the
|
|
179
|
+
* caller's own failure (a sync timeout, an echo that never comes) is still
|
|
180
|
+
* the authority, and the next turn tries again.
|
|
181
|
+
*/
|
|
182
|
+
async ensureSession(force = false) {
|
|
183
|
+
if (this.borrowedClient || !this.client || !this.keypair) return true;
|
|
184
|
+
if (!force && this.tokenExpiresAt - Date.now() > TOKEN_REFRESH_MARGIN_MS) return true;
|
|
185
|
+
if (force && Date.now() - this.lastForcedRenewAt < FORCED_RENEW_MIN_GAP_MS) return true;
|
|
186
|
+
if (force) this.lastForcedRenewAt = Date.now();
|
|
187
|
+
if (this.renewing) return this.renewing;
|
|
188
|
+
const renew = (async () => {
|
|
189
|
+
const client = this.client;
|
|
190
|
+
const keypair = this.keypair;
|
|
191
|
+
try {
|
|
192
|
+
const shared = client;
|
|
193
|
+
if (typeof shared.ensureFreshToken === "function") {
|
|
194
|
+
const ok = await shared.ensureFreshToken();
|
|
195
|
+
this.tokenExpiresAt = junTokenExpiry(client.token);
|
|
196
|
+
if (!ok) this.log("the SDK could not renew the session \u2014 will try again");
|
|
197
|
+
return ok;
|
|
198
|
+
}
|
|
199
|
+
await this.loginRetrying(client, keypair);
|
|
200
|
+
this.tokenExpiresAt = junTokenExpiry(client.token);
|
|
201
|
+
this.refreshOpenSockets(client.token ?? "");
|
|
202
|
+
this.log(
|
|
203
|
+
"renewed the session" + (this.tokenExpiresAt ? ` \u2014 good for another ${Math.round((this.tokenExpiresAt - Date.now()) / 6e4)}m` : "")
|
|
204
|
+
);
|
|
205
|
+
return true;
|
|
206
|
+
} catch (error) {
|
|
207
|
+
this.log(`could not renew the session: ${error?.message ?? error}`);
|
|
208
|
+
return false;
|
|
209
|
+
} finally {
|
|
210
|
+
this.renewing = null;
|
|
211
|
+
}
|
|
212
|
+
})();
|
|
213
|
+
this.renewing = renew;
|
|
214
|
+
return renew;
|
|
215
|
+
}
|
|
216
|
+
/** Re-arm every socket this actor holds with a freshly minted token. */
|
|
217
|
+
refreshOpenSockets(token) {
|
|
218
|
+
if (!token) return;
|
|
219
|
+
const payload = `auth:refresh ${JSON.stringify({ token })}`;
|
|
220
|
+
for (const provider of [this.rootProvider, this.open?.provider]) {
|
|
221
|
+
try {
|
|
222
|
+
provider?.sendStateless(payload);
|
|
223
|
+
} catch {
|
|
224
|
+
}
|
|
225
|
+
}
|
|
117
226
|
}
|
|
118
227
|
// ── Presence ───────────────────────────────────────────────────────────────
|
|
119
228
|
/**
|
|
@@ -178,6 +287,7 @@ export class JunJanitorActor {
|
|
|
178
287
|
if (this.open?.docId === docId) return this.open;
|
|
179
288
|
await this.leave();
|
|
180
289
|
if (!this.client) return null;
|
|
290
|
+
await this.ensureSession();
|
|
181
291
|
const doc = new Y.Doc({ guid: docId });
|
|
182
292
|
const provider = new AbracadabraProvider({
|
|
183
293
|
name: docId,
|
|
@@ -188,12 +298,13 @@ export class JunJanitorActor {
|
|
|
188
298
|
});
|
|
189
299
|
try {
|
|
190
300
|
await waitForSync(provider, SYNC_TIMEOUT_MS);
|
|
191
|
-
} catch {
|
|
192
|
-
this.log(`could not open ${docId} \u2014
|
|
301
|
+
} catch (error) {
|
|
302
|
+
this.log(`could not open ${docId} \u2014 ${error?.message ?? error}`);
|
|
193
303
|
try {
|
|
194
304
|
provider.destroy();
|
|
195
305
|
} catch {
|
|
196
306
|
}
|
|
307
|
+
await this.ensureSession(true);
|
|
197
308
|
return null;
|
|
198
309
|
}
|
|
199
310
|
provider.awareness?.setLocalStateField("user", {
|
|
@@ -317,6 +428,10 @@ export class JunJanitorActor {
|
|
|
317
428
|
}
|
|
318
429
|
// ── Shutdown ───────────────────────────────────────────────────────────────
|
|
319
430
|
async destroy() {
|
|
431
|
+
if (this.sessionTimer) {
|
|
432
|
+
clearInterval(this.sessionTimer);
|
|
433
|
+
this.sessionTimer = null;
|
|
434
|
+
}
|
|
320
435
|
await this.leave();
|
|
321
436
|
const provider = this.rootProvider;
|
|
322
437
|
this.rootProvider = null;
|