@abraca/junis 2.88.0 → 2.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.d.mts +39 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +57 -0
- package/dist/runtime/components/JunNavMenu.client.vue +24 -1
- package/dist/runtime/components/JunOfflinePanel.client.d.vue.ts +3 -0
- package/dist/runtime/components/JunOfflinePanel.client.vue +293 -0
- package/dist/runtime/components/JunOfflinePanel.client.vue.d.ts +3 -0
- package/dist/runtime/components/renderers/JunConfigRenderer.vue +132 -0
- package/dist/runtime/composables/useJunCommands.d.ts +1 -1
- package/dist/runtime/composables/useJunCommands.js +14 -1
- package/dist/runtime/composables/useJunOffline.d.ts +109 -0
- package/dist/runtime/composables/useJunOffline.js +294 -0
- package/dist/runtime/composables/useJunSettings.d.ts +1 -1
- package/dist/runtime/composables/useJunSettings.js +2 -0
- package/dist/runtime/composables/useJunSiteConfig.d.ts +19 -0
- package/dist/runtime/layouts/jun.vue +12 -2
- package/dist/runtime/server/api/offline.get.d.ts +10 -0
- package/dist/runtime/server/api/offline.get.js +13 -0
- package/dist/runtime/server/plugins/jun-compress.d.ts +2 -0
- package/dist/runtime/server/plugins/jun-compress.js +76 -0
- package/dist/runtime/server/routes/jun-sw.js.get.js +66 -13
- package/dist/runtime/server/routes/sitemap.xml.get.js +5 -18
- package/dist/runtime/server/utils/junPages.d.ts +51 -0
- package/dist/runtime/server/utils/junPages.js +70 -0
- package/dist/runtime/types.d.ts +70 -0
- package/dist/runtime/utils/junOffline.d.ts +138 -0
- package/dist/runtime/utils/junOffline.js +73 -0
- package/dist/runtime/utils/junViewSpecs.d.ts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +10 -8
package/dist/module.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { JunBrand, JunPageTypesOption, JunFeatures, JunContextMenuOptions, JunNavigationOptions, JunCampfireOptions, JunBackdropKind, JunLayoutPolicy, JunSiteConfigDefaults, JunSeedOptions, JunJanitorOptions, JunGuestNames, JunRendererDefaults, JunEmbedOptions, JunMosaicOptions, JunServicesOptions, JunPaletteSet } from '../dist/runtime/types.js';
|
|
3
|
-
export { JunBackdropKind, JunBrand, JunCampfireOptions, JunCampfirePillMode, JunCampfirePlacement, JunCampfireRosterStyle, JunCampfireSize, JunCampfireTab, JunContextMenuOptions, JunEmbedOptions, JunFeatures, JunGuestNames, JunJanitorBaselineMode, JunJanitorIdentity, JunJanitorIdentityMode, JunJanitorMode, JunJanitorOptions, JunJsonLdSpec, JunLayoutPolicy, JunMosaicOptions, JunNavActiveStyle, JunNavItemMode, JunNavPlacement, JunNavShape, JunNavSize, JunNavigationOptions, JunPageTypeKey, JunPageTypeOverride, JunPageTypesOption, JunPalette, JunPaletteSet, JunRendererDefaults, JunRuntimeOptions, JunSeedNode, JunSeedOptions, JunServicesOptions, JunSiteConfigDefaults } from '../dist/runtime/types.js';
|
|
2
|
+
import { JunBrand, JunPageTypesOption, JunFeatures, JunContextMenuOptions, JunNavigationOptions, JunCampfireOptions, JunBackdropKind, JunLayoutPolicy, JunSiteConfigDefaults, JunSeedOptions, JunJanitorOptions, JunGuestNames, JunRendererDefaults, JunEmbedOptions, JunMosaicOptions, JunOfflineOptions, JunPrefetchPolicy, JunServicesOptions, JunPaletteSet } from '../dist/runtime/types.js';
|
|
3
|
+
export { JunBackdropKind, JunBrand, JunCampfireOptions, JunCampfirePillMode, JunCampfirePlacement, JunCampfireRosterStyle, JunCampfireSize, JunCampfireTab, JunContextMenuOptions, JunEmbedOptions, JunFeatures, JunGuestNames, JunJanitorBaselineMode, JunJanitorIdentity, JunJanitorIdentityMode, JunJanitorMode, JunJanitorOptions, JunJsonLdSpec, JunLayoutPolicy, JunMosaicOptions, JunNavActiveStyle, JunNavItemMode, JunNavPlacement, JunNavShape, JunNavSize, JunNavigationOptions, JunOfflineOptions, JunPageTypeKey, JunPageTypeOverride, JunPageTypesOption, JunPalette, JunPaletteSet, JunPrefetchPolicy, JunRendererDefaults, JunRuntimeOptions, JunSeedNode, JunSeedOptions, JunServicesOptions, JunSiteConfigDefaults } from '../dist/runtime/types.js';
|
|
4
4
|
|
|
5
5
|
interface ModuleOptions {
|
|
6
6
|
/** Site identity. The only thing most sites need to set. */
|
|
@@ -129,6 +129,43 @@ interface ModuleOptions {
|
|
|
129
129
|
* embedded mosaic may nest. Content is document meta, not config.
|
|
130
130
|
*/
|
|
131
131
|
mosaic?: JunMosaicOptions;
|
|
132
|
+
/**
|
|
133
|
+
* What an offline copy of this site may contain, and whether one is offered
|
|
134
|
+
* at all. Every key is a ceiling the Site Config can lower; none of them
|
|
135
|
+
* downloads anything. See `JunOfflineOptions`.
|
|
136
|
+
*/
|
|
137
|
+
offline?: JunOfflineOptions;
|
|
138
|
+
/**
|
|
139
|
+
* Compress what the site sends — `/_nuxt/**` at build time, HTML and JSON per
|
|
140
|
+
* request.
|
|
141
|
+
*
|
|
142
|
+
* **On**, and it is the one default here that exists because of a production
|
|
143
|
+
* measurement rather than a preference: jun.is served 8.28 MB over 295
|
|
144
|
+
* requests on a cold visit with not one `content-encoding` header anywhere on
|
|
145
|
+
* the origin. Set `false` only when something in front of the app already
|
|
146
|
+
* compresses — a CDN, or a proxy with the middleware actually enabled.
|
|
147
|
+
*/
|
|
148
|
+
compress?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* When a link fetches the page behind it.
|
|
151
|
+
*
|
|
152
|
+
* `'interaction'` is the default, and it is a correction rather than a
|
|
153
|
+
* preference. Nuxt's own default is `{ visibility: true }` — every lazy route
|
|
154
|
+
* whose link enters the viewport is fetched at idle. On this module's
|
|
155
|
+
* navigation that is most of the site: **jun.is shipped 160 prefetched
|
|
156
|
+
* chunks, 0.79 MB on the wire**, after first paint, to a visitor who may read
|
|
157
|
+
* one page and leave.
|
|
158
|
+
*
|
|
159
|
+
* That is the same silent download the offline round exists to prevent. It
|
|
160
|
+
* would be incoherent to ship three tiers so a reader can choose what to keep
|
|
161
|
+
* and leave three quarters of a megabyte fetching itself underneath them.
|
|
162
|
+
*
|
|
163
|
+
* `'interaction'` fetches when someone reaches for a link — hover, or focus —
|
|
164
|
+
* which on a pointer device lands well before the click. `'visibility'`
|
|
165
|
+
* restores Nuxt's default for a site whose readers move fast and whose
|
|
166
|
+
* bandwidth is not the constraint. `false` fetches nothing ahead of time.
|
|
167
|
+
*/
|
|
168
|
+
prefetch?: JunPrefetchPolicy | false;
|
|
132
169
|
/** Which external-service adapters the `services` page type may call. */
|
|
133
170
|
services?: JunServicesOptions;
|
|
134
171
|
/**
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -798,8 +798,23 @@ const module$1 = defineNuxtModule({
|
|
|
798
798
|
apiBase: "/api/_jun",
|
|
799
799
|
fonts: true,
|
|
800
800
|
autoInstall: true,
|
|
801
|
+
// Nuxt's default is `visibility`, which on this module's navigation fetched
|
|
802
|
+
// 160 chunks — 0.79 MB — after first paint. See the option's own comment.
|
|
803
|
+
prefetch: "interaction",
|
|
801
804
|
embeds: { remoteThumbnails: false },
|
|
802
805
|
mosaic: { maxPanes: 24, maxDepth: 1 },
|
|
806
|
+
// Conservative all the way down. `defaultMode: 'visited'` is the only one
|
|
807
|
+
// of these that is not simply "no": it keeps the pages a reader opened
|
|
808
|
+
// anyway, which costs nothing and is the difference between a tunnel and a
|
|
809
|
+
// dinosaur.
|
|
810
|
+
offline: {
|
|
811
|
+
enabled: true,
|
|
812
|
+
defaultMode: "visited",
|
|
813
|
+
fullSite: true,
|
|
814
|
+
media: false,
|
|
815
|
+
budgetMb: 60,
|
|
816
|
+
docSync: false
|
|
817
|
+
},
|
|
803
818
|
services: { adapters: DEFAULT_SERVICE_ADAPTERS, ttl: 600 },
|
|
804
819
|
renderers: {}
|
|
805
820
|
},
|
|
@@ -967,6 +982,14 @@ Switch them off with \`jun.pageTypes: { ${missing.map((e) => `${e.key}: false`).
|
|
|
967
982
|
maxPanes: options.mosaic?.maxPanes ?? 24,
|
|
968
983
|
maxDepth: options.mosaic?.maxDepth ?? 1
|
|
969
984
|
},
|
|
985
|
+
offline: {
|
|
986
|
+
enabled: options.offline?.enabled !== false,
|
|
987
|
+
defaultMode: options.offline?.defaultMode ?? "visited",
|
|
988
|
+
fullSite: options.offline?.fullSite !== false,
|
|
989
|
+
media: options.offline?.media === true,
|
|
990
|
+
budgetMb: options.offline?.budgetMb ?? 60,
|
|
991
|
+
docSync: options.offline?.docSync === true
|
|
992
|
+
},
|
|
970
993
|
// The site's house style for its renderers. Not merged with anything —
|
|
971
994
|
// there is no module-level default block, because each renderer declares
|
|
972
995
|
// its own defaults beside the layout they drive (`useJunViewOptions`).
|
|
@@ -1017,6 +1040,9 @@ Switch them off with \`jun.pageTypes: { ${missing.map((e) => `${e.key}: false`).
|
|
|
1017
1040
|
);
|
|
1018
1041
|
const abra = siblingOptions(nuxt, "abracadabra");
|
|
1019
1042
|
abra.guestName ??= runtime.guestNames;
|
|
1043
|
+
const abraFeatures = asRecord(abra.features) ?? {};
|
|
1044
|
+
abraFeatures.backgroundSync ??= runtime.offline.docSync;
|
|
1045
|
+
abra.features = abraFeatures;
|
|
1020
1046
|
if (options.fonts !== false) {
|
|
1021
1047
|
const fonts = siblingOptions(nuxt, "fonts");
|
|
1022
1048
|
const families = Array.isArray(fonts.families) ? fonts.families : [];
|
|
@@ -1216,6 +1242,9 @@ Switch them off with \`jun.pageTypes: { ${missing.map((e) => `${e.key}: false`).
|
|
|
1216
1242
|
addServerHandler({ route: "/jun-sw.js", handler: resolver.resolve("./runtime/server/routes/jun-sw.js.get") });
|
|
1217
1243
|
addPlugin(resolver.resolve("./runtime/plugins/jun-sw.client"));
|
|
1218
1244
|
}
|
|
1245
|
+
if (runtime.offline.enabled) {
|
|
1246
|
+
addServerHandler({ route: `${base}/offline`, handler: resolver.resolve("./runtime/server/api/offline.get") });
|
|
1247
|
+
}
|
|
1219
1248
|
}
|
|
1220
1249
|
addServerHandler({ route: `${base}/health`, handler: resolver.resolve("./runtime/server/api/health.get") });
|
|
1221
1250
|
addServerPlugin(resolver.resolve("./runtime/server/plugins/jun-watchdog"));
|
|
@@ -1241,6 +1270,34 @@ Switch them off with \`jun.pageTypes: { ${missing.map((e) => `${e.key}: false`).
|
|
|
1241
1270
|
nuxt.options.nitro.externals = defu(nuxt.options.nitro.externals, {
|
|
1242
1271
|
inline: ["happy-dom"]
|
|
1243
1272
|
});
|
|
1273
|
+
if (options.compress !== false) {
|
|
1274
|
+
nuxt.options.nitro.compressPublicAssets = defu(
|
|
1275
|
+
// `true` is a legal value for this option, and `defu` would treat it as
|
|
1276
|
+
// a scalar and refuse to merge — normalise it first.
|
|
1277
|
+
asRecord(nuxt.options.nitro.compressPublicAssets) ?? (nuxt.options.nitro.compressPublicAssets === true ? {} : void 0),
|
|
1278
|
+
{ gzip: true, brotli: true }
|
|
1279
|
+
);
|
|
1280
|
+
addServerPlugin(resolver.resolve("./runtime/server/plugins/jun-compress"));
|
|
1281
|
+
}
|
|
1282
|
+
if (options.prefetch !== void 0) {
|
|
1283
|
+
const appChose = nuxt.options._layers?.some(
|
|
1284
|
+
(layer) => layer?.config?.experimental?.defaults?.nuxtLink !== void 0
|
|
1285
|
+
);
|
|
1286
|
+
if (!appChose) {
|
|
1287
|
+
const link = options.prefetch === false ? { prefetch: false } : {
|
|
1288
|
+
prefetch: true,
|
|
1289
|
+
// Both keys, explicitly. `prefetchOn` is a partial object and
|
|
1290
|
+
// omitting one leaves whatever was there before.
|
|
1291
|
+
prefetchOn: options.prefetch === "interaction" ? { visibility: false, interaction: true } : { visibility: true, interaction: false }
|
|
1292
|
+
};
|
|
1293
|
+
nuxt.options.experimental ??= {};
|
|
1294
|
+
nuxt.options.experimental.defaults ??= {};
|
|
1295
|
+
nuxt.options.experimental.defaults.nuxtLink = {
|
|
1296
|
+
...nuxt.options.experimental.defaults.nuxtLink,
|
|
1297
|
+
...link
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1244
1301
|
if (options.pwa !== false && hasNuxtModule("@vite-pwa/nuxt")) {
|
|
1245
1302
|
const all = nuxtOptionsRecord(nuxt);
|
|
1246
1303
|
all.pwa = defu(asRecord(all.pwa), {
|
|
@@ -4,8 +4,10 @@ import { useRoute } from "#imports";
|
|
|
4
4
|
import { onKeyStroke } from "@vueuse/core";
|
|
5
5
|
import { useJunNavItems } from "../composables/useJunNavItems";
|
|
6
6
|
import { useJunNavSettings } from "../composables/useJunNavSettings";
|
|
7
|
+
import { useJunOffline } from "../composables/useJunOffline";
|
|
7
8
|
import { useJunOptions } from "../composables/useJunOptions";
|
|
8
9
|
import { useJunSearch } from "../composables/useJunSearch";
|
|
10
|
+
import { useJunEffectiveConfig } from "../composables/useJunSiteConfig";
|
|
9
11
|
import { useJunStudio } from "../composables/useJunStudio";
|
|
10
12
|
const props = defineProps({
|
|
11
13
|
open: { type: Boolean, required: true },
|
|
@@ -14,7 +16,7 @@ const props = defineProps({
|
|
|
14
16
|
});
|
|
15
17
|
const emit = defineEmits(["update:open"]);
|
|
16
18
|
const route = useRoute();
|
|
17
|
-
const { features } = useJunOptions();
|
|
19
|
+
const { features, offline, pwa } = useJunOptions();
|
|
18
20
|
const nav = useJunNavSettings();
|
|
19
21
|
const { openSearch } = useJunSearch();
|
|
20
22
|
const { editing, canEdit, openLogin } = useJunStudio();
|
|
@@ -207,6 +209,9 @@ const isGrid = computed(() => shape.value === "grid");
|
|
|
207
209
|
const showIcon = computed(() => isGrid.value || nav.menuItemMode.value !== "text");
|
|
208
210
|
const showLabel = computed(() => !isGrid.value ? nav.menuItemMode.value !== "icon" : true);
|
|
209
211
|
const hasExtras = computed(() => nav.menuExtras.value);
|
|
212
|
+
const { openOffline } = useJunOffline();
|
|
213
|
+
const effectiveConfig = useJunEffectiveConfig();
|
|
214
|
+
const offlineOffered = computed(() => pwa && offline.enabled && effectiveConfig.value.offlineOffer !== false);
|
|
210
215
|
</script>
|
|
211
216
|
|
|
212
217
|
<template>
|
|
@@ -443,6 +448,24 @@ const hasExtras = computed(() => nav.menuExtras.value);
|
|
|
443
448
|
|
|
444
449
|
<JunThemeToggle />
|
|
445
450
|
|
|
451
|
+
<!-- Offline. This is the surface a phone reaches it from — the
|
|
452
|
+
palette needs a keyboard, and "will this site work on the train"
|
|
453
|
+
is a question asked ON the train. -->
|
|
454
|
+
<button
|
|
455
|
+
v-if="offlineOffered"
|
|
456
|
+
type="button"
|
|
457
|
+
class="flex size-8 items-center justify-center rounded-full text-black/55 transition-colors hover:text-black dark:text-white/55 dark:hover:text-white"
|
|
458
|
+
aria-label="Offline"
|
|
459
|
+
title="Offline"
|
|
460
|
+
@click="close();
|
|
461
|
+
openOffline()"
|
|
462
|
+
>
|
|
463
|
+
<UIcon
|
|
464
|
+
name="i-lucide-cloud-download"
|
|
465
|
+
class="size-4"
|
|
466
|
+
/>
|
|
467
|
+
</button>
|
|
468
|
+
|
|
446
469
|
<button
|
|
447
470
|
v-if="features.studio && !canEdit"
|
|
448
471
|
type="button"
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref, watch } from "vue";
|
|
3
|
+
import { useJunOffline, useJunStudio } from "#imports";
|
|
4
|
+
import { junFormatBytes } from "../utils/junOffline";
|
|
5
|
+
const {
|
|
6
|
+
open,
|
|
7
|
+
mode,
|
|
8
|
+
media,
|
|
9
|
+
policy,
|
|
10
|
+
manifest,
|
|
11
|
+
usage,
|
|
12
|
+
receipt,
|
|
13
|
+
receiptStale,
|
|
14
|
+
saving,
|
|
15
|
+
savedCount,
|
|
16
|
+
savedTotal,
|
|
17
|
+
savedBytes,
|
|
18
|
+
progress,
|
|
19
|
+
lastError,
|
|
20
|
+
syncing,
|
|
21
|
+
syncedDocs,
|
|
22
|
+
syncTotal,
|
|
23
|
+
syncDocuments,
|
|
24
|
+
setMode,
|
|
25
|
+
setMedia,
|
|
26
|
+
loadManifest,
|
|
27
|
+
estimate,
|
|
28
|
+
save,
|
|
29
|
+
purge
|
|
30
|
+
} = useJunOffline();
|
|
31
|
+
const { canEdit } = useJunStudio();
|
|
32
|
+
const estimated = ref(null);
|
|
33
|
+
watch(open, async (isOpen) => {
|
|
34
|
+
if (!isOpen) return;
|
|
35
|
+
await loadManifest();
|
|
36
|
+
estimated.value = await estimate();
|
|
37
|
+
});
|
|
38
|
+
const TIERS = [
|
|
39
|
+
{
|
|
40
|
+
value: "off",
|
|
41
|
+
label: "Nothing",
|
|
42
|
+
hint: "Keep no part of this site on this device.",
|
|
43
|
+
icon: "i-lucide-cloud-off"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
value: "visited",
|
|
47
|
+
label: "Pages you open",
|
|
48
|
+
hint: "The default. Nothing is downloaded on its own \u2014 pages you read are kept, so they are still there when the signal drops.",
|
|
49
|
+
icon: "i-lucide-history"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
value: "site",
|
|
53
|
+
label: "The whole site",
|
|
54
|
+
hint: "Downloaded once, now, so every page works offline.",
|
|
55
|
+
icon: "i-lucide-hard-drive-download"
|
|
56
|
+
}
|
|
57
|
+
];
|
|
58
|
+
async function pick(next) {
|
|
59
|
+
if (saving.value) return;
|
|
60
|
+
if (next === "site") {
|
|
61
|
+
await save();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
await setMode(next);
|
|
65
|
+
}
|
|
66
|
+
const tiers = computed(() => TIERS.filter((t) => t.value !== "site" || policy.value.fullSite));
|
|
67
|
+
const savedAgo = computed(() => {
|
|
68
|
+
const at = receipt.value?.at;
|
|
69
|
+
if (!at) return "";
|
|
70
|
+
const mins = Math.round((Date.now() - at) / 6e4);
|
|
71
|
+
if (mins < 1) return "just now";
|
|
72
|
+
if (mins < 60) return `${mins} minute${mins === 1 ? "" : "s"} ago`;
|
|
73
|
+
const hours = Math.round(mins / 60);
|
|
74
|
+
if (hours < 24) return `${hours} hour${hours === 1 ? "" : "s"} ago`;
|
|
75
|
+
const days = Math.round(hours / 24);
|
|
76
|
+
return `${days} day${days === 1 ? "" : "s"} ago`;
|
|
77
|
+
});
|
|
78
|
+
async function clear() {
|
|
79
|
+
await purge();
|
|
80
|
+
if (mode.value === "site") await setMode("visited");
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<template>
|
|
85
|
+
<UModal
|
|
86
|
+
v-model:open="open"
|
|
87
|
+
:dismissible="true"
|
|
88
|
+
:ui="{
|
|
89
|
+
content: 'jun-blur-gradient max-w-lg rounded-xl divide-y-0 border-1 border-white/10 shadow-none ring-1 ring-black/5 dark:border-black/5 dark:ring-white/10',
|
|
90
|
+
overlay: 'bg-black/[0.06] dark:bg-black/35'
|
|
91
|
+
}"
|
|
92
|
+
>
|
|
93
|
+
<template #content>
|
|
94
|
+
<div class="flex min-h-0 flex-col overflow-hidden rounded-xl">
|
|
95
|
+
<div class="flex h-12 shrink-0 items-center gap-2 border-b border-black/5 px-3 dark:border-white/10">
|
|
96
|
+
<UIcon
|
|
97
|
+
name="i-lucide-cloud-download"
|
|
98
|
+
class="ml-1 size-4 shrink-0 opacity-60"
|
|
99
|
+
/>
|
|
100
|
+
<span class="min-w-0 flex-1 truncate text-sm tracking-widest">Offline</span>
|
|
101
|
+
<button
|
|
102
|
+
type="button"
|
|
103
|
+
class="hidden shrink-0 opacity-60 transition-opacity hover:opacity-100 sm:inline-flex"
|
|
104
|
+
aria-label="Close"
|
|
105
|
+
@click="open = false"
|
|
106
|
+
>
|
|
107
|
+
<UKbd value="esc" />
|
|
108
|
+
</button>
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<div class="min-h-0 flex-1 space-y-5 overflow-y-auto p-4 sm:p-5">
|
|
112
|
+
<p class="text-xs text-muted">
|
|
113
|
+
This site can keep itself on your device, so it still works with no
|
|
114
|
+
connection. Nothing is downloaded unless you ask for it here.
|
|
115
|
+
</p>
|
|
116
|
+
|
|
117
|
+
<!-- The tiers. Buttons rather than a radio group: picking "the whole
|
|
118
|
+
site" STARTS A DOWNLOAD, and a radio implies a setting that takes
|
|
119
|
+
effect quietly. -->
|
|
120
|
+
<div
|
|
121
|
+
class="space-y-2"
|
|
122
|
+
role="group"
|
|
123
|
+
aria-label="How much of this site to keep"
|
|
124
|
+
>
|
|
125
|
+
<button
|
|
126
|
+
v-for="tier in tiers"
|
|
127
|
+
:key="tier.value"
|
|
128
|
+
type="button"
|
|
129
|
+
:disabled="saving"
|
|
130
|
+
:aria-pressed="mode === tier.value"
|
|
131
|
+
class="flex w-full cursor-pointer items-start gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors disabled:cursor-wait disabled:opacity-60"
|
|
132
|
+
:class="mode === tier.value ? 'border-black/15 bg-black/[0.04] dark:border-white/20 dark:bg-white/[0.06]' : 'border-black/5 hover:bg-black/[0.02] dark:border-white/10 dark:hover:bg-white/[0.03]'"
|
|
133
|
+
@click="pick(tier.value)"
|
|
134
|
+
>
|
|
135
|
+
<UIcon
|
|
136
|
+
:name="tier.icon"
|
|
137
|
+
class="mt-0.5 size-4 shrink-0 opacity-70"
|
|
138
|
+
/>
|
|
139
|
+
<span class="min-w-0 flex-1">
|
|
140
|
+
<span class="flex items-center gap-2">
|
|
141
|
+
<span class="text-sm font-medium">{{ tier.label }}</span>
|
|
142
|
+
<span
|
|
143
|
+
v-if="tier.value === 'site' && estimated"
|
|
144
|
+
class="rounded-full bg-black/5 px-1.5 py-0.5 text-[0.6875rem] opacity-70 dark:bg-white/10"
|
|
145
|
+
>about {{ junFormatBytes(estimated) }}</span>
|
|
146
|
+
</span>
|
|
147
|
+
<span class="mt-0.5 block text-[11px] text-muted">{{ tier.hint }}</span>
|
|
148
|
+
<span
|
|
149
|
+
v-if="tier.value === 'site' && manifest"
|
|
150
|
+
class="mt-0.5 block text-[11px] text-muted"
|
|
151
|
+
>{{ manifest.count }} pages across {{ manifest.sections.length }} sections</span>
|
|
152
|
+
</span>
|
|
153
|
+
<UIcon
|
|
154
|
+
v-if="mode === tier.value"
|
|
155
|
+
name="i-lucide-check"
|
|
156
|
+
class="mt-0.5 size-4 shrink-0"
|
|
157
|
+
/>
|
|
158
|
+
</button>
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
<!-- Saving. A live byte count, because the estimate above is one. -->
|
|
162
|
+
<div
|
|
163
|
+
v-if="saving"
|
|
164
|
+
class="space-y-1.5"
|
|
165
|
+
aria-live="polite"
|
|
166
|
+
>
|
|
167
|
+
<div class="h-1 overflow-hidden rounded-full bg-black/10 dark:bg-white/10">
|
|
168
|
+
<div
|
|
169
|
+
class="h-full rounded-full bg-current transition-[width] duration-200"
|
|
170
|
+
:style="{ width: `${Math.round(progress * 100)}%` }"
|
|
171
|
+
/>
|
|
172
|
+
</div>
|
|
173
|
+
<p class="text-[11px] text-muted">
|
|
174
|
+
Saving {{ savedCount }} of {{ savedTotal }} pages · {{ junFormatBytes(savedBytes) }}
|
|
175
|
+
</p>
|
|
176
|
+
</div>
|
|
177
|
+
|
|
178
|
+
<!-- Images. Off unless the owner allows it AND the reader asks: this
|
|
179
|
+
is the half whose size is a property of the content. -->
|
|
180
|
+
<JunConfigRow
|
|
181
|
+
v-if="policy.media"
|
|
182
|
+
label="Include images"
|
|
183
|
+
hint="Photographs are the heavy part of a copy. Without them, a saved page shows its words and not its pictures."
|
|
184
|
+
>
|
|
185
|
+
<USwitch
|
|
186
|
+
:model-value="media"
|
|
187
|
+
:disabled="saving"
|
|
188
|
+
@update:model-value="setMedia($event)"
|
|
189
|
+
/>
|
|
190
|
+
</JunConfigRow>
|
|
191
|
+
|
|
192
|
+
<!-- What is actually stored. From the browser, not from our own sums. -->
|
|
193
|
+
<div class="space-y-1.5 border-t border-black/5 pt-4 dark:border-white/10">
|
|
194
|
+
<div
|
|
195
|
+
v-if="receipt && !receiptStale"
|
|
196
|
+
class="flex items-baseline justify-between gap-3 text-xs"
|
|
197
|
+
>
|
|
198
|
+
<span class="text-muted">Saved copy</span>
|
|
199
|
+
<span>{{ receipt.pages }} pages, {{ savedAgo }}</span>
|
|
200
|
+
</div>
|
|
201
|
+
<p
|
|
202
|
+
v-else-if="receiptStale"
|
|
203
|
+
class="text-[11px] text-muted"
|
|
204
|
+
>
|
|
205
|
+
A new version of this site was published, so the saved copy was
|
|
206
|
+
replaced. Save it again to have it offline.
|
|
207
|
+
</p>
|
|
208
|
+
<div
|
|
209
|
+
v-if="usage"
|
|
210
|
+
class="flex items-baseline justify-between gap-3 text-xs"
|
|
211
|
+
>
|
|
212
|
+
<span class="text-muted">This site is using</span>
|
|
213
|
+
<span>{{ junFormatBytes(usage.used) }}</span>
|
|
214
|
+
</div>
|
|
215
|
+
<p
|
|
216
|
+
v-if="receipt?.stopped === 'budget'"
|
|
217
|
+
class="text-[11px] text-muted"
|
|
218
|
+
>
|
|
219
|
+
The copy reached this site's size limit and stopped there. The
|
|
220
|
+
pages it did save still work offline.
|
|
221
|
+
</p>
|
|
222
|
+
<p
|
|
223
|
+
v-if="lastError"
|
|
224
|
+
class="text-[11px] text-muted"
|
|
225
|
+
>
|
|
226
|
+
{{ lastError }}
|
|
227
|
+
</p>
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
231
|
+
<UButton
|
|
232
|
+
v-if="policy.fullSite"
|
|
233
|
+
size="xs"
|
|
234
|
+
color="neutral"
|
|
235
|
+
variant="soft"
|
|
236
|
+
icon="i-lucide-refresh-cw"
|
|
237
|
+
:loading="saving"
|
|
238
|
+
:disabled="saving"
|
|
239
|
+
@click="save()"
|
|
240
|
+
>
|
|
241
|
+
{{ receipt && !receiptStale ? "Update the copy" : "Save the whole site" }}
|
|
242
|
+
</UButton>
|
|
243
|
+
<UButton
|
|
244
|
+
size="xs"
|
|
245
|
+
color="neutral"
|
|
246
|
+
variant="ghost"
|
|
247
|
+
icon="i-lucide-trash-2"
|
|
248
|
+
:disabled="saving"
|
|
249
|
+
@click="clear()"
|
|
250
|
+
>
|
|
251
|
+
Clear what is stored
|
|
252
|
+
</UButton>
|
|
253
|
+
</div>
|
|
254
|
+
|
|
255
|
+
<!-- The CRDT half. Owner-only, and a BUTTON rather than a setting:
|
|
256
|
+
this is every document into IndexedDB, which is precisely the
|
|
257
|
+
download nobody asked for when it happens on its own. -->
|
|
258
|
+
<div
|
|
259
|
+
v-if="canEdit && policy.docSync"
|
|
260
|
+
class="space-y-2 border-t border-black/5 pt-4 dark:border-white/10"
|
|
261
|
+
>
|
|
262
|
+
<p class="text-xs font-medium">
|
|
263
|
+
Keep the documents too
|
|
264
|
+
</p>
|
|
265
|
+
<p class="text-[11px] text-muted">
|
|
266
|
+
The pages above are what a reader sees. This copies the documents
|
|
267
|
+
themselves onto this device, so you can edit with no connection —
|
|
268
|
+
a bigger download, and one nothing starts on its own.
|
|
269
|
+
</p>
|
|
270
|
+
<div class="flex items-center gap-2">
|
|
271
|
+
<UButton
|
|
272
|
+
size="xs"
|
|
273
|
+
color="neutral"
|
|
274
|
+
variant="soft"
|
|
275
|
+
icon="i-lucide-refresh-ccw-dot"
|
|
276
|
+
:loading="syncing"
|
|
277
|
+
:disabled="syncing"
|
|
278
|
+
@click="syncDocuments()"
|
|
279
|
+
>
|
|
280
|
+
Sync documents
|
|
281
|
+
</UButton>
|
|
282
|
+
<span
|
|
283
|
+
v-if="syncTotal"
|
|
284
|
+
class="text-[11px] text-muted"
|
|
285
|
+
aria-live="polite"
|
|
286
|
+
>{{ syncedDocs }} of {{ syncTotal }} documents</span>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
</div>
|
|
290
|
+
</div>
|
|
291
|
+
</template>
|
|
292
|
+
</UModal>
|
|
293
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -479,6 +479,34 @@ const feedsEnabled = computed({
|
|
|
479
479
|
get: () => config.value.feedsEnabled !== false,
|
|
480
480
|
set: (v) => set({ feedsEnabled: v ? void 0 : false })
|
|
481
481
|
});
|
|
482
|
+
const offlineOffer = computed({
|
|
483
|
+
get: () => config.value.offlineOffer !== false && opts.offline.enabled,
|
|
484
|
+
set: (v) => set({ offlineOffer: v ? void 0 : false })
|
|
485
|
+
});
|
|
486
|
+
const offlineFullSite = computed({
|
|
487
|
+
get: () => config.value.offlineFullSite !== false && opts.offline.fullSite,
|
|
488
|
+
set: (v) => set({ offlineFullSite: v ? void 0 : false })
|
|
489
|
+
});
|
|
490
|
+
const offlineMedia = computed({
|
|
491
|
+
get: () => config.value.offlineMedia ?? opts.offline.media,
|
|
492
|
+
set: (v) => set({ offlineMedia: v === opts.offline.media ? void 0 : v })
|
|
493
|
+
});
|
|
494
|
+
const offlineDocSync = computed({
|
|
495
|
+
get: () => config.value.offlineDocSync ?? opts.offline.docSync,
|
|
496
|
+
set: (v) => set({ offlineDocSync: v === opts.offline.docSync ? void 0 : v })
|
|
497
|
+
});
|
|
498
|
+
const offlineBudget = computed({
|
|
499
|
+
get: () => config.value.offlineBudgetMb ?? opts.offline.budgetMb,
|
|
500
|
+
set: (v) => set({ offlineBudgetMb: v === opts.offline.budgetMb ? void 0 : v })
|
|
501
|
+
});
|
|
502
|
+
function setBudget(e) {
|
|
503
|
+
const raw = Number(e.target.value);
|
|
504
|
+
if (!Number.isFinite(raw) || raw <= 0) {
|
|
505
|
+
set({ offlineBudgetMb: void 0 });
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
offlineBudget.value = Math.round(raw);
|
|
509
|
+
}
|
|
482
510
|
const fire = opts.campfire;
|
|
483
511
|
function fireChoice(key, allowed, fallback) {
|
|
484
512
|
return navChoice(key, allowed, fallback);
|
|
@@ -776,6 +804,18 @@ function shows(id) {
|
|
|
776
804
|
@change="setText('seoOgImage', $event)"
|
|
777
805
|
/>
|
|
778
806
|
</UFormField>
|
|
807
|
+
<UFormField
|
|
808
|
+
label="Language"
|
|
809
|
+
help="A BCP-47 tag — en, de, pt-BR. What a screen reader announces in."
|
|
810
|
+
>
|
|
811
|
+
<UInput
|
|
812
|
+
:model-value="config.seoLang ?? ''"
|
|
813
|
+
:disabled="!editing"
|
|
814
|
+
placeholder="en"
|
|
815
|
+
class="w-full"
|
|
816
|
+
@change="setText('seoLang', $event)"
|
|
817
|
+
/>
|
|
818
|
+
</UFormField>
|
|
779
819
|
<UFormField
|
|
780
820
|
label="Canonical site address"
|
|
781
821
|
help="Used for canonical links and og:url. Empty uses the address the visitor arrived on."
|
|
@@ -2590,6 +2630,98 @@ function shows(id) {
|
|
|
2590
2630
|
</div>
|
|
2591
2631
|
</section>
|
|
2592
2632
|
|
|
2633
|
+
<!-- Offline -->
|
|
2634
|
+
<section
|
|
2635
|
+
v-if="shows('offline')"
|
|
2636
|
+
class="space-y-5"
|
|
2637
|
+
:class="bare ? '' : 'jun-card rounded-2xl p-6'"
|
|
2638
|
+
>
|
|
2639
|
+
<header class="flex items-start gap-3">
|
|
2640
|
+
<span class="flex size-9 flex-none items-center justify-center rounded-lg bg-black/5 dark:bg-white/10">
|
|
2641
|
+
<UIcon
|
|
2642
|
+
name="i-lucide-cloud-download"
|
|
2643
|
+
class="size-4.5"
|
|
2644
|
+
/>
|
|
2645
|
+
</span>
|
|
2646
|
+
<div>
|
|
2647
|
+
<h2 class="text-sm font-semibold text-highlighted">
|
|
2648
|
+
Offline
|
|
2649
|
+
</h2>
|
|
2650
|
+
<p class="text-xs text-muted">
|
|
2651
|
+
What a reader may keep on their own device. Nothing here downloads
|
|
2652
|
+
anything — every visitor still has to ask.
|
|
2653
|
+
</p>
|
|
2654
|
+
</div>
|
|
2655
|
+
</header>
|
|
2656
|
+
|
|
2657
|
+
<div class="space-y-4">
|
|
2658
|
+
<JunConfigRow
|
|
2659
|
+
label="Offer an offline copy"
|
|
2660
|
+
hint="Adds an Offline panel to the command palette and the navigation menu. Without it, a reader still keeps the pages they open — they just cannot choose."
|
|
2661
|
+
>
|
|
2662
|
+
<USwitch
|
|
2663
|
+
v-model="offlineOffer"
|
|
2664
|
+
:disabled="!editing"
|
|
2665
|
+
color="neutral"
|
|
2666
|
+
/>
|
|
2667
|
+
</JunConfigRow>
|
|
2668
|
+
|
|
2669
|
+
<JunConfigRow
|
|
2670
|
+
label="Allow the whole site"
|
|
2671
|
+
:muted="!offlineOffer"
|
|
2672
|
+
hint="One press downloads every page. Turn it off for a site whose readers should take one page at a time."
|
|
2673
|
+
>
|
|
2674
|
+
<USwitch
|
|
2675
|
+
v-model="offlineFullSite"
|
|
2676
|
+
:disabled="!editing || !offlineOffer"
|
|
2677
|
+
color="neutral"
|
|
2678
|
+
/>
|
|
2679
|
+
</JunConfigRow>
|
|
2680
|
+
|
|
2681
|
+
<JunConfigRow
|
|
2682
|
+
label="Include images"
|
|
2683
|
+
:muted="!offlineOffer"
|
|
2684
|
+
hint="The heavy half — the only part of a copy whose size comes from your content rather than your page count. Off means saved pages show their words and not their pictures."
|
|
2685
|
+
>
|
|
2686
|
+
<USwitch
|
|
2687
|
+
v-model="offlineMedia"
|
|
2688
|
+
:disabled="!editing || !offlineOffer"
|
|
2689
|
+
color="neutral"
|
|
2690
|
+
/>
|
|
2691
|
+
</JunConfigRow>
|
|
2692
|
+
|
|
2693
|
+
<JunConfigRow
|
|
2694
|
+
label="Size limit"
|
|
2695
|
+
:muted="!offlineOffer"
|
|
2696
|
+
>
|
|
2697
|
+
<template #hint>
|
|
2698
|
+
Megabytes. A copy stops here and says so rather than filling
|
|
2699
|
+
somebody's phone.
|
|
2700
|
+
</template>
|
|
2701
|
+
<UInput
|
|
2702
|
+
:model-value="offlineBudget"
|
|
2703
|
+
type="number"
|
|
2704
|
+
min="1"
|
|
2705
|
+
step="10"
|
|
2706
|
+
class="w-24"
|
|
2707
|
+
:disabled="!editing || !offlineOffer"
|
|
2708
|
+
@change="setBudget($event)"
|
|
2709
|
+
/>
|
|
2710
|
+
</JunConfigRow>
|
|
2711
|
+
|
|
2712
|
+
<JunConfigRow
|
|
2713
|
+
label="Keep documents in sync"
|
|
2714
|
+
hint="For you, not for readers: every document onto this device so the site is editable with no connection. A much larger copy, and one nothing starts on its own."
|
|
2715
|
+
>
|
|
2716
|
+
<USwitch
|
|
2717
|
+
v-model="offlineDocSync"
|
|
2718
|
+
:disabled="!editing"
|
|
2719
|
+
color="neutral"
|
|
2720
|
+
/>
|
|
2721
|
+
</JunConfigRow>
|
|
2722
|
+
</div>
|
|
2723
|
+
</section>
|
|
2724
|
+
|
|
2593
2725
|
<!-- Visitors -->
|
|
2594
2726
|
<section
|
|
2595
2727
|
v-if="shows('visitors')"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The groups, in the order they appear. */
|
|
2
|
-
export type JunCommandGroup = 'Go' | 'Appearance' | 'Studio' | 'Player' | 'Share';
|
|
2
|
+
export type JunCommandGroup = 'Go' | 'Appearance' | 'Studio' | 'Player' | 'This device' | 'Share';
|
|
3
3
|
export interface JunCommand {
|
|
4
4
|
/** Stable across renders — it is the list key and the selection identity. */
|
|
5
5
|
key: string;
|