domma-cms 1.61.1 → 1.61.3
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/CHANGELOG.md +16 -0
- package/docs/cache.md +6 -0
- package/package.json +1 -1
- package/plugins/_lib/admin/mail/body-menu.js +1 -1
- package/plugins/_lib/admin/mail/cms-host.js +1 -1
- package/plugins/_lib/admin/mail/compose-window.js +1 -1
- package/plugins/_lib/admin/mail/contacts.js +1 -1
- package/plugins/_lib/admin/mail/diagnostics-section.js +1 -1
- package/plugins/_lib/admin/mail/drag-drop.js +1 -1
- package/plugins/_lib/admin/mail/folder-tree.js +1 -1
- package/plugins/_lib/admin/mail/font-controls.js +1 -1
- package/plugins/_lib/admin/mail/fonts.js +1 -1
- package/plugins/_lib/admin/mail/host-context.js +1 -1
- package/plugins/_lib/admin/mail/identity.js +1 -1
- package/plugins/_lib/admin/mail/image-senders-section.js +1 -1
- package/plugins/_lib/admin/mail/keyboard.js +1 -1
- package/plugins/_lib/admin/mail/mail.html +1 -1
- package/plugins/_lib/admin/mail/message-actions.js +1 -1
- package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
- package/plugins/_lib/admin/mail/panes.js +1 -1
- package/plugins/_lib/admin/mail/reader-kit.js +1 -1
- package/plugins/_lib/admin/mail/reader-runtime.js +27 -1
- package/plugins/_lib/admin/mail/reader-view.js +1 -1
- package/plugins/_lib/admin/mail/resizable.js +1 -1
- package/plugins/_lib/admin/mail/restore-spam.js +1 -1
- package/plugins/_lib/admin/mail/rules.js +1 -1
- package/plugins/_lib/admin/mail/scheduling.js +1 -1
- package/plugins/_lib/admin/mail/section-kit.js +1 -1
- package/plugins/_lib/admin/mail/security-note.js +1 -1
- package/plugins/_lib/admin/mail/settings-section.js +1 -1
- package/plugins/_lib/admin/mail/templates.js +1 -1
- package/plugins/_lib/admin/mail/threads.js +1 -1
- package/plugins/_lib/admin/mail/vacation.js +1 -1
- package/plugins/_lib/admin/mail/when-closed.js +1 -1
- package/plugins/_lib/admin/ui/dates.js +1 -1
- package/plugins/_lib/admin/ui/resizable.js +1 -1
- package/plugins/_lib/domma-mail.lock.json +80 -80
- package/plugins/_lib/mail/accountFileStore.js +1 -1
- package/plugins/_lib/mail/accountRepository.js +1 -1
- package/plugins/_lib/mail/accountRoutes.js +1 -1
- package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
- package/plugins/_lib/mail/bodyTokens.js +1 -1
- package/plugins/_lib/mail/compose.js +1 -1
- package/plugins/_lib/mail/defaults.js +1 -1
- package/plugins/_lib/mail/envelope.js +1 -1
- package/plugins/_lib/mail/folderActions.js +1 -1
- package/plugins/_lib/mail/folderRuntime.js +1 -1
- package/plugins/_lib/mail/folders.js +1 -1
- package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
- package/plugins/_lib/mail/mbox.js +1 -1
- package/plugins/_lib/mail/message-action.js +1 -1
- package/plugins/_lib/mail/messageSecurity.js +1 -1
- package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
- package/plugins/_lib/mail/networkAddresses.js +1 -1
- package/plugins/_lib/mail/networkPolicy.js +1 -1
- package/plugins/_lib/mail/oauthAccounts.js +1 -1
- package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
- package/plugins/_lib/mail/oauthRuntime.js +1 -1
- package/plugins/_lib/mail/pollSchedule.js +1 -1
- package/plugins/_lib/mail/poller.js +1 -1
- package/plugins/_lib/mail/pollerRuntime.js +1 -1
- package/plugins/_lib/mail/priority.js +1 -1
- package/plugins/_lib/mail/publicMailbox.js +1 -1
- package/plugins/_lib/mail/readRuntime.js +1 -1
- package/plugins/_lib/mail/render.js +1 -1
- package/plugins/_lib/mail/ruleRunner.js +1 -1
- package/plugins/_lib/mail/schedulerRuntime.js +1 -1
- package/plugins/_lib/mail/secretProvider.js +1 -1
- package/plugins/_lib/mail/secretbox.js +1 -1
- package/plugins/_lib/mail/senderAuth.js +1 -1
- package/plugins/_lib/mail/sieve.js +1 -1
- package/plugins/_lib/mail/smtpService.js +1 -1
- package/plugins/_lib/mail/snoozeRuntime.js +1 -1
- package/plugins/_lib/mail/store.js +1 -1
- package/plugins/_lib/mail/subscriptions.js +1 -1
- package/plugins/_lib/mail/syncPlan.js +1 -1
- package/plugins/_lib/mail/syncRuntime.js +1 -1
- package/plugins/_lib/mail/syncSelection.js +1 -1
- package/plugins/_lib/mail/unreadBadge.js +1 -1
- package/plugins/_lib/mail/unsubscribe.js +1 -1
- package/plugins/_lib/mail/vacationRuntime.js +1 -1
- package/plugins/_lib/mail/write.js +1 -1
- package/plugins/docs/CHANGELOG.md +5 -0
- package/plugins/docs/CLAUDE.md +30 -0
- package/plugins/docs/admin/views/docs.js +2 -1
- package/plugins/docs/admin/views/editor.js +5 -3
- package/plugins/docs/docs/guide.md +11 -0
- package/plugins/docs/lib/store.js +46 -2
- package/plugins/docs/plugin.js +70 -28
- package/plugins/docs/plugin.json +14 -1
- package/plugins/docs/tests/restricted.test.js +240 -0
- package/plugins/free-tier.lock.json +15 -13
- package/plugins/mail-reader/CLAUDE.md +6 -0
- package/plugins/mail-reader/plugin.js +9 -0
- package/plugins/mail-reader/plugin.json +1 -1
- package/server/services/publicAssets.js +55 -6
- package/server/templates/page.html +4 -7
|
@@ -56,6 +56,13 @@ import {createHash} from 'node:crypto';
|
|
|
56
56
|
import {encode, pickEncoding} from './htmlResponse.js';
|
|
57
57
|
|
|
58
58
|
export const IMMUTABLE = 'public, max-age=31536000, immutable';
|
|
59
|
+
/**
|
|
60
|
+
* For a file the page cannot fingerprint - an image, or a stylesheet or font a script
|
|
61
|
+
* asks for by its plain URL: the browser shows the copy it has straight away and checks
|
|
62
|
+
* for a newer one in the background (RFC 5861). The page never waits on the check, and
|
|
63
|
+
* a changed file shows from the next view on.
|
|
64
|
+
*/
|
|
65
|
+
export const REVALIDATE_IN_BACKGROUND = 'public, max-age=0, stale-while-revalidate=604800';
|
|
59
66
|
export const VERSION_PARAM = '_pv';
|
|
60
67
|
/** The URL the site's custom CSS is served at once it is too big to inline. */
|
|
61
68
|
export const CUSTOM_CSS_URL = '/content/custom.css';
|
|
@@ -63,6 +70,28 @@ export const CUSTOM_CSS_URL = '/content/custom.css';
|
|
|
63
70
|
export const CUSTOM_CSS_INLINE_MAX = 4096;
|
|
64
71
|
|
|
65
72
|
const TEXT_TYPES = new Set(['.css', '.js', '.mjs']);
|
|
73
|
+
/** Served REVALIDATE_IN_BACKGROUND when not fingerprinted. Not scripts: a script one view out of date can break a page. */
|
|
74
|
+
const BACKGROUND_TYPES = new Set([
|
|
75
|
+
'.css',
|
|
76
|
+
'.png', '.jpg', '.jpeg', '.gif', '.webp', '.avif', '.svg', '.ico', '.bmp',
|
|
77
|
+
'.woff', '.woff2', '.ttf', '.otf', '.eot'
|
|
78
|
+
]);
|
|
79
|
+
/** Where those are served from: the static mounts in server.js. */
|
|
80
|
+
const BACKGROUND_PREFIX = /^\/(?:media|public|dist\/domma|plugins\/[^/?#]+\/public)\//;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Does a request for this URL get REVALIDATE_IN_BACKGROUND? Its path is under one of the
|
|
84
|
+
* static mounts and names an image, a font or a stylesheet.
|
|
85
|
+
*
|
|
86
|
+
* @param {string} rawUrl - the request URL as sent
|
|
87
|
+
* @returns {boolean}
|
|
88
|
+
*/
|
|
89
|
+
export function revalidatesInBackground(rawUrl) {
|
|
90
|
+
if (typeof rawUrl !== 'string') return false;
|
|
91
|
+
const pathname = rawUrl.split(/[?#]/)[0];
|
|
92
|
+
if (!BACKGROUND_PREFIX.test(pathname) || pathname.includes('..')) return false;
|
|
93
|
+
return BACKGROUND_TYPES.has(path.extname(pathname).toLowerCase());
|
|
94
|
+
}
|
|
66
95
|
|
|
67
96
|
/** @type {{root: string, dommaDist: string, pluginsDir: string, customCss: string}|null} */
|
|
68
97
|
let _roots = null;
|
|
@@ -261,10 +290,27 @@ async function importMapFor(html) {
|
|
|
261
290
|
else if (found.has(url)) rewrite.add(url);
|
|
262
291
|
}
|
|
263
292
|
if (!found.size) return none;
|
|
293
|
+
// One file, one module. Two importers that name it differently - `characters.mjs` and
|
|
294
|
+
// `characters.mjs?v=...` - would get two instances, each running its top level. So
|
|
295
|
+
// every URL for a file maps to the same target: the URL the page's own tag loads it by,
|
|
296
|
+
// when it has one, otherwise the first of its URLs, fingerprinted.
|
|
297
|
+
const fileOf = (url) => { try { return decodeURIComponent(url.split('?')[0]); } catch { return url; } };
|
|
298
|
+
const fingerprinted = (url, version) => `${url}${url.includes('?') ? '&' : '?'}${VERSION_PARAM}=${version}`;
|
|
299
|
+
/** @type {Map<string, string>} file path -> the one URL every import of it resolves to */
|
|
300
|
+
const target = new Map();
|
|
301
|
+
for (const url of [...entries].sort()) {
|
|
302
|
+
const file = fileOf(url);
|
|
303
|
+
if (target.has(file)) continue;
|
|
304
|
+
if (imported.has(url) && !found.has(url)) target.set(file, url);
|
|
305
|
+
else if (rewrite.has(url)) target.set(file, fingerprinted(url, found.get(url)));
|
|
306
|
+
}
|
|
264
307
|
const imports = {};
|
|
265
308
|
for (const url of [...found.keys()].sort()) {
|
|
266
|
-
|
|
309
|
+
const file = fileOf(url);
|
|
310
|
+
if (!target.has(file)) target.set(file, fingerprinted(url, found.get(url)));
|
|
311
|
+
if (target.get(file) !== url) imports[url] = target.get(file);
|
|
267
312
|
}
|
|
313
|
+
if (!Object.keys(imports).length) return none;
|
|
268
314
|
return {tag: `<script type="importmap">${JSON.stringify({imports}).replace(/</g, '\\u003c')}</script>`, rewrite};
|
|
269
315
|
}
|
|
270
316
|
|
|
@@ -440,20 +486,23 @@ export function registerPublicAssets(app, roots) {
|
|
|
440
486
|
}
|
|
441
487
|
|
|
442
488
|
app.decorateRequest('dmImmutableAsset', false);
|
|
489
|
+
app.decorateRequest('dmBackgroundAsset', false);
|
|
443
490
|
// Added by serve(), after the plugins, as adminAssets' is: a plugin's onRequest hook that
|
|
444
491
|
// answers a request itself (site-manager proxying another site's host) must run first, or
|
|
445
492
|
// this would judge that site's fingerprint against THIS install's files.
|
|
446
493
|
const serve = () => {
|
|
494
|
+
// Decided here, not in onSend: a request another hook has already answered (the
|
|
495
|
+
// Manager proxying a site's host) never gets this far, and keeps that site's own header.
|
|
447
496
|
app.addHook('onRequest', async (request) => {
|
|
448
497
|
if (request.method !== 'GET' && request.method !== 'HEAD') return;
|
|
449
|
-
if (!request.raw.url.includes(`${VERSION_PARAM}=`)) return;
|
|
450
498
|
if (request.raw.url.startsWith(CUSTOM_CSS_URL)) return; // its route decides for itself
|
|
451
|
-
if (await matches(request.raw.url)) request.dmImmutableAsset = true;
|
|
499
|
+
if (request.raw.url.includes(`${VERSION_PARAM}=`) && await matches(request.raw.url)) request.dmImmutableAsset = true;
|
|
500
|
+
else if (revalidatesInBackground(request.raw.url)) request.dmBackgroundAsset = true;
|
|
452
501
|
});
|
|
453
502
|
app.addHook('onSend', async (request, reply, payload) => {
|
|
454
|
-
if (
|
|
455
|
-
|
|
456
|
-
|
|
503
|
+
if (reply.statusCode !== 200 && reply.statusCode !== 304) return payload;
|
|
504
|
+
if (request.dmImmutableAsset) reply.header('cache-control', IMMUTABLE);
|
|
505
|
+
else if (request.dmBackgroundAsset) reply.header('cache-control', REVALIDATE_IN_BACKGROUND);
|
|
457
506
|
return payload;
|
|
458
507
|
});
|
|
459
508
|
};
|
|
@@ -195,13 +195,10 @@
|
|
|
195
195
|
<!-- [image zoom] pictures' full-size view - only on a page that has one -->
|
|
196
196
|
{{imageZoomModule}}
|
|
197
197
|
|
|
198
|
-
<!-- Floating menu panels
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
<!-- Core Forms renderer -->
|
|
204
|
-
<script src="/public/js/forms.js?v=20261109-form-embed" type="module"></script>
|
|
198
|
+
<!-- Floating menu panels (menu-float.js) and the core Forms renderer (forms.js)
|
|
199
|
+
come in with site.js, which imports both: every page, whatever its navbar.
|
|
200
|
+
A tag of their own here kept them out of the import map, so a returning
|
|
201
|
+
visitor's browser asked about both on every page. -->
|
|
205
202
|
|
|
206
203
|
<!-- Core effects runtime -->
|
|
207
204
|
<script src="/public/js/effects.js?v=20261111-inline-settings" defer></script>
|